parade 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +542 -0
  3. data/Rakefile +15 -0
  4. data/bin/parade +138 -0
  5. data/lib/parade.rb +43 -0
  6. data/lib/parade/commands/commands.rb +84 -0
  7. data/lib/parade/commands/generate_outline.rb +34 -0
  8. data/lib/parade/commands/generate_presentation.rb +34 -0
  9. data/lib/parade/commands/generate_rackup.rb +32 -0
  10. data/lib/parade/commands/html_output.rb +47 -0
  11. data/lib/parade/commands/render_from_template.rb +50 -0
  12. data/lib/parade/commands/static_html.rb +38 -0
  13. data/lib/parade/commands/static_pdf.rb +39 -0
  14. data/lib/parade/commands/unknown.rb +23 -0
  15. data/lib/parade/features/live_ruby.rb +18 -0
  16. data/lib/parade/features/pdf_presentation.rb +24 -0
  17. data/lib/parade/features/preshow.rb +11 -0
  18. data/lib/parade/helpers/encode_image.rb +24 -0
  19. data/lib/parade/helpers/template_generator.rb +130 -0
  20. data/lib/parade/metadata.rb +73 -0
  21. data/lib/parade/metadata/assignment.rb +38 -0
  22. data/lib/parade/metadata/css_classes.rb +22 -0
  23. data/lib/parade/metadata/html_id.rb +35 -0
  24. data/lib/parade/metadata/template.rb +31 -0
  25. data/lib/parade/parsers/dsl.rb +138 -0
  26. data/lib/parade/parsers/dsl_file_parser.rb +17 -0
  27. data/lib/parade/parsers/json_file_parser.rb +67 -0
  28. data/lib/parade/parsers/markdown_image_paths.rb +44 -0
  29. data/lib/parade/parsers/markdown_slide_splitter.rb +63 -0
  30. data/lib/parade/parsers/presentation_directory_parser.rb +36 -0
  31. data/lib/parade/parsers/presentation_file_parser.rb +27 -0
  32. data/lib/parade/parsers/presentation_filepath_parser.rb +35 -0
  33. data/lib/parade/parsers/slides_file_content_parser.rb +27 -0
  34. data/lib/parade/renderers/columns_renderer.rb +68 -0
  35. data/lib/parade/renderers/command_line_renderer.rb +142 -0
  36. data/lib/parade/renderers/html_with_pygments.rb +42 -0
  37. data/lib/parade/renderers/inline_images.rb +31 -0
  38. data/lib/parade/renderers/special_paragraph_renderer.rb +23 -0
  39. data/lib/parade/renderers/update_image_paths.rb +75 -0
  40. data/lib/parade/section.rb +183 -0
  41. data/lib/parade/server.rb +139 -0
  42. data/lib/parade/slide.rb +128 -0
  43. data/lib/parade/version.rb +3 -0
  44. data/lib/public/css/960.css +653 -0
  45. data/lib/public/css/fg.menu.css +114 -0
  46. data/lib/public/css/ghf_marked.css +180 -0
  47. data/lib/public/css/jquery-terminal.css +73 -0
  48. data/lib/public/css/onepage.css +62 -0
  49. data/lib/public/css/parade.css +450 -0
  50. data/lib/public/css/pdf.css +13 -0
  51. data/lib/public/css/reset.css +53 -0
  52. data/lib/public/css/spinner_bar.gif +0 -0
  53. data/lib/public/css/theme/images/ui-bg_diagonals-small_100_f0efea_40x40.png +0 -0
  54. data/lib/public/css/theme/images/ui-bg_flat_35_f0f0f0_40x100.png +0 -0
  55. data/lib/public/css/theme/images/ui-bg_glass_55_fcf0ba_1x400.png +0 -0
  56. data/lib/public/css/theme/images/ui-bg_glow-ball_25_2e2e28_600x600.png +0 -0
  57. data/lib/public/css/theme/images/ui-bg_highlight-soft_100_f0efea_1x100.png +0 -0
  58. data/lib/public/css/theme/images/ui-bg_highlight-soft_25_327E04_1x100.png +0 -0
  59. data/lib/public/css/theme/images/ui-bg_highlight-soft_25_5A9D1A_1x100.png +0 -0
  60. data/lib/public/css/theme/images/ui-bg_highlight-soft_95_ffedad_1x100.png +0 -0
  61. data/lib/public/css/theme/images/ui-bg_inset-soft_22_3b3b35_1x100.png +0 -0
  62. data/lib/public/css/theme/images/ui-icons_808080_256x240.png +0 -0
  63. data/lib/public/css/theme/images/ui-icons_8DC262_256x240.png +0 -0
  64. data/lib/public/css/theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  65. data/lib/public/css/theme/images/ui-icons_e7e6e4_256x240.png +0 -0
  66. data/lib/public/css/theme/images/ui-icons_eeeeee_256x240.png +0 -0
  67. data/lib/public/css/theme/images/ui-icons_ffffff_256x240.png +0 -0
  68. data/lib/public/css/theme/ui.accordion.css +9 -0
  69. data/lib/public/css/theme/ui.all.css +2 -0
  70. data/lib/public/css/theme/ui.base.css +9 -0
  71. data/lib/public/css/theme/ui.core.css +37 -0
  72. data/lib/public/css/theme/ui.datepicker.css +62 -0
  73. data/lib/public/css/theme/ui.dialog.css +13 -0
  74. data/lib/public/css/theme/ui.progressbar.css +4 -0
  75. data/lib/public/css/theme/ui.resizable.css +13 -0
  76. data/lib/public/css/theme/ui.slider.css +17 -0
  77. data/lib/public/css/theme/ui.tabs.css +9 -0
  78. data/lib/public/css/theme/ui.theme.css +245 -0
  79. data/lib/public/favicon.ico +0 -0
  80. data/lib/public/js/coffee-script.js +8 -0
  81. data/lib/public/js/fg.menu.js +645 -0
  82. data/lib/public/js/jTypeWriter.js +26 -0
  83. data/lib/public/js/jquery-1.4.2.js +6240 -0
  84. data/lib/public/js/jquery-print.js +109 -0
  85. data/lib/public/js/jquery-pubsub.js +27 -0
  86. data/lib/public/js/jquery-terminal.js +2712 -0
  87. data/lib/public/js/jquery.batchImageLoad.js +56 -0
  88. data/lib/public/js/jquery.cycle.all.js +1284 -0
  89. data/lib/public/js/keyboard.js +733 -0
  90. data/lib/public/js/parade-code-execution.js +122 -0
  91. data/lib/public/js/parade-command-input.js +16 -0
  92. data/lib/public/js/parade-command-visor.js +92 -0
  93. data/lib/public/js/parade-keyboard-input.js +54 -0
  94. data/lib/public/js/parade.js +675 -0
  95. data/lib/public/js/spine.js +904 -0
  96. data/lib/templates/config.ru.erb +4 -0
  97. data/lib/templates/showoff.erb +27 -0
  98. data/lib/templates/slides.md.erb +25 -0
  99. data/lib/views/header.erb +73 -0
  100. data/lib/views/index.erb +53 -0
  101. data/lib/views/inline_css.erb +3 -0
  102. data/lib/views/inline_js.erb +3 -0
  103. data/lib/views/onepage.erb +17 -0
  104. data/lib/views/pdf.erb +17 -0
  105. data/lib/views/slide.erb +5 -0
  106. metadata +317 -0
