Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // jquery Cookie by carhartl (Klaus Hartl)
- (function($) {
- $.cookie = function(key, value, options) {
- // key and at least value given, set cookie...
- if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
- options = $.extend({}, options);
- if (value === null || value === undefined) {
- options.expires = -1;
- }
- if (typeof options.expires === 'number') {
- var days = options.expires, t = options.expires = new Date();
- t.setDate(t.getDate() + days);
- }
- value = String(value);
- return (document.cookie = [
- encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
- options.path ? '; path=' + options.path : '',
- options.domain ? '; domain=' + options.domain : '',
- options.secure ? '; secure' : ''
- ].join(''));
- }
- // key and possibly options given, get cookie...
- options = value || {};
- var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
- var pairs = document.cookie.split('; ');
- for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
- if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
- }
- return null;
- };
- })(jQuery);
- // jquery FontZoom by mxtracks.de
- jQuery(document).ready(function(){
- var $j = jQuery.noConflict();
- var contentarea = $j('body'); // der Bereich, welcher den kompletten Content umschließt. Hier die ID eines DIV
- var default_size = 90; // Die Standardgroeße in %
- var max_size = 120; // Die Maximale Zoomgroeße in %
- var min_size = 60; // Die Minimale Zoomgroeße in %
- var currentSize = default_size; // für die initialisierung des Scripts
- var unit = "%"; // Die Prozentangabe
- if ($j.cookie("fontSize")) { // Gibt es schon ein Cookie?
- newsize = $j.cookie("fontSize"); // dann schreib die groeße die im Cookie steht in eine Variable
- currentSize = parseInt(newsize); // setze die aktuelle groeße auf die groeße im Cookie
- contentarea.css('font-size', currentSize + unit); // uebergebe die groeße ans CSS
- }
- $j("a.fontChange").mousedown(function() { // Es wird auf einen der 3 Buttons geklickt
- if (this.id == 'fontLarge'){ // Button zum vergroeßern
- currentSize = currentSize + 15;
- if (currentSize > max_size){
- currentSize = max_size;
- }
- num = currentSize;
- } else if (this.id == 'fontSmall') { // Button zum verkleinern
- currentSize = currentSize - 15;
- if (currentSize < min_size){
- currentSize = min_size;
- }
- num = currentSize;
- } else if (this.id == 'fontDefault') { // Button fuer die Standardgroeße
- currentSize = default_size;
- num = default_size;
- }
- num = parseInt(num);
- $j.cookie("fontSize", num, { path: '/', expires: 90 }); // Cookie mit der gewaehlten groeße setzen
- contentarea.animate({'font-size' : num + unit},500);
- return false;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement