/*
* Kendo UI Web v2012.3.1114 (http://kendoui.com)
* Copyright 2012 Telerik AD. All rights reserved.
*
* Kendo UI Web commercial licenses may be obtained at
* https://www.kendoui.com/purchase/license-agreement/kendo-ui-web-commercial.aspx
* If you do not own a commercial license, this file shall be governed by the
* GNU General Public License (GPL) version 3.
* For GPL requirements, please review: http://www.gnu.org/copyleft/gpl.html
*/
(function(e,t){function a(e){e.preventDefault()}function n(e){var t=i.getCulture(e.culture).calendars.standard.patterns;e.format=s(e.format||t.g),e.timeFormat=s(e.timeFormat||t.t),i.DateView.normalize(e),e.parseFormats.splice(1,0,e.timeFormat)}var i=window.kendo,o=i.TimeView,r=i.parseDate,s=i._extractFormat,l=i.calendar,c=l.isInRange,u=l.restrictValue,m=l.isEqualDatePart,d=o.getMilliseconds,p=i.ui,f=p.Widget,v="open",_="close",g="change",h=".kendoDateTimePicker",w="touchend"+h+" click"+h,k="disabled",V="k-state-default",x="k-state-focused",y="k-state-hover",D="k-state-disabled",b="mouseenter"+h+" mouseleave"+h,I="touchstart"+h+" mousedown"+h,A="month",C="",F="aria-activedescendant",T="aria-expanded",R="aria-hidden",W="aria-owns",H=Date,E=new H(1900,0,1),S=new H(2099,11,31),M={view:"date"},q={view:"time"},B=e.extend,N=f.extend({init:function(t,a){var o=this;f.fn.init.call(o,t,a),t=o.element,a=o.options,n(a),o._wrapper(),o._views(),o._icons(),o._reset(),o._template(),t[0].type="text",t.addClass("k-input").on("keydown"+h,e.proxy(o._keydown,o)).on("focus"+h,function(){o._inputWrapper.addClass(x)}).on("blur"+h,function(){o._inputWrapper.removeClass(x),o._change(t.val()),o.close("date"),o.close("time")}).attr({role:"textbox","aria-haspopup":!0,"aria-expanded":!1}),o._midnight=0===d(a.min)+d(a.max),o.enable(!t.is("[disabled]")),o.value(a.value||t.val()),i.notify(o)},options:{name:"DateTimePicker",value:null,format:"",timeFormat:"",culture:"",parseFormats:[],dates:[],min:new H(E),max:new H(S),interval:30,height:200,footer:"",start:A,depth:A,animation:{},month:{},ARIATemplate:'Current focused date is #=kendo.toString(data.current, "G")#'},events:[v,_,g],setOptions:function(e){var t=this,a=t.dateView.options,i=t.timeView.options;f.fn.setOptions.call(t,e),n(t.options),e=t.options,B(a,e,{change:a.change,close:a.close,open:a.open}),B(i,e,{format:e.timeFormat,active:i.active,change:i.change,close:i.close,open:i.open}),t.timeView.ul[0].innerHTML=""},enable:function(e){var t=this,n=t.element,i=t._dateIcon.off(h),o=t._timeIcon.off(h),r=t._inputWrapper.off(b);e===!1?(r.removeClass(V).addClass(D),n.attr(k,k)):(r.addClass(V).removeClass(D).on(b,t._toggleHover),n.removeAttr(k),i.on(I,a).on(w,function(e){t.toggle("date"),"click"===e.type&&n[0]!==document.activeElement&&n.focus()}),o.on(I,a).on(w,function(e){t.toggle("time"),"click"===e.type&&n[0]!==document.activeElement&&n.focus()}))},destroy:function(){var e=this;f.fn.destroy.call(e),e.dateView.destroy(),e.timeView.destroy(),e.element.off(h),e._dateIcon.off(h),e._timeIcon.off(h),e._inputWrapper.off(h),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 a=this;return e===t?a._value:(a._old=a._update(e),t)},_change:function(e){var t=this;e=t._update(e),+t._old!=+e&&(t._old=e,t.trigger(g),t.element.trigger(g))},_option:function(e,a){var n=this,i=n.options,o=n.timeView,s=o.options,l=n._value||n._old;if(a===t)return i[e];if(a=r(a,i.parseFormats,i.culture)){if(i[e]=new H(+a),n.dateView[e](a),n._midnight=0===d(i.min)+d(i.max),l&&m(a,l)){if(n._midnight&&"max"==e)return s[e]=S,o.dataBind([S]),t;s[e]=a}else s.max=S,s.min=E;o.bind()}},_toggleHover:function(t){e(t.currentTarget).toggleClass(y,"mouseenter"===t.type)},_update:function(t){var a,n,o,s,l,d=this,p=d.options,f=p.min,v=p.max,_=p.dates,g=d.timeView,h=r(t,p.parseFormats,p.culture);return+h===+d._value?(l=i.toString(h,p.format,p.culture),l!==t&&d.element.val(null===h?t:l),h):(null!==h&&m(h,f)?h=u(h,f,v):c(h,f,v)||(h=null),d._value=h,g.value(h),d.dateView.value(h),h&&(o=d._old,n=g.options,_[0]&&(_=e.grep(_,function(e){return m(h,e)}),_[0]&&(g.dataBind(_),s=!0)),s||(m(h,f)&&(n.min=f,n.max=S,a=!0),m(h,v)&&(d._midnight?(g.dataBind([S]),s=!0):(n.max=v,a||(n.min=E),a=!0))),!s&&(!o&&a||o&&!m(o,h))&&(a||(n.max=S,n.min=E),g.bind())),d.element.val(h?i.toString(h,p.format,p.culture):t),d._updateARIA(h),h)},_keydown:function(e){var t=this,a=t.dateView,n=t.timeView,o=a.popup.visible();e.altKey&&e.keyCode===i.keys.DOWN?t.toggle(o?"time":"date"):o?(a.move(e),t._updateARIA(a._current)):n.popup.visible()?n.move(e):e.keyCode===i.keys.ENTER&&t._change(t.element.val())},_views:function(){var e,t,a,n,s,l=this,u=l.element,m=l.options,d=u.attr("id");l.dateView=e=new i.DateView(B({},m,{id:d,anchor:l.wrapper,change:function(){var t,a=e.calendar.value(),n=+a,i=+m.min,o=+m.max;(n===i||n===o)&&(t=new H(+l._value),t.setFullYear(a.getFullYear()),t.setMonth(a.getMonth()),t.setDate(a.getDate()),c(t,i,o)&&(a=t)),l._change(a),l.close("date")},close:function(e){l.trigger(_,M)?e.preventDefault():(u.attr(T,!1),a.attr(R,!0),t.popup.visible()||u.removeAttr(W))},open:function(t){l.trigger(v,M)?t.preventDefault():(s=r(u.val(),m.parseFormats,m.culture),s?(l.dateView._current=s,l.dateView.calendar._focus(s)):l.dateView.value(s),a.attr(R,!1),u.attr(T,!0).attr(W,e._dateViewID))}})),a=e.div,l.timeView=t=new o({id:d,value:m.value,anchor:l.wrapper,animation:m.animation,format:m.timeFormat,culture:m.culture,height:m.height,interval:m.interval,min:new H(E),max:new H(S),parseFormats:m.parseFormats,change:function(a,n){a=t._parse(a),m.min>a?(a=new H(+m.min),t.options.min=a):a>m.max&&(a=new H(+m.max),t.options.max=a),n?(l._timeSelected=!0,l._change(a)):(u.val(i.toString(a,m.format,m.culture)),e.value(a),l._updateARIA(a))},close:function(t){l.trigger(_,q)?t.preventDefault():(n.attr(R,!0),u.attr(T,!1),e.popup.visible()||u.removeAttr(W))},open:function(e){l.trigger(v,q)?e.preventDefault():(n.attr(R,!1),u.attr(T,!0).attr(W,t._timeViewID))},active:function(e){u.removeAttr(F),e&&u.attr(F,t._optionID)}}),n=t.ul},_icons:function(){var t,a=this,n=a.element;t=n.next("span.k-select"),t[0]||(t=e('selectselect').insertAfter(n)),t=t.children(),a._dateIcon=t.eq(0).attr({role:"button","aria-controls":a.dateView._dateViewID}),a._timeIcon=t.eq(1).attr({role:"button","aria-controls":a.timeView._timeViewID})},_wrapper:function(){var t,a=this,n=a.element;t=n.parents(".k-datetimepicker"),t[0]||(t=n.wrap(C).parent().addClass("k-picker-wrap k-state-default"),t=t.wrap(C).parent()),t[0].style.cssText=n[0].style.cssText,n.css({width:"100%",height:n[0].style.height}),a.wrapper=t.addClass("k-widget k-datetimepicker k-header").addClass(n[0].className),a._inputWrapper=e(t[0].firstChild)},_reset:function(){var e=this,t=e.element,a=t.closest("form");a[0]&&(e._resetHandler=function(){e.value(t[0].defaultValue)},e._form=a.on("reset",e._resetHandler))},_template:function(){this._ariaTemplate=i.template(this.options.ARIATemplate)},_updateARIA:function(e){this.element.attr("aria-label",this._ariaTemplate({current:e}))}});p.plugin(N)})(window.kendo.jQuery);