vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-3.0.2.1 vs vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-3.0.3
- old
+ new
@@ -1,7 +1,7 @@
/*
-//! version : 3.0.2
+//! version : 3.0.3
=========================================================
bootstrap-datetimepicker.js
https://github.com/Eonasdan/bootstrap-datetimepicker
=========================================================
The MIT License (MIT)
@@ -24,51 +24,46 @@
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-; (function (factory) {
+;(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD is used - Register as an anonymous module.
define(['jquery', 'moment'], factory);
} else {
// AMD is not used - Attempt to fetch dependencies from scope.
if (!jQuery) {
- throw 'bootstrap-datetimepicker requires jQuery to be loaded first';
- } else if (!moment) {
- throw 'bootstrap-datetimepicker requires moment.js to be loaded first';
- } else {
- factory(jQuery, moment);
+ throw new Error('bootstrap-datetimepicker requires jQuery to be loaded first');
}
+ if (!moment) {
+ throw new Error('bootstrap-datetimepicker requires moment.js to be loaded first');
+ }
+ factory(root.jQuery, moment);
}
-}
-
-(function ($, moment) {
+}(this, function ($, moment) {
'use strict';
if (typeof moment === 'undefined') {
throw new Error('momentjs is required');
}
var dpgId = 0,
- pMoment = moment,
-
-// ReSharper disable once InconsistentNaming
DateTimePicker = function (element, options) {
var defaults = $.fn.datetimepicker.defaults,
- icons = {
- time: 'glyphicon glyphicon-time',
- date: 'glyphicon glyphicon-calendar',
- up: 'glyphicon glyphicon-chevron-up',
- down: 'glyphicon glyphicon-chevron-down'
- },
+ icons = {
+ time: 'glyphicon glyphicon-time',
+ date: 'glyphicon glyphicon-calendar',
+ up: 'glyphicon glyphicon-chevron-up',
+ down: 'glyphicon glyphicon-chevron-down'
+ },
- picker = this,
+ picker = this,
- dDate,
+ dDate,
init = function () {
var icon = false, localeData, rInterval;
picker.options = $.extend({}, defaults, options);
picker.options.icons = $.extend({}, icons, picker.options.icons);
@@ -80,12 +75,12 @@
if (!(picker.options.pickTime || picker.options.pickDate)) {
throw new Error('Must choose at least one picker');
}
picker.id = dpgId++;
- pMoment.locale(picker.options.language);
- picker.date = pMoment();
+ moment.locale(picker.options.language);
+ picker.date = moment();
picker.unset = false;
picker.isInput = picker.element.is('input');
picker.component = false;
if (picker.element.hasClass('input-group')) {
@@ -96,11 +91,11 @@
picker.component = picker.element.find('.datepickerbutton');
}
}
picker.format = picker.options.format;
- localeData = pMoment().localeData();
+ localeData = moment().localeData();
if (!picker.format) {
picker.format = (picker.options.pickDate ? localeData.longDateFormat('L') : '');
if (picker.options.pickDate && picker.options.pickTime) {
picker.format += ' ';
@@ -140,14 +135,10 @@
}).get(0) ||
'body';
picker.widget = $(getTemplate()).appendTo(picker.options.widgetParent);
- if (picker.options.useSeconds && !picker.use24hours) {
- picker.widget.width(300);
- }
-
picker.minViewMode = picker.options.minViewMode || 0;
if (typeof picker.minViewMode === 'string') {
switch (picker.minViewMode) {
case 'months':
picker.minViewMode = 1;
@@ -173,10 +164,12 @@
picker.viewMode = 0;
break;
}
}
+ picker.viewMode = Math.max(picker.viewMode, picker.minViewMode);
+
picker.options.disabledDates = indexGivenDates(picker.options.disabledDates);
picker.options.enabledDates = indexGivenDates(picker.options.enabledDates);
picker.startViewMode = picker.viewMode;
picker.setMinDate(picker.options.minDate);
@@ -277,10 +270,19 @@
picker.options.direction = eData.dateDirection;
}
if (eData.dateSidebyside !== undefined) {
picker.options.sideBySide = eData.dateSidebyside;
}
+ if (eData.dateDaysofweekdisabled !== undefined) {
+ picker.options.daysOfWeekDisabled = eData.dateDaysofweekdisabled;
+ }
+// $.each(defaults, function (key) {
+// var attributeName = 'date' + key.charAt(0).toUpperCase() + key.slice(1);
+// if (eData[attributeName] !== undefined) {
+// picker.options[key] = eData[attributeName];
+// }
+// });
},
place = function () {
var position = 'absolute',
offset = picker.component ? picker.component.offset() : picker.element.offset(),
@@ -340,52 +342,52 @@
right: offset.right
});
},
notifyChange = function (oldDate, eventType) {
- if (pMoment(picker.date).isSame(pMoment(oldDate))) {
+ if (moment(picker.date).isSame(moment(oldDate))) {
return;
}
picker.element.trigger({
type: 'dp.change',
- date: pMoment(picker.date),
- oldDate: pMoment(oldDate)
+ date: moment(picker.date),
+ oldDate: moment(oldDate)
});
if (eventType !== 'change') {
picker.element.change();
}
},
notifyError = function (date) {
picker.element.trigger({
type: 'dp.error',
- date: pMoment(date, picker.format, picker.options.useStrict)
+ date: moment(date, picker.format, picker.options.useStrict)
});
},
update = function (newDate) {
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
var dateStr = newDate;
if (!dateStr) {
dateStr = getPickerInput().val();
if (dateStr) {
- picker.date = pMoment(dateStr, picker.format, picker.options.useStrict);
+ picker.date = moment(dateStr, picker.format, picker.options.useStrict);
}
if (!picker.date) {
- picker.date = pMoment();
+ picker.date = moment();
}
}
- picker.viewDate = pMoment(picker.date).startOf('month');
+ picker.viewDate = moment(picker.date).startOf('month');
fillDate();
fillTime();
},
fillDow = function () {
- pMoment.locale(picker.options.language);
- var html = $('<tr>'), weekdaysMin = pMoment.weekdaysMin(), i;
- if (pMoment().localeData()._week.dow === 0) { // starts on Sunday
+ moment.locale(picker.options.language);
+ var html = $('<tr>'), weekdaysMin = moment.weekdaysMin(), i;
+ if (moment().localeData()._week.dow === 0) { // starts on Sunday
for (i = 0; i < 7; i++) {
html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
}
} else {
for (i = 1; i < 8; i++) {
@@ -398,69 +400,69 @@
}
picker.widget.find('.datepicker-days thead').append(html);
},
fillMonths = function () {
- pMoment.locale(picker.options.language);
- var html = '', i, monthsShort = pMoment.monthsShort();
+ moment.locale(picker.options.language);
+ var html = '', i, monthsShort = moment.monthsShort();
for (i = 0; i < 12; i++) {
html += '<span class="month">' + monthsShort[i] + '</span>';
}
picker.widget.find('.datepicker-months td').append(html);
},
fillDate = function () {
if (!picker.options.pickDate) {
return;
}
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
var year = picker.viewDate.year(),
month = picker.viewDate.month(),
startYear = picker.options.minDate.year(),
startMonth = picker.options.minDate.month(),
endYear = picker.options.maxDate.year(),
endMonth = picker.options.maxDate.month(),
currentDate,
- prevMonth, nextMonth, html = [], row, clsName, i, days, yearCont, currentYear, months = pMoment.months();
+ prevMonth, nextMonth, html = [], row, clsName, i, days, yearCont, currentYear, months = moment.months();
picker.widget.find('.datepicker-days').find('.disabled').removeClass('disabled');
picker.widget.find('.datepicker-months').find('.disabled').removeClass('disabled');
picker.widget.find('.datepicker-years').find('.disabled').removeClass('disabled');
picker.widget.find('.datepicker-days th:eq(1)').text(
months[month] + ' ' + year);
- prevMonth = pMoment(picker.viewDate, picker.format, picker.options.useStrict).subtract(1, 'months');
+ prevMonth = moment(picker.viewDate, picker.format, picker.options.useStrict).subtract(1, 'months');
days = prevMonth.daysInMonth();
prevMonth.date(days).startOf('week');
if ((year === startYear && month <= startMonth) || year < startYear) {
picker.widget.find('.datepicker-days th:eq(0)').addClass('disabled');
}
if ((year === endYear && month >= endMonth) || year > endYear) {
picker.widget.find('.datepicker-days th:eq(2)').addClass('disabled');
}
- nextMonth = pMoment(prevMonth).add(42, 'd');
+ nextMonth = moment(prevMonth).add(42, 'd');
while (prevMonth.isBefore(nextMonth)) {
- if (prevMonth.weekday() === pMoment().startOf('week').weekday()) {
+ if (prevMonth.weekday() === moment().startOf('week').weekday()) {
row = $('<tr>');
html.push(row);
}
clsName = '';
if (prevMonth.year() < year || (prevMonth.year() === year && prevMonth.month() < month)) {
clsName += ' old';
} else if (prevMonth.year() > year || (prevMonth.year() === year && prevMonth.month() > month)) {
clsName += ' new';
}
- if (prevMonth.isSame(pMoment({y: picker.date.year(), M: picker.date.month(), d: picker.date.date()}))) {
+ if (prevMonth.isSame(moment({y: picker.date.year(), M: picker.date.month(), d: picker.date.date()}))) {
clsName += ' active';
}
if (isInDisableDates(prevMonth, 'day') || !isInEnableDates(prevMonth)) {
clsName += ' disabled';
}
if (picker.options.showToday === true) {
- if (prevMonth.isSame(pMoment(), 'day')) {
+ if (prevMonth.isSame(moment(), 'day')) {
clsName += ' today';
}
}
if (picker.options.daysOfWeekDisabled) {
for (i = 0; i < picker.options.daysOfWeekDisabled.length; i++) {
@@ -483,14 +485,14 @@
currentYear = picker.date.year();
months = picker.widget.find('.datepicker-months').find('th:eq(1)').text(year).end().find('span').removeClass('active');
if (currentYear === year) {
months.eq(picker.date.month()).addClass('active');
}
- if (currentYear - 1 < startYear) {
+ if (year - 1 < startYear) {
picker.widget.find('.datepicker-months th:eq(0)').addClass('disabled');
}
- if (currentYear + 1 > endYear) {
+ if (year + 1 > endYear) {
picker.widget.find('.datepicker-months th:eq(2)').addClass('disabled');
}
for (i = 0; i < 12; i++) {
if ((year === startYear && startMonth > i) || (year < startYear)) {
$(months[i]).addClass('disabled');
@@ -500,11 +502,11 @@
}
html = '';
year = parseInt(year / 10, 10) * 10;
yearCont = picker.widget.find('.datepicker-years').find(
- 'th:eq(1)').text(year + '-' + (year + 9)).end().find('td');
+ 'th:eq(1)').text(year + '-' + (year + 9)).parents('table').find('td');
picker.widget.find('.datepicker-years').find('th').removeClass('disabled');
if (startYear > year) {
picker.widget.find('.datepicker-years').find('th:eq(0)').addClass('disabled');
}
if (endYear < year + 9) {
@@ -517,11 +519,11 @@
}
yearCont.html(html);
},
fillHours = function () {
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
var table = picker.widget.find('.timepicker .timepicker-hours table'), html = '', current, i, j;
table.parent().hide();
if (picker.use24hours) {
current = 0;
for (i = 0; i < 6; i += 1) {
@@ -604,17 +606,17 @@
click = function (e) {
e.stopPropagation();
e.preventDefault();
picker.unset = false;
- var target = $(e.target).closest('span, td, th'), month, year, step, day, oldDate = pMoment(picker.date);
+ var target = $(e.target).closest('span, td, th'), month, year, step, day, oldDate = moment(picker.date);
if (target.length === 1) {
if (!target.is('.disabled')) {
switch (target[0].nodeName.toLowerCase()) {
case 'th':
switch (target[0].className) {
- case 'switch':
+ case 'picker-switch':
showMode(1);
break;
case 'prev':
case 'next':
step = dpGlobal.modes[picker.viewMode].navStep;
@@ -633,20 +635,20 @@
} else {
year = parseInt(target.text(), 10) || 0;
picker.viewDate.year(year);
}
if (picker.viewMode === picker.minViewMode) {
- picker.date = pMoment({
+ picker.date = moment({
y: picker.viewDate.year(),
M: picker.viewDate.month(),
d: picker.viewDate.date(),
h: picker.date.hours(),
m: picker.date.minutes(),
s: picker.date.seconds()
});
- notifyChange(oldDate, e.type);
set();
+ notifyChange(oldDate, e.type);
}
showMode(-1);
fillDate();
break;
case 'td':
@@ -667,20 +669,20 @@
year += 1;
} else {
month += 1;
}
}
- picker.date = pMoment({
+ picker.date = moment({
y: year,
M: month,
d: day,
h: picker.date.hours(),
m: picker.date.minutes(),
s: picker.date.seconds()
}
);
- picker.viewDate = pMoment({
+ picker.viewDate = moment({
y: year, M: month, d: Math.min(28, day)
});
fillDate();
set();
notifyChange(oldDate, e.type);
@@ -746,12 +748,20 @@
picker.widget.find('.timepicker .timepicker-seconds').show();
},
selectHour: function (e) {
var hour = parseInt($(e.target).text(), 10);
- if (picker.date.hours() > 12) {
- hour += 12;
+ if (!picker.use24hours) {
+ if (picker.date.hours() >= 12) {
+ if (hour !== 12) {
+ hour += 12;
+ }
+ } else {
+ if (hour === 12) {
+ hour = 0;
+ }
+ }
}
picker.date.hours(hour);
actions.showPicker.call(picker);
},
@@ -765,16 +775,16 @@
actions.showPicker.call(picker);
}
},
doAction = function (e) {
- var oldDate = pMoment(picker.date),
+ var oldDate = moment(picker.date),
action = $(e.currentTarget).data('action'),
rv = actions[action].apply(picker, arguments);
stopEvent(e);
if (!picker.date) {
- picker.date = pMoment({y: 1970});
+ picker.date = moment({y: 1970});
}
set();
fillTime();
notifyChange(oldDate, e.type);
return rv;
@@ -790,12 +800,12 @@
picker.hide();
}
},
change = function (e) {
- pMoment.locale(picker.options.language);
- var input = $(e.target), oldDate = pMoment(picker.date), newDate = pMoment(input.val(), picker.format, picker.options.useStrict);
+ moment.locale(picker.options.language);
+ var input = $(e.target), oldDate = moment(picker.date), newDate = moment(input.val(), picker.format, picker.options.useStrict);
if (newDate.isValid() && !isInDisableDates(newDate) && isInEnableDates(newDate)) {
update();
picker.setValue(newDate);
notifyChange(oldDate, e.type);
set();
@@ -835,26 +845,30 @@
return;
}
expanded.collapse('hide');
closed.collapse('show');
$this.find('span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
- picker.element.find('[class^="input-group-"] span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
+ if (picker.component) {
+ picker.component.find('span').toggleClass(picker.options.icons.time + ' ' + picker.options.icons.date);
+ }
}
});
}
if (picker.isInput) {
picker.element.on({
+ 'click': $.proxy(picker.show, this),
'focus': $.proxy(picker.show, this),
'change': $.proxy(change, this),
'blur': $.proxy(picker.hide, this)
});
} else {
picker.element.on({
'change': $.proxy(change, this)
}, 'input');
if (picker.component) {
picker.component.on('click', $.proxy(picker.show, this));
+ picker.component.on('mousedown', $.proxy(stopEvent, this));
} else {
picker.element.on('click', $.proxy(picker.show, this));
}
}
},
@@ -876,18 +890,21 @@
picker.widget.off('click.togglePicker');
}
if (picker.isInput) {
picker.element.off({
'focus': picker.show,
- 'change': picker.change
+ 'change': picker.change,
+ 'click': picker.show,
+ 'blur' : picker.hide
});
} else {
picker.element.off({
'change': picker.change
}, 'input');
if (picker.component) {
picker.component.off('click', picker.show);
+ picker.component.off('mousedown', picker.stopEvent);
} else {
picker.element.off('click', picker.show);
}
}
},
@@ -913,36 +930,36 @@
return false;
}
},
set = function () {
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
var formatted = '';
if (!picker.unset) {
- formatted = pMoment(picker.date).format(picker.format);
+ formatted = moment(picker.date).format(picker.format);
}
getPickerInput().val(formatted);
picker.element.data('date', formatted);
if (!picker.options.pickTime) {
picker.hide();
}
},
checkDate = function (direction, unit, amount) {
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
var newDate;
if (direction === 'add') {
- newDate = pMoment(picker.date);
+ newDate = moment(picker.date);
if (newDate.hours() === 23) {
newDate.add(amount, unit);
}
newDate.add(amount, unit);
}
else {
- newDate = pMoment(picker.date).subtract(amount, unit);
+ newDate = moment(picker.date).subtract(amount, unit);
}
- if (isInDisableDates(pMoment(newDate.subtract(amount, unit))) || isInDisableDates(newDate)) {
+ if (isInDisableDates(moment(newDate.subtract(amount, unit))) || isInDisableDates(newDate)) {
notifyError(newDate.format(picker.format));
return;
}
if (direction === 'add') {
@@ -953,13 +970,13 @@
}
picker.unset = false;
},
isInDisableDates = function (date, timeUnit) {
- pMoment.locale(picker.options.language);
- var maxDate = pMoment(picker.options.maxDate, picker.format, picker.options.useStrict),
- minDate = pMoment(picker.options.minDate, picker.format, picker.options.useStrict);
+ moment.locale(picker.options.language);
+ var maxDate = moment(picker.options.maxDate, picker.format, picker.options.useStrict),
+ minDate = moment(picker.options.minDate, picker.format, picker.options.useStrict);
if (timeUnit) {
maxDate = maxDate.endOf(timeUnit);
minDate = minDate.startOf(timeUnit);
}
@@ -971,11 +988,11 @@
return false;
}
return picker.options.disabledDates[date.format('YYYY-MM-DD')] === true;
},
isInEnableDates = function (date) {
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
if (picker.options.enabledDates === false) {
return true;
}
return picker.options.enabledDates[date.format('YYYY-MM-DD')] === true;
},
@@ -984,14 +1001,14 @@
// Store given enabledDates and disabledDates as keys.
// This way we can check their existence in O(1) time instead of looping through whole array.
// (for example: picker.options.enabledDates['2014-02-27'] === true)
var givenDatesIndexed = {}, givenDatesCount = 0, i;
for (i = 0; i < givenDatesArray.length; i++) {
- if (pMoment.isMoment(givenDatesArray[i]) || givenDatesArray[i] instanceof Date) {
- dDate = pMoment(givenDatesArray[i]);
+ if (moment.isMoment(givenDatesArray[i]) || givenDatesArray[i] instanceof Date) {
+ dDate = moment(givenDatesArray[i]);
} else {
- dDate = pMoment(givenDatesArray[i], picker.format, picker.options.useStrict);
+ dDate = moment(givenDatesArray[i], picker.format, picker.options.useStrict);
}
if (dDate.isValid()) {
givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
givenDatesCount++;
}
@@ -1011,11 +1028,11 @@
},
getTemplate = function () {
if (picker.options.pickDate && picker.options.pickTime) {
var ret = '';
- ret = '<div class="bootstrap-datetimepicker-widget' + (picker.options.sideBySide ? ' timepicker-sbs' : '') + ' dropdown-menu" style="z-index:9999 !important;">';
+ ret = '<div class="bootstrap-datetimepicker-widget' + (picker.options.sideBySide ? ' timepicker-sbs' : '') + (picker.use24hours ? ' usetwentyfour' : '') + ' dropdown-menu" style="z-index:9999 !important;">';
if (picker.options.sideBySide) {
ret += '<div class="row">' +
'<div class="col-sm-6 datepicker">' + dpGlobal.template + '</div>' +
'<div class="col-sm-6 timepicker">' + tpGlobal.getTemplate() + '</div>' +
'</div>';
@@ -1066,11 +1083,11 @@
}
],
headTemplate:
'<thead>' +
'<tr>' +
- '<th class="prev">‹</th><th colspan="5" class="switch"></th><th class="next">›</th>' +
+ '<th class="prev">‹</th><th colspan="5" class="picker-switch"></th><th class="next">›</th>' +
'</tr>' +
'</thead>',
contTemplate:
'<tbody><tr><td colspan="7"></td></tr></tbody>'
},
@@ -1146,20 +1163,24 @@
picker.show = function (e) {
if (picker.options.useCurrent) {
if (getPickerInput().val() === '') {
if (picker.options.minuteStepping !== 1) {
- var mDate = pMoment(),
+ var mDate = moment(),
rInterval = picker.options.minuteStepping;
mDate.minutes((Math.round(mDate.minutes() / rInterval) * rInterval) % 60).seconds(0);
picker.setValue(mDate.format(picker.format));
} else {
- picker.setValue(pMoment().format(picker.format));
+ picker.setValue(moment().format(picker.format));
}
notifyChange('', e.type);
}
}
+ // if this is a click event on the input field and picker is already open don't hide it
+ if (e && e.type === 'click' && picker.isInput && picker.widget.hasClass('picker-open')) {
+ return;
+ }
if (picker.widget.hasClass('picker-open')) {
picker.widget.hide();
picker.widget.removeClass('picker-open');
}
else {
@@ -1168,11 +1189,11 @@
}
picker.height = picker.component ? picker.component.outerHeight() : picker.element.outerHeight();
place();
picker.element.trigger({
type: 'dp.show',
- date: pMoment(picker.date)
+ date: moment(picker.date)
});
attachDatePickerGlobalEvents();
if (e) {
stopEvent(e);
}
@@ -1194,14 +1215,11 @@
}
input.prop('disabled', false);
attachDatePickerEvents();
};
- picker.hide = function (event) {
- if (event && $(event.target).is('#' + picker.element.attr('id'))) {
- return;
- }
+ picker.hide = function () {
// Ignore event if in the middle of a picker transition
var collapse = picker.widget.find('.collapse'), i, collapseData;
for (i = 0; i < collapse.length; i++) {
collapseData = collapse.eq(i).data('collapse');
if (collapseData && collapseData.transitioning) {
@@ -1212,30 +1230,32 @@
picker.widget.removeClass('picker-open');
picker.viewMode = picker.startViewMode;
showMode();
picker.element.trigger({
type: 'dp.hide',
- date: pMoment(picker.date)
+ date: moment(picker.date)
});
detachDatePickerGlobalEvents();
};
picker.setValue = function (newDate) {
- pMoment.locale(picker.options.language);
+ moment.locale(picker.options.language);
if (!newDate) {
picker.unset = true;
set();
} else {
picker.unset = false;
}
- if (!pMoment.isMoment(newDate)) {
- newDate = (newDate instanceof Date) ? pMoment(newDate) : pMoment(newDate, picker.format, picker.options.useStrict);
+ if (!moment.isMoment(newDate)) {
+ newDate = (newDate instanceof Date) ? moment(newDate) : moment(newDate, picker.format, picker.options.useStrict);
+ } else {
+ newDate = newDate.locale(picker.options.language);
}
if (newDate.isValid()) {
picker.date = newDate;
set();
- picker.viewDate = pMoment({y: picker.date.year(), M: picker.date.month()});
+ picker.viewDate = moment({y: picker.date.year(), M: picker.date.month()});
fillDate();
fillTime();
}
else {
notifyError(newDate);
@@ -1244,15 +1264,15 @@
picker.getDate = function () {
if (picker.unset) {
return null;
}
- return pMoment(picker.date);
+ return moment(picker.date);
};
picker.setDate = function (date) {
- var oldDate = pMoment(picker.date);
+ var oldDate = moment(picker.date);
if (!date) {
picker.setValue(null);
} else {
picker.setValue(date);
}
@@ -1275,28 +1295,28 @@
picker.setMaxDate = function (date) {
if (date === undefined) {
return;
}
- if (pMoment.isMoment(date) || date instanceof Date) {
- picker.options.maxDate = pMoment(date);
+ if (moment.isMoment(date) || date instanceof Date) {
+ picker.options.maxDate = moment(date);
} else {
- picker.options.maxDate = pMoment(date, picker.format, picker.options.useStrict);
+ picker.options.maxDate = moment(date, picker.format, picker.options.useStrict);
}
if (picker.viewDate) {
update();
}
};
picker.setMinDate = function (date) {
if (date === undefined) {
return;
}
- if (pMoment.isMoment(date) || date instanceof Date) {
- picker.options.minDate = pMoment(date);
+ if (moment.isMoment(date) || date instanceof Date) {
+ picker.options.minDate = moment(date);
} else {
- picker.options.minDate = pMoment(date, picker.format, picker.options.useStrict);
+ picker.options.minDate = moment(date, picker.format, picker.options.useStrict);
}
if (picker.viewDate) {
update();
}
};
@@ -1304,35 +1324,37 @@
init();
};
$.fn.datetimepicker = function (options) {
return this.each(function () {
- var $this = $(this), data = $this.data('DateTimePicker');
+ var $this = $(this),
+ data = $this.data('DateTimePicker');
if (!data) {
$this.data('DateTimePicker', new DateTimePicker(this, options));
}
});
};
$.fn.datetimepicker.defaults = {
+ format: false,
pickDate: true,
pickTime: true,
useMinutes: true,
useSeconds: false,
useCurrent: true,
minuteStepping: 1,
- minDate: pMoment({y: 1900}),
- maxDate: pMoment().add(100, 'y'),
+ minDate: moment({y: 1900}),
+ maxDate: moment().add(100, 'y'),
showToday: true,
collapse: true,
- language: 'en',
+ language: moment.locale(),
defaultDate: '',
disabledDates: false,
enabledDates: false,
icons: {},
useStrict: false,
direction: 'auto',
sideBySide: false,
- daysOfWeekDisabled: false,
+ daysOfWeekDisabled: [],
widgetParent: false
};
}));