Author: apatel
Date: Fri Nov 16 02:53:38 2007 New Revision: 595619 URL: http://svn.apache.org/viewvc?rev=595619&view=rev Log: Javascript library and supporting css to display progress bar. Added: ofbiz/trunk/framework/images/webapp/images/prototypejs/control.progress_bar.js ofbiz/trunk/framework/images/webapp/images/prototypejs/progress_bar.css Added: ofbiz/trunk/framework/images/webapp/images/prototypejs/control.progress_bar.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/prototypejs/control.progress_bar.js?rev=595619&view=auto ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/prototypejs/control.progress_bar.js (added) +++ ofbiz/trunk/framework/images/webapp/images/prototypejs/control.progress_bar.js Fri Nov 16 02:53:38 2007 @@ -0,0 +1,99 @@ +/** + * @author Ryan Johnson <[hidden email]> + * @copyright 2007 LivePipe LLC + * @package Control.ProgressBar + * @license MIT + * @url http://livepipe.net/projects/control_progress_bar/ + * @version 1.0.1 + */ + +if(typeof(Control) == 'undefined') + Control = {}; +Control.ProgressBar = Class.create(); +Object.extend(Control.ProgressBar.prototype,{ + container: false, + containerWidth: 0, + progressContainer: false, + progress: 0, + executer: false, + active: false, + poller: false, + initialize: function(container,options){ + this.container = $(container); + this.containerWidth = this.container.getDimensions().width - (parseInt(this.container.getStyle('border-right-width').replace(/px/,'')) + parseInt(this.container.getStyle('border-left-width').replace(/px/,''))); + this.progressContainer = $(document.createElement('div')); + this.progressContainer.setStyle({ + width: this.containerWidth + 'px', + height: '100%', + position: 'absolute', + top: '0px', + right: '0px' + }); + this.container.appendChild(this.progressContainer); + this.options = { + afterChange: Prototype.emptyFunction, + interval: 0.25, + step: 1, + classNames: { + active: 'progress_bar_active', + inactive: 'progress_bar_inactive' + } + }; + Object.extend(this.options,options || {}); + this.container.addClassName(this.options.classNames.inactive); + this.active = false; + }, + setProgress: function(value){ + this.progress = value; + this.draw(); + if(this.progress >= 100) + this.stop(false); + this.notify('afterChange',this.progress,this.active); + }, + poll: function(url,interval){ + this.active = true; + this.poller = new PeriodicalExecuter(function(){ + new Ajax.Request(url,{ + onSuccess: function(request){ + this.setProgress(parseInt(request.responseText)); + if(!this.active) + this.poller.stop(); + }.bind(this) + }); + }.bind(this),interval || 3); + }, + start: function(){ + this.active = true; + this.container.removeClassName(this.options.classNames.inactive); + this.container.addClassName(this.options.classNames.active); + this.executer = new PeriodicalExecuter(this.step.bind(this,this.options.step),this.options.interval); + }, + stop: function(reset){ + this.active = false; + if(this.executer) + this.executer.stop(); + this.container.removeClassName(this.options.classNames.active); + this.container.addClassName(this.options.classNames.inactive); + if(typeof(reset) == 'undefined' || reset == true) + this.reset(); + }, + step: function(amount){ + this.active = true; + this.setProgress(Math.min(100,this.progress + amount)); + }, + reset: function(){ + this.active = false; + this.setProgress(0); + }, + draw: function(){ + this.progressContainer.setStyle({ + width: (this.containerWidth - Math.floor((this.progress / 100) * this.containerWidth)) + 'px' + }); + }, + notify: function(event_name){ + if(this.options[event_name]) + return [this.options[event_name].apply(this.options[event_name],$A(arguments).slice(1))]; + } +}); +if(typeof(Object.Event) != 'undefined') + Object.Event.extend(Control.ProgressBar); \ No newline at end of file Added: ofbiz/trunk/framework/images/webapp/images/prototypejs/progress_bar.css URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/prototypejs/progress_bar.css?rev=595619&view=auto ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/prototypejs/progress_bar.css (added) +++ ofbiz/trunk/framework/images/webapp/images/prototypejs/progress_bar.css Fri Nov 16 02:53:38 2007 @@ -0,0 +1,23 @@ +/** + * @author Ryan Johnson <[hidden email]> + * @copyright 2007 LivePipe LLC + * @package Control.ProgressBar + * @license MIT + * @url http://livepipe.net/projects/control_progress_bar/ + * @version 1.0.1 + */ + +#progress_bar { + width:102px; + height:7px; + border:1px solid #ccc; + padding:0; + margin:0; + position:relative; + background-image:url("/images/gradient_main.gif"); + background-repeat:repeat-x; +} + +#progress_bar div { + background-color:#fff; +} |
Free forum by Nabble | Edit this page |