active_administration 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +2 -1
  4. data/active_administration.gemspec +2 -1
  5. data/app/assets/javascripts/active_administration/README.md +0 -0
  6. data/app/assets/javascripts/active_administration/metro-accordion.js +70 -0
  7. data/app/assets/javascripts/active_administration/metro-button-set.js +88 -0
  8. data/app/assets/javascripts/active_administration/metro-calendar.js +437 -0
  9. data/app/assets/javascripts/active_administration/metro-carousel.js +304 -0
  10. data/app/assets/javascripts/active_administration/metro-core.js +39 -0
  11. data/app/assets/javascripts/active_administration/metro-countdown.js +200 -0
  12. data/app/assets/javascripts/active_administration/metro-date-format.js +137 -0
  13. data/app/assets/javascripts/active_administration/metro-datepicker.js +138 -0
  14. data/app/assets/javascripts/active_administration/metro-dialog.js +221 -0
  15. data/app/assets/javascripts/active_administration/metro-drag-tile.js +46 -0
  16. data/app/assets/javascripts/active_administration/metro-dropdown.js +112 -0
  17. data/app/assets/javascripts/active_administration/metro-fluentmenu.js +57 -0
  18. data/app/assets/javascripts/active_administration/metro-global.js +4 -0
  19. data/app/assets/javascripts/active_administration/metro-hint.js +104 -0
  20. data/app/assets/javascripts/active_administration/metro-initiator.js +271 -0
  21. data/app/assets/javascripts/active_administration/metro-input-control.js +318 -0
  22. data/app/assets/javascripts/active_administration/metro-listview.js +53 -0
  23. data/app/assets/javascripts/active_administration/metro-live-tile.js +162 -0
  24. data/app/assets/javascripts/active_administration/metro-loader.js +46 -0
  25. data/app/assets/javascripts/active_administration/metro-locale.js +132 -0
  26. data/app/assets/javascripts/active_administration/metro-notify.js +120 -0
  27. data/app/assets/javascripts/active_administration/metro-panel.js +41 -0
  28. data/app/assets/javascripts/active_administration/metro-plugin-template.js +21 -0
  29. data/app/assets/javascripts/active_administration/metro-progressbar.js +97 -0
  30. data/app/assets/javascripts/active_administration/metro-pull.js +38 -0
  31. data/app/assets/javascripts/active_administration/metro-rating.js +99 -0
  32. data/app/assets/javascripts/active_administration/metro-scroll.js +756 -0
  33. data/app/assets/javascripts/active_administration/metro-slider.js +304 -0
  34. data/app/assets/javascripts/active_administration/metro-stepper.js +105 -0
  35. data/app/assets/javascripts/active_administration/metro-streamer.js +214 -0
  36. data/app/assets/javascripts/active_administration/metro-tab-control.js +96 -0
  37. data/app/assets/javascripts/active_administration/metro-table.js +74 -0
  38. data/app/assets/javascripts/active_administration/metro-tile-transform.js +65 -0
  39. data/app/assets/javascripts/active_administration/metro-times.js +190 -0
  40. data/app/assets/javascripts/active_administration/metro-touch-handler.js +65 -0
  41. data/app/assets/javascripts/active_administration/metro-treeview.js +64 -0
  42. data/app/assets/javascripts/active_administration/metro-wizard.js +148 -0
  43. data/app/assets/stylesheets/active_administration/accordion.less +64 -0
  44. data/app/assets/stylesheets/active_administration/balloon.less +88 -0
  45. data/app/assets/stylesheets/active_administration/breadcrumbs.less +118 -0
  46. data/app/assets/stylesheets/active_administration/buttons.less +383 -0
  47. data/app/assets/stylesheets/active_administration/calendar.less +123 -0
  48. data/app/assets/stylesheets/active_administration/carousel.less +118 -0
  49. data/app/assets/stylesheets/active_administration/colors.less +589 -0
  50. data/app/assets/stylesheets/active_administration/countdown.less +57 -0
  51. data/app/assets/stylesheets/active_administration/dataTables.less +134 -0
  52. data/app/assets/stylesheets/active_administration/fluent-menu.less +231 -0
  53. data/app/assets/stylesheets/active_administration/forms.less +414 -0
  54. data/app/assets/stylesheets/active_administration/funcs.less +178 -0
  55. data/app/assets/stylesheets/active_administration/grid.less +91 -0
  56. data/app/assets/stylesheets/active_administration/hint.less +120 -0
  57. data/app/assets/stylesheets/active_administration/iconFont-content.less +1353 -0
  58. data/app/assets/stylesheets/active_administration/iconFont.less +47 -0
  59. data/app/assets/stylesheets/active_administration/icons.less +10 -0
  60. data/app/assets/stylesheets/active_administration/images.less +75 -0
  61. data/app/assets/stylesheets/active_administration/layout.less +137 -0
  62. data/app/assets/stylesheets/active_administration/lists.less +258 -0
  63. data/app/assets/stylesheets/active_administration/menus.less +469 -0
  64. data/app/assets/stylesheets/active_administration/metro-bootstrap-responsive.less +300 -0
  65. data/app/assets/stylesheets/active_administration/metro-bootstrap.less +68 -0
  66. data/app/assets/stylesheets/active_administration/misc.less +72 -0
  67. data/app/assets/stylesheets/active_administration/navigation-bar.less +317 -0
  68. data/app/assets/stylesheets/active_administration/notice.less +52 -0
  69. data/app/assets/stylesheets/active_administration/notify.less +43 -0
  70. data/app/assets/stylesheets/active_administration/pagination.less +83 -0
  71. data/app/assets/stylesheets/active_administration/panels.less +38 -0
  72. data/app/assets/stylesheets/active_administration/progress-bar.less +25 -0
  73. data/app/assets/stylesheets/active_administration/rating.less +103 -0
  74. data/app/assets/stylesheets/active_administration/reset.less +219 -0
  75. data/app/assets/stylesheets/active_administration/scroll.less +141 -0
  76. data/app/assets/stylesheets/active_administration/sidebar.less +158 -0
  77. data/app/assets/stylesheets/active_administration/slider.less +106 -0
  78. data/app/assets/stylesheets/active_administration/stepper.less +80 -0
  79. data/app/assets/stylesheets/active_administration/streamer.less +250 -0
  80. data/app/assets/stylesheets/active_administration/tab-control.less +79 -0
  81. data/app/assets/stylesheets/active_administration/tables.less +170 -0
  82. data/app/assets/stylesheets/active_administration/tiles.less +599 -0
  83. data/app/assets/stylesheets/active_administration/transform.less +23 -0
  84. data/app/assets/stylesheets/active_administration/treeview.less +96 -0
  85. data/app/assets/stylesheets/active_administration/typography.less +382 -0
  86. data/app/assets/stylesheets/active_administration/utils.less +180 -0
  87. data/app/assets/stylesheets/active_administration/variables.less +250 -0
  88. data/app/assets/stylesheets/active_administration/window.less +225 -0
  89. data/app/assets/stylesheets/active_administration/wizard.less +53 -0
  90. data/lib/active_admin/version.rb +1 -1
  91. metadata +103 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4869147cbc28e3ea088e65a3c69bd1a96d15e857
