ligerButton.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * jQuery ligerUI 1.1.9
  3. *
  4. * http://ligerui.com
  5. *
  6. * Author daomi 2012 [ gd_star@163.com ]
  7. *
  8. */
  9. (function ($)
  10. {
  11. $.fn.ligerButton = function (options)
  12. {
  13. return $.ligerui.run.call(this, "ligerButton", arguments);
  14. };
  15. $.fn.ligerGetButtonManager = function ()
  16. {
  17. return $.ligerui.run.call(this, "ligerGetButtonManager", arguments);
  18. };
  19. $.ligerDefaults.Button = { width: 100, text: '查询', disabled: false };
  20. $.ligerMethos.Button = {};
  21. $.ligerui.controls.Button = function (element, options)
  22. {
  23. $.ligerui.controls.Button.base.constructor.call(this, element, options);
  24. };
  25. $.ligerui.controls.Button.ligerExtend($.ligerui.controls.Input, {
  26. __getType: function ()
  27. {
  28. return 'Button';
  29. },
  30. __idPrev: function ()
  31. {
  32. return 'Button';
  33. },
  34. _extendMethods: function ()
  35. {
  36. return $.ligerMethos.Button;
  37. },
  38. _render: function ()
  39. {
  40. var g = this, p = this.options;
  41. g.button = $(g.element);
  42. g.button.addClass("l-btn");
  43. g.button.append('<div class="l-btn-l"></div><div class="l-btn-r"></div><span></span>');
  44. p.click && g.button.click(function ()
  45. {
  46. if (!p.disabled)
  47. p.click();
  48. });
  49. g.set(p);
  50. },
  51. _setEnabled: function (value)
  52. {
  53. if (value)
  54. this.button.removeClass("l-btn-disabled");
  55. },
  56. _setDisabled: function (value)
  57. {
  58. if (value)
  59. {
  60. this.button.addClass("l-btn-disabled");
  61. this.options.disabled = true;
  62. }
  63. },
  64. _setWidth: function (value)
  65. {
  66. this.button.width(value);
  67. },
  68. _setText: function (value)
  69. {
  70. $("span", this.button).html(value);
  71. },
  72. setValue: function (value)
  73. {
  74. this.set('text', value);
  75. },
  76. getValue: function ()
  77. {
  78. return this.options.text;
  79. },
  80. setEnabled: function ()
  81. {
  82. this.set('disabled', false);
  83. },
  84. setDisabled: function ()
  85. {
  86. this.set('disabled', true);
  87. }
  88. });
  89. })(jQuery);