Advertisement
Guest User

Untitled

a guest
Mar 18th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // jquery Cookie by carhartl (Klaus Hartl)
  2.  
  3. (function($) {
  4.     $.cookie = function(key, value, options) {
  5.  
  6.         // key and at least value given, set cookie...
  7.         if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
  8.             options = $.extend({}, options);
  9.  
  10.             if (value === null || value === undefined) {
  11.                 options.expires = -1;
  12.             }
  13.  
  14.             if (typeof options.expires === 'number') {
  15.                 var days = options.expires, t = options.expires = new Date();
  16.                 t.setDate(t.getDate() + days);
  17.             }
  18.  
  19.             value = String(value);
  20.  
  21.             return (document.cookie = [
  22.                 encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
  23.                 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  24.                 options.path    ? '; path=' + options.path : '',
  25.                 options.domain  ? '; domain=' + options.domain : '',
  26.                 options.secure  ? '; secure' : ''
  27.             ].join(''));
  28.         }
  29.  
  30.         // key and possibly options given, get cookie...
  31.         options = value || {};
  32.         var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
  33.  
  34.         var pairs = document.cookie.split('; ');
  35.         for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
  36.             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
  37.         }
  38.         return null;
  39.     };
  40. })(jQuery);
  41.  
  42. // jquery FontZoom by mxtracks.de
  43.  
  44. jQuery(document).ready(function(){
  45. var $j = jQuery.noConflict();
  46.  
  47.     var contentarea     = $j('body'); // der Bereich, welcher den kompletten Content umschließt. Hier die ID eines DIV
  48.     var default_size    = 90; // Die Standardgroeße in %
  49.     var max_size        = 120; // Die Maximale Zoomgroeße in %
  50.     var min_size        = 60; // Die Minimale Zoomgroeße in %
  51.     var currentSize     = default_size; // für die initialisierung des Scripts
  52.     var unit            = "%"; // Die Prozentangabe
  53.  
  54.     if ($j.cookie("fontSize")) { // Gibt es schon ein Cookie?
  55.         newsize = $j.cookie("fontSize"); // dann schreib die groeße die im Cookie steht in eine Variable
  56.         currentSize = parseInt(newsize);  // setze die aktuelle groeße auf die groeße im Cookie
  57.         contentarea.css('font-size', currentSize + unit); // uebergebe die groeße ans CSS
  58.         }
  59.  
  60.     $j("a.fontChange").mousedown(function() { // Es wird auf einen der 3 Buttons geklickt
  61.         if (this.id == 'fontLarge'){ // Button zum vergroeßern
  62.             currentSize = currentSize + 15;
  63.             if (currentSize > max_size){
  64.                 currentSize = max_size;
  65.                 }
  66.             num = currentSize;
  67.         } else if (this.id == 'fontSmall') { // Button zum verkleinern
  68.             currentSize = currentSize - 15;
  69.             if (currentSize < min_size){
  70.                 currentSize = min_size;
  71.                 }
  72.             num = currentSize;
  73.         } else if (this.id == 'fontDefault') { // Button fuer die Standardgroeße
  74.             currentSize = default_size;
  75.             num = default_size;
  76.         }
  77.         num = parseInt(num);
  78.         $j.cookie("fontSize", num, { path: '/', expires: 90 }); // Cookie mit der gewaehlten groeße setzen
  79.         contentarea.animate({'font-size' : num + unit},500);
  80.            return false;
  81.     });
  82. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement