buttons.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var AIRTIME = (function(AIRTIME) {
  2. var mod, DEFAULT_CLASS = 'ui-button ui-state-default', DISABLED_CLASS = 'ui-state-disabled';
  3. if (AIRTIME.button === undefined) {
  4. AIRTIME.button = {};
  5. }
  6. mod = AIRTIME.button;
  7. mod.isDisabled = function(c, useParent) {
  8. var button = $("." + c);
  9. if (useParent) {
  10. button = button.parent();
  11. }
  12. if (button.hasClass(DISABLED_CLASS)) {
  13. return true;
  14. }
  15. return false;
  16. };
  17. mod.enableButton = function(c, useParent) {
  18. if (useParent) {
  19. var button = $("." + c).parent();
  20. } else {
  21. var button = $("." + c);
  22. }
  23. if (button.hasClass(DISABLED_CLASS)) {
  24. button.removeClass(DISABLED_CLASS);
  25. button.removeAttr('disabled');
  26. }
  27. };
  28. mod.disableButton = function(c, useParent) {
  29. if (useParent) {
  30. var button = $("." + c).parent();
  31. } else {
  32. var button = $("." + c);
  33. }
  34. if (!button.hasClass(DISABLED_CLASS)) {
  35. button.addClass(DISABLED_CLASS);
  36. button.attr('disabled', 'disabled');
  37. }
  38. };
  39. return AIRTIME;
  40. }(AIRTIME || {}));