jquerypp-rails 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +24 -0
- data/Rakefile +2 -0
- data/jquerypp-rails.gemspec +20 -0
- data/lib/jquerypp/generators/jquerypp/install/install_generator.rb +49 -0
- data/lib/jquerypp/rails/engine.rb +8 -0
- data/lib/jquerypp/rails/version.rb +6 -0
- data/lib/jquerypp/rails.rb +8 -0
- data/lib/jquerypp-rails.rb +1 -0
- data/vendor/assets/javascripts/jquerypp.js +5419 -0
- data/vendor/assets/javascripts/lib/jquery.animate.js +326 -0
- data/vendor/assets/javascripts/lib/jquery.compare.js +75 -0
- data/vendor/assets/javascripts/lib/jquery.cookie.js +118 -0
- data/vendor/assets/javascripts/lib/jquery.dimensions.js +191 -0
- data/vendor/assets/javascripts/lib/jquery.event.default.js +115 -0
- data/vendor/assets/javascripts/lib/jquery.event.destroyed.js +23 -0
- data/vendor/assets/javascripts/lib/jquery.event.drag.js +727 -0
- data/vendor/assets/javascripts/lib/jquery.event.drop.js +457 -0
- data/vendor/assets/javascripts/lib/jquery.event.fastfix.js +95 -0
- data/vendor/assets/javascripts/lib/jquery.event.hover.js +266 -0
- data/vendor/assets/javascripts/lib/jquery.event.key.js +156 -0
- data/vendor/assets/javascripts/lib/jquery.event.livehack.js +174 -0
- data/vendor/assets/javascripts/lib/jquery.event.pause.js +92 -0
- data/vendor/assets/javascripts/lib/jquery.event.resize.js +47 -0
- data/vendor/assets/javascripts/lib/jquery.event.swipe.js +133 -0
- data/vendor/assets/javascripts/lib/jquery.fills.js +249 -0
- data/vendor/assets/javascripts/lib/jquery.form_params.js +167 -0
- data/vendor/assets/javascripts/lib/jquery.lang.json.js +196 -0
- data/vendor/assets/javascripts/lib/jquery.lang.vector.js +214 -0
- data/vendor/assets/javascripts/lib/jquery.range.js +861 -0
- data/vendor/assets/javascripts/lib/jquery.selection.js +232 -0
- data/vendor/assets/javascripts/lib/jquery.styles.js +103 -0
- data/vendor/assets/javascripts/lib/jquery.within.js +94 -0
- metadata +81 -0
@@ -0,0 +1,326 @@
|
|
1
|
+
// Dependencies:
|
2
|
+
//
|
3
|
+
// - jquery.animate.js
|
4
|
+
// - jquery.styles.js
|
5
|
+
|
6
|
+
(function ($) {
|
7
|
+
|
8
|
+
// Overwrites `jQuery.fn.animate` to use CSS 3 animations if possible
|
9
|
+
|
10
|
+
var
|
11
|
+
// The global animation counter
|
12
|
+
animationNum = 0,
|
13
|
+
// The stylesheet for our animations
|
14
|
+
styleSheet = null,
|
15
|
+
// The animation cache
|
16
|
+
cache = [],
|
17
|
+
// Stores the browser properties like transition end event name and prefix
|
18
|
+
browser = null,
|
19
|
+
// Store the original $.fn.animate
|
20
|
+
oldanimate = $.fn.animate,
|
21
|
+
|
22
|
+
// Return the stylesheet, create it if it doesn't exists
|
23
|
+
getStyleSheet = function () {
|
24
|
+
if(!styleSheet) {
|
25
|
+
var style = document.createElement('style');
|
26
|
+
style.setAttribute("type", "text/css");
|
27
|
+
style.setAttribute("media", "screen");
|
28
|
+
|
29
|
+
document.getElementsByTagName('head')[0].appendChild(style);
|
30
|
+
if (!window.createPopup) { /* For Safari */
|
31
|
+
style.appendChild(document.createTextNode(''));
|
32
|
+
}
|
33
|
+
|
34
|
+
styleSheet = style.sheet;
|
35
|
+
}
|
36
|
+
|
37
|
+
return styleSheet;
|
38
|
+
},
|
39
|
+
|
40
|
+
//removes an animation rule from a sheet
|
41
|
+
removeAnimation = function (sheet, name) {
|
42
|
+
for (var j = sheet.cssRules.length - 1; j >= 0; j--) {
|
43
|
+
var rule = sheet.cssRules[j];
|
44
|
+
// 7 means the keyframe rule
|
45
|
+
if (rule.type === 7 && rule.name == name) {
|
46
|
+
sheet.deleteRule(j)
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
},
|
51
|
+
|
52
|
+
// Returns whether the animation should be passed to the original $.fn.animate.
|
53
|
+
passThrough = function (props, ops) {
|
54
|
+
var nonElement = !(this[0] && this[0].nodeType),
|
55
|
+
isInline = !nonElement && $(this).css("display") === "inline" && $(this).css("float") === "none";
|
56
|
+
|
57
|
+
for (var name in props) {
|
58
|
+
// jQuery does something with these values
|
59
|
+
if (props[name] == 'show' || props[name] == 'hide' || props[name] == 'toggle'
|
60
|
+
// Arrays for individual easing
|
61
|
+
|| $.isArray(props[name])
|
62
|
+
// Negative values not handled the same
|
63
|
+
|| props[name] < 0
|
64
|
+
// unit-less value
|
65
|
+
|| name == 'zIndex' || name == 'z-index'
|
66
|
+
) {
|
67
|
+
return true;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
return props.jquery === true || getBrowser() === null ||
|
72
|
+
// Animating empty properties
|
73
|
+
$.isEmptyObject(props) ||
|
74
|
+
// We can't do custom easing
|
75
|
+
ops.length == 4 || typeof ops[2] == 'string' ||
|
76
|
+
// Second parameter is an object - we can only handle primitives
|
77
|
+
$.isPlainObject(ops) ||
|
78
|
+
// Inline and non elements
|
79
|
+
isInline || nonElement;
|
80
|
+
},
|
81
|
+
|
82
|
+
// Gets a CSS number (with px added as the default unit if the value is a number)
|
83
|
+
cssValue = function(origName, value) {
|
84
|
+
if (typeof value === "number" && !$.cssNumber[ origName ]) {
|
85
|
+
return value += "px";
|
86
|
+
}
|
87
|
+
return value;
|
88
|
+
},
|
89
|
+
|
90
|
+
// Feature detection borrowed by http://modernizr.com/
|
91
|
+
getBrowser = function(){
|
92
|
+
if(!browser) {
|
93
|
+
var t,
|
94
|
+
el = document.createElement('fakeelement'),
|
95
|
+
transitions = {
|
96
|
+
'transition': {
|
97
|
+
transitionEnd : 'transitionEnd',
|
98
|
+
prefix : ''
|
99
|
+
},
|
100
|
+
// 'OTransition': {
|
101
|
+
// transitionEnd : 'oTransitionEnd',
|
102
|
+
// prefix : '-o-'
|
103
|
+
// },
|
104
|
+
// 'MSTransition': {
|
105
|
+
// transitionEnd : 'msTransitionEnd',
|
106
|
+
// prefix : '-ms-'
|
107
|
+
// },
|
108
|
+
'MozTransition': {
|
109
|
+
transitionEnd : 'animationend',
|
110
|
+
prefix : '-moz-'
|
111
|
+
},
|
112
|
+
'WebkitTransition': {
|
113
|
+
transitionEnd : 'webkitAnimationEnd',
|
114
|
+
prefix : '-webkit-'
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
for(t in transitions){
|
119
|
+
if( el.style[t] !== undefined ){
|
120
|
+
browser = transitions[t];
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
return browser;
|
125
|
+
},
|
126
|
+
|
127
|
+
// Properties that Firefox can't animate if set to 'auto':
|
128
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=571344
|
129
|
+
// Provides a converter that returns the actual value
|
130
|
+
ffProps = {
|
131
|
+
top : function(el) {
|
132
|
+
return el.position().top;
|
133
|
+
},
|
134
|
+
left : function(el) {
|
135
|
+
return el.position().left;
|
136
|
+
},
|
137
|
+
width : function(el) {
|
138
|
+
return el.width();
|
139
|
+
},
|
140
|
+
height : function(el) {
|
141
|
+
return el.height();
|
142
|
+
},
|
143
|
+
fontSize : function(el) {
|
144
|
+
return '1em';
|
145
|
+
}
|
146
|
+
},
|
147
|
+
|
148
|
+
// Add browser specific prefix
|
149
|
+
addPrefix = function(properties) {
|
150
|
+
var result = {};
|
151
|
+
$.each(properties, function(name, value) {
|
152
|
+
result[getBrowser().prefix + name] = value;
|
153
|
+
});
|
154
|
+
return result;
|
155
|
+
},
|
156
|
+
|
157
|
+
// Returns the animation name for a given style. It either uses a cached
|
158
|
+
// version or adds it to the stylesheet, removing the oldest style if the
|
159
|
+
// cache has reached a certain size.
|
160
|
+
getAnimation = function(style) {
|
161
|
+
var sheet, name, last;
|
162
|
+
|
163
|
+
// Look up the cached style, set it to that name and reset age if found
|
164
|
+
// increment the age for any other animation
|
165
|
+
$.each(cache, function(i, animation) {
|
166
|
+
if(style === animation.style) {
|
167
|
+
name = animation.name;
|
168
|
+
animation.age = 0;
|
169
|
+
} else {
|
170
|
+
animation.age += 1;
|
171
|
+
}
|
172
|
+
});
|
173
|
+
|
174
|
+
if(!name) { // Add a new style
|
175
|
+
sheet = getStyleSheet();
|
176
|
+
name = "jquerypp_animation_" + (animationNum++);
|
177
|
+
// get the last sheet and insert this rule into it
|
178
|
+
sheet.insertRule("@" + getBrowser().prefix + "keyframes " + name + ' ' + style,
|
179
|
+
(sheet.cssRules && sheet.cssRules.length) || 0);
|
180
|
+
cache.push({
|
181
|
+
name : name,
|
182
|
+
style : style,
|
183
|
+
age : 0
|
184
|
+
});
|
185
|
+
|
186
|
+
// Sort the cache by age
|
187
|
+
cache.sort(function(first, second) {
|
188
|
+
return first.age - second.age;
|
189
|
+
});
|
190
|
+
|
191
|
+
// Remove the last (oldest) item from the cache if it has more than 20 items
|
192
|
+
if(cache.length > 20) {
|
193
|
+
last = cache.pop();
|
194
|
+
removeAnimation(sheet, last.name);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
return name;
|
199
|
+
};
|
200
|
+
|
201
|
+
/**
|
202
|
+
* @function $.fn.animate
|
203
|
+
* @parent $.animate
|
204
|
+
*
|
205
|
+
* Animate CSS properties using native CSS animations, if possible.
|
206
|
+
* Uses the original [$.fn.animate()](http://api.$.com/animate/) otherwise.
|
207
|
+
*
|
208
|
+
* @param {Object} props The CSS properties to animate
|
209
|
+
* @param {Integer|String|Object} [speed=400] The animation duration in ms.
|
210
|
+
* Will use $.fn.animate if a string or object is passed
|
211
|
+
* @param {Function} [callback] A callback to execute once the animation is complete
|
212
|
+
* @return {jQuery} The jQuery element
|
213
|
+
*/
|
214
|
+
$.fn.animate = function (props, speed, easing, callback) {
|
215
|
+
//default to normal animations if browser doesn't support them
|
216
|
+
if (passThrough.apply(this, arguments)) {
|
217
|
+
return oldanimate.apply(this, arguments);
|
218
|
+
}
|
219
|
+
|
220
|
+
var optall = jQuery.speed(speed, easing, callback);
|
221
|
+
|
222
|
+
// Add everything to the animation queue
|
223
|
+
this.queue(optall.queue, function(done) {
|
224
|
+
var
|
225
|
+
//current CSS values
|
226
|
+
current,
|
227
|
+
// The list of properties passed
|
228
|
+
properties = [],
|
229
|
+
to = "",
|
230
|
+
prop,
|
231
|
+
self = $(this),
|
232
|
+
duration = optall.duration,
|
233
|
+
//the animation keyframe name
|
234
|
+
animationName,
|
235
|
+
// The key used to store the animation hook
|
236
|
+
dataKey,
|
237
|
+
//the text for the keyframe
|
238
|
+
style = "{ from {",
|
239
|
+
// The animation end event handler.
|
240
|
+
// Will be called both on animation end and after calling .stop()
|
241
|
+
animationEnd = function (currentCSS, exec) {
|
242
|
+
self.css(currentCSS);
|
243
|
+
|
244
|
+
self.css(addPrefix({
|
245
|
+
"animation-duration" : "",
|
246
|
+
"animation-name" : "",
|
247
|
+
"animation-fill-mode" : "",
|
248
|
+
"animation-play-state" : ""
|
249
|
+
}));
|
250
|
+
|
251
|
+
// Call the original callback
|
252
|
+
if (optall.old && exec) {
|
253
|
+
// Call success, pass the DOM element as the this reference
|
254
|
+
optall.old.call(self[0], true)
|
255
|
+
}
|
256
|
+
|
257
|
+
$.removeData(self, dataKey, true);
|
258
|
+
}
|
259
|
+
|
260
|
+
for(prop in props) {
|
261
|
+
properties.push(prop);
|
262
|
+
}
|
263
|
+
|
264
|
+
if(getBrowser().prefix === '-moz-') {
|
265
|
+
// Normalize 'auto' properties in FF
|
266
|
+
$.each(properties, function(i, prop) {
|
267
|
+
var converter = ffProps[$.camelCase(prop)];
|
268
|
+
if(converter && self.css(prop) == 'auto') {
|
269
|
+
self.css(prop, converter(self));
|
270
|
+
}
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
// Use $.styles
|
275
|
+
current = self.styles.apply(self, properties);
|
276
|
+
$.each(properties, function(i, cur) {
|
277
|
+
// Convert a camelcased property name
|
278
|
+
var name = cur.replace(/([A-Z]|^ms)/g, "-$1" ).toLowerCase();
|
279
|
+
style += name + " : " + cssValue(cur, current[cur]) + "; ";
|
280
|
+
to += name + " : " + cssValue(cur, props[cur]) + "; ";
|
281
|
+
});
|
282
|
+
|
283
|
+
style += "} to {" + to + " }}";
|
284
|
+
|
285
|
+
animationName = getAnimation(style);
|
286
|
+
dataKey = animationName + '.run';
|
287
|
+
|
288
|
+
// Add a hook which will be called when the animation stops
|
289
|
+
$._data(this, dataKey, {
|
290
|
+
stop : function(gotoEnd) {
|
291
|
+
// Pause the animation
|
292
|
+
self.css(addPrefix({
|
293
|
+
'animation-play-state' : 'paused'
|
294
|
+
}));
|
295
|
+
// Unbind the animation end handler
|
296
|
+
self.off(getBrowser().transitionEnd, animationEnd);
|
297
|
+
if(!gotoEnd) {
|
298
|
+
// We were told not to finish the animation
|
299
|
+
// Call animationEnd but set the CSS to the current computed style
|
300
|
+
animationEnd(self.styles.apply(self, properties), false);
|
301
|
+
} else {
|
302
|
+
// Finish animaion
|
303
|
+
animationEnd(props, true);
|
304
|
+
}
|
305
|
+
}
|
306
|
+
});
|
307
|
+
|
308
|
+
// set this element to point to that animation
|
309
|
+
self.css(addPrefix({
|
310
|
+
"animation-duration" : duration + "ms",
|
311
|
+
"animation-name" : animationName,
|
312
|
+
"animation-fill-mode": "forwards"
|
313
|
+
}));
|
314
|
+
|
315
|
+
// Attach the transition end event handler to run only once
|
316
|
+
self.one(getBrowser().transitionEnd, function() {
|
317
|
+
// Call animationEnd using the passed properties
|
318
|
+
animationEnd(props, true);
|
319
|
+
done();
|
320
|
+
});
|
321
|
+
|
322
|
+
});
|
323
|
+
|
324
|
+
return this;
|
325
|
+
};
|
326
|
+
})(jQuery)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
// - jquery.compare.js
|
2
|
+
(function($){
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @function jQuery.fn.compare
|
6
|
+
* @parent jQuery.compare
|
7
|
+
*
|
8
|
+
* Compare two elements and return a bitmask as a number representing the following conditions:
|
9
|
+
*
|
10
|
+
* - `000000` -> __0__: Elements are identical
|
11
|
+
* - `000001` -> __1__: The nodes are in different documents (or one is outside of a document)
|
12
|
+
* - `000010` -> __2__: #bar precedes #foo
|
13
|
+
* - `000100` -> __4__: #foo precedes #bar
|
14
|
+
* - `001000` -> __8__: #bar contains #foo
|
15
|
+
* - `010000` -> __16__: #foo contains #bar
|
16
|
+
*
|
17
|
+
* You can check for any of these conditions using a bitwise AND:
|
18
|
+
*
|
19
|
+
* if( $('#foo').compare($('#bar')) & 2 ) {
|
20
|
+
* console.log("#bar precedes #foo")
|
21
|
+
* }
|
22
|
+
*
|
23
|
+
* @param {HTMLElement|jQuery} element an element or jQuery collection to compare against.
|
24
|
+
* @return {Number} A number representing a bitmask deatiling how the elements are positioned from each other.
|
25
|
+
*/
|
26
|
+
|
27
|
+
// See http://ejohn.org/blog/comparing-document-position/
|
28
|
+
jQuery.fn.compare = function(element){ //usually
|
29
|
+
try{
|
30
|
+
// Firefox 3 throws an error with XUL - we can't use compare then
|
31
|
+
element = element.jquery ? element[0] : element;
|
32
|
+
}catch(e){
|
33
|
+
return null;
|
34
|
+
}
|
35
|
+
|
36
|
+
// make sure we aren't coming from XUL element
|
37
|
+
if (window.HTMLElement) {
|
38
|
+
var s = HTMLElement.prototype.toString.call(element)
|
39
|
+
if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]' || s === '[object Window]') {
|
40
|
+
return null;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
if(this[0].compareDocumentPosition){
|
45
|
+
// For browsers that support it, use compareDocumentPosition
|
46
|
+
// https://developer.mozilla.org/en/DOM/Node.compareDocumentPosition
|
47
|
+
return this[0].compareDocumentPosition(element);
|
48
|
+
}
|
49
|
+
|
50
|
+
// this[0] contains element
|
51
|
+
if(this[0] == document && element != document) return 8;
|
52
|
+
|
53
|
+
var number =
|
54
|
+
// this[0] contains element
|
55
|
+
(this[0] !== element && this[0].contains(element) && 16) +
|
56
|
+
// element contains this[0]
|
57
|
+
(this[0] != element && element.contains(this[0]) && 8),
|
58
|
+
docEl = document.documentElement;
|
59
|
+
|
60
|
+
// Use the sourceIndex
|
61
|
+
if(this[0].sourceIndex){
|
62
|
+
// this[0] precedes element
|
63
|
+
number += (this[0].sourceIndex < element.sourceIndex && 4)
|
64
|
+
// element precedes foo[0]
|
65
|
+
number += (this[0].sourceIndex > element.sourceIndex && 2)
|
66
|
+
// The nodes are in different documents
|
67
|
+
number += (this[0].ownerDocument !== element.ownerDocument ||
|
68
|
+
(this[0] != docEl && this[0].sourceIndex <= 0 ) ||
|
69
|
+
(element != docEl && element.sourceIndex <= 0 )) && 1
|
70
|
+
}
|
71
|
+
|
72
|
+
return number;
|
73
|
+
}
|
74
|
+
|
75
|
+
})(jQuery)
|
@@ -0,0 +1,118 @@
|
|
1
|
+
// Dependencies:
|
2
|
+
//
|
3
|
+
// - jquery.cookie.js
|
4
|
+
// - jquery.lang.json.js
|
5
|
+
|
6
|
+
(function() {
|
7
|
+
/**
|
8
|
+
* @function jQuery.cookie
|
9
|
+
* @parent jquerypp
|
10
|
+
* @plugin jquery/dom/cookie
|
11
|
+
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
12
|
+
*
|
13
|
+
* `jQuery.cookie(name, [value], [options])` lets you create, read and remove cookies. It is the
|
14
|
+
* [jQuery cookie plugin](https://github.com/carhartl/jquery-cookie) written by [Klaus Hartl](stilbuero.de)
|
15
|
+
* and dual licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php)
|
16
|
+
* and [GPL](http://www.gnu.org/licenses/gpl.html) licenses.
|
17
|
+
*
|
18
|
+
* ## Examples
|
19
|
+
*
|
20
|
+
* Set the value of a cookie.
|
21
|
+
*
|
22
|
+
* $.cookie('the_cookie', 'the_value');
|
23
|
+
*
|
24
|
+
* Create a cookie with all available options.
|
25
|
+
*
|
26
|
+
* $.cookie('the_cookie', 'the_value', {
|
27
|
+
* expires: 7,
|
28
|
+
* path: '/',
|
29
|
+
* domain: 'jquery.com',
|
30
|
+
* secure: true
|
31
|
+
* });
|
32
|
+
*
|
33
|
+
* Create a session cookie.
|
34
|
+
*
|
35
|
+
* $.cookie('the_cookie', 'the_value');
|
36
|
+
*
|
37
|
+
* Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
38
|
+
* used when the cookie was set.
|
39
|
+
*
|
40
|
+
* $.cookie('the_cookie', null);
|
41
|
+
*
|
42
|
+
* Get the value of a cookie.
|
43
|
+
*
|
44
|
+
* $.cookie('the_cookie');
|
45
|
+
*
|
46
|
+
* @param {String} [name] The name of the cookie.
|
47
|
+
* @param {String} [value] The value of the cookie.
|
48
|
+
* @param {Object} [options] An object literal containing key/value pairs to provide optional cookie attributes. Values can be:
|
49
|
+
*
|
50
|
+
* - `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.
|
51
|
+
* - `domain` - The domain name
|
52
|
+
* - `path` - The value of the path atribute of the cookie (default: path of page that created the cookie).
|
53
|
+
* - `secure` - If true, the secure attribute of the cookie will be set and the cookie transmission will require a secure protocol (like HTTPS).
|
54
|
+
*
|
55
|
+
* @return {String} the value of the cookie or {undefined} when setting the cookie.
|
56
|
+
*/
|
57
|
+
jQuery.cookie = function(name, value, options) {
|
58
|
+
if (typeof value != 'undefined') {
|
59
|
+
// name and value given, set cookie
|
60
|
+
options = options ||
|
61
|
+
{};
|
62
|
+
if (value === null) {
|
63
|
+
value = '';
|
64
|
+
options.expires = -1;
|
65
|
+
}
|
66
|
+
// convert value to JSON string
|
67
|
+
if (typeof value == 'object' && jQuery.toJSON) {
|
68
|
+
value = jQuery.toJSON(value);
|
69
|
+
}
|
70
|
+
var expires = '';
|
71
|
+
// Set expiry
|
72
|
+
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
73
|
+
var date;
|
74
|
+
if (typeof options.expires == 'number') {
|
75
|
+
date = new Date();
|
76
|
+
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
date = options.expires;
|
80
|
+
}
|
81
|
+
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
82
|
+
}
|
83
|
+
// CAUTION: Needed to parenthesize options.path and options.domain
|
84
|
+
// in the following expressions, otherwise they evaluate to undefined
|
85
|
+
// in the packed version for some reason...
|
86
|
+
var path = options.path ? '; path=' + (options.path) : '';
|
87
|
+
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
88
|
+
var secure = options.secure ? '; secure' : '';
|
89
|
+
// Set the cookie name=value;expires=;path=;domain=;secure-
|
90
|
+
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
91
|
+
}
|
92
|
+
else { // only name given, get cookie
|
93
|
+
var cookieValue = null;
|
94
|
+
if (document.cookie && document.cookie != '') {
|
95
|
+
var cookies = document.cookie.split(';');
|
96
|
+
for (var i = 0; i < cookies.length; i++) {
|
97
|
+
var cookie = jQuery.trim(cookies[i]);
|
98
|
+
// Does this cookie string begin with the name we want?
|
99
|
+
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
100
|
+
// Get the cookie value
|
101
|
+
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
// Parse JSON from the cookie into an object
|
107
|
+
if (jQuery.evalJSON && cookieValue && cookieValue.match(/^\s*\{/)) {
|
108
|
+
try {
|
109
|
+
cookieValue = jQuery.evalJSON(cookieValue);
|
110
|
+
}
|
111
|
+
catch (e) {
|
112
|
+
}
|
113
|
+
}
|
114
|
+
return cookieValue;
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
})(jQuery)
|