/* ========================================================= * bootstrap-datepicker.js * http://www.eyecon.ro/bootstrap-datepicker * ========================================================= * Copyright 2012 Stefan Petre * Improvements by Andrew Rowls * * 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(e){var m=function(a,b){this.element=e(a);this.language=b.language||this.element.data("date-language")||"en";this.language=this.language in l?this.language:"en";this.format=g.parseFormat(b.format||this.element.data("date-format")||"mm/dd/yyyy");this.picker=e(g.template).appendTo("body").on({click:e.proxy(this.click,this),mousedown:e.proxy(this.mousedown,this)});this.isInput=this.element.is("input");if((this.component=this.element.is(".date")?this.element.find(".add-on"):!1)&&0===this.component.length)this.component= !1;if(this.isInput)this.element.on({focus:e.proxy(this.show,this),blur:e.proxy(this._hide,this),keyup:e.proxy(this.update,this),keydown:e.proxy(this.keydown,this)});else if(this.component)this.component.on("click",e.proxy(this.show,this)),a=this.element.find("input"),a.on({blur:e.proxy(this._hide,this)});else this.element.on("click",e.proxy(this.show,this));this.autoclose=!1;"autoclose"in b?this.autoclose=b.autoclose:"dateAutoclose"in this.element.data()&&(this.autoclose=this.element.data("date-autoclose")); switch(b.startView){case 2:case "decade":this.viewMode=this.startViewMode=2;break;case 1:case "year":this.viewMode=this.startViewMode=1;break;default:this.viewMode=this.startViewMode=0}this.weekStart=(b.weekStart||this.element.data("date-weekstart")||l[this.language].weekStart||0)%7;this.weekEnd=(this.weekStart+6)%7;this.startDate=-Infinity;this.endDate=Infinity;this.setStartDate(b.startDate||this.element.data("date-startdate"));this.setEndDate(b.endDate||this.element.data("date-enddate"));this.fillDow(); this.fillMonths();this.update();this.showMode()};m.prototype={constructor:m,show:function(a){this.picker.show();this.height=this.component?this.component.outerHeight():this.element.outerHeight();this.place();e(window).on("resize",e.proxy(this.place,this));a&&(a.stopPropagation(),a.preventDefault());if(!this.isInput)e(document).on("mousedown",e.proxy(this.hide,this));this.element.trigger({type:"show",date:this.date})},_hide:function(a){if(e.browser.msie){var b=this,c=arguments,f=function(){clearTimeout(j); a.target.focus();b.picker.off("click",f)};this.picker.on("click",f);var j=setTimeout(function(){b.hide.apply(b,c);b.picker.off("click",f)},100)}else return this.hide.apply(this,arguments)},hide:function(a){this.picker.hide();e(window).off("resize",this.place);this.viewMode=this.startViewMode;this.showMode();this.isInput||e(document).off("mousedown",this.hide);a&&a.currentTarget.value&&this.setValue();this.element.trigger({type:"hide",date:this.date})},setValue:function(){var a=g.formatDate(this.date, this.format,this.language);this.isInput?this.element.prop("value",a):(this.component&&this.element.find("input").prop("value",a),this.element.data("date",a))},setStartDate:function(a){this.startDate=a||-Infinity;-Infinity!==this.startDate&&(this.startDate=g.parseDate(this.startDate,this.format,this.language));this.update();this.updateNavArrows()},setEndDate:function(a){this.endDate=a||Infinity;Infinity!==this.endDate&&(this.endDate=g.parseDate(this.endDate,this.format,this.language));this.update(); this.updateNavArrows()},place:function(){var a=this.component?this.component.offset():this.element.offset(),b=e(window).width()-a.left,c=this.component?this.component.outerWidth():0;208>b?this.picker.addClass("dp_right").css({top:a.top+this.height,right:b-c,left:"auto"}):this.picker.css({top:a.top+this.height,left:a.left})},update:function(){this.date=g.parseDate(this.isInput?this.element.prop("value"):this.element.data("date"),this.format,this.language);this.viewDate=this.datethis.endDate?new Date(this.endDate):new Date(this.date);this.fill()},fillDow:function(){for(var a=this.weekStart,b="";a'+l[this.language].daysMin[a++%7]+"";this.picker.find(".datepicker-days thead").append(b+"")},fillMonths:function(){for(var a="",b=0;12>b;)a+=''+l[this.language].monthsShort[b++]+"";this.picker.find(".datepicker-months td").html(a)},fill:function(){var a=new Date(this.viewDate),b=a.getFullYear(), c=a.getMonth(),a=-Infinity!==this.startDate?this.startDate.getFullYear():-Infinity,f=-Infinity!==this.startDate?this.startDate.getMonth():-Infinity,e=Infinity!==this.endDate?this.endDate.getFullYear():Infinity,i=Infinity!==this.endDate?this.endDate.getMonth():Infinity,h=this.date.valueOf();this.picker.find(".datepicker-days th:eq(1)").text(l[this.language].months[c]+" "+b);this.updateNavArrows();this.fillMonths();var d=new Date(b,c-1,28,0,0,0,0),n=g.getDaysInMonth(d.getFullYear(),d.getMonth());d.setDate(n); d.setDate(n-(d.getDay()-this.weekStart+7)%7);n=new Date(d);n.setDate(n.getDate()+42);n=n.valueOf();html=[];for(var k;d.valueOf()");k="";if(d.getFullYear()b||d.getFullYear()==b&&d.getMonth()>c)k+=" new";d.valueOf()==h&&(k+=" active");if(d.valueOf()this.endDate)k+=" disabled";html.push(''+d.getDate()+"");d.getDay()==this.weekEnd&& html.push("");d.setDate(d.getDate()+1)}this.picker.find(".datepicker-days tbody").empty().append(html.join(""));c=this.date.getFullYear();h=this.picker.find(".datepicker-months").find("th:eq(1)").text(b).end().find("span").removeClass("active");c==b&&h.eq(this.date.getMonth()).addClass("active");(be)&&h.addClass("disabled");b==a&&h.slice(0,f).addClass("disabled");b==e&&h.slice(i+1).addClass("disabled");html="";b=10*parseInt(b/10,10);f=this.picker.find(".datepicker-years").find("th:eq(1)").text(b+ "-"+(b+9)).end().find("td");b-=1;for(i=-1;11>i;i++)html+='e?" disabled":"")+'">'+b+"",b+=1;f.html(html)},updateNavArrows:function(){var a=new Date(this.viewDate),b=a.getFullYear(),a=a.getMonth();switch(this.viewMode){case 0:-Infinity!==this.startDate&&b<=this.startDate.getFullYear()&&a<=this.startDate.getMonth()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"});Infinity!== this.endDate&&b>=this.endDate.getFullYear()&&a>=this.endDate.getMonth()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 1:case 2:-Infinity!==this.startDate&&b<=this.startDate.getFullYear()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),Infinity!==this.endDate&&b>=this.endDate.getFullYear()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"})}}, click:function(a){a.stopPropagation();a.preventDefault();a=e(a.target).closest("span, td, th");if(1==a.length)switch(a[0].nodeName.toLowerCase()){case "th":switch(a[0].className){case "switch":this.showMode(1);break;case "prev":case "next":var b=g.modes[this.viewMode].navStep*("prev"==a[0].className?-1:1);switch(this.viewMode){case 0:this.viewDate=this.moveMonth(this.viewDate,b);break;case 1:case 2:this.viewDate=this.moveYear(this.viewDate,b)}this.fill()}break;case "span":if(!a.is(".disabled")){if(a.is(".month")){var c= a.parent().find("span").index(a);this.viewDate.setMonth(c)}else{var f=parseInt(a.text(),10)||0;this.viewDate.setFullYear(f)}this.showMode(-1);this.fill()}break;case "td":if(a.is(".day")&&!a.is(".disabled")){var j=parseInt(a.text(),10)||1,f=this.viewDate.getFullYear(),c=this.viewDate.getMonth();a.is(".old")?0==c?(c=11,f-=1):c-=1:a.is(".new")&&(11==c?(c=0,f+=1):c+=1);this.date=new Date(f,c,j,0,0,0,0);this.viewDate=new Date(f,c,j,0,0,0,0);this.fill();this.setValue();this.element.trigger({type:"changeDate", date:this.date});this.isInput?b=this.element:this.component&&(b=this.element.find("input"));b&&(b.change(),this.autoclose&&b.blur())}}},mousedown:function(a){a.stopPropagation();a.preventDefault()},moveMonth:function(a,b){if(!b)return a;var c=new Date(a.valueOf()),e=c.getDate(),j=c.getMonth(),i=Math.abs(b),h,b=0h||11div").hide().filter(".datepicker-"+g.modes[this.viewMode].clsName).show();this.updateNavArrows()}};e.fn.datepicker=function(a){var b=Array.apply(null, arguments);b.shift();return this.each(function(){var c=e(this),f=c.data("datepicker"),j="object"==typeof a&&a;f||c.data("datepicker",f=new m(this,e.extend({},e.fn.datepicker.defaults,j)));"string"==typeof a&&f[a].apply(f,b)})};e.fn.datepicker.defaults={};e.fn.datepicker.Constructor=m;var l=e.fn.datepicker.dates={en:{days:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),daysShort:"Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),daysMin:"Su Mo Tu We Th Fr Sa Su".split(" "),months:"January February March April May June July August September October November December".split(" "), monthsShort:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")}},g={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],isLeapYear:function(a){return 0===a%4&&0!==a%100||0===a%400},getDaysInMonth:function(a,b){return[31,g.isLeapYear(a)?29:28,31,30,31,30,31,31,30,31,30,31][b]},validParts:/dd?|mm?|MM?|yy(?:yy)?/g,nonpunctuation:/[^ -\/:-@\[-`{-~\t\n\r]+/g,parseFormat:function(a){var b=a.replace(this.validParts, "\x00").split("\x00"),a=a.match(this.validParts);if(!b||!b.length||!a||0==a.length)throw Error("Invalid date format.");return{separators:b,parts:a}},parseDate:function(a,b,c){if(a instanceof Date)return a;if(/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(a)){for(var f=/([-+]\d+)([dmwy])/,j=a.match(/([-+]\d+)([dmwy])/g),i,h,a=new Date,d=0;dc.d?"0":"")+c.d;c.mm=(10>c.m?"0":"")+c.m;for(var a=[],f=e.extend([],b.separators),g=0,i=b.parts.length;g',contTemplate:''}; g.template='"}(window.jQuery);