[ Index ]

PHP Cross Reference of MyBB 1.8.27

title

Body

[close]

/jscripts/ -> jquery.plugins.js (source)

   1  /**
   2   * jGrowl 1.4.5
   3   *
   4   * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
   5   * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
   6   *
   7   * Written by Stan Lemon <stosh1985@gmail.com>
   8   * Last updated: 2015.02.01
   9   */
  10  (function($) {
  11      /** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/
  12      $.jGrowl = function( m , o ) {
  13          // To maintain compatibility with older version that only supported one instance we'll create the base container.
  14          if ( $('#jGrowl').length === 0 )
  15              $('<div id="jGrowl"></div>').addClass( (o && o.position) ? o.position : $.jGrowl.defaults.position ).appendTo( (o && o.appendTo) ? o.appendTo : $.jGrowl.defaults.appendTo );
  16  
  17          // Create a notification on the container.
  18          $('#jGrowl').jGrowl(m,o);
  19      };
  20  
  21  
  22      /** Raise jGrowl Notification on a jGrowl Container **/
  23      $.fn.jGrowl = function( m , o ) {
  24          // Short hand for passing in just an object to this method
  25          if ( o === undefined && $.isPlainObject(m) ) {
  26              o = m;
  27              m = o.message;
  28          }
  29  
  30          if ( $.isFunction(this.each) ) {
  31              var args = arguments;
  32  
  33              return this.each(function() {
  34                  /** Create a jGrowl Instance on the Container if it does not exist **/
  35                  if ( $(this).data('jGrowl.instance') === undefined ) {
  36                      $(this).data('jGrowl.instance', $.extend( new $.fn.jGrowl(), { notifications: [], element: null, interval: null } ));
  37                      $(this).data('jGrowl.instance').startup( this );
  38                  }
  39  
  40                  /** Optionally call jGrowl instance methods, or just raise a normal notification **/
  41                  if ( $.isFunction($(this).data('jGrowl.instance')[m]) ) {
  42                      $(this).data('jGrowl.instance')[m].apply( $(this).data('jGrowl.instance') , $.makeArray(args).slice(1) );
  43                  } else {
  44                      $(this).data('jGrowl.instance').create( m , o );
  45                  }
  46              });
  47          }
  48      };
  49  
  50      $.extend( $.fn.jGrowl.prototype , {
  51  
  52          /** Default JGrowl Settings **/
  53          defaults: {
  54              pool:                0,
  55              header:                '',
  56              group:                '',
  57              sticky:                false,
  58              position:            'top-right',
  59              appendTo:            'body',
  60              glue:                'after',
  61              theme:                'default',
  62              themeState:            'highlight',
  63              corners:            '10px',
  64              check:                250,
  65              life:                3000,
  66              closeDuration:        'normal',
  67              openDuration:        'normal',
  68              easing:                'swing',
  69              closer:                true,
  70              closeTemplate:        '&times;',
  71              closerTemplate:        '<div>[ close all ]</div>',
  72              log:                function() {},
  73              beforeOpen:            function() {},
  74              afterOpen:            function() {},
  75              open:                function() {},
  76              beforeClose:        function() {},
  77              close:                function() {},
  78              click:                function() {},
  79              animateOpen:        {
  80                  opacity:        'show'
  81              },
  82              animateClose:        {
  83                  opacity:        'hide'
  84              }
  85          },
  86  
  87          notifications: [],
  88  
  89          /** jGrowl Container Node **/
  90          element:                null,
  91  
  92          /** Interval Function **/
  93          interval:                null,
  94  
  95          /** Create a Notification **/
  96          create: function( message , options ) {
  97              var o = $.extend({}, this.defaults, options);
  98  
  99              /* To keep backward compatibility with 1.24 and earlier, honor 'speed' if the user has set it */
 100              if (typeof o.speed !== 'undefined') {
 101                  o.openDuration = o.speed;
 102                  o.closeDuration = o.speed;
 103              }
 104  
 105              this.notifications.push({ message: message , options: o });
 106  
 107              o.log.apply( this.element , [this.element,message,o] );
 108          },
 109  
 110          render: function( n ) {
 111              var self = this;
 112              var message = n.message;
 113              var o = n.options;
 114  
 115              // Support for jQuery theme-states, if this is not used it displays a widget header
 116              o.themeState = (o.themeState === '') ? '' : 'ui-state-' + o.themeState;
 117  
 118              var notification = $('<div/>')
 119                  .addClass('jGrowl-notification alert ' + o.themeState + ' ui-corner-all' + ((o.group !== undefined && o.group !== '') ? ' ' + o.group : ''))
 120                  .append($('<button/>').addClass('jGrowl-close').html(o.closeTemplate))
 121                  .append($('<div/>').addClass('jGrowl-header').html(o.header))
 122                  .append($('<div/>').addClass('jGrowl-message').html(message))
 123                  .data("jGrowl", o).addClass(o.theme).children('.jGrowl-close').bind("click.jGrowl", function() {
 124                      $(this).parent().trigger('jGrowl.beforeClose');
 125                      return false;
 126                  })
 127                  .parent();
 128  
 129  
 130              /** Notification Actions **/
 131              $(notification).bind("mouseover.jGrowl", function() {
 132                  $('.jGrowl-notification', self.element).data("jGrowl.pause", true);
 133              }).bind("mouseout.jGrowl", function() {
 134                  $('.jGrowl-notification', self.element).data("jGrowl.pause", false);
 135              }).bind('jGrowl.beforeOpen', function() {
 136                  if ( o.beforeOpen.apply( notification , [notification,message,o,self.element] ) !== false ) {
 137                      $(this).trigger('jGrowl.open');
 138                  }
 139              }).bind('jGrowl.open', function() {
 140                  if ( o.open.apply( notification , [notification,message,o,self.element] ) !== false ) {
 141                      if ( o.glue == 'after' ) {
 142                          $('.jGrowl-notification:last', self.element).after(notification);
 143                      } else {
 144                          $('.jGrowl-notification:first', self.element).before(notification);
 145                      }
 146  
 147                      $(this).animate(o.animateOpen, o.openDuration, o.easing, function() {
 148                          // Fixes some anti-aliasing issues with IE filters.
 149                          if ($.support.opacity === false)
 150                              this.style.removeAttribute('filter');
 151  
 152                          if ( $(this).data("jGrowl") !== null && typeof $(this).data("jGrowl") !== 'undefined') // Happens when a notification is closing before it's open.
 153                              $(this).data("jGrowl").created = new Date();
 154  
 155                          $(this).trigger('jGrowl.afterOpen');
 156                      });
 157                  }
 158              }).bind('jGrowl.afterOpen', function() {
 159                  o.afterOpen.apply( notification , [notification,message,o,self.element] );
 160              }).bind('click', function() {
 161                  o.click.apply( notification, [notification,message,o,self.element] );
 162              }).bind('jGrowl.beforeClose', function() {
 163                  if ( o.beforeClose.apply( notification , [notification,message,o,self.element] ) !== false )
 164                      $(this).trigger('jGrowl.close');
 165              }).bind('jGrowl.close', function() {
 166                  // Pause the notification, lest during the course of animation another close event gets called.
 167                  $(this).data('jGrowl.pause', true);
 168                  $(this).animate(o.animateClose, o.closeDuration, o.easing, function() {
 169                      if ( $.isFunction(o.close) ) {
 170                          if ( o.close.apply( notification , [notification,message,o,self.element] ) !== false )
 171                              $(this).remove();
 172                      } else {
 173                          $(this).remove();
 174                      }
 175                  });
 176              }).trigger('jGrowl.beforeOpen');
 177  
 178              /** Optional Corners Plugin **/
 179              if ( o.corners !== '' && $.fn.corner !== undefined ) $(notification).corner( o.corners );
 180  
 181              /** Add a Global Closer if more than one notification exists **/
 182              if ($('.jGrowl-notification:parent', self.element).length > 1 &&
 183                  $('.jGrowl-closer', self.element).length === 0 && this.defaults.closer !== false ) {
 184                  $(this.defaults.closerTemplate).addClass('jGrowl-closer ' + this.defaults.themeState + ' ui-corner-all').addClass(this.defaults.theme)
 185                      .appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing)
 186                      .bind("click.jGrowl", function() {
 187                          $(this).siblings().trigger("jGrowl.beforeClose");
 188  
 189                          if ( $.isFunction( self.defaults.closer ) ) {
 190                              self.defaults.closer.apply( $(this).parent()[0] , [$(this).parent()[0]] );
 191                          }
 192                      });
 193              }
 194          },
 195  
 196          /** Update the jGrowl Container, removing old jGrowl notifications **/
 197          update: function() {
 198              $(this.element).find('.jGrowl-notification:parent').each( function() {
 199                  if ($(this).data("jGrowl") !== undefined && $(this).data("jGrowl").created !== undefined &&
 200                      ($(this).data("jGrowl").created.getTime() + parseInt($(this).data("jGrowl").life, 10))  < (new Date()).getTime() &&
 201                      $(this).data("jGrowl").sticky !== true &&
 202                      ($(this).data("jGrowl.pause") === undefined || $(this).data("jGrowl.pause") !== true) ) {
 203  
 204                      // Pause the notification, lest during the course of animation another close event gets called.
 205                      $(this).trigger('jGrowl.beforeClose');
 206                  }
 207              });
 208  
 209              if (this.notifications.length > 0 &&
 210                  (this.defaults.pool === 0 || $(this.element).find('.jGrowl-notification:parent').length < this.defaults.pool) )
 211                  this.render( this.notifications.shift() );
 212  
 213              if ($(this.element).find('.jGrowl-notification:parent').length < 2 ) {
 214                  $(this.element).find('.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function() {
 215                      $(this).remove();
 216                  });
 217              }
 218          },
 219  
 220          /** Setup the jGrowl Notification Container **/
 221          startup: function(e) {
 222              this.element = $(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>');
 223              this.interval = setInterval( function() {
 224                  // some error in chage ^^
 225                  var instance = $(e).data('jGrowl.instance');
 226                  if (undefined !== instance) {
 227                      instance.update();
 228                  }
 229              }, parseInt(this.defaults.check, 10));
 230          },
 231  
 232          /** Shutdown jGrowl, removing it and clearing the interval **/
 233          shutdown: function() {
 234              $(this.element).removeClass('jGrowl')
 235                  .find('.jGrowl-notification').trigger('jGrowl.close')
 236                  .parent().empty()
 237              ;
 238  
 239              clearInterval(this.interval);
 240          },
 241  
 242          close: function() {
 243              $(this.element).find('.jGrowl-notification').each(function(){
 244                  $(this).trigger('jGrowl.beforeClose');
 245              });
 246          }
 247      });
 248  
 249      /** Reference the Defaults Object for compatibility with older versions of jGrowl **/
 250      $.jGrowl.defaults = $.fn.jGrowl.prototype.defaults;
 251  
 252  })(jQuery);
 253  
 254  /*
 255      A simple jQuery modal (http://github.com/kylefox/jquery-modal)
 256      Version 0.8.0
 257  */
 258  
 259  (function (factory) {
 260    // Making your jQuery plugin work better with npm tools
 261    // http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm
 262    if(typeof module === "object" && typeof module.exports === "object") {
 263      factory(require("jquery"), window, document);
 264    }
 265    else {
 266      factory(jQuery, window, document);
 267    }
 268  }(function($, window, document, undefined) {
 269  
 270    var modals = [],
 271        getCurrent = function() {
 272          return modals.length ? modals[modals.length - 1] : null;
 273        },
 274        selectCurrent = function() {
 275          var i,
 276              selected = false;
 277          for (i=modals.length-1; i>=0; i--) {
 278            if (modals[i].$blocker) {
 279              modals[i].$blocker.toggleClass('current',!selected).toggleClass('behind',selected);
 280              selected = true;
 281            }
 282          }
 283        };
 284  
 285    $.modal = function(el, options) {
 286      var remove, target;
 287      this.$body = $('body');
 288      this.options = $.extend({}, $.modal.defaults, options);
 289      this.options.doFade = !isNaN(parseInt(this.options.fadeDuration, 10));
 290      this.$blocker = null;
 291      if (this.options.closeExisting)
 292        while ($.modal.isActive())
 293          $.modal.close(); // Close any open modals.
 294      modals.push(this);
 295      if (el.is('a')) {
 296        target = el.attr('href');
 297        //Select element by id from href
 298        if (/^#/.test(target)) {
 299          this.$elm = $(target);
 300          if (this.$elm.length !== 1) return null;
 301          this.$body.append(this.$elm);
 302          this.open();
 303        //AJAX
 304        } else {
 305          this.$elm = $('<div>');
 306          this.$body.append(this.$elm);
 307          remove = function(event, modal) { modal.elm.remove(); };
 308          this.showSpinner();
 309          el.trigger($.modal.AJAX_SEND);
 310          $.get(target).done(function(html) {
 311            if (!$.modal.isActive()) return;
 312            el.trigger($.modal.AJAX_SUCCESS);
 313            var current = getCurrent();
 314            current.$elm.empty().append(html).on($.modal.CLOSE, remove);
 315            current.hideSpinner();
 316            current.open();
 317            el.trigger($.modal.AJAX_COMPLETE);
 318          }).fail(function() {
 319            el.trigger($.modal.AJAX_FAIL);
 320            var current = getCurrent();
 321            current.hideSpinner();
 322            modals.pop(); // remove expected modal from the list
 323            el.trigger($.modal.AJAX_COMPLETE);
 324          });
 325        }
 326      } else {
 327        this.$elm = el;
 328        this.$body.append(this.$elm);
 329        this.open();
 330      }
 331    };
 332  
 333    $.modal.prototype = {
 334      constructor: $.modal,
 335  
 336      open: function() {
 337        var m = this;
 338        this.block();
 339        if(this.options.doFade) {
 340          setTimeout(function() {
 341            m.show();
 342          }, this.options.fadeDuration * this.options.fadeDelay);
 343        } else {
 344          this.show();
 345        }
 346        $(document).off('keydown.modal').on('keydown.modal', function(event) {
 347          var current = getCurrent();
 348          if (event.which == 27 && current.options.escapeClose) current.close();
 349        });
 350        if (this.options.clickClose)
 351          this.$blocker.on('click',function(e) {
 352            if (e.target==this)
 353              $.modal.close();
 354          });
 355      },
 356  
 357      close: function() {
 358        modals.pop();
 359        this.unblock();
 360        this.hide();
 361        if (!$.modal.isActive())
 362          $(document).off('keydown.modal');
 363      },
 364  
 365      block: function() {
 366        this.$elm.trigger($.modal.BEFORE_BLOCK, [this._ctx()]);
 367        this.$body.css('overflow','hidden');
 368        this.$blocker = $('<div class="jquery-modal blocker current"></div>').appendTo(this.$body);
 369        selectCurrent();
 370        if(this.options.doFade) {
 371          this.$blocker.css('opacity',0).animate({opacity: 1}, this.options.fadeDuration);
 372        }
 373        this.$elm.trigger($.modal.BLOCK, [this._ctx()]);
 374      },
 375  
 376      unblock: function(now) {
 377        if (!now && this.options.doFade)
 378          this.$blocker.fadeOut(this.options.fadeDuration, this.unblock.bind(this,true));
 379        else {
 380          this.$blocker.children().appendTo(this.$body);
 381          this.$blocker.remove();
 382          this.$blocker = null;
 383          selectCurrent();
 384          if (!$.modal.isActive())
 385            this.$body.css('overflow','');
 386        }
 387      },
 388  
 389      show: function() {
 390        this.$elm.trigger($.modal.BEFORE_OPEN, [this._ctx()]);
 391        if (this.options.showClose) {
 392          this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>');
 393          this.$elm.append(this.closeButton);
 394        }
 395        this.$elm.addClass(this.options.modalClass).appendTo(this.$blocker);
 396        if(this.options.doFade) {
 397          this.$elm.css('opacity',0).show().animate({opacity: 1}, this.options.fadeDuration);
 398        } else {
 399          this.$elm.show();
 400        }
 401        this.$elm.trigger($.modal.OPEN, [this._ctx()]);
 402      },
 403  
 404      hide: function() {
 405        this.$elm.trigger($.modal.BEFORE_CLOSE, [this._ctx()]);
 406        if (this.closeButton) this.closeButton.remove();
 407        var _this = this;
 408        if(this.options.doFade) {
 409          this.$elm.fadeOut(this.options.fadeDuration, function () {
 410            _this.$elm.trigger($.modal.AFTER_CLOSE, [_this._ctx()]);
 411          });
 412        } else {
 413          this.$elm.hide(0, function () {
 414            _this.$elm.trigger($.modal.AFTER_CLOSE, [_this._ctx()]);
 415          });
 416        }
 417        this.$elm.trigger($.modal.CLOSE, [this._ctx()]);
 418      },
 419  
 420      showSpinner: function() {
 421        if (!this.options.showSpinner) return;
 422        this.spinner = this.spinner || $('<div class="' + this.options.modalClass + '-spinner"></div>')
 423          .append(this.options.spinnerHtml);
 424        this.$body.append(this.spinner);
 425        this.spinner.show();
 426      },
 427  
 428      hideSpinner: function() {
 429        if (this.spinner) this.spinner.remove();
 430      },
 431  
 432      //Return context for custom events
 433      _ctx: function() {
 434        return { elm: this.$elm, $blocker: this.$blocker, options: this.options };
 435      }
 436    };
 437  
 438    $.modal.close = function(event) {
 439      if (!$.modal.isActive()) return;
 440      if (event) event.preventDefault();
 441      var current = getCurrent();
 442      current.close();
 443      return current.$elm;
 444    };
 445  
 446    // Returns if there currently is an active modal
 447    $.modal.isActive = function () {
 448      return modals.length > 0;
 449    }
 450  
 451    $.modal.getCurrent = getCurrent;
 452  
 453    $.modal.defaults = {
 454      closeExisting: true,
 455      escapeClose: true,
 456      clickClose: true,
 457      closeText: 'Close',
 458      closeClass: '',
 459      modalClass: "modal",
 460      spinnerHtml: null,
 461      showSpinner: true,
 462      showClose: true,
 463      fadeDuration: null,   // Number of milliseconds the fade animation takes.
 464      fadeDelay: 1.0        // Point during the overlay's fade-in that the modal begins to fade in (.5 = 50%, 1.5 = 150%, etc.)
 465    };
 466  
 467    // Event constants
 468    $.modal.BEFORE_BLOCK = 'modal:before-block';
 469    $.modal.BLOCK = 'modal:block';
 470    $.modal.BEFORE_OPEN = 'modal:before-open';
 471    $.modal.OPEN = 'modal:open';
 472    $.modal.BEFORE_CLOSE = 'modal:before-close';
 473    $.modal.CLOSE = 'modal:close';
 474    $.modal.AFTER_CLOSE = 'modal:after-close';
 475    $.modal.AJAX_SEND = 'modal:ajax:send';
 476    $.modal.AJAX_SUCCESS = 'modal:ajax:success';
 477    $.modal.AJAX_FAIL = 'modal:ajax:fail';
 478    $.modal.AJAX_COMPLETE = 'modal:ajax:complete';
 479  
 480    $.fn.modal = function(options){
 481      if (this.length === 1) {
 482        new $.modal(this, options);
 483      }
 484      return this;
 485    };
 486  
 487    // Automatically bind links with rel="modal:close" to, well, close the modal.
 488    $(document).on('click.modal', 'a[rel="modal:close"]', $.modal.close);
 489    $(document).on('click.modal', 'a[rel="modal:open"]', function(event) {
 490      event.preventDefault();
 491      $(this).modal();
 492    });
 493  }));
 494  
 495  /*
 496      Conversion of 1.6.x popup_menu.js
 497  */
 498  (function($){
 499      var current_popup = '';
 500      var PopupMenu = function(el, close_in_popupmenu)
 501      {
 502          var el = $(el);
 503          var popup = this;
 504          var popup_menu = $("#" + el.attr('id') + "_popup");
 505          if(typeof close_in_popupmenu == 'undefined')
 506          {
 507              var close_in_popupmenu = true;
 508          }
 509          // Opening Popup
 510          this.open = function(e)
 511          {
 512              e.preventDefault();
 513  
 514              if(popup_menu.is(':visible'))
 515              {
 516                  popup.close();
 517                  return;
 518              }
 519  
 520              // Setup popup menu
 521              var offset = el.offset();
 522              offset.top += el.outerHeight();
 523  
 524              // We only adjust if it goes out of the page (?)
 525              if((el.offset().left + popup_menu.outerWidth()) > $(window).width())
 526                  var adjust = popup_menu.outerWidth() - el.outerWidth();
 527              else
 528                  var adjust = 0;
 529  
 530              popup_menu.css({
 531                  position: 'absolute',
 532                  top: offset.top,
 533                  left: offset.left-adjust
 534              });
 535  
 536              popup_menu.show();
 537  
 538              // Closes the popup if we click outside the button (this doesn't seem to work properly - couldn't find any solutions that actually did - if we click the first item on the menu)
 539              // Credits: http://stackoverflow.com/questions/1160880/detect-click-outside-element
 540              $('body, .popup_item').bind('click.close_popup', function(e) {
 541                  if(close_in_popupmenu)
 542                  {
 543                      if($(e.target).closest("#" + el.attr('id')).length == 0) {
 544                          popup.close();
 545                      }
 546                  }
 547                  else
 548                  {
 549                      if($(e.target).closest("#" + el.attr('id')).length == 0 && $(e.target).closest("#" + el.attr('id') + '_popup').length == 0) {
 550                          popup.close();
 551                      }
 552                  }
 553              });
 554          }
 555          this.close = function(e)
 556          {
 557              popup_menu.hide();
 558          }
 559      }
 560      $.fn.popupMenu = function(close_in_popupmenu)
 561      {
 562          return this.each(function()
 563          {
 564              var popup = new PopupMenu(this, close_in_popupmenu);
 565              $(this).on('click',popup.open);
 566          });
 567      }
 568  })(jQuery);
 569  
 570  /*!
 571   * JavaScript Cookie v2.1.4
 572   * https://github.com/js-cookie/js-cookie
 573   *
 574   * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
 575   * Released under the MIT license
 576   */
 577  ;(function (factory) {
 578      var registeredInModuleLoader = false;
 579      if (typeof define === 'function' && define.amd) {
 580          define(factory);
 581          registeredInModuleLoader = true;
 582      }
 583      if (typeof exports === 'object') {
 584          module.exports = factory();
 585          registeredInModuleLoader = true;
 586      }
 587      if (!registeredInModuleLoader) {
 588          var OldCookies = window.Cookies;
 589          var api = window.Cookies = factory();
 590          api.noConflict = function () {
 591              window.Cookies = OldCookies;
 592              return api;
 593          };
 594      }
 595  }(function () {
 596  	function extend () {
 597          var i = 0;
 598          var result = {};
 599          for (; i < arguments.length; i++) {
 600              var attributes = arguments[ i ];
 601              for (var key in attributes) {
 602                  result[key] = attributes[key];
 603              }
 604          }
 605          return result;
 606      }
 607  
 608  	function init (converter) {
 609  		function api (key, value, attributes) {
 610              var result;
 611              if (typeof document === 'undefined') {
 612                  return;
 613              }
 614  
 615              // Write
 616  
 617              if (arguments.length > 1) {
 618                  attributes = extend({
 619                      path: '/'
 620                  }, api.defaults, attributes);
 621  
 622                  if (typeof attributes.expires === 'number') {
 623                      var expires = new Date();
 624                      expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
 625                      attributes.expires = expires;
 626                  }
 627  
 628                  // We're using "expires" because "max-age" is not supported by IE
 629                  attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
 630  
 631                  try {
 632                      result = JSON.stringify(value);
 633                      if (/^[\{\[]/.test(result)) {
 634                          value = result;
 635                      }
 636                  } catch (e) {}
 637  
 638                  if (!converter.write) {
 639                      value = encodeURIComponent(String(value))
 640                          .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
 641                  } else {
 642                      value = converter.write(value, key);
 643                  }
 644  
 645                  key = encodeURIComponent(String(key));
 646                  key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
 647                  key = key.replace(/[\(\)]/g, escape);
 648  
 649                  var stringifiedAttributes = '';
 650  
 651                  for (var attributeName in attributes) {
 652                      if (!attributes[attributeName]) {
 653                          continue;
 654                      }
 655                      stringifiedAttributes += '; ' + attributeName;
 656                      if (attributes[attributeName] === true) {
 657                          continue;
 658                      }
 659                      stringifiedAttributes += '=' + attributes[attributeName];
 660                  }
 661                  return (document.cookie = key + '=' + value + stringifiedAttributes);
 662              }
 663  
 664              // Read
 665  
 666              if (!key) {
 667                  result = {};
 668              }
 669  
 670              // To prevent the for loop in the first place assign an empty array
 671              // in case there are no cookies at all. Also prevents odd result when
 672              // calling "get()"
 673              var cookies = document.cookie ? document.cookie.split('; ') : [];
 674              var rdecode = /(%[0-9A-Z]{2})+/g;
 675              var i = 0;
 676  
 677              for (; i < cookies.length; i++) {
 678                  var parts = cookies[i].split('=');
 679                  var cookie = parts.slice(1).join('=');
 680  
 681                  if (cookie.charAt(0) === '"') {
 682                      cookie = cookie.slice(1, -1);
 683                  }
 684  
 685                  try {
 686                      var name = parts[0].replace(rdecode, decodeURIComponent);
 687                      cookie = converter.read ?
 688                          converter.read(cookie, name) : converter(cookie, name) ||
 689                          cookie.replace(rdecode, decodeURIComponent);
 690  
 691                      if (this.json) {
 692                          try {
 693                              cookie = JSON.parse(cookie);
 694                          } catch (e) {}
 695                      }
 696  
 697                      if (key === name) {
 698                          result = cookie;
 699                          break;
 700                      }
 701  
 702                      if (!key) {
 703                          result[name] = cookie;
 704                      }
 705                  } catch (e) {}
 706              }
 707  
 708              return result;
 709          }
 710  
 711          api.set = api;
 712          api.get = function (key) {
 713              return api.call(api, key);
 714          };
 715          api.getJSON = function () {
 716              return api.apply({
 717                  json: true
 718              }, [].slice.call(arguments));
 719          };
 720          api.defaults = {};
 721  
 722          api.remove = function (key, attributes) {
 723              api(key, '', extend(attributes, {
 724                  expires: -1
 725              }));
 726          };
 727  
 728          api.withConverter = init;
 729  
 730          return api;
 731      }
 732  
 733      return init(function () {});
 734  }));


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref