diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-10-28 20:22:05 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-10-28 20:22:05 +0100 |
commit | 23a363f01514464eb2238ac09ec7723d03d57ecb (patch) | |
tree | 42c7dcff8c5b0e506a25d08ee5583ed2a24e8602 /lib/scripts/jquery/jquery.cookie.js | |
parent | 25e48e54df60b3df6efa365daceb3a8966c8f427 (diff) | |
parent | 75cf672f10a71f7dee6d50eb70b742689838bc36 (diff) | |
download | rpg-23a363f01514464eb2238ac09ec7723d03d57ecb.tar.gz rpg-23a363f01514464eb2238ac09ec7723d03d57ecb.tar.bz2 |
Merge branch 'master' into stable
* master: (413 commits)
release preparation
fixed strict violation in ACL plugin
Fix issues from teams:i18n:translation-check in localizations
ensure locale is set back to the original value
skip FS#2867 test if \s doesn't match \xA0 after attempting to change the locale
unittests for auth_loadACL
translation update
allow charset for SSO to be configured FS#2148
Mailer: avoid overlong headers in content ids FS#2868
translation update
translation update
replace \s, \S with [ \t], [^ \t] in regexs used with acls
translation update
translation update
translation update
translation update
Fix handling of the legacy subscription action name
remove obsolete opera handling and session closing
remove no longer used ajax.php
fix proxy CONNECT where HTTP 1.1 answer is given
...
Diffstat (limited to 'lib/scripts/jquery/jquery.cookie.js')
-rw-r--r-- | lib/scripts/jquery/jquery.cookie.js | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/lib/scripts/jquery/jquery.cookie.js b/lib/scripts/jquery/jquery.cookie.js index 2d4c05a84..c4f99af00 100644 --- a/lib/scripts/jquery/jquery.cookie.js +++ b/lib/scripts/jquery/jquery.cookie.js @@ -1,13 +1,19 @@ /*! - * jQuery Cookie Plugin v1.3 + * jQuery Cookie Plugin v1.3.1 * https://github.com/carhartl/jquery-cookie * - * Copyright 2011, Klaus Hartl - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://www.opensource.org/licenses/mit-license.php - * http://www.opensource.org/licenses/GPL-2.0 + * Copyright 2013 Klaus Hartl + * Released under the MIT license */ -(function ($, document, undefined) { +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as anonymous module. + define(['jquery'], factory); + } else { + // Browser globals. + factory(jQuery); + } +}(function ($) { var pluses = /\+/g; @@ -19,16 +25,22 @@ return decodeURIComponent(s.replace(pluses, ' ')); } + function converted(s) { + if (s.indexOf('"') === 0) { + // This is a quoted cookie as according to RFC2068, unescape + s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); + } + try { + return config.json ? JSON.parse(s) : s; + } catch(er) {} + } + var config = $.cookie = function (key, value, options) { // write if (value !== undefined) { options = $.extend({}, config.defaults, options); - if (value === null) { - options.expires = -1; - } - if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); @@ -37,7 +49,9 @@ value = config.json ? JSON.stringify(value) : String(value); return (document.cookie = [ - encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value), + config.raw ? key : encodeURIComponent(key), + '=', + config.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 : '', @@ -48,25 +62,34 @@ // read var decode = config.raw ? raw : decoded; var cookies = document.cookie.split('; '); + var result = key ? undefined : {}; for (var i = 0, l = cookies.length; i < l; i++) { var parts = cookies[i].split('='); - if (decode(parts.shift()) === key) { - var cookie = decode(parts.join('=')); - return config.json ? JSON.parse(cookie) : cookie; + var name = decode(parts.shift()); + var cookie = decode(parts.join('=')); + + if (key && key === name) { + result = converted(cookie); + break; + } + + if (!key) { + result[name] = converted(cookie); } } - return null; + return result; }; config.defaults = {}; $.removeCookie = function (key, options) { - if ($.cookie(key) !== null) { - $.cookie(key, null, options); + if ($.cookie(key) !== undefined) { + // Must not alter options, thus extending a fresh object... + $.cookie(key, '', $.extend({}, options, { expires: -1 })); return true; } return false; }; -})(jQuery, document); +})); |