@@ -0,0 +1,904 @@
1
+ // Generated by CoffeeScript 1.3.3
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
+ evs = ev.split(' ');
14
+ calls = this.hasOwnProperty('_callbacks') && this._callbacks || (this._callbacks = {});
15
+ for (_i = 0, _len = evs.length; _i < _len; _i++) {
16
+ name = evs[_i];
17
+ calls[name] || (calls[name] = []);
18
+ calls[name].push(callback);
19
+ }
20
+ return this;
21
+ },
22
+ one: function(ev, callback) {
23
+ return this.bind(ev, function() {
24
+ this.unbind(ev, arguments.callee);
25
+ return callback.apply(this, arguments);
26
+ });
27
+ },
28
+ trigger: function() {
29
+ var args, callback, ev, list, _i, _len, _ref;
30
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
31
+ ev = args.shift();
32
+ list = this.hasOwnProperty('_callbacks') && ((_ref = this._callbacks) != null ? _ref[ev] : void 0);
33
+ if (!list) {
34
+ return;
35
+ }
36
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
37
+ callback = list[_i];
38
+ if (callback.apply(this, args) === false) {
39
+ break;
40
+ }
41
+ }
42
+ return true;
43
+ },
44
+ unbind: function(ev, callback) {
45
+ var cb, i, list, _i, _len, _ref;
46
+ if (!ev) {
47
+ this._callbacks = {};
48
+ return this;
49
+ }
50
+ list = (_ref = this._callbacks) != null ? _ref[ev] : void 0;
51
+ if (!list) {
52
+ return this;
53
+ }
54
+ if (!callback) {
55
+ delete this._callbacks[ev];
56
+ return this;
57
+ }
58
+ for (i = _i = 0, _len = list.length; _i < _len; i = ++_i) {
59
+ cb = list[i];
60
+ if (!(cb === callback)) {
61
+ continue;
62
+ }
63
+ list = list.slice();
64
+ list.splice(i, 1);
65
+ this._callbacks[ev] = list;
66
+ break;
67
+ }
68
+ return this;
69
+ }
70
+ };
71
+
72
+ Log = {
73
+ trace: true,
74
+ logPrefix: '(App)',
75
+ log: function() {
76
+ var args;
77
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
78
+ if (!this.trace) {
79
+ return;
80
+ }
81
+ if (this.logPrefix) {
82
+ args.unshift(this.logPrefix);
83
+ }
84
+ if (typeof console !== "undefined" && console !== null) {
85
+ if (typeof console.log === "function") {
86
+ console.log.apply(console, args);
87
+ }
88
+ }
89
+ return this;
90
+ }
91
+ };
92
+
93
+ moduleKeywords = ['included', 'extended'];
94
+
95
+ Module = (function() {
96
+
97
+ Module.include = function(obj) {
98
+ var key, value, _ref;
99
+ if (!obj) {
100
+ throw 'include(obj) requires obj';
101
+ }
102
+ for (key in obj) {
103
+ value = obj[key];
104
+ if (__indexOf.call(moduleKeywords, key) < 0) {
105
+ this.prototype[key] = value;
106
+ }
107
+ }
108
+ if ((_ref = obj.included) != null) {
109
+ _ref.apply(this);
110
+ }
111
+ return this;
112
+ };
113
+
114
+ Module.extend = function(obj) {
115
+ var key, value, _ref;
116
+ if (!obj) {
117
+ throw 'extend(obj) requires obj';
118
+ }
119
+ for (key in obj) {
120
+ value = obj[key];
121
+ if (__indexOf.call(moduleKeywords, key) < 0) {
122
+ this[key] = value;
123
+ }
124
+ }
125
+ if ((_ref = obj.extended) != null) {
126
+ _ref.apply(this);
127
+ }
128
+ return this;
129
+ };
130
+
131
+ Module.proxy = function(func) {
132
+ var _this = this;
133
+ return function() {
134
+ return func.apply(_this, arguments);
135
+ };
136
+ };
137
+
138
+ Module.prototype.proxy = function(func) {
139
+ var _this = this;
140
+ return function() {
141
+ return func.apply(_this, arguments);
142
+ };
143
+ };
144
+
145
+ function Module() {
146
+ if (typeof this.init === "function") {
147
+ this.init.apply(this, arguments);
148
+ }
149
+ }
150
+
151
+ return Module;
152
+
153
+ })();
154
+
155
+ Model = (function(_super) {
156
+
157
+ __extends(Model, _super);
158
+
159
+ Model.extend(Events);
160
+
161
+ Model.records = {};
162
+
163
+ Model.crecords = {};
164
+
165
+ Model.attributes = [];
166
+
167
+ Model.configure = function() {
168
+ var attributes, name;
169
+ name = arguments[0], attributes = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
170
+ this.className = name;
171
+ this.records = {};
172
+ this.crecords = {};
173
+ if (attributes.length) {
174
+ this.attributes = attributes;
175
+ }
176
+ this.attributes && (this.attributes = makeArray(this.attributes));
177
+ this.attributes || (this.attributes = []);
178
+ this.unbind();
179
+ return this;
180
+ };
181
+
182
+ Model.toString = function() {
183
+ return "" + this.className + "(" + (this.attributes.join(", ")) + ")";
184
+ };
185
+
186
+ Model.find = function(id) {
187
+ var record;
188
+ record = this.records[id];
189
+ if (!record && ("" + id).match(/c-\d+/)) {
190
+ return this.findCID(id);
191
+ }
192
+ if (!record) {
193
+ throw 'Unknown record';
194
+ }
195
+ return record.clone();
196
+ };
197
+
198
+ Model.findCID = function(cid) {
199
+ var record;
200
+ record = this.crecords[cid];
201
+ if (!record) {
202
+ throw 'Unknown record';
203
+ }
204
+ return record.clone();
205
+ };
206
+
207
+ Model.exists = function(id) {
208
+ try {
209
+ return this.find(id);
210
+ } catch (e) {
211
+ return false;
212
+ }
213
+ };
214
+
215
+ Model.refresh = function(values, options) {
216
+ var record, records, _i, _len;
217
+ if (options == null) {
218
+ options = {};
219
+ }
220
+ if (options.clear) {
221
+ this.records = {};
222
+ this.crecords = {};
223
+ }
224
+ records = this.fromJSON(values);
225
+ if (!isArray(records)) {
226
+ records = [records];
227
+ }
228
+ for (_i = 0, _len = records.length; _i < _len; _i++) {
229
+ record = records[_i];
230
+ record.id || (record.id = record.cid);
231
+ this.records[record.id] = record;
232
+ this.crecords[record.cid] = record;
233
+ }
234
+ this.trigger('refresh', this.cloneArray(records));
235
+ return this;
236
+ };
237
+
238
+ Model.select = function(callback) {
239
+ var id, record, result;
240
+ result = (function() {
241
+ var _ref, _results;
242
+ _ref = this.records;
243
+ _results = [];
244
+ for (id in _ref) {
245
+ record = _ref[id];
246
+ if (callback(record)) {
247
+ _results.push(record);
248
+ }
249
+ }
250
+ return _results;
251
+ }).call(this);
252
+ return this.cloneArray(result);
253
+ };
254
+
255
+ Model.findByAttribute = function(name, value) {
256
+ var id, record, _ref;
257
+ _ref = this.records;
258
+ for (id in _ref) {
259
+ record = _ref[id];
260
+ if (record[name] === value) {
261
+ return record.clone();
262
+ }
263
+ }
264
+ return null;
265
+ };
266
+
267
+ Model.findAllByAttribute = function(name, value) {
268
+ return this.select(function(item) {
269
+ return item[name] === value;
270
+ });
271
+ };
272
+
273
+ Model.each = function(callback) {
274
+ var key, value, _ref, _results;
275
+ _ref = this.records;
276
+ _results = [];
277
+ for (key in _ref) {
278
+ value = _ref[key];
279
+ _results.push(callback(value.clone()));
280
+ }
281
+ return _results;
282
+ };
283
+
284
+ Model.all = function() {
285
+ return this.cloneArray(this.recordsValues());
286
+ };
287
+
288
+ Model.first = function() {
289
+ var record;
290
+ record = this.recordsValues()[0];
291
+ return record != null ? record.clone() : void 0;
292
+ };
293
+
294
+ Model.last = function() {
295
+ var record, values;
296
+ values = this.recordsValues();
297
+ record = values[values.length - 1];
298
+ return record != null ? record.clone() : void 0;
299
+ };
300
+
301
+ Model.count = function() {
302
+ return this.recordsValues().length;
303
+ };
304
+
305
+ Model.deleteAll = function() {
306
+ var key, value, _ref, _results;
307
+ _ref = this.records;
308
+ _results = [];
309
+ for (key in _ref) {
310
+ value = _ref[key];
311
+ _results.push(delete this.records[key]);
312
+ }
313
+ return _results;
314
+ };
315
+
316
+ Model.destroyAll = function() {
317
+ var key, value, _ref, _results;
318
+ _ref = this.records;
319
+ _results = [];
320
+ for (key in _ref) {
321
+ value = _ref[key];
322
+ _results.push(this.records[key].destroy());
323
+ }
324
+ return _results;
325
+ };
326
+
327
+ Model.update = function(id, atts, options) {
328
+ return this.find(id).updateAttributes(atts, options);
329
+ };
330
+
331
+ Model.create = function(atts, options) {
332
+ var record;
333
+ record = new this(atts);
334
+ return record.save(options);
335
+ };
336
+
337
+ Model.destroy = function(id, options) {
338
+ return this.find(id).destroy(options);
339
+ };
340
+
341
+ Model.change = function(callbackOrParams) {
342
+ if (typeof callbackOrParams === 'function') {
343
+ return this.bind('change', callbackOrParams);
344
+ } else {
345
+ return this.trigger('change', callbackOrParams);
346
+ }
347
+ };
348
+
349
+ Model.fetch = function(callbackOrParams) {
350
+ if (typeof callbackOrParams === 'function') {
351
+ return this.bind('fetch', callbackOrParams);
352
+ } else {
353
+ return this.trigger('fetch', callbackOrParams);
354
+ }
355
+ };
356
+
357
+ Model.toJSON = function() {
358
+ return this.recordsValues();
359
+ };
360
+
361
+ Model.fromJSON = function(objects) {
362
+ var value, _i, _len, _results;
363
+ if (!objects) {
364
+ return;
365
+ }
366
+ if (typeof objects === 'string') {
367
+ objects = JSON.parse(objects);
368
+ }
369
+ if (isArray(objects)) {
370
+ _results = [];
371
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
372
+ value = objects[_i];
373
+ _results.push(new this(value));
374
+ }
375
+ return _results;
376
+ } else {
377
+ return new this(objects);
378
+ }
379
+ };
380
+
381
+ Model.fromForm = function() {
382
+ var _ref;
383
+ return (_ref = new this).fromForm.apply(_ref, arguments);
384
+ };
385
+
386
+ Model.recordsValues = function() {
387
+ var key, result, value, _ref;
388
+ result = [];
389
+ _ref = this.records;
390
+ for (key in _ref) {
391
+ value = _ref[key];
392
+ result.push(value);
393
+ }
394
+ return result;
395
+ };
396
+
397
+ Model.cloneArray = function(array) {
398
+ var value, _i, _len, _results;
399
+ _results = [];
400
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
401
+ value = array[_i];
402
+ _results.push(value.clone());
403
+ }
404
+ return _results;
405
+ };
406
+
407
+ Model.idCounter = 0;
408
+
409
+ Model.uid = function(prefix) {
410
+ if (prefix == null) {
411
+ prefix = '';
412
+ }
413
+ return prefix + this.idCounter++;
414
+ };
415
+
416
+ function Model(atts) {
417
+ Model.__super__.constructor.apply(this, arguments);
418
+ if (atts) {
419
+ this.load(atts);
420
+ }
421
+ this.cid = this.constructor.uid('c-');
422
+ }
423
+
424
+ Model.prototype.isNew = function() {
425
+ return !this.exists();
426
+ };
427
+
428
+ Model.prototype.isValid = function() {
429
+ return !this.validate();
430
+ };
431
+
432
+ Model.prototype.validate = function() {};
433
+
434
+ Model.prototype.load = function(atts) {
435
+ var key, value;
436
+ for (key in atts) {
437
+ value = atts[key];
438
+ if (typeof this[key] === 'function') {
439
+ this[key](value);
440
+ } else {
441
+ this[key] = value;
442
+ }
443
+ }
444
+ return this;
445
+ };
446
+
447
+ Model.prototype.attributes = function() {
448
+ var key, result, _i, _len, _ref;
449
+ result = {};
450
+ _ref = this.constructor.attributes;
451
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
452
+ key = _ref[_i];
453
+ if (key in this) {
454
+ if (typeof this[key] === 'function') {
455
+ result[key] = this[key]();
456
+ } else {
457
+ result[key] = this[key];
458
+ }
459
+ }
460
+ }
461
+ if (this.id) {
462
+ result.id = this.id;
463
+ }
464
+ return result;
465
+ };
466
+
467
+ Model.prototype.eql = function(rec) {
468
+ return !!(rec && rec.constructor === this.constructor && (rec.cid === this.cid) || (rec.id && rec.id === this.id));
469
+ };
470
+
471
+ Model.prototype.save = function(options) {
472
+ var error, record;
473
+ if (options == null) {
474
+ options = {};
475
+ }
476
+ if (options.validate !== false) {
477
+ error = this.validate();
478
+ if (error) {
479
+ this.trigger('error', error);
480
+ return false;
481
+ }
482
+ }
483
+ this.trigger('beforeSave', options);
484
+ record = this.isNew() ? this.create(options) : this.update(options);
485
+ this.trigger('save', options);
486
+ return record;
487
+ };
488
+
489
+ Model.prototype.updateAttribute = function(name, value, options) {
490
+ this[name] = value;
491
+ return this.save(options);
492
+ };
493
+
494
+ Model.prototype.updateAttributes = function(atts, options) {
495
+ this.load(atts);
496
+ return this.save(options);
497
+ };
498
+
499
+ Model.prototype.changeID = function(id) {
500
+ var records;
501
+ records = this.constructor.records;
502
+ records[id] = records[this.id];
503
+ delete records[this.id];
504
+ this.id = id;
505
+ return this.save();
506
+ };
507
+
508
+ Model.prototype.destroy = function(options) {
509
+ if (options == null) {
510
+ options = {};
511
+ }
512
+ this.trigger('beforeDestroy', options);
513
+ delete this.constructor.records[this.id];
514
+ delete this.constructor.crecords[this.cid];
515
+ this.destroyed = true;
516
+ this.trigger('destroy', options);
517
+ this.trigger('change', 'destroy', options);
518
+ this.unbind();
519
+ return this;
520
+ };
521
+
522
+ Model.prototype.dup = function(newRecord) {
523
+ var result;
524
+ result = new this.constructor(this.attributes());
525
+ if (newRecord === false) {
526
+ result.cid = this.cid;
527
+ } else {
528
+ delete result.id;
529
+ }
530
+ return result;
531
+ };
532
+
533
+ Model.prototype.clone = function() {
534
+ return createObject(this);
535
+ };
536
+
537
+ Model.prototype.reload = function() {
538
+ var original;
539
+ if (this.isNew()) {
540
+ return this;
541
+ }
542
+ original = this.constructor.find(this.id);
543
+ this.load(original.attributes());
544
+ return original;
545
+ };
546
+
547
+ Model.prototype.toJSON = function() {
548
+ return this.attributes();
549
+ };
550
+
551
+ Model.prototype.toString = function() {
552
+ return "<" + this.constructor.className + " (" + (JSON.stringify(this)) + ")>";
553
+ };
554
+
555
+ Model.prototype.fromForm = function(form) {
556
+ var key, result, _i, _len, _ref;
557
+ result = {};
558
+ _ref = $(form).serializeArray();
559
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
560
+ key = _ref[_i];
561
+ result[key.name] = key.value;
562
+ }
563
+ return this.load(result);
564
+ };
565
+
566
+ Model.prototype.exists = function() {
567
+ return this.id && this.id in this.constructor.records;
568
+ };
569
+
570
+ Model.prototype.update = function(options) {
571
+ var clone, records;
572
+ this.trigger('beforeUpdate', options);
573
+ records = this.constructor.records;
574
+ records[this.id].load(this.attributes());
575
+ clone = records[this.id].clone();
576
+ clone.trigger('update', options);
577
+ clone.trigger('change', 'update', options);
578
+ return clone;
579
+ };
580
+
581
+ Model.prototype.create = function(options) {
582
+ var clone, record;
583
+ this.trigger('beforeCreate', options);
584
+ if (!this.id) {
585
+ this.id = this.cid;
586
+ }
587
+ record = this.dup(false);
588
+ this.constructor.records[this.id] = record;
589
+ this.constructor.crecords[this.cid] = record;
590
+ clone = record.clone();
591
+ clone.trigger('create', options);
592
+ clone.trigger('change', 'create', options);
593
+ return clone;
594
+ };
595
+
596
+ Model.prototype.bind = function(events, callback) {
597
+ var binder, unbinder,
598
+ _this = this;
599
+ this.constructor.bind(events, binder = function(record) {
600
+ if (record && _this.eql(record)) {
601
+ return callback.apply(_this, arguments);
602
+ }
603
+ });
604
+ this.constructor.bind('unbind', unbinder = function(record) {
605
+ if (record && _this.eql(record)) {
606
+ _this.constructor.unbind(events, binder);
607
+ return _this.constructor.unbind('unbind', unbinder);
608
+ }
609
+ });
610
+ return binder;
611
+ };
612
+
613
+ Model.prototype.one = function(events, callback) {
614
+ var binder,
615
+ _this = this;
616
+ return binder = this.bind(events, function() {
617
+ _this.constructor.unbind(events, binder);
618
+ return callback.apply(_this, arguments);
619
+ });
620
+ };
621
+
622
+ Model.prototype.trigger = function() {
623
+ var args, _ref;
624
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
625
+ args.splice(1, 0, this);
626
+ return (_ref = this.constructor).trigger.apply(_ref, args);
627
+ };
628
+
629
+ Model.prototype.unbind = function() {
630
+ return this.trigger('unbind');
631
+ };
632
+
633
+ return Model;
634
+
635
+ })(Module);
636
+
637
+ Controller = (function(_super) {
638
+
639
+ __extends(Controller, _super);
640
+
641
+ Controller.include(Events);
642
+
643
+ Controller.include(Log);
644
+
645
+ Controller.prototype.eventSplitter = /^(\S+)\s*(.*)$/;
646
+
647
+ Controller.prototype.tag = 'div';
648
+
649
+ function Controller(options) {
650
+ this.release = __bind(this.release, this);
651
+
652
+ var key, value, _ref;
653
+ this.options = options;
654
+ _ref = this.options;
655
+ for (key in _ref) {
656
+ value = _ref[key];
657
+ this[key] = value;
658
+ }
659
+ if (!this.el) {
660
+ this.el = document.createElement(this.tag);
661
+ }
662
+ this.el = $(this.el);
663
+ if (this.className) {
664
+ this.el.addClass(this.className);
665
+ }
666
+ if (this.attributes) {
667
+ this.el.attr(this.attributes);
668
+ }
669
+ if (!this.events) {
670
+ this.events = this.constructor.events;
671
+ }
672
+ if (!this.elements) {
673
+ this.elements = this.constructor.elements;
674
+ }
675
+ if (this.events) {
676
+ this.delegateEvents(this.events);
677
+ }
678
+ if (this.elements) {
679
+ this.refreshElements();
680
+ }
681
+ Controller.__super__.constructor.apply(this, arguments);
682
+ }
683
+
684
+ Controller.prototype.release = function() {
685
+ this.trigger('release');
686
+ this.el.remove();
687
+ return this.unbind();
688
+ };
689
+
690
+ Controller.prototype.$ = function(selector) {
691
+ return $(selector, this.el);
692
+ };
693
+
694
+ Controller.prototype.delegateEvents = function(events) {
695
+ var eventName, key, match, method, selector, _results,
696
+ _this = this;
697
+ _results = [];
698
+ for (key in events) {
699
+ method = events[key];
700
+ if (typeof method === 'function') {
701
+ method = (function(method) {
702
+ return function() {
703
+ method.apply(_this, arguments);
704
+ return true;
705
+ };
706
+ })(method);
707
+ } else {
708
+ method = (function(method) {
709
+ return function() {
710
+ _this[method].apply(_this, arguments);
711
+ return true;
712
+ };
713
+ })(method);
714
+ }
715
+ match = key.match(this.eventSplitter);
716
+ eventName = match[1];
717
+ selector = match[2];
718
+ if (selector === '') {
719
+ _results.push(this.el.bind(eventName, method));
720
+ } else {
721
+ _results.push(this.el.delegate(selector, eventName, method));
722
+ }
723
+ }
724
+ return _results;
725
+ };
726
+
727
+ Controller.prototype.refreshElements = function() {
728
+ var key, value, _ref, _results;
729
+ _ref = this.elements;
730
+ _results = [];
731
+ for (key in _ref) {
732
+ value = _ref[key];
733
+ _results.push(this[value] = this.$(key));
734
+ }
735
+ return _results;
736
+ };
737
+
738
+ Controller.prototype.delay = function(func, timeout) {
739
+ return setTimeout(this.proxy(func), timeout || 0);
740
+ };
741
+
742
+ Controller.prototype.html = function(element) {
743
+ this.el.html(element.el || element);
744
+ this.refreshElements();
745
+ return this.el;
746
+ };
747
+
748
+ Controller.prototype.append = function() {
749
+ var e, elements, _ref;
750
+ elements = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
751
+ elements = (function() {
752
+ var _i, _len, _results;
753
+ _results = [];
754
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
755
+ e = elements[_i];
756
+ _results.push(e.el || e);
757
+ }
758
+ return _results;
759
+ })();
760
+ (_ref = this.el).append.apply(_ref, elements);
761
+ this.refreshElements();
762
+ return this.el;
763
+ };
764
+
765
+ Controller.prototype.appendTo = function(element) {
766
+ this.el.appendTo(element.el || element);
767
+ this.refreshElements();
768
+ return this.el;
769
+ };
770
+
771
+ Controller.prototype.prepend = function() {
772
+ var e, elements, _ref;
773
+ elements = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
774
+ elements = (function() {
775
+ var _i, _len, _results;
776
+ _results = [];
777
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
778
+ e = elements[_i];
779
+ _results.push(e.el || e);
780
+ }
781
+ return _results;
782
+ })();
783
+ (_ref = this.el).prepend.apply(_ref, elements);
784
+ this.refreshElements();
785
+ return this.el;
786
+ };
787
+
788
+ Controller.prototype.replace = function(element) {
789
+ var previous, _ref;
790
+ _ref = [this.el, $(element.el || element)], previous = _ref[0], this.el = _ref[1];
791
+ previous.replaceWith(this.el);
792
+ this.delegateEvents(this.events);
793
+ this.refreshElements();
794
+ return this.el;
795
+ };
796
+
797
+ return Controller;
798
+
799
+ })(Module);
800
+
801
+ $ = (typeof window !== "undefined" && window !== null ? window.jQuery : void 0) || (typeof window !== "undefined" && window !== null ? window.Zepto : void 0) || function(element) {
802
+ return element;
803
+ };
804
+
805
+ createObject = Object.create || function(o) {
806
+ var Func;
807
+ Func = function() {};
808
+ Func.prototype = o;
809
+ return new Func();
810
+ };
811
+
812
+ isArray = function(value) {
813
+ return Object.prototype.toString.call(value) === '[object Array]';
814
+ };
815
+
816
+ isBlank = function(value) {
817
+ var key;
818
+ if (!value) {
819
+ return true;
820
+ }
821
+ for (key in value) {
822
+ return false;
823
+ }
824
+ return true;
825
+ };
826
+
827
+ makeArray = function(args) {
828
+ return Array.prototype.slice.call(args, 0);
829
+ };
830
+
831
+ Spine = this.Spine = {};
832
+
833
+ if (typeof module !== "undefined" && module !== null) {
834
+ module.exports = Spine;
835
+ }
836
+
837
+ Spine.version = '1.0.6';
838
+
839
+ Spine.isArray = isArray;
840
+
841
+ Spine.isBlank = isBlank;
842
+
843
+ Spine.$ = $;
844
+
845
+ Spine.Events = Events;
846
+
847
+ Spine.Log = Log;
848
+
849
+ Spine.Module = Module;
850
+
851
+ Spine.Controller = Controller;
852
+
853
+ Spine.Model = Model;
854
+
855
+ Module.extend.call(Spine, Events);
856
+
857
+ Module.create = Module.sub = Controller.create = Controller.sub = Model.sub = function(instances, statics) {
858
+ var result;
859
+ result = (function(_super) {
860
+
861
+ __extends(result, _super);
862
+
863
+ function result() {
864
+ return result.__super__.constructor.apply(this, arguments);
865
+ }
866
+
867
+ return result;
868
+
869
+ })(this);
870
+ if (instances) {
871
+ result.include(instances);
872
+ }
873
+ if (statics) {
874
+ result.extend(statics);
875
+ }
876
+ if (typeof result.unbind === "function") {
877
+ result.unbind();
878
+ }
879
+ return result;
880
+ };
881
+
882
+ Model.setup = function(name, attributes) {
883
+ var Instance;
884
+ if (attributes == null) {
885
+ attributes = [];
886
+ }
887
+ Instance = (function(_super) {
888
+
889
+ __extends(Instance, _super);
890
+
891
+ function Instance() {
892
+ return Instance.__super__.constructor.apply(this, arguments);
893
+ }
894
+
895
+ return Instance;
896
+
897
+ })(this);
898
+ Instance.configure.apply(Instance, [name].concat(__slice.call(attributes)));
899
+ return Instance;
900
+ };
901
+
902
+ Spine.Class = Module;
903
+
904
+ }).call(this);