16 lines
8.8 KiB
JavaScript
16 lines
8.8 KiB
JavaScript
|
/**
|
||
|
* Copyright 2014 Telerik AD
|
||
|
*
|
||
|
* 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,define){define(["./kendo.datepicker.min","./kendo.timepicker.min"],e)}(function(){return function(e,t){function n(e){var t=new Date(2100,0,1);return t.setMinutes(-e),t}function i(e){e.preventDefault()}function r(t){var n,i=o.getCulture(t.culture).calendars.standard.patterns;t.format=d(t.format||i.g),t.timeFormat=n=d(t.timeFormat||i.t),o.DateView.normalize(t),-1===e.inArray(n,t.parseFormats)&&t.parseFormats.splice(1,0,n)}var o=window.kendo,a=o.TimeView,s=o.parseDate,l=o._activeElement,d=o._extractFormat,c=o.calendar,u=c.isInRange,p=c.restrictValue,f=c.isEqualDatePart,h=a.getMilliseconds,m=o.ui,g=m.Widget,v="open",_="close",k="change",b=".kendoDateTimePicker",w="click"+b,y="disabled",x="readonly",C="k-state-default",T="k-state-focused",S="k-state-hover",F="k-state-disabled",D="mouseenter"+b+" mouseleave"+b,E="mousedown"+b,A="month",I="<span/>",H="aria-activedescendant",N="aria-expanded",M="aria-hidden",R="aria-owns",O="aria-disabled",P="aria-readonly",z=Date,L=new z(1900,0,1),B=new z(2099,11,31),W={view:"date"},U={view:"time"},V=e.extend,q=g.extend({init:function(e,t){var n,i=this;g.fn.init.call(i,e,t),e=i.element,t=i.options,t.min=s(e.attr("min"))||s(t.min),t.max=s(e.attr("max"))||s(t.max),r(t),i._wrapper(),i._views(),i._icons(),i._reset(),i._template();try{e[0].setAttribute("type","text")}catch(a){e[0].type="text"}e.addClass("k-input").attr({role:"combobox","aria-expanded":!1}),i._midnight=h(t.min)+h(t.max)===0,n=e.is("[disabled]"),n?i.enable(!1):i.readonly(e.is("[readonly]")),i._old=i._update(t.value||i.element.val()),i._oldText=e.val(),o.notify(i)},options:{name:"DateTimePicker",value:null,format:"",timeFormat:"",culture:"",parseFormats:[],dates:[],min:new z(L),max:new z(B),interval:30,height:200,footer:"",start:A,depth:A,animation:{},month:{},ARIATemplate:'Current focused date is #=kendo.toString(data.current, "d")#'},events:[v,_,k],setOptions:function(e){var t,n,i,a=this,l=a._value;g.fn.setOptions.call(a,e),e=a.options,e.min=t=s(e.min),e.max=n=s(e.max),r(e),i=e.value||a._value||a.dateView._current,t&&!f(t,i)&&(t=new z(L)),n&&!f(n,i)&&(n=new z(B)),a.dateView.setOptions(e),a.timeView.setOptions(V({},e,{format:e.timeFormat,min:t,max:n})),l&&(a.element.val(o.toString(l,e.format,e.culture)),a._updateARIA(l))},_editable:function(t){var n=this,r=n.element.off(b),a=n._dateIcon.off(b),s=n._timeIcon.off(b),d=n._inputWrapper.off(b),c=t.readonly,u=t.disable;c||u?(d.addClass(u?F:C).removeClass(u?C:F),r.attr(y,u).attr(x,c).attr(O,u).attr(P,c)):(d.addClass(C).removeClass(F).on(D,n._toggleHover),r.removeAttr(y).removeAttr(x).attr(O,!1).attr(P,!1).on("keydown"+b,e.proxy(n._keydown,n)).on("focus"+b,function(){n._inputWrapper.addClass(T)}).on("focusout"+b,function(){n._inputWrapper.removeClass(T),r.val()!==n._oldText&&n._change(r.val()),n.close("date"),n.close("time")}),a.on(E,i).on(w,function(){n.toggle("date"),o.support.touch||r[0]===l()||r.focus()}),s.on(E,i).on(w,function(){n.toggle("time"),o.support.touch||r[0]===l()||r.focus()}))},readonly:function(e){this._editable({readonly:e===t?!0:e,disable:!1})},enable:function(e){this._editable({readonly:!1,disable:!(e=e===t?!0:e)})},destroy:function(){var e=this;g.fn.destroy.call(e),e.dateView.destroy(),e.timeView.destroy(),e.element.off(b),e._dateIcon.off(b),e._timeIcon.off(b),e._inputWrapper.off(b),e._form&&e._form.off("reset",e._resetHandler)},close:function(e){"time"!==e&&(e="date"),this[e+"View"].close()},open:function(e){"time"!==e&&(e="date"),this[e+"View"].open()},min:function(e){return this._option("min",e)},max:function(e){return this._option("max",e)},toggle:function(e){var t="timeView";"time"!==e?e="date":t="dateView",this[e+"View"].toggle(),this[t].close()},value:function(e){var n=this;return e===t?n._value:(n._old=n._update(e),null===n._old&&n.element.val(""),n._oldText=n.element.val(),t)},_change:function(e){var t=this;e=t._update(e),+t._old!=+e&&(t._old=e,t._oldText=t.element.val(),t.trigger(k),t.element.trigger(k))},_option:function(e,i){var r,o,a=this,l=a.options,d=a.timeView,c=d.options,u=a._value||a._old;if(i===t)return l[e];if(i=s(i,l.parseFormats,l.cultur
|