vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-4.17.43 vs vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-4.17.47
- old
+ new
@@ -1,6 +1,6 @@
-/*! version : 4.17.42
+/*! version : 4.17.47
=========================================================
bootstrap-datetimejs
https://github.com/Eonasdan/bootstrap-datetimepicker
Copyright (c) 2015 Jonathan Peterson
=========================================================
@@ -140,10 +140,14 @@
getMoment = function (d) {
var returnMoment;
if (d === undefined || d === null) {
returnMoment = moment(); //TODO should this use format? and locale?
+ } else if (moment.isDate(d) || moment.isMoment(d)) {
+ // If the date that is passed in is already a Date() or moment() object,
+ // pass it directly to moment.
+ returnMoment = moment(d);
} else if (hasTimeZone()) { // There is a string to parse and a default time zone
// parse with the tz function which takes a default time zone if it is not in the format string
returnMoment = moment.tz(d, parseFormats, options.useStrict, options.timeZone);
} else {
returnMoment = moment(d, parseFormats, options.useStrict);
@@ -334,10 +338,11 @@
}
if (use24Hours) {
template.addClass('usetwentyfour');
}
+
if (isEnabled('s') && !use24Hours) {
template.addClass('wider');
}
if (options.sideBySide && hasDate() && hasTime()) {
@@ -446,19 +451,19 @@
widget.addClass('pull-right');
} else {
widget.removeClass('pull-right');
}
- // find the first parent element that has a relative css positioning
- if (parent.css('position') !== 'relative') {
+ // find the first parent element that has a non-static css positioning
+ if (parent.css('position') === 'static') {
parent = parent.parents().filter(function () {
- return $(this).css('position') === 'relative';
+ return $(this).css('position') !== 'static';
}).first();
}
if (parent.length === 0) {
- throw new Error('datetimepicker component should be placed within a relative positioned container');
+ throw new Error('datetimepicker component should be placed within a non-static positioned container');
}
widget.css({
top: vertical === 'top' ? 'auto' : position.top + element.outerHeight(),
bottom: vertical === 'top' ? parent.outerHeight() - (parent === element ? 0 : position.top) : 'auto',
@@ -684,11 +689,11 @@
var daysView = widget.find('.datepicker-days'),
daysViewHeader = daysView.find('th'),
currentDate,
html = [],
row,
- clsName,
+ clsNames = [],
i;
if (!hasDate()) {
return;
}
@@ -715,30 +720,35 @@
if (options.calendarWeeks) {
row.append('<td class="cw">' + currentDate.week() + '</td>');
}
html.push(row);
}
- clsName = '';
+ clsNames = ['day'];
if (currentDate.isBefore(viewDate, 'M')) {
- clsName += ' old';
+ clsNames.push('old');
}
if (currentDate.isAfter(viewDate, 'M')) {
- clsName += ' new';
+ clsNames.push('new');
}
if (currentDate.isSame(date, 'd') && !unset) {
- clsName += ' active';
+ clsNames.push('active');
}
if (!isValid(currentDate, 'd')) {
- clsName += ' disabled';
+ clsNames.push('disabled');
}
if (currentDate.isSame(getMoment(), 'd')) {
- clsName += ' today';
+ clsNames.push('today');
}
if (currentDate.day() === 0 || currentDate.day() === 6) {
- clsName += ' weekend';
+ clsNames.push('weekend');
}
- row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="day' + clsName + '">' + currentDate.date() + '</td>');
+ notifyEvent({
+ type: 'dp.classify',
+ date: currentDate,
+ classNames: clsNames
+ });
+ row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="' + clsNames.join(' ') + '">' + currentDate.date() + '</td>');
currentDate.add(1, 'd');
}
daysView.find('tbody').empty().append(html);
@@ -860,15 +870,19 @@
targetMoment.tz(options.timeZone);
}
if (options.stepping !== 1) {
targetMoment.minutes((Math.round(targetMoment.minutes() / options.stepping) * options.stepping)).seconds(0);
+
+ while (options.minDate && targetMoment.isBefore(options.minDate)) {
+ targetMoment.add(options.stepping, 'minutes');
+ }
}
if (isValid(targetMoment)) {
date = targetMoment;
- //viewDate = date.clone(); // TODO this doesn't work right on first use
+ viewDate = date.clone();
input.val(date.format(actualFormat));
element.data('date', date.format(actualFormat));
unset = false;
update();
notifyEvent({
@@ -931,11 +945,10 @@
date: date.clone()
});
input.blur();
- currentViewMode = 0;
viewDate = date.clone();
return picker;
},
@@ -943,11 +956,11 @@
setValue(null);
},
parseInputDate = function (inputDate) {
if (options.parseInputDate === undefined) {
- if (!moment.isMoment(inputDate)) {
+ if (!moment.isMoment(inputDate) || inputDate instanceof Date) {
inputDate = getMoment(inputDate);
}
} else {
inputDate = options.parseInputDate(inputDate);
}
@@ -2400,15 +2413,16 @@
thisMethods = ['destroy', 'hide', 'show', 'toggle'],
returnValue;
if (typeof options === 'object') {
return this.each(function () {
- var $this = $(this);
+ var $this = $(this),
+ _options;
if (!$this.data('DateTimePicker')) {
// create a private copy of the defaults object
- options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
- $this.data('DateTimePicker', dateTimePicker($this, options));
+ _options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
+ $this.data('DateTimePicker', dateTimePicker($this, _options));
}
});
} else if (typeof options === 'string') {
this.each(function () {
var $this = $(this),
@@ -2615,9 +2629,8 @@
disabledTimeIntervals: false,
disabledHours: false,
enabledHours: false,
viewDate: false
};
- if (typeof module !== 'undefined') {
- module.exports = $.fn.datetimepicker;
- }
+
+ return $.fn.datetimepicker;
}));