4
- data.tar.gz: e0012586ffb44572615e192d3996eeb03f2b3ee6
3
+ metadata.gz: 51367a985a3d1b25a78afa5d655f3bf28fcfb932
4
+ data.tar.gz: 1cc8f4e7efebef5339236aadea9e8dc1dfb8e9b8
5
5
  SHA512:
6
- metadata.gz: 0eb4b03389654f09c8737d1398382430bba8fda8171b7b8570aed4002361108c42791d091d89de5ae4a4296de04348d7c3b90d5de66824bada5ec47087b825f1
7
- data.tar.gz: 917d046e911a5fe3ff91ed93793b97979b52398ffbe773e3e8cec8a3f8fc2fc5602cded40835e2ce73542ae69895c991b42d124ea9a75a752f6ade129c90bd58
6
+ metadata.gz: c10b1856ea093eacfab2963ef574e89033071af4936cc0284b496651d95ea844cb872cba3df9fb0d14edba3f9b4600d96337c5300bb5678d5f480709e782faa8
7
+ data.tar.gz: 771735d7b28e860d5061b1e2e34416f28f08776b3a5aba8efe9d0e583853b1bebcafffea9942a0d687b1ae716f5bde42cca1985c4da949e69bf4a32e19cafc1e
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ ACTIVE_ADMIN_PATH = File.dirname(__FILE__) unless defined?(ACTIVE_ADMIN_PATH)
7
7
  require File.expand_path('spec/support/detect_rails_version', ACTIVE_ADMIN_PATH)
