summaryrefslogtreecommitdiff
path: root/lib/jquery.cookie.js
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-03-04 15:32:05 -0800
committerBharat Mediratta <bharat@menalto.com>2013-03-04 15:32:05 -0800
commit0fb8e202c9b41973d96a89f7ecea3007722fa022 (patch)
tree4f5ad280772d9d056ecdaa646dc7a4d0e9d5faed /lib/jquery.cookie.js
parentf1884b59f13a704e53975a8104df83b9b8891f24 (diff)
parent1544a83279853acccccdf179b6c96d044fee1cf6 (diff)
Merge pull request #185 from shadlaws/minifyjs_20130304
Minify (and re-minify) JS libraries (in sync with gallery3-vendor).
Diffstat (limited to 'lib/jquery.cookie.js')
-rw-r--r--lib/jquery.cookie.js88
1 files changed, 3 insertions, 85 deletions
diff --git a/lib/jquery.cookie.js b/lib/jquery.cookie.js
index 8463b44e..869ff3c8 100644
--- a/lib/jquery.cookie.js
+++ b/lib/jquery.cookie.js
@@ -5,88 +5,6 @@
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
-(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;
-
- function raw(s) {
- return s;
- }
-
- function decoded(s) {
- 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 (typeof options.expires === 'number') {
- var days = options.expires, t = options.expires = new Date();
- t.setDate(t.getDate() + days);
- }
-
- value = config.json ? JSON.stringify(value) : String(value);
-
- return (document.cookie = [
- 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 : '',
- options.secure ? '; secure' : ''
- ].join(''));
- }
-
- // 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('=');
- 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 result;
- };
-
- config.defaults = {};
-
- $.removeCookie = function (key, options) {
- if ($.cookie(key) !== undefined) {
- $.cookie(key, '', $.extend(options, { expires: -1 }));
- return true;
- }
- return false;
- };
-
-}));
+(function(d){"function"===typeof define&&define.amd?define(["jquery"],d):d(jQuery)})(function(d){function m(a){return a}function n(a){return decodeURIComponent(a.replace(j," "))}function k(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return e.json?JSON.parse(a):a}catch(c){}}var j=/\+/g,e=d.cookie=function(a,c,b){if(void 0!==c){b=d.extend({},e.defaults,b);if("number"===typeof b.expires){var g=b.expires,f=b.expires=new Date;f.setDate(f.getDate()+g)}c=e.json?
+JSON.stringify(c):String(c);return document.cookie=[encodeURIComponent(a),"=",e.raw?c:encodeURIComponent(c),b.expires?"; expires="+b.expires.toUTCString():"",b.path?"; path="+b.path:"",b.domain?"; domain="+b.domain:"",b.secure?"; secure":""].join("")}c=e.raw?m:n;b=document.cookie.split("; ");for(var g=a?void 0:{},f=0,j=b.length;f<j;f++){var h=b[f].split("="),l=c(h.shift()),h=c(h.join("="));if(a&&a===l){g=k(h);break}a||(g[l]=k(h))}return g};e.defaults={};d.removeCookie=function(a,c){return void 0!==
+d.cookie(a)?(d.cookie(a,"",d.extend(c,{expires:-1})),!0):!1}});