UNPKG

@atlassian/aui

Version:

Atlassian User Interface Framework

113 lines (93 loc) 3.4 kB
(function (global, factory) { if (typeof define === "function" && define.amd) { define(['./jquery', './internal/log', './internal/amdify', './internal/skate'], factory); } else if (typeof exports !== "undefined") { factory(require('./jquery'), require('./internal/log'), require('./internal/amdify'), require('./internal/skate')); } else { var mod = { exports: {} }; factory(global.jquery, global.log, global.amdify, global.skate); global.button = mod.exports; } })(this, function (_jquery, _log, _amdify, _skate) { 'use strict'; var _jquery2 = _interopRequireDefault(_jquery); var logger = _interopRequireWildcard(_log); var _amdify2 = _interopRequireDefault(_amdify); var _skate2 = _interopRequireDefault(_skate); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _isBusy(button) { return button.hasAttribute('aria-busy') && button.getAttribute('aria-busy') === 'true'; } function isInputNode(button) { return button.nodeName === 'INPUT'; } (0, _skate2.default)('aui-button', { type: _skate2.default.type.CLASSNAME, prototype: { /** * Adds a spinner to the button and hides the text * * @returns {HTMLElement} */ busy: function busy() { if (isInputNode(this) || _isBusy(this)) { logger.warn('It is not valid to call busy() on an input button.'); return this; } (0, _jquery2.default)(this).spin(); this.setAttribute('aria-busy', true); this.setAttribute('busy', ''); return this; }, /** * Removes the spinner and shows the tick on the button * * @returns {HTMLElement} */ idle: function idle() { if (isInputNode(this) || !_isBusy(this)) { logger.warn('It is not valid to call idle() on an input button.'); return this; } (0, _jquery2.default)(this).spinStop(); this.removeAttribute('aria-busy'); this.removeAttribute('busy'); return this; }, /** * Removes the spinner and shows the tick on the button * * @returns {Boolean} */ isBusy: function isBusy() { if (isInputNode(this)) { logger.warn('It is not valid to call isBusy() on an input button.'); return false; } return _isBusy(this); } } }); (0, _amdify2.default)('aui/button'); }); //# sourceMappingURL=button.js.map