Fork of the espurna firmware for `mhsw` switches
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.

0 lines
6.5 KiB

  1. (function(){var e,i,t,n=[].slice;null==$.browser&&(t=navigator.userAgent||"",jQuery.uaMatch=function(e){var i;return e=e.toLowerCase(),i=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(e)||[],{browser:i[1]||"",version:i[2]||"0"}},i=jQuery.uaMatch(t),jQuery.browser={},i.browser&&(jQuery.browser[i.browser]=!0,jQuery.browser.version=i.version),jQuery.browser.webkit&&(jQuery.browser.safari=!0)),e=function(){function e(i,t){var n,s,a;this.elem=$(i),s=$.extend({},e.defaults,t);for(n in s)a=s[n],this[n]=a;this.elem.data(this.dataName,this),this.wrapCheckboxWithDivs(),this.attachEvents(),this.disableTextSelection(),this.calculateDimensions()}return e.prototype.calculateDimensions=function(){return this.resizeHandle&&this.optionallyResize("handle"),this.resizeContainer&&this.optionallyResize("container"),this.initialPosition()},e.prototype.isDisabled=function(){return this.elem.is(":disabled")},e.prototype.wrapCheckboxWithDivs=function(){return this.elem.wrap("<div class='"+this.containerClass+"' />"),this.container=this.elem.parent(),this.offLabel=$("<label class='"+this.labelOffClass+"'>\n <span>"+this.uncheckedLabel+"</span>\n</label>").appendTo(this.container),this.offSpan=this.offLabel.children("span"),this.onLabel=$("<label class='"+this.labelOnClass+"'>\n <span>"+this.checkedLabel+"</span>\n</label>").appendTo(this.container),this.onSpan=this.onLabel.children("span"),this.handle=$("<div class='"+this.handleClass+"'>\n <div class='"+this.handleRightClass+"'>\n <div class='"+this.handleCenterClass+"' />\n </div>\n</div>").appendTo(this.container)},e.prototype.disableTextSelection=function(){return $.browser.msie?$([this.handle,this.offLabel,this.onLabel,this.container]).attr("unselectable","on"):void 0},e.prototype._getDimension=function(e,i){return null!=$.fn.actual?e.actual(i):e[i]()},e.prototype.optionallyResize=function(e){var i,t,n,s,a;return a=this.onLabel.find("span"),s=this._getDimension(a,"width"),s+=parseInt(a.css("padding-left"),10),n=this.offLabel.find("span"),t=this._getDimension(n,"width"),t+=parseInt(n.css("padding-right"),10),"container"===e?(i=s>t?s:t,i+=this._getDimension(this.handle,"width")+this.handleMargin,this.container.css({width:i})):(i=s>t?s:t,this.handle.css({width:i}))},e.prototype.onMouseDown=function(i){var t;return i.preventDefault(),this.isDisabled()?void 0:(t=i.pageX||i.originalEvent.changedTouches[0].pageX,e.currentlyClicking=this.handle,e.dragStartPosition=t,e.handleLeftOffset=parseInt(this.handle.css("left"),10)||0)},e.prototype.onDragMove=function(i,t){var n,s;if(e.currentlyClicking===this.handle)return s=(t+e.handleLeftOffset-e.dragStartPosition)/this.rightSide,0>s&&(s=0),s>1&&(s=1),n=s*this.rightSide,this.handle.css({left:n}),this.onLabel.css({width:n+this.handleRadius}),this.offSpan.css({marginRight:-n}),this.onSpan.css({marginLeft:-(1-s)*this.rightSide})},e.prototype.onDragEnd=function(i,t){var n;if(e.currentlyClicking===this.handle&&!this.isDisabled())return e.dragging?(n=(t-e.dragStartPosition)/this.rightSide,this.elem.prop("checked",n>=.5).change()):this.elem.prop("checked",!this.elem.prop("checked")).change(),e.currentlyClicking=null,e.dragging=null,"function"==typeof this.onChange&&this.onChange(this.elem,this.elem.prop("checked")),this.didChange()},e.prototype.refresh=function(){return this.didChange()},e.prototype.didChange=function(){var e;return this.isDisabled()?(this.container.addClass(this.disabledClass),!1):(this.container.removeClass(this.disabledClass),e=this.elem.prop("checked")?this.rightSide:0,this.handle.animate({left:e},this.duration),this.onLabel.animate({width:e+this.handleRadius},this.duration),this.offSpan.animate({marginRight:-e},this.duration),this.onSpan.animate({marginLeft:e-this.rightSide},this.duration))},e.prototype.attachEvents=function(){var e,i,t;return t=this,e=function(e){return t.onGlobalMove.apply(t,arguments)},i=function(n){return t.onGlobalUp.apply(t,arguments),$(document).unbind("mous