UU跑腿标准版

ligerButton.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * jQuery ligerUI 1.2.3
  3. *
  4. * http://ligerui.com
  5. *
  6. * Author daomi 2014 [ 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 = {
  20. width: 60,
  21. text: 'Button',
  22. disabled: false,
  23. click: null,
  24. icon : null
  25. };
  26. $.ligerMethos.Button = {};
  27. $.ligerui.controls.Button = function (element, options)
  28. {
  29. $.ligerui.controls.Button.base.constructor.call(this, element, options);
  30. };
  31. $.ligerui.controls.Button.ligerExtend($.ligerui.controls.Input, {
  32. __getType: function ()
  33. {
  34. return 'Button';
  35. },
  36. __idPrev: function ()
  37. {
  38. return 'Button';
  39. },
  40. _extendMethods: function ()
  41. {
  42. return $.ligerMethos.Button;
  43. },
  44. _render: function ()
  45. {
  46. var g = this, p = this.options;
  47. g.button = $(g.element);
  48. g.button.addClass("l-button");
  49. g.button.append('<div class="l-button-l"></div><div class="l-button-r"></div><span></span>');
  50. g.button.hover(function () {
  51. if (p.disabled) return;
  52. g.button.addClass("l-button-over");
  53. }, function () {
  54. if (p.disabled) return;
  55. g.button.removeClass("l-button-over");
  56. });
  57. p.click && g.button.click(function ()
  58. {
  59. if (!p.disabled)
  60. p.click();
  61. });
  62. g.set(p);
  63. },
  64. _setIcon : function(url)
  65. {
  66. var g = this;
  67. if (!url)
  68. {
  69. g.button.removeClass("l-button-hasicon");
  70. g.button.find('img').remove();
  71. } else
  72. {
  73. g.button.addClass("l-button-hasicon");
  74. g.button.append('<img src="' + url + '" />');
  75. }
  76. },
  77. _setEnabled: function (value)
  78. {
  79. if (value)
  80. this.button.removeClass("l-button-disabled");
  81. },
  82. _setDisabled: function (value)
  83. {
  84. if (value) {
  85. this.button.addClass("l-button-disabled");
  86. this.options.disabled = true;
  87. } else {
  88. this.button.removeClass("l-button-disabled");
  89. this.options.disabled = false;
  90. }
  91. },
  92. _setWidth: function (value)
  93. {
  94. this.button.width(value);
  95. },
  96. _setText: function (value)
  97. {
  98. $("span", this.button).html(value);
  99. },
  100. setValue: function (value)
  101. {
  102. this.set('text', value);
  103. },
  104. getValue: function ()
  105. {
  106. return this.options.text;
  107. },
  108. setEnabled: function ()
  109. {
  110. this.set('disabled', false);
  111. },
  112. setDisabled: function ()
  113. {
  114. this.set('disabled', true);
  115. }
  116. });
  117. })(jQuery);