首页 > 其他 > 详细

JEasyUI: Create endless progressbar

时间:2016-03-08 12:01:33      阅读:232      评论:0      收藏:0      [点我收藏+]

We know that jeasyui have a very nice progress messager. Its progress is updated with percentage (%) value which ranged from 0 to 100.

However, most of time, we do not have this information or hard to get the progress in percentage.

For example, during alax loading, we show progress bar with loading message and close it when loading is complete.

This custom is to create a loading progress with moving block.

Step 1. Adding a option called endless with default boolean value true

	$.fn.progressbar.defaults = {
		width: ‘auto‘,
		height: 22,
		value: 0,	// percentage value
		text: ‘{value}%‘,
		endless: true,  //Refer to Custom Note (1)
		onChange:function(newValue,oldValue){}
	};

  

Step 2. Update left attribute when setvalue fired, hide the persentage text.

	$.fn.progressbar.methods = {
		options: function(jq){
			return $.data(jq[0], ‘progressbar‘).options;
		},
		resize: function(jq, width){
			return jq.each(function(){
				setSize(this, width);
			});
		},
		getValue: function(jq){
			return $.data(jq[0], ‘progressbar‘).options.value;
		},
		setValue: function(jq, value){
			if (value < 0) value = 0;
			if (value > 100) value = 100;
			return jq.each(function(){
				var opts = $.data(this, ‘progressbar‘).options;
				var text = opts.text.replace(/{value}/, value);
				var oldValue = opts.value;
				opts.value = value;
				$(this).find(‘div.progressbar-value‘).width(value+‘%‘);
				///////////////////////Refer to Custom Note (1)////////////////////////////////
				//modified by rongbin to support endless progress... 
				if(opts.endless == true){
					var leftValue = value-5;
					if (leftValue < 0) leftValue = 0;					
					$(this).find(‘div.progressbar-value‘).css(‘left‘, leftValue+‘%‘);
				}else{
					$(this).find(‘div.progressbar-text‘).html(text);
				}			
				///////////////////////////////////////////////////////////////////////////////
				if (oldValue != value){
					opts.onChange.call(this, value, oldValue);
				}
			});
		}
	};

  

 

 

 

 

End of Note

JEasyUI: Create endless progressbar

原文:http://www.cnblogs.com/binglong/p/5253463.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!