www-thermferm/jqwidgets/jqxprogressbar.js

changeset 511
2d1d43c3a2c2
parent 373
f6850e0b5d35
child 617
b216f9d4b917
equal deleted inserted replaced
510:2da3d3340403 511:2d1d43c3a2c2
1 /* 1 /*
2 jQWidgets v3.8.0 (2015-Apr) 2 jQWidgets v4.5.2 (2017-May)
3 Copyright (c) 2011-2015 jQWidgets. 3 Copyright (c) 2011-2017 jQWidgets.
4 License: http://jqwidgets.com/license/ 4 License: http://jqwidgets.com/license/
5 */ 5 */
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);
6 7
7 (function(a){a.jqx.jqxWidget("jqxProgressBar","",{});a.extend(a.jqx._jqxProgressBar.prototype,{defineInstance:function(){var b={value:0,oldValue:null,max:100,min:0,orientation:"horizontal",layout:"normal",width:null,height:null,showText:false,animationDuration:300,disabled:false,rtl:false,renderText:null,aria:{"aria-valuenow":{name:"value",type:"number"},"aria-disabled":{name:"disabled",type:"boolean"}},events:["valueChanged","invalidValue","complete","change"]};a.extend(true,this,b);return b},createInstance:function(c){var b=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);if(this.width!=null&&this.width.toString().indexOf("px")!=-1){this.host.width(this.width)}else{if(this.width!=undefined&&!isNaN(this.width)){this.host.width(this.width)}else{this.host.width(this.width)}}if(this.height!=null&&this.height.toString().indexOf("px")!=-1){this.host.height(this.height)}else{if(this.height!=undefined&&!isNaN(this.height)){this.host.height(this.height)}else{this.host.height(this.height)}}this.valueDiv=a("<div></div>").appendTo(this.element);if(this.orientation=="horizontal"){this.valueDiv.width(0);this.valueDiv.addClass(this.toThemeProperty("jqx-progressbar-value"))}else{this.valueDiv.height(0);this.valueDiv.addClass(this.toThemeProperty("jqx-progressbar-value-vertical"))}this.valueDiv.addClass(this.toThemeProperty("jqx-fill-state-pressed"));this.feedbackElementHost=a("<div style='width: 100%; height: 100%; position: relative;'></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(){b.refresh()})},resize:function(c,b){this.width=c;this.height=b;this.refresh()},destroy:function(){this.host.removeClass();this.valueDiv.removeClass();this.valueDiv.remove();this.feedbackElement.remove()},_raiseevent:function(g,d,f){if(this.isInitialized!=undefined&&this.isInitialized==true){var c=this.events[g];var e=new a.Event(c);e.previousValue=d;e.currentValue=f;e.owner=this;var b=this.host.trigger(e);return b}},actualValue:function(b){if(b===undefined){return this._value()}a.jqx.aria(this,"aria-valuenow",b);a.jqx.setvalueraiseevent(this,"value",b);return this._value()},val:function(b){if(arguments.length==0||typeof(b)=="object"){return this.actualValue()}return this.actualValue(b)},propertyChangedHandler:function(c,d,b,f){if(!this.isInitialized){return}var e=this;if(d=="min"&&c.value<f){c.value=f}else{if(d=="max"&&c.value>f){c.value=f}}if(d==="value"&&e.value!=undefined){e.value=f;e.oldValue=b;a.jqx.aria(c,"aria-valuenow",f);if(f<e.min||f>e.max){e._raiseevent(1,b,f)}e.refresh()}if(d=="theme"){a.jqx.utilities.setTheme(b,f,c.host)}if(d=="renderText"||d=="orientation"||d=="layout"||d=="showText"||d=="min"||d=="max"){e.refresh()}else{if(d=="width"&&e.width!=undefined){if(e.width!=undefined&&!isNaN(e.width)){e.host.width(e.width);e.refresh()}}else{if(d=="height"&&e.height!=undefined){if(e.height!=undefined&&!isNaN(e.height)){e.host.height(e.height);e.refresh()}}}}if(d=="disabled"){e.refresh()}},_value:function(){var c=this.value;if(typeof c!=="number"){var b=parseInt(c);if(isNaN(b)){c=0}else{c=b}}return Math.min(this.max,Math.max(this.min,c))},_percentage:function(){return 100*this._value()/this.max},_textwidth:function(d){var c=a("<span>"+d+"</span>");a(this.host).append(c);var b=c.width();c.remove();return b},_textheight:function(d){var c=a("<span>"+d+"</span>");a(this.host).append(c);var b=c.height();c.remove();return b},_initialRender:true,refresh:function(){var l=this.actualValue();var p=this._percentage();if(this.disabled){this.host.addClass(this.toThemeProperty("jqx-progressbar-disabled"));this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));return}else{this.host.removeClass(this.toThemeProperty("jqx-progressbar-disabled"));this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled"));a(this.element.children[0]).show()}if(isNaN(l)){return}if(isNaN(p)){return}if(this.oldValue!==l){this._raiseevent(0,this.oldValue,l);this._raiseevent(3,this.oldValue,l);this.oldValue=l}var b=this.oldValue;var n=this.host.outerHeight();var c=this.host.outerWidth();if(this.width!=null){c=parseInt(this.width)}if(this.height!=null){n=parseInt(this.height)}var f=parseInt(this.host.outerWidth())/2;var i=parseInt(this.host.outerHeight())/2;if(isNaN(p)){p=0}var j=this;try{var m=this.element.children[0];a(m)[0].style.position="relative";if(this.orientation=="horizontal"){a(m).toggle(l>=this.min);var c=this.host.outerWidth()*p/100;var e=0;if(this.layout=="reverse"||this.rtl){if(this._initialRender){a(m)[0].style.left=this.host.width()+"px";a(m)[0].style.width=0}e=this.host.outerWidth()-c}a(m).animate({width:c,left:e+"px"},this.animationDuration,function(){if(j._value()===j.max){j._raiseevent(2,b,j.max)}});this.feedbackElementHost.css("margin-top",-this.host.height())}else{a(m).toggle(l>=this.min);var n=this.host.height()*p/100;var d=0;if(this.layout=="reverse"){if(this._initialRender){a(m)[0].style.top=this.host.height()+"px";a(m)[0].style.height=0}d=this.host.height()-n}this.feedbackElementHost.animate({"margin-top":-(p.toFixed(0)*j.host.height())/100},this.animationDuration,function(){});a(m).animate({height:n,top:d+"px"},this.animationDuration,function(){var q=j._percentage();if(isNaN(q)){q=0}if(q.toFixed(0)==j.min){a(m).hide();if(j._value()===j.max){j._raiseevent(2,b,j.max)}}})}}catch(h){}this._initialRender=false;this.feedbackElement.html(p.toFixed(0)+"%").toggle(this.showText==true);if(this.renderText){this.feedbackElement.html(this.renderText(p.toFixed(0)+"%"))}this.feedbackElement.css("position","absolute");this.feedbackElement.css("top","50%");this.feedbackElement.css("left","0");var k=this.feedbackElement.height();var g=this.feedbackElement.width();var o=Math.floor(f-(parseInt(g)/2));this.feedbackElement.css({left:(o),"margin-top":-parseInt(k)/2+"px"})}})})(jqxBaseFramework);

mercurial