jquery.progressbar.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * jQuery EasyUI 1.3.4
  3. *
  4. * Copyright (c) 2009-2013 www.jeasyui.com. All rights reserved.
  5. *
  6. * Licensed under the GPL or commercial licenses
  7. * To use it on other terms please contact us: info@jeasyui.com
  8. * http://www.gnu.org/licenses/gpl.txt
  9. * http://www.jeasyui.com/license_commercial.php
  10. *
  11. */
  12. (function($){
  13. function _1(_2){
  14. $(_2).addClass("progressbar");
  15. $(_2).html("<div class=\"progressbar-text\"></div><div class=\"progressbar-value\"><div class=\"progressbar-text\"></div></div>");
  16. return $(_2);
  17. };
  18. function _3(_4,_5){
  19. var _6=$.data(_4,"progressbar").options;
  20. var _7=$.data(_4,"progressbar").bar;
  21. if(_5){
  22. _6.width=_5;
  23. }
  24. _7._outerWidth(_6.width)._outerHeight(_6.height);
  25. _7.find("div.progressbar-text").width(_7.width());
  26. _7.find("div.progressbar-text,div.progressbar-value").css({height:_7.height()+"px",lineHeight:_7.height()+"px"});
  27. };
  28. $.fn.progressbar=function(_8,_9){
  29. if(typeof _8=="string"){
  30. var _a=$.fn.progressbar.methods[_8];
  31. if(_a){
  32. return _a(this,_9);
  33. }
  34. }
  35. _8=_8||{};
  36. return this.each(function(){
  37. var _b=$.data(this,"progressbar");
  38. if(_b){
  39. $.extend(_b.options,_8);
  40. }else{
  41. _b=$.data(this,"progressbar",{options:$.extend({},$.fn.progressbar.defaults,$.fn.progressbar.parseOptions(this),_8),bar:_1(this)});
  42. }
  43. $(this).progressbar("setValue",_b.options.value);
  44. _3(this);
  45. });
  46. };
  47. $.fn.progressbar.methods={options:function(jq){
  48. return $.data(jq[0],"progressbar").options;
  49. },resize:function(jq,_c){
  50. return jq.each(function(){
  51. _3(this,_c);
  52. });
  53. },getValue:function(jq){
  54. return $.data(jq[0],"progressbar").options.value;
  55. },setValue:function(jq,_d){
  56. if(_d<0){
  57. _d=0;
  58. }
  59. if(_d>100){
  60. _d=100;
  61. }
  62. return jq.each(function(){
  63. var _e=$.data(this,"progressbar").options;
  64. var _f=_e.text.replace(/{value}/,_d);
  65. var _10=_e.value;
  66. _e.value=_d;
  67. $(this).find("div.progressbar-value").width(_d+"%");
  68. $(this).find("div.progressbar-text").html(_f);
  69. if(_10!=_d){
  70. _e.onChange.call(this,_d,_10);
  71. }
  72. });
  73. }};
  74. $.fn.progressbar.parseOptions=function(_11){
  75. return $.extend({},$.parser.parseOptions(_11,["width","height","text",{value:"number"}]));
  76. };
  77. $.fn.progressbar.defaults={width:"auto",height:22,value:0,text:"{value}%",onChange:function(_12,_13){
  78. }};
  79. })(jQuery);