romo 0.19.10 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/css/romo/buttons.scss +1 -0
- data/assets/css/romo/modal.scss +5 -0
- data/assets/js/romo/ajax.js +75 -89
- data/assets/js/romo/base.js +699 -274
- data/assets/js/romo/currency_text_input.js +93 -83
- data/assets/js/romo/date.js +3 -3
- data/assets/js/romo/datepicker.js +227 -234
- data/assets/js/romo/dropdown.js +235 -344
- data/assets/js/romo/dropdown_form.js +77 -76
- data/assets/js/romo/form.js +215 -159
- data/assets/js/romo/indicator_text_input.js +64 -95
- data/assets/js/romo/inline.js +66 -59
- data/assets/js/romo/inline_form.js +74 -73
- data/assets/js/romo/modal.js +218 -294
- data/assets/js/romo/modal_form.js +83 -82
- data/assets/js/romo/onkey.js +25 -22
- data/assets/js/romo/option_list_dropdown.js +318 -298
- data/assets/js/romo/picker.js +175 -181
- data/assets/js/romo/select.js +177 -165
- data/assets/js/romo/select_dropdown.js +86 -93
- data/assets/js/romo/selected_options_list.js +66 -76
- data/assets/js/romo/sortable.js +154 -120
- data/assets/js/romo/{indicator.js → spinner.js} +74 -89
- data/assets/js/romo/tooltip.js +257 -271
- data/assets/js/romo/word_boundary_filter.js +7 -10
- data/lib/romo/dassets.rb +1 -1
- data/lib/romo/version.rb +1 -1
- data/test/unit/dassets_tests.rb +1 -1
- metadata +3 -3
@@ -1,280 +1,195 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return new RomoDatepicker(element);
|
4
|
-
});
|
5
|
-
}
|
6
|
-
|
7
|
-
var RomoDatepicker = function(element) {
|
8
|
-
this.elem = $(element);
|
1
|
+
var RomoDatepicker = RomoComponent(function(elem) {
|
2
|
+
this.elem = elem;
|
9
3
|
|
10
4
|
this.defaultFormat = 'yyyy-mm-dd'
|
11
5
|
this.defaultPrevClass = undefined;
|
12
6
|
this.defaultNextClass = undefined;
|
13
7
|
this.itemSelector = 'TD.romo-datepicker-day:not(.disabled)';
|
14
|
-
this.calTable =
|
8
|
+
this.calTable = undefined;
|
15
9
|
this.date = undefined;
|
16
10
|
this.today = RomoDate.today();
|
17
11
|
this.prevValue = undefined;
|
18
12
|
|
19
13
|
this.doInit();
|
20
|
-
this.
|
21
|
-
this.doSetFormat();
|
22
|
-
this.doSetDate(this.elem.val());
|
23
|
-
this.doBindDropdown();
|
24
|
-
this.doBuildUI();
|
14
|
+
this._bindElem();
|
25
15
|
|
26
|
-
this.elem
|
16
|
+
Romo.trigger(this.elem, 'romoDatepicker:ready', [this]);
|
17
|
+
});
|
18
|
+
|
19
|
+
RomoDatepicker.prototype.formatString = function() {
|
20
|
+
return Romo.data(this.elem, 'romo-datepicker-format') || this.defaultFormat;
|
27
21
|
}
|
28
22
|
|
29
|
-
RomoDatepicker.prototype.
|
30
|
-
|
23
|
+
RomoDatepicker.prototype.doSetDate = function(value) {
|
24
|
+
this.date = RomoDate.parse(value);
|
25
|
+
if (this.date !== undefined) {
|
26
|
+
this.elem.value = RomoDate.format(this.date, this.formatString());
|
27
|
+
} else {
|
28
|
+
this.elem.value = value;
|
29
|
+
}
|
31
30
|
}
|
32
31
|
|
33
|
-
RomoDatepicker.prototype.
|
34
|
-
this.
|
35
|
-
this.
|
32
|
+
RomoDatepicker.prototype.doRefreshUI = function(date) {
|
33
|
+
var rDate = date || this.date || this.today;
|
34
|
+
this._refreshCalendar(rDate);
|
35
|
+
Romo.trigger(this.elem, 'romoDatepicker:refresh', [rDate, this]);
|
36
|
+
|
37
|
+
var itemElems = Romo.find(this.calTable, this.itemSelector);
|
38
|
+
Romo.on(itemElems, 'mouseenter', Romo.proxy(this._onItemEnter, this));
|
39
|
+
Romo.on(itemElems, 'click', Romo.proxy(this._onItemClick, this));
|
40
|
+
|
41
|
+
Romo.on(this.romoDropdown.popupElem, 'mousedown', Romo.proxy(this._onPopupMouseDown, this));
|
42
|
+
Romo.on(this.romoDropdown.popupElem, 'mouseup', Romo.proxy(this._onPopupMouseUp, this));
|
43
|
+
}
|
44
|
+
|
45
|
+
// private
|
46
|
+
|
47
|
+
RomoDatepicker.prototype._bindElem = function() {
|
48
|
+
Romo.setAttr(this.elem, 'autocomplete', 'off');
|
49
|
+
Romo.setData(this.elem, 'romo-indicator-text-input-indicator-position', "right");
|
36
50
|
|
37
|
-
if (this.elem
|
38
|
-
this.elem
|
51
|
+
if (Romo.data(this.elem, 'romo-datepicker-indicator') !== undefined) {
|
52
|
+
Romo.setData(this.elem, 'romo-indicator-text-input-indicator', Romo.data(this.elem, 'romo-datepicker-indicator'));
|
39
53
|
}
|
40
|
-
if (this.elem
|
41
|
-
this.elem
|
54
|
+
if (Romo.data(this.elem, 'romo-datepicker-indicator-width-px') !== undefined) {
|
55
|
+
Romo.setData(this.elem, 'romo-indicator-text-input-indicator-width-px', Romo.data(this.elem, 'romo-datepicker-indicator-width-px'));
|
42
56
|
}
|
43
|
-
if (this.elem
|
44
|
-
this.elem
|
57
|
+
if (Romo.data(this.elem, 'romo-datepicker-btn-group') === true) {
|
58
|
+
Romo.setData(this.elem, 'romo-indicator-text-input-btn-group', Romo.data(this.elem, 'romo-datepicker-btn-group'));
|
45
59
|
}
|
46
|
-
if (this.elem
|
47
|
-
this.elem
|
60
|
+
if (Romo.data(this.elem, 'romo-datepicker-elem-display') !== undefined) {
|
61
|
+
Romo.setData(this.elem, 'romo-indicator-text-input-elem-display', Romo.data(this.elem, 'romo-datepicker-elem-display'));
|
48
62
|
}
|
49
63
|
|
50
|
-
this.elem
|
64
|
+
new RomoIndicatorTextInput(this.elem);
|
51
65
|
|
52
|
-
this.prevValue = this.elem.
|
53
|
-
this.elem
|
54
|
-
var newValue = this.elem.
|
55
|
-
this.elem
|
66
|
+
this.prevValue = this.elem.value;
|
67
|
+
Romo.on(this.elem, 'change', Romo.proxy(function(e) {
|
68
|
+
var newValue = this.elem.value;
|
69
|
+
Romo.trigger(this.elem, 'romoDatepicker:change', [newValue, this.prevValue, this]);
|
56
70
|
this.prevValue = newValue;
|
57
71
|
}, this));
|
58
72
|
|
59
|
-
this.elem
|
73
|
+
Romo.on(this.elem, 'romoIndicatorTextInput:indicatorClick', Romo.proxy(function(e) {
|
60
74
|
this._clearBlurTimeout();
|
61
|
-
this.elem
|
75
|
+
Romo.trigger(this.elem, 'romoDatepicker:triggerPopupOpen');
|
62
76
|
}, this));
|
63
77
|
|
64
|
-
this.elem
|
65
|
-
this.elem
|
78
|
+
Romo.on(this.elem, 'romoDatepicker:triggerEnable', Romo.proxy(function(e) {
|
79
|
+
Romo.trigger(this.elem, 'romoIndicatorTextInput:triggerEnable', []);
|
66
80
|
}, this));
|
67
|
-
this.elem
|
68
|
-
this.elem
|
81
|
+
Romo.on(this.elem, 'romoDatepicker:triggerDisable', Romo.proxy(function(e) {
|
82
|
+
Romo.trigger(this.elem, 'romoIndicatorTextInput:triggerDisable', []);
|
69
83
|
}, this));
|
70
|
-
this.elem
|
71
|
-
this.elem
|
84
|
+
Romo.on(this.elem, 'romoDatepicker:triggerShow', Romo.proxy(function(e) {
|
85
|
+
Romo.trigger(this.elem, 'romoIndicatorTextInput:triggerShow', []);
|
72
86
|
}, this));
|
73
|
-
this.elem
|
74
|
-
this.elem
|
87
|
+
Romo.on(this.elem, 'romoDatepicker:triggerHide', Romo.proxy(function(e) {
|
88
|
+
Romo.trigger(this.elem, 'romoIndicatorTextInput:triggerHide', []);
|
75
89
|
}, this));
|
76
90
|
|
77
|
-
this.elem
|
78
|
-
this.doSetFormat();
|
79
|
-
}, this));
|
80
|
-
this.elem.on('datepicker:triggerSetDate', $.proxy(this.onTriggerSetDate, this));
|
81
|
-
}
|
91
|
+
Romo.on(this.elem, 'romoDatepicker:triggerSetDate', Romo.proxy(this._onTriggerSetDate, this));
|
82
92
|
|
83
|
-
|
84
|
-
this.
|
93
|
+
this._bindDropdown();
|
94
|
+
this.doSetDate(this.elem.value);
|
95
|
+
this._buildUI();
|
85
96
|
}
|
86
97
|
|
87
|
-
RomoDatepicker.prototype.
|
88
|
-
this.
|
89
|
-
if (this.
|
90
|
-
|
91
|
-
} else {
|
92
|
-
this.elem.val(value);
|
98
|
+
RomoDatepicker.prototype._bindDropdown = function() {
|
99
|
+
Romo.setData(this.elem, 'romo-dropdown-disable-toggle', 'true');
|
100
|
+
if (Romo.data(this.elem, 'romo-dropdown-width') === undefined) {
|
101
|
+
Romo.setData(this.elem, 'romo-dropdown-width', 'elem');
|
93
102
|
}
|
94
|
-
|
95
|
-
|
96
|
-
RomoDatepicker.prototype.doBindDropdown = function() {
|
97
|
-
this.elem.attr('data-romo-dropdown-disable-toggle', 'true');
|
98
|
-
if (this.elem.data('romo-dropdown-width') === undefined) {
|
99
|
-
this.elem.attr('data-romo-dropdown-width', 'elem');
|
103
|
+
if (parseInt(Romo.css(this.elem, 'width'), 10) < 175) {
|
104
|
+
Romo.setData(this.elem, 'romo-dropdown-width', '175px');
|
100
105
|
}
|
101
|
-
|
102
|
-
this.elem.attr('data-romo-dropdown-width', '175px');
|
103
|
-
}
|
104
|
-
this.romoDropdown = this.elem.romoDropdown()[0];
|
106
|
+
this.romoDropdown = new RomoDropdown(this.elem);
|
105
107
|
|
106
108
|
this.romoDropdown.doSetPopupZIndex(this.elem);
|
107
|
-
this.romoDropdown.bodyElem
|
108
|
-
this.romoDropdown.elem
|
109
|
-
this.romoDropdown.elem
|
110
|
-
this.romoDropdown.elem
|
111
|
-
this.blurTimeoutId = setTimeout(
|
109
|
+
Romo.addClass(this.romoDropdown.bodyElem, 'romo-datepicker-calendar');
|
110
|
+
Romo.on(this.romoDropdown.elem, 'romoDropdown:popupOpen', Romo.proxy(this._onPopupOpen, this));
|
111
|
+
Romo.on(this.romoDropdown.elem, 'romoDropdown:popupClose', Romo.proxy(this._onPopupClose, this));
|
112
|
+
Romo.on(this.romoDropdown.elem, 'blur', Romo.proxy(function(e) {
|
113
|
+
this.blurTimeoutId = setTimeout(Romo.proxy(function() {
|
112
114
|
if (this.popupMouseDown !== true) {
|
113
|
-
this.romoDropdown.elem
|
115
|
+
Romo.trigger(this.romoDropdown.elem, 'romoDropdown:triggerPopupClose', []);
|
114
116
|
}
|
115
117
|
}, this), 10);
|
116
118
|
}, this));
|
117
|
-
this.romoDropdown.elem
|
119
|
+
Romo.on(this.romoDropdown.elem, 'keydown', Romo.proxy(this._onElemKeyDown, this));
|
118
120
|
|
119
|
-
this.romoDropdown.elem
|
120
|
-
this.elem
|
121
|
+
Romo.on(this.romoDropdown.elem, 'romoDropdown:toggle', Romo.proxy(function(e, romoDropdown) {
|
122
|
+
Romo.trigger(this.elem, 'romoDatepicker:romoDropdown:toggle', [romoDropdown, this]);
|
121
123
|
}, this));
|
122
|
-
this.romoDropdown.elem
|
123
|
-
this.elem
|
124
|
+
Romo.on(this.romoDropdown.elem, 'romoDropdown:popupOpen', Romo.proxy(function(e, romoDropdown) {
|
125
|
+
Romo.trigger(this.elem, 'romoDatepicker:romoDropdown:popupOpen', [romoDropdown, this]);
|
124
126
|
}, this));
|
125
|
-
this.romoDropdown.elem
|
126
|
-
this.elem
|
127
|
+
Romo.on(this.romoDropdown.elem, 'romoDropdown:popupClose', Romo.proxy(function(e, romoDropdown) {
|
128
|
+
Romo.trigger(this.elem, 'romoDatepicker:romoDropdown:popupClose', [romoDropdown, this]);
|
127
129
|
}, this));
|
128
130
|
|
129
|
-
this.elem
|
130
|
-
this.romoDropdown.elem
|
131
|
+
Romo.on(this.elem, 'romoDatepicker:triggerToggle', Romo.proxy(function(e) {
|
132
|
+
Romo.trigger(this.romoDropdown.elem, 'romoDropdown:triggerToggle', []);
|
131
133
|
}, this));
|
132
|
-
this.elem
|
133
|
-
this.romoDropdown.elem
|
134
|
+
Romo.on(this.elem, 'romoDatepicker:triggerPopupOpen', Romo.proxy(function(e) {
|
135
|
+
Romo.trigger(this.romoDropdown.elem, 'romoDropdown:triggerPopupOpen', []);
|
134
136
|
}, this));
|
135
|
-
this.elem
|
136
|
-
this.romoDropdown.elem
|
137
|
+
Romo.on(this.elem, 'romoDatepicker:triggerPopupClose', Romo.proxy(function(e) {
|
138
|
+
Romo.trigger(this.romoDropdown.elem, 'romoDropdown:triggerPopupClose', []);
|
137
139
|
}, this));
|
138
140
|
}
|
139
141
|
|
140
|
-
RomoDatepicker.prototype.
|
142
|
+
RomoDatepicker.prototype._buildUI = function() {
|
141
143
|
this.calTable = this._buildCalendar();
|
142
|
-
this.romoDropdown.bodyElem
|
143
|
-
this.romoDropdown.bodyElem
|
144
|
-
|
145
|
-
this.calTable.find('.romo-datepicker-prev').on('click', $.proxy(this.onPrevClick, this));
|
146
|
-
this.calTable.find('.romo-datepicker-next').on('click', $.proxy(this.onNextClick, this));
|
147
|
-
}
|
148
|
-
|
149
|
-
RomoDatepicker.prototype.doRefreshUI = function(date) {
|
150
|
-
var rDate = date || this.date || this.today;
|
151
|
-
this._refreshCalendar(rDate);
|
152
|
-
this.elem.trigger('datepicker:refresh', [rDate, this]);
|
153
|
-
|
154
|
-
this.calTable.find(this.itemSelector).on('mouseenter', $.proxy(this.onItemEnter, this));
|
155
|
-
this.calTable.find(this.itemSelector).on('click', $.proxy(this.onItemClick, this));
|
144
|
+
Romo.updateHtml(this.romoDropdown.bodyElem, '');
|
145
|
+
Romo.append(this.romoDropdown.bodyElem, this.calTable);
|
156
146
|
|
157
|
-
|
158
|
-
|
147
|
+
var prevElem = Romo.find(this.calTable, '.romo-datepicker-prev')[0];
|
148
|
+
Romo.on(prevElem, 'click', Romo.proxy(this._onPrevClick, this));
|
149
|
+
var nextElem = Romo.find(this.calTable, '.romo-datepicker-next')[0];
|
150
|
+
Romo.on(nextElem, 'click', Romo.proxy(this._onNextClick, this));
|
159
151
|
}
|
160
152
|
|
161
|
-
RomoDatepicker.prototype.
|
153
|
+
RomoDatepicker.prototype._refreshToPrevMonth = function() {
|
162
154
|
var date = this.refreshDate || this.date || (new Date);
|
163
155
|
var pDate = RomoDate.lastDateOfPrevMonth(date);
|
164
156
|
this.doRefreshUI(pDate);
|
165
|
-
this.elem
|
157
|
+
Romo.trigger(this.elem, 'romoDatepicker:prevRefresh', [pDate, this]);
|
166
158
|
}
|
167
159
|
|
168
|
-
RomoDatepicker.prototype.
|
160
|
+
RomoDatepicker.prototype._refreshToNextMonth = function() {
|
169
161
|
var date = this.refreshDate || this.date || (new Date);
|
170
162
|
var nDate = RomoDate.firstDateOfNextMonth(date);
|
171
163
|
this.doRefreshUI(nDate);
|
172
|
-
this.elem
|
164
|
+
Romo.trigger(this.elem, 'romoDatepicker:nextRefresh', [nDate, this]);
|
173
165
|
}
|
174
166
|
|
175
|
-
RomoDatepicker.prototype.
|
176
|
-
var
|
167
|
+
RomoDatepicker.prototype._selectHighlightedItem = function() {
|
168
|
+
var highlightElem = Romo.find(this.calTable, 'TD.romo-datepicker-highlight')[0];
|
169
|
+
var newValue = Romo.data(highlightElem, 'romo-datepicker-value');
|
177
170
|
|
178
171
|
this.romoDropdown.doPopupClose();
|
179
172
|
this.doSetDate(newValue);
|
180
173
|
this.elem.focus();
|
181
|
-
this.elem
|
174
|
+
Romo.trigger(this.elem, 'romoDatepicker:itemSelected', [newValue, this]);
|
182
175
|
if (newValue !== this.prevValue) {
|
183
|
-
this.elem
|
176
|
+
Romo.trigger(this.elem, 'romoDatepicker:newItemSelected', [newValue, this]);
|
184
177
|
}
|
185
178
|
// always publish the item selected events before publishing any change events
|
186
179
|
this._triggerSetDateChangeEvent();
|
187
180
|
}
|
188
181
|
|
189
|
-
RomoDatepicker.prototype.onTriggerSetDate = function(e, value) {
|
190
|
-
this.doSetDate(value);
|
191
|
-
this._triggerSetDateChangeEvent();
|
192
|
-
}
|
193
|
-
|
194
|
-
RomoDatepicker.prototype.onElemKeyDown = function(e) {
|
195
|
-
if (this.elem.hasClass('disabled') === false) {
|
196
|
-
if (this.romoDropdown.popupOpen()) {
|
197
|
-
return true;
|
198
|
-
} else {
|
199
|
-
if(e.keyCode === 40 /* Down */ ) {
|
200
|
-
this.romoDropdown.doPopupOpen();
|
201
|
-
this.romoDropdown.popupElem.focus();
|
202
|
-
return false;
|
203
|
-
} else {
|
204
|
-
return true;
|
205
|
-
}
|
206
|
-
}
|
207
|
-
}
|
208
|
-
return true;
|
209
|
-
}
|
210
|
-
|
211
|
-
RomoDatepicker.prototype.onPopupOpen = function(e) {
|
212
|
-
if (this.elem.hasClass('disabled') === false) {
|
213
|
-
this.doSetDate(this.elem.val());
|
214
|
-
this.doRefreshUI();
|
215
|
-
}
|
216
|
-
}
|
217
|
-
|
218
|
-
RomoDatepicker.prototype.onPopupClose = function(e) {
|
219
|
-
this._highlightItem($());
|
220
|
-
}
|
221
|
-
|
222
|
-
RomoDatepicker.prototype.onItemEnter = function(e) {
|
223
|
-
if (e !== undefined) {
|
224
|
-
e.preventDefault();
|
225
|
-
e.stopPropagation();
|
226
|
-
}
|
227
|
-
this._highlightItem($(e.target));
|
228
|
-
}
|
229
|
-
|
230
|
-
RomoDatepicker.prototype.onItemClick = function(e) {
|
231
|
-
this._clearBlurTimeout();
|
232
|
-
if (e !== undefined) {
|
233
|
-
e.preventDefault();
|
234
|
-
e.stopPropagation();
|
235
|
-
}
|
236
|
-
this.doSelectHighlightedItem();
|
237
|
-
}
|
238
|
-
|
239
|
-
RomoDatepicker.prototype.onPrevClick = function(e) {
|
240
|
-
this._clearBlurTimeout();
|
241
|
-
if (e !== undefined) {
|
242
|
-
e.preventDefault();
|
243
|
-
e.stopPropagation();
|
244
|
-
}
|
245
|
-
this.doRefreshToPrevMonth();
|
246
|
-
}
|
247
|
-
|
248
|
-
RomoDatepicker.prototype.onNextClick = function(e) {
|
249
|
-
this._clearBlurTimeout();
|
250
|
-
if (e !== undefined) {
|
251
|
-
e.preventDefault();
|
252
|
-
e.stopPropagation();
|
253
|
-
}
|
254
|
-
this.doRefreshToNextMonth();
|
255
|
-
}
|
256
|
-
|
257
|
-
RomoDatepicker.prototype.onPopupMouseDown = function(e) {
|
258
|
-
this.popupMouseDown = true;
|
259
|
-
}
|
260
|
-
|
261
|
-
RomoDatepicker.prototype.onPopupMouseUp = function(e) {
|
262
|
-
this.popupMouseDown = false;
|
263
|
-
}
|
264
|
-
|
265
|
-
// private
|
266
|
-
|
267
182
|
RomoDatepicker.prototype._show = function(elem) {
|
268
|
-
|
183
|
+
Romo.show(elem);
|
269
184
|
}
|
270
185
|
|
271
186
|
RomoDatepicker.prototype._hide = function(elem) {
|
272
|
-
|
187
|
+
Romo.hide(elem);
|
273
188
|
}
|
274
189
|
|
275
190
|
RomoDatepicker.prototype._triggerSetDateChangeEvent = function() {
|
276
|
-
if (this.elem.
|
277
|
-
this.elem
|
191
|
+
if (this.elem.value !== this.prevValue) {
|
192
|
+
Romo.trigger(this.elem, 'change');
|
278
193
|
}
|
279
194
|
}
|
280
195
|
|
@@ -286,59 +201,66 @@ RomoDatepicker.prototype._clearBlurTimeout = function() {
|
|
286
201
|
}
|
287
202
|
|
288
203
|
RomoDatepicker.prototype._refreshCalendar = function(date) {
|
289
|
-
this.calTable
|
290
|
-
|
204
|
+
var titleElem = Romo.find(this.calTable, '.romo-datepicker-title')[0];
|
205
|
+
Romo.updateText(titleElem, this._buildCalendarTitle(date));
|
206
|
+
|
207
|
+
var tableBodyElem = Romo.find(this.calTable, 'tbody')[0];
|
208
|
+
Romo.updateHtml(tableBodyElem, '');
|
209
|
+
var rowElems = this._buildCalendarBodyRows(date);
|
210
|
+
Romo.append(tableBodyElem, rowElems);
|
211
|
+
|
291
212
|
this.refreshDate = date;
|
292
213
|
}
|
293
214
|
|
294
215
|
RomoDatepicker.prototype._buildCalendar = function() {
|
295
|
-
var
|
296
|
-
|
297
|
-
|
298
|
-
return
|
216
|
+
var tableElem = Romo.elems('<table></table>')[0];
|
217
|
+
Romo.append(tableElem, this._buildCalendarHeader());
|
218
|
+
Romo.appendHtml(tableElem, '<tbody></tbody>');
|
219
|
+
return tableElem;
|
299
220
|
}
|
300
221
|
|
301
222
|
RomoDatepicker.prototype._buildCalendarHeader = function() {
|
302
|
-
var prevClass
|
303
|
-
var nextClass
|
304
|
-
var
|
305
|
-
|
306
|
-
var
|
307
|
-
var th = $('<th class="romo-datepicker-prev" title="Previous Month"></th>');
|
223
|
+
var prevClass = Romo.data(this.elem, 'romo-datepicker-prev') || this.defaultPrevClass;
|
224
|
+
var nextClass = Romo.data(this.elem, 'romo-datepicker-next') || this.defaultNextClass;
|
225
|
+
var headerElem = Romo.elems('<thead></thead')[0];
|
226
|
+
var titleRowElem = Romo.elems('<tr></tr>')[0];
|
227
|
+
var thPrevElem = Romo.elems('<th class="romo-datepicker-prev" title="Previous Month"></th>')[0];
|
308
228
|
if (prevClass) {
|
309
|
-
|
229
|
+
Romo.updateHtml(thPrevElem, '<i class="'+prevClass+'"></i>');
|
310
230
|
} else {
|
311
|
-
|
231
|
+
Romo.updateText(thPrevElem, '<<');
|
312
232
|
}
|
313
|
-
|
314
|
-
|
315
|
-
|
233
|
+
Romo.append(titleRowElem, thPrevElem);
|
234
|
+
|
235
|
+
Romo.appendHtml(titleRowElem, '<th class="romo-datepicker-title" colspan="5"></th>');
|
236
|
+
|
237
|
+
var thNextElem = Romo.elems('<th class="romo-datepicker-next" title="Next Month"></th>')[0];
|
316
238
|
if (nextClass) {
|
317
|
-
|
239
|
+
Romo.updateHtml(thNextElem, '<i class="'+nextClass+'"></i>');
|
318
240
|
} else {
|
319
|
-
|
241
|
+
Romo.updateText(thNextElem, '>>');
|
320
242
|
}
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
return
|
243
|
+
Romo.append(titleRowElem, thNextElem);
|
244
|
+
Romo.append(headerElem, titleRowElem);
|
245
|
+
|
246
|
+
var daysRowElem = Romo.elems('<tr></tr>')[0];
|
247
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">S</th>');
|
248
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">M</th>');
|
249
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">T</th>');
|
250
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">W</th>');
|
251
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">T</th>');
|
252
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">F</th>');
|
253
|
+
Romo.appendHtml(daysRowElem, '<th class="romo-datepicker-day">S</th>');
|
254
|
+
Romo.append(headerElem, daysRowElem);
|
255
|
+
|
256
|
+
return headerElem;
|
335
257
|
}
|
336
258
|
|
337
259
|
RomoDatepicker.prototype._buildCalendarTitle = function(date) {
|
338
260
|
return RomoDate.format(date, 'MM yyyy');
|
339
261
|
}
|
340
262
|
|
341
|
-
RomoDatepicker.prototype.
|
263
|
+
RomoDatepicker.prototype._buildCalendarBodyRows = function(date) {
|
342
264
|
var html = [];
|
343
265
|
|
344
266
|
// prefer showing as many past dates in each month as possible
|
@@ -378,7 +300,7 @@ RomoDatepicker.prototype._buildCalendarBody = function(date) {
|
|
378
300
|
|
379
301
|
html.push('<td');
|
380
302
|
html.push(' class="'+cls.join(' ')+'"');
|
381
|
-
var dt = RomoDate.format(iDate, this.formatString);
|
303
|
+
var dt = RomoDate.format(iDate, this.formatString());
|
382
304
|
html.push(' title="'+dt+'"');
|
383
305
|
html.push(' data-romo-datepicker-value="'+dt+'"');
|
384
306
|
html.push('>');
|
@@ -392,14 +314,85 @@ RomoDatepicker.prototype._buildCalendarBody = function(date) {
|
|
392
314
|
iDate = RomoDate.next(iDate);
|
393
315
|
}
|
394
316
|
|
395
|
-
return
|
317
|
+
return Romo.elems(html.join(''));
|
396
318
|
}
|
397
319
|
|
398
|
-
RomoDatepicker.prototype._highlightItem = function(
|
399
|
-
this.calTable
|
400
|
-
|
320
|
+
RomoDatepicker.prototype._highlightItem = function(itemElem) {
|
321
|
+
var highlightElem = Romo.find(this.calTable, 'TD.romo-datepicker-highlight')[0];
|
322
|
+
if(highlightElem !== undefined) {
|
323
|
+
Romo.removeClass(highlightElem, 'romo-datepicker-highlight');
|
324
|
+
}
|
325
|
+
if(itemElem !== undefined) {
|
326
|
+
Romo.addClass(itemElem, 'romo-datepicker-highlight');
|
327
|
+
}
|
401
328
|
}
|
402
329
|
|
403
|
-
|
404
|
-
|
405
|
-
|
330
|
+
// event functions
|
331
|
+
|
332
|
+
RomoDatepicker.prototype.romoEvFn._onTriggerSetDate = function(e, value) {
|
333
|
+
this.doSetDate(value);
|
334
|
+
this._triggerSetDateChangeEvent();
|
335
|
+
}
|
336
|
+
|
337
|
+
RomoDatepicker.prototype.romoEvFn._onElemKeyDown = function(e) {
|
338
|
+
if (Romo.hasClass(this.elem, 'disabled') === false) {
|
339
|
+
if (this.romoDropdown.popupOpen()) {
|
340
|
+
return true;
|
341
|
+
} else {
|
342
|
+
if(e.keyCode === 40 /* Down */ ) {
|
343
|
+
this.romoDropdown.doPopupOpen();
|
344
|
+
this.romoDropdown.popupElem.focus();
|
345
|
+
return false;
|
346
|
+
} else {
|
347
|
+
return true;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
return true;
|
352
|
+
}
|
353
|
+
|
354
|
+
RomoDatepicker.prototype.romoEvFn._onPopupOpen = function(e) {
|
355
|
+
if (Romo.hasClass(this.elem, 'disabled') === false) {
|
356
|
+
this.doSetDate(this.elem.value);
|
357
|
+
this.doRefreshUI();
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
RomoDatepicker.prototype.romoEvFn._onPopupClose = function(e) {
|
362
|
+
this._highlightItem(undefined);
|
363
|
+
}
|
364
|
+
|
365
|
+
RomoDatepicker.prototype.romoEvFn._onItemEnter = function(e) {
|
366
|
+
this._highlightItem(e.target);
|
367
|
+
return false
|
368
|
+
}
|
369
|
+
|
370
|
+
RomoDatepicker.prototype.romoEvFn._onItemClick = function(e) {
|
371
|
+
this._clearBlurTimeout();
|
372
|
+
this._selectHighlightedItem();
|
373
|
+
return false;
|
374
|
+
}
|
375
|
+
|
376
|
+
RomoDatepicker.prototype.romoEvFn._onPrevClick = function(e) {
|
377
|
+
this._clearBlurTimeout();
|
378
|
+
this._refreshToPrevMonth();
|
379
|
+
return false;
|
380
|
+
}
|
381
|
+
|
382
|
+
RomoDatepicker.prototype.romoEvFn._onNextClick = function(e) {
|
383
|
+
this._clearBlurTimeout();
|
384
|
+
this._refreshToNextMonth();
|
385
|
+
return false;
|
386
|
+
}
|
387
|
+
|
388
|
+
RomoDatepicker.prototype.romoEvFn._onPopupMouseDown = function(e) {
|
389
|
+
this.popupMouseDown = true;
|
390
|
+
}
|
391
|
+
|
392
|
+
RomoDatepicker.prototype.romoEvFn._onPopupMouseUp = function(e) {
|
393
|
+
this.popupMouseDown = false;
|
394
|
+
}
|
395
|
+
|
396
|
+
// init
|
397
|
+
|
398
|
+
Romo.addElemsInitSelector('[data-romo-datepicker-auto="true"]', RomoDatepicker);
|