diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2013-07-30 10:50:52 +0200 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2013-07-30 10:50:52 +0200 |
commit | af07997c5ff7cc096965159d90158e3710d2d019 (patch) | |
tree | defaf770e77a679436eb56291185905b547640d0 /lib/scripts/jquery/jquery.cookie.js | |
parent | bdac741579f8c6f00248d5d3ec635d4c2e08fb1e (diff) | |
parent | 7d8a6abbb21979fd77dca10275ebb8e01a04b6e4 (diff) | |
download | rpg-af07997c5ff7cc096965159d90158e3710d2d019.tar.gz rpg-af07997c5ff7cc096965159d90158e3710d2d019.tar.bz2 |
Merge branch 'master' into configmgr_improvements
Conflicts:
inc/auth.php
inc/template.php
lib/plugins/authad/lang/zh/settings.php
lib/plugins/authldap/lang/en/settings.php
lib/plugins/authldap/lang/zh/settings.php
lib/plugins/authmysql/lang/zh/settings.php
lib/plugins/config/settings/config.class.php
lib/plugins/usermanager/admin.php
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); +})); |