]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/jquery/jquery.cookie.js
Update jquery.cookie
[rails.git] / vendor / assets / jquery / jquery.cookie.js
index feb62e92561a63eae96ff42e50ed873944382a5d..8218817b9492926c8ddb832f7793bd31afb7e609 100644 (file)
@@ -7,11 +7,11 @@
  */
 (function (factory) {
        if (typeof define === 'function' && define.amd) {
-               // AMD
+               // AMD (Register as an anonymous module)
                define(['jquery'], factory);
        } else if (typeof exports === 'object') {
-               // CommonJS
-               factory(require('jquery'));
+               // Node/CommonJS
+               module.exports = factory(require('jquery'));
        } else {
                // Browser globals
                factory(jQuery);
@@ -61,7 +61,7 @@
 
                        if (typeof options.expires === 'number') {
                                var days = options.expires, t = options.expires = new Date();
-                               t.setTime(+t + days * 864e+5);
+                               t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
                        }
 
                        return (document.cookie = [
 
                // Read
 
-               var result = key ? undefined : {};
+               var result = key ? undefined : {},
+                       // To prevent the for loop in the first place assign an empty array
+                       // in case there are no cookies at all. Also prevents odd result when
+                       // calling $.cookie().
+                       cookies = document.cookie ? document.cookie.split('; ') : [],
+                       i = 0,
+                       l = cookies.length;
 
-               // To prevent the for loop in the first place assign an empty array
-               // in case there are no cookies at all. Also prevents odd result when
-               // calling $.cookie().
-               var cookies = document.cookie ? document.cookie.split('; ') : [];
+               for (; i < l; i++) {
+                       var parts = cookies[i].split('='),
+                               name = decode(parts.shift()),
+                               cookie = parts.join('=');
 
-               for (var i = 0, l = cookies.length; i < l; i++) {
-                       var parts = cookies[i].split('=');
-                       var name = decode(parts.shift());
-                       var cookie = parts.join('=');
-
-                       if (key && key === name) {
+                       if (key === name) {
                                // If second argument (value) is a function it's a converter...
                                result = read(cookie, value);
                                break;
        config.defaults = {};
 
        $.removeCookie = function (key, options) {
-               if ($.cookie(key) === undefined) {
-                       return false;
-               }
-
                // Must not alter options, thus extending a fresh object...
                $.cookie(key, '', $.extend({}, options, { expires: -1 }));
                return !$.cookie(key);