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