/** * 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="",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.culture)){if(l.min.getTime()===l.max.getTime()&&(c.dates=[]),l[e]=new z(i.getTime()),a.dateView[e](i),a._midnight=h(l.min)+h(l.max)===0,u&&(r=f(l.min,u),o=f(l.max,u)),r||o){if(c[e]=i,r&&!o&&(c.max=n(l.interval)),o){if(a._midnight)return d.dataBind([B]),t;r||(c.min=L)}}else c.max=B,c.min=L;d.bind()}},_toggleHover:function(t){e(t.currentTarget).toggleClass(S,"mouseenter"===t.type)},_update:function(t){var i,r,a,l,d,c=this,h=c.options,m=h.min,g=h.max,v=h.dates,_=c.timeView,k=c._value,b=s(t,h.parseFormats,h.culture),w=null===b&&null===k||b instanceof Date&&k instanceof Date;return+b===+k&&w?(d=o.toString(b,h.format,h.culture),d!==t&&c.element.val(null===b?t:d),b):(null!==b&&f(b,m)?b=p(b,m,g):u(b,m,g)||(b=null),c._value=b,_.value(b),c.dateView.value(b),b&&(a=c._old,r=_.options,v[0]&&(v=e.grep(v,function(e){return f(b,e)}),v[0]&&(_.dataBind(v),l=!0)),l||(f(b,m)&&(r.min=m,r.max=n(h.interval),i=!0),f(b,g)&&(c._midnight?(_.dataBind([B]),l=!0):(r.max=g,i||(r.min=L),i=!0))),!l&&(!a&&i||a&&!f(a,b))&&(i||(r.max=B,r.min=L),_.bind())),c.element.val(b?o.toString(b,h.format,h.culture):t),c._updateARIA(b),b)},_keydown:function(e){var t=this,n=t.dateView,i=t.timeView,r=t.element.val(),a=n.popup.visible();e.altKey&&e.keyCode===o.keys.DOWN?t.toggle(a?"time":"date"):a?(n.move(e),t._updateARIA(n._current)):i.popup.visible()?i.move(e):e.keyCode===o.keys.ENTER&&r!==t._oldText&&t._change(r)},_views:function(){var e,t,n,i,r,l,d=this,c=d.element,p=d.options,f=c.attr("id");d.dateView=e=new o.DateView(V({},p,{id:f,anchor:d.wrapper,change:function(){var t,n=e.calendar.value(),i=+n,r=+p.min,o=+p.max;(i===r||i===o)&&(t=new z(+d._value),t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),u(t,r,o)&&(n=t)),d._change(n),d.close("date")},close:function(e){d.trigger(_,W)?e.preventDefault():(c.attr(N,!1),n.attr(M,!0),t.popup.visible()||c.removeAttr(R))},open:function(t){d.trigger(v,W)?t.preventDefault():(d.element.val()!==d._oldText&&(l=s(c.val(),p.parseFormats,p.culture),d.dateView[l?"current":"value"](l)),n.attr(M,!1),c.attr(N,!0).attr(R,e._dateViewID),d._updateARIA(l))}})),n=e.div,r=p.min.getTime(),d.timeView=t=new a({id:f,value:p.value,anchor:d.wrapper,animation:p.animation,format:p.timeFormat,culture:p.culture,height:p.height,interval:p.interval,min:new z(L),max:new z(B),dates:r===p.max.getTime()?[new Date(r)]:[],parseFormats:p.parseFormats,change:function(n,i){n=t._parse(n),p.min>n?(n=new z(+p.min),t.options.min=n):n>p.max&&(n=new z(+p.max),t.options.max=n),i?(d._timeSelected=!0,d._change(n)):(c.val(o.toString(n,p.format,p.culture)),e.value(n),d._updateARIA(n))},close:function(t){d.trigger(_,U)?t.preventDefault():(i.attr(M,!0),c.attr(N,!1),e.popup.visible()||c.removeAttr(R))},open:function(e){t._adjustListWidth(),d.trigger(v,U)?e.preventDefault():(i.attr(M,!1),c.attr(N,!0).attr(R,t._timeViewID),t.options.active(t.current()))},active:function(e){c.removeAttr(H),e&&c.attr(H,t._optionID)}}),i=t.ul},_icons:function(){var t,n=this,i=n.element;t=i.next("span.k-select"),t[0]||(t=e('selectselect').insertAfter(i)),t=t.children(),n._dateIcon=t.eq(0).attr({role:"button","aria-controls":n.dateView._dateViewID}),n._timeIcon=t.eq(1).attr({role:"button","aria-controls":n.timeView._timeViewID})},_wrapper:function(){var t,n=this,i=n.element;t=i.parents(".k-datetimepicker"),t[0]||(t=i.wrap(I).parent().addClass("k-picker-wrap k-state-default"),t=t.wrap(I).parent()),t[0].style.cssText=i[0].style.cssText,i.css({width:"100%",height:i[0].style.height}),n.wrapper=t.addClass("k-widget k-datetimepicker k-header").addClass(i[0].className),n._inputWrapper=e(t[0].firstChild)},_reset:function(){var t=this,n=t.element,i=n.attr("form"),r=i?e("#"+i):n.closest("form");r[0]&&(t._resetHandler=function(){t.value(n[0].defaultValue)},t._form=r.on("reset",t._resetHandler))},_template:function(){this._ariaTemplate=o.template(this.options.ARIATemplate)},_updateARIA:function(e){var t,n=this,i=n.dateView.calendar;n.element.removeAttr(H),i&&(t=i._cell,t.attr("aria-label",n._ariaTemplate({current:e||i.current()})),n.element.attr(H,t.attr("id")))}});m.plugin(q)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});