mirror of https://github.com/dani/vroom.git
Switch to stable 1.4.0 bootstrap-datepicker
This commit is contained in:
parent
c7fc40b2f3
commit
fe5b1766c2
|
@ -1,34 +1,10 @@
|
|||
/* =========================================================
|
||||
* bootstrap-datepicker.js
|
||||
* Repo: https://github.com/eternicode/bootstrap-datepicker/
|
||||
* Demo: http://eternicode.github.io/bootstrap-datepicker/
|
||||
* Docs: http://bootstrap-datepicker.readthedocs.org/
|
||||
* Forked from http://www.eyecon.ro/bootstrap-datepicker
|
||||
* =========================================================
|
||||
* Started by Stefan Petre; improvements by Andrew Rowls + contributors
|
||||
/*!
|
||||
* Datepicker for Bootstrap v1.4.0 (https://github.com/eternicode/bootstrap-datepicker)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================= */
|
||||
|
||||
(function(factory){
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["jquery"], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function($, undefined){
|
||||
* Copyright 2012 Stefan Petre
|
||||
* Improvements by Andrew Rowls
|
||||
* Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
*/(function($, undefined){
|
||||
|
||||
function UTCDate(){
|
||||
return new Date(Date.UTC.apply(Date, arguments));
|
||||
|
@ -139,7 +115,6 @@
|
|||
this.setStartDate(this._o.startDate);
|
||||
this.setEndDate(this._o.endDate);
|
||||
this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
|
||||
this.setDaysOfWeekHighlighted(this.o.daysOfWeekHighlighted);
|
||||
this.setDatesDisabled(this.o.datesDisabled);
|
||||
|
||||
this.fillDow();
|
||||
|
@ -200,20 +175,6 @@
|
|||
o.minViewMode = 0;
|
||||
}
|
||||
|
||||
switch (o.maxViewMode) {
|
||||
case 0:
|
||||
case 'days':
|
||||
o.maxViewMode = 0;
|
||||
break;
|
||||
case 1:
|
||||
case 'months':
|
||||
o.maxViewMode = 1;
|
||||
break;
|
||||
default:
|
||||
o.maxViewMode = 2;
|
||||
}
|
||||
|
||||
o.startView = Math.min(o.startView, o.maxViewMode);
|
||||
o.startView = Math.max(o.startView, o.minViewMode);
|
||||
|
||||
// true, false, or Number > 0
|
||||
|
@ -258,13 +219,6 @@
|
|||
return parseInt(d, 10);
|
||||
});
|
||||
|
||||
o.daysOfWeekHighlighted = o.daysOfWeekHighlighted||[];
|
||||
if (!$.isArray(o.daysOfWeekHighlighted))
|
||||
o.daysOfWeekHighlighted = o.daysOfWeekHighlighted.split(/[,\s]*/);
|
||||
o.daysOfWeekHighlighted = $.map(o.daysOfWeekHighlighted, function(d){
|
||||
return parseInt(d, 10);
|
||||
});
|
||||
|
||||
o.datesDisabled = o.datesDisabled||[];
|
||||
if (!$.isArray(o.datesDisabled)) {
|
||||
var datesDisabled = [];
|
||||
|
@ -352,8 +306,7 @@
|
|||
if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
|
||||
this.update();
|
||||
}, this),
|
||||
keydown: $.proxy(this.keydown, this),
|
||||
paste: $.proxy(this.paste, this)
|
||||
keydown: $.proxy(this.keydown, this)
|
||||
};
|
||||
|
||||
if (this.o.showOnFocus === true) {
|
||||
|
@ -399,15 +352,6 @@
|
|||
}]
|
||||
);
|
||||
|
||||
if (this.o.immediateUpdates) {
|
||||
// Trigger input updates immediately on changed year/month
|
||||
this._events.push([this.element, {
|
||||
'changeYear changeMonth': $.proxy(function(e){
|
||||
this.update(e.date);
|
||||
}, this)
|
||||
}]);
|
||||
}
|
||||
|
||||
this._secondaryEvents = [
|
||||
[this.picker, {
|
||||
click: $.proxy(this.click, this)
|
||||
|
@ -416,17 +360,15 @@
|
|||
resize: $.proxy(this.place, this)
|
||||
}],
|
||||
[$(document), {
|
||||
mousedown: $.proxy(function(e){
|
||||
'mousedown touchstart': $.proxy(function(e){
|
||||
// Clicked outside the datepicker, hide it
|
||||
if (!(
|
||||
this.element.is(e.target) ||
|
||||
this.element.find(e.target).length ||
|
||||
this.picker.is(e.target) ||
|
||||
this.picker.find(e.target).length ||
|
||||
this.picker.hasClass('datepicker-inline')
|
||||
this.picker.find(e.target).length
|
||||
)){
|
||||
$(this.picker).hide();
|
||||
this._trigger('hide');
|
||||
this.hide();
|
||||
}
|
||||
}, this)
|
||||
}]
|
||||
|
@ -520,23 +462,6 @@
|
|||
return this;
|
||||
},
|
||||
|
||||
paste: function(evt){
|
||||
var dateString;
|
||||
if (evt.originalEvent.clipboardData && evt.originalEvent.clipboardData.types
|
||||
&& $.inArray('text/plain', evt.originalEvent.clipboardData.types) !== -1) {
|
||||
dateString = evt.originalEvent.clipboardData.getData('text/plain');
|
||||
}
|
||||
else if (window.clipboardData) {
|
||||
dateString = window.clipboardData.getData('Text');
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
this.setDate(dateString);
|
||||
this.update();
|
||||
evt.preventDefault();
|
||||
},
|
||||
|
||||
_utc_to_local: function(utc){
|
||||
return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
|
||||
},
|
||||
|
@ -582,7 +507,7 @@
|
|||
}
|
||||
|
||||
if (element) {
|
||||
element.val('');
|
||||
element.val('').change();
|
||||
}
|
||||
|
||||
this.update();
|
||||
|
@ -615,11 +540,11 @@
|
|||
var formatted = this.getFormattedDate();
|
||||
if (!this.isInput){
|
||||
if (this.component){
|
||||
this.element.find('input').val(formatted);
|
||||
this.element.find('input').val(formatted).change();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.element.val(formatted);
|
||||
this.element.val(formatted).change();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
@ -655,12 +580,6 @@
|
|||
return this;
|
||||
},
|
||||
|
||||
setDaysOfWeekHighlighted: function(daysOfWeekHighlighted){
|
||||
this._process_options({daysOfWeekHighlighted: daysOfWeekHighlighted});
|
||||
this.update();
|
||||
return this;
|
||||
},
|
||||
|
||||
setDatesDisabled: function(datesDisabled){
|
||||
this._process_options({datesDisabled: datesDisabled});
|
||||
this.update();
|
||||
|
@ -673,11 +592,10 @@
|
|||
var calendarWidth = this.picker.outerWidth(),
|
||||
calendarHeight = this.picker.outerHeight(),
|
||||
visualPadding = 10,
|
||||
container = $(this.o.container),
|
||||
windowWidth = container.width(),
|
||||
windowHeight = container.height(),
|
||||
scrollTop = container.scrollTop(),
|
||||
appendOffset = container.offset();
|
||||
windowWidth = $(this.o.container).width(),
|
||||
windowHeight = $(this.o.container).height(),
|
||||
scrollTop = $(this.o.container).scrollTop(),
|
||||
appendOffset = $(this.o.container).offset();
|
||||
|
||||
var parentsZindex = [];
|
||||
this.element.parents().each(function(){
|
||||
|
@ -732,9 +650,9 @@
|
|||
}
|
||||
this.picker.addClass('datepicker-orient-' + yorient);
|
||||
if (yorient === 'top')
|
||||
top -= calendarHeight + parseInt(this.picker.css('padding-top'));
|
||||
else
|
||||
top += height;
|
||||
else
|
||||
top -= calendarHeight + parseInt(this.picker.css('padding-top'));
|
||||
|
||||
if (this.o.rtl) {
|
||||
var right = windowWidth - (left + width);
|
||||
|
@ -798,8 +716,6 @@
|
|||
this.viewDate = new Date(this.o.startDate);
|
||||
else if (this.viewDate > this.o.endDate)
|
||||
this.viewDate = new Date(this.o.endDate);
|
||||
else
|
||||
this.viewDate = this.o.defaultViewDate;
|
||||
|
||||
if (fromArgs){
|
||||
// setting date by clicking
|
||||
|
@ -814,7 +730,6 @@
|
|||
this._trigger('clearDate');
|
||||
|
||||
this.fill();
|
||||
this.element.change();
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -822,11 +737,12 @@
|
|||
var dowCnt = this.o.weekStart,
|
||||
html = '<tr>';
|
||||
if (this.o.calendarWeeks){
|
||||
this.picker.find('.datepicker-days .datepicker-switch')
|
||||
this.picker.find('.datepicker-days thead tr:first-child .datepicker-switch')
|
||||
.attr('colspan', function(i, val){
|
||||
return parseInt(val) + 1;
|
||||
});
|
||||
html += '<th class="cw"> </th>';
|
||||
var cell = '<th class="cw"> </th>';
|
||||
html += cell;
|
||||
}
|
||||
while (dowCnt < this.o.weekStart + 7){
|
||||
html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
|
||||
|
@ -880,10 +796,6 @@
|
|||
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
|
||||
cls.push('disabled');
|
||||
}
|
||||
if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
|
||||
$.inArray(date.getUTCDay(), this.o.daysOfWeekHighlighted) !== -1){
|
||||
cls.push('highlighted');
|
||||
}
|
||||
if (this.o.datesDisabled.length > 0 &&
|
||||
$.grep(this.o.datesDisabled, function(d){
|
||||
return isUTCEquals(date, d); }).length > 0) {
|
||||
|
@ -911,21 +823,17 @@
|
|||
endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
|
||||
todaytxt = dates[this.o.language].today || dates['en'].today || '',
|
||||
cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
|
||||
titleFormat = dates[this.o.language].titleFormat || dates['en'].titleFormat,
|
||||
tooltip;
|
||||
if (isNaN(year) || isNaN(month))
|
||||
return;
|
||||
this.picker.find('.datepicker-days thead .datepicker-switch')
|
||||
.text(DPGlobal.formatDate(new Date(year, month), titleFormat, this.o.language));
|
||||
.text(dates[this.o.language].months[month]+' '+year);
|
||||
this.picker.find('tfoot .today')
|
||||
.text(todaytxt)
|
||||
.toggle(this.o.todayBtn !== false);
|
||||
this.picker.find('tfoot .clear')
|
||||
.text(cleartxt)
|
||||
.toggle(this.o.clearBtn !== false);
|
||||
this.picker.find('thead .datepicker-title')
|
||||
.text(this.o.title)
|
||||
.toggle(this.o.title !== '');
|
||||
this.updateNavArrows();
|
||||
this.fillMonths();
|
||||
var prevMonth = UTCDate(year, month-1, 28),
|
||||
|
@ -986,8 +894,8 @@
|
|||
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
||||
|
||||
var months = this.picker.find('.datepicker-months')
|
||||
.find('.datepicker-switch')
|
||||
.text(this.o.maxViewMode < 2 ? 'Months' : year)
|
||||
.find('th:eq(1)')
|
||||
.text(year)
|
||||
.end()
|
||||
.find('span').removeClass('active');
|
||||
|
||||
|
@ -1021,7 +929,7 @@
|
|||
html = '';
|
||||
year = parseInt(year/10, 10) * 10;
|
||||
var yearCont = this.picker.find('.datepicker-years')
|
||||
.find('.datepicker-switch')
|
||||
.find('th:eq(1)')
|
||||
.text(year + '-' + (year + 9))
|
||||
.end()
|
||||
.find('td');
|
||||
|
@ -1032,8 +940,6 @@
|
|||
classes;
|
||||
for (var i = -1; i < 11; i++){
|
||||
classes = ['year'];
|
||||
tooltip = null;
|
||||
|
||||
if (i === -1)
|
||||
classes.push('old');
|
||||
else if (i === 10)
|
||||
|
@ -1042,24 +948,7 @@
|
|||
classes.push('active');
|
||||
if (year < startYear || year > endYear)
|
||||
classes.push('disabled');
|
||||
|
||||
if (this.o.beforeShowYear !== $.noop) {
|
||||
var yrBefore = this.o.beforeShowYear(new Date(year, 0, 1));
|
||||
if (yrBefore === undefined)
|
||||
yrBefore = {};
|
||||
else if (typeof(yrBefore) === 'boolean')
|
||||
yrBefore = {enabled: yrBefore};
|
||||
else if (typeof(yrBefore) === 'string')
|
||||
yrBefore = {classes: yrBefore};
|
||||
if (yrBefore.enabled === false)
|
||||
classes.push('disabled');
|
||||
if (yrBefore.classes)
|
||||
classes = classes.concat(yrBefore.classes.split(/\s+/));
|
||||
if (yrBefore.tooltip)
|
||||
tooltip = yrBefore.tooltip;
|
||||
}
|
||||
|
||||
html += '<span class="' + classes.join(' ') + '"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>' + year + '</span>';
|
||||
html += '<span class="' + classes.join(' ') + '">' + year + '</span>';
|
||||
year += 1;
|
||||
}
|
||||
yearCont.html(html);
|
||||
|
@ -1089,13 +978,13 @@
|
|||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() || this.o.maxViewMode < 2){
|
||||
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){
|
||||
this.picker.find('.prev').css({visibility: 'hidden'});
|
||||
}
|
||||
else {
|
||||
this.picker.find('.prev').css({visibility: 'visible'});
|
||||
}
|
||||
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() || this.o.maxViewMode < 2){
|
||||
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()){
|
||||
this.picker.find('.next').css({visibility: 'hidden'});
|
||||
}
|
||||
else {
|
||||
|
@ -1107,7 +996,6 @@
|
|||
|
||||
click: function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var target = $(e.target).closest('span, td, th'),
|
||||
year, month, day;
|
||||
if (target.length === 1){
|
||||
|
@ -1158,9 +1046,6 @@
|
|||
this._trigger('changeMonth', this.viewDate);
|
||||
if (this.o.minViewMode === 1){
|
||||
this._setDate(UTCDate(year, month, day));
|
||||
this.showMode();
|
||||
} else {
|
||||
this.showMode(-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1172,8 +1057,8 @@
|
|||
if (this.o.minViewMode === 2){
|
||||
this._setDate(UTCDate(year, month, day));
|
||||
}
|
||||
this.showMode(-1);
|
||||
}
|
||||
this.showMode(-1);
|
||||
this.fill();
|
||||
}
|
||||
break;
|
||||
|
@ -1320,7 +1205,7 @@
|
|||
|
||||
keydown: function(e){
|
||||
if (!this.picker.is(':visible')){
|
||||
if (e.keyCode === 40 || e.keyCode === 27) // allow down to re-show picker
|
||||
if (e.keyCode === 27) // allow escape to hide and re-show picker
|
||||
this.show();
|
||||
return;
|
||||
}
|
||||
|
@ -1446,13 +1331,13 @@
|
|||
|
||||
showMode: function(dir){
|
||||
if (dir){
|
||||
this.viewMode = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, this.viewMode + dir));
|
||||
this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
|
||||
}
|
||||
this.picker
|
||||
.children('div')
|
||||
.hide()
|
||||
.filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName)
|
||||
.show();
|
||||
.css('display', 'block');
|
||||
this.updateNavArrows();
|
||||
}
|
||||
};
|
||||
|
@ -1465,7 +1350,7 @@
|
|||
delete options.inputs;
|
||||
|
||||
datepickerPlugin.call($(this.inputs), options)
|
||||
.on('changeDate', $.proxy(this.dateUpdated, this));
|
||||
.bind('changeDate', $.proxy(this.dateUpdated, this));
|
||||
|
||||
this.pickers = $.map(this.inputs, function(i){
|
||||
return $(i).data('datepicker');
|
||||
|
@ -1609,12 +1494,10 @@
|
|||
autoclose: false,
|
||||
beforeShowDay: $.noop,
|
||||
beforeShowMonth: $.noop,
|
||||
beforeShowYear: $.noop,
|
||||
calendarWeeks: false,
|
||||
clearBtn: false,
|
||||
toggleActive: false,
|
||||
daysOfWeekDisabled: [],
|
||||
daysOfWeekHighlighted: [],
|
||||
datesDisabled: [],
|
||||
endDate: Infinity,
|
||||
forceParse: true,
|
||||
|
@ -1622,7 +1505,6 @@
|
|||
keyboardNavigation: true,
|
||||
language: 'en',
|
||||
minViewMode: 0,
|
||||
maxViewMode: 2,
|
||||
multidate: false,
|
||||
multidateSeparator: ',',
|
||||
orientation: "auto",
|
||||
|
@ -1633,10 +1515,8 @@
|
|||
todayHighlight: false,
|
||||
weekStart: 0,
|
||||
disableTouchKeyboard: false,
|
||||
enableOnReadonly: true,
|
||||
container: 'body',
|
||||
immediateUpdates: false,
|
||||
title: ''
|
||||
enableOnReadonly: true,
|
||||
container: 'body'
|
||||
};
|
||||
var locale_opts = $.fn.datepicker.locale_opts = [
|
||||
'format',
|
||||
|
@ -1646,14 +1526,13 @@
|
|||
$.fn.datepicker.Constructor = Datepicker;
|
||||
var dates = $.fn.datepicker.dates = {
|
||||
en: {
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
today: "Today",
|
||||
clear: "Clear",
|
||||
titleFormat: "MM yyyy"
|
||||
clear: "Clear"
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1826,9 +1705,6 @@
|
|||
return date.join('');
|
||||
},
|
||||
headTemplate: '<thead>'+
|
||||
'<tr>'+
|
||||
'<th colspan="7" class="datepicker-title"></th>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<th class="prev">«</th>'+
|
||||
'<th colspan="5" class="datepicker-switch"></th>'+
|
||||
|
@ -1882,7 +1758,7 @@
|
|||
|
||||
/* DATEPICKER VERSION
|
||||
* =================== */
|
||||
$.fn.datepicker.version = "1.4.1-dev";
|
||||
$.fn.datepicker.version = "1.4.0";
|
||||
|
||||
/* DATEPICKER DATA-API
|
||||
* ================== */
|
||||
|
@ -1903,4 +1779,4 @@
|
|||
datepickerPlugin.call($('[data-provide="datepicker-inline"]'));
|
||||
});
|
||||
|
||||
}));
|
||||
}(window.jQuery));
|
||||
|
|
Loading…
Reference in New Issue