forked from GNUsocial/gnu-social
updated and moved jquery-cookie
Also added to minification Makefile in js/ as it was not delivered from upstream as .min.js
This commit is contained in:
parent
31bace8cfd
commit
360492472c
@ -1,6 +1,6 @@
|
|||||||
.fake: all clean
|
.fake: all clean
|
||||||
|
|
||||||
TARGETS=util.min.js extlib/json2.min.js
|
TARGETS=util.min.js extlib/json2.min.js extlib/jquery.cookie.min.js
|
||||||
UTIL_SOURCES=util.js xbImportNode.js geometa.js
|
UTIL_SOURCES=util.js xbImportNode.js geometa.js
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
@ -13,3 +13,6 @@ util.min.js: $(UTIL_SOURCES)
|
|||||||
|
|
||||||
extlib/json2.min.js: extlib/json2.js
|
extlib/json2.min.js: extlib/json2.js
|
||||||
yui-compressor $+ > $@
|
yui-compressor $+ > $@
|
||||||
|
|
||||||
|
extlib/jquery.cookie.min.js: extlib/jquery.cookie.js
|
||||||
|
yui-compressor $+ > $@
|
||||||
|
107
js/extlib/jquery.cookie.js
Normal file
107
js/extlib/jquery.cookie.js
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*!
|
||||||
|
* jQuery Cookie Plugin v1.3.1
|
||||||
|
* https://github.com/carhartl/jquery-cookie
|
||||||
|
*
|
||||||
|
* 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 decode(s) {
|
||||||
|
if (config.raw) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// If we can't decode the cookie, ignore it, it's unusable.
|
||||||
|
return decodeURIComponent(s.replace(pluses, ' '));
|
||||||
|
} catch(e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function decodeAndParse(s) {
|
||||||
|
if (s.indexOf('"') === 0) {
|
||||||
|
// This is a quoted cookie as according to RFC2068, unescape...
|
||||||
|
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
s = decode(s);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// If we can't parse the cookie, ignore it, it's unusable.
|
||||||
|
return config.json ? JSON.parse(s) : s;
|
||||||
|
} catch(e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = [
|
||||||
|
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 : '',
|
||||||
|
options.secure ? '; secure' : ''
|
||||||
|
].join(''));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read
|
||||||
|
|
||||||
|
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().
|
||||||
|
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||||
|
|
||||||
|
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) {
|
||||||
|
result = decodeAndParse(cookie);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent storing a cookie that we couldn't decode.
|
||||||
|
if (!key && (cookie = decodeAndParse(cookie)) !== undefined) {
|
||||||
|
result[name] = cookie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.defaults = {};
|
||||||
|
|
||||||
|
$.removeCookie = function (key, options) {
|
||||||
|
if ($.cookie(key) !== undefined) {
|
||||||
|
// Must not alter options, thus extending a fresh object...
|
||||||
|
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
}));
|
8
js/extlib/jquery.cookie.min.js
vendored
Normal file
8
js/extlib/jquery.cookie.min.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* jQuery Cookie Plugin v1.3.1
|
||||||
|
* https://github.com/carhartl/jquery-cookie
|
||||||
|
*
|
||||||
|
* Copyright 2013 Klaus Hartl
|
||||||
|
* Released under the MIT license
|
||||||
|
*/
|
||||||
|
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{a(jQuery)}}(function(c){var a=/\+/g;function d(f){if(b.raw){return f}try{return decodeURIComponent(f.replace(a," "))}catch(g){}}function e(f){if(f.indexOf('"')===0){f=f.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}f=d(f);try{return b.json?JSON.parse(f):f}catch(g){}}var b=c.cookie=function(n,m,r){if(m!==undefined){r=c.extend({},b.defaults,r);if(typeof r.expires==="number"){var o=r.expires,q=r.expires=new Date();q.setDate(q.getDate()+o)}m=b.json?JSON.stringify(m):String(m);return(document.cookie=[b.raw?n:encodeURIComponent(n),"=",b.raw?m:encodeURIComponent(m),r.expires?"; expires="+r.expires.toUTCString():"",r.path?"; path="+r.path:"",r.domain?"; domain="+r.domain:"",r.secure?"; secure":""].join(""))}var s=n?undefined:{};var p=document.cookie?document.cookie.split("; "):[];for(var k=0,h=p.length;k<h;k++){var j=p[k].split("=");var f=d(j.shift());var g=j.join("=");if(n&&n===f){s=e(g);break}if(!n&&(g=e(g))!==undefined){s[f]=g}}return s};b.defaults={};c.removeCookie=function(g,f){if(c.cookie(g)!==undefined){c.cookie(g,"",c.extend({},f,{expires:-1}));return true}return false}}));
|
@ -1,96 +0,0 @@
|
|||||||
/**
|
|
||||||
* Cookie plugin
|
|
||||||
*
|
|
||||||
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
|
||||||
* Dual licensed under the MIT and GPL licenses:
|
|
||||||
* http://www.opensource.org/licenses/mit-license.php
|
|
||||||
* http://www.gnu.org/licenses/gpl.html
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a cookie with the given name and value and other optional parameters.
|
|
||||||
*
|
|
||||||
* @example $.cookie('the_cookie', 'the_value');
|
|
||||||
* @desc Set the value of a cookie.
|
|
||||||
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
|
||||||
* @desc Create a cookie with all available options.
|
|
||||||
* @example $.cookie('the_cookie', 'the_value');
|
|
||||||
* @desc Create a session cookie.
|
|
||||||
* @example $.cookie('the_cookie', null);
|
|
||||||
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
|
||||||
* used when the cookie was set.
|
|
||||||
*
|
|
||||||
* @param String name The name of the cookie.
|
|
||||||
* @param String value The value of the cookie.
|
|
||||||
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
|
||||||
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
|
||||||
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
|
||||||
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
|
||||||
* when the the browser exits.
|
|
||||||
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
|
||||||
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
|
||||||
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
|
||||||
* require a secure protocol (like HTTPS).
|
|
||||||
* @type undefined
|
|
||||||
*
|
|
||||||
* @name $.cookie
|
|
||||||
* @cat Plugins/Cookie
|
|
||||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the value of a cookie with the given name.
|
|
||||||
*
|
|
||||||
* @example $.cookie('the_cookie');
|
|
||||||
* @desc Get the value of a cookie.
|
|
||||||
*
|
|
||||||
* @param String name The name of the cookie.
|
|
||||||
* @return The value of the cookie.
|
|
||||||
* @type String
|
|
||||||
*
|
|
||||||
* @name $.cookie
|
|
||||||
* @cat Plugins/Cookie
|
|
||||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
|
||||||
*/
|
|
||||||
jQuery.cookie = function(name, value, options) {
|
|
||||||
if (typeof value != 'undefined') { // name and value given, set cookie
|
|
||||||
options = options || {};
|
|
||||||
if (value === null) {
|
|
||||||
value = '';
|
|
||||||
options.expires = -1;
|
|
||||||
}
|
|
||||||
var expires = '';
|
|
||||||
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
|
||||||
var date;
|
|
||||||
if (typeof options.expires == 'number') {
|
|
||||||
date = new Date();
|
|
||||||
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
|
||||||
} else {
|
|
||||||
date = options.expires;
|
|
||||||
}
|
|
||||||
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
|
||||||
}
|
|
||||||
// CAUTION: Needed to parenthesize options.path and options.domain
|
|
||||||
// in the following expressions, otherwise they evaluate to undefined
|
|
||||||
// in the packed version for some reason...
|
|
||||||
var path = options.path ? '; path=' + (options.path) : '';
|
|
||||||
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
|
||||||
var secure = options.secure ? '; secure' : '';
|
|
||||||
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
|
||||||
} else { // only name given, get cookie
|
|
||||||
var cookieValue = null;
|
|
||||||
if (document.cookie && document.cookie != '') {
|
|
||||||
var cookies = document.cookie.split(';');
|
|
||||||
for (var i = 0; i < cookies.length; i++) {
|
|
||||||
var cookie = jQuery.trim(cookies[i]);
|
|
||||||
// Does this cookie string begin with the name we want?
|
|
||||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
|
||||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cookieValue;
|
|
||||||
}
|
|
||||||
};
|
|
1
js/jquery.cookie.min.js
vendored
1
js/jquery.cookie.min.js
vendored
@ -1 +0,0 @@
|
|||||||
jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};
|
|
@ -362,14 +362,14 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
$this->script('extlib/jquery.min.js');
|
$this->script('extlib/jquery.min.js');
|
||||||
$this->script('extlib/jquery.form.min.js');
|
$this->script('extlib/jquery.form.min.js');
|
||||||
$this->script('extlib/jquery-ui/jquery-ui.min.js');
|
$this->script('extlib/jquery-ui/jquery-ui.min.js');
|
||||||
$this->script('jquery.cookie.min.js');
|
$this->script('extlib/jquery.cookie.min.js');
|
||||||
$this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.min.js', StatusNet::isHTTPS()).'"); }');
|
$this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.min.js', StatusNet::isHTTPS()).'"); }');
|
||||||
$this->script('extlib/jquery.infieldlabel.min.js');
|
$this->script('extlib/jquery.infieldlabel.min.js');
|
||||||
} else {
|
} else {
|
||||||
$this->script('extlib/jquery.js');
|
$this->script('extlib/jquery.js');
|
||||||
$this->script('extlib/jquery.form.js');
|
$this->script('extlib/jquery.form.js');
|
||||||
$this->script('extlib/jquery-ui/jquery-ui.js');
|
$this->script('extlib/jquery-ui/jquery-ui.js');
|
||||||
$this->script('jquery.cookie.js');
|
$this->script('extlib/jquery.cookie.js');
|
||||||
$this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.js', StatusNet::isHTTPS()).'"); }');
|
$this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.js', StatusNet::isHTTPS()).'"); }');
|
||||||
$this->script('extlib/jquery.infieldlabel.js');
|
$this->script('extlib/jquery.infieldlabel.js');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user