vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-3.0.3 vs vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-3.1.1
- old
+ new
@@ -1,7 +1,7 @@
/*
-//! version : 3.0.3
+//! version : 3.1.1
=========================================================
bootstrap-datetimepicker.js
https://github.com/Eonasdan/bootstrap-datetimepicker
=========================================================
The MIT License (MIT)
@@ -58,11 +58,11 @@
up: 'glyphicon glyphicon-chevron-up',
down: 'glyphicon glyphicon-chevron-down'
},
picker = this,
-
+ errored = false,
dDate,
init = function () {
var icon = false, localeData, rInterval;
picker.options = $.extend({}, defaults, options);
@@ -108,11 +108,11 @@
else {
picker.format += ':ss';
}
}
}
- picker.use24hours = picker.format.toLowerCase().indexOf('a') < 1;
+ picker.use24hours = (picker.format.toLowerCase().indexOf('a') < 0 && picker.format.indexOf('h') < 0);
if (picker.component) {
icon = picker.component.find('span');
}
@@ -231,10 +231,13 @@
picker.options.useSeconds = eData.dateUseseconds;
}
if (eData.dateUsecurrent !== undefined) {
picker.options.useCurrent = eData.dateUsecurrent;
}
+ if (eData.calendarWeeks !== undefined) {
+ picker.options.calendarWeeks = eData.calendarWeeks;
+ }
if (eData.dateMinutestepping !== undefined) {
picker.options.minuteStepping = eData.dateMinutestepping;
}
if (eData.dateMindate !== undefined) {
picker.options.minDate = eData.dateMindate;
@@ -302,11 +305,11 @@
} else {
placePosition = 'bottom';
}
}
if (placePosition === 'top') {
- offset.top -= picker.widget.height() + picker.element.outerHeight() + 15;
+ offset.bottom = $window.height() - offset.top + picker.element.outerHeight() + 3;
picker.widget.addClass('top').removeClass('bottom');
} else {
offset.top += 1;
picker.widget.addClass('bottom').removeClass('top');
}
@@ -333,22 +336,33 @@
} else {
offset.right = 'auto';
picker.widget.removeClass('pull-right');
}
- picker.widget.css({
- position: position,
- top: offset.top,
- left: offset.left,
- right: offset.right
- });
+ if (placePosition === 'top') {
+ picker.widget.css({
+ position: position,
+ bottom: offset.bottom,
+ top: 'auto',
+ left: offset.left,
+ right: offset.right
+ });
+ } else {
+ picker.widget.css({
+ position: position,
+ top: offset.top,
+ left: offset.left,
+ right: offset.right
+ });
+ }
},
notifyChange = function (oldDate, eventType) {
- if (moment(picker.date).isSame(moment(oldDate))) {
+ if (moment(picker.date).isSame(moment(oldDate)) && !errored) {
return;
}
+ errored = false;
picker.element.trigger({
type: 'dp.change',
date: moment(picker.date),
oldDate: moment(oldDate)
});
@@ -357,10 +371,11 @@
picker.element.change();
}
},
notifyError = function (date) {
+ errored = true;
picker.element.trigger({
type: 'dp.error',
date: moment(date, picker.format, picker.options.useStrict)
});
},
@@ -383,10 +398,13 @@
},
fillDow = function () {
moment.locale(picker.options.language);
var html = $('<tr>'), weekdaysMin = moment.weekdaysMin(), i;
+ if (picker.options.calendarWeeks === true) {
+ html.append('<th class="cw">#</th>');
+ }
if (moment().localeData()._week.dow === 0) { // starts on Sunday
for (i = 0; i < 7; i++) {
html.append('<th class="dow">' + weekdaysMin[i] + '</th>');
}
} else {
@@ -444,10 +462,13 @@
nextMonth = moment(prevMonth).add(42, 'd');
while (prevMonth.isBefore(nextMonth)) {
if (prevMonth.weekday() === moment().startOf('week').weekday()) {
row = $('<tr>');
html.push(row);
+ if (picker.options.calendarWeeks === true) {
+ row.append('<td class="cw">' + prevMonth.week() + '</td>');
+ }
}
clsName = '';
if (prevMonth.year() < year || (prevMonth.year() === year && prevMonth.month() < month)) {
clsName += ' old';
} else if (prevMonth.year() > year || (prevMonth.year() === year && prevMonth.month() > month)) {
@@ -1026,22 +1047,40 @@
}
return '0' + string;
},
getTemplate = function () {
+ var
+ headTemplate =
+ '<thead>' +
+ '<tr>' +
+ '<th class="prev">‹</th><th colspan="' + (picker.options.calendarWeeks ? '6' : '5') + '" class="picker-switch"></th><th class="next">›</th>' +
+ '</tr>' +
+ '</thead>',
+ contTemplate =
+ '<tbody><tr><td colspan="' + (picker.options.calendarWeeks ? '8' : '7') + '"></td></tr></tbody>',
+ template = '<div class="datepicker-days">' +
+ '<table class="table-condensed">' + headTemplate + '<tbody></tbody></table>' +
+ '</div>' +
+ '<div class="datepicker-months">' +
+ '<table class="table-condensed">' + headTemplate + contTemplate + '</table>' +
+ '</div>' +
+ '<div class="datepicker-years">' +
+ '<table class="table-condensed">' + headTemplate + contTemplate + '</table>' +
+ '</div>',
+ ret = '';
if (picker.options.pickDate && picker.options.pickTime) {
- var ret = '';
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 datepicker">' + template + '</div>' +
'<div class="col-sm-6 timepicker">' + tpGlobal.getTemplate() + '</div>' +
'</div>';
} else {
ret += '<ul class="list-unstyled">' +
'<li' + (picker.options.collapse ? ' class="collapse in"' : '') + '>' +
- '<div class="datepicker">' + dpGlobal.template + '</div>' +
+ '<div class="datepicker">' + template + '</div>' +
'</li>' +
'<li class="picker-switch accordion-toggle"><a class="btn" style="width:100%"><span class="' + picker.options.icons.time + '"></span></a></li>' +
'<li' + (picker.options.collapse ? ' class="collapse"' : '') + '>' +
'<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
'</li>' +
@@ -1057,11 +1096,11 @@
'</div>'
);
}
return (
'<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
- '<div class="datepicker">' + dpGlobal.template + '</div>' +
+ '<div class="datepicker">' + template + '</div>' +
'</div>'
);
},
dpGlobal = {
@@ -1079,38 +1118,19 @@
{
clsName: 'years',
navFnc: 'year',
navStep: 10
}
- ],
- headTemplate:
- '<thead>' +
- '<tr>' +
- '<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>'
+ ]
},
tpGlobal = {
hourTemplate: '<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>',
minuteTemplate: '<span data-action="showMinutes" data-time-component="minutes" class="timepicker-minute"></span>',
secondTemplate: '<span data-action="showSeconds" data-time-component="seconds" class="timepicker-second"></span>'
};
- dpGlobal.template =
- '<div class="datepicker-days">' +
- '<table class="table-condensed">' + dpGlobal.headTemplate + '<tbody></tbody></table>' +
- '</div>' +
- '<div class="datepicker-months">' +
- '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
- '</div>' +
- '<div class="datepicker-years">' +
- '<table class="table-condensed">' + dpGlobal.headTemplate + dpGlobal.contTemplate + '</table>' +
- '</div>';
-
tpGlobal.getTemplate = function () {
return (
'<div class="timepicker-picker">' +
'<table class="table-condensed">' +
'<tr>' +
@@ -1339,9 +1359,10 @@
pickDate: true,
pickTime: true,
useMinutes: true,
useSeconds: false,
useCurrent: true,
+ calendarWeeks: false,
minuteStepping: 1,
minDate: moment({y: 1900}),
maxDate: moment().add(100, 'y'),
showToday: true,
collapse: true,