diff --git a/addons/web/static/lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css b/addons/web/static/lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css
deleted file mode 100644
index 69ca89a2e5e..00000000000
--- a/addons/web/static/lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css
+++ /dev/null
@@ -1,234 +0,0 @@
-/*!
- * Datetimepicker for Bootstrap v3
-//! version : 3.0.3
- * https://github.com/Eonasdan/bootstrap-datetimepicker/
- */
-.bootstrap-datetimepicker-widget {
- top: 0;
- left: 0;
- width: 250px;
- padding: 4px;
- margin-top: 1px;
- z-index: 99999 !important;
- border-radius: 4px;
-}
-.bootstrap-datetimepicker-widget.timepicker-sbs {
- width: 600px;
-}
-.bootstrap-datetimepicker-widget.bottom:before {
- content: '';
- display: inline-block;
- border-left: 7px solid transparent;
- border-right: 7px solid transparent;
- border-bottom: 7px solid #ccc;
- border-bottom-color: rgba(0, 0, 0, 0.2);
- position: absolute;
- top: -7px;
- left: 7px;
-}
-.bootstrap-datetimepicker-widget.bottom:after {
- content: '';
- display: inline-block;
- border-left: 6px solid transparent;
- border-right: 6px solid transparent;
- border-bottom: 6px solid white;
- position: absolute;
- top: -6px;
- left: 8px;
-}
-.bootstrap-datetimepicker-widget.top:before {
- content: '';
- display: inline-block;
- border-left: 7px solid transparent;
- border-right: 7px solid transparent;
- border-top: 7px solid #ccc;
- border-top-color: rgba(0, 0, 0, 0.2);
- position: absolute;
- bottom: -7px;
- left: 6px;
-}
-.bootstrap-datetimepicker-widget.top:after {
- content: '';
- display: inline-block;
- border-left: 6px solid transparent;
- border-right: 6px solid transparent;
- border-top: 6px solid white;
- position: absolute;
- bottom: -6px;
- left: 7px;
-}
-.bootstrap-datetimepicker-widget .dow {
- width: 14.2857%;
-}
-.bootstrap-datetimepicker-widget.pull-right:before {
- left: auto;
- right: 6px;
-}
-.bootstrap-datetimepicker-widget.pull-right:after {
- left: auto;
- right: 7px;
-}
-.bootstrap-datetimepicker-widget > ul {
- list-style-type: none;
- margin: 0;
-}
-.bootstrap-datetimepicker-widget a[data-action] {
- padding: 6px 0;
-}
-.bootstrap-datetimepicker-widget .timepicker-hour,
-.bootstrap-datetimepicker-widget .timepicker-minute,
-.bootstrap-datetimepicker-widget .timepicker-second {
- width: 54px;
- font-weight: bold;
- font-size: 1.2em;
- margin: 0;
-}
-.bootstrap-datetimepicker-widget button[data-action] {
- padding: 6px;
-}
-.bootstrap-datetimepicker-widget table[data-hour-format="12"] .separator {
- width: 4px;
- padding: 0;
- margin: 0;
-}
-.bootstrap-datetimepicker-widget .datepicker > div {
- display: none;
-}
-.bootstrap-datetimepicker-widget .picker-switch {
- text-align: center;
-}
-.bootstrap-datetimepicker-widget table {
- width: 100%;
- margin: 0;
-}
-.bootstrap-datetimepicker-widget td,
-.bootstrap-datetimepicker-widget th {
- text-align: center;
- border-radius: 4px;
-}
-.bootstrap-datetimepicker-widget td {
- height: 54px;
- line-height: 54px;
- width: 54px;
-}
-.bootstrap-datetimepicker-widget td.cw {
- font-size: 10px;
- height: 20px;
- line-height: 20px;
-}
-.bootstrap-datetimepicker-widget td.day {
- height: 20px;
- line-height: 20px;
- width: 20px;
-}
-.bootstrap-datetimepicker-widget td.day:hover,
-.bootstrap-datetimepicker-widget td.hour:hover,
-.bootstrap-datetimepicker-widget td.minute:hover,
-.bootstrap-datetimepicker-widget td.second:hover {
- background: #eeeeee;
- cursor: pointer;
-}
-.bootstrap-datetimepicker-widget td.old,
-.bootstrap-datetimepicker-widget td.new {
- color: #777777;
-}
-.bootstrap-datetimepicker-widget td.today {
- position: relative;
-}
-.bootstrap-datetimepicker-widget td.today:before {
- content: '';
- display: inline-block;
- border-left: 7px solid transparent;
- border-bottom: 7px solid #428bca;
- border-top-color: rgba(0, 0, 0, 0.2);
- position: absolute;
- bottom: 4px;
- right: 4px;
-}
-.bootstrap-datetimepicker-widget td.active,
-.bootstrap-datetimepicker-widget td.active:hover {
- background-color: #428bca;
- color: #fff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
-}
-.bootstrap-datetimepicker-widget td.active.today:before {
- border-bottom-color: #fff;
-}
-.bootstrap-datetimepicker-widget td.disabled,
-.bootstrap-datetimepicker-widget td.disabled:hover {
- background: none;
- color: #777777;
- cursor: not-allowed;
-}
-.bootstrap-datetimepicker-widget td span {
- display: inline-block;
- width: 54px;
- height: 54px;
- line-height: 54px;
- margin: 2px 1.5px;
- cursor: pointer;
- border-radius: 4px;
-}
-.bootstrap-datetimepicker-widget td span:hover {
- background: #eeeeee;
-}
-.bootstrap-datetimepicker-widget td span.active {
- background-color: #428bca;
- color: #fff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
-}
-.bootstrap-datetimepicker-widget td span.old {
- color: #777777;
-}
-.bootstrap-datetimepicker-widget td span.disabled,
-.bootstrap-datetimepicker-widget td span.disabled:hover {
- background: none;
- color: #777777;
- cursor: not-allowed;
-}
-.bootstrap-datetimepicker-widget th {
- height: 20px;
- line-height: 20px;
- width: 20px;
-}
-.bootstrap-datetimepicker-widget th.picker-switch {
- width: 145px;
-}
-.bootstrap-datetimepicker-widget th.next,
-.bootstrap-datetimepicker-widget th.prev {
- font-size: 21px;
-}
-.bootstrap-datetimepicker-widget th.disabled,
-.bootstrap-datetimepicker-widget th.disabled:hover {
- background: none;
- color: #777777;
- cursor: not-allowed;
-}
-.bootstrap-datetimepicker-widget thead tr:first-child th {
- cursor: pointer;
-}
-.bootstrap-datetimepicker-widget thead tr:first-child th:hover {
- background: #eeeeee;
-}
-.input-group.date .input-group-addon span {
- display: block;
- cursor: pointer;
- width: 16px;
- height: 16px;
-}
-.bootstrap-datetimepicker-widget.left-oriented:before {
- left: auto;
- right: 6px;
-}
-.bootstrap-datetimepicker-widget.left-oriented:after {
- left: auto;
- right: 7px;
-}
-.bootstrap-datetimepicker-widget ul.list-unstyled li div.timepicker div.timepicker-picker table.table-condensed tbody > tr > td {
- padding: 0px !important;
-}
-@media screen and (max-width: 767px) {
- .bootstrap-datetimepicker-widget.timepicker-sbs {
- width: 283px;
- }
-}
diff --git a/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js b/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js
index 8619c44a7d6..807bdff70dd 100644
--- a/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js
+++ b/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js
@@ -1,1370 +1,2636 @@
+/*! version : 4.17.42
+ =========================================================
+ bootstrap-datetimejs
+ https://github.com/Eonasdan/bootstrap-datetimepicker
+ Copyright (c) 2015 Jonathan Peterson
+ =========================================================
+ */
/*
-//! version : 3.0.3
-=========================================================
-bootstrap-datetimepicker.js
-https://github.com/Eonasdan/bootstrap-datetimepicker
-=========================================================
-The MIT License (MIT)
+ The MIT License (MIT)
-Copyright (c) 2014 Jonathan Peterson
+ Copyright (c) 2015 Jonathan Peterson
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-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 (root, factory) {
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ 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.
+ */
+/*global define:false */
+/*global exports:false */
+/*global require:false */
+/*global jQuery:false */
+/*global moment:false */
+(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD is used - Register as an anonymous module.
define(['jquery', 'moment'], factory);
+ } else if (typeof exports === 'object') {
+ module.exports = factory(require('jquery'), require('moment'));
} else {
- // AMD is not used - Attempt to fetch dependencies from scope.
- if (!jQuery) {
- throw new Error('bootstrap-datetimepicker requires jQuery to be loaded first');
+ // Neither AMD nor CommonJS used. Use global variables.
+ if (typeof jQuery === 'undefined') {
+ throw 'bootstrap-datetimepicker requires jQuery to be loaded first';
}
- if (!moment) {
- throw new Error('bootstrap-datetimepicker requires moment.js to be loaded first');
+ if (typeof moment === 'undefined') {
+ throw 'bootstrap-datetimepicker requires Moment.js to be loaded first';
}
- factory(root.jQuery, moment);
+ factory(jQuery, moment);
}
-}(this, function ($, moment) {
+}(function ($, moment) {
'use strict';
- if (typeof moment === 'undefined') {
- throw new Error('momentjs is required');
+ if (!moment) {
+ throw new Error('bootstrap-datetimepicker requires Moment.js to be loaded first');
}
- var dpgId = 0,
+ var dateTimePicker = function (element, options) {
+ var picker = {},
+ date,
+ viewDate,
+ unset = true,
+ input,
+ component = false,
+ widget = false,
+ use24Hours,
+ minViewModeNumber = 0,
+ actualFormat,
+ parseFormats,
+ currentViewMode,
+ datePickerModes = [
+ {
+ clsName: 'days',
+ navFnc: 'M',
+ navStep: 1
+ },
+ {
+ clsName: 'months',
+ navFnc: 'y',
+ navStep: 1
+ },
+ {
+ clsName: 'years',
+ navFnc: 'y',
+ navStep: 10
+ },
+ {
+ clsName: 'decades',
+ navFnc: 'y',
+ navStep: 100
+ }
+ ],
+ viewModes = ['days', 'months', 'years', 'decades'],
+ verticalModes = ['top', 'bottom', 'auto'],
+ horizontalModes = ['left', 'right', 'auto'],
+ toolbarPlacements = ['default', 'top', 'bottom'],
+ keyMap = {
+ 'up': 38,
+ 38: 'up',
+ 'down': 40,
+ 40: 'down',
+ 'left': 37,
+ 37: 'left',
+ 'right': 39,
+ 39: 'right',
+ 'tab': 9,
+ 9: 'tab',
+ 'escape': 27,
+ 27: 'escape',
+ 'enter': 13,
+ 13: 'enter',
+ 'pageUp': 33,
+ 33: 'pageUp',
+ 'pageDown': 34,
+ 34: 'pageDown',
+ 'shift': 16,
+ 16: 'shift',
+ 'control': 17,
+ 17: 'control',
+ 'space': 32,
+ 32: 'space',
+ 't': 84,
+ 84: 't',
+ 'delete': 46,
+ 46: 'delete'
+ },
+ keyState = {},
- DateTimePicker = function (element, options) {
- var defaults = $.fn.datetimepicker.defaults,
+ /********************************************************************************
+ *
+ * Private functions
+ *
+ ********************************************************************************/
- icons = {
- time: 'glyphicon glyphicon-time',
- date: 'glyphicon glyphicon-calendar',
- up: 'glyphicon glyphicon-chevron-up',
- down: 'glyphicon glyphicon-chevron-down'
+ hasTimeZone = function () {
+ return moment.tz !== undefined && options.timeZone !== undefined && options.timeZone !== null && options.timeZone !== '';
},
- picker = this,
+ getMoment = function (d) {
+ var returnMoment;
- dDate,
-
- init = function () {
- var icon = false, localeData, rInterval;
- picker.options = $.extend({}, defaults, options);
- picker.options.icons = $.extend({}, icons, picker.options.icons);
-
- picker.element = $(element);
-
- dataToOptions();
-
- if (!(picker.options.pickTime || picker.options.pickDate)) {
- throw new Error('Must choose at least one picker');
- }
-
- picker.id = dpgId++;
- 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')) {
- if (picker.element.find('.datepickerbutton').size() === 0) {//in case there is more then one 'input-group-addon' Issue #48
- picker.component = picker.element.find('[class^="input-group-"]');
- }
- else {
- picker.component = picker.element.find('.datepickerbutton');
- }
- }
- picker.format = picker.options.format;
-
- localeData = moment().localeData();
-
- if (!picker.format) {
- picker.format = (picker.options.pickDate ? localeData.longDateFormat('L') : '');
- if (picker.options.pickDate && picker.options.pickTime) {
- picker.format += ' ';
- }
- picker.format += (picker.options.pickTime ? localeData.longDateFormat('LT') : '');
- if (picker.options.useSeconds) {
- if (localeData.longDateFormat('LT').indexOf(' A') !== -1) {
- picker.format = picker.format.split(' A')[0] + ':ss A';
- }
- else {
- picker.format += ':ss';
- }
- }
- }
- picker.use24hours = picker.format.toLowerCase().indexOf('a') < 1;
-
- if (picker.component) {
- icon = picker.component.find('span');
- }
-
- if (picker.options.pickTime) {
- if (icon) {
- icon.addClass(picker.options.icons.time);
- }
- }
- if (picker.options.pickDate) {
- if (icon) {
- icon.removeClass(picker.options.icons.time);
- icon.addClass(picker.options.icons.date);
- }
- }
-
- picker.options.widgetParent =
- typeof picker.options.widgetParent === 'string' && picker.options.widgetParent ||
- picker.element.parents().filter(function () {
- return 'scroll' === $(this).css('overflow-y');
- }).get(0) ||
- 'body';
-
- picker.widget = $(getTemplate()).appendTo(picker.options.widgetParent);
-
- picker.minViewMode = picker.options.minViewMode || 0;
- if (typeof picker.minViewMode === 'string') {
- switch (picker.minViewMode) {
- case 'months':
- picker.minViewMode = 1;
- break;
- case 'years':
- picker.minViewMode = 2;
- break;
- default:
- picker.minViewMode = 0;
- break;
- }
- }
- picker.viewMode = picker.options.viewMode || 0;
- if (typeof picker.viewMode === 'string') {
- switch (picker.viewMode) {
- case 'months':
- picker.viewMode = 1;
- break;
- case 'years':
- picker.viewMode = 2;
- break;
- default:
- 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);
- picker.setMaxDate(picker.options.maxDate);
- fillDow();
- fillMonths();
- fillHours();
- fillMinutes();
- fillSeconds();
- update();
- showMode();
- attachDatePickerEvents();
- if (picker.options.defaultDate !== '' && getPickerInput().val() === '') {
- picker.setValue(picker.options.defaultDate);
- }
- if (picker.options.minuteStepping !== 1) {
- rInterval = picker.options.minuteStepping;
- picker.date.minutes((Math.round(picker.date.minutes() / rInterval) * rInterval) % 60).seconds(0);
- }
- },
-
- getPickerInput = function () {
- var input;
-
- if (picker.isInput) {
- return picker.element;
- }
- input = picker.element.find('.datepickerinput');
- if (input.size() === 0) {
- input = picker.element.find('input');
- }
- else if (!input.is('input')) {
- throw new Error('CSS class "datepickerinput" cannot be applied to non input element');
- }
- return input;
- },
-
- dataToOptions = function () {
- var eData;
- if (picker.element.is('input')) {
- eData = picker.element.data();
- }
- else {
- eData = picker.element.find('input').data();
- }
- if (eData.dateFormat !== undefined) {
- picker.options.format = eData.dateFormat;
- }
- if (eData.datePickdate !== undefined) {
- picker.options.pickDate = eData.datePickdate;
- }
- if (eData.datePicktime !== undefined) {
- picker.options.pickTime = eData.datePicktime;
- }
- if (eData.dateUseminutes !== undefined) {
- picker.options.useMinutes = eData.dateUseminutes;
- }
- if (eData.dateUseseconds !== undefined) {
- 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;
- }
- if (eData.dateMaxdate !== undefined) {
- picker.options.maxDate = eData.dateMaxdate;
- }
- if (eData.dateShowtoday !== undefined) {
- picker.options.showToday = eData.dateShowtoday;
- }
- if (eData.dateCollapse !== undefined) {
- picker.options.collapse = eData.dateCollapse;
- }
- if (eData.dateLanguage !== undefined) {
- picker.options.language = eData.dateLanguage;
- }
- if (eData.dateDefaultdate !== undefined) {
- picker.options.defaultDate = eData.dateDefaultdate;
- }
- if (eData.dateDisableddates !== undefined) {
- picker.options.disabledDates = eData.dateDisableddates;
- }
- if (eData.dateEnableddates !== undefined) {
- picker.options.enabledDates = eData.dateEnableddates;
- }
- if (eData.dateIcons !== undefined) {
- picker.options.icons = eData.dateIcons;
- }
- if (eData.dateUsestrict !== undefined) {
- picker.options.useStrict = eData.dateUsestrict;
- }
- if (eData.dateDirection !== undefined) {
- 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(),
- $window = $(window),
- placePosition;
-
- picker.width = picker.component ? picker.component.outerWidth() : picker.element.outerWidth();
- offset.top = offset.top + picker.element.outerHeight();
-
- if (picker.options.direction === 'up') {
- placePosition = 'top';
- } else if (picker.options.direction === 'bottom') {
- placePosition = 'bottom';
- } else if (picker.options.direction === 'auto') {
- if (offset.top + picker.widget.height() > $window.height() + $window.scrollTop() && picker.widget.height() + picker.element.outerHeight() < offset.top) {
- placePosition = 'top';
+ 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 {
- placePosition = 'bottom';
+ returnMoment = moment(d, parseFormats, options.useStrict);
}
- }
- if (placePosition === 'top') {
- offset.top -= picker.widget.height() + picker.element.outerHeight() + 15;
- picker.widget.addClass('top').removeClass('bottom');
- } else {
- offset.top += 1;
- picker.widget.addClass('bottom').removeClass('top');
- }
- if (picker.options.width !== undefined) {
- picker.widget.width(picker.options.width);
- }
-
- if (picker.options.orientation === 'left') {
- picker.widget.addClass('left-oriented');
- offset.left = offset.left - picker.widget.width() + 20;
- }
-
- if (isInFixed()) {
- position = 'fixed';
- offset.top -= $window.scrollTop();
- offset.left -= $window.scrollLeft();
- }
-
- if ($window.width() < offset.left + picker.widget.outerWidth()) {
- offset.right = $window.width() - offset.left - picker.width;
- offset.left = 'auto';
- picker.widget.addClass('pull-right');
- } else {
- offset.right = 'auto';
- picker.widget.removeClass('pull-right');
- }
-
- 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))) {
- return;
- }
- picker.element.trigger({
- type: 'dp.change',
- date: moment(picker.date),
- oldDate: moment(oldDate)
- });
-
- if (eventType !== 'change') {
- picker.element.change();
- }
- },
-
- notifyError = function (date) {
- picker.element.trigger({
- type: 'dp.error',
- date: moment(date, picker.format, picker.options.useStrict)
- });
- },
-
- update = function (newDate) {
- moment.locale(picker.options.language);
- var dateStr = newDate;
- if (!dateStr) {
- dateStr = getPickerInput().val();
- if (dateStr) {
- picker.date = moment(dateStr, picker.format, picker.options.useStrict);
+ if (hasTimeZone()) {
+ returnMoment.tz(options.timeZone);
}
- if (!picker.date) {
- picker.date = moment();
- }
- }
- picker.viewDate = moment(picker.date).startOf('month');
- fillDate();
- fillTime();
- },
- fillDow = function () {
- moment.locale(picker.options.language);
- var html = $('
'), weekdaysMin = moment.weekdaysMin(), i;
- if (picker.options.calendarWeeks === true) {
- html.append('| # | ');
- }
- if (moment().localeData()._week.dow === 0) { // starts on Sunday
- for (i = 0; i < 7; i++) {
- html.append('' + weekdaysMin[i] + ' | ');
+ return returnMoment;
+ },
+
+ isEnabled = function (granularity) {
+ if (typeof granularity !== 'string' || granularity.length > 1) {
+ throw new TypeError('isEnabled expects a single character string parameter');
}
- } else {
- for (i = 1; i < 8; i++) {
- if (i === 7) {
- html.append('' + weekdaysMin[0] + ' | ');
+ switch (granularity) {
+ case 'y':
+ return actualFormat.indexOf('Y') !== -1;
+ case 'M':
+ return actualFormat.indexOf('M') !== -1;
+ case 'd':
+ return actualFormat.toLowerCase().indexOf('d') !== -1;
+ case 'h':
+ case 'H':
+ return actualFormat.toLowerCase().indexOf('h') !== -1;
+ case 'm':
+ return actualFormat.indexOf('m') !== -1;
+ case 's':
+ return actualFormat.indexOf('s') !== -1;
+ default:
+ return false;
+ }
+ },
+
+ hasTime = function () {
+ return (isEnabled('h') || isEnabled('m') || isEnabled('s'));
+ },
+
+ hasDate = function () {
+ return (isEnabled('y') || isEnabled('M') || isEnabled('d'));
+ },
+
+ getDatePickerTemplate = function () {
+ var headTemplate = $('')
+ .append($('')
+ .append($('| ').addClass('prev').attr('data-action', 'previous')
+ .append($('').addClass(options.icons.previous))
+ )
+ .append($(' | ').addClass('picker-switch').attr('data-action', 'pickerSwitch').attr('colspan', (options.calendarWeeks ? '6' : '5')))
+ .append($(' | ').addClass('next').attr('data-action', 'next')
+ .append($('').addClass(options.icons.next))
+ )
+ ),
+ contTemplate = $('')
+ .append($('')
+ .append($('').attr('colspan', (options.calendarWeeks ? '8' : '7')))
+ );
+
+ return [
+ $('').addClass('datepicker-days')
+ .append($(' ').addClass('table-condensed')
+ .append(headTemplate)
+ .append($(''))
+ ),
+ $('').addClass('datepicker-months')
+ .append($(' ').addClass('table-condensed')
+ .append(headTemplate.clone())
+ .append(contTemplate.clone())
+ ),
+ $('').addClass('datepicker-years')
+ .append($(' ').addClass('table-condensed')
+ .append(headTemplate.clone())
+ .append(contTemplate.clone())
+ ),
+ $('').addClass('datepicker-decades')
+ .append($(' ').addClass('table-condensed')
+ .append(headTemplate.clone())
+ .append(contTemplate.clone())
+ )
+ ];
+ },
+
+ getTimePickerMainTemplate = function () {
+ var topRow = $(''),
+ middleRow = $(' '),
+ bottomRow = $(' ');
+
+ if (isEnabled('h')) {
+ topRow.append($('| ')
+ .append($('').attr({ href: '#', tabindex: '-1', 'title': options.tooltips.incrementHour }).addClass('btn').attr('data-action', 'incrementHours').append($('').addClass(options.icons.up))));
+ middleRow.append($(' | ')
+ .append($('').addClass('timepicker-hour').attr({ 'data-time-component': 'hours', 'title': options.tooltips.pickHour }).attr('data-action', 'showHours')));
+ bottomRow.append($(' | ')
+ .append($('').attr({ href: '#', tabindex: '-1', 'title': options.tooltips.decrementHour }).addClass('btn').attr('data-action', 'decrementHours').append($('').addClass(options.icons.down))));
+ }
+ if (isEnabled('m')) {
+ if (isEnabled('h')) {
+ topRow.append($(' | ').addClass('separator'));
+ middleRow.append($(' | ').addClass('separator').html(':'));
+ bottomRow.append($(' | ').addClass('separator'));
+ }
+ topRow.append($(' | ')
+ .append($('').attr({ href: '#', tabindex: '-1', 'title': options.tooltips.incrementMinute }).addClass('btn').attr('data-action', 'incrementMinutes')
+ .append($('').addClass(options.icons.up))));
+ middleRow.append($(' | ')
+ .append($('').addClass('timepicker-minute').attr({ 'data-time-component': 'minutes', 'title': options.tooltips.pickMinute }).attr('data-action', 'showMinutes')));
+ bottomRow.append($(' | ')
+ .append($('').attr({ href: '#', tabindex: '-1', 'title': options.tooltips.decrementMinute }).addClass('btn').attr('data-action', 'decrementMinutes')
+ .append($('').addClass(options.icons.down))));
+ }
+ if (isEnabled('s')) {
+ if (isEnabled('m')) {
+ topRow.append($(' | ').addClass('separator'));
+ middleRow.append($(' | ').addClass('separator').html(':'));
+ bottomRow.append($(' | ').addClass('separator'));
+ }
+ topRow.append($(' | ')
+ .append($('').attr({ href: '#', tabindex: '-1', 'title': options.tooltips.incrementSecond }).addClass('btn').attr('data-action', 'incrementSeconds')
+ .append($('').addClass(options.icons.up))));
+ middleRow.append($(' | ')
+ .append($('').addClass('timepicker-second').attr({ 'data-time-component': 'seconds', 'title': options.tooltips.pickSecond }).attr('data-action', 'showSeconds')));
+ bottomRow.append($(' | ')
+ .append($('').attr({ href: '#', tabindex: '-1', 'title': options.tooltips.decrementSecond }).addClass('btn').attr('data-action', 'decrementSeconds')
+ .append($('').addClass(options.icons.down))));
+ }
+
+ if (!use24Hours) {
+ topRow.append($(' | ').addClass('separator'));
+ middleRow.append($(' | ')
+ .append($(' | | |