/*
* Kendo UI Beta v2013.2.716 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Beta license terms available at
* http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx
*/
("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.popup.min"],function(){!function(e,t){function n(e,t,n){var i,o=e.getTimezoneOffset();e.setTime(e.getTime()+t),n||(i=e.getTimezoneOffset()-o,e.setTime(e.getTime()+i*M))}function i(){var e=new Q,t=new Q(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0),n=new Q(e.getFullYear(),e.getMonth(),e.getDate(),12,0,0);return-1*(t.getTimezoneOffset()-n.getTimezoneOffset())}function o(e){return 60*e.getHours()*M+e.getMinutes()*M+1e3*e.getSeconds()+e.getMilliseconds()}function a(e,t,n){var i,a=o(t),r=o(n);return e&&a!=r?(i=o(e),a>i&&(i+=A),a>r&&(r+=A),i>=a&&r>=i):!0}function r(e){var t=e.parseFormats;e.format=f(e.format||c.getCulture(e.culture).calendars.standard.patterns.t),t=Y(t)?t:[t],t.splice(0,0,e.format),e.parseFormats=t}function s(e){e.preventDefault()}var l,u,c=window.kendo,p=c.keys,d=c._activeElement,f=c._extractFormat,m=c.support,h=m.browser,v=c.ui,g=v.Widget,_="open",w="close",k="change",y=".kendoTimePicker",b="click"+y,x="k-state-default",T="disabled",C="readonly",D="li",V="",F="k-state-focused",W="k-state-hover",S="mouseenter"+y+" mouseleave"+y,H="mousedown"+y,M=6e4,A=864e5,I="k-state-selected",O="k-state-disabled",B="aria-selected",E="aria-expanded",L="aria-hidden",N="aria-disabled",R="aria-readonly",z="aria-activedescendant",P="id",Y=e.isArray,j=e.extend,K=e.proxy,Q=Date,U=new Q;U=new Q(U.getFullYear(),U.getMonth(),U.getDate(),0,0,0),l=function(t){var n=this,i=t.id;n.options=t,n.ul=e('
').css({overflow:m.kineticScrollNeeded?"":"auto"}).on(b,D,K(n._click,n)).on("mouseenter"+y,D,function(){e(this).addClass(W)}).on("mouseleave"+y,D,function(){e(this).removeClass(W)}),n.list=e("").append(n.ul).on(H,s),i&&(n._timeViewID=i+"_timeview",n._optionID=i+"_option_selected",n.ul.attr(P,n._timeViewID)),n._popup(),n.template=c.template('#=data#',{useWithBlock:!1})},l.prototype={current:function(n){var i=this,o=i.options.active;return n===t?i._current:(i._current&&i._current.removeClass(I).removeAttr(B).removeAttr(P),n&&(n=e(n).addClass(I).attr(P,i._optionID).attr(B,!0),i.scroll(n[0])),i._current=n,o&&o(n),t)},close:function(){this.popup.close()},destroy:function(){var e=this;e.ul.off(y),e.list.off(y),e.popup.destroy()},open:function(){var e=this;e.ul[0].firstChild||e.bind(),e.popup.open(),e._current&&e.scroll(e._current[0])},dataBind:function(e){for(var t,n=this,i=n.options,o=i.format,r=c.toString,s=n.template,l=e.length,u=0,p="";l>u;u++)t=e[u],a(t,i.min,i.max)&&(p+=s(r(t,o,i.culture)));n._html(p,l)},refresh:function(){var e,t,a,r=this,s=r.options,l=s.format,u=i(),p=0>u,d=s.min,f=s.max,m=o(d),h=o(f),v=s.interval*M,g=c.toString,_=r.template,w=new Q(+d),k=w.getDate(),y=0,b="";for(a=p?(A+u*M)/v:A/v,m!=h&&(m>h&&(h+=A),a=(h-m)/v+1),t=parseInt(a,10);a>y;y++)y&&n(w,v,p),h&&t==y&&(e=o(w),kh&&(w=new Q(+f))),b+=_(g(w,l,s.culture));r._html(b,a)},bind:function(){var e=this,t=e.options.dates;t&&t[0]?e.dataBind(t):e.refresh()},_html:function(e,t){var n=this;n.ul[0].innerHTML=e,n._height(t),n.current(null),n.select(n._value)},scroll:function(e){if(e){var t=this.ul[0],n=e.offsetTop,i=e.offsetHeight,o=t.scrollTop,a=t.clientHeight,r=n+i;t.scrollTop=o>n?n:r>o+a?r-a:o}},select:function(t){var n=this,i=n.options,o=n._current;t instanceof Date&&(t=c.toString(t,i.format,i.culture)),"string"==typeof t&&(o&&o.text()===t?t=o:(t=e.grep(n.ul[0].childNodes,function(e){return(e.textContent||e.innerText)==t}),t=t[0]?t:null)),n.current(t)},toggle:function(){var e=this;e.popup.visible()?e.close():e.open()},value:function(e){var t=this;t._value=e,t.ul[0].firstChild&&t.select(e)},_click:function(t){var n=this,i=e(t.currentTarget);t.isDefaultPrevented()||(n.select(i),n.options.change(i.text(),!0),n.close())},_height:function(e){if(e){var t=this,n=t.list,i=n.parent(".k-animation-container"),o=t.options.height;n.add(i).show().height(t.ul[0].scrollHeight>o?o:"auto").hide()}},_parse:function(e){var t=this,n=t.options,i=t._value||U;return e instanceof Q?e:(e=c.parseDate(e,n.parseFormats,n.culture),e&&(e=new Q(i.getFullYear(),i.getMonth(),i.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())),e)},_adjustListWidth:function(){var e,t,n=this.list,i=n[0].style.width,o=this.options.anchor;(n.data("width")||!i)&&(e=window.getComputedStyle?window.getComputedStyle(o[0],null):0,t=e?parseFloat(e.width):o.outerWidth(),e&&(h.mozilla||h.msie)&&(t+=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth)),i=t-(n.outerWidth()-n.width()),n.css({fontFamily:o.css("font-family"),width:i}).data("width",i))},_popup:function(){var e=this,t=e.list,n=e.options,i=n.anchor;e.popup=new v.Popup(t,j(n.popup,{anchor:i,open:n.open,close:n.close,animation:n.animation,isRtl:m.isRtl(n.anchor)})),c.touchScroller(e.popup.element)},move:function(e){var n=this,i=e.keyCode,o=n.ul[0],a=n._current,r=i===p.DOWN;if(i===p.UP||r){if(e.altKey)return n.toggle(r),t;a=r?a?a[0].nextSibling:o.firstChild:a?a[0].previousSibling:o.lastChild,a&&n.select(a),n.options.change(n._current.text()),e.preventDefault()}else(i===p.ENTER||i===p.TAB||i===p.ESC)&&(e.preventDefault(),a&&n.options.change(a.text(),!0),n.close())}},l.getMilliseconds=o,c.TimeView=l,u=g.extend({init:function(e,t){var n,i,o,a=this;g.fn.init.call(a,e,t),e=a.element,t=a.options,r(t),a._wrapper(),a.timeView=i=new l(j({},t,{id:e.attr(P),anchor:a.wrapper,format:t.format,change:function(t,n){n?a._change(t):e.val(t)},open:function(t){a.timeView._adjustListWidth(),a.trigger(_)?t.preventDefault():(e.attr(E,!0),n.attr(L,!1))},close:function(t){a.trigger(w)?t.preventDefault():(e.attr(E,!1),n.attr(L,!0))},active:function(t){e.removeAttr(z),t&&e.attr(z,i._optionID)}})),n=i.ul,a._icon(),a._reset(),e[0].type="text",e.addClass("k-input").attr({role:"textbox","aria-haspopup":!0,"aria-expanded":!1,"aria-owns":i._timeViewID}),o=e.is("[disabled]"),o?a.enable(!1):a.readonly(e.is("[readonly]")),a.value(t.value||e.val()),c.notify(a)},options:{name:"TimePicker",min:U,max:U,format:"",dates:[],parseFormats:[],value:null,interval:30,height:200,animation:{}},events:[_,w,k],setOptions:function(e){var t=this,n=t.timeView,i=n.options;g.fn.setOptions.call(t,e),r(t.options),n.options=j(i,t.options,{active:i.active,change:i.change,close:i.close,open:i.open}),n.ul[0].innerHTML=""},dataBind:function(e){Y(e)&&this.timeView.dataBind(e)},_editable:function(e){var t=this,n=e.disable,i=e.readonly,o=t._arrow.off(y),a=t.element.off(y),r=t._inputWrapper.off(y);i||n?(r.addClass(n?O:x).removeClass(n?x:O),a.attr(T,n).attr(C,i).attr(N,n).attr(R,i)):(r.addClass(x).removeClass(O).on(S,t._toggleHover),a.removeAttr(T).removeAttr(C).attr(N,!1).attr(R,!1).on("keydown"+y,K(t._keydown,t)).on("blur"+y,K(t._blur,t)).on("focus"+y,function(){t._inputWrapper.addClass(F)}),o.on(b,K(t._click,t)).on(H,s))},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.timeView.destroy(),e.element.off(y),e._arrow.off(y),e._inputWrapper.off(y),e._form&&e._form.off("reset",e._resetHandler)},close:function(){this.timeView.close()},open:function(){this.timeView.open()},min:function(e){return this._option("min",e)},max:function(e){return this._option("max",e)},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)},_blur:function(){var e=this,t=e.element.val();e.close(),t!==e._oldText&&e._change(t),e._inputWrapper.removeClass(F)},_click:function(){var e=this,t=e.element;e.timeView.toggle(),m.touch||t[0]===d()||t.focus()},_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))},_icon:function(){var t,n=this,i=n.element;t=i.next("span.k-select"),t[0]||(t=e('select').insertAfter(i)),n._arrow=t.attr({role:"button","aria-controls":n.timeView._timeViewID})},_keydown:function(e){var t=this,n=e.keyCode,i=t.timeView,o=t.element.val();i.popup.visible()||e.altKey?i.move(e):n===p.ENTER&&o!==t._oldText&&t._change(o)},_option:function(e,n){var i=this,o=i.options;return n===t?o[e]:(n=i.timeView._parse(n),n&&(n=new Q(+n),o[e]=n,i.timeView.options[e]=n,i.timeView.bind()),t)},_toggleHover:function(t){e(t.currentTarget).toggleClass(W,"mouseenter"===t.type)},_update:function(e){var t=this,n=t.options,i=t.timeView,o=i._parse(e);return a(o,n.min,n.max)||(o=null),t._value=o,t.element.val(o?c.toString(o,n.format,n.culture):e),i.value(o),o},_wrapper:function(){var t,n=this,i=n.element;t=i.parents(".k-timepicker"),t[0]||(t=i.wrap(V).parent().addClass("k-picker-wrap k-state-default"),t=t.wrap(V).parent()),t[0].style.cssText=i[0].style.cssText,n.wrapper=t.addClass("k-widget k-timepicker k-header").addClass(i[0].className),i.css({width:"100%",height:i[0].style.height}),n._inputWrapper=e(t[0].firstChild)},_reset:function(){var t=this,n=t.element,i=n.attr("form"),o=i?e("#"+i):n.closest("form");o[0]&&(t._resetHandler=function(){t.value(n[0].defaultValue)},t._form=o.on("reset",t._resetHandler))}}),v.plugin(u)}(window.kendo.jQuery)});