|
|
|
@ -1,26 +1,18 @@ |
|
|
|
|
/* ========================================================= |
|
|
|
|
* 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.5.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($, 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(factory){ |
|
|
|
|
if (typeof define === "function" && define.amd) { |
|
|
|
|
define(["jquery"], factory); |
|
|
|
|
} else if (typeof exports === 'object') { |
|
|
|
|
factory(require('jquery')); |
|
|
|
|
} else { |
|
|
|
|
factory(jQuery); |
|
|
|
|
} |
|
|
|
|
}(function($, undefined){ |
|
|
|
|
|
|
|
|
|
function UTCDate(){ |
|
|
|
|
return new Date(Date.UTC.apply(Date, arguments)); |
|
|
|
@ -41,6 +33,9 @@ |
|
|
|
|
return this[method].apply(this, arguments); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
function isValidDate(d) { |
|
|
|
|
return d && !isNaN(d.getTime()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var DateArray = (function(){ |
|
|
|
|
var extras = { |
|
|
|
@ -131,6 +126,7 @@ |
|
|
|
|
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(); |
|
|
|
@ -191,6 +187,20 @@ |
|
|
|
|
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
|
|
|
|
@ -235,6 +245,13 @@ |
|
|
|
|
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 = []; |
|
|
|
@ -285,6 +302,7 @@ |
|
|
|
|
o.defaultViewDate = UTCToday(); |
|
|
|
|
} |
|
|
|
|
o.showOnFocus = o.showOnFocus !== undefined ? o.showOnFocus : true; |
|
|
|
|
o.zIndexOffset = o.zIndexOffset !== undefined ? o.zIndexOffset : 10; |
|
|
|
|
}, |
|
|
|
|
_events: [], |
|
|
|
|
_secondaryEvents: [], |
|
|
|
@ -322,7 +340,8 @@ |
|
|
|
|
if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1) |
|
|
|
|
this.update(); |
|
|
|
|
}, this), |
|
|
|
|
keydown: $.proxy(this.keydown, this) |
|
|
|
|
keydown: $.proxy(this.keydown, this), |
|
|
|
|
paste: $.proxy(this.paste, this) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (this.o.showOnFocus === true) { |
|
|
|
@ -368,6 +387,15 @@ |
|
|
|
|
}] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
@ -376,13 +404,14 @@ |
|
|
|
|
resize: $.proxy(this.place, this) |
|
|
|
|
}], |
|
|
|
|
[$(document), { |
|
|
|
|
'mousedown touchstart': $.proxy(function(e){ |
|
|
|
|
mousedown: $.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.find(e.target).length || |
|
|
|
|
this.picker.hasClass('datepicker-inline') |
|
|
|
|
)){ |
|
|
|
|
this.hide(); |
|
|
|
|
} |
|
|
|
@ -478,6 +507,23 @@ |
|
|
|
|
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)); |
|
|
|
|
}, |
|
|
|
@ -523,7 +569,7 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (element) { |
|
|
|
|
element.val('').change(); |
|
|
|
|
element.val(''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.update(); |
|
|
|
@ -556,11 +602,11 @@ |
|
|
|
|
var formatted = this.getFormattedDate(); |
|
|
|
|
if (!this.isInput){ |
|
|
|
|
if (this.component){ |
|
|
|
|
this.element.find('input').val(formatted).change(); |
|
|
|
|
this.element.find('input').val(formatted); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
this.element.val(formatted).change(); |
|
|
|
|
this.element.val(formatted); |
|
|
|
|
} |
|
|
|
|
return this; |
|
|
|
|
}, |
|
|
|
@ -596,6 +642,12 @@ |
|
|
|
|
return this; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setDaysOfWeekHighlighted: function(daysOfWeekHighlighted){ |
|
|
|
|
this._process_options({daysOfWeekHighlighted: daysOfWeekHighlighted}); |
|
|
|
|
this.update(); |
|
|
|
|
return this; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setDatesDisabled: function(datesDisabled){ |
|
|
|
|
this._process_options({datesDisabled: datesDisabled}); |
|
|
|
|
this.update(); |
|
|
|
@ -608,17 +660,17 @@ |
|
|
|
|
var calendarWidth = this.picker.outerWidth(), |
|
|
|
|
calendarHeight = this.picker.outerHeight(), |
|
|
|
|
visualPadding = 10, |
|
|
|
|
windowWidth = $(this.o.container).width(), |
|
|
|
|
windowHeight = $(this.o.container).height(), |
|
|
|
|
scrollTop = $(this.o.container).scrollTop(), |
|
|
|
|
appendOffset = $(this.o.container).offset(); |
|
|
|
|
container = $(this.o.container), |
|
|
|
|
windowWidth = container.width(), |
|
|
|
|
scrollTop = container.scrollTop(), |
|
|
|
|
appendOffset = container.offset(); |
|
|
|
|
|
|
|
|
|
var parentsZindex = []; |
|
|
|
|
this.element.parents().each(function(){ |
|
|
|
|
var itemZIndex = $(this).css('z-index'); |
|
|
|
|
if (itemZIndex !== 'auto' && itemZIndex !== 0) parentsZindex.push(parseInt(itemZIndex)); |
|
|
|
|
}); |
|
|
|
|
var zIndex = Math.max.apply(Math, parentsZindex) + 10; |
|
|
|
|
var zIndex = Math.max.apply(Math, parentsZindex) + this.o.zIndexOffset; |
|
|
|
|
var offset = this.component ? this.component.parent().offset() : this.element.offset(); |
|
|
|
|
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false); |
|
|
|
|
var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false); |
|
|
|
@ -655,20 +707,17 @@ |
|
|
|
|
// auto y orientation is best-situation: top or bottom, no fudging,
|
|
|
|
|
// decision based on which shows more of the calendar
|
|
|
|
|
var yorient = this.o.orientation.y, |
|
|
|
|
top_overflow, bottom_overflow; |
|
|
|
|
top_overflow; |
|
|
|
|
if (yorient === 'auto'){ |
|
|
|
|
top_overflow = -scrollTop + top - calendarHeight; |
|
|
|
|
bottom_overflow = scrollTop + windowHeight - (top + height + calendarHeight); |
|
|
|
|
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow) |
|
|
|
|
yorient = 'top'; |
|
|
|
|
else |
|
|
|
|
yorient = 'bottom'; |
|
|
|
|
yorient = top_overflow < 0 ? 'bottom' : 'top'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.picker.addClass('datepicker-orient-' + yorient); |
|
|
|
|
if (yorient === 'top') |
|
|
|
|
top += height; |
|
|
|
|
else |
|
|
|
|
top -= calendarHeight + parseInt(this.picker.css('padding-top')); |
|
|
|
|
else |
|
|
|
|
top += height; |
|
|
|
|
|
|
|
|
|
if (this.o.rtl) { |
|
|
|
|
var right = windowWidth - (left + width); |
|
|
|
@ -732,6 +781,8 @@ |
|
|
|
|
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
|
|
|
|
@ -746,6 +797,7 @@ |
|
|
|
|
this._trigger('clearDate'); |
|
|
|
|
|
|
|
|
|
this.fill(); |
|
|
|
|
this.element.change(); |
|
|
|
|
return this; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -753,12 +805,11 @@ |
|
|
|
|
var dowCnt = this.o.weekStart, |
|
|
|
|
html = '<tr>'; |
|
|
|
|
if (this.o.calendarWeeks){ |
|
|
|
|
this.picker.find('.datepicker-days thead tr:first-child .datepicker-switch') |
|
|
|
|
this.picker.find('.datepicker-days .datepicker-switch') |
|
|
|
|
.attr('colspan', function(i, val){ |
|
|
|
|
return parseInt(val) + 1; |
|
|
|
|
}); |
|
|
|
|
var cell = '<th class="cw"> </th>'; |
|
|
|
|
html += cell; |
|
|
|
|
html += '<th class="cw"> </th>'; |
|
|
|
|
} |
|
|
|
|
while (dowCnt < this.o.weekStart + 7){ |
|
|
|
|
html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>'; |
|
|
|
@ -812,6 +863,9 @@ |
|
|
|
|
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){ |
|
|
|
|
cls.push('disabled'); |
|
|
|
|
} |
|
|
|
|
if ($.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) { |
|
|
|
@ -825,6 +879,12 @@ |
|
|
|
|
if ($.inArray(date.valueOf(), this.range) !== -1){ |
|
|
|
|
cls.push('selected'); |
|
|
|
|
} |
|
|
|
|
if (date.valueOf() === this.range[0]){ |
|
|
|
|
cls.push('range-start'); |
|
|
|
|
} |
|
|
|
|
if (date.valueOf() === this.range[this.range.length-1]){ |
|
|
|
|
cls.push('range-end'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return cls; |
|
|
|
|
}, |
|
|
|
@ -839,17 +899,21 @@ |
|
|
|
|
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(dates[this.o.language].months[month]+' '+year); |
|
|
|
|
.text(DPGlobal.formatDate(new UTCDate(year, month), titleFormat, this.o.language)); |
|
|
|
|
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), |
|
|
|
@ -857,6 +921,9 @@ |
|
|
|
|
prevMonth.setUTCDate(day); |
|
|
|
|
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7); |
|
|
|
|
var nextMonth = new Date(prevMonth); |
|
|
|
|
if (prevMonth.getUTCFullYear() < 100){ |
|
|
|
|
nextMonth.setUTCFullYear(prevMonth.getUTCFullYear()); |
|
|
|
|
} |
|
|
|
|
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42); |
|
|
|
|
nextMonth = nextMonth.valueOf(); |
|
|
|
|
var html = []; |
|
|
|
@ -910,8 +977,8 @@ |
|
|
|
|
this.picker.find('.datepicker-days tbody').empty().append(html.join('')); |
|
|
|
|
|
|
|
|
|
var months = this.picker.find('.datepicker-months') |
|
|
|
|
.find('th:eq(1)') |
|
|
|
|
.text(year) |
|
|
|
|
.find('.datepicker-switch') |
|
|
|
|
.text(this.o.maxViewMode < 2 ? 'Months' : year) |
|
|
|
|
.end() |
|
|
|
|
.find('span').removeClass('active'); |
|
|
|
|
|
|
|
|
@ -945,7 +1012,7 @@ |
|
|
|
|
html = ''; |
|
|
|
|
year = parseInt(year/10, 10) * 10; |
|
|
|
|
var yearCont = this.picker.find('.datepicker-years') |
|
|
|
|
.find('th:eq(1)') |
|
|
|
|
.find('.datepicker-switch') |
|
|
|
|
.text(year + '-' + (year + 9)) |
|
|
|
|
.end() |
|
|
|
|
.find('td'); |
|
|
|
@ -956,6 +1023,8 @@ |
|
|
|
|
classes; |
|
|
|
|
for (var i = -1; i < 11; i++){ |
|
|
|
|
classes = ['year']; |
|
|
|
|
tooltip = null; |
|
|
|
|
|
|
|
|
|
if (i === -1) |
|
|
|
|
classes.push('old'); |
|
|
|
|
else if (i === 10) |
|
|
|
@ -964,7 +1033,24 @@ |
|
|
|
|
classes.push('active'); |
|
|
|
|
if (year < startYear || year > endYear) |
|
|
|
|
classes.push('disabled'); |
|
|
|
|
html += '<span class="' + classes.join(' ') + '">' + year + '</span>'; |
|
|
|
|
|
|
|
|
|
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>'; |
|
|
|
|
year += 1; |
|
|
|
|
} |
|
|
|
|
yearCont.html(html); |
|
|
|
@ -994,13 +1080,13 @@ |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
case 2: |
|
|
|
|
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){ |
|
|
|
|
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() || this.o.maxViewMode < 2){ |
|
|
|
|
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()){ |
|
|
|
|
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() || this.o.maxViewMode < 2){ |
|
|
|
|
this.picker.find('.next').css({visibility: 'hidden'}); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
@ -1012,6 +1098,7 @@ |
|
|
|
|
|
|
|
|
|
click: function(e){ |
|
|
|
|
e.preventDefault(); |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
var target = $(e.target).closest('span, td, th'), |
|
|
|
|
year, month, day; |
|
|
|
|
if (target.length === 1){ |
|
|
|
@ -1062,6 +1149,9 @@ |
|
|
|
|
this._trigger('changeMonth', this.viewDate); |
|
|
|
|
if (this.o.minViewMode === 1){ |
|
|
|
|
this._setDate(UTCDate(year, month, day)); |
|
|
|
|
this.showMode(); |
|
|
|
|
} else { |
|
|
|
|
this.showMode(-1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
@ -1073,8 +1163,8 @@ |
|
|
|
|
if (this.o.minViewMode === 2){ |
|
|
|
|
this._setDate(UTCDate(year, month, day)); |
|
|
|
|
} |
|
|
|
|
this.showMode(-1); |
|
|
|
|
} |
|
|
|
|
this.showMode(-1); |
|
|
|
|
this.fill(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -1162,8 +1252,8 @@ |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
moveMonth: function(date, dir){ |
|
|
|
|
if (!date) |
|
|
|
|
return undefined; |
|
|
|
|
if (!isValidDate(date)) |
|
|
|
|
return this.o.defaultViewDate; |
|
|
|
|
if (!dir) |
|
|
|
|
return date; |
|
|
|
|
var new_date = new Date(date.valueOf()), |
|
|
|
@ -1221,8 +1311,10 @@ |
|
|
|
|
|
|
|
|
|
keydown: function(e){ |
|
|
|
|
if (!this.picker.is(':visible')){ |
|
|
|
|
if (e.keyCode === 27) // allow escape to hide and re-show picker
|
|
|
|
|
if (e.keyCode === 40 || e.keyCode === 27) { // allow down to re-show picker
|
|
|
|
|
this.show(); |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var dateChanged = false, |
|
|
|
@ -1238,6 +1330,7 @@ |
|
|
|
|
else |
|
|
|
|
this.hide(); |
|
|
|
|
e.preventDefault(); |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
break; |
|
|
|
|
case 37: // left
|
|
|
|
|
case 39: // right
|
|
|
|
@ -1300,6 +1393,9 @@ |
|
|
|
|
// As such, its behavior should not be hijacked.
|
|
|
|
|
break; |
|
|
|
|
case 13: // enter
|
|
|
|
|
if (!this.o.forceParse) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
focusDate = this.focusDate || this.dates.get(-1) || this.viewDate; |
|
|
|
|
if (this.o.keyboardNavigation) { |
|
|
|
|
this._toggle_multidate(focusDate); |
|
|
|
@ -1347,13 +1443,13 @@ |
|
|
|
|
|
|
|
|
|
showMode: function(dir){ |
|
|
|
|
if (dir){ |
|
|
|
|
this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir)); |
|
|
|
|
this.viewMode = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, this.viewMode + dir)); |
|
|
|
|
} |
|
|
|
|
this.picker |
|
|
|
|
.children('div') |
|
|
|
|
.hide() |
|
|
|
|
.filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName) |
|
|
|
|
.css('display', 'block'); |
|
|
|
|
.show(); |
|
|
|
|
this.updateNavArrows(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -1366,7 +1462,7 @@ |
|
|
|
|
delete options.inputs; |
|
|
|
|
|
|
|
|
|
datepickerPlugin.call($(this.inputs), options) |
|
|
|
|
.bind('changeDate', $.proxy(this.dateUpdated, this)); |
|
|
|
|
.on('changeDate', $.proxy(this.dateUpdated, this)); |
|
|
|
|
|
|
|
|
|
this.pickers = $.map(this.inputs, function(i){ |
|
|
|
|
return $(i).data('datepicker'); |
|
|
|
@ -1396,8 +1492,13 @@ |
|
|
|
|
return; |
|
|
|
|
this.updating = true; |
|
|
|
|
|
|
|
|
|
var dp = $(e.target).data('datepicker'), |
|
|
|
|
new_date = dp.getUTCDate(), |
|
|
|
|
var dp = $(e.target).data('datepicker'); |
|
|
|
|
|
|
|
|
|
if (typeof(dp) === "undefined") { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var new_date = dp.getUTCDate(), |
|
|
|
|
i = $.inArray(e.target, this.inputs), |
|
|
|
|
j = i - 1, |
|
|
|
|
k = i + 1, |
|
|
|
@ -1495,14 +1596,20 @@ |
|
|
|
|
} |
|
|
|
|
if (typeof option === 'string' && typeof data[option] === 'function'){ |
|
|
|
|
internal_return = data[option].apply(data, args); |
|
|
|
|
if (internal_return !== undefined) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (internal_return !== undefined) |
|
|
|
|
return internal_return; |
|
|
|
|
else |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
internal_return === undefined || |
|
|
|
|
internal_return instanceof Datepicker || |
|
|
|
|
internal_return instanceof DateRangePicker |
|
|
|
|
) |
|
|
|
|
return this; |
|
|
|
|
|
|
|
|
|
if (this.length > 1) |
|
|
|
|
throw new Error('Using only allowed for the collection of a single element (' + option + ' function)'); |
|
|
|
|
else |
|
|
|
|
return internal_return; |
|
|
|
|
}; |
|
|
|
|
$.fn.datepicker = datepickerPlugin; |
|
|
|
|
|
|
|
|
@ -1510,10 +1617,12 @@ |
|
|
|
|
autoclose: false, |
|
|
|
|
beforeShowDay: $.noop, |
|
|
|
|
beforeShowMonth: $.noop, |
|
|
|
|
beforeShowYear: $.noop, |
|
|
|
|
calendarWeeks: false, |
|
|
|
|
clearBtn: false, |
|
|
|
|
toggleActive: false, |
|
|
|
|
daysOfWeekDisabled: [], |
|
|
|
|
daysOfWeekHighlighted: [], |
|
|
|
|
datesDisabled: [], |
|
|
|
|
endDate: Infinity, |
|
|
|
|
forceParse: true, |
|
|
|
@ -1521,6 +1630,7 @@ |
|
|
|
|
keyboardNavigation: true, |
|
|
|
|
language: 'en', |
|
|
|
|
minViewMode: 0, |
|
|
|
|
maxViewMode: 2, |
|
|
|
|
multidate: false, |
|
|
|
|
multidateSeparator: ',', |
|
|
|
|
orientation: "auto", |
|
|
|
@ -1531,8 +1641,10 @@ |
|
|
|
|
todayHighlight: false, |
|
|
|
|
weekStart: 0, |
|
|
|
|
disableTouchKeyboard: false, |
|
|
|
|
enableOnReadonly: true, |
|
|
|
|
container: 'body' |
|
|
|
|
enableOnReadonly: true, |
|
|
|
|
container: 'body', |
|
|
|
|
immediateUpdates: false, |
|
|
|
|
title: '' |
|
|
|
|
}; |
|
|
|
|
var locale_opts = $.fn.datepicker.locale_opts = [ |
|
|
|
|
'format', |
|
|
|
@ -1542,13 +1654,14 @@ |
|
|
|
|
$.fn.datepicker.Constructor = Datepicker; |
|
|
|
|
var dates = $.fn.datepicker.dates = { |
|
|
|
|
en: { |
|
|
|
|
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"], |
|
|
|
|
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], |
|
|
|
|
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], |
|
|
|
|
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], |
|
|
|
|
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" |
|
|
|
|
clear: "Clear", |
|
|
|
|
titleFormat: "MM yyyy" |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -1578,7 +1691,9 @@ |
|
|
|
|
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g, |
|
|
|
|
nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g, |
|
|
|
|
parseFormat: function(format){ |
|
|
|
|
// IE treats \0 as a string end in inputs (truncating the value),
|
|
|
|
|
if (typeof format.toValue === 'function' && typeof format.toDisplay === 'function') |
|
|
|
|
return format; |
|
|
|
|
// IE treats \0 as a string end in inputs (truncating the value),
|
|
|
|
|
// so it's a bad format delimiter, anyway
|
|
|
|
|
var separators = format.replace(this.validParts, '\0').split('\0'), |
|
|
|
|
parts = format.match(this.validParts); |
|
|
|
@ -1594,7 +1709,9 @@ |
|
|
|
|
return date; |
|
|
|
|
if (typeof format === 'string') |
|
|
|
|
format = DPGlobal.parseFormat(format); |
|
|
|
|
var part_re = /([\-+]\d+)([dmwy])/, |
|
|
|
|
if (format.toValue) |
|
|
|
|
return format.toValue(date, format, language); |
|
|
|
|
var part_re = /([\-+]\d+)([dmwy])/, |
|
|
|
|
parts = date.match(/([\-+]\d+)([dmwy])/g), |
|
|
|
|
part, dir, i; |
|
|
|
|
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){ |
|
|
|
@ -1699,7 +1816,9 @@ |
|
|
|
|
return ''; |
|
|
|
|
if (typeof format === 'string') |
|
|
|
|
format = DPGlobal.parseFormat(format); |
|
|
|
|
var val = { |
|
|
|
|
if (format.toDisplay) |
|
|
|
|
return format.toDisplay(date, format, language); |
|
|
|
|
var val = { |
|
|
|
|
d: date.getUTCDate(), |
|
|
|
|
D: dates[language].daysShort[date.getUTCDay()], |
|
|
|
|
DD: dates[language].days[date.getUTCDay()], |
|
|
|
@ -1721,6 +1840,9 @@ |
|
|
|
|
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>'+ |
|
|
|
@ -1774,7 +1896,7 @@ |
|
|
|
|
|
|
|
|
|
/* DATEPICKER VERSION |
|
|
|
|
* =================== */ |
|
|
|
|
$.fn.datepicker.version = "1.4.1"; |
|
|
|
|
$.fn.datepicker.version = '1.5.0'; |
|
|
|
|
|
|
|
|
|
/* DATEPICKER DATA-API |
|
|
|
|
* ================== */ |
|
|
|
@ -1795,4 +1917,4 @@ |
|
|
|
|
datepickerPlugin.call($('[data-provide="datepicker-inline"]')); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}(window.jQuery)); |
|
|
|
|
})); |
|
|
|
|