jquery.numberspinner.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * EasyUI for jQuery 1.6.10
  3. *
  4. * Copyright (c) 2009-2018 www.jeasyui.com. All rights reserved.
  5. *
  6. * Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
  7. * To use it on other terms please contact us: info@jeasyui.com
  8. *
  9. */
  10. (function($){
  11. function _1(_2){
  12. $(_2).addClass("numberspinner-f");
  13. var _3=$.data(_2,"numberspinner").options;
  14. $(_2).numberbox($.extend({},_3,{doSize:false})).spinner(_3);
  15. $(_2).numberbox("setValue",_3.value);
  16. };
  17. function _4(_5,_6){
  18. var _7=$.data(_5,"numberspinner").options;
  19. var v=parseFloat($(_5).numberbox("getValue")||_7.value)||0;
  20. if(_6){
  21. v-=_7.increment;
  22. }else{
  23. v+=_7.increment;
  24. }
  25. $(_5).numberbox("setValue",v);
  26. };
  27. $.fn.numberspinner=function(_8,_9){
  28. if(typeof _8=="string"){
  29. var _a=$.fn.numberspinner.methods[_8];
  30. if(_a){
  31. return _a(this,_9);
  32. }else{
  33. return this.numberbox(_8,_9);
  34. }
  35. }
  36. _8=_8||{};
  37. return this.each(function(){
  38. var _b=$.data(this,"numberspinner");
  39. if(_b){
  40. $.extend(_b.options,_8);
  41. }else{
  42. $.data(this,"numberspinner",{options:$.extend({},$.fn.numberspinner.defaults,$.fn.numberspinner.parseOptions(this),_8)});
  43. }
  44. _1(this);
  45. });
  46. };
  47. $.fn.numberspinner.methods={options:function(jq){
  48. var _c=jq.numberbox("options");
  49. return $.extend($.data(jq[0],"numberspinner").options,{width:_c.width,value:_c.value,originalValue:_c.originalValue,disabled:_c.disabled,readonly:_c.readonly});
  50. }};
  51. $.fn.numberspinner.parseOptions=function(_d){
  52. return $.extend({},$.fn.spinner.parseOptions(_d),$.fn.numberbox.parseOptions(_d),{});
  53. };
  54. $.fn.numberspinner.defaults=$.extend({},$.fn.spinner.defaults,$.fn.numberbox.defaults,{spin:function(_e){
  55. _4(this,_e);
  56. }});
  57. })(jQuery);