frontend-helpers 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +59 -58
- data/README.md +8 -0
- data/Rakefile +1 -1
- data/app/views/layouts/mail.html.haml +54 -0
- data/frontend-helpers.gemspec +29 -26
- data/lib/generators/frontend/install/install_generator.rb +5 -0
- data/vendor/assets/javascripts/backbone/authtoken.js +58 -0
- data/vendor/assets/javascripts/backbone/backbone.js +25 -16
- data/vendor/assets/javascripts/backbone/index.js +2 -1
- data/vendor/assets/javascripts/backbone/underscore.js +49 -17
- data/vendor/assets/javascripts/jquery.cookie.js +42 -35
- data/vendor/assets/javascripts/jquery.slides.js +538 -31
- data/vendor/assets/stylesheets/fancybox.css.scss +17 -17
- metadata +26 -23
@@ -1,4 +1,4 @@
|
|
1
|
-
// Underscore.js 1.1.
|
1
|
+
// Underscore.js 1.1.7
|
2
2
|
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
|
3
3
|
// Underscore is freely distributable under the MIT license.
|
4
4
|
// Portions of Underscore are inspired or borrowed from Prototype,
|
@@ -55,25 +55,26 @@
|
|
55
55
|
module.exports = _;
|
56
56
|
_._ = _;
|
57
57
|
} else {
|
58
|
-
|
58
|
+
// Exported as a string, for Closure Compiler "advanced" mode.
|
59
|
+
root['_'] = _;
|
59
60
|
}
|
60
61
|
|
61
62
|
// Current version.
|
62
|
-
_.VERSION = '1.1.
|
63
|
+
_.VERSION = '1.1.7';
|
63
64
|
|
64
65
|
// Collection Functions
|
65
66
|
// --------------------
|
66
67
|
|
67
68
|
// The cornerstone, an `each` implementation, aka `forEach`.
|
68
|
-
// Handles objects
|
69
|
+
// Handles objects with the built-in `forEach`, arrays, and raw objects.
|
69
70
|
// Delegates to **ECMAScript 5**'s native `forEach` if available.
|
70
71
|
var each = _.each = _.forEach = function(obj, iterator, context) {
|
71
72
|
if (obj == null) return;
|
72
73
|
if (nativeForEach && obj.forEach === nativeForEach) {
|
73
74
|
obj.forEach(iterator, context);
|
74
|
-
} else if (
|
75
|
+
} else if (obj.length === +obj.length) {
|
75
76
|
for (var i = 0, l = obj.length; i < l; i++) {
|
76
|
-
if (iterator.call(context, obj[i], i, obj) === breaker) return;
|
77
|
+
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
|
77
78
|
}
|
78
79
|
} else {
|
79
80
|
for (var key in obj) {
|
@@ -106,7 +107,7 @@
|
|
106
107
|
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
|
107
108
|
}
|
108
109
|
each(obj, function(value, index, list) {
|
109
|
-
if (!initial
|
110
|
+
if (!initial) {
|
110
111
|
memo = value;
|
111
112
|
initial = true;
|
112
113
|
} else {
|
@@ -181,14 +182,14 @@
|
|
181
182
|
// Delegates to **ECMAScript 5**'s native `some` if available.
|
182
183
|
// Aliased as `any`.
|
183
184
|
var any = _.some = _.any = function(obj, iterator, context) {
|
184
|
-
iterator
|
185
|
+
iterator = iterator || _.identity;
|
185
186
|
var result = false;
|
186
187
|
if (obj == null) return result;
|
187
188
|
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
|
188
189
|
each(obj, function(value, index, list) {
|
189
|
-
if (result
|
190
|
+
if (result |= iterator.call(context, value, index, list)) return breaker;
|
190
191
|
});
|
191
|
-
return result;
|
192
|
+
return !!result;
|
192
193
|
};
|
193
194
|
|
194
195
|
// Determine if a given value is included in the array or object using `===`.
|
@@ -251,6 +252,16 @@
|
|
251
252
|
}), 'value');
|
252
253
|
};
|
253
254
|
|
255
|
+
// Groups the object's values by a criterion produced by an iterator
|
256
|
+
_.groupBy = function(obj, iterator) {
|
257
|
+
var result = {};
|
258
|
+
each(obj, function(value, index) {
|
259
|
+
var key = iterator(value, index);
|
260
|
+
(result[key] || (result[key] = [])).push(value);
|
261
|
+
});
|
262
|
+
return result;
|
263
|
+
};
|
264
|
+
|
254
265
|
// Use a comparator function to figure out at what index an object should
|
255
266
|
// be inserted so as to maintain order. Uses binary search.
|
256
267
|
_.sortedIndex = function(array, obj, iterator) {
|
@@ -267,7 +278,7 @@
|
|
267
278
|
_.toArray = function(iterable) {
|
268
279
|
if (!iterable) return [];
|
269
280
|
if (iterable.toArray) return iterable.toArray();
|
270
|
-
if (_.isArray(iterable)) return iterable;
|
281
|
+
if (_.isArray(iterable)) return slice.call(iterable);
|
271
282
|
if (_.isArguments(iterable)) return slice.call(iterable);
|
272
283
|
return _.values(iterable);
|
273
284
|
};
|
@@ -316,8 +327,7 @@
|
|
316
327
|
|
317
328
|
// Return a version of the array that does not contain the specified value(s).
|
318
329
|
_.without = function(array) {
|
319
|
-
|
320
|
-
return _.filter(array, function(value){ return !_.include(values, value); });
|
330
|
+
return _.difference(array, slice.call(arguments, 1));
|
321
331
|
};
|
322
332
|
|
323
333
|
// Produce a duplicate-free version of the array. If the array has already
|
@@ -330,9 +340,15 @@
|
|
330
340
|
}, []);
|
331
341
|
};
|
332
342
|
|
343
|
+
// Produce an array that contains the union: each distinct element from all of
|
344
|
+
// the passed-in arrays.
|
345
|
+
_.union = function() {
|
346
|
+
return _.uniq(_.flatten(arguments));
|
347
|
+
};
|
348
|
+
|
333
349
|
// Produce an array that contains every item shared between all the
|
334
|
-
// passed-in arrays.
|
335
|
-
_.intersect = function(array) {
|
350
|
+
// passed-in arrays. (Aliased as "intersect" for back-compat.)
|
351
|
+
_.intersection = _.intersect = function(array) {
|
336
352
|
var rest = slice.call(arguments, 1);
|
337
353
|
return _.filter(_.uniq(array), function(item) {
|
338
354
|
return _.every(rest, function(other) {
|
@@ -341,6 +357,12 @@
|
|
341
357
|
});
|
342
358
|
};
|
343
359
|
|
360
|
+
// Take the difference between one array and another.
|
361
|
+
// Only the elements present in just the first array will remain.
|
362
|
+
_.difference = function(array, other) {
|
363
|
+
return _.filter(array, function(value){ return !_.include(other, value); });
|
364
|
+
};
|
365
|
+
|
344
366
|
// Zip together multiple lists into a single array -- elements that share
|
345
367
|
// an index go together.
|
346
368
|
_.zip = function() {
|
@@ -502,7 +524,7 @@
|
|
502
524
|
var funcs = slice.call(arguments);
|
503
525
|
return function() {
|
504
526
|
var args = slice.call(arguments);
|
505
|
-
for (var i=funcs.length-1; i >= 0; i--) {
|
527
|
+
for (var i = funcs.length - 1; i >= 0; i--) {
|
506
528
|
args = [funcs[i].apply(this, args)];
|
507
529
|
}
|
508
530
|
return args[0];
|
@@ -537,7 +559,11 @@
|
|
537
559
|
// Return a sorted list of the function names available on the object.
|
538
560
|
// Aliased as `methods`
|
539
561
|
_.functions = _.methods = function(obj) {
|
540
|
-
|
562
|
+
var names = [];
|
563
|
+
for (var key in obj) {
|
564
|
+
if (_.isFunction(obj[key])) names.push(key);
|
565
|
+
}
|
566
|
+
return names.sort();
|
541
567
|
};
|
542
568
|
|
543
569
|
// Extend a given object with all the properties in passed-in object(s).
|
@@ -589,6 +615,7 @@
|
|
589
615
|
if (b._chain) b = b._wrapped;
|
590
616
|
// One of them implements an isEqual()?
|
591
617
|
if (a.isEqual) return a.isEqual(b);
|
618
|
+
if (b.isEqual) return b.isEqual(a);
|
592
619
|
// Check dates' integer values.
|
593
620
|
if (_.isDate(a) && _.isDate(b)) return a.getTime() === b.getTime();
|
594
621
|
// Both are NaN?
|
@@ -630,6 +657,11 @@
|
|
630
657
|
return toString.call(obj) === '[object Array]';
|
631
658
|
};
|
632
659
|
|
660
|
+
// Is a given variable an object?
|
661
|
+
_.isObject = function(obj) {
|
662
|
+
return obj === Object(obj);
|
663
|
+
};
|
664
|
+
|
633
665
|
// Is a given variable an arguments object?
|
634
666
|
_.isArguments = function(obj) {
|
635
667
|
return !!(obj && hasOwnProperty.call(obj, 'callee'));
|
@@ -1,19 +1,15 @@
|
|
1
|
-
/*jslint browser: true */ /*global jQuery: true */
|
2
|
-
|
3
1
|
/**
|
4
|
-
*
|
2
|
+
* Cookie plugin
|
5
3
|
*
|
6
|
-
* Copyright (c)
|
4
|
+
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
7
5
|
* Dual licensed under the MIT and GPL licenses:
|
8
6
|
* http://www.opensource.org/licenses/mit-license.php
|
9
7
|
* http://www.gnu.org/licenses/gpl.html
|
10
8
|
*
|
11
9
|
*/
|
12
10
|
|
13
|
-
// JsDoc
|
14
|
-
|
15
11
|
/**
|
16
|
-
* Create a cookie with the given
|
12
|
+
* Create a cookie with the given name and value and other optional parameters.
|
17
13
|
*
|
18
14
|
* @example $.cookie('the_cookie', 'the_value');
|
19
15
|
* @desc Set the value of a cookie.
|
@@ -25,7 +21,7 @@
|
|
25
21
|
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
26
22
|
* used when the cookie was set.
|
27
23
|
*
|
28
|
-
* @param String
|
24
|
+
* @param String name The name of the cookie.
|
29
25
|
* @param String value The value of the cookie.
|
30
26
|
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
31
27
|
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
@@ -44,12 +40,12 @@
|
|
44
40
|
*/
|
45
41
|
|
46
42
|
/**
|
47
|
-
* Get the value of a cookie with the given
|
43
|
+
* Get the value of a cookie with the given name.
|
48
44
|
*
|
49
45
|
* @example $.cookie('the_cookie');
|
50
46
|
* @desc Get the value of a cookie.
|
51
47
|
*
|
52
|
-
* @param String
|
48
|
+
* @param String name The name of the cookie.
|
53
49
|
* @return The value of the cookie.
|
54
50
|
* @type String
|
55
51
|
*
|
@@ -57,33 +53,44 @@
|
|
57
53
|
* @cat Plugins/Cookie
|
58
54
|
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
59
55
|
*/
|
60
|
-
jQuery.cookie = function
|
61
|
-
|
62
|
-
|
63
|
-
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
|
64
|
-
options = jQuery.extend({}, options);
|
65
|
-
|
56
|
+
jQuery.cookie = function(name, value, options) {
|
57
|
+
if (typeof value != 'undefined') { // name and value given, set cookie
|
58
|
+
options = options || {};
|
66
59
|
if (value === null) {
|
60
|
+
value = '';
|
67
61
|
options.expires = -1;
|
68
62
|
}
|
69
|
-
|
70
|
-
if (typeof options.expires
|
71
|
-
var
|
72
|
-
|
63
|
+
var expires = '';
|
64
|
+
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
65
|
+
var date;
|
66
|
+
if (typeof options.expires == 'number') {
|
67
|
+
date = new Date();
|
68
|
+
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
69
|
+
} else {
|
70
|
+
date = options.expires;
|
71
|
+
}
|
72
|
+
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
73
73
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
74
|
+
// CAUTION: Needed to parenthesize options.path and options.domain
|
75
|
+
// in the following expressions, otherwise they evaluate to undefined
|
76
|
+
// in the packed version for some reason...
|
77
|
+
var path = options.path ? '; path=' + (options.path) : '';
|
78
|
+
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
79
|
+
var secure = options.secure ? '; secure' : '';
|
80
|
+
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
81
|
+
} else { // only name given, get cookie
|
82
|
+
var cookieValue = null;
|
83
|
+
if (document.cookie && document.cookie != '') {
|
84
|
+
var cookies = document.cookie.split(';');
|
85
|
+
for (var i = 0; i < cookies.length; i++) {
|
86
|
+
var cookie = jQuery.trim(cookies[i]);
|
87
|
+
// Does this cookie string begin with the name we want?
|
88
|
+
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
89
|
+
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return cookieValue;
|
83
95
|
}
|
84
|
-
|
85
|
-
// key and possibly options given, get cookie...
|
86
|
-
options = value || {};
|
87
|
-
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
|
88
|
-
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
|
89
|
-
};
|
96
|
+
};
|