romo 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -3
- data/assets/css/romo/_mixins.scss +190 -60
- data/assets/css/romo/_vars.scss +262 -100
- data/assets/css/romo/base.scss +0 -106
- data/assets/css/romo/buttons.scss +58 -68
- data/assets/css/romo/colors.scss +212 -0
- data/assets/css/romo/datepicker.scss +2 -2
- data/assets/css/romo/grid_table.scss +215 -70
- data/assets/css/romo/labels.scss +39 -13
- data/assets/css/romo/table.scss +151 -51
- data/assets/js/romo/ajax.js +114 -0
- data/assets/js/romo/date.js +310 -0
- data/assets/js/romo/datepicker.js +35 -194
- data/assets/js/romo/dropdown.js +6 -6
- data/assets/js/romo/inline.js +3 -3
- data/assets/js/romo/modal.js +6 -6
- data/assets/js/romo/tooltip.js +9 -9
- data/lib/romo/dassets.rb +3 -1
- data/lib/romo/version.rb +1 -1
- data/test/unit/dassets_tests.rb +3 -1
- metadata +5 -3
- data/assets/js/romo/invoke.js +0 -112
@@ -0,0 +1,310 @@
|
|
1
|
+
var RomoDate = {
|
2
|
+
|
3
|
+
date: function(date) {
|
4
|
+
if (date === undefined || date === null) {
|
5
|
+
return undefined;
|
6
|
+
} else {
|
7
|
+
var d = new Date(date);
|
8
|
+
d.setHours(0,0,0,0); // RomoDate Dates are always local with zero time
|
9
|
+
return d;
|
10
|
+
}
|
11
|
+
},
|
12
|
+
|
13
|
+
for: function(yearNum, zeroBasedMonthNum, dayNum) {
|
14
|
+
return RomoDate.date(new Date(yearNum, zeroBasedMonthNum, dayNum));
|
15
|
+
},
|
16
|
+
|
17
|
+
parse: function(dateString) {
|
18
|
+
return (new RomoDate.Parser(String(dateString).trim())).date();
|
19
|
+
},
|
20
|
+
|
21
|
+
format: function(date, formatString) {
|
22
|
+
return (new RomoDate.Formatter(String(formatString).trim())).dateString(date);
|
23
|
+
},
|
24
|
+
|
25
|
+
today: function() {
|
26
|
+
return RomoDate.date(new Date());
|
27
|
+
},
|
28
|
+
|
29
|
+
currentYear: function() {
|
30
|
+
return RomoDate.today().getFullYear();
|
31
|
+
},
|
32
|
+
|
33
|
+
vector: function(date, numDays) {
|
34
|
+
var d = RomoDate.date(date)
|
35
|
+
return RomoDate.for(d.getFullYear(), d.getMonth(), d.getDate()+(numDays || 0));
|
36
|
+
},
|
37
|
+
|
38
|
+
next: function(date, numDays) {
|
39
|
+
return RomoDate.vector(date, numDays || 1);
|
40
|
+
},
|
41
|
+
|
42
|
+
prev: function(date, numDays) {
|
43
|
+
return RomoDate.vector(date, -(numDays || 1));
|
44
|
+
},
|
45
|
+
|
46
|
+
firstDateOfMonth: function(monthDate, vectorNumMonths) {
|
47
|
+
var d = RomoDate.date(monthDate)
|
48
|
+
return RomoDate.for(d.getFullYear(), d.getMonth()+(vectorNumMonths || 0), 1);
|
49
|
+
},
|
50
|
+
|
51
|
+
lastDateOfMonth: function(monthDate, vectorNumMonths) {
|
52
|
+
var d = RomoDate.date(monthDate)
|
53
|
+
return RomoDate.for(d.getFullYear(), d.getMonth()+(vectorNumMonths || 0)+1, 0);
|
54
|
+
},
|
55
|
+
|
56
|
+
firstDateOfNextMonth: function(monthDate, numMonths) {
|
57
|
+
return RomoDate.firstDateOfMonth(monthDate, numMonths || 1);
|
58
|
+
},
|
59
|
+
|
60
|
+
firstDateOfPrevMonth: function(monthDate, numMonths) {
|
61
|
+
return RomoDate.firstDateOfMonth(monthDate, -(numMonths || 1));
|
62
|
+
},
|
63
|
+
|
64
|
+
lastDateOfNextMonth: function(monthDate, numMonths) {
|
65
|
+
return RomoDate.lastDateOfMonth(monthDate, numMonths || 1);
|
66
|
+
},
|
67
|
+
|
68
|
+
lastDateOfPrevMonth: function(monthDate, numMonths) {
|
69
|
+
return RomoDate.lastDateOfMonth(monthDate, -(numMonths || 1));
|
70
|
+
},
|
71
|
+
|
72
|
+
daysInMonth: function(monthDate, vectorNumMonths) {
|
73
|
+
return RomoDate.lastDateOfMonth(monthDate, vectorNumMonths).getDate();
|
74
|
+
},
|
75
|
+
|
76
|
+
daysRemainingInMonth: function(monthDate) {
|
77
|
+
var d = RomoDate.date(monthDate)
|
78
|
+
return RomoDate.daysInMonth(d) - d.getDate() + 1;
|
79
|
+
},
|
80
|
+
|
81
|
+
isoWeekNum: function(weekDate) {
|
82
|
+
var d = RomoDate.date(weekDate)
|
83
|
+
|
84
|
+
// calc full weeks to nearest Thursday (basis for ISO week numbers)
|
85
|
+
// set to nearest Thursday: current date + 4 - current day number
|
86
|
+
d.setDate(d.getDate() + 4 - (d.getDay()||7));
|
87
|
+
var yearStartDate = RomoDate.for(d.getFullYear(), 0, 1);
|
88
|
+
var milliSecsSinceYearStart = d - yearStartDate;
|
89
|
+
var milliSecsInADay = 24*60*60*1000;
|
90
|
+
var daysSinceYearStart = milliSecsSinceYearStart / milliSecsInADay;
|
91
|
+
var weekNumber = Math.ceil((daysSinceYearStart + 1) / 7);
|
92
|
+
|
93
|
+
return weekNumber;
|
94
|
+
},
|
95
|
+
|
96
|
+
isEqual: function(date1, date2, formatString) {
|
97
|
+
var d1 = RomoDate.date(date1);
|
98
|
+
var d2 = RomoDate.date(date2);
|
99
|
+
var f = formatString || 'yyyy-mm-dd'
|
100
|
+
|
101
|
+
if (d1 === undefined || d2 === undefined) {
|
102
|
+
return d1 === d2;
|
103
|
+
} else {
|
104
|
+
return RomoDate.format(d1, f) === RomoDate.format(d2, f)
|
105
|
+
}
|
106
|
+
},
|
107
|
+
|
108
|
+
isSameDate: function(date1, date2) {
|
109
|
+
return RomoDate.isEqual(date1, date2);
|
110
|
+
},
|
111
|
+
|
112
|
+
isSameMonth: function(date1, date2) {
|
113
|
+
return RomoDate.isEqual(date1, date2, 'yyyy-mm')
|
114
|
+
},
|
115
|
+
|
116
|
+
isSameYear: function(date1, date2) {
|
117
|
+
return RomoDate.isEqual(date1, date2, 'yyyy')
|
118
|
+
},
|
119
|
+
|
120
|
+
isDay: function(date, day) {
|
121
|
+
if (date === undefined || date === null) {
|
122
|
+
return false;
|
123
|
+
}
|
124
|
+
var d_day = RomoDate.date(date).getDay();
|
125
|
+
return (day === d_day ||
|
126
|
+
day === RomoDate.Utils.dayNames[d_day] ||
|
127
|
+
day === RomoDate.Utils.dayAbbrevs[d_day]);
|
128
|
+
},
|
129
|
+
|
130
|
+
isWeekend: function(date) {
|
131
|
+
if (date === undefined || date === null) {
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
var dow = RomoDate.date(date).getDay();
|
135
|
+
return (dow === 0 || dow === 6);
|
136
|
+
},
|
137
|
+
|
138
|
+
// child classes
|
139
|
+
|
140
|
+
Parser: function(trimmedDateString) {
|
141
|
+
this.dateString = trimmedDateString;
|
142
|
+
},
|
143
|
+
|
144
|
+
Formatter: function(trimmedFormatString) {
|
145
|
+
this.formatString = trimmedFormatString;
|
146
|
+
},
|
147
|
+
|
148
|
+
Utils: undefined,
|
149
|
+
|
150
|
+
}
|
151
|
+
|
152
|
+
// Parser - child utility class to encapsulate parsing a Date obj from a trimmed
|
153
|
+
// date String ('12/25', '12/25/16', '12/25/2016', '2016/12/25')
|
154
|
+
|
155
|
+
RomoDate.Parser.prototype.date = function() {
|
156
|
+
if (this.dateString === undefined || this.dateString === '') {
|
157
|
+
return undefined;
|
158
|
+
}
|
159
|
+
|
160
|
+
var dateValues = this._parseValues(this.dateString);
|
161
|
+
if (dateValues.length === 0) {
|
162
|
+
return undefined;
|
163
|
+
}
|
164
|
+
var year = parseInt(dateValues[0]);
|
165
|
+
if (year < 0) {
|
166
|
+
return undefined;
|
167
|
+
}
|
168
|
+
if (dateValues[0].length > 2 && year < 100) {
|
169
|
+
return undefined;
|
170
|
+
}
|
171
|
+
if (dateValues[0].length === 2 && year < 100) {
|
172
|
+
var cy = RomoDate.currentYear();
|
173
|
+
year = cy - (cy % 100) + year; // 2-digit years are subjective. prefer assuming
|
174
|
+
if ((year - cy) > 10) { // they are past years except assuming all years
|
175
|
+
year = year - 100; // in the next decade are future years.
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
var month = parseInt(dateValues[1]) - 1;
|
180
|
+
if (month < 0 || month > 11) {
|
181
|
+
return undefined;
|
182
|
+
}
|
183
|
+
|
184
|
+
var day = parseInt(dateValues[2]);
|
185
|
+
var date = RomoDate.for(year, month, day);
|
186
|
+
if (date.getMonth() !== month) {
|
187
|
+
return undefined;
|
188
|
+
}
|
189
|
+
|
190
|
+
return date;
|
191
|
+
}
|
192
|
+
|
193
|
+
RomoDate.Parser.prototype._parseValues = function(dateString) {
|
194
|
+
var regex, matches;
|
195
|
+
|
196
|
+
regex = /^([0-9]{1,2})[^0-9]+([0-9]{1,2})[^0-9]+([0-9]{2,4})$/; // "mm dd yyyy" or "mm dd yy"
|
197
|
+
matches = RomoDate.Utils.regexMatches(dateString, regex);
|
198
|
+
if (matches.length === 3) {
|
199
|
+
return [matches[2], matches[0], matches[1]];
|
200
|
+
}
|
201
|
+
|
202
|
+
regex = /^([0-9]{3,4})[^0-9]+([0-9]{1,2})[^0-9]+([0-9]{1,2})$/; // "yyyy mm dd"
|
203
|
+
matches = RomoDate.Utils.regexMatches(dateString, regex);
|
204
|
+
if (matches.length === 3) {
|
205
|
+
return matches;
|
206
|
+
}
|
207
|
+
|
208
|
+
regex = /^([0-9]{1,2})[^0-9]+([0-9]{1,2})$/; // "mm dd"
|
209
|
+
matches = RomoDate.Utils.regexMatches(dateString, regex);
|
210
|
+
if (matches.length === 2) {
|
211
|
+
return [RomoDate.currentYear(), matches[0], matches[1]];
|
212
|
+
}
|
213
|
+
|
214
|
+
return [];
|
215
|
+
}
|
216
|
+
|
217
|
+
// Parser
|
218
|
+
|
219
|
+
// Formatter - child utility class to encapsulate formatting a Date obj into a
|
220
|
+
// date String ('12/25', '12/25/16', '12/25/2016', '2016/12/25')
|
221
|
+
|
222
|
+
RomoDate.Formatter.prototype.dateString = function(forDate) {
|
223
|
+
var d = RomoDate.date(forDate)
|
224
|
+
var year = d.getFullYear();
|
225
|
+
var month = d.getMonth() + 1; // months are zero-based
|
226
|
+
var day = d.getDate();
|
227
|
+
|
228
|
+
var formatter = this;
|
229
|
+
|
230
|
+
return this.formatString.replace(/([ymMdD]+)/g, function(match) {
|
231
|
+
switch (match) {
|
232
|
+
case "yyyy":
|
233
|
+
case "yyy":
|
234
|
+
return year.toString();
|
235
|
+
case "yy":
|
236
|
+
case "y":
|
237
|
+
return year.toString().slice(-2);
|
238
|
+
case "mm":
|
239
|
+
return ("00"+ month.toString()).slice(-2); // pad 2 with "0"s
|
240
|
+
case "m":
|
241
|
+
return month.toString();
|
242
|
+
case "MM":
|
243
|
+
return RomoDate.Utils.monthNames[d.getMonth()]
|
244
|
+
case "M":
|
245
|
+
return RomoDate.Utils.monthAbbrevs[d.getMonth()]
|
246
|
+
case "ddd":
|
247
|
+
var ds = day.toString();
|
248
|
+
switch (ds.slice(-1)) {
|
249
|
+
case '1':
|
250
|
+
ds += 'st';
|
251
|
+
break;
|
252
|
+
case '2':
|
253
|
+
ds += 'nd'
|
254
|
+
break;
|
255
|
+
case '3':
|
256
|
+
ds += 'rd';
|
257
|
+
break;
|
258
|
+
default:
|
259
|
+
ds += 'th';
|
260
|
+
break;
|
261
|
+
}
|
262
|
+
return ds;
|
263
|
+
case "dd":
|
264
|
+
return ("00"+ day.toString()).slice(-2); // pad 2 with "0"s
|
265
|
+
case "d":
|
266
|
+
return day.toString();
|
267
|
+
case "DD":
|
268
|
+
return RomoDate.Utils.dayNames[d.getDay()]
|
269
|
+
case "D":
|
270
|
+
return RomoDate.Utils.dayAbbrevs[d.getDay()]
|
271
|
+
default:
|
272
|
+
return match; // delimeter, pass-thru
|
273
|
+
}
|
274
|
+
});
|
275
|
+
}
|
276
|
+
|
277
|
+
// Formatter
|
278
|
+
|
279
|
+
// Utils - sub utility functions shared by the utility classes
|
280
|
+
|
281
|
+
RomoDate.Utils = {
|
282
|
+
|
283
|
+
regexMatches: function(value, regex) {
|
284
|
+
if (regex.test(value) === true) {
|
285
|
+
return regex.exec(value).slice(1);
|
286
|
+
}
|
287
|
+
return [];
|
288
|
+
},
|
289
|
+
|
290
|
+
monthNames: [
|
291
|
+
"January", "Febuary", "March", "April", "May", "June",
|
292
|
+
"July", "August", "September", "October", "November", "December"
|
293
|
+
],
|
294
|
+
|
295
|
+
monthAbbrevs: [
|
296
|
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
297
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
298
|
+
],
|
299
|
+
|
300
|
+
dayNames: [
|
301
|
+
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
|
302
|
+
],
|
303
|
+
|
304
|
+
dayAbbrevs: [
|
305
|
+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
306
|
+
],
|
307
|
+
|
308
|
+
}
|
309
|
+
|
310
|
+
// Utils
|
@@ -6,10 +6,6 @@ $.fn.romoDatepicker = function() {
|
|
6
6
|
|
7
7
|
var RomoDatepicker = function(element) {
|
8
8
|
this.elem = $(element);
|
9
|
-
this.monthNames = [
|
10
|
-
"January", "February", "March", "April", "May", "June",
|
11
|
-
"July", "August", "September", "October", "November", "December"
|
12
|
-
]
|
13
9
|
|
14
10
|
this.defaultFormat = 'yyyy-mm-dd'
|
15
11
|
this.defaultPrevClass = undefined;
|
@@ -17,7 +13,7 @@ var RomoDatepicker = function(element) {
|
|
17
13
|
this.itemSelector = 'TD.romo-datepicker-day:not(.disabled)';
|
18
14
|
this.calTable = $();
|
19
15
|
this.date = undefined;
|
20
|
-
this.today =
|
16
|
+
this.today = RomoDate.today();
|
21
17
|
this.prevValue = undefined;
|
22
18
|
|
23
19
|
this.doInit();
|
@@ -84,14 +80,13 @@ RomoDatepicker.prototype.doBindElem = function() {
|
|
84
80
|
}
|
85
81
|
|
86
82
|
RomoDatepicker.prototype.doSetFormat = function() {
|
87
|
-
|
88
|
-
this.formatValues = this._parseFormatValues(format);
|
83
|
+
this.formatString = this.elem.data('romo-datepicker-format') || this.defaultFormat;
|
89
84
|
}
|
90
85
|
|
91
86
|
RomoDatepicker.prototype.doSetDate = function(value) {
|
92
|
-
this.date =
|
87
|
+
this.date = RomoDate.parse(value);
|
93
88
|
if (this.date !== undefined) {
|
94
|
-
this.elem.val(
|
89
|
+
this.elem.val(RomoDate.format(this.date, this.formatString));
|
95
90
|
} else {
|
96
91
|
this.elem.val(value);
|
97
92
|
}
|
@@ -151,7 +146,7 @@ RomoDatepicker.prototype.doBuildUI = function() {
|
|
151
146
|
}
|
152
147
|
|
153
148
|
RomoDatepicker.prototype.doRefreshUI = function(date) {
|
154
|
-
var rDate = date || this.date ||
|
149
|
+
var rDate = date || this.date || this.today;
|
155
150
|
this._refreshCalendar(rDate);
|
156
151
|
this.elem.trigger('datepicker:refresh', [rDate, this]);
|
157
152
|
|
@@ -163,29 +158,15 @@ RomoDatepicker.prototype.doRefreshUI = function(date) {
|
|
163
158
|
}
|
164
159
|
|
165
160
|
RomoDatepicker.prototype.doRefreshToPrevMonth = function() {
|
166
|
-
var date
|
167
|
-
var
|
168
|
-
var month = date.getUTCMonth() - 1;
|
169
|
-
if (month < 0) {
|
170
|
-
year -= 1;
|
171
|
-
month = 11;
|
172
|
-
}
|
173
|
-
|
174
|
-
var pDate = this._UTCDate(year, month, 1);
|
161
|
+
var date = this.refreshDate || this.date || (new Date);
|
162
|
+
var pDate = RomoDate.lastDateOfPrevMonth(date);
|
175
163
|
this.doRefreshUI(pDate);
|
176
164
|
this.elem.trigger('datepicker:prevRefresh', [pDate, this]);
|
177
165
|
}
|
178
166
|
|
179
167
|
RomoDatepicker.prototype.doRefreshToNextMonth = function() {
|
180
|
-
var date
|
181
|
-
var
|
182
|
-
var month = date.getUTCMonth() + 1;
|
183
|
-
if (month > 11) {
|
184
|
-
year += 1;
|
185
|
-
month = 0;
|
186
|
-
}
|
187
|
-
|
188
|
-
var nDate = this._UTCDate(year, month, 1);
|
168
|
+
var date = this.refreshDate || this.date || (new Date);
|
169
|
+
var nDate = RomoDate.firstDateOfNextMonth(date);
|
189
170
|
this.doRefreshUI(nDate);
|
190
171
|
this.elem.trigger('datepicker:nextRefresh', [nDate, this]);
|
191
172
|
}
|
@@ -336,11 +317,11 @@ RomoDatepicker.prototype._buildCalendarHeader = function() {
|
|
336
317
|
header.append(row);
|
337
318
|
|
338
319
|
row = $('<tr></tr>');
|
339
|
-
row.append($('<th class="romo-datepicker-day">
|
320
|
+
row.append($('<th class="romo-datepicker-day">S</th>'));
|
340
321
|
row.append($('<th class="romo-datepicker-day">M</th>'));
|
341
322
|
row.append($('<th class="romo-datepicker-day">T</th>'));
|
342
323
|
row.append($('<th class="romo-datepicker-day">W</th>'));
|
343
|
-
row.append($('<th class="romo-datepicker-day">
|
324
|
+
row.append($('<th class="romo-datepicker-day">T</th>'));
|
344
325
|
row.append($('<th class="romo-datepicker-day">F</th>'));
|
345
326
|
row.append($('<th class="romo-datepicker-day">S</th>'));
|
346
327
|
header.append(row);
|
@@ -349,66 +330,61 @@ RomoDatepicker.prototype._buildCalendarHeader = function() {
|
|
349
330
|
}
|
350
331
|
|
351
332
|
RomoDatepicker.prototype._buildCalendarTitle = function(date) {
|
352
|
-
return
|
333
|
+
return RomoDate.format(date, 'MM yyyy');
|
353
334
|
}
|
354
335
|
|
355
336
|
RomoDatepicker.prototype._buildCalendarBody = function(date) {
|
356
|
-
var ty = this.today.getUTCFullYear();
|
357
|
-
var tm = this.today.getUTCMonth();
|
358
|
-
var td = this.today.getUTCDate();
|
359
|
-
var year = date.getUTCFullYear();
|
360
|
-
var month = date.getUTCMonth();
|
361
|
-
var day = date.getUTCDate();
|
362
|
-
var fomdow = this._UTCDate(year, month, 1).getUTCDay(); // first-of-the-month day-of-the-week
|
363
|
-
if (fomdow == 0) {
|
364
|
-
fomdow = 7; // don't start calendar on the first-of-the-month, show last week of prev month
|
365
|
-
}
|
366
|
-
var iDate = this._UTCDate(year, month, 1 - fomdow);
|
367
|
-
var iWeek = 0;
|
368
337
|
var html = [];
|
369
338
|
|
339
|
+
// prefer showing as many past dates in each month as possible
|
340
|
+
// calc the most post days we can show and still fit the date's
|
341
|
+
// month in 6 weeks of displayed days:
|
342
|
+
// 7 days * 6 weeks = 42 displayed days
|
343
|
+
// 42 displayed days - {days in month} = {max past days}
|
344
|
+
var fom = RomoDate.firstDateOfMonth(date); // first-of-month
|
345
|
+
var dim = RomoDate.daysInMonth(date); // days-in-month
|
346
|
+
var past = fom.getDay(); // start on this week's Sunday
|
347
|
+
if ((past+7) <= (42-dim)) { // if there is enough room,
|
348
|
+
past = past+7; // start on prev week's Sunday
|
349
|
+
}
|
350
|
+
var iDate = RomoDate.vector(fom, -past);
|
351
|
+
|
352
|
+
var iWeek = 0;
|
370
353
|
while (iWeek < 6) { // render 6 weeks in the calendar
|
371
|
-
var y = iDate.getUTCFullYear();
|
372
|
-
var m = iDate.getUTCMonth();
|
373
|
-
var d = iDate.getUTCDate();
|
374
|
-
var dow = iDate.getUTCDay();
|
375
354
|
var cls = [];
|
376
355
|
|
377
|
-
if (
|
356
|
+
if (RomoDate.isDay(iDate, 'Sunday')) {
|
378
357
|
html.push('<tr>');
|
379
358
|
}
|
380
359
|
|
381
360
|
cls.push('romo-datepicker-day');
|
382
|
-
if (
|
361
|
+
if (RomoDate.isWeekend(iDate)) {
|
383
362
|
cls.push('romo-datepicker-day-weekend');
|
384
363
|
}
|
385
|
-
if (
|
364
|
+
if (!RomoDate.isSameMonth(iDate, date)) {
|
386
365
|
cls.push('romo-datepicker-day-other');
|
387
366
|
}
|
388
|
-
if (
|
367
|
+
if (RomoDate.isEqual(iDate, this.today)) {
|
389
368
|
cls.push('romo-datepicker-day-today');
|
390
369
|
}
|
391
|
-
if (this.date
|
392
|
-
y === this.date.getUTCFullYear() &&
|
393
|
-
m === this.date.getUTCMonth() &&
|
394
|
-
d === this.date.getUTCDate()) {
|
370
|
+
if (RomoDate.isEqual(iDate, this.date)) {
|
395
371
|
cls.push('selected');
|
396
372
|
}
|
397
373
|
|
398
374
|
html.push('<td');
|
399
375
|
html.push(' class="'+cls.join(' ')+'"');
|
400
|
-
var dt =
|
376
|
+
var dt = RomoDate.format(iDate, this.formatString);
|
401
377
|
html.push(' title="'+dt+'"');
|
402
378
|
html.push(' data-romo-datepicker-value="'+dt+'"');
|
403
379
|
html.push('>');
|
404
|
-
html.push(
|
380
|
+
html.push(RomoDate.format(iDate, 'd'));
|
405
381
|
html.push('</td>');
|
406
382
|
|
407
|
-
if (
|
383
|
+
if (RomoDate.isDay(iDate, 'Saturday')) {
|
408
384
|
html.push('</tr>');
|
409
385
|
iWeek += 1;
|
410
386
|
}
|
411
|
-
iDate.
|
387
|
+
iDate = RomoDate.next(iDate);
|
412
388
|
}
|
413
389
|
|
414
390
|
return $(html.join(''));
|
@@ -419,141 +395,6 @@ RomoDatepicker.prototype._highlightItem = function(item) {
|
|
419
395
|
item.addClass('romo-datepicker-highlight');
|
420
396
|
}
|
421
397
|
|
422
|
-
RomoDatepicker.prototype._formatDate = function(date) {
|
423
|
-
var year = date.getUTCFullYear();
|
424
|
-
var month = date.getUTCMonth() + 1;
|
425
|
-
var day = date.getUTCDate();
|
426
|
-
|
427
|
-
return this.formatValues.reduce(function(prev, curr) {
|
428
|
-
switch (curr) {
|
429
|
-
case "yyyy":
|
430
|
-
case "yyy":
|
431
|
-
prev += year.toString();
|
432
|
-
break;
|
433
|
-
case "yy":
|
434
|
-
case "y":
|
435
|
-
prev += year.toString().slice(-2);
|
436
|
-
break;
|
437
|
-
case "mm":
|
438
|
-
prev += ("00"+ month.toString()).slice(-2); // pad 2 with "0"s
|
439
|
-
break;
|
440
|
-
case "m":
|
441
|
-
prev += month.toString();
|
442
|
-
break;
|
443
|
-
case "dd":
|
444
|
-
prev += ("00"+ day.toString()).slice(-2); // pad 2 with "0"s
|
445
|
-
break;
|
446
|
-
case "d":
|
447
|
-
prev += day.toString();
|
448
|
-
break;
|
449
|
-
default:
|
450
|
-
prev += curr; // delimeter, pass-thru
|
451
|
-
}
|
452
|
-
return prev;
|
453
|
-
}, '');
|
454
|
-
}
|
455
|
-
|
456
|
-
RomoDatepicker.prototype._parseFormatValues = function(value) {
|
457
|
-
var regex, matches;
|
458
|
-
|
459
|
-
regex = /^([m]{1,2})([^md]+)([d]{1,2})([^dy]+)([y]{2,4})$/; // mm dd yyyy or mm dd yy
|
460
|
-
matches = this._regexMatches(value, regex);
|
461
|
-
if (matches.length === 5) {
|
462
|
-
return matches;
|
463
|
-
}
|
464
|
-
|
465
|
-
regex = /^([y]{3,4})([^ym]+)([m]{1,2})([^md]+)([d]{1,2})$/; // yyyy mm dd
|
466
|
-
matches = this._regexMatches(value, regex);
|
467
|
-
if (matches.length === 5) {
|
468
|
-
return matches;
|
469
|
-
}
|
470
|
-
|
471
|
-
return ['yyyy', '-', 'mm', '-', 'dd'];
|
472
|
-
}
|
473
|
-
|
474
|
-
RomoDatepicker.prototype._parseDate = function(value) {
|
475
|
-
if (value.trim() === '') {
|
476
|
-
return undefined;
|
477
|
-
}
|
478
|
-
|
479
|
-
var dateValues = this._parseDateValues(value.trim());
|
480
|
-
if (dateValues.length === 0) {
|
481
|
-
return undefined;
|
482
|
-
}
|
483
|
-
|
484
|
-
var year = parseInt(dateValues[0]);
|
485
|
-
if (year < 0) {
|
486
|
-
return undefined;
|
487
|
-
}
|
488
|
-
if (dateValues[0].length > 2 && year < 100) {
|
489
|
-
return undefined;
|
490
|
-
}
|
491
|
-
if (dateValues[0].length === 2 && year < 100) {
|
492
|
-
year = this._currentYear() - (this._currentYear() % 1000) + year;
|
493
|
-
}
|
494
|
-
|
495
|
-
var month = parseInt(dateValues[1]) - 1;
|
496
|
-
if (month < 0 || month > 11) {
|
497
|
-
return undefined;
|
498
|
-
}
|
499
|
-
|
500
|
-
var day = parseInt(dateValues[2]);
|
501
|
-
var date = this._UTCDate(year, month, day);
|
502
|
-
if (date.getUTCMonth() !== month) {
|
503
|
-
return undefined;
|
504
|
-
}
|
505
|
-
|
506
|
-
return date;
|
507
|
-
}
|
508
|
-
|
509
|
-
RomoDatepicker.prototype._parseDateValues = function(value) {
|
510
|
-
var regex, matches;
|
511
|
-
|
512
|
-
regex = /^([0-9]{1,2})[^0-9]+([0-9]{1,2})[^0-9]+([0-9]{2,4})$/; // mm dd yyyy or mm dd yy
|
513
|
-
matches = this._regexMatches(value, regex);
|
514
|
-
if (matches.length === 3) {
|
515
|
-
return [matches[2], matches[0], matches[1]];
|
516
|
-
}
|
517
|
-
|
518
|
-
regex = /^([0-9]{3,4})[^0-9]+([0-9]{1,2})[^0-9]+([0-9]{1,2})$/; // yyyy mm dd
|
519
|
-
matches = this._regexMatches(value, regex);
|
520
|
-
if (matches.length === 3) {
|
521
|
-
return matches;
|
522
|
-
}
|
523
|
-
|
524
|
-
regex = /^([0-9]{1,2})[^0-9]+([0-9]{1,2})$/; // mm dd
|
525
|
-
matches = this._regexMatches(value, regex);
|
526
|
-
if (matches.length === 2) {
|
527
|
-
return [this._currentYear(), matches[0], matches[1]];
|
528
|
-
}
|
529
|
-
|
530
|
-
return [];
|
531
|
-
}
|
532
|
-
|
533
|
-
RomoDatepicker.prototype._regexMatches = function(value, regex) {
|
534
|
-
if (regex.test(value) === true) {
|
535
|
-
return regex.exec(value).slice(1);
|
536
|
-
}
|
537
|
-
return [];
|
538
|
-
}
|
539
|
-
|
540
|
-
RomoDatepicker.prototype._currentYear = function() {
|
541
|
-
return (new Date).getUTCFullYear();
|
542
|
-
}
|
543
|
-
|
544
|
-
RomoDatepicker.prototype._getTodaysDate = function() {
|
545
|
-
var today = new Date();
|
546
|
-
var dd = today.getDate();
|
547
|
-
var mm = today.getMonth();
|
548
|
-
var yyyy = today.getFullYear();
|
549
|
-
|
550
|
-
return this._UTCDate(yyyy, mm, dd);
|
551
|
-
}
|
552
|
-
|
553
|
-
RomoDatepicker.prototype._UTCDate = function(year, month, day) {
|
554
|
-
return new Date(Date.UTC.apply(Date, [year, month, day]));
|
555
|
-
}
|
556
|
-
|
557
398
|
Romo.onInitUI(function(e) {
|
558
399
|
Romo.initUIElems(e, '[data-romo-datepicker-auto="true"]').romoDatepicker();
|
559
400
|
});
|
data/assets/js/romo/dropdown.js
CHANGED
@@ -7,8 +7,8 @@ $.fn.romoDropdown = function() {
|
|
7
7
|
var RomoDropdown = function(element) {
|
8
8
|
this.elem = $(element);
|
9
9
|
this.doInitPopup();
|
10
|
-
this.
|
11
|
-
this.
|
10
|
+
this.romoAjax = this.elem.romoAjax()[0];
|
11
|
+
this.romoAjax.doUnbindElem(); // disable auto invoke on click
|
12
12
|
|
13
13
|
if (this.elem.data('romo-dropdown-disable-click-invoke') !== true) {
|
14
14
|
this.elem.unbind('click');
|
@@ -17,15 +17,15 @@ var RomoDropdown = function(element) {
|
|
17
17
|
this.elem.on('dropdown:triggerToggle', $.proxy(this.onToggleClick, this));
|
18
18
|
this.elem.on('dropdown:triggerPopupOpen', $.proxy(this.onPopupOpen, this));
|
19
19
|
this.elem.on('dropdown:triggerPopupClose', $.proxy(this.onPopupClose, this));
|
20
|
-
this.elem.on('
|
20
|
+
this.elem.on('romoAjax:callStart', $.proxy(function(e, romoAjax) {
|
21
21
|
this.doLoadBodyStart();
|
22
22
|
return false;
|
23
23
|
}, this));
|
24
|
-
this.elem.on('
|
24
|
+
this.elem.on('romoAjax:callSuccess', $.proxy(function(e, data, romoAjax) {
|
25
25
|
this.doLoadBodySuccess(data);
|
26
26
|
return false;
|
27
27
|
}, this));
|
28
|
-
this.elem.on('
|
28
|
+
this.elem.on('romoAjax:callError', $.proxy(function(e, xhr, romoAjax) {
|
29
29
|
this.doLoadBodyError(xhr);
|
30
30
|
return false;
|
31
31
|
}, this));
|
@@ -206,7 +206,7 @@ RomoDropdown.prototype.doPopupOpen = function() {
|
|
206
206
|
if (this.elem.data('romo-dropdown-content-elem') !== undefined) {
|
207
207
|
this.doLoadBodySuccess($(this.elem.data('romo-dropdown-content-elem')).html())
|
208
208
|
} else {
|
209
|
-
this.
|
209
|
+
this.romoAjax.doInvoke();
|
210
210
|
}
|
211
211
|
|
212
212
|
this.popupElem.addClass('romo-dropdown-open');
|
data/assets/js/romo/inline.js
CHANGED
@@ -14,15 +14,15 @@ var RomoInline = function(element) {
|
|
14
14
|
this.doShow();
|
15
15
|
}, this));
|
16
16
|
|
17
|
-
this.elem.on('
|
17
|
+
this.elem.on('romoAjax:callStart', $.proxy(function(e, romoAjax) {
|
18
18
|
this.doLoadStart();
|
19
19
|
return false;
|
20
20
|
}, this));
|
21
|
-
this.elem.on('
|
21
|
+
this.elem.on('romoAjax:callSuccess', $.proxy(function(e, data, romoAjax) {
|
22
22
|
this.doLoadSuccess(data);
|
23
23
|
return false;
|
24
24
|
}, this));
|
25
|
-
this.elem.on('
|
25
|
+
this.elem.on('romoAjax:callError', $.proxy(function(e, xhr, romoAjax) {
|
26
26
|
this.doLoadError(xhr);
|
27
27
|
return false;
|
28
28
|
}, this));
|