You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sonarr/NzbDrone.Web/Scripts/2010.3.1318/telerik.timepicker.min.js

1 line
6.5 KiB

(function(a){var b=a.telerik;b.timeView=function(c){a.extend(this,c);var d=this.dropDown=new b.dropDown({attr:this.dropDownAttr,effects:this.effects,onClick:function(f){var g=f.item;c.onChange(g.innerText||g.textContent)}});d.$element.addClass("t-time-popup").css("direction",this.isRtl?"rtl":"")};b.timeView.prototype={_ensureItems:function(){if(!this.dropDown.$items){this.bind()}},open:function(c){this._ensureItems();this.dropDown.open(c)},close:function(){this.dropDown.close()},bind:function(){var j=b.timeView.getTimeMilliseconds;var g=[];var c=this.format;var n=this.interval;var p=this.minValue;var d=j(p);var f=j(this.maxValue);var l=n*b.datetime.msPerMinute;var k=parseInt(b.datetime.msPerDay/(n*b.datetime.msPerMinute));if(d!=f){var o=d<f?f-d:f+b.datetime.msPerDay-d;k=parseInt(o/l)+1}var m=b.datetime.add;var e=b.datetime.format;for(var h=0;h<k;h++){g[h]=e(p.toDate(),c);p=m(p,l)}if(j(p)-l-f!=0&&d!=f){g[k]=e(this.maxValue.toDate(),c)}this.dropDown.dataBind(g)},isOpened:function(){return this.dropDown.isOpened()},value:function(c){this._ensureItems();var e=this.dropDown;if(c===undefined){return e.$items.filter(".t-state-selected").text()}var d=e.$items;if(!d){return}d.removeClass("t-state-selected");if(c){e.highlight(a.grep(d,function(f){return(f.innerText||f.textContent)==c}))}},navigate:function(i){var g=i.keyCode||i.which;if(g==38||g==40){i.preventDefault()}this._ensureItems();var d=this.dropDown;var f=d.$items;var h=f.filter(".t-state-selected");var c=h.length==0||f.length==1?f.first():(g==38)?h.prev():(g==40)?h.next():[];if(c.length){var j=c.text();d.scrollTo(c[0]);d.highlight(c[0]);if(!d.isOpened()){this.onChange(j)}else{this.onNavigateWithOpenPopup(j)}}}};a.each(["min","max"],a.proxy(function(d,c){b.timeView.prototype[c]=function(f){var e=c+"Value";if(f===undefined){return this[e].toDate()}this[e]=f.value?f:new b.datetime(f);this.bind()}},this));a.extend(b.timeView,{isInRange:function(c,j,g){if(c===null){return true}var f=b.timeView.getTimeMilliseconds;var d=b.datetime.msPerDay;var i=f(c);var e=f(j);var h=f(g);i=e>i?i+d:i;h=e>h?h+d:h;return e-h==0||i>=e&&i<=h},getTimeMilliseconds:function(c){return((c.hours()*60)+c.minutes())*b.datetime.msPerMinute+c.seconds()*1000+c.milliseconds()}});b.timepicker=function(d,e){a.extend(this,e);this.element=d;this.$element=a(d);var f=this.$input=a(".t-input",d).attr("autocomplete","off").bind({change:function(g){g.stopPropagation()},keydown:a.proxy(this._keydown,this),focus:a.proxy(function(g){this._change(f.val());this._open();this.$input.removeClass("t-state-error")},this)});this.timeView=new b.timeView({effects:this.effects,dropDownAttr:this.dropDownAttr,format:this.format,interval:this.interval,isRtl:f.closest(".t-rtl").length,minValue:this.minValue,maxValue:this.maxValue,onNavigateWithOpenPopup:a.proxy(function(g){this.$input.val(g)},this),onChange:a.proxy(function(g){this._change(g);this._close()},this)});this.inputValue=f.val();var c=this.selectedValue||this.inputValue;if(c){this._value(this.parse(c))}a(".t-icon",d).bind("click",this.enabled?a.proxy(this._togglePopup,this):b.preventDefault);a(document.documentElement).bind("mousedown",a.proxy(function(i){var g=this.timeView.dropDown.$element;var h=g&&g.parent().length>0;if(!h||a.contains(this.element,i.target)||a.contains(g.parent()[0],i.target)){return}this._change(this.$input.val());this._close()},this));b.bind(this,{open:this.onOpen,close:this.onClose,change:this.onChange,load:this.onLoad})};b.timepicker.prototype={_close:function(){var c=this.timeView.dropDown;if(!c.$element.is(":animated")&&c.isOpened()){this._trigger("close")}},_open:function(){if(!this.timeView.isOpened()){this._trigger("open")}},_trigger:function(c){if(!b.trigger(this.element,c)){this[c]()}},_togglePopup:function(){if(this.timeView.isOpened()){this._change(this.$input.val());this._close()}else{this.$input[0].focus()}},_change:function(c){var k=this.minValue;var e=this.maxValue;var i=this.parse(c);var m=this.selectedValue;if(!b.timeView.isInRange(i,k,e)){var d=b.timeView.getTimeMilliseconds;var h=d(i);var f=d(k);var l=d(e);var j=Math.abs(f-h);var g=M