spine_paginator 0.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/.gitignore +22 -0
- data/Gemfile +4 -0
- data/Gruntfile.coffee +52 -0
- data/LICENSE-MIT +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/component.json +21 -0
- data/dist/.gitkeep +0 -0
- data/dist/spine.paginator.js +271 -0
- data/dist/spine.paginator.min.js +5 -0
- data/lib/spine_paginator/railtie.rb +11 -0
- data/lib/spine_paginator/version.rb +3 -0
- data/lib/spine_paginator.rb +9 -0
- data/package.json +32 -0
- data/spec/lib/.gitkeep +0 -0
- data/spec/lib/spine.js +1184 -0
- data/spec/spine.paginator/.gitkeep +0 -0
- data/spine_paginator.gemspec +19 -0
- data/src/spine.paginator.coffee +199 -0
- metadata +68 -0
data/spec/lib/spine.js
ADDED
@@ -0,0 +1,1184 @@
|
|
1
|
+
// Generated by CoffeeScript 1.6.2
|
2
|
+
(function() {
|
3
|
+
var $, Controller, Events, Log, Model, Module, Spine, createObject, isArray, isBlank, makeArray, moduleKeywords,
|
4
|
+
__slice = [].slice,
|
5
|
+
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
6
|
+
__hasProp = {}.hasOwnProperty,
|
7
|
+
__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; },
|
8
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
9
|
+
|
10
|
+
Events = {
|
11
|
+
bind: function(ev, callback) {
|
12
|
+
var calls, evs, name, _i, _len;
|
13
|
+
|
14
|
+
evs = ev.split(' ');
|
15
|
+
calls = this.hasOwnProperty('_callbacks') && this._callbacks || (this._callbacks = {});
|
16
|
+
for (_i = 0, _len = evs.length; _i < _len; _i++) {
|
17
|
+
name = evs[_i];
|
18
|
+
calls[name] || (calls[name] = []);
|
19
|
+
calls[name].push(callback);
|
20
|
+
}
|
21
|
+
return this;
|
22
|
+
},
|
23
|
+
one: function(ev, callback) {
|
24
|
+
var handler;
|
25
|
+
|
26
|
+
return this.bind(ev, handler = function() {
|
27
|
+
this.unbind(ev, handler);
|
28
|
+
return callback.apply(this, arguments);
|
29
|
+
});
|
30
|
+
},
|
31
|
+
trigger: function() {
|
32
|
+
var args, callback, ev, list, _i, _len, _ref;
|
33
|
+
|
34
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
35
|
+
ev = args.shift();
|
36
|
+
list = this.hasOwnProperty('_callbacks') && ((_ref = this._callbacks) != null ? _ref[ev] : void 0);
|
37
|
+
if (!list) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
for (_i = 0, _len = list.length; _i < _len; _i++) {
|
41
|
+
callback = list[_i];
|
42
|
+
if (callback.apply(this, args) === false) {
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return true;
|
47
|
+
},
|
48
|
+
listenTo: function(obj, ev, callback) {
|
49
|
+
obj.bind(ev, callback);
|
50
|
+
this.listeningTo || (this.listeningTo = []);
|
51
|
+
this.listeningTo.push(obj);
|
52
|
+
return this;
|
53
|
+
},
|
54
|
+
listenToOnce: function(obj, ev, callback) {
|
55
|
+
var listeningToOnce;
|
56
|
+
|
57
|
+
listeningToOnce = this.listeningToOnce || (this.listeningToOnce = []);
|
58
|
+
listeningToOnce.push(obj);
|
59
|
+
obj.one(ev, function() {
|
60
|
+
var idx;
|
61
|
+
|
62
|
+
idx = listeningToOnce.indexOf(obj);
|
63
|
+
if (idx !== -1) {
|
64
|
+
listeningToOnce.splice(idx, 1);
|
65
|
+
}
|
66
|
+
return callback.apply(this, arguments);
|
67
|
+
});
|
68
|
+
return this;
|
69
|
+
},
|
70
|
+
stopListening: function(obj, ev, callback) {
|
71
|
+
var idx, listeningTo, retain, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _results;
|
72
|
+
|
73
|
+
if (arguments.length === 0) {
|
74
|
+
retain = [];
|
75
|
+
_ref = [this.listeningTo, this.listeningToOnce];
|
76
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
77
|
+
listeningTo = _ref[_i];
|
78
|
+
if (!listeningTo) {
|
79
|
+
continue;
|
80
|
+
}
|
81
|
+
for (_j = 0, _len1 = listeningTo.length; _j < _len1; _j++) {
|
82
|
+
obj = listeningTo[_j];
|
83
|
+
if (!(!(__indexOf.call(retain, obj) >= 0))) {
|
84
|
+
continue;
|
85
|
+
}
|
86
|
+
obj.unbind();
|
87
|
+
retain.push(obj);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
this.listeningTo = void 0;
|
91
|
+
return this.listeningToOnce = void 0;
|
92
|
+
} else if (obj) {
|
93
|
+
if (ev) {
|
94
|
+
obj.unbind(ev, callback);
|
95
|
+
}
|
96
|
+
if (!ev) {
|
97
|
+
obj.unbind();
|
98
|
+
}
|
99
|
+
_ref1 = [this.listeningTo, this.listeningToOnce];
|
100
|
+
_results = [];
|
101
|
+
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
|
102
|
+
listeningTo = _ref1[_k];
|
103
|
+
if (!listeningTo) {
|
104
|
+
continue;
|
105
|
+
}
|
106
|
+
idx = listeningTo.indexOf(obj);
|
107
|
+
if (idx !== -1) {
|
108
|
+
_results.push(listeningTo.splice(idx, 1));
|
109
|
+
} else {
|
110
|
+
_results.push(void 0);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
return _results;
|
114
|
+
}
|
115
|
+
},
|
116
|
+
unbind: function(ev, callback) {
|
117
|
+
var cb, evs, i, list, name, _i, _j, _len, _len1, _ref;
|
118
|
+
|
119
|
+
if (arguments.length === 0) {
|
120
|
+
this._callbacks = {};
|
121
|
+
return this;
|
122
|
+
}
|
123
|
+
if (!ev) {
|
124
|
+
return this;
|
125
|
+
}
|
126
|
+
evs = ev.split(' ');
|
127
|
+
for (_i = 0, _len = evs.length; _i < _len; _i++) {
|
128
|
+
name = evs[_i];
|
129
|
+
list = (_ref = this._callbacks) != null ? _ref[name] : void 0;
|
130
|
+
if (!list) {
|
131
|
+
continue;
|
132
|
+
}
|
133
|
+
if (!callback) {
|
134
|
+
delete this._callbacks[name];
|
135
|
+
continue;
|
136
|
+
}
|
137
|
+
for (i = _j = 0, _len1 = list.length; _j < _len1; i = ++_j) {
|
138
|
+
cb = list[i];
|
139
|
+
if (!(cb === callback)) {
|
140
|
+
continue;
|
141
|
+
}
|
142
|
+
list = list.slice();
|
143
|
+
list.splice(i, 1);
|
144
|
+
this._callbacks[name] = list;
|
145
|
+
break;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
return this;
|
149
|
+
}
|
150
|
+
};
|
151
|
+
|
152
|
+
Events.on = Events.bind;
|
153
|
+
|
154
|
+
Events.off = Events.unbind;
|
155
|
+
|
156
|
+
Log = {
|
157
|
+
trace: true,
|
158
|
+
logPrefix: '(App)',
|
159
|
+
log: function() {
|
160
|
+
var args;
|
161
|
+
|
162
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
163
|
+
if (!this.trace) {
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
if (this.logPrefix) {
|
167
|
+
args.unshift(this.logPrefix);
|
168
|
+
}
|
169
|
+
if (typeof console !== "undefined" && console !== null) {
|
170
|
+
if (typeof console.log === "function") {
|
171
|
+
console.log.apply(console, args);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
return this;
|
175
|
+
}
|
176
|
+
};
|
177
|
+
|
178
|
+
moduleKeywords = ['included', 'extended'];
|
179
|
+
|
180
|
+
Module = (function() {
|
181
|
+
Module.include = function(obj) {
|
182
|
+
var key, value, _ref;
|
183
|
+
|
184
|
+
if (!obj) {
|
185
|
+
throw new Error('include(obj) requires obj');
|
186
|
+
}
|
187
|
+
for (key in obj) {
|
188
|
+
value = obj[key];
|
189
|
+
if (__indexOf.call(moduleKeywords, key) < 0) {
|
190
|
+
this.prototype[key] = value;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
if ((_ref = obj.included) != null) {
|
194
|
+
_ref.apply(this);
|
195
|
+
}
|
196
|
+
return this;
|
197
|
+
};
|
198
|
+
|
199
|
+
Module.extend = function(obj) {
|
200
|
+
var key, value, _ref;
|
201
|
+
|
202
|
+
if (!obj) {
|
203
|
+
throw new Error('extend(obj) requires obj');
|
204
|
+
}
|
205
|
+
for (key in obj) {
|
206
|
+
value = obj[key];
|
207
|
+
if (__indexOf.call(moduleKeywords, key) < 0) {
|
208
|
+
this[key] = value;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
if ((_ref = obj.extended) != null) {
|
212
|
+
_ref.apply(this);
|
213
|
+
}
|
214
|
+
return this;
|
215
|
+
};
|
216
|
+
|
217
|
+
Module.proxy = function(func) {
|
218
|
+
var _this = this;
|
219
|
+
|
220
|
+
return function() {
|
221
|
+
return func.apply(_this, arguments);
|
222
|
+
};
|
223
|
+
};
|
224
|
+
|
225
|
+
Module.prototype.proxy = function(func) {
|
226
|
+
var _this = this;
|
227
|
+
|
228
|
+
return function() {
|
229
|
+
return func.apply(_this, arguments);
|
230
|
+
};
|
231
|
+
};
|
232
|
+
|
233
|
+
function Module() {
|
234
|
+
if (typeof this.init === "function") {
|
235
|
+
this.init.apply(this, arguments);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
return Module;
|
240
|
+
|
241
|
+
})();
|
242
|
+
|
243
|
+
Model = (function(_super) {
|
244
|
+
__extends(Model, _super);
|
245
|
+
|
246
|
+
Model.extend(Events);
|
247
|
+
|
248
|
+
Model.records = [];
|
249
|
+
|
250
|
+
Model.irecords = {};
|
251
|
+
|
252
|
+
Model.crecords = {};
|
253
|
+
|
254
|
+
Model.attributes = [];
|
255
|
+
|
256
|
+
Model.configure = function() {
|
257
|
+
var attributes, name;
|
258
|
+
|
259
|
+
name = arguments[0], attributes = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
260
|
+
this.className = name;
|
261
|
+
this.deleteAll();
|
262
|
+
if (attributes.length) {
|
263
|
+
this.attributes = attributes;
|
264
|
+
}
|
265
|
+
this.attributes && (this.attributes = makeArray(this.attributes));
|
266
|
+
this.attributes || (this.attributes = []);
|
267
|
+
this.unbind();
|
268
|
+
return this;
|
269
|
+
};
|
270
|
+
|
271
|
+
Model.toString = function() {
|
272
|
+
return "" + this.className + "(" + (this.attributes.join(", ")) + ")";
|
273
|
+
};
|
274
|
+
|
275
|
+
Model.find = function(id) {
|
276
|
+
var record;
|
277
|
+
|
278
|
+
record = this.exists(id);
|
279
|
+
if (!record) {
|
280
|
+
throw new Error("\"" + this.className + "\" model could not find a record for the ID \"" + id + "\"");
|
281
|
+
}
|
282
|
+
return record;
|
283
|
+
};
|
284
|
+
|
285
|
+
Model.exists = function(id) {
|
286
|
+
var _ref, _ref1;
|
287
|
+
|
288
|
+
return (_ref = (_ref1 = this.irecords[id]) != null ? _ref1 : this.crecords[id]) != null ? _ref.clone() : void 0;
|
289
|
+
};
|
290
|
+
|
291
|
+
Model.refresh = function(values, options) {
|
292
|
+
var record, records, result, _i, _len;
|
293
|
+
|
294
|
+
if (options == null) {
|
295
|
+
options = {};
|
296
|
+
}
|
297
|
+
if (options.clear) {
|
298
|
+
this.deleteAll();
|
299
|
+
}
|
300
|
+
records = this.fromJSON(values);
|
301
|
+
if (!isArray(records)) {
|
302
|
+
records = [records];
|
303
|
+
}
|
304
|
+
for (_i = 0, _len = records.length; _i < _len; _i++) {
|
305
|
+
record = records[_i];
|
306
|
+
if (record.id && this.irecords[record.id]) {
|
307
|
+
this.records[this.records.indexOf(this.irecords[record.id])] = record;
|
308
|
+
} else {
|
309
|
+
record.id || (record.id = record.cid);
|
310
|
+
this.records.push(record);
|
311
|
+
}
|
312
|
+
this.irecords[record.id] = record;
|
313
|
+
this.crecords[record.cid] = record;
|
314
|
+
}
|
315
|
+
this.sort();
|
316
|
+
result = this.cloneArray(records);
|
317
|
+
this.trigger('refresh', this.cloneArray(records));
|
318
|
+
return result;
|
319
|
+
};
|
320
|
+
|
321
|
+
Model.select = function(callback) {
|
322
|
+
var record, _i, _len, _ref, _results;
|
323
|
+
|
324
|
+
_ref = this.records;
|
325
|
+
_results = [];
|
326
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
327
|
+
record = _ref[_i];
|
328
|
+
if (callback(record)) {
|
329
|
+
_results.push(record.clone());
|
330
|
+
}
|
331
|
+
}
|
332
|
+
return _results;
|
333
|
+
};
|
334
|
+
|
335
|
+
Model.findByAttribute = function(name, value) {
|
336
|
+
var record, _i, _len, _ref;
|
337
|
+
|
338
|
+
_ref = this.records;
|
339
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
340
|
+
record = _ref[_i];
|
341
|
+
if (record[name] === value) {
|
342
|
+
return record.clone();
|
343
|
+
}
|
344
|
+
}
|
345
|
+
return null;
|
346
|
+
};
|
347
|
+
|
348
|
+
Model.findAllByAttribute = function(name, value) {
|
349
|
+
return this.select(function(item) {
|
350
|
+
return item[name] === value;
|
351
|
+
});
|
352
|
+
};
|
353
|
+
|
354
|
+
Model.each = function(callback) {
|
355
|
+
var record, _i, _len, _ref, _results;
|
356
|
+
|
357
|
+
_ref = this.records;
|
358
|
+
_results = [];
|
359
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
360
|
+
record = _ref[_i];
|
361
|
+
_results.push(callback(record.clone()));
|
362
|
+
}
|
363
|
+
return _results;
|
364
|
+
};
|
365
|
+
|
366
|
+
Model.all = function() {
|
367
|
+
return this.cloneArray(this.records);
|
368
|
+
};
|
369
|
+
|
370
|
+
Model.first = function() {
|
371
|
+
var _ref;
|
372
|
+
|
373
|
+
return (_ref = this.records[0]) != null ? _ref.clone() : void 0;
|
374
|
+
};
|
375
|
+
|
376
|
+
Model.last = function() {
|
377
|
+
var _ref;
|
378
|
+
|
379
|
+
return (_ref = this.records[this.records.length - 1]) != null ? _ref.clone() : void 0;
|
380
|
+
};
|
381
|
+
|
382
|
+
Model.count = function() {
|
383
|
+
return this.records.length;
|
384
|
+
};
|
385
|
+
|
386
|
+
Model.deleteAll = function() {
|
387
|
+
this.records = [];
|
388
|
+
this.irecords = {};
|
389
|
+
return this.crecords = {};
|
390
|
+
};
|
391
|
+
|
392
|
+
Model.destroyAll = function(options) {
|
393
|
+
var record, _i, _len, _ref, _results;
|
394
|
+
|
395
|
+
_ref = this.records;
|
396
|
+
_results = [];
|
397
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
398
|
+
record = _ref[_i];
|
399
|
+
_results.push(record.destroy(options));
|
400
|
+
}
|
401
|
+
return _results;
|
402
|
+
};
|
403
|
+
|
404
|
+
Model.update = function(id, atts, options) {
|
405
|
+
return this.find(id).updateAttributes(atts, options);
|
406
|
+
};
|
407
|
+
|
408
|
+
Model.create = function(atts, options) {
|
409
|
+
var record;
|
410
|
+
|
411
|
+
record = new this(atts);
|
412
|
+
return record.save(options);
|
413
|
+
};
|
414
|
+
|
415
|
+
Model.destroy = function(id, options) {
|
416
|
+
return this.find(id).destroy(options);
|
417
|
+
};
|
418
|
+
|
419
|
+
Model.change = function(callbackOrParams) {
|
420
|
+
if (typeof callbackOrParams === 'function') {
|
421
|
+
return this.bind('change', callbackOrParams);
|
422
|
+
} else {
|
423
|
+
return this.trigger.apply(this, ['change'].concat(__slice.call(arguments)));
|
424
|
+
}
|
425
|
+
};
|
426
|
+
|
427
|
+
Model.fetch = function(callbackOrParams) {
|
428
|
+
if (typeof callbackOrParams === 'function') {
|
429
|
+
return this.bind('fetch', callbackOrParams);
|
430
|
+
} else {
|
431
|
+
return this.trigger.apply(this, ['fetch'].concat(__slice.call(arguments)));
|
432
|
+
}
|
433
|
+
};
|
434
|
+
|
435
|
+
Model.toJSON = function() {
|
436
|
+
return this.records;
|
437
|
+
};
|
438
|
+
|
439
|
+
Model.fromJSON = function(objects) {
|
440
|
+
var value, _i, _len, _results;
|
441
|
+
|
442
|
+
if (!objects) {
|
443
|
+
return;
|
444
|
+
}
|
445
|
+
if (typeof objects === 'string') {
|
446
|
+
objects = JSON.parse(objects);
|
447
|
+
}
|
448
|
+
if (isArray(objects)) {
|
449
|
+
_results = [];
|
450
|
+
for (_i = 0, _len = objects.length; _i < _len; _i++) {
|
451
|
+
value = objects[_i];
|
452
|
+
_results.push(new this(value));
|
453
|
+
}
|
454
|
+
return _results;
|
455
|
+
} else {
|
456
|
+
return new this(objects);
|
457
|
+
}
|
458
|
+
};
|
459
|
+
|
460
|
+
Model.fromForm = function() {
|
461
|
+
var _ref;
|
462
|
+
|
463
|
+
return (_ref = new this).fromForm.apply(_ref, arguments);
|
464
|
+
};
|
465
|
+
|
466
|
+
Model.sort = function() {
|
467
|
+
if (this.comparator) {
|
468
|
+
this.records.sort(this.comparator);
|
469
|
+
}
|
470
|
+
return this.records;
|
471
|
+
};
|
472
|
+
|
473
|
+
Model.cloneArray = function(array) {
|
474
|
+
var value, _i, _len, _results;
|
475
|
+
|
476
|
+
_results = [];
|
477
|
+
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
478
|
+
value = array[_i];
|
479
|
+
_results.push(value.clone());
|
480
|
+
}
|
481
|
+
return _results;
|
482
|
+
};
|
483
|
+
|
484
|
+
Model.idCounter = 0;
|
485
|
+
|
486
|
+
Model.uid = function(prefix) {
|
487
|
+
var uid;
|
488
|
+
|
489
|
+
if (prefix == null) {
|
490
|
+
prefix = '';
|
491
|
+
}
|
492
|
+
uid = prefix + this.idCounter++;
|
493
|
+
if (this.exists(uid)) {
|
494
|
+
uid = this.uid(prefix);
|
495
|
+
}
|
496
|
+
return uid;
|
497
|
+
};
|
498
|
+
|
499
|
+
function Model(atts) {
|
500
|
+
Model.__super__.constructor.apply(this, arguments);
|
501
|
+
if (atts) {
|
502
|
+
this.load(atts);
|
503
|
+
}
|
504
|
+
this.cid = this.constructor.uid('c-');
|
505
|
+
}
|
506
|
+
|
507
|
+
Model.prototype.isNew = function() {
|
508
|
+
return !this.exists();
|
509
|
+
};
|
510
|
+
|
511
|
+
Model.prototype.isValid = function() {
|
512
|
+
return !this.validate();
|
513
|
+
};
|
514
|
+
|
515
|
+
Model.prototype.validate = function() {};
|
516
|
+
|
517
|
+
Model.prototype.load = function(atts) {
|
518
|
+
var key, value;
|
519
|
+
|
520
|
+
if (atts.id) {
|
521
|
+
this.id = atts.id;
|
522
|
+
}
|
523
|
+
for (key in atts) {
|
524
|
+
value = atts[key];
|
525
|
+
if (atts.hasOwnProperty(key) && typeof this[key] === 'function') {
|
526
|
+
this[key](value);
|
527
|
+
} else {
|
528
|
+
this[key] = value;
|
529
|
+
}
|
530
|
+
}
|
531
|
+
return this;
|
532
|
+
};
|
533
|
+
|
534
|
+
Model.prototype.attributes = function() {
|
535
|
+
var key, result, _i, _len, _ref;
|
536
|
+
|
537
|
+
result = {};
|
538
|
+
_ref = this.constructor.attributes;
|
539
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
540
|
+
key = _ref[_i];
|
541
|
+
if (key in this) {
|
542
|
+
if (typeof this[key] === 'function') {
|
543
|
+
result[key] = this[key]();
|
544
|
+
} else {
|
545
|
+
result[key] = this[key];
|
546
|
+
}
|
547
|
+
}
|
548
|
+
}
|
549
|
+
if (this.id) {
|
550
|
+
result.id = this.id;
|
551
|
+
}
|
552
|
+
return result;
|
553
|
+
};
|
554
|
+
|
555
|
+
Model.prototype.eql = function(rec) {
|
556
|
+
return !!(rec && rec.constructor === this.constructor && (rec.cid === this.cid) || (rec.id && rec.id === this.id));
|
557
|
+
};
|
558
|
+
|
559
|
+
Model.prototype.save = function(options) {
|
560
|
+
var error, record;
|
561
|
+
|
562
|
+
if (options == null) {
|
563
|
+
options = {};
|
564
|
+
}
|
565
|
+
if (options.validate !== false) {
|
566
|
+
error = this.validate();
|
567
|
+
if (error) {
|
568
|
+
this.trigger('error', error);
|
569
|
+
return false;
|
570
|
+
}
|
571
|
+
}
|
572
|
+
this.trigger('beforeSave', options);
|
573
|
+
record = this.isNew() ? this.create(options) : this.update(options);
|
574
|
+
this.stripCloneAttrs();
|
575
|
+
this.trigger('save', options);
|
576
|
+
return record;
|
577
|
+
};
|
578
|
+
|
579
|
+
Model.prototype.stripCloneAttrs = function() {
|
580
|
+
var key, value;
|
581
|
+
|
582
|
+
if (this.hasOwnProperty('cid')) {
|
583
|
+
return;
|
584
|
+
}
|
585
|
+
for (key in this) {
|
586
|
+
if (!__hasProp.call(this, key)) continue;
|
587
|
+
value = this[key];
|
588
|
+
if (this.constructor.attributes.indexOf(key) > -1) {
|
589
|
+
delete this[key];
|
590
|
+
}
|
591
|
+
}
|
592
|
+
return this;
|
593
|
+
};
|
594
|
+
|
595
|
+
Model.prototype.updateAttribute = function(name, value, options) {
|
596
|
+
var atts;
|
597
|
+
|
598
|
+
atts = {};
|
599
|
+
atts[name] = value;
|
600
|
+
return this.updateAttributes(atts, options);
|
601
|
+
};
|
602
|
+
|
603
|
+
Model.prototype.updateAttributes = function(atts, options) {
|
604
|
+
this.load(atts);
|
605
|
+
return this.save(options);
|
606
|
+
};
|
607
|
+
|
608
|
+
Model.prototype.changeID = function(id) {
|
609
|
+
var records;
|
610
|
+
|
611
|
+
records = this.constructor.irecords;
|
612
|
+
records[id] = records[this.id];
|
613
|
+
delete records[this.id];
|
614
|
+
this.id = id;
|
615
|
+
return this.save();
|
616
|
+
};
|
617
|
+
|
618
|
+
Model.prototype.destroy = function(options) {
|
619
|
+
var i, record, records, _i, _len;
|
620
|
+
|
621
|
+
if (options == null) {
|
622
|
+
options = {};
|
623
|
+
}
|
624
|
+
this.trigger('beforeDestroy', options);
|
625
|
+
records = this.constructor.records.slice(0);
|
626
|
+
for (i = _i = 0, _len = records.length; _i < _len; i = ++_i) {
|
627
|
+
record = records[i];
|
628
|
+
if (!(this.eql(record))) {
|
629
|
+
continue;
|
630
|
+
}
|
631
|
+
records.splice(i, 1);
|
632
|
+
break;
|
633
|
+
}
|
634
|
+
this.constructor.records = records;
|
635
|
+
delete this.constructor.irecords[this.id];
|
636
|
+
delete this.constructor.crecords[this.cid];
|
637
|
+
this.destroyed = true;
|
638
|
+
this.trigger('destroy', options);
|
639
|
+
this.trigger('change', 'destroy', options);
|
640
|
+
if (this.listeningTo) {
|
641
|
+
this.stopListening();
|
642
|
+
}
|
643
|
+
this.unbind();
|
644
|
+
return this;
|
645
|
+
};
|
646
|
+
|
647
|
+
Model.prototype.dup = function(newRecord) {
|
648
|
+
var result;
|
649
|
+
|
650
|
+
result = new this.constructor(this.attributes());
|
651
|
+
if (newRecord === false) {
|
652
|
+
result.cid = this.cid;
|
653
|
+
} else {
|
654
|
+
delete result.id;
|
655
|
+
}
|
656
|
+
return result;
|
657
|
+
};
|
658
|
+
|
659
|
+
Model.prototype.clone = function() {
|
660
|
+
return createObject(this);
|
661
|
+
};
|
662
|
+
|
663
|
+
Model.prototype.reload = function() {
|
664
|
+
var original;
|
665
|
+
|
666
|
+
if (this.isNew()) {
|
667
|
+
return this;
|
668
|
+
}
|
669
|
+
original = this.constructor.find(this.id);
|
670
|
+
this.load(original.attributes());
|
671
|
+
return original;
|
672
|
+
};
|
673
|
+
|
674
|
+
Model.prototype.toJSON = function() {
|
675
|
+
return this.attributes();
|
676
|
+
};
|
677
|
+
|
678
|
+
Model.prototype.toString = function() {
|
679
|
+
return "<" + this.constructor.className + " (" + (JSON.stringify(this)) + ")>";
|
680
|
+
};
|
681
|
+
|
682
|
+
Model.prototype.fromForm = function(form) {
|
683
|
+
var checkbox, key, name, result, _i, _j, _k, _len, _len1, _len2, _name, _ref, _ref1, _ref2;
|
684
|
+
|
685
|
+
result = {};
|
686
|
+
_ref = $(form).find('[type=checkbox]:not([value])');
|
687
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
688
|
+
checkbox = _ref[_i];
|
689
|
+
result[checkbox.name] = $(checkbox).prop('checked');
|
690
|
+
}
|
691
|
+
_ref1 = $(form).find('[type=checkbox][name$="[]"]');
|
692
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
693
|
+
checkbox = _ref1[_j];
|
694
|
+
name = checkbox.name.replace(/\[\]$/, '');
|
695
|
+
result[name] || (result[name] = []);
|
696
|
+
if ($(checkbox).prop('checked')) {
|
697
|
+
result[name].push(checkbox.value);
|
698
|
+
}
|
699
|
+
}
|
700
|
+
_ref2 = $(form).serializeArray();
|
701
|
+
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
702
|
+
key = _ref2[_k];
|
703
|
+
result[_name = key.name] || (result[_name] = key.value);
|
704
|
+
}
|
705
|
+
return this.load(result);
|
706
|
+
};
|
707
|
+
|
708
|
+
Model.prototype.exists = function() {
|
709
|
+
return this.constructor.exists(this.id);
|
710
|
+
};
|
711
|
+
|
712
|
+
Model.prototype.update = function(options) {
|
713
|
+
var clone, records;
|
714
|
+
|
715
|
+
this.trigger('beforeUpdate', options);
|
716
|
+
records = this.constructor.irecords;
|
717
|
+
records[this.id].load(this.attributes());
|
718
|
+
this.constructor.sort();
|
719
|
+
clone = records[this.id].clone();
|
720
|
+
clone.trigger('update', options);
|
721
|
+
clone.trigger('change', 'update', options);
|
722
|
+
return clone;
|
723
|
+
};
|
724
|
+
|
725
|
+
Model.prototype.create = function(options) {
|
726
|
+
var clone, record;
|
727
|
+
|
728
|
+
this.trigger('beforeCreate', options);
|
729
|
+
if (!this.id) {
|
730
|
+
this.id = this.cid;
|
731
|
+
}
|
732
|
+
record = this.dup(false);
|
733
|
+
this.constructor.records.push(record);
|
734
|
+
this.constructor.irecords[this.id] = record;
|
735
|
+
this.constructor.crecords[this.cid] = record;
|
736
|
+
this.constructor.sort();
|
737
|
+
clone = record.clone();
|
738
|
+
clone.trigger('create', options);
|
739
|
+
clone.trigger('change', 'create', options);
|
740
|
+
return clone;
|
741
|
+
};
|
742
|
+
|
743
|
+
Model.prototype.bind = function(events, callback) {
|
744
|
+
var binder, singleEvent, _fn, _i, _len, _ref,
|
745
|
+
_this = this;
|
746
|
+
|
747
|
+
this.constructor.bind(events, binder = function(record) {
|
748
|
+
if (record && _this.eql(record)) {
|
749
|
+
return callback.apply(_this, arguments);
|
750
|
+
}
|
751
|
+
});
|
752
|
+
_ref = events.split(' ');
|
753
|
+
_fn = function(singleEvent) {
|
754
|
+
var unbinder;
|
755
|
+
|
756
|
+
return _this.constructor.bind("unbind", unbinder = function(record, event, cb) {
|
757
|
+
if (record && _this.eql(record)) {
|
758
|
+
if (event && event !== singleEvent) {
|
759
|
+
return;
|
760
|
+
}
|
761
|
+
if (cb && cb !== callback) {
|
762
|
+
return;
|
763
|
+
}
|
764
|
+
_this.constructor.unbind(singleEvent, binder);
|
765
|
+
return _this.constructor.unbind("unbind", unbinder);
|
766
|
+
}
|
767
|
+
});
|
768
|
+
};
|
769
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
770
|
+
singleEvent = _ref[_i];
|
771
|
+
_fn(singleEvent);
|
772
|
+
}
|
773
|
+
return this;
|
774
|
+
};
|
775
|
+
|
776
|
+
Model.prototype.one = function(events, callback) {
|
777
|
+
var handler,
|
778
|
+
_this = this;
|
779
|
+
|
780
|
+
return this.bind(events, handler = function() {
|
781
|
+
_this.unbind(events, handler);
|
782
|
+
return callback.apply(_this, arguments);
|
783
|
+
});
|
784
|
+
};
|
785
|
+
|
786
|
+
Model.prototype.trigger = function() {
|
787
|
+
var args, _ref;
|
788
|
+
|
789
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
790
|
+
args.splice(1, 0, this);
|
791
|
+
return (_ref = this.constructor).trigger.apply(_ref, args);
|
792
|
+
};
|
793
|
+
|
794
|
+
Model.prototype.listenTo = function(obj, events, callback) {
|
795
|
+
obj.bind(events, callback);
|
796
|
+
this.listeningTo || (this.listeningTo = []);
|
797
|
+
return this.listeningTo.push(obj);
|
798
|
+
};
|
799
|
+
|
800
|
+
Model.prototype.listenToOnce = function(obj, events, callback) {
|
801
|
+
var handler, listeningToOnce,
|
802
|
+
_this = this;
|
803
|
+
|
804
|
+
listeningToOnce = this.listeningToOnce || (this.listeningToOnce = []);
|
805
|
+
listeningToOnce.push(obj);
|
806
|
+
return obj.bind(events, handler = function() {
|
807
|
+
var idx;
|
808
|
+
|
809
|
+
idx = listeningToOnce.indexOf(obj);
|
810
|
+
if (idx !== -1) {
|
811
|
+
listeningToOnce.splice(idx, 1);
|
812
|
+
}
|
813
|
+
obj.unbind(events, handler);
|
814
|
+
return callback.apply(obj, arguments);
|
815
|
+
});
|
816
|
+
};
|
817
|
+
|
818
|
+
Model.prototype.stopListening = function(obj, events, callback) {
|
819
|
+
var idx, listeningTo, retain, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
|
820
|
+
|
821
|
+
if (arguments.length === 0) {
|
822
|
+
retain = [];
|
823
|
+
_ref = [this.listeningTo, this.listeningToOnce];
|
824
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
825
|
+
listeningTo = _ref[_i];
|
826
|
+
if (!listeningTo) {
|
827
|
+
continue;
|
828
|
+
}
|
829
|
+
_ref1 = this.listeningTo;
|
830
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
831
|
+
obj = _ref1[_j];
|
832
|
+
if (!(!(__indexOf.call(retain, obj) >= 0))) {
|
833
|
+
continue;
|
834
|
+
}
|
835
|
+
obj.unbind();
|
836
|
+
retain.push(obj);
|
837
|
+
}
|
838
|
+
}
|
839
|
+
this.listeningTo = void 0;
|
840
|
+
this.listeningToOnce = void 0;
|
841
|
+
return;
|
842
|
+
}
|
843
|
+
if (obj) {
|
844
|
+
if (!events) {
|
845
|
+
obj.unbind();
|
846
|
+
}
|
847
|
+
if (events) {
|
848
|
+
obj.unbind(events, callback);
|
849
|
+
}
|
850
|
+
_ref2 = [this.listeningTo, this.listeningToOnce];
|
851
|
+
_results = [];
|
852
|
+
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
853
|
+
listeningTo = _ref2[_k];
|
854
|
+
if (!listeningTo) {
|
855
|
+
continue;
|
856
|
+
}
|
857
|
+
idx = listeningTo.indexOf(obj);
|
858
|
+
if (idx !== -1) {
|
859
|
+
_results.push(listeningTo.splice(idx, 1));
|
860
|
+
} else {
|
861
|
+
_results.push(void 0);
|
862
|
+
}
|
863
|
+
}
|
864
|
+
return _results;
|
865
|
+
}
|
866
|
+
};
|
867
|
+
|
868
|
+
Model.prototype.unbind = function(events, callback) {
|
869
|
+
var event, _i, _len, _ref, _results;
|
870
|
+
|
871
|
+
if (arguments.length === 0) {
|
872
|
+
return this.trigger('unbind');
|
873
|
+
} else if (events) {
|
874
|
+
_ref = events.split(' ');
|
875
|
+
_results = [];
|
876
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
877
|
+
event = _ref[_i];
|
878
|
+
_results.push(this.trigger('unbind', event, callback));
|
879
|
+
}
|
880
|
+
return _results;
|
881
|
+
}
|
882
|
+
};
|
883
|
+
|
884
|
+
return Model;
|
885
|
+
|
886
|
+
})(Module);
|
887
|
+
|
888
|
+
Model.prototype.on = Model.prototype.bind;
|
889
|
+
|
890
|
+
Model.prototype.off = Model.prototype.unbind;
|
891
|
+
|
892
|
+
Controller = (function(_super) {
|
893
|
+
__extends(Controller, _super);
|
894
|
+
|
895
|
+
Controller.include(Events);
|
896
|
+
|
897
|
+
Controller.include(Log);
|
898
|
+
|
899
|
+
Controller.prototype.eventSplitter = /^(\S+)\s*(.*)$/;
|
900
|
+
|
901
|
+
Controller.prototype.tag = 'div';
|
902
|
+
|
903
|
+
function Controller(options) {
|
904
|
+
this.release = __bind(this.release, this);
|
905
|
+
var context, key, parent_prototype, value, _ref;
|
906
|
+
|
907
|
+
this.options = options;
|
908
|
+
_ref = this.options;
|
909
|
+
for (key in _ref) {
|
910
|
+
value = _ref[key];
|
911
|
+
this[key] = value;
|
912
|
+
}
|
913
|
+
if (!this.el) {
|
914
|
+
this.el = document.createElement(this.tag);
|
915
|
+
}
|
916
|
+
this.el = $(this.el);
|
917
|
+
this.$el = this.el;
|
918
|
+
if (this.className) {
|
919
|
+
this.el.addClass(this.className);
|
920
|
+
}
|
921
|
+
if (this.attributes) {
|
922
|
+
this.el.attr(this.attributes);
|
923
|
+
}
|
924
|
+
if (!this.events) {
|
925
|
+
this.events = this.constructor.events;
|
926
|
+
}
|
927
|
+
if (!this.elements) {
|
928
|
+
this.elements = this.constructor.elements;
|
929
|
+
}
|
930
|
+
context = this;
|
931
|
+
while (parent_prototype = context.constructor.__super__) {
|
932
|
+
if (parent_prototype.events) {
|
933
|
+
this.events = $.extend({}, parent_prototype.events, this.events);
|
934
|
+
}
|
935
|
+
if (parent_prototype.elements) {
|
936
|
+
this.elements = $.extend({}, parent_prototype.elements, this.elements);
|
937
|
+
}
|
938
|
+
context = parent_prototype;
|
939
|
+
}
|
940
|
+
if (this.events) {
|
941
|
+
this.delegateEvents(this.events);
|
942
|
+
}
|
943
|
+
if (this.elements) {
|
944
|
+
this.refreshElements();
|
945
|
+
}
|
946
|
+
Controller.__super__.constructor.apply(this, arguments);
|
947
|
+
}
|
948
|
+
|
949
|
+
Controller.prototype.release = function() {
|
950
|
+
this.trigger('release', this);
|
951
|
+
this.el.remove();
|
952
|
+
this.unbind();
|
953
|
+
return this.stopListening();
|
954
|
+
};
|
955
|
+
|
956
|
+
Controller.prototype.$ = function(selector) {
|
957
|
+
return $(selector, this.el);
|
958
|
+
};
|
959
|
+
|
960
|
+
Controller.prototype.delegateEvents = function(events) {
|
961
|
+
var eventName, key, match, method, selector, _results,
|
962
|
+
_this = this;
|
963
|
+
|
964
|
+
_results = [];
|
965
|
+
for (key in events) {
|
966
|
+
method = events[key];
|
967
|
+
if (typeof method === 'function') {
|
968
|
+
method = (function(method) {
|
969
|
+
return function() {
|
970
|
+
method.apply(_this, arguments);
|
971
|
+
return true;
|
972
|
+
};
|
973
|
+
})(method);
|
974
|
+
} else {
|
975
|
+
if (!this[method]) {
|
976
|
+
throw new Error("" + method + " doesn't exist");
|
977
|
+
}
|
978
|
+
method = (function(method) {
|
979
|
+
return function() {
|
980
|
+
_this[method].apply(_this, arguments);
|
981
|
+
return true;
|
982
|
+
};
|
983
|
+
})(method);
|
984
|
+
}
|
985
|
+
match = key.match(this.eventSplitter);
|
986
|
+
eventName = match[1];
|
987
|
+
selector = match[2];
|
988
|
+
if (selector === '') {
|
989
|
+
_results.push(this.el.bind(eventName, method));
|
990
|
+
} else {
|
991
|
+
_results.push(this.el.delegate(selector, eventName, method));
|
992
|
+
}
|
993
|
+
}
|
994
|
+
return _results;
|
995
|
+
};
|
996
|
+
|
997
|
+
Controller.prototype.refreshElements = function() {
|
998
|
+
var key, value, _ref, _results;
|
999
|
+
|
1000
|
+
_ref = this.elements;
|
1001
|
+
_results = [];
|
1002
|
+
for (key in _ref) {
|
1003
|
+
value = _ref[key];
|
1004
|
+
_results.push(this[value] = this.$(key));
|
1005
|
+
}
|
1006
|
+
return _results;
|
1007
|
+
};
|
1008
|
+
|
1009
|
+
Controller.prototype.delay = function(func, timeout) {
|
1010
|
+
return setTimeout(this.proxy(func), timeout || 0);
|
1011
|
+
};
|
1012
|
+
|
1013
|
+
Controller.prototype.html = function(element) {
|
1014
|
+
this.el.html(element.el || element);
|
1015
|
+
this.refreshElements();
|
1016
|
+
return this.el;
|
1017
|
+
};
|
1018
|
+
|
1019
|
+
Controller.prototype.append = function() {
|
1020
|
+
var e, elements, _ref;
|
1021
|
+
|
1022
|
+
elements = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1023
|
+
elements = (function() {
|
1024
|
+
var _i, _len, _results;
|
1025
|
+
|
1026
|
+
_results = [];
|
1027
|
+
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
1028
|
+
e = elements[_i];
|
1029
|
+
_results.push(e.el || e);
|
1030
|
+
}
|
1031
|
+
return _results;
|
1032
|
+
})();
|
1033
|
+
(_ref = this.el).append.apply(_ref, elements);
|
1034
|
+
this.refreshElements();
|
1035
|
+
return this.el;
|
1036
|
+
};
|
1037
|
+
|
1038
|
+
Controller.prototype.appendTo = function(element) {
|
1039
|
+
this.el.appendTo(element.el || element);
|
1040
|
+
this.refreshElements();
|
1041
|
+
return this.el;
|
1042
|
+
};
|
1043
|
+
|
1044
|
+
Controller.prototype.prepend = function() {
|
1045
|
+
var e, elements, _ref;
|
1046
|
+
|
1047
|
+
elements = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1048
|
+
elements = (function() {
|
1049
|
+
var _i, _len, _results;
|
1050
|
+
|
1051
|
+
_results = [];
|
1052
|
+
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
1053
|
+
e = elements[_i];
|
1054
|
+
_results.push(e.el || e);
|
1055
|
+
}
|
1056
|
+
return _results;
|
1057
|
+
})();
|
1058
|
+
(_ref = this.el).prepend.apply(_ref, elements);
|
1059
|
+
this.refreshElements();
|
1060
|
+
return this.el;
|
1061
|
+
};
|
1062
|
+
|
1063
|
+
Controller.prototype.replace = function(element) {
|
1064
|
+
var previous, _ref;
|
1065
|
+
|
1066
|
+
_ref = [this.el, $(element.el || element)], previous = _ref[0], this.el = _ref[1];
|
1067
|
+
previous.replaceWith(this.el);
|
1068
|
+
this.delegateEvents(this.events);
|
1069
|
+
this.refreshElements();
|
1070
|
+
return this.el;
|
1071
|
+
};
|
1072
|
+
|
1073
|
+
return Controller;
|
1074
|
+
|
1075
|
+
})(Module);
|
1076
|
+
|
1077
|
+
$ = (typeof window !== "undefined" && window !== null ? window.jQuery : void 0) || (typeof window !== "undefined" && window !== null ? window.Zepto : void 0) || function(element) {
|
1078
|
+
return element;
|
1079
|
+
};
|
1080
|
+
|
1081
|
+
createObject = Object.create || function(o) {
|
1082
|
+
var Func;
|
1083
|
+
|
1084
|
+
Func = function() {};
|
1085
|
+
Func.prototype = o;
|
1086
|
+
return new Func();
|
1087
|
+
};
|
1088
|
+
|
1089
|
+
isArray = function(value) {
|
1090
|
+
return Object.prototype.toString.call(value) === '[object Array]';
|
1091
|
+
};
|
1092
|
+
|
1093
|
+
isBlank = function(value) {
|
1094
|
+
var key;
|
1095
|
+
|
1096
|
+
if (!value) {
|
1097
|
+
return true;
|
1098
|
+
}
|
1099
|
+
for (key in value) {
|
1100
|
+
return false;
|
1101
|
+
}
|
1102
|
+
return true;
|
1103
|
+
};
|
1104
|
+
|
1105
|
+
makeArray = function(args) {
|
1106
|
+
return Array.prototype.slice.call(args, 0);
|
1107
|
+
};
|
1108
|
+
|
1109
|
+
Spine = this.Spine = {};
|
1110
|
+
|
1111
|
+
if (typeof module !== "undefined" && module !== null) {
|
1112
|
+
module.exports = Spine;
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
Spine.version = '1.1.0';
|
1116
|
+
|
1117
|
+
Spine.isArray = isArray;
|
1118
|
+
|
1119
|
+
Spine.isBlank = isBlank;
|
1120
|
+
|
1121
|
+
Spine.$ = $;
|
1122
|
+
|
1123
|
+
Spine.Events = Events;
|
1124
|
+
|
1125
|
+
Spine.Log = Log;
|
1126
|
+
|
1127
|
+
Spine.Module = Module;
|
1128
|
+
|
1129
|
+
Spine.Controller = Controller;
|
1130
|
+
|
1131
|
+
Spine.Model = Model;
|
1132
|
+
|
1133
|
+
Module.extend.call(Spine, Events);
|
1134
|
+
|
1135
|
+
Module.create = Module.sub = Controller.create = Controller.sub = Model.sub = function(instances, statics) {
|
1136
|
+
var Result, _ref;
|
1137
|
+
|
1138
|
+
Result = (function(_super) {
|
1139
|
+
__extends(Result, _super);
|
1140
|
+
|
1141
|
+
function Result() {
|
1142
|
+
_ref = Result.__super__.constructor.apply(this, arguments);
|
1143
|
+
return _ref;
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
return Result;
|
1147
|
+
|
1148
|
+
})(this);
|
1149
|
+
if (instances) {
|
1150
|
+
Result.include(instances);
|
1151
|
+
}
|
1152
|
+
if (statics) {
|
1153
|
+
Result.extend(statics);
|
1154
|
+
}
|
1155
|
+
if (typeof Result.unbind === "function") {
|
1156
|
+
Result.unbind();
|
1157
|
+
}
|
1158
|
+
return Result;
|
1159
|
+
};
|
1160
|
+
|
1161
|
+
Model.setup = function(name, attributes) {
|
1162
|
+
var Instance, _ref;
|
1163
|
+
|
1164
|
+
if (attributes == null) {
|
1165
|
+
attributes = [];
|
1166
|
+
}
|
1167
|
+
Instance = (function(_super) {
|
1168
|
+
__extends(Instance, _super);
|
1169
|
+
|
1170
|
+
function Instance() {
|
1171
|
+
_ref = Instance.__super__.constructor.apply(this, arguments);
|
1172
|
+
return _ref;
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
return Instance;
|
1176
|
+
|
1177
|
+
})(this);
|
1178
|
+
Instance.configure.apply(Instance, [name].concat(__slice.call(attributes)));
|
1179
|
+
return Instance;
|
1180
|
+
};
|
1181
|
+
|
1182
|
+
Spine.Class = Module;
|
1183
|
+
|
1184
|
+
}).call(this);
|