|
|
|
|
(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))}function UTCToday(){var today=new Date;return UTCDate(today.getFullYear(),today.getMonth(),today.getDate())}function isUTCEquals(date1,date2){return date1.getUTCFullYear()===date2.getUTCFullYear()&&date1.getUTCMonth()===date2.getUTCMonth()&&date1.getUTCDate()===date2.getUTCDate()}function alias(method,deprecationMsg){return function(){if(deprecationMsg!==undefined){$.fn.bootstrapDatepicker.deprecated(deprecationMsg)}return this[method].apply(this,arguments)}}function isValidDate(d){return d&&!isNaN(d.getTime())}var DateArray=function(){var extras={get:function(i){return this.slice(i)[0]},contains:function(d){var val=d&&d.valueOf();for(var i=0,l=this.length;i<l;i++)if(0<=this[i].valueOf()-val&&this[i].valueOf()-val<1e3*60*60*24)return i;return-1},remove:function(i){this.splice(i,1)},replace:function(new_array){if(!new_array)return;if(!Array.isArray(new_array))new_array=[new_array];this.clear();this.push.apply(this,new_array)},clear:function(){this.length=0},copy:function(){var a=new DateArray;a.replace(this);return a}};return function(){var a=[];a.push.apply(a,arguments);$.extend(a,extras);return a}}();var Datepicker=function(element,options){$.data(element,"datepicker",this);this._events=[];this._secondaryEvents=[];this._process_options(options);this.dates=new DateArray;this.viewDate=this.o.defaultViewDate;this.focusDate=null;this.element=$(element);this.isInput=this.element.is("input");this.inputField=this.isInput?this.element:this.element.find("input");this.component=this.element.hasClass("date")?this.element.find(".add-on, .input-group-addon, .input-group-append, .input-group-prepend, .btn"):false;if(this.component&&this.component.length===0){this.component=false}if(this.o.isInline===null){this.isInline=!this.component&&!this.isInput}else{this.isInline=this.o.isInline}this.picker=$(DPGlobal.template);if(this._check_template(this.o.templates.leftArrow)){this.picker.find(".prev").html(this.o.templates.leftArrow)}if(this._check_template(this.o.templates.rightArrow)){this.picker.find(".next").html(this.o.templates.rightArrow)}this._buildEvents();this._attachEvents();if(this.isInline){this.picker.addClass("datepicker-inline").appendTo(this.element)}else{this.picker.addClass("datepicker-dropdown dropdown-menu")}if(this.o.rtl){this.picker.addClass("datepicker-rtl")}if(this.o.calendarWeeks){this.picker.find(".datepicker-days .datepicker-switch, thead .datepicker-title, tfoot .today, tfoot .clear").attr("colspan",(function(i,val){return Number(val)+1}))}this._process_options({startDate:this._o.startDate,endDate:this._o.endDate,daysOfWeekDisabled:this.o.daysOfWeekDisabled,daysOfWeekHighlighted:this.o.daysOfWeekHighlighted,datesDisabled:this.o.datesDisabled});this._allow_update=false;this.setViewMode(this.o.startView);this._allow_update=true;this.fillDow();this.fillMonths();this.update();if(this.isInline){this.show()}};Datepicker.prototype={constructor:Datepicker,_resolveViewName:function(view){$.each(DPGlobal.viewModes,(function(i,viewMode){if(view===i||$.inArray(view,viewMode.names)!==-1){view=i;return false}}));return view},_resolveDaysOfWeek:function(daysOfWeek){if(!Array.isArray(daysOfWeek))daysOfWeek=daysOfWeek.split(/[,\s]*/);return $.map(daysOfWeek,Number)},_check_template:function(tmp){try{if(tmp===undefined||tmp===""){return false}if((tmp.match(/[<>]/g)||[]).length<=0){return true}var jDom=$(tmp);return jDom.length>0}catch(ex){return false}},_process_options:function(opts){this._o=$.extend({},this._o,opts);var o=this.o=$.extend({},this._o);var lang=o.language;if(!dates[lang]){lang=lang.split("-")[0];if(!dates[lang])lang=defaults.language}o.language=lang;o.startView=this._resolveViewName(o.startView);o.minViewMode=this._resolveViewName(o.minViewMode);o.maxViewMode=this._resolveViewName(o.maxViewMode);o.startView=Math.max(this.o.minViewMode,Math.min(this.o.max
|