Working : bootstrap datepicker commented out to keep style for jquery.datepicker (Mika)

This commit is contained in:
gmorel
2013-09-13 15:36:15 +02:00
parent ed4809bac4
commit d829835d51

View File

@@ -1,474 +1,474 @@
/* ========================================================= ///* =========================================================
* bootstrap-datepicker.js // * bootstrap-datepicker.js
* http://www.eyecon.ro/bootstrap-datepicker // * http://www.eyecon.ro/bootstrap-datepicker
* ========================================================= // * =========================================================
* Copyright 2012 Stefan Petre // * Copyright 2012 Stefan Petre
* // *
* Licensed under the Apache License, Version 2.0 (the "License"); // * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. // * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at // * You may obtain a copy of the License at
* // *
* http://www.apache.org/licenses/LICENSE-2.0 // * http://www.apache.org/licenses/LICENSE-2.0
* // *
* Unless required by applicable law or agreed to in writing, software // * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, // * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and // * See the License for the specific language governing permissions and
* limitations under the License. // * limitations under the License.
* ========================================================= */ // * ========================================================= */
//
!function( $ ) { //!function( $ ) {
//
// Picker object // // Picker object
//
var Datepicker = function(element, options){ // var Datepicker = function(element, options){
this.element = $(element); // this.element = $(element);
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy'); // this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
this.picker = $(DPGlobal.template) // this.picker = $(DPGlobal.template)
.appendTo('body') // .appendTo('body')
.on({ // .on({
click: $.proxy(this.click, this)//, // click: $.proxy(this.click, this)//,
//mousedown: $.proxy(this.mousedown, this) // //mousedown: $.proxy(this.mousedown, this)
}); // });
this.isInput = this.element.is('input'); // this.isInput = this.element.is('input');
this.component = this.element.is('.date') ? this.element.find('.add-on') : false; // this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
//
if (this.isInput) { // if (this.isInput) {
this.element.on({ // this.element.on({
focus: $.proxy(this.show, this), // focus: $.proxy(this.show, this),
//blur: $.proxy(this.hide, this), // //blur: $.proxy(this.hide, this),
keyup: $.proxy(this.update, this) // keyup: $.proxy(this.update, this)
}); // });
} else { // } else {
if (this.component){ // if (this.component){
this.component.on('click', $.proxy(this.show, this)); // this.component.on('click', $.proxy(this.show, this));
} else { // } else {
this.element.on('click', $.proxy(this.show, this)); // this.element.on('click', $.proxy(this.show, this));
} // }
} // }
//
this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0; // this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0;
if (typeof this.minViewMode === 'string') { // if (typeof this.minViewMode === 'string') {
switch (this.minViewMode) { // switch (this.minViewMode) {
case 'months': // case 'months':
this.minViewMode = 1; // this.minViewMode = 1;
break; // break;
case 'years': // case 'years':
this.minViewMode = 2; // this.minViewMode = 2;
break; // break;
default: // default:
this.minViewMode = 0; // this.minViewMode = 0;
break; // break;
} // }
} // }
this.viewMode = options.viewMode||this.element.data('date-viewmode')||0; // this.viewMode = options.viewMode||this.element.data('date-viewmode')||0;
if (typeof this.viewMode === 'string') { // if (typeof this.viewMode === 'string') {
switch (this.viewMode) { // switch (this.viewMode) {
case 'months': // case 'months':
this.viewMode = 1; // this.viewMode = 1;
break; // break;
case 'years': // case 'years':
this.viewMode = 2; // this.viewMode = 2;
break; // break;
default: // default:
this.viewMode = 0; // this.viewMode = 0;
break; // break;
} // }
} // }
this.startViewMode = this.viewMode; // this.startViewMode = this.viewMode;
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0; // this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; // this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
this.onRender = options.onRender; // this.onRender = options.onRender;
this.fillDow(); // this.fillDow();
this.fillMonths(); // this.fillMonths();
this.update(); // this.update();
this.showMode(); // this.showMode();
}; // };
//
Datepicker.prototype = { // Datepicker.prototype = {
constructor: Datepicker, // constructor: Datepicker,
//
show: function(e) { // show: function(e) {
this.picker.show(); // this.picker.show();
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight(); // this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
this.place(); // this.place();
$(window).on('resize', $.proxy(this.place, this)); // $(window).on('resize', $.proxy(this.place, this));
if (e ) { // if (e ) {
e.stopPropagation(); // e.stopPropagation();
e.preventDefault(); // e.preventDefault();
} // }
if (!this.isInput) { // if (!this.isInput) {
} // }
var that = this; // var that = this;
$(document).on('mousedown', function(ev){ // $(document).on('mousedown', function(ev){
if ($(ev.target).closest('.datepicker').length == 0) { // if ($(ev.target).closest('.datepicker').length == 0) {
that.hide(); // that.hide();
} // }
}); // });
this.element.trigger({ // this.element.trigger({
type: 'show', // type: 'show',
date: this.date // date: this.date
}); // });
}, // },
//
hide: function(){ // hide: function(){
this.picker.hide(); // this.picker.hide();
$(window).off('resize', this.place); // $(window).off('resize', this.place);
this.viewMode = this.startViewMode; // this.viewMode = this.startViewMode;
this.showMode(); // this.showMode();
if (!this.isInput) { // if (!this.isInput) {
$(document).off('mousedown', this.hide); // $(document).off('mousedown', this.hide);
} // }
// //this.set();
// this.element.trigger({
// type: 'hide',
// date: this.date
// });
// },
//
// set: function() {
// var formated = DPGlobal.formatDate(this.date, this.format);
// if (!this.isInput) {
// if (this.component){
// this.element.find('input').prop('value', formated);
// }
// this.element.data('date', formated);
// } else {
// this.element.prop('value', formated);
// }
// },
//
// setValue: function(newDate) {
// if (typeof newDate === 'string') {
// this.date = DPGlobal.parseDate(newDate, this.format);
// } else {
// this.date = new Date(newDate);
// }
// this.set(); // this.set();
this.element.trigger({ // this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
type: 'hide', // this.fill();
date: this.date // },
}); //
}, // place: function(){
// var offset = this.component ? this.component.offset() : this.element.offset();
set: function() { // this.picker.css({
var formated = DPGlobal.formatDate(this.date, this.format); // top: offset.top + this.height,
if (!this.isInput) { // left: offset.left
if (this.component){ // });
this.element.find('input').prop('value', formated); // },
} //
this.element.data('date', formated); // update: function(newDate){
} else { // this.date = DPGlobal.parseDate(
this.element.prop('value', formated); // typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')),
} // this.format
}, // );
// this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
setValue: function(newDate) { // this.fill();
if (typeof newDate === 'string') { // },
this.date = DPGlobal.parseDate(newDate, this.format); //
} else { // fillDow: function(){
this.date = new Date(newDate); // var dowCnt = this.weekStart;
} // var html = '<tr>';
this.set(); // while (dowCnt < this.weekStart + 7) {
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); // html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>';
this.fill(); // }
}, // html += '</tr>';
// this.picker.find('.datepicker-days thead').append(html);
place: function(){ // },
var offset = this.component ? this.component.offset() : this.element.offset(); //
this.picker.css({ // fillMonths: function(){
top: offset.top + this.height, // var html = '';
left: offset.left // var i = 0
}); // while (i < 12) {
}, // html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
// }
update: function(newDate){ // this.picker.find('.datepicker-months td').append(html);
this.date = DPGlobal.parseDate( // },
typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')), //
this.format // fill: function() {
); // var d = new Date(this.viewDate),
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0); // year = d.getFullYear(),
this.fill(); // month = d.getMonth(),
}, // currentDate = this.date.valueOf();
// this.picker.find('.datepicker-days th:eq(1)')
fillDow: function(){ // .text(DPGlobal.dates.months[month]+' '+year);
var dowCnt = this.weekStart; // var prevMonth = new Date(year, month-1, 28,0,0,0,0),
var html = '<tr>'; // day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
while (dowCnt < this.weekStart + 7) { // prevMonth.setDate(day);
html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>'; // prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
} // var nextMonth = new Date(prevMonth);
html += '</tr>'; // nextMonth.setDate(nextMonth.getDate() + 42);
this.picker.find('.datepicker-days thead').append(html); // nextMonth = nextMonth.valueOf();
}, // var html = [];
// var clsName,
fillMonths: function(){ // prevY,
var html = ''; // prevM;
var i = 0 // while(prevMonth.valueOf() < nextMonth) {
while (i < 12) { // if (prevMonth.getDay() === this.weekStart) {
html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>'; // html.push('<tr>');
} // }
this.picker.find('.datepicker-months td').append(html); // clsName = this.onRender(prevMonth);
}, // prevY = prevMonth.getFullYear();
// prevM = prevMonth.getMonth();
fill: function() { // if ((prevM < month && prevY === year) || prevY < year) {
var d = new Date(this.viewDate), // clsName += ' old';
year = d.getFullYear(), // } else if ((prevM > month && prevY === year) || prevY > year) {
month = d.getMonth(), // clsName += ' new';
currentDate = this.date.valueOf(); // }
this.picker.find('.datepicker-days th:eq(1)') // if (prevMonth.valueOf() === currentDate) {
.text(DPGlobal.dates.months[month]+' '+year); // clsName += ' active';
var prevMonth = new Date(year, month-1, 28,0,0,0,0), // }
day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth()); // html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>');
prevMonth.setDate(day); // if (prevMonth.getDay() === this.weekEnd) {
prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7); // html.push('</tr>');
var nextMonth = new Date(prevMonth); // }
nextMonth.setDate(nextMonth.getDate() + 42); // prevMonth.setDate(prevMonth.getDate()+1);
nextMonth = nextMonth.valueOf(); // }
var html = []; // this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
var clsName, // var currentYear = this.date.getFullYear();
prevY, //
prevM; // var months = this.picker.find('.datepicker-months')
while(prevMonth.valueOf() < nextMonth) { // .find('th:eq(1)')
if (prevMonth.getDay() === this.weekStart) { // .text(year)
html.push('<tr>'); // .end()
} // .find('span').removeClass('active');
clsName = this.onRender(prevMonth); // if (currentYear === year) {
prevY = prevMonth.getFullYear(); // months.eq(this.date.getMonth()).addClass('active');
prevM = prevMonth.getMonth(); // }
if ((prevM < month && prevY === year) || prevY < year) { //
clsName += ' old'; // html = '';
} else if ((prevM > month && prevY === year) || prevY > year) { // year = parseInt(year/10, 10) * 10;
clsName += ' new'; // var yearCont = this.picker.find('.datepicker-years')
} // .find('th:eq(1)')
if (prevMonth.valueOf() === currentDate) { // .text(year + '-' + (year + 9))
clsName += ' active'; // .end()
} // .find('td');
html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>'); // year -= 1;
if (prevMonth.getDay() === this.weekEnd) { // for (var i = -1; i < 11; i++) {
html.push('</tr>'); // html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>';
} // year += 1;
prevMonth.setDate(prevMonth.getDate()+1); // }
} // yearCont.html(html);
this.picker.find('.datepicker-days tbody').empty().append(html.join('')); // },
var currentYear = this.date.getFullYear(); //
// click: function(e) {
var months = this.picker.find('.datepicker-months') // e.stopPropagation();
.find('th:eq(1)') // e.preventDefault();
.text(year) // var target = $(e.target).closest('span, td, th');
.end() // if (target.length === 1) {
.find('span').removeClass('active'); // switch(target[0].nodeName.toLowerCase()) {
if (currentYear === year) { // case 'th':
months.eq(this.date.getMonth()).addClass('active'); // switch(target[0].className) {
} // case 'switch':
// this.showMode(1);
html = ''; // break;
year = parseInt(year/10, 10) * 10; // case 'prev':
var yearCont = this.picker.find('.datepicker-years') // case 'next':
.find('th:eq(1)') // this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
.text(year + '-' + (year + 9)) // this.viewDate,
.end() // this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
.find('td'); // DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1)
year -= 1; // );
for (var i = -1; i < 11; i++) { // this.fill();
html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>'; // this.set();
year += 1; // break;
} // }
yearCont.html(html); // break;
}, // case 'span':
// if (target.is('.month')) {
click: function(e) { // var month = target.parent().find('span').index(target);
e.stopPropagation(); // this.viewDate.setMonth(month);
e.preventDefault(); // } else {
var target = $(e.target).closest('span, td, th'); // var year = parseInt(target.text(), 10)||0;
if (target.length === 1) { // this.viewDate.setFullYear(year);
switch(target[0].nodeName.toLowerCase()) { // }
case 'th': // if (this.viewMode !== 0) {
switch(target[0].className) { // this.date = new Date(this.viewDate);
case 'switch': // this.element.trigger({
this.showMode(1); // type: 'changeDate',
break; // date: this.date,
case 'prev': // viewMode: DPGlobal.modes[this.viewMode].clsName
case 'next': // });
this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call( // }
this.viewDate, // this.showMode(-1);
this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) + // this.fill();
DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1) // this.set();
); // break;
this.fill(); // case 'td':
this.set(); // if (target.is('.day') && !target.is('.disabled')){
break; // var day = parseInt(target.text(), 10)||1;
} // var month = this.viewDate.getMonth();
break; // if (target.is('.old')) {
case 'span': // month -= 1;
if (target.is('.month')) { // } else if (target.is('.new')) {
var month = target.parent().find('span').index(target); // month += 1;
this.viewDate.setMonth(month); // }
} else { // var year = this.viewDate.getFullYear();
var year = parseInt(target.text(), 10)||0; // this.date = new Date(year, month, day,0,0,0,0);
this.viewDate.setFullYear(year); // this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0);
} // this.fill();
if (this.viewMode !== 0) { // this.set();
this.date = new Date(this.viewDate); // this.element.trigger({
this.element.trigger({ // type: 'changeDate',
type: 'changeDate', // date: this.date,
date: this.date, // viewMode: DPGlobal.modes[this.viewMode].clsName
viewMode: DPGlobal.modes[this.viewMode].clsName // });
}); // }
} // break;
this.showMode(-1); // }
this.fill(); // }
this.set(); // },
break; //
case 'td': // mousedown: function(e){
if (target.is('.day') && !target.is('.disabled')){ // e.stopPropagation();
var day = parseInt(target.text(), 10)||1; // e.preventDefault();
var month = this.viewDate.getMonth(); // },
if (target.is('.old')) { //
month -= 1; // showMode: function(dir) {
} else if (target.is('.new')) { // if (dir) {
month += 1; // this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
} // }
var year = this.viewDate.getFullYear(); // this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
this.date = new Date(year, month, day,0,0,0,0); // }
this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0); // };
this.fill(); //
this.set(); // $.fn.datepicker = function ( option, val ) {
this.element.trigger({ // return this.each(function () {
type: 'changeDate', // var $this = $(this),
date: this.date, // data = $this.data('datepicker'),
viewMode: DPGlobal.modes[this.viewMode].clsName // options = typeof option === 'object' && option;
}); // if (!data) {
} // $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
break; // }
} // if (typeof option === 'string') data[option](val);
} // });
}, // };
//
mousedown: function(e){ // $.fn.datepicker.defaults = {
e.stopPropagation(); // onRender: function(date) {
e.preventDefault(); // return '';
}, // }
// };
showMode: function(dir) { // $.fn.datepicker.Constructor = Datepicker;
if (dir) { //
this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir)); // var DPGlobal = {
} // modes: [
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show(); // {
} // clsName: 'days',
}; // navFnc: 'Month',
// navStep: 1
$.fn.datepicker = function ( option, val ) { // },
return this.each(function () { // {
var $this = $(this), // clsName: 'months',
data = $this.data('datepicker'), // navFnc: 'FullYear',
options = typeof option === 'object' && option; // navStep: 1
if (!data) { // },
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options)))); // {
} // clsName: 'years',
if (typeof option === 'string') data[option](val); // navFnc: 'FullYear',
}); // navStep: 10
}; // }],
// dates:{
$.fn.datepicker.defaults = { // days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
onRender: function(date) { // daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
return ''; // 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"]
$.fn.datepicker.Constructor = Datepicker; // },
// isLeapYear: function (year) {
var DPGlobal = { // return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
modes: [ // },
{ // getDaysInMonth: function (year, month) {
clsName: 'days', // return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
navFnc: 'Month', // },
navStep: 1 // parseFormat: function(format){
}, // var separator = format.match(/[.\/\-\s].*?/),
{ // parts = format.split(/\W+/);
clsName: 'months', // if (!separator || !parts || parts.length === 0){
navFnc: 'FullYear', // throw new Error("Invalid date format.");
navStep: 1 // }
}, // return {separator: separator, parts: parts};
{ // },
clsName: 'years', // parseDate: function(date, format) {
navFnc: 'FullYear', // var parts = date.split(format.separator),
navStep: 10 // date = new Date(),
}], // val;
dates:{ // date.setHours(0);
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], // date.setMinutes(0);
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], // date.setSeconds(0);
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], // date.setMilliseconds(0);
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], // if (parts.length === format.parts.length) {
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] // var year = date.getFullYear(), day = date.getDate(), month = date.getMonth();
}, // for (var i=0, cnt = format.parts.length; i < cnt; i++) {
isLeapYear: function (year) { // val = parseInt(parts[i], 10)||1;
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) // switch(format.parts[i]) {
}, // case 'dd':
getDaysInMonth: function (year, month) { // case 'd':
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] // day = val;
}, // date.setDate(val);
parseFormat: function(format){ // break;
var separator = format.match(/[.\/\-\s].*?/), // case 'mm':
parts = format.split(/\W+/); // case 'm':
if (!separator || !parts || parts.length === 0){ // month = val - 1;
throw new Error("Invalid date format."); // date.setMonth(val - 1);
} // break;
return {separator: separator, parts: parts}; // case 'yy':
}, // year = 2000 + val;
parseDate: function(date, format) { // date.setFullYear(2000 + val);
var parts = date.split(format.separator), // break;
date = new Date(), // case 'yyyy':
val; // year = val;
date.setHours(0); // date.setFullYear(val);
date.setMinutes(0); // break;
date.setSeconds(0); // }
date.setMilliseconds(0); // }
if (parts.length === format.parts.length) { // date = new Date(year, month, day, 0 ,0 ,0);
var year = date.getFullYear(), day = date.getDate(), month = date.getMonth(); // }
for (var i=0, cnt = format.parts.length; i < cnt; i++) { // return date;
val = parseInt(parts[i], 10)||1; // },
switch(format.parts[i]) { // formatDate: function(date, format){
case 'dd': // var val = {
case 'd': // d: date.getDate(),
day = val; // m: date.getMonth() + 1,
date.setDate(val); // yy: date.getFullYear().toString().substring(2),
break; // yyyy: date.getFullYear()
case 'mm': // };
case 'm': // val.dd = (val.d < 10 ? '0' : '') + val.d;
month = val - 1; // val.mm = (val.m < 10 ? '0' : '') + val.m;
date.setMonth(val - 1); // var date = [];
break; // for (var i=0, cnt = format.parts.length; i < cnt; i++) {
case 'yy': // date.push(val[format.parts[i]]);
year = 2000 + val; // }
date.setFullYear(2000 + val); // return date.join(format.separator);
break; // },
case 'yyyy': // headTemplate: '<thead>'+
year = val; // '<tr>'+
date.setFullYear(val); // '<th class="prev">&lsaquo;</th>'+
break; // '<th colspan="5" class="switch"></th>'+
} // '<th class="next">&rsaquo;</th>'+
} // '</tr>'+
date = new Date(year, month, day, 0 ,0 ,0); // '</thead>',
} // contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
return date; // };
}, // DPGlobal.template = '<div class="datepicker dropdown-menu">'+
formatDate: function(date, format){ // '<div class="datepicker-days">'+
var val = { // '<table class=" table-condensed">'+
d: date.getDate(), // DPGlobal.headTemplate+
m: date.getMonth() + 1, // '<tbody></tbody>'+
yy: date.getFullYear().toString().substring(2), // '</table>'+
yyyy: date.getFullYear() // '</div>'+
}; // '<div class="datepicker-months">'+
val.dd = (val.d < 10 ? '0' : '') + val.d; // '<table class="table-condensed">'+
val.mm = (val.m < 10 ? '0' : '') + val.m; // DPGlobal.headTemplate+
var date = []; // DPGlobal.contTemplate+
for (var i=0, cnt = format.parts.length; i < cnt; i++) { // '</table>'+
date.push(val[format.parts[i]]); // '</div>'+
} // '<div class="datepicker-years">'+
return date.join(format.separator); // '<table class="table-condensed">'+
}, // DPGlobal.headTemplate+
headTemplate: '<thead>'+ // DPGlobal.contTemplate+
'<tr>'+ // '</table>'+
'<th class="prev">&lsaquo;</th>'+ // '</div>'+
'<th colspan="5" class="switch"></th>'+ // '</div>';
'<th class="next">&rsaquo;</th>'+ //
'</tr>'+ //}( window.jQuery );
'</thead>',
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
};
DPGlobal.template = '<div class="datepicker dropdown-menu">'+
'<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>'+
'</div>';
}( window.jQuery );