tres 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +67 -0
- data/README.md +50 -0
- data/Rakefile +16 -0
- data/VERSION +1 -0
- data/bin/tres +103 -0
- data/examples/anagen/anagen.coffee +61 -0
- data/examples/anagen/anagen.css +1413 -0
- data/examples/anagen/anagen.js +182 -0
- data/examples/anagen/anagen.scss +20 -0
- data/examples/anagen/backbone-min.js +38 -0
- data/examples/anagen/index.html +50 -0
- data/examples/anagen/jquery-1.8.0.min.js +2 -0
- data/examples/anagen/templates.coffee +6 -0
- data/examples/anagen/templates.js +13 -0
- data/examples/anagen/tres.js +375 -0
- data/examples/anagen/underscore-min.js +32 -0
- data/font/fontawesome-webfont.eot +0 -0
- data/font/fontawesome-webfont.svg +255 -0
- data/font/fontawesome-webfont.ttf +0 -0
- data/font/fontawesome-webfont.woff +0 -0
- data/javascripts/backbone-min.js +38 -0
- data/javascripts/jquery-1.8.0.min.js +2 -0
- data/javascripts/tres.coffee +210 -0
- data/javascripts/underscore-min.js +32 -0
- data/lib/ext/.filemethods.rb.swp +0 -0
- data/lib/ext/filemethods.rb +109 -0
- data/lib/ext/string.rb +33 -0
- data/lib/tres/app.rb +92 -0
- data/lib/tres/asset_packager.rb +45 -0
- data/lib/tres/errors.rb +6 -0
- data/lib/tres/logger.rb +9 -0
- data/lib/tres/rack_logger.rb +37 -0
- data/lib/tres/server.rb +50 -0
- data/lib/tres/template_compiler.rb +113 -0
- data/lib/tres.rb +64 -0
- data/sass/font-awesome.scss +329 -0
- data/sass/tres/base.scss +131 -0
- data/sass/tres/themes/default.scss +71 -0
- data/spec/app_spec.rb +44 -0
- data/spec/asset_packager_spec.rb +74 -0
- data/spec/filemethods_spec.rb +84 -0
- data/spec/fixtures/index.haml +41 -0
- data/spec/fixtures/index.html +50 -0
- data/spec/sample/assets/javascripts/all.coffee +12 -0
- data/spec/sample/assets/javascripts/anagen.coffee +7 -0
- data/spec/sample/assets/javascripts/backbone-min.js +38 -0
- data/spec/sample/assets/javascripts/jquery-1.8.0.min.js +2 -0
- data/spec/sample/assets/javascripts/underscore-min.js +32 -0
- data/spec/sample/assets/stylesheets/app.scss +7 -0
- data/spec/sample/assets/stylesheets/with_imports.scss +10 -0
- data/spec/sample/templates/article.html +0 -0
- data/spec/sample/templates/book.haml +4 -0
- data/spec/sample/templates/books/li.haml +2 -0
- data/spec/sample/templates/index.html +50 -0
- data/spec/server_spec.rb +35 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/template_compiler_spec.rb +96 -0
- data/templates/all.coffee +21 -0
- data/templates/all.scss +11 -0
- data/templates/app.coffee +10 -0
- data/templates/collection_script.coffee.erb +6 -0
- data/templates/config.ru +3 -0
- data/templates/home.coffee +7 -0
- data/templates/home.haml +17 -0
- data/templates/index.html +15 -0
- data/templates/model_script.coffee.erb +3 -0
- data/templates/screen_script.coffee.erb +5 -0
- data/templates/templates.js +2 -0
- data/tres.gemspec +29 -0
- metadata +257 -0
@@ -0,0 +1,375 @@
|
|
1
|
+
(function() {
|
2
|
+
var $, $body, $window, Backbone, Device, JST, Router, Tres, defaultTemplate, make, _,
|
3
|
+
__hasProp = {}.hasOwnProperty,
|
4
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
5
|
+
|
6
|
+
Tres = {};
|
7
|
+
|
8
|
+
$ = window.jQuery;
|
9
|
+
|
10
|
+
_ = window._;
|
11
|
+
|
12
|
+
Backbone = window.Backbone;
|
13
|
+
|
14
|
+
JST = window.JST;
|
15
|
+
|
16
|
+
$window = $(window);
|
17
|
+
|
18
|
+
$body = $('body');
|
19
|
+
|
20
|
+
make = Backbone.View.prototype.make;
|
21
|
+
|
22
|
+
defaultTemplate = _.template("<header></header>\n<h1>Tres</h1>\n<p>Welcome to Tres</p>");
|
23
|
+
|
24
|
+
Device = (function() {
|
25
|
+
|
26
|
+
function Device() {
|
27
|
+
_.extend(this, Backbone.Events);
|
28
|
+
$window.on('orientationchange', _.bind(this.trigger, this, 'orientation:change'));
|
29
|
+
}
|
30
|
+
|
31
|
+
Device.prototype.width = function() {
|
32
|
+
return window.outerWidth;
|
33
|
+
};
|
34
|
+
|
35
|
+
Device.prototype.height = function() {
|
36
|
+
return window.outerHeight;
|
37
|
+
};
|
38
|
+
|
39
|
+
Device.prototype.orientation = function() {};
|
40
|
+
|
41
|
+
return Device;
|
42
|
+
|
43
|
+
})();
|
44
|
+
|
45
|
+
Tres.Device = new Device;
|
46
|
+
|
47
|
+
Tres.Screen = (function(_super) {
|
48
|
+
|
49
|
+
__extends(Screen, _super);
|
50
|
+
|
51
|
+
function Screen() {
|
52
|
+
return Screen.__super__.constructor.apply(this, arguments);
|
53
|
+
}
|
54
|
+
|
55
|
+
Screen.prototype.tagName = 'section';
|
56
|
+
|
57
|
+
Screen.prototype.__events = {
|
58
|
+
"click a[href]:not('.outlink')": 'touchLink',
|
59
|
+
"submit form": '__submit'
|
60
|
+
};
|
61
|
+
|
62
|
+
Screen.prototype.events = {};
|
63
|
+
|
64
|
+
Screen.prototype.initialize = function(options) {
|
65
|
+
if (options == null) {
|
66
|
+
options = {};
|
67
|
+
}
|
68
|
+
return _.extend(this, options);
|
69
|
+
};
|
70
|
+
|
71
|
+
Screen.prototype.title = function(title) {
|
72
|
+
if (title == null) {
|
73
|
+
title = null;
|
74
|
+
}
|
75
|
+
if (title != null) {
|
76
|
+
return this.$el.find('h1').html(title);
|
77
|
+
} else {
|
78
|
+
return this.$el.find('h1').html();
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
Screen.prototype.render = function() {
|
83
|
+
this.$el.html((this.template || defaultTemplate)(this.model));
|
84
|
+
this.delegateEvents(_.extend(this.events, this.__events));
|
85
|
+
return this;
|
86
|
+
};
|
87
|
+
|
88
|
+
Screen.prototype.embed = function() {
|
89
|
+
if (this.embedded) {
|
90
|
+
return false;
|
91
|
+
}
|
92
|
+
this.render();
|
93
|
+
$body.append(this.el);
|
94
|
+
this.embedded = true;
|
95
|
+
return this;
|
96
|
+
};
|
97
|
+
|
98
|
+
Screen.prototype.touchLink = function(event) {
|
99
|
+
event.preventDefault();
|
100
|
+
return Tres.Router.navigate($(event.currentTarget).attr('href'), true);
|
101
|
+
};
|
102
|
+
|
103
|
+
Screen.prototype.__submit = function(event) {
|
104
|
+
this.submit.apply(this, arguments);
|
105
|
+
return this.$el.find(':focus').blur();
|
106
|
+
};
|
107
|
+
|
108
|
+
Screen.prototype.submit = function() {};
|
109
|
+
|
110
|
+
Screen.prototype.activate = function() {
|
111
|
+
$body.find('>section').removeClass('current');
|
112
|
+
this.$el.addClass('current');
|
113
|
+
if (_.isFunction(this.active)) {
|
114
|
+
return this.active.apply(this, arguments);
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
return Screen;
|
119
|
+
|
120
|
+
})(Backbone.View);
|
121
|
+
|
122
|
+
Tres.ListEntry = (function(_super) {
|
123
|
+
|
124
|
+
__extends(ListEntry, _super);
|
125
|
+
|
126
|
+
function ListEntry() {
|
127
|
+
return ListEntry.__super__.constructor.apply(this, arguments);
|
128
|
+
}
|
129
|
+
|
130
|
+
ListEntry.prototype.initialize = function(options) {
|
131
|
+
if (options == null) {
|
132
|
+
options = {};
|
133
|
+
}
|
134
|
+
return _.extend(this, options);
|
135
|
+
};
|
136
|
+
|
137
|
+
ListEntry.prototype.render = function() {
|
138
|
+
this.$el.html(this.template(this.model));
|
139
|
+
if (_.isFunction(this.url)) {
|
140
|
+
this.delegateEvents({
|
141
|
+
'click': 'touch'
|
142
|
+
});
|
143
|
+
}
|
144
|
+
return this;
|
145
|
+
};
|
146
|
+
|
147
|
+
ListEntry.prototype.touch = function(event) {
|
148
|
+
return Tres.Router.navigate(this.url(), true);
|
149
|
+
};
|
150
|
+
|
151
|
+
return ListEntry;
|
152
|
+
|
153
|
+
})(Backbone.View);
|
154
|
+
|
155
|
+
Tres.List = (function(_super) {
|
156
|
+
|
157
|
+
__extends(List, _super);
|
158
|
+
|
159
|
+
function List() {
|
160
|
+
return List.__super__.constructor.apply(this, arguments);
|
161
|
+
}
|
162
|
+
|
163
|
+
List.prototype._tagMap = {
|
164
|
+
'UL': 'LI',
|
165
|
+
'OL': 'LI',
|
166
|
+
'DIV': 'DIV'
|
167
|
+
};
|
168
|
+
|
169
|
+
List.prototype.initialize = function(options) {
|
170
|
+
if (options == null) {
|
171
|
+
options = {};
|
172
|
+
}
|
173
|
+
_.extend(this, options);
|
174
|
+
this.setElement(this.el);
|
175
|
+
this.collection.on('add', this.__add, this);
|
176
|
+
this.collection.on('remove', this.__remove, this);
|
177
|
+
return this.collection.on('reset', this.__addAll, this);
|
178
|
+
};
|
179
|
+
|
180
|
+
List.prototype.__add = function(model) {
|
181
|
+
var tag, template;
|
182
|
+
tag = this.entry.tagName || this._tagMap[this.$el.get(0).tagName];
|
183
|
+
template = new Tres.ListEntry(_.extend(this.entry, {
|
184
|
+
tagName: tag,
|
185
|
+
model: model
|
186
|
+
}));
|
187
|
+
model.template = template;
|
188
|
+
return this.$el.append(template.render().el);
|
189
|
+
};
|
190
|
+
|
191
|
+
List.prototype.__remove = function(model) {
|
192
|
+
return model.template.remove();
|
193
|
+
};
|
194
|
+
|
195
|
+
List.prototype.__addAll = function() {
|
196
|
+
var _this = this;
|
197
|
+
this.$el.empty();
|
198
|
+
return this.collection.each(function(model) {
|
199
|
+
return _this.__add(model);
|
200
|
+
});
|
201
|
+
};
|
202
|
+
|
203
|
+
List.prototype.remove = function() {
|
204
|
+
if (this.collection != null) {
|
205
|
+
this.collection.off();
|
206
|
+
}
|
207
|
+
return List.__super__.remove.apply(this, arguments);
|
208
|
+
};
|
209
|
+
|
210
|
+
return List;
|
211
|
+
|
212
|
+
})(Backbone.View);
|
213
|
+
|
214
|
+
Tres.Form = (function() {
|
215
|
+
|
216
|
+
function Form($el) {
|
217
|
+
this.$el = $el;
|
218
|
+
}
|
219
|
+
|
220
|
+
Form.prototype.fieldset = function(filter) {
|
221
|
+
return new Tres.Form(this.$el.find('fieldset').filter(filter));
|
222
|
+
};
|
223
|
+
|
224
|
+
Form.prototype.attributes = function(options) {
|
225
|
+
var attributes, inputs;
|
226
|
+
if (options == null) {
|
227
|
+
options = {};
|
228
|
+
}
|
229
|
+
attributes = {};
|
230
|
+
if (options.only != null) {
|
231
|
+
inputs = this.$el.find("" + options.only + " :input[name]");
|
232
|
+
} else {
|
233
|
+
inputs = this.$el.find(':input[name]');
|
234
|
+
_.each(inputs, function(el) {
|
235
|
+
var $el;
|
236
|
+
$el = $(el);
|
237
|
+
if ($el.is(':checkbox')) {
|
238
|
+
return attributes[$el.attr('name')] = $el.is(':checked');
|
239
|
+
} else {
|
240
|
+
return attributes[$el.attr('name')] = $el.val();
|
241
|
+
}
|
242
|
+
});
|
243
|
+
}
|
244
|
+
return attributes;
|
245
|
+
};
|
246
|
+
|
247
|
+
Form.prototype.setFromModel = function(model) {
|
248
|
+
var _this = this;
|
249
|
+
return _.each(_.keys(model.attributes), function(key) {
|
250
|
+
var $el;
|
251
|
+
$el = _this.$el.find("[name=\"" + key + "\"]");
|
252
|
+
if ($el.is(':checkbox') && model.attributes[key] === true) {
|
253
|
+
return $el.attr('checked', 'checked');
|
254
|
+
} else {
|
255
|
+
return $el.val(model.attributes[key]);
|
256
|
+
}
|
257
|
+
});
|
258
|
+
};
|
259
|
+
|
260
|
+
Form.prototype.clear = function() {
|
261
|
+
_.each(this.$el.find(':input'), function(el) {
|
262
|
+
var $el;
|
263
|
+
$el = $(el);
|
264
|
+
if ($el.is(':checkbox')) {
|
265
|
+
$el.removeAttr('checked');
|
266
|
+
}
|
267
|
+
return $el.val('');
|
268
|
+
});
|
269
|
+
return this;
|
270
|
+
};
|
271
|
+
|
272
|
+
return Form;
|
273
|
+
|
274
|
+
})();
|
275
|
+
|
276
|
+
Tres.Notifier = {
|
277
|
+
$el: $(make('ul', {
|
278
|
+
id: 'notifications'
|
279
|
+
})),
|
280
|
+
notify: function(message, options) {
|
281
|
+
var $li,
|
282
|
+
_this = this;
|
283
|
+
if (options == null) {
|
284
|
+
options = {
|
285
|
+
duration: 5000,
|
286
|
+
type: 'exclamation-sign'
|
287
|
+
};
|
288
|
+
}
|
289
|
+
this.$el.appendTo($body);
|
290
|
+
$li = $(make('li', {
|
291
|
+
"class": "icon-" + options.type
|
292
|
+
}, message));
|
293
|
+
this.$el.append($li);
|
294
|
+
return $li.slideDown(250, function() {
|
295
|
+
return _.delay(function() {
|
296
|
+
return $li.slideUp(function() {
|
297
|
+
return $li.remove();
|
298
|
+
});
|
299
|
+
}, options.duration);
|
300
|
+
});
|
301
|
+
}
|
302
|
+
};
|
303
|
+
|
304
|
+
Router = (function(_super) {
|
305
|
+
|
306
|
+
__extends(Router, _super);
|
307
|
+
|
308
|
+
function Router() {
|
309
|
+
return Router.__super__.constructor.apply(this, arguments);
|
310
|
+
}
|
311
|
+
|
312
|
+
return Router;
|
313
|
+
|
314
|
+
})(Backbone.Router);
|
315
|
+
|
316
|
+
Tres.Router = new Router;
|
317
|
+
|
318
|
+
Tres.App = (function() {
|
319
|
+
|
320
|
+
function App(options) {
|
321
|
+
if (options == null) {
|
322
|
+
options = {};
|
323
|
+
}
|
324
|
+
_.extend(this, options);
|
325
|
+
}
|
326
|
+
|
327
|
+
App.prototype.screens = [];
|
328
|
+
|
329
|
+
App.prototype.on = function(map) {
|
330
|
+
var _this = this;
|
331
|
+
if (map == null) {
|
332
|
+
map = {};
|
333
|
+
}
|
334
|
+
return _.each(_.keys(map), function(url) {
|
335
|
+
return Tres.Router.route(url, _.uniqueId('r'), function() {
|
336
|
+
var args, screen;
|
337
|
+
screen = map[url];
|
338
|
+
if (screen.embedded !== true) {
|
339
|
+
screen.embed();
|
340
|
+
}
|
341
|
+
args = arguments;
|
342
|
+
return _.defer(function() {
|
343
|
+
return screen.activate.apply(screen, args);
|
344
|
+
});
|
345
|
+
});
|
346
|
+
});
|
347
|
+
};
|
348
|
+
|
349
|
+
App.prototype.boot = function(options) {
|
350
|
+
var __super,
|
351
|
+
_this = this;
|
352
|
+
if (options == null) {
|
353
|
+
options = {};
|
354
|
+
}
|
355
|
+
__super = Backbone.history.loadUrl;
|
356
|
+
Backbone.history.loadUrl = function() {
|
357
|
+
if (_.isFunction(Tres.Router.before)) {
|
358
|
+
Tres.Router.before.call(_this);
|
359
|
+
}
|
360
|
+
Tres.Router.trigger('navigate');
|
361
|
+
window.scroll(0, 0);
|
362
|
+
return __super.apply(Backbone.history, arguments);
|
363
|
+
};
|
364
|
+
return Backbone.history.start(_.extend(options, {
|
365
|
+
pushState: true
|
366
|
+
}));
|
367
|
+
};
|
368
|
+
|
369
|
+
return App;
|
370
|
+
|
371
|
+
})();
|
372
|
+
|
373
|
+
window.Tres = Tres;
|
374
|
+
|
375
|
+
}).call(this);
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Underscore.js 1.3.3
|
2
|
+
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
3
|
+
// Underscore is freely distributable under the MIT license.
|
4
|
+
// Portions of Underscore are inspired or borrowed from Prototype,
|
5
|
+
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
6
|
+
// For all details and documentation:
|
7
|
+
// http://documentcloud.github.com/underscore
|
8
|
+
(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
|
9
|
+
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
|
10
|
+
g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
|
11
|
+
c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
|
12
|
+
a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
|
13
|
+
c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
|
14
|
+
a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
|
15
|
+
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
|
16
|
+
(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
|
17
|
+
j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
|
18
|
+
0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
|
19
|
+
e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
|
20
|
+
i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
|
21
|
+
1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
|
22
|
+
i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
|
23
|
+
g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
|
24
|
+
return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
|
25
|
+
c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
|
26
|
+
function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
|
27
|
+
b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
|
28
|
+
b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
|
29
|
+
function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
|
30
|
+
u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
|
31
|
+
b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
|
32
|
+
this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
|
Binary file
|