8
8
 
9
9
  rails_version = detect_rails_version
10
- gem 'rails', rails_version
10
+ gem 'rails', rails_version, path: '/root/rails'
11
11
 
12
12
  gem 'arbre', github: 'gregbell/arbre' # until gregbell/arbre#16 makes it into an official release
13
13
 
data/README.md CHANGED
@@ -4,5 +4,6 @@ Active Administration is a Ruby on Rails framework for creating professional adm
4
4
 
5
5
  ## Difference from Active Admin
6
6
 
7
- * Built default user interface upon [![Metro-UI-CSS](https://github.com/olton/Metro-UI-CSS)]
7
+ * Utilizes [Metro-UI-CSS](https://github.com/olton/Metro-UI-CSS) to build polished user interfaces
8
+ * Supports up to Rails 4.2.0.alpha
8
9
  * to be continued...
@@ -27,8 +27,9 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency 'jquery-rails'
28
28
  s.add_dependency 'jquery-ui-rails'
29
29
  s.add_dependency 'kaminari', '~> 0.15'
30
- s.add_dependency 'rails', '>= 3.2', '< 4.1'
30
+ s.add_dependency 'rails', '>= 4.0.4'
31
31
  s.add_dependency 'ransack', '~> 1.0'
32
32
  s.add_dependency 'sass-rails'
33
+ s.add_dependency 'less-rails'
33
34
  end
34
35
 
@@ -0,0 +1,70 @@
1
+ (function( $ ) {
2
+ $.widget("metro.accordion", {
3
+
4
+ version: "1.0.0",
5
+
6
+ options: {
7
+ closeAny: true,
8
+ open: function(frame){},
9
+ action: function(frame){}
10
+ },
11
+
12
+ _frames: {},
13
+
14
+ _create: function(){
15
+ var element = this.element;
16
+
17
+ if (element.data('closeany') != undefined) this.options.closeAny = element.data('closeany');
18
+
19
+ this._frames = element.children(".accordion-frame");
20
+
21
+ this.init();
22
+ },
23
+
24
+ init: function(){
25
+ var that = this;
26
+
27
+ this._frames.each(function(){
28
+ var frame = this,
29
+ a = $(this).children(".heading"),
30
+ content = $(this).children(".content");
31
+
32
+ if ($(a).hasClass("active") && !$(a).attr('disabled') && $(a).data('action') != 'none') {
33
+ $(content).show();
34
+ $(a).removeClass("collapsed");
35
+ } else {
36
+ $(a).addClass("collapsed");
37
+ }
38
+
39
+ a.on('click', function(e){
40
+ e.preventDefault();
41
+ if ($(this).attr('disabled') || $(this).data('action') == 'none') return;
42
+
43
+ if (that.options.closeAny) that._closeFrames();
44
+
45
+ if ($(content).is(":hidden")) {
46
+ $(content).slideDown();
47
+ $(this).removeClass("collapsed");
48
+ that._trigger("frame", e, {frame: frame});
49
+ that.options.open(frame);
50
+ } else {
51
+ $(content).slideUp();
52
+ $(this).addClass("collapsed");
53
+ }
54
+ that.options.action(frame);
55
+ });
56
+ });
57
+ },
58
+
59
+ _closeFrames: function(){
60
+ this._frames.children(".content").slideUp().parent().children('.heading').addClass("collapsed");
61
+ },
62
+
63
+ _destroy: function(){},
64
+
65
+ _setOption: function(key, value){
66
+ this._super('_setOption', key, value);
67
+ }
68
+ })
69
+ })( jQuery );
70
+
@@ -0,0 +1,88 @@
1
+ (function( $ ) {
2
+ $.widget("metro.buttonset", {
3
+
4
+ version: "1.0.0",
5
+
6
+ options: {
7
+ click: function(btn, on){}
8
+ },
9
+
10
+ _buttons: {},
11
+
12
+ _create: function(){
13
+ var element = this.element;
14
+
15
+ this._buttons = element.find("button, .button");
16
+
17
+ this.init();
18
+ },
19
+
20
+ init: function(){
21
+ var that = this;
22
+
23
+ this._buttons.each(function(){
24
+ var btn = $(this);
25
+
26
+ btn.on('click', function(e){
27
+ e.preventDefault();
28
+ btn.toggleClass("active");
29
+
30
+ that.options.click(btn, btn.hasClass("active"));
31
+ that._trigger("click", null, {button: btn, on: (btn.hasClass("active"))});
32
+ });
33
+ });
34
+ },
35
+
36
+ _destroy: function(){},
37
+
38
+ _setOption: function(key, value){
39
+ this._super('_setOption', key, value);
40
+ }
41
+ })
42
+ })( jQuery );
43
+
44
+ (function( $ ) {
45
+ $.widget("metro.buttongroup", {
46
+
47
+ version: "1.0.0",
48
+
49
+ options: {
50
+ click: function(btn, on){}
51
+ },
52
+
53
+ _buttons: {},
54
+
55
+ _create: function(){
56
+ var element = this.element;
57
+
58
+ this._buttons = element.find("button, .button");
59
+
60
+ this.init();
61
+ },
62
+
63
+ init: function(){
64
+ var that = this;
65
+
66
+ this._buttons.each(function(){
67
+ var btn = $(this);
68
+
69
+ btn.on('click', function(e){
70
+ e.preventDefault();
71
+ that._buttons.removeClass("active");
72
+ btn.addClass("active");
73
+
74
+ that.options.click(btn, btn.hasClass("active"));
75
+ that._trigger("click", null, {button: btn, on: (btn.hasClass("active"))});
76
+ });
77
+ });
78
+ },
79
+
80
+ _destroy: function(){},
81
+
82
+ _setOption: function(key, value){
83
+ this._super('_setOption', key, value);
84
+ }
85
+ })
86
+ })( jQuery );
87
+
88
+
@@ -0,0 +1,437 @@
1
+ // Calendar
2
+
3
+ (function( $ ) {
4
+ $.widget("metro.calendar", {
5
+
6
+ version: "1.0.0",
7
+
8
+ options: {
9
+ format: "yyyy-mm-dd",
10
+ multiSelect: false,
11
+ startMode: 'day', //year, month, day
12
+ weekStart: (METRO_WEEK_START != undefined ? METRO_WEEK_START : 0), // 0 - Sunday, 1 - Monday
13
+ otherDays: false,
14
+ date: new Date(),
15
+ buttons: true,
16
+ locale: $.Metro.currentLocale,
17
+ getDates: function(d){},
18
+ click: function(d, d0){},
19
+ _storage: []
20
+ },
21
+
22
+ _year: 0,
23
+ _month: 0,
24
+ _day: 0,
25
+ _today: new Date(),
26
+ _event: '',
27
+
28
+ _mode: 'day', // day, month, year
29
+ _distance: 0,
30
+
31
+ _events: [],
32
+
33
+ _create: function(){
34
+ var element = this.element;
35
+
36
+ if (element.data('multiSelect') != undefined) this.options.multiSelect = element.data("multiSelect");
37
+ if (element.data('format') != undefined) this.options.format = element.data("format");
38
+ if (element.data('date') != undefined) this.options.date = new Date(element.data("date"));
39
+ if (element.data('locale') != undefined) this.options.locale = element.data("locale");
40
+ if (element.data('startMode') != undefined) this.options.startMode = element.data('startMode');
41
+ if (element.data('weekStart') != undefined) this.options.weekStart = element.data('weekStart');
42
+ if (element.data('otherDays') != undefined) this.options.otherDays = element.data('otherDays');
43
+
44
+ this._year = this.options.date.getFullYear();
45
+ this._distance = parseInt(this.options.date.getFullYear())-4;
46
+ this._month = this.options.date.getMonth();
47
+ this._day = this.options.date.getDate();
48
+ this._mode = this.options.startMode;
49
+
50
+ element.data("_storage", []);
51
+
52
+ this._renderCalendar();
53
+ },
54
+
55
+ _renderMonth: function(){
56
+ var year = this._year,
57
+ month = this._month,
58
+ day = this._day,
59
+ event = this._event,
60
+ feb = 28;
61
+
62
+ if (month == 1) {
63
+ if ((year%100!=0) && (year%4==0) || (year%400==0)) {
64
+ feb = 29;
65
+ }
66
+ }
67
+
68
+ var totalDays = ["31", ""+feb+"","31","30","31","30","31","31","30","31","30","31"];
69
+ var daysInMonth = totalDays[month];
70
+ var first_week_day = new Date(year, month, 1).getDay();
71
+
72
+ var table, tr, td, i;
73
+
74
+ this.element.html("");
75
+
76
+ table = $("<table/>").addClass("bordered");
77
+
78
+ // Add calendar header
79
+ tr = $("<tr/>");
80
+
81
+ $("<td/>").addClass("text-center").html("<a class='btn-previous-year' href='#'><i class='icon-previous'></i></a>").appendTo(tr);
82
+ $("<td/>").addClass("text-center").html("<a class='btn-previous-month' href='#'><i class='icon-arrow-left-4'></i></a>").appendTo(tr);
83
+
84
+ $("<td/>").attr("colspan", 3).addClass("text-center").html("<a class='btn-select-month' href='#'>"+ $.Metro.Locale[this.options.locale].months[month]+' '+year+"</a>").appendTo(tr);
85
+
86
+ $("<td/>").addClass("text-center").html("<a class='btn-next-month' href='#'><i class='icon-arrow-right-4'></i></a>").appendTo(tr);
87
+ $("<td/>").addClass("text-center").html("<a class='btn-next-year' href='#'><i class='icon-next'></i></a>").appendTo(tr);
88
+
89
+ tr.addClass("calendar-header").appendTo(table);
90
+
91
+ // Add day names
92
+ var j;
93
+ tr = $("<tr/>");
94
+ for(i = 0; i < 7; i++) {
95
+ if (!this.options.weekStart)
96
+ td = $("<td/>").addClass("text-center day-of-week").html($.Metro.Locale[this.options.locale].days[i+7]).appendTo(tr);
97
+ else {
98
+ j = i + 1;
99
+ if (j == 7) j = 0;
100
+ td = $("<td/>").addClass("text-center day-of-week").html($.Metro.Locale[this.options.locale].days[j+7]).appendTo(tr);
101
+
102
+ }
103
+ }
104
+ tr.addClass("calendar-subheader").appendTo(table);
105
+
106
+ // Add empty days for previos month
107
+ var prevMonth = this._month - 1; if (prevMonth < 0) prevMonth = 11; var daysInPrevMonth = totalDays[prevMonth];
108
+ var _first_week_day = ((this.options.weekStart) ? first_week_day + 6 : first_week_day)%7;
109
+ var htmlPrevDay = "";
110
+ tr = $("<tr/>");
111
+ for(i = 0; i < _first_week_day; i++) {
112
+ if (this.options.otherDays) htmlPrevDay = daysInPrevMonth - (_first_week_day - i - 1);
113
+ td = $("<td/>").addClass("empty").html("<small class='other-day'>"+htmlPrevDay+"</small>").appendTo(tr);
114
+ }
115
+
116
+ var week_day = ((this.options.weekStart) ? first_week_day + 6 : first_week_day)%7;
117
+ //console.log(week_day, week_day%7);
118
+
119
+ for (i = 1; i <= daysInMonth; i++) {
120
+ //console.log(week_day, week_day%7);
121
+
122
+ week_day %= 7;
123
+
124
+ if (week_day == 0) {
125
+ tr.appendTo(table);
126
+ tr = $("<tr/>");
127
+ }
128
+
129
+ td = $("<td/>").addClass("text-center day").html("<a href='#'>"+i+"</a>");
130
+ if (year == this._today.getFullYear() && month == this._today.getMonth() && this._today.getDate() == i) {
131
+ td.addClass("today");
132
+ }
133
+
134
+ var d = (new Date(this._year, this._month, i)).format('yyyy-mm-dd');
135
+ if (this.element.data('_storage').indexOf(d)>=0) {
136
+ td.find("a").addClass("selected");
137
+ }
138
+
139
+ td.appendTo(tr);
140
+ week_day++;
141
+ }
142
+
143
+ // next month other days
144
+ var htmlOtherDays = "";
145
+ for (i = week_day+1; i<=7; i++){
146
+ if (this.options.otherDays) htmlOtherDays = i - week_day;
147
+ td = $("<td/>").addClass("empty").html("<small class='other-day'>"+htmlOtherDays+"</small>").appendTo(tr);
148
+ }
149
+
150
+ tr.appendTo(table);
151
+
152
+ if (this.options.buttons) {
153
+ tr = $("<tr/>").addClass("calendar-actions");
154
+ td = $("<td/>").attr('colspan', 7).addClass("text-left").html("" +
155
+ "<button class='button calendar-btn-today small success'>"+$.Metro.Locale[this.options.locale].buttons[0]+
156
+ "</button>&nbsp;<button class='button calendar-btn-clear small warning'>"+$.Metro.Locale[this.options.locale].buttons[1]+"</button>");
157
+ td.appendTo(tr);
158
+ tr.appendTo(table);
159
+ }
160
+
161
+ table.appendTo(this.element);
162
+
163
+ this.options.getDates(this.element.data('_storage'));
164
+ },
165
+
166
+ _renderMonths: function(){
167
+ var table, tr, td, i, j;
168
+
169
+ this.element.html("");
170
+
171
+ table = $("<table/>").addClass("bordered");
172
+
173
+ // Add calendar header
174
+ tr = $("<tr/>");
175
+
176
+ $("<td/>").addClass("text-center").html("<a class='btn-previous-year' href='#'><i class='icon-arrow-left-4'></i></a>").appendTo(tr);
177
+ $("<td/>").attr("colspan", 2).addClass("text-center").html("<a class='btn-select-year' href='#'>"+this._year+"</a>").appendTo(tr);
178
+ $("<td/>").addClass("text-center").html("<a class='btn-next-year' href='#'><i class='icon-arrow-right-4'></i></a>").appendTo(tr);
179
+
180
+ tr.addClass("calendar-header").appendTo(table);
181
+
182
+ tr = $("<tr/>");
183
+ j = 0;
184
+ for (i=0;i<12;i++) {
185
+
186
+ //td = $("<td/>").addClass("text-center month").html("<a href='#' data-month='"+i+"'>"+this.options.monthsShort[i]+"</a>");
187
+ td = $("<td/>").addClass("text-center month").html("<a href='#' data-month='"+i+"'>"+$.Metro.Locale[this.options.locale].months[i+12]+"</a>");
188
+
189
+ if (this._month == i && (new Date()).getFullYear() == this._year) {
190
+ td.addClass("today");
191
+ }
192
+
193
+ td.appendTo(tr);
194
+ if ((j+1) % 4 == 0) {
195
+ tr.appendTo(table);
196
+ tr = $("<tr/>");
197
+ }
198
+ j+=1;
199
+ }
200
+
201
+ table.appendTo(this.element);
202
+ },
203
+
204
+ _renderYears: function(){
205
+ var table, tr, td, i, j;
206
+
207
+ this.element.html("");
208
+
209
+ table = $("<table/>").addClass("bordered");
210
+
211
+ // Add calendar header
212
+ tr = $("<tr/>");
213
+
214
+ $("<td/>").addClass("text-center").html("<a class='btn-previous-year' href='#'><i class='icon-arrow-left-4'></i></a>").appendTo(tr);
215
+ $("<td/>").attr("colspan", 2).addClass("text-center").html( (this._distance)+"-"+(this._distance+11) ).appendTo(tr);
216
+ $("<td/>").addClass("text-center").html("<a class='btn-next-year' href='#'><i class='icon-arrow-right-4'></i></a>").appendTo(tr);
217
+
218
+ tr.addClass("calendar-header").appendTo(table);
219
+
220
+ tr = $("<tr/>");
221
+
222
+ j = 0;
223
+ for (i=this._distance;i<this._distance+12;i++) {
224
+ td = $("<td/>").addClass("text-center year").html("<a href='#' data-year='"+i+"'>"+i+"</a>");
225
+ if ((new Date()).getFullYear() == i) {
226
+ td.addClass("today");
227
+ }
228
+ td.appendTo(tr);
229
+ if ((j+1) % 4 == 0) {
230
+ tr.appendTo(table);
231
+ tr = $("<tr/>");
232
+ }
233
+ j+=1;
234
+ }
235
+
236
+ table.appendTo(this.element);
237
+ },
238
+
239
+ _renderCalendar: function(){
240
+ switch (this._mode) {
241
+ case 'year': this._renderYears(); break;
242
+ case 'month': this._renderMonths(); break;
243
+ default: this._renderMonth();
244
+ }
245
+ this._initButtons();
246
+ },
247
+
248
+ _initButtons: function(){
249
+ // Add actions
250
+ var that = this, table = this.element.find('table');
251
+
252
+ if (this._mode == 'day') {
253
+ table.find('.btn-select-month').on('click', function(e){
254
+ e.preventDefault();
255
+ e.stopPropagation();
256
+ that._mode = 'month';
257
+ that._renderCalendar();
258
+ });
259
+ table.find('.btn-previous-month').on('click', function(e){
260
+ that._event = 'eventPrevious';
261
+ e.preventDefault();
262
+ e.stopPropagation();
263
+ that._month -= 1;
264
+ if (that._month < 0) {
265
+ that._year -= 1;
266
+ that._month = 11;
267
+ }
268
+ that._renderCalendar();
269
+ });
270
+ table.find('.btn-next-month').on('click', function(e){
271
+ that._event = 'eventNext';
272
+ e.preventDefault();
273
+ e.stopPropagation();
274
+ that._month += 1;
275
+ if (that._month == 12) {
276
+ that._year += 1;
277
+ that._month = 0;
278
+ }
279
+ that._renderCalendar();
280
+ });
281
+ table.find('.btn-previous-year').on('click', function(e){
282
+ that._event = 'eventPrevious';
283
+ e.preventDefault();
284
+ e.stopPropagation();
285
+ that._year -= 1;
286
+ that._renderCalendar();
287
+ });
288
+ table.find('.btn-next-year').on('click', function(e){
289
+ that._event = 'eventNext';
290
+ e.preventDefault();
291
+ e.stopPropagation();
292
+ that._year += 1;
293
+ that._renderCalendar();
294
+ });
295
+ table.find('.calendar-btn-today').on('click', function(e){
296
+ that._event = 'eventNext';
297
+ e.preventDefault();
298
+ e.stopPropagation();
299
+ that.options.date = new Date();
300
+ that._year = that.options.date.getFullYear();
301
+ that._month = that.options.date.getMonth();
302
+ that._day = that.options.date.getDate();
303
+ that._renderCalendar();
304
+ });
305
+ table.find('.calendar-btn-clear').on('click', function(e){
306
+ e.preventDefault();
307
+ e.stopPropagation();
308
+ that.options.date = new Date();
309
+ that._year = that.options.date.getFullYear();
310
+ that._month = that.options.date.getMonth();
311
+ that._day = that.options.date.getDate();
312
+ that.element.data('_storage', []);
313
+ that._renderCalendar();
314
+ });
315
+ table.find('.day a').on('click', function(e){
316
+ e.preventDefault();
317
+ e.stopPropagation();
318
+ var d = (new Date(that._year, that._month, parseInt($(this).html()))).format(that.options.format,null);
319
+ var d0 = (new Date(that._year, that._month, parseInt($(this).html())));
320
+
321
+ if (that.options.multiSelect) {
322
+ $(this).toggleClass("selected");
323
+
324
+ if ($(this).hasClass("selected")) {
325
+ that._addDate(d);
326
+ } else {
327
+ that._removeDate(d);
328
+ }
329
+ } else {
330
+ table.find('.day a').removeClass('selected');
331
+ $(this).addClass("selected");
332
+ that.element.data('_storage', []);
333
+ that._addDate(d);
334
+ }
335
+ that.options.getDates(that.element.data('_storage'));
336
+ that.options.click(d, d0);
337
+ });
338
+ } else if (this._mode == 'month') {
339
+ table.find('.month a').on('click', function(e){
340
+ that._event = 'eventNext';
341
+ e.preventDefault();
342
+ e.stopPropagation();
343
+ that._month = parseInt($(this).data('month'));
344
+ that._mode = 'day';
345
+ that._renderCalendar();
346
+ });
347
+ table.find('.btn-previous-year').on('click', function(e){
348
+ that._event = 'eventPrevious';
349
+ e.preventDefault();
350
+ e.stopPropagation();
351
+ that._year -= 1;
352
+ that._renderCalendar();
353
+ });
354
+ table.find('.btn-next-year').on('click', function(e){
355
+ that._event = 'eventNext';
356
+ e.preventDefault();
357
+ e.stopPropagation();
358
+ that._year += 1;
359
+ that._renderCalendar();
360
+ });
361
+ table.find('.btn-select-year').on('click', function(e){
362
+ that._event = 'eventNext';
363
+ e.preventDefault();
364
+ e.stopPropagation();
365
+ that._mode = 'year';
366
+ that._renderCalendar();
367
+ });
368
+ } else {
369
+ table.find('.year a').on('click', function(e){
370
+ that._event = 'eventNext';
371
+ e.preventDefault();
372
+ e.stopPropagation();
373
+ that._year = parseInt($(this).data('year'));
374
+ that._mode = 'month';
375
+ that._renderCalendar();
376
+ });
377
+ table.find('.btn-previous-year').on('click', function(e){
378
+ that._event = 'eventPrevious';
379
+ e.preventDefault();
380
+ e.stopPropagation();
381
+ that._distance -= 10;
382
+ that._renderCalendar();
383
+ });
384
+ table.find('.btn-next-year').on('click', function(e){
385
+ that._event = 'eventNext';
386
+ e.preventDefault();
387
+ e.stopPropagation();
388
+ that._distance += 10;
389
+ that._renderCalendar();
390
+ });
391
+ }
392
+ },
393
+
394
+ _addDate: function(d){
395
+ var index = this.element.data('_storage').indexOf(d);
396
+ if (index < 0) this.element.data('_storage').push(d);
397
+ },
398
+
399
+ _removeDate: function(d){
400
+ var index = this.element.data('_storage').indexOf(d);
401
+ this.element.data('_storage').splice(index, 1);
402
+ },
403
+
404
+ setDate: function(d){
405
+ var r;
406
+ d = new Date(d);
407
+ r = (new Date(d.getFullYear()+"/"+ (d.getMonth()+1)+"/"+ d.getDate())).format('yyyy-mm-dd');
408
+ this._addDate(r);
409
+ this._renderCalendar();
410
+ },
411
+
412
+ getDate: function(index){
413
+ return new Date(index != undefined ? this.element.data('_storage')[index] : this.element.data('_storage')[0]).format(this.options.format);
414
+ },
415
+
416
+ getDates: function(){
417
+ return this.element.data('_storage');
418
+ },
419
+
420
+ unsetDate: function(d){
421
+ var r;
422
+ d = new Date(d);
423
+ r = (new Date(d.getFullYear()+"-"+ (d.getMonth()+1)+"-"+ d.getDate())).format('yyyy-mm-dd');
424
+ this._removeDate(r);
425
+ this._renderCalendar();
426
+ },
427
+
428
+ _destroy: function(){},
429
+
430
+ _setOption: function(key, value){
431
+ this._super('_setOption', key, value);
432
+ }
433
+ })
434
+ })( jQuery );
435
+
436
+
437
+