www-thermferm/jqwidgets/jqxprogressbar.js

Sun, 07 Jul 2019 14:31:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 07 Jul 2019 14:31:10 +0200
branch
stable
changeset 603
fcff55324b84
parent 511
2d1d43c3a2c2
child 617
b216f9d4b917
permissions
-rw-r--r--

Merged fix from default

117
7119ea8a5225 Initial setup of wqwidgets
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*
511
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
2 jQWidgets v4.5.2 (2017-May)
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
3 Copyright (c) 2011-2017 jQWidgets.
117
7119ea8a5225 Initial setup of wqwidgets
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 License: http://jqwidgets.com/license/
511
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
5 */
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
6 !function(a){a.jqx.jqxWidget("jqxProgressBar","",{}),a.extend(a.jqx._jqxProgressBar.prototype,{defineInstance:function(){var b={colorRanges:[],value:0,oldValue:null,max:100,min:0,orientation:"horizontal",layout:"normal",width:null,height:null,showText:!1,animationDuration:300,disabled:!1,rtl:!1,renderText:null,template:"",aria:{"aria-valuenow":{name:"value",type:"number"},"aria-disabled":{name:"disabled",type:"boolean"}},events:["valueChanged","invalidValue","complete","change"]};return this===a.jqx._jqxProgressBar.prototype?b:(a.extend(!0,this,b),b)},createInstance:function(b){var c=this;this.host.addClass(this.toThemeProperty("jqx-progressbar")),this.host.addClass(this.toThemeProperty("jqx-widget")),this.host.addClass(this.toThemeProperty("jqx-widget-content")),this.host.addClass(this.toThemeProperty("jqx-rc-all")),a.jqx.aria(this),null!=this.width&&this.width.toString().indexOf("px")!=-1?this.host.width(this.width):void 0==this.width||isNaN(this.width)?this.host.width(this.width):this.host.width(this.width),null!=this.height&&this.height.toString().indexOf("px")!=-1?this.host.height(this.height):void 0==this.height||isNaN(this.height)?this.host.height(this.height):this.host.height(this.height),this.valueDiv=a("<div></div>").appendTo(this.element),this._addRanges(),this.valueDiv.addClass(this.toThemeProperty("jqx-fill-state-pressed")),this.template&&this.valueDiv.addClass(this.toThemeProperty("jqx-"+this.template)),this.feedbackElementHost=a("<div style='left: 0px; top: 0px; width: 100%; height: 100%; position: absolute;'></div>").appendTo(this.host),this.feedbackElement=a("<span class='text'></span>").appendTo(this.feedbackElementHost),this.feedbackElement.addClass(this.toThemeProperty("jqx-progressbar-text")),this.oldValue=this._value(),this.refresh(),a.jqx.utilities.resize(this.host,function(){c.refresh()})},_addRanges:function(){if(0!=this.colorRanges.length)for(var a="vertical"==this.orientation,b=this.colorRanges,c=b.length,d=0;d<c;d++){var e=b[d].stop,f=b[d].color;this._createColorElements(e,f,a,c-d,d)}},_refreshColorElements:function(){for(var a=this.host.outerWidth(),b=this.host.outerHeight(),c="vertical"==this.orientation,d=0;d<this.colorRanges.length;d++){var e=this.colorRanges[d].element;if(!e)return this.host.find(".jqx-progressbar-range").remove(),void this._addRanges();var f=this.colorRanges[d].stop;f>Math.min(this.max,this.value)&&(f=Math.min(this.max,this.value));var g=100*(f-this.min)/(this.max-this.min);c?size=b*g/100:size=a*g/100,size+="px",c?(e.css("height",size),"reverse"==this.layout?e.css("bottom",0):e.css("top",0)):(e.css("width",size),(this.rtl||"reverse"==this.layout)&&e.css("right","0px"))}},_createColorElements:function(b,c,d,e,f){var g;b>Math.min(this.max,this.value)&&(b=Math.min(this.max,this.value));var h=100*b/this.max;this.host.width(),this.host.height();g=d?this.host.outerHeight()*h/100:this.host.outerWidth()*h/100,g+="px";var i=a(this.valueDiv).parent()[0];if(i.style.position="relative",d=d||!1){var j=a("<div/>");j.attr("class","jqx-progressbar-range"),j.css("width","100%"),j.css("height",g),j.css("background-color",c),j.css("position","absolute"),j.css("z-index",e),"reverse"==this.layout?j.css("bottom",0):j.css("top",0),j.appendTo(i)}else{var j=a("<div/>");j.attr("class","jqx-progressbar-range"),j.css("width",g),j.css("height","100%"),j.css("background-color",c),j.css("position","absolute"),j.css("z-index",e),j.css("top","0px"),this.rtl&&j.css("right","0px"),j.appendTo(i)}this.colorRanges[f].element=j},resize:function(a,b){this.width=a,this.height=b,this.refresh()},destroy:function(){this.host.removeClass(),this.valueDiv.removeClass(),this.valueDiv.remove(),this.feedbackElement.remove()},_raiseevent:function(b,c,d){if(void 0!=this.isInitialized&&1==this.isInitialized){var e=this.events[b],f=new a.Event(e);f.previousValue=c,f.currentValue=d,f.owner=this;var g=this.host.trigger(f);return g}},actualValue:function(b){return void 0===b?this._value():(a.jqx.aria(this,"aria-valuenow",b),a.jqx.setvalueraiseevent(this,"value",b),this._value())},val:function(a){return 0==arguments.length||"object"==typeof a?this.actualValue():this.actualValue(a)},propertiesChangedHandler:function(a,b,c){c&&c.width&&c.height&&2==Object.keys(c).length&&(a.host.width(c.width),a.host.height(c.height),a.refresh())},propertyChangedHandler:function(b,c,d,e){if(this.isInitialized&&d!=e&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)){var f=this;"colorRanges"==c&&(b.host.find(".jqx-progressbar-range").remove(),b._addRanges()),"min"==c&&b.value<e?b.value=e:"max"==c&&b.value>e&&(b.value=e),"value"===c&&void 0!=f.value&&(f.value=e,f.oldValue=d,a.jqx.aria(b,"aria-valuenow",e),(e<f.min||e>f.max)&&f._raiseevent(1,d,e),f.refresh()),"theme"==c&&a.jqx.utilities.setTheme(d,e,b.host),"renderText"==c||"orientation"==c||"layout"==c||"showText"==c||"min"==c||"max"==c?f.refresh():"width"==c&&void 0!=f.width?void 0==f.width||isNaN(f.width)||(f.host.width(f.width),f.refresh()):"height"==c&&void 0!=f.height&&(void 0==f.height||isNaN(f.height)||(f.host.height(f.height),f.refresh())),"disabled"==c&&f.refresh()}},_value:function(){var a=this.value;if("number"!=typeof a){var b=parseInt(a);a=isNaN(b)?0:b}return Math.min(this.max,Math.max(this.min,a))},_percentage:function(){return 100*(this._value()-this.min)/(this.max-this.min)},_textwidth:function(b){var c=a("<span>"+b+"</span>");a(this.host).append(c);var d=c.width();return c.remove(),d},_textheight:function(b){var c=a("<span>"+b+"</span>");a(this.host).append(c);var d=c.height();return c.remove(),d},_initialRender:!0,refresh:function(b){if(b!==!0){var c=this.actualValue(),d=this._percentage();if(this.disabled)return this.host.addClass(this.toThemeProperty("jqx-progressbar-disabled")),void this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));if(this.host.removeClass(this.toThemeProperty("jqx-progressbar-disabled")),this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled")),a(this.element.children[0]).show(),!isNaN(c)&&!isNaN(d)){this.oldValue!==c&&(this._raiseevent(0,this.oldValue,c),this._raiseevent(3,this.oldValue,c),this.oldValue=c);var e=this.oldValue,f=this.host.outerHeight(),g=this.host.outerWidth();null!=this.width&&(g=parseInt(this.width)),null!=this.height&&(f=parseInt(this.height)),this._refreshColorElements();var h=parseInt(this.host.outerWidth())/2;parseInt(this.host.outerHeight())/2;isNaN(d)&&(d=0),this.valueDiv.removeClass(this.toThemeProperty("jqx-progressbar-value-vertical jqx-progressbar-value")),"horizontal"==this.orientation?(this.valueDiv.width(0),this.valueDiv[0].style.height="100%",this.valueDiv.addClass(this.toThemeProperty("jqx-progressbar-value"))):(this.valueDiv[0].style.width="100%",this.valueDiv.height(0),this.valueDiv.addClass(this.toThemeProperty("jqx-progressbar-value-vertical")));var i=this;try{var j=this.element.children[0];if(a(j)[0].style.position="relative","horizontal"==this.orientation){a(j).toggle(c>=this.min);var g=this.host.outerWidth()*d/100,k=0;("reverse"==this.layout||this.rtl)&&(this._initialRender&&(a(j)[0].style.left=this.host.width()+"px",a(j)[0].style.width=0),k=this.host.outerWidth()-g),a(j).stop(),a(j).animate({width:g,left:k+"px"},this.animationDuration,function(){i._value()===i.max&&i._raiseevent(2,e,i.max)})}else{a(j).toggle(c>=this.min);var f=this.host.height()*d/100,l=0;"reverse"==this.layout&&(this._initialRender&&(a(j)[0].style.top=this.host.height()+"px",a(j)[0].style.height=0),l=this.host.height()-f),a(j).stop(),a(j).animate({height:f,top:l+"px"},this.animationDuration,function(){var b=i._percentage();isNaN(b)&&(b=0),b.toFixed(0)==i.min&&(a(j).hide(),i._value()===i.max&&i._raiseevent(2,e,i.max))})}}catch(a){}this._initialRender=!1,this.feedbackElement.html(d.toFixed(0)+"%").toggle(1==this.showText),this.renderText&&this.feedbackElement.html(this.renderText(d.toFixed(0)+"%",d)),this.feedbackElement.css("position","absolute"),this.feedbackElement.css("top","50%"),this.feedbackElement.css("left","0"),this.colorRanges.length>0&&this.feedbackElement.css("z-index",this.colorRanges.length+1);var m=this.feedbackElement.height(),n=this.feedbackElement.width(),o=Math.floor(h-parseInt(n)/2);this.feedbackElement.css({left:o,"margin-top":-parseInt(m)/2+"px"})}}}})}(jqxBaseFramework);
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
7

mercurial