X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/54608122bb64c27f618773f4ad01a6822cfd0f1b..480eaa1b3638f29fcf05b67f67e31319f596130b:/vendor/assets/jquery/jquery.cookie.js diff --git a/vendor/assets/jquery/jquery.cookie.js b/vendor/assets/jquery/jquery.cookie.js index 64128472e..8218817b9 100644 --- a/vendor/assets/jquery/jquery.cookie.js +++ b/vendor/assets/jquery/jquery.cookie.js @@ -1,16 +1,19 @@ /*! - * jQuery Cookie Plugin v1.4.0 + * jQuery Cookie Plugin v1.4.1 * https://github.com/carhartl/jquery-cookie * - * Copyright 2013 Klaus Hartl + * Copyright 2006, 2014 Klaus Hartl * Released under the MIT license */ (function (factory) { if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. + // AMD (Register as an anonymous module) define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS + module.exports = factory(require('jquery')); } else { - // Browser globals. + // Browser globals factory(jQuery); } }(function ($) { @@ -53,12 +56,12 @@ // Write - if (value !== undefined && !$.isFunction(value)) { + if (arguments.length > 1 && !$.isFunction(value)) { options = $.extend({}, config.defaults, options); 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 = [ @@ -72,19 +75,20 @@ // 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; @@ -102,10 +106,6 @@ 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);