effective_form_inputs 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_date_time_picker/bootstrap-datetimepicker.js +103 -36
- data/app/assets/stylesheets/effective_date_time_picker/bootstrap-datetimepicker.scss +1 -1
- data/app/models/effective/form_input.rb +3 -0
- data/lib/effective_form_inputs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9669ce7ecda604b1c0bd0ef1bbaddcf6dcbbb0cb
|
4
|
+
data.tar.gz: 16032e2ed35d105bebee6a0cdc4e9395742b9b32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25abb4767be706f8b4fc5465c626b85be207b8c96501c34a9627c1efcf3ae815b716436aaaad530e3f82cccdf43144af3525494fff0e625d781423ddc2128077
|
7
|
+
data.tar.gz: 3549365f9f6a87246958cff727c73e46b5345da77e39ec46ae834849dcf791a2d0beb832952b87073458be89ab07410c07833d3f26fa67e59aaa0bda6f773515
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! version : 4.
|
1
|
+
/*! version : 4.17.37
|
2
2
|
=========================================================
|
3
3
|
bootstrap-datetimejs
|
4
4
|
https://github.com/Eonasdan/bootstrap-datetimepicker
|
@@ -58,8 +58,8 @@
|
|
58
58
|
|
59
59
|
var dateTimePicker = function (element, options) {
|
60
60
|
var picker = {},
|
61
|
-
date
|
62
|
-
viewDate
|
61
|
+
date,
|
62
|
+
viewDate,
|
63
63
|
unset = true,
|
64
64
|
input,
|
65
65
|
component = false,
|
@@ -132,6 +132,40 @@
|
|
132
132
|
* Private functions
|
133
133
|
*
|
134
134
|
********************************************************************************/
|
135
|
+
getMoment = function (d) {
|
136
|
+
var tzEnabled = false,
|
137
|
+
returnMoment,
|
138
|
+
currentZoneOffset,
|
139
|
+
incomingZoneOffset,
|
140
|
+
timeZoneIndicator,
|
141
|
+
dateWithTimeZoneInfo;
|
142
|
+
|
143
|
+
if (moment.tz !== undefined && options.timeZone !== undefined && options.timeZone !== null && options.timeZone !== '') {
|
144
|
+
tzEnabled = true;
|
145
|
+
}
|
146
|
+
if (d === undefined || d === null) {
|
147
|
+
if (tzEnabled) {
|
148
|
+
returnMoment = moment().tz(options.timeZone).startOf('d');
|
149
|
+
} else {
|
150
|
+
returnMoment = moment().startOf('d');
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
if (tzEnabled) {
|
154
|
+
currentZoneOffset = moment().tz(options.timeZone).utcOffset();
|
155
|
+
incomingZoneOffset = moment(d, parseFormats, options.useStrict).utcOffset();
|
156
|
+
if (incomingZoneOffset !== currentZoneOffset) {
|
157
|
+
timeZoneIndicator = moment().tz(options.timeZone).format('Z');
|
158
|
+
dateWithTimeZoneInfo = moment(d, parseFormats, options.useStrict).format('YYYY-MM-DD[T]HH:mm:ss') + timeZoneIndicator;
|
159
|
+
returnMoment = moment(dateWithTimeZoneInfo, parseFormats, options.useStrict).tz(options.timeZone);
|
160
|
+
} else {
|
161
|
+
returnMoment = moment(d, parseFormats, options.useStrict).tz(options.timeZone);
|
162
|
+
}
|
163
|
+
} else {
|
164
|
+
returnMoment = moment(d, parseFormats, options.useStrict);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return returnMoment;
|
168
|
+
},
|
135
169
|
isEnabled = function (granularity) {
|
136
170
|
if (typeof granularity !== 'string' || granularity.length > 1) {
|
137
171
|
throw new TypeError('isEnabled expects a single character string parameter');
|
@@ -209,12 +243,12 @@
|
|
209
243
|
|
210
244
|
if (isEnabled('h')) {
|
211
245
|
topRow.append($('<td>')
|
212
|
-
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':
|
246
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title': options.tooltips.incrementHour}).addClass('btn').attr('data-action', 'incrementHours')
|
213
247
|
.append($('<span>').addClass(options.icons.up))));
|
214
248
|
middleRow.append($('<td>')
|
215
|
-
.append($('<span>').addClass('timepicker-hour').attr({'data-time-component':'hours', 'title':
|
249
|
+
.append($('<span>').addClass('timepicker-hour').attr({'data-time-component':'hours', 'title': options.tooltips.pickHour}).attr('data-action', 'showHours')));
|
216
250
|
bottomRow.append($('<td>')
|
217
|
-
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':
|
251
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title': options.tooltips.decrementHour}).addClass('btn').attr('data-action', 'decrementHours')
|
218
252
|
.append($('<span>').addClass(options.icons.down))));
|
219
253
|
}
|
220
254
|
if (isEnabled('m')) {
|
@@ -224,12 +258,12 @@
|
|
224
258
|
bottomRow.append($('<td>').addClass('separator'));
|
225
259
|
}
|
226
260
|
topRow.append($('<td>')
|
227
|
-
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':
|
261
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title': options.tooltips.incrementMinute}).addClass('btn').attr('data-action', 'incrementMinutes')
|
228
262
|
.append($('<span>').addClass(options.icons.up))));
|
229
263
|
middleRow.append($('<td>')
|
230
|
-
.append($('<span>').addClass('timepicker-minute').attr({'data-time-component': 'minutes', 'title':
|
264
|
+
.append($('<span>').addClass('timepicker-minute').attr({'data-time-component': 'minutes', 'title': options.tooltips.pickMinute}).attr('data-action', 'showMinutes')));
|
231
265
|
bottomRow.append($('<td>')
|
232
|
-
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':
|
266
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title': options.tooltips.decrementMinute}).addClass('btn').attr('data-action', 'decrementMinutes')
|
233
267
|
.append($('<span>').addClass(options.icons.down))));
|
234
268
|
}
|
235
269
|
if (isEnabled('s')) {
|
@@ -239,19 +273,19 @@
|
|
239
273
|
bottomRow.append($('<td>').addClass('separator'));
|
240
274
|
}
|
241
275
|
topRow.append($('<td>')
|
242
|
-
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':
|
276
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title': options.tooltips.incrementSecond}).addClass('btn').attr('data-action', 'incrementSeconds')
|
243
277
|
.append($('<span>').addClass(options.icons.up))));
|
244
278
|
middleRow.append($('<td>')
|
245
|
-
.append($('<span>').addClass('timepicker-second').attr({'data-time-component': 'seconds', 'title':
|
279
|
+
.append($('<span>').addClass('timepicker-second').attr({'data-time-component': 'seconds', 'title': options.tooltips.pickSecond}).attr('data-action', 'showSeconds')));
|
246
280
|
bottomRow.append($('<td>')
|
247
|
-
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':
|
281
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title': options.tooltips.decrementSecond}).addClass('btn').attr('data-action', 'decrementSeconds')
|
248
282
|
.append($('<span>').addClass(options.icons.down))));
|
249
283
|
}
|
250
284
|
|
251
285
|
if (!use24Hours) {
|
252
286
|
topRow.append($('<td>').addClass('separator'));
|
253
287
|
middleRow.append($('<td>')
|
254
|
-
.append($('<button>').addClass('btn btn-primary').attr({'data-action': 'togglePeriod', tabindex: '-1', 'title':
|
288
|
+
.append($('<button>').addClass('btn btn-primary').attr({'data-action': 'togglePeriod', tabindex: '-1', 'title': options.tooltips.togglePeriod})));
|
255
289
|
bottomRow.append($('<td>').addClass('separator'));
|
256
290
|
}
|
257
291
|
|
@@ -288,7 +322,7 @@
|
|
288
322
|
row.push($('<td>').append($('<a>').attr({'data-action':'today', 'title': options.tooltips.today}).append($('<span>').addClass(options.icons.today))));
|
289
323
|
}
|
290
324
|
if (!options.sideBySide && hasDate() && hasTime()) {
|
291
|
-
row.push($('<td>').append($('<a>').attr({'data-action':'togglePicker', 'title':
|
325
|
+
row.push($('<td>').append($('<a>').attr({'data-action':'togglePicker', 'title': options.tooltips.selectTime}).append($('<span>').addClass(options.icons.time))));
|
292
326
|
}
|
293
327
|
if (options.showClear) {
|
294
328
|
row.push($('<td>').append($('<a>').attr({'data-action':'clear', 'title': options.tooltips.clear}).append($('<span>').addClass(options.icons.clear))));
|
@@ -593,9 +627,9 @@
|
|
593
627
|
endYear = viewDate.clone().add(6, 'y'),
|
594
628
|
html = '';
|
595
629
|
|
596
|
-
yearsViewHeader.eq(0).find('span').attr('title', options.tooltips.
|
630
|
+
yearsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevDecade);
|
597
631
|
yearsViewHeader.eq(1).attr('title', options.tooltips.selectDecade);
|
598
|
-
yearsViewHeader.eq(2).find('span').attr('title', options.tooltips.
|
632
|
+
yearsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextDecade);
|
599
633
|
|
600
634
|
yearsView.find('.disabled').removeClass('disabled');
|
601
635
|
|
@@ -620,8 +654,9 @@
|
|
620
654
|
updateDecades = function () {
|
621
655
|
var decadesView = widget.find('.datepicker-decades'),
|
622
656
|
decadesViewHeader = decadesView.find('th'),
|
623
|
-
startDecade =
|
657
|
+
startDecade = moment({y: viewDate.year() - (viewDate.year() % 100) - 1}),
|
624
658
|
endDecade = startDecade.clone().add(100, 'y'),
|
659
|
+
startedAt = startDecade.clone(),
|
625
660
|
html = '';
|
626
661
|
|
627
662
|
decadesViewHeader.eq(0).find('span').attr('title', options.tooltips.prevCentury);
|
@@ -647,6 +682,7 @@
|
|
647
682
|
html += '<span></span><span></span><span></span>'; //push the dangling block over, at least this way it's even
|
648
683
|
|
649
684
|
decadesView.find('td').html(html);
|
685
|
+
decadesViewHeader.eq(1).text((startedAt.year() + 1) + '-' + (startDecade.year()));
|
650
686
|
},
|
651
687
|
|
652
688
|
fillDate = function () {
|
@@ -699,7 +735,7 @@
|
|
699
735
|
if (!isValid(currentDate, 'd')) {
|
700
736
|
clsName += ' disabled';
|
701
737
|
}
|
702
|
-
if (currentDate.isSame(
|
738
|
+
if (currentDate.isSame(getMoment(), 'd')) {
|
703
739
|
clsName += ' today';
|
704
740
|
}
|
705
741
|
if (currentDate.day() === 0 || currentDate.day() === 6) {
|
@@ -1108,8 +1144,9 @@
|
|
1108
1144
|
clear: clear,
|
1109
1145
|
|
1110
1146
|
today: function () {
|
1111
|
-
|
1112
|
-
|
1147
|
+
var todaysDate = getMoment();
|
1148
|
+
if (isValid(todaysDate, 'd')) {
|
1149
|
+
setValue(todaysDate);
|
1113
1150
|
}
|
1114
1151
|
},
|
1115
1152
|
|
@@ -1151,7 +1188,7 @@
|
|
1151
1188
|
if (input.val() !== undefined && input.val().trim().length !== 0) {
|
1152
1189
|
setValue(parseInputDate(input.val().trim()));
|
1153
1190
|
} else if (options.useCurrent && unset && ((input.is('input') && input.val().trim().length === 0) || options.inline)) {
|
1154
|
-
currentMoment =
|
1191
|
+
currentMoment = getMoment();
|
1155
1192
|
if (typeof options.useCurrent === 'string') {
|
1156
1193
|
currentMoment = useCurrentGranularity[options.useCurrent](currentMoment);
|
1157
1194
|
}
|
@@ -1200,7 +1237,7 @@
|
|
1200
1237
|
if (moment.isMoment(inputDate) || inputDate instanceof Date) {
|
1201
1238
|
inputDate = moment(inputDate);
|
1202
1239
|
} else {
|
1203
|
-
inputDate =
|
1240
|
+
inputDate = getMoment(inputDate);
|
1204
1241
|
}
|
1205
1242
|
} else {
|
1206
1243
|
inputDate = options.parseInputDate(inputDate);
|
@@ -1486,6 +1523,16 @@
|
|
1486
1523
|
return picker;
|
1487
1524
|
};
|
1488
1525
|
|
1526
|
+
picker.timeZone = function (newZone) {
|
1527
|
+
if (arguments.length === 0) {
|
1528
|
+
return options.timeZone;
|
1529
|
+
}
|
1530
|
+
|
1531
|
+
options.timeZone = newZone;
|
1532
|
+
|
1533
|
+
return picker;
|
1534
|
+
};
|
1535
|
+
|
1489
1536
|
picker.dayViewHeaderFormat = function (newFormat) {
|
1490
1537
|
if (arguments.length === 0) {
|
1491
1538
|
return options.dayViewHeaderFormat;
|
@@ -1622,7 +1669,7 @@
|
|
1622
1669
|
|
1623
1670
|
if (typeof maxDate === 'string') {
|
1624
1671
|
if (maxDate === 'now' || maxDate === 'moment') {
|
1625
|
-
maxDate =
|
1672
|
+
maxDate = getMoment();
|
1626
1673
|
}
|
1627
1674
|
}
|
1628
1675
|
|
@@ -1658,7 +1705,7 @@
|
|
1658
1705
|
|
1659
1706
|
if (typeof minDate === 'string') {
|
1660
1707
|
if (minDate === 'now' || minDate === 'moment') {
|
1661
|
-
minDate =
|
1708
|
+
minDate = getMoment();
|
1662
1709
|
}
|
1663
1710
|
}
|
1664
1711
|
|
@@ -1700,7 +1747,7 @@
|
|
1700
1747
|
|
1701
1748
|
if (typeof defaultDate === 'string') {
|
1702
1749
|
if (defaultDate === 'now' || defaultDate === 'moment') {
|
1703
|
-
defaultDate =
|
1750
|
+
defaultDate = getMoment();
|
1704
1751
|
}
|
1705
1752
|
}
|
1706
1753
|
|
@@ -1714,7 +1761,7 @@
|
|
1714
1761
|
|
1715
1762
|
options.defaultDate = parsedDate;
|
1716
1763
|
|
1717
|
-
if (options.defaultDate && options.inline ||
|
1764
|
+
if ((options.defaultDate && options.inline) || input.val().trim() === '') {
|
1718
1765
|
setValue(options.defaultDate);
|
1719
1766
|
}
|
1720
1767
|
return picker;
|
@@ -2041,6 +2088,10 @@
|
|
2041
2088
|
return picker;
|
2042
2089
|
};
|
2043
2090
|
|
2091
|
+
picker.getMoment = function (d) {
|
2092
|
+
return getMoment(d);
|
2093
|
+
};
|
2094
|
+
|
2044
2095
|
picker.debug = function (debug) {
|
2045
2096
|
if (typeof debug !== 'boolean') {
|
2046
2097
|
throw new TypeError('debug() expects a boolean parameter');
|
@@ -2271,6 +2322,10 @@
|
|
2271
2322
|
throw new Error('Could not initialize DateTimePicker without an input element');
|
2272
2323
|
}
|
2273
2324
|
|
2325
|
+
// Set defaults for date here now instead of in var declaration
|
2326
|
+
date = getMoment();
|
2327
|
+
viewDate = date.clone();
|
2328
|
+
|
2274
2329
|
$.extend(true, options, dataToOptions());
|
2275
2330
|
|
2276
2331
|
picker.options(options);
|
@@ -2312,6 +2367,7 @@
|
|
2312
2367
|
};
|
2313
2368
|
|
2314
2369
|
$.fn.datetimepicker.defaults = {
|
2370
|
+
timeZone: 'Etc/UTC',
|
2315
2371
|
format: false,
|
2316
2372
|
dayViewHeaderFormat: 'MMMM YYYY',
|
2317
2373
|
extraFormats: false,
|
@@ -2349,7 +2405,18 @@
|
|
2349
2405
|
prevDecade: 'Previous Decade',
|
2350
2406
|
nextDecade: 'Next Decade',
|
2351
2407
|
prevCentury: 'Previous Century',
|
2352
|
-
nextCentury: 'Next Century'
|
2408
|
+
nextCentury: 'Next Century',
|
2409
|
+
pickHour: 'Pick Hour',
|
2410
|
+
incrementHour: 'Increment Hour',
|
2411
|
+
decrementHour: 'Decrement Hour',
|
2412
|
+
pickMinute: 'Pick Minute',
|
2413
|
+
incrementMinute: 'Increment Minute',
|
2414
|
+
decrementMinute: 'Decrement Minute',
|
2415
|
+
pickSecond: 'Pick Second',
|
2416
|
+
incrementSecond: 'Increment Second',
|
2417
|
+
decrementSecond: 'Decrement Second',
|
2418
|
+
togglePeriod: 'Toggle Period',
|
2419
|
+
selectTime: 'Select Time'
|
2353
2420
|
},
|
2354
2421
|
useStrict: false,
|
2355
2422
|
sideBySide: false,
|
@@ -2376,7 +2443,7 @@
|
|
2376
2443
|
if (!widget) {
|
2377
2444
|
return;
|
2378
2445
|
}
|
2379
|
-
var d = this.date() ||
|
2446
|
+
var d = this.date() || this.getMoment();
|
2380
2447
|
if (widget.find('.datepicker').is(':visible')) {
|
2381
2448
|
this.date(d.clone().subtract(7, 'd'));
|
2382
2449
|
} else {
|
@@ -2388,7 +2455,7 @@
|
|
2388
2455
|
this.show();
|
2389
2456
|
return;
|
2390
2457
|
}
|
2391
|
-
var d = this.date() ||
|
2458
|
+
var d = this.date() || this.getMoment();
|
2392
2459
|
if (widget.find('.datepicker').is(':visible')) {
|
2393
2460
|
this.date(d.clone().add(7, 'd'));
|
2394
2461
|
} else {
|
@@ -2399,7 +2466,7 @@
|
|
2399
2466
|
if (!widget) {
|
2400
2467
|
return;
|
2401
2468
|
}
|
2402
|
-
var d = this.date() ||
|
2469
|
+
var d = this.date() || this.getMoment();
|
2403
2470
|
if (widget.find('.datepicker').is(':visible')) {
|
2404
2471
|
this.date(d.clone().subtract(1, 'y'));
|
2405
2472
|
} else {
|
@@ -2410,7 +2477,7 @@
|
|
2410
2477
|
if (!widget) {
|
2411
2478
|
return;
|
2412
2479
|
}
|
2413
|
-
var d = this.date() ||
|
2480
|
+
var d = this.date() || this.getMoment();
|
2414
2481
|
if (widget.find('.datepicker').is(':visible')) {
|
2415
2482
|
this.date(d.clone().add(1, 'y'));
|
2416
2483
|
} else {
|
@@ -2421,7 +2488,7 @@
|
|
2421
2488
|
if (!widget) {
|
2422
2489
|
return;
|
2423
2490
|
}
|
2424
|
-
var d = this.date() ||
|
2491
|
+
var d = this.date() || this.getMoment();
|
2425
2492
|
if (widget.find('.datepicker').is(':visible')) {
|
2426
2493
|
this.date(d.clone().subtract(1, 'd'));
|
2427
2494
|
}
|
@@ -2430,7 +2497,7 @@
|
|
2430
2497
|
if (!widget) {
|
2431
2498
|
return;
|
2432
2499
|
}
|
2433
|
-
var d = this.date() ||
|
2500
|
+
var d = this.date() || this.getMoment();
|
2434
2501
|
if (widget.find('.datepicker').is(':visible')) {
|
2435
2502
|
this.date(d.clone().add(1, 'd'));
|
2436
2503
|
}
|
@@ -2439,7 +2506,7 @@
|
|
2439
2506
|
if (!widget) {
|
2440
2507
|
return;
|
2441
2508
|
}
|
2442
|
-
var d = this.date() ||
|
2509
|
+
var d = this.date() || this.getMoment();
|
2443
2510
|
if (widget.find('.datepicker').is(':visible')) {
|
2444
2511
|
this.date(d.clone().subtract(1, 'M'));
|
2445
2512
|
}
|
@@ -2448,7 +2515,7 @@
|
|
2448
2515
|
if (!widget) {
|
2449
2516
|
return;
|
2450
2517
|
}
|
2451
|
-
var d = this.date() ||
|
2518
|
+
var d = this.date() || this.getMoment();
|
2452
2519
|
if (widget.find('.datepicker').is(':visible')) {
|
2453
2520
|
this.date(d.clone().add(1, 'M'));
|
2454
2521
|
}
|
@@ -2469,7 +2536,7 @@
|
|
2469
2536
|
}
|
2470
2537
|
},
|
2471
2538
|
t: function () {
|
2472
|
-
this.date(
|
2539
|
+
this.date(this.getMoment());
|
2473
2540
|
},
|
2474
2541
|
'delete': function () {
|
2475
2542
|
this.clear();
|
@@ -22,6 +22,9 @@ module Effective
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
@js_opts = @js_opts.with_indifferent_access
|
26
|
+
@html_opts = @html_opts.with_indifferent_access
|
27
|
+
|
25
28
|
# Reverse merge in the defaults, so the current values take precedence over defaults
|
26
29
|
@js_opts.reverse_merge!((default_input_js || {}))
|
27
30
|
@html_opts.reverse_merge!((default_input_html || {}).except(:class))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_form_inputs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|