event_cal 1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module EventCal
2
- VERSION = "1.2"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -3,9 +3,31 @@ class CalendarApplication
3
3
  'ul.dates': CalendarDatesController
4
4
  'ul.event_details': CalendarEventsController
5
5
 
6
- @initialize = () ->
6
+ @initialize = (options = {}) ->
7
7
  for element, controller of calendarElements
8
8
  for el in $(element)
9
9
  new controller($(el))
10
10
 
11
+ if options.history
12
+ @initializeHistory(options.basePath)
13
+
14
+ @initializeHistory = (basePath) ->
15
+ CalendarDate.all().map(
16
+ (date) ->
17
+ date.element.bind('click', (event) ->
18
+ window?.history?.pushState(
19
+ { dateObjectId: date.id },
20
+ null,
21
+ "#{basePath}/#{date.toPath()}"
22
+ )
23
+ )
24
+ )
25
+
26
+ window?.onpopstate = (event) ->
27
+ if event.state?.dateObjectId?
28
+ date = CalendarDate.find(event.state.dateObjectId)
29
+ date.trigger('activate')
30
+ CalendarDate.deactivateAllDates()
31
+ date.updateAttributes(active: true)
32
+
11
33
  window.CalendarApplication = CalendarApplication
@@ -1,10 +1,10 @@
1
- // Generated by CoffeeScript 1.3.1
1
+ // Generated by CoffeeScript 1.3.3
2
2
  (function() {
3
3
  var $, CalendarApplication, CalendarDate, CalendarDatesController, CalendarEvent, CalendarEventsController, Controller, Events, Log, Model, Module, Spine, createObject, isArray, isBlank, makeArray, moduleKeywords,
4
4
  __slice = [].slice,
5
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
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; },
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
8
  __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
9
9
 
10
10
  Events = {
@@ -94,8 +94,6 @@
94
94
 
95
95
  Module = (function() {
96
96
 
97
- Module.name = 'Module';
98
-
99
97
  Module.include = function(obj) {
100
98
  var key, value, _ref;
101
99
  if (!obj) {
@@ -158,8 +156,6 @@
158
156
 
159
157
  __extends(Model, _super);
160
158
 
161
- Model.name = 'Model';
162
-
163
159
  Model.extend(Events);
164
160
 
165
161
  Model.records = {};
@@ -647,8 +643,6 @@
647
643
 
648
644
  __extends(Controller, _super);
649
645
 
650
- Controller.name = 'Controller';
651
-
652
646
  Controller.include(Events);
653
647
 
654
648
  Controller.include(Log);
@@ -875,8 +869,6 @@
875
869
 
876
870
  __extends(Result, _super);
877
871
 
878
- Result.name = 'Result';
879
-
880
872
  function Result() {
881
873
  return Result.__super__.constructor.apply(this, arguments);
882
874
  }
@@ -905,8 +897,6 @@
905
897
 
906
898
  __extends(Instance, _super);
907
899
 
908
- Instance.name = 'Instance';
909
-
910
900
  function Instance() {
911
901
  return Instance.__super__.constructor.apply(this, arguments);
912
902
  }
@@ -924,8 +914,6 @@
924
914
 
925
915
  __extends(CalendarDate, _super);
926
916
 
927
- CalendarDate.name = 'CalendarDate';
928
-
929
917
  function CalendarDate() {
930
918
  return CalendarDate.__super__.constructor.apply(this, arguments);
931
919
  }
@@ -954,8 +942,6 @@
954
942
 
955
943
  __extends(CalendarEvent, _super);
956
944
 
957
- CalendarEvent.name = 'CalendarEvent';
958
-
959
945
  function CalendarEvent() {
960
946
  return CalendarEvent.__super__.constructor.apply(this, arguments);
961
947
  }
@@ -993,8 +979,6 @@
993
979
 
994
980
  __extends(CalendarDatesController, _super);
995
981
 
996
- CalendarDatesController.name = 'CalendarDatesController';
997
-
998
982
  function CalendarDatesController(element) {
999
983
  this.element = element;
1000
984
  this.initializeDates();
@@ -1048,8 +1032,6 @@
1048
1032
 
1049
1033
  __extends(CalendarEventsController, _super);
1050
1034
 
1051
- CalendarEventsController.name = 'CalendarEventsController';
1052
-
1053
1035
  function CalendarEventsController(element) {
1054
1036
  var el, event, _i, _len, _ref;
1055
1037
  _ref = element.find('.event_detail');
@@ -1084,8 +1066,6 @@
1084
1066
  CalendarApplication = (function() {
1085
1067
  var calendarElements;
1086
1068
 
1087
- CalendarApplication.name = 'CalendarApplication';
1088
-
1089
1069
  function CalendarApplication() {}
1090
1070
 
1091
1071
  calendarElements = {
@@ -1093,23 +1073,44 @@
1093
1073
  'ul.event_details': CalendarEventsController
1094
1074
  };
1095
1075
 
1096
- CalendarApplication.initialize = function() {
1097
- var controller, el, element, _results;
1098
- _results = [];
1076
+ CalendarApplication.initialize = function(options) {
1077
+ var controller, el, element, _i, _len, _ref;
1078
+ if (options == null) {
1079
+ options = {};
1080
+ }
1099
1081
  for (element in calendarElements) {
1100
1082
  controller = calendarElements[element];
1101
- _results.push((function() {
1102
- var _i, _len, _ref, _results1;
1103
- _ref = $(element);
1104
- _results1 = [];
1105
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1106
- el = _ref[_i];
1107
- _results1.push(new controller($(el)));
1108
- }
1109
- return _results1;
1110
- })());
1083
+ _ref = $(element);
1084
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1085
+ el = _ref[_i];
1086
+ new controller($(el));
1087
+ }
1111
1088
  }
1112
- return _results;
1089
+ if (options.history) {
1090
+ return this.initializeHistory(options.basePath);
1091
+ }
1092
+ };
1093
+
1094
+ CalendarApplication.initializeHistory = function(basePath) {
1095
+ CalendarDate.all().map(function(date) {
1096
+ return date.element.bind('click', function(event) {
1097
+ var _ref;
1098
+ return typeof window !== "undefined" && window !== null ? (_ref = window.history) != null ? _ref.pushState({
1099
+ dateObjectId: date.id
1100
+ }, null, "" + basePath + "/" + (date.toPath())) : void 0 : void 0;
1101
+ });
1102
+ });
1103
+ return typeof window !== "undefined" && window !== null ? window.onpopstate = function(event) {
1104
+ var date, _ref;
1105
+ if (((_ref = event.state) != null ? _ref.dateObjectId : void 0) != null) {
1106
+ date = CalendarDate.find(event.state.dateObjectId);
1107
+ date.trigger('activate');
1108
+ CalendarDate.deactivateAllDates();
1109
+ return date.updateAttributes({
1110
+ active: true
1111
+ });
1112
+ }
1113
+ } : void 0;
1113
1114
  };
1114
1115
 
1115
1116
  return CalendarApplication;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_cal
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
12
+ date: 2013-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  segments:
258
258
  - 0
259
- hash: -3951531597306759713
259
+ hash: -4110643961258391012
260
260
  required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  none: false
262
262
  requirements:
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  segments:
267
267
  - 0
268
- hash: -3951531597306759713
268
+ hash: -4110643961258391012
269
269
  requirements: []
270
270
  rubyforge_project:
271
271
  rubygems_version: 1.8.24