summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-07-12 17:29:28 +0200
committerAndreas Gohr <andi@splitbrain.org>2013-07-12 17:29:28 +0200
commitfbd8067eeeb9f424981aad8b283e17f734c738c3 (patch)
tree3c2df351b08a5f3243ad8168bc61962d9dba5cfa /lib/scripts
parent89e71fa967a455a3c062b26a00af0e886fbecd86 (diff)
downloadrpg-fbd8067eeeb9f424981aad8b283e17f734c738c3.tar.gz
rpg-fbd8067eeeb9f424981aad8b283e17f734c738c3.tar.bz2
updated jquery.cookie.js to 1.3.1 FS#2804
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/jquery/jquery.cookie.js59
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);
+}));