From 0007e57b118cee24aba27e1d6fc33c0659348024 Mon Sep 17 00:00:00 2001 From: Eonasdan Date: Wed, 29 Jan 2014 14:11:37 +0000 Subject: [PATCH] hotfix for #140 and #151 --- README.md | 5 +++++ bower.json | 2 +- build/js/bootstrap-datetimepicker.min.js | 4 ++-- component.json | 2 +- package.json | 2 +- src/js/bootstrap-datetimepicker.js | 15 ++++++++------- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2178351d4..e3b7a020a 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,11 @@ Finally include the main javascript file. # Change Log +## 2.1.32 (Hotfix) + +* Fix for #151: When a bad date value or the picker is cleared, the plugin will not longer attempt to reset it back to the previous date +* Fix for #140: `setDate` can be given `null` to force clear the picker + ## 2.1.30 #### Important! `build.less` file name has been been changed to `bootstrap-datetimepicker-build.less` to prevent collisions diff --git a/bower.json b/bower.json index 56eebb7c6..bd8d69dae 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "eonasdan-bootstrap-datetimepicker", - "version": "2.2.20", + "version": "2.2.22", "main": [ "build/css/bootstrap-datetimepicker.min.css", "build/js/bootstrap-datetimepicker.min.js" diff --git a/build/js/bootstrap-datetimepicker.min.js b/build/js/bootstrap-datetimepicker.min.js index 124a75fef..f8471ab3b 100644 --- a/build/js/bootstrap-datetimepicker.min.js +++ b/build/js/bootstrap-datetimepicker.min.js @@ -1,5 +1,5 @@ /** - * version 2.1.30 + * version 2.1.32 * @license * ========================================================= * bootstrap-datetimepicker.js @@ -25,4 +25,4 @@ * limitations under the License. * ========================================================= */ -(function(a){if(typeof define==="function"&&define.amd){define(["jquery","moment"],a)}else{if(!jQuery){throw"bootstrap-datetimepicker requires jQuery to be loaded first"}else{if(!moment){throw"bootstrap-datetimepicker requires moment.js to be loaded first"}else{a(jQuery,moment)}}}}(function(d,e){if(typeof e==="undefined"){alert("momentjs is requried");throw new Error("momentjs is required")}var c=0,a=e,b=function(o,q){var z={pickDate:true,pickTime:true,useMinutes:true,useSeconds:false,minuteStepping:1,startDate:new a({y:1970}),endDate:new a().add(50,"y"),collapse:true,language:a.lang(),defaultDate:"",disabledDates:[],enabledDates:false,icons:{},useStrict:false,direction:"auto"},M={time:"glyphicon glyphicon-time",date:"glyphicon glyphicon-calendar",up:"glyphicon glyphicon-chevron-up",down:"glyphicon glyphicon-chevron-down"},l=this,I=function(){var S=false,R,T,Q;l.options=d.extend({},z,q);l.options.icons=d.extend({},M,l.options.icons);l.element=d(o);f();if(!(l.options.pickTime||l.options.pickDate)){throw new Error("Must choose at least one picker")}l.id=c++;a.lang(l.options.language);l.date=a();l.unset=false;l.isInput=l.element.is("input");l.component=false;if(l.element.hasClass("input-group")){if(l.element.find(".datepickerbutton").size()==0){l.component=l.element.find("[class^='input-group-']")}else{l.component=l.element.find(".datepickerbutton")}}l.format=l.options.format;Q=a()._lang._longDateFormat;if(!l.format){if(l.isInput){l.format=l.element.data("format")}else{l.format=l.element.find("input").data("format")}if(!l.format){l.format=(l.options.pickDate?Q.L:"");if(l.options.pickDate&&l.options.pickTime){l.format+=" "}l.format+=(l.options.pickTime?Q.LT:"");if(l.options.useSeconds){if(~Q.LT.indexOf(" A")){l.format=l.format.split(" A")[0]+":ss A"}else{l.format+=":ss"}}}}l.options.use24hours=l.format.toLowerCase().indexOf("a")<1;if(l.component){S=l.component.find("span")}if(l.options.pickTime){if(S){S.addClass(l.options.icons.time)}}if(l.options.pickDate){if(S){S.removeClass(l.options.icons.time);S.addClass(l.options.icons.date)}}l.widget=d(P(l.options.pickDate,l.options.pickTime,l.options.collapse)).appendTo("body");l.minViewMode=l.options.minViewMode||l.element.data("date-minviewmode")||0;if(typeof l.minViewMode==="string"){switch(l.minViewMode){case"months":l.minViewMode=1;break;case"years":l.minViewMode=2;break;default:l.minViewMode=0;break}}l.viewMode=l.options.viewMode||l.element.data("date-viewmode")||0;if(typeof l.viewMode==="string"){switch(l.viewMode){case"months":l.viewMode=1;break;case"years":l.viewMode=2;break;default:l.viewMode=0;break}}for(R=0;R"),Q=a.weekdaysMin(),R;if(a()._lang._week.dow==0){for(R=0;R<7;R++){S.append(''+Q[R]+"")}}else{for(R=1;R<8;R++){if(R==7){S.append(''+Q[0]+"")}else{S.append(''+Q[R]+"")}}}l.widget.find(".datepicker-days thead").append(S)},u=function(){a.lang(l.options.language);var R="",Q=0,S=a.monthsShort();while(Q<12){R+=''+S[Q++]+""}l.widget.find(".datepicker-months td").append(R)},n=function(){a.lang(l.options.language);var ab=l.viewDate.year(),Z=l.viewDate.month(),aa=l.options.startDate.year(),ad=l.options.startDate.month(),ae=l.options.endDate.year(),X=l.options.endDate.month(),T,W,V=[],af,S,U,ac,R,Y,Q=a.months();l.widget.find(".datepicker-days").find(".disabled").removeClass("disabled");l.widget.find(".datepicker-months").find(".disabled").removeClass("disabled");l.widget.find(".datepicker-years").find(".disabled").removeClass("disabled");l.widget.find(".datepicker-days th:eq(1)").text(Q[Z]+" "+ab);T=a(l.viewDate).subtract("months",1);ac=T.daysInMonth();T.date(ac).startOf("week");if((ab==aa&&Z<=ad)||ab=X)||ab>ae){l.widget.find(".datepicker-days th:eq(2)").addClass("disabled")}W=a(T).add(42,"d");while(T.isBefore(W)){if(T.weekday()===a().startOf("week").weekday()){af=d("");V.push(af)}S="";if(T.year()ab||(T.year()==ab&&T.month()>Z)){S+=" new"}}if(T.isSame(a({y:l.date.year(),M:l.date.month(),d:l.date.date()}))){S+=" active"}if(O(T)||!s(T)){S+=" disabled"}af.append(''+T.date()+"");T.add(1,"d")}l.widget.find(".datepicker-days tbody").empty().append(V);Y=a().year(),Q=l.widget.find(".datepicker-months").find("th:eq(1)").text(ab).end().find("span").removeClass("active");if(Y===ab){Q.eq(a().month()).addClass("active")}if(Y-1ae){l.widget.find(".datepicker-months th:eq(2)").addClass("disabled")}for(U=0;U<12;U++){if((ab==aa&&ad>U)||(abae)){d(Q[U]).addClass("disabled")}}}V="";ab=parseInt(ab/10,10)*10;R=l.widget.find(".datepicker-years").find("th:eq(1)").text(ab+"-"+(ab+9)).end().find("td");l.widget.find(".datepicker-years").find("th").removeClass("disabled");if(aa>ab){l.widget.find(".datepicker-years").find("th:eq(0)").addClass("disabled")}if(aeae)?" disabled":"")+'">'+ab+"";ab+=1}R.html(V)},v=function(){a.lang(l.options.language);var T=l.widget.find(".timepicker .timepicker-hours table"),S="",U,R,Q;T.parent().hide();if(l.options.use24hours){U=0;for(R=0;R<6;R+=1){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U++}S+=""}}else{U=1;for(R=0;R<3;R+=1){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U++}S+=""}}T.html(S)},t=function(){var T=l.widget.find(".timepicker .timepicker-minutes table"),S="",U=0,R,Q;T.parent().hide();for(R=0;R<5;R++){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U+=3}S+=""}T.html(S)},h=function(){var T=l.widget.find(".timepicker .timepicker-seconds table"),S="",U=0,R,Q;T.parent().hide();for(R=0;R<5;R++){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U+=3}S+=""}T.html(S)},k=function(){if(!l.date){return}var S=l.widget.find(".timepicker span[data-time-component]"),Q=l.date.hours(),R="AM";if(!l.options.use24hours){if(Q>=12){R="PM"}if(Q===0){Q=12}else{if(Q!=12){Q=Q%12}}l.widget.find(".timepicker [data-action=togglePeriod]").text(R)}S.filter("[data-time-component=hours]").text(N(Q));S.filter("[data-time-component=minutes]").text(N(l.date.minutes()));S.filter("[data-time-component=seconds]").text(N(l.date.second()))},A=function(W){W.stopPropagation();W.preventDefault();l.unset=false;var V=d(W.target).closest("span, td, th"),U,S,T,Q,R=a(l.date);if(V.length===1){if(!V.is(".disabled")){switch(V[0].nodeName.toLowerCase()){case"th":switch(V[0].className){case"switch":g(1);break;case"prev":case"next":T=w.modes[l.viewMode].navStep;if(V[0].className==="prev"){T=T*-1}l.viewDate.add(T,w.modes[l.viewMode].navFnc);n();break}break;case"span":if(V.is(".month")){U=V.parent().find("span").index(V);l.viewDate.month(U)}else{S=parseInt(V.text(),10)||0;l.viewDate.year(S)}if(l.viewMode!==0){l.date=a({y:l.viewDate.year(),M:l.viewDate.month(),d:l.viewDate.date(),h:l.date.hours(),m:l.date.minutes()});p(R,W.type)}g(-1);n();break;case"td":if(V.is(".day")){Q=parseInt(V.text(),10)||1;U=l.viewDate.month();S=l.viewDate.year();if(V.is(".old")){if(U===0){U=11;S-=1}else{U-=1}}else{if(V.is(".new")){if(U==11){U=0;S+=1}else{U+=1}}}l.date=a({y:S,M:U,d:Q,h:l.date.hours(),m:l.date.minutes()});l.viewDate=a({y:S,M:U,d:Math.min(28,Q)});n();r();p(R,W.type)}break}}}},D={incrementHours:function(){m("add","hours",1)},incrementMinutes:function(){m("add","minutes",l.options.minuteStepping)},incrementSeconds:function(){m("add","seconds",1)},decrementHours:function(){m("subtract","hours",1)},decrementMinutes:function(){m("subtract","minutes",l.options.minuteStepping)},decrementSeconds:function(){m("subtract","seconds",1)},togglePeriod:function(){var Q=l.date.hours();if(Q>=12){Q-=12}else{Q+=12}l.date.hours(Q)},showPicker:function(){l.widget.find(".timepicker > div:not(.timepicker-picker)").hide();l.widget.find(".timepicker .timepicker-picker").show()},showHours:function(){l.widget.find(".timepicker .timepicker-picker").hide();l.widget.find(".timepicker .timepicker-hours").show()},showMinutes:function(){l.widget.find(".timepicker .timepicker-picker").hide();l.widget.find(".timepicker .timepicker-minutes").show()},showSeconds:function(){l.widget.find(".timepicker .timepicker-picker").hide();l.widget.find(".timepicker .timepicker-seconds").show()},selectHour:function(Q){l.date.hours(parseInt(d(Q.target).text(),10));D.showPicker.call(l)},selectMinute:function(Q){l.date.minutes(parseInt(d(Q.target).text(),10));D.showPicker.call(l)},selectSecond:function(Q){l.date.seconds(parseInt(d(Q.target).text(),10));D.showPicker.call(l)}},x=function(S){var Q=a(l.date),R=d(S.currentTarget).data("action"),T=D[R].apply(l,arguments);K(S);if(!l.date){l.date=a({y:1970})}r();k();p(Q,S.type);return T},K=function(Q){Q.stopPropagation();Q.preventDefault()},i=function(T){a.lang(l.options.language);var R=d(T.target),S=a(l.date),Q=a(R.val(),l.format,l.options.useStrict);if(Q.isValid()&&!O(Q)&&s(Q)){y();l.setValue(Q);p(S,T.type);r()}else{l.viewDate=S;R.val(a(S).format(l.format));p(S,T.type);C(Q);l.unset=true}},g=function(Q){if(Q){l.viewMode=Math.max(l.minViewMode,Math.min(2,l.viewMode+Q))}l.widget.find(".datepicker > div").hide().filter(".datepicker-"+w.modes[l.viewMode].clsName).show()},J=function(){var U,T,R,Q,S;l.widget.on("click",".datepicker *",d.proxy(A,this));l.widget.on("click","[data-action]",d.proxy(x,this));l.widget.on("mousedown",d.proxy(K,this));if(l.options.pickDate&&l.options.pickTime){l.widget.on("click.togglePicker",".accordion-toggle",function(V){V.stopPropagation();U=d(this);T=U.closest("ul");R=T.find(".in");Q=T.find(".collapse:not(.in)");if(R&&R.length){S=R.data("collapse");if(S&&S.transitioning){return}R.collapse("hide");Q.collapse("show");U.find("span").toggleClass(l.options.icons.time+" "+l.options.icons.date);l.element.find(".input-group-addon span").toggleClass(l.options.icons.time+" "+l.options.icons.date)}})}if(l.isInput){l.element.on({focus:d.proxy(l.show,this),change:d.proxy(i,this),blur:d.proxy(l.hide,this)})}else{l.element.on({change:d.proxy(i,this)},"input");if(l.component){l.component.on("click",d.proxy(l.show,this))}else{l.element.on("click",d.proxy(l.show,this))}}},L=function(){d(window).on("resize.datetimepicker"+l.id,d.proxy(j,this));if(!l.isInput){d(document).on("mousedown.datetimepicker"+l.id,d.proxy(l.hide,this))}},F=function(){l.widget.off("click",".datepicker *",l.click);l.widget.off("click","[data-action]");l.widget.off("mousedown",l.stopEvent);if(l.options.pickDate&&l.options.pickTime){l.widget.off("click.togglePicker")}if(l.isInput){l.element.off({focus:l.show,change:l.change})}else{l.element.off({change:l.change},"input");if(l.component){l.component.off("click",l.show)}else{l.element.off("click",l.show)}}},E=function(){d(window).off("resize.datetimepicker"+l.id);if(!l.isInput){d(document).off("mousedown.datetimepicker"+l.id)}},B=function(){if(l.element){var R=l.element.parents(),Q=false,S;for(S=0;S=2){return Q}else{return"0"+Q}},P=function(R,Q,S){if(R&&Q){return('")}else{if(Q){return('")}else{return('")}}},w={modes:[{clsName:"days",navFnc:"month",navStep:1},{clsName:"months",navFnc:"year",navStep:1},{clsName:"years",navFnc:"year",navStep:10}],headTemplate:'‹›',contTemplate:''},G={hourTemplate:'',minuteTemplate:'',secondTemplate:''};w.template='
'+w.headTemplate+'
'+w.headTemplate+w.contTemplate+'
'+w.headTemplate+w.contTemplate+"
";G.getTemplate=function(){return('
"+(l.options.useSeconds?'':"")+(l.options.use24hours?"":'')+" "+(l.options.useSeconds?'":"")+(l.options.use24hours?"":'')+'"+(l.options.useSeconds?'':"")+(l.options.use24hours?"":'')+'
'+(l.options.useMinutes?'':"")+"
"+G.hourTemplate+' :'+(l.options.useMinutes?G.minuteTemplate:'00')+":'+G.secondTemplate+"
'+(l.options.useMinutes?'':"")+"
'+(l.options.useSeconds?'
':""))};l.destroy=function(){F();E();l.widget.remove();l.element.removeData("DateTimePicker");if(l.component){l.component.removeData("DateTimePicker")}};l.show=function(Q){l.widget.show();l.height=l.component?l.component.outerHeight():l.element.outerHeight();j();l.element.trigger({type:"show.dp",date:a(l.date)});L();if(Q){K(Q)}},l.disable=function(){var Q=l.element.find("input");if(Q.prop("disabled")){return}Q.prop("disabled",true);F()},l.enable=function(){var Q=l.element.find("input");if(!Q.prop("disabled")){return}Q.prop("disabled",false);J()},l.hide=function(S){if(S&&d(S.target).is(l.element.attr("id"))){return}var T=l.widget.find(".collapse"),Q,R;for(Q=0;Q"),Q=a.weekdaysMin(),R;if(a()._lang._week.dow==0){for(R=0;R<7;R++){S.append(''+Q[R]+"")}}else{for(R=1;R<8;R++){if(R==7){S.append(''+Q[0]+"")}else{S.append(''+Q[R]+"")}}}l.widget.find(".datepicker-days thead").append(S)},u=function(){a.lang(l.options.language);var R="",Q=0,S=a.monthsShort();while(Q<12){R+=''+S[Q++]+""}l.widget.find(".datepicker-months td").append(R)},n=function(){a.lang(l.options.language);var ab=l.viewDate.year(),Z=l.viewDate.month(),aa=l.options.startDate.year(),ad=l.options.startDate.month(),ae=l.options.endDate.year(),X=l.options.endDate.month(),T,W,V=[],af,S,U,ac,R,Y,Q=a.months();l.widget.find(".datepicker-days").find(".disabled").removeClass("disabled");l.widget.find(".datepicker-months").find(".disabled").removeClass("disabled");l.widget.find(".datepicker-years").find(".disabled").removeClass("disabled");l.widget.find(".datepicker-days th:eq(1)").text(Q[Z]+" "+ab);T=a(l.viewDate).subtract("months",1);ac=T.daysInMonth();T.date(ac).startOf("week");if((ab==aa&&Z<=ad)||ab=X)||ab>ae){l.widget.find(".datepicker-days th:eq(2)").addClass("disabled")}W=a(T).add(42,"d");while(T.isBefore(W)){if(T.weekday()===a().startOf("week").weekday()){af=d("");V.push(af)}S="";if(T.year()ab||(T.year()==ab&&T.month()>Z)){S+=" new"}}if(T.isSame(a({y:l.date.year(),M:l.date.month(),d:l.date.date()}))){S+=" active"}if(O(T)||!s(T)){S+=" disabled"}af.append(''+T.date()+"");T.add(1,"d")}l.widget.find(".datepicker-days tbody").empty().append(V);Y=a().year(),Q=l.widget.find(".datepicker-months").find("th:eq(1)").text(ab).end().find("span").removeClass("active");if(Y===ab){Q.eq(a().month()).addClass("active")}if(Y-1ae){l.widget.find(".datepicker-months th:eq(2)").addClass("disabled")}for(U=0;U<12;U++){if((ab==aa&&ad>U)||(abae)){d(Q[U]).addClass("disabled")}}}V="";ab=parseInt(ab/10,10)*10;R=l.widget.find(".datepicker-years").find("th:eq(1)").text(ab+"-"+(ab+9)).end().find("td");l.widget.find(".datepicker-years").find("th").removeClass("disabled");if(aa>ab){l.widget.find(".datepicker-years").find("th:eq(0)").addClass("disabled")}if(aeae)?" disabled":"")+'">'+ab+"";ab+=1}R.html(V)},v=function(){a.lang(l.options.language);var T=l.widget.find(".timepicker .timepicker-hours table"),S="",U,R,Q;T.parent().hide();if(l.options.use24hours){U=0;for(R=0;R<6;R+=1){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U++}S+=""}}else{U=1;for(R=0;R<3;R+=1){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U++}S+=""}}T.html(S)},t=function(){var T=l.widget.find(".timepicker .timepicker-minutes table"),S="",U=0,R,Q;T.parent().hide();for(R=0;R<5;R++){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U+=3}S+=""}T.html(S)},h=function(){var T=l.widget.find(".timepicker .timepicker-seconds table"),S="",U=0,R,Q;T.parent().hide();for(R=0;R<5;R++){S+="";for(Q=0;Q<4;Q+=1){S+=''+N(U.toString())+"";U+=3}S+=""}T.html(S)},k=function(){if(!l.date){return}var S=l.widget.find(".timepicker span[data-time-component]"),Q=l.date.hours(),R="AM";if(!l.options.use24hours){if(Q>=12){R="PM"}if(Q===0){Q=12}else{if(Q!=12){Q=Q%12}}l.widget.find(".timepicker [data-action=togglePeriod]").text(R)}S.filter("[data-time-component=hours]").text(N(Q));S.filter("[data-time-component=minutes]").text(N(l.date.minutes()));S.filter("[data-time-component=seconds]").text(N(l.date.second()))},A=function(W){W.stopPropagation();W.preventDefault();l.unset=false;var V=d(W.target).closest("span, td, th"),U,S,T,Q,R=a(l.date);if(V.length===1){if(!V.is(".disabled")){switch(V[0].nodeName.toLowerCase()){case"th":switch(V[0].className){case"switch":g(1);break;case"prev":case"next":T=w.modes[l.viewMode].navStep;if(V[0].className==="prev"){T=T*-1}l.viewDate.add(T,w.modes[l.viewMode].navFnc);n();break}break;case"span":if(V.is(".month")){U=V.parent().find("span").index(V);l.viewDate.month(U)}else{S=parseInt(V.text(),10)||0;l.viewDate.year(S)}if(l.viewMode!==0){l.date=a({y:l.viewDate.year(),M:l.viewDate.month(),d:l.viewDate.date(),h:l.date.hours(),m:l.date.minutes()});p(R,W.type)}g(-1);n();break;case"td":if(V.is(".day")){Q=parseInt(V.text(),10)||1;U=l.viewDate.month();S=l.viewDate.year();if(V.is(".old")){if(U===0){U=11;S-=1}else{U-=1}}else{if(V.is(".new")){if(U==11){U=0;S+=1}else{U+=1}}}l.date=a({y:S,M:U,d:Q,h:l.date.hours(),m:l.date.minutes()});l.viewDate=a({y:S,M:U,d:Math.min(28,Q)});n();r();p(R,W.type)}break}}}},D={incrementHours:function(){m("add","hours",1)},incrementMinutes:function(){m("add","minutes",l.options.minuteStepping)},incrementSeconds:function(){m("add","seconds",1)},decrementHours:function(){m("subtract","hours",1)},decrementMinutes:function(){m("subtract","minutes",l.options.minuteStepping)},decrementSeconds:function(){m("subtract","seconds",1)},togglePeriod:function(){var Q=l.date.hours();if(Q>=12){Q-=12}else{Q+=12}l.date.hours(Q)},showPicker:function(){l.widget.find(".timepicker > div:not(.timepicker-picker)").hide();l.widget.find(".timepicker .timepicker-picker").show()},showHours:function(){l.widget.find(".timepicker .timepicker-picker").hide();l.widget.find(".timepicker .timepicker-hours").show()},showMinutes:function(){l.widget.find(".timepicker .timepicker-picker").hide();l.widget.find(".timepicker .timepicker-minutes").show()},showSeconds:function(){l.widget.find(".timepicker .timepicker-picker").hide();l.widget.find(".timepicker .timepicker-seconds").show()},selectHour:function(Q){l.date.hours(parseInt(d(Q.target).text(),10));D.showPicker.call(l)},selectMinute:function(Q){l.date.minutes(parseInt(d(Q.target).text(),10));D.showPicker.call(l)},selectSecond:function(Q){l.date.seconds(parseInt(d(Q.target).text(),10));D.showPicker.call(l)}},x=function(S){var Q=a(l.date),R=d(S.currentTarget).data("action"),T=D[R].apply(l,arguments);K(S);if(!l.date){l.date=a({y:1970})}r();k();p(Q,S.type);return T},K=function(Q){Q.stopPropagation();Q.preventDefault()},i=function(T){a.lang(l.options.language);var R=d(T.target),S=a(l.date),Q=a(R.val(),l.format,l.options.useStrict);if(Q.isValid()&&!O(Q)&&s(Q)){y();l.setValue(Q);p(S,T.type);r()}else{l.viewDate=S;p(S,T.type);C(Q);l.unset=true}},g=function(Q){if(Q){l.viewMode=Math.max(l.minViewMode,Math.min(2,l.viewMode+Q))}l.widget.find(".datepicker > div").hide().filter(".datepicker-"+w.modes[l.viewMode].clsName).show()},J=function(){var U,T,R,Q,S;l.widget.on("click",".datepicker *",d.proxy(A,this));l.widget.on("click","[data-action]",d.proxy(x,this));l.widget.on("mousedown",d.proxy(K,this));if(l.options.pickDate&&l.options.pickTime){l.widget.on("click.togglePicker",".accordion-toggle",function(V){V.stopPropagation();U=d(this);T=U.closest("ul");R=T.find(".in");Q=T.find(".collapse:not(.in)");if(R&&R.length){S=R.data("collapse");if(S&&S.transitioning){return}R.collapse("hide");Q.collapse("show");U.find("span").toggleClass(l.options.icons.time+" "+l.options.icons.date);l.element.find(".input-group-addon span").toggleClass(l.options.icons.time+" "+l.options.icons.date)}})}if(l.isInput){l.element.on({focus:d.proxy(l.show,this),change:d.proxy(i,this),blur:d.proxy(l.hide,this)})}else{l.element.on({change:d.proxy(i,this)},"input");if(l.component){l.component.on("click",d.proxy(l.show,this))}else{l.element.on("click",d.proxy(l.show,this))}}},L=function(){d(window).on("resize.datetimepicker"+l.id,d.proxy(j,this));if(!l.isInput){d(document).on("mousedown.datetimepicker"+l.id,d.proxy(l.hide,this))}},F=function(){l.widget.off("click",".datepicker *",l.click);l.widget.off("click","[data-action]");l.widget.off("mousedown",l.stopEvent);if(l.options.pickDate&&l.options.pickTime){l.widget.off("click.togglePicker")}if(l.isInput){l.element.off({focus:l.show,change:l.change})}else{l.element.off({change:l.change},"input");if(l.component){l.component.off("click",l.show)}else{l.element.off("click",l.show)}}},E=function(){d(window).off("resize.datetimepicker"+l.id);if(!l.isInput){d(document).off("mousedown.datetimepicker"+l.id)}},B=function(){if(l.element){var R=l.element.parents(),Q=false,S;for(S=0;S=2){return Q}else{return"0"+Q}},P=function(R,Q,S){if(R&&Q){return('")}else{if(Q){return('")}else{return('")}}},w={modes:[{clsName:"days",navFnc:"month",navStep:1},{clsName:"months",navFnc:"year",navStep:1},{clsName:"years",navFnc:"year",navStep:10}],headTemplate:'‹›',contTemplate:''},G={hourTemplate:'',minuteTemplate:'',secondTemplate:''};w.template='
'+w.headTemplate+'
'+w.headTemplate+w.contTemplate+'
'+w.headTemplate+w.contTemplate+"
";G.getTemplate=function(){return('
"+(l.options.useSeconds?'':"")+(l.options.use24hours?"":'')+" "+(l.options.useSeconds?'":"")+(l.options.use24hours?"":'')+'"+(l.options.useSeconds?'':"")+(l.options.use24hours?"":'')+'
'+(l.options.useMinutes?'':"")+"
"+G.hourTemplate+' :'+(l.options.useMinutes?G.minuteTemplate:'00')+":'+G.secondTemplate+"
'+(l.options.useMinutes?'':"")+"
'+(l.options.useSeconds?'
':""))};l.destroy=function(){F();E();l.widget.remove();l.element.removeData("DateTimePicker");if(l.component){l.component.removeData("DateTimePicker")}};l.show=function(Q){l.widget.show();l.height=l.component?l.component.outerHeight():l.element.outerHeight();j();l.element.trigger({type:"show.dp",date:a(l.date)});L();if(Q){K(Q)}},l.disable=function(){var Q=l.element.find("input");if(Q.prop("disabled")){return}Q.prop("disabled",true);F()},l.enable=function(){var Q=l.element.find("input");if(!Q.prop("disabled")){return}Q.prop("disabled",false);J()},l.hide=function(S){if(S&&d(S.target).is(l.element.attr("id"))){return}var T=l.widget.find(".collapse"),Q,R;for(Q=0;Q=1.8.3", diff --git a/package.json b/package.json index e93521e40..92e45d93c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-datetimepicker", - "version": "2.1.30", + "version": "2.1.32", "repository": { "type": "git", "url": "git://github.com/eonasdan/bootstrap-datetimepicker.git" diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index 0175f0b97..c34c904ba 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -1,5 +1,5 @@ /** - * version 2.1.30 + * version 2.1.32 * @license * ========================================================= * bootstrap-datetimepicker.js @@ -62,7 +62,7 @@ startDate: new pMoment({ y: 1970 }), endDate: new pMoment().add(50, "y"), collapse: true, - language: pMoment.lang(), + language: "en", defaultDate: "", disabledDates: [], enabledDates: false, @@ -668,8 +668,6 @@ } else { picker.viewDate = oldDate; - input.val(pMoment(oldDate).format(picker.format)); - //picker.setValue(""); // unset the date when the input is erased notifyChange(oldDate, e.type); notifyError(newDate); picker.unset = true; @@ -1032,6 +1030,7 @@ pMoment.lang(picker.options.language); if (!newDate) { picker.unset = true; + set(); } else { picker.unset = false; } @@ -1054,9 +1053,11 @@ }, picker.setDate = function (date) { - date = pMoment(date); - if (!date) picker.setValue(null); - else picker.setValue(date); + if (!date) { + picker.setValue(null); + } else { + picker.setValue(pMoment(date)); + } }, picker.setEnabledDates = function (dates) {