From 660505188241418ffda53b5eb848defecd5f57e1 Mon Sep 17 00:00:00 2001 From: fat Date: Thu, 7 May 2015 17:07:38 -0700 Subject: [PATCH] button -> es6 --- Gruntfile.js | 3 +- js/dist/alert.js | 8 +- js/dist/alert.js.map | 2 +- js/dist/button.js | 158 +++++++++++++++++++ js/dist/button.js.map | 1 + js/dist/util.js | 4 +- js/dist/util.js.map | 2 +- js/script-compiled.js | 305 ------------------------------------ js/src/alert.js | 8 +- js/src/button.js | 158 +++++++++++++++++++ js/src/util.js | 4 +- js/tests/index.html | 2 +- js/tests/unit/button.js | 58 ------- js/tests/visual/button.html | 8 +- 14 files changed, 338 insertions(+), 383 deletions(-) create mode 100644 js/dist/button.js create mode 100644 js/dist/button.js.map delete mode 100644 js/script-compiled.js create mode 100644 js/src/button.js diff --git a/Gruntfile.js b/Gruntfile.js index 09268ecb1f..c32f79f0e1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -64,7 +64,8 @@ module.exports = function (grunt) { dist: { files: { 'js/dist/util.js': 'js/src/util.js', - 'js/dist/alert.js': 'js/src/alert.js' + 'js/dist/alert.js': 'js/src/alert.js', + 'js/dist/button.js': 'js/src/button.js', } } }, diff --git a/js/dist/alert.js b/js/dist/alert.js index 76b280a0c3..4226dd61a7 100644 --- a/js/dist/alert.js +++ b/js/dist/alert.js @@ -11,7 +11,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * -------------------------------------------------------------------------- */ -var Alert = (function () { +var Alert = (function ($) { /** * ------------------------------------------------------------------------ @@ -62,6 +62,8 @@ var Alert = (function () { // public value: function close(element) { + element = element || this.element; + var rootElement = this._getRootElement(element); var customEvent = this._triggerCloseEvent(rootElement); @@ -167,10 +169,10 @@ var Alert = (function () { $.fn[NAME] = Alert._jQueryInterface; $.fn[NAME].Constructor = Alert; $.fn[NAME].noConflict = function () { - $.fn[NAME] = Alert._JQUERY_NO_CONFLICT; + $.fn[NAME] = JQUERY_NO_CONFLICT; return Alert._jQueryInterface; }; return Alert; -})(); +})(jQuery); //# sourceMappingURL=alert.js.map \ No newline at end of file diff --git a/js/dist/alert.js.map b/js/dist/alert.js.map index f3bc7ad7fc..aa106df1e8 100644 --- a/js/dist/alert.js.map +++ b/js/dist/alert.js.map @@ -1 +1 @@ -{"version":3,"sources":["js/src/alert.js"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,IAAM,KAAK,GAAG,CAAC,YAAM;;;;;;;;AASnB,MAAM,IAAI,GAAkB,OAAO,CAAA;AACnC,MAAM,OAAO,GAAe,OAAO,CAAA;AACnC,MAAM,QAAQ,GAAc,UAAU,CAAA;AACtC,MAAM,kBAAkB,GAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;AACtC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;AAE/B,MAAM,QAAQ,GAAG;AACf,WAAO,EAAG,wBAAwB;GACnC,CAAA;;AAED,MAAM,KAAK,GAAG;AACZ,SAAK,EAAI,gBAAgB;AACzB,UAAM,EAAG,iBAAiB;AAC1B,SAAK,EAAI,yBAAyB;GACnC,CAAA;;AAED,MAAM,SAAS,GAAG;AAChB,SAAK,EAAG,OAAO;AACf,QAAI,EAAI,MAAM;AACd,MAAE,EAAM,IAAI;GACb,CAAA;;;;;;;;MASK,KAAK;AAEE,aAFP,KAAK,CAEG,OAAO,EAAE;4BAFjB,KAAK;;AAGP,UAAI,OAAO,EAAE;AACX,YAAI,CAAC,OAAO,GAAG,OAAO,CAAA;OACvB;KACF;;iBANG,KAAK;;;;;aAWJ,eAAC,OAAO,EAAE;AACb,YAAI,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;AAC/C,YAAI,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;;AAEtD,YAAI,WAAW,CAAC,kBAAkB,EAAE,EAAE;AACpC,iBAAM;SACP;;AAED,YAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;OACjC;;;;;;aAKc,y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SAAO,KAAK,CAAA;CAEb,CAAA,EAAG,CAAA","file":"js/src/alert.js","sourcesContent":["import Util from './util'\n\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): alert.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Alert = (() => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'alert'\n const VERSION = '4.0.0'\n const DATA_KEY = 'bs.alert'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n const TRANSITION_DURATION = 150\n\n const Selector = {\n DISMISS : '[data-dismiss=\"alert\"]'\n }\n\n const Event = {\n CLOSE : 'close.bs.alert',\n CLOSED : 'closed.bs.alert',\n CLICK : 'click.bs.alert.data-api'\n }\n\n const ClassName = {\n ALERT : 'alert',\n FADE : 'fade',\n IN : 'in'\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Alert {\n\n constructor(element) {\n if (element) {\n this.element = element\n }\n }\n\n\n // public\n\n close(element) {\n let rootElement = this._getRootElement(element)\n let customEvent = this._triggerCloseEvent(rootElement)\n\n if (customEvent.isDefaultPrevented()) {\n return\n }\n\n this._removeElement(rootElement)\n }\n\n\n // private\n\n _getRootElement(element) {\n let parent = false\n let selector = Util.getSelectorFromElement(element)\n\n if (selector) {\n parent = $(selector)[0]\n }\n\n if (!parent) {\n parent = $(element).closest('.' + ClassName.ALERT)[0]\n }\n\n return parent\n }\n\n _triggerCloseEvent(element) {\n var closeEvent = $.Event(Event.CLOSE)\n $(element).trigger(closeEvent)\n return closeEvent\n }\n\n _removeElement(element) {\n $(element).removeClass(ClassName.IN)\n\n if (!Util.supportsTransitionEnd() ||\n !$(element).hasClass(ClassName.FADE)) {\n this._destroyElement(element)\n return\n }\n\n $(element)\n .one(Util.TRANSITION_END, this._destroyElement.bind(this, element))\n .emulateTransitionEnd(TRANSITION_DURATION)\n }\n\n _destroyElement(element) {\n $(element)\n .detach()\n .trigger(Event.CLOSED)\n .remove()\n }\n\n\n // static\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let $element = $(this)\n let data = $element.data(DATA_KEY)\n\n if (!data) {\n data = new Alert(this)\n $element.data(DATA_KEY, data)\n }\n\n if (config === 'close') {\n data[config](this)\n }\n })\n }\n\n static _handleDismiss(alertInstance) {\n return function (event) {\n if (event) {\n event.preventDefault()\n }\n\n alertInstance.close(this)\n }\n }\n\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n $(document).on(\n Event.CLICK,\n Selector.DISMISS,\n Alert._handleDismiss(new Alert())\n )\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Alert._jQueryInterface\n $.fn[NAME].Constructor = Alert\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = Alert._JQUERY_NO_CONFLICT\n return Alert._jQueryInterface\n }\n\n return Alert\n\n})()\n\nexport default Alert\n"]} \ No newline at end of file +{"version":3,"sources":["js/src/alert.js"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,IAAM,KAAK,GAAG,CAAC,UAAC,CAAC,EAAK;;;;;;;;AASpB,MAAM,IAAI,GAAkB,OAAO,CAAA;AACnC,MAAM,OAAO,GAAe,OAAO,CAAA;AACnC,MAAM,QAAQ,GAAc,UAAU,CAAA;AACtC,MAAM,kBAAkB,GAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;AACtC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;AAE/B,MAAM,QAAQ,GAAG;AACf,WAAO,EAAG,wBAAwB;GACnC,CAAA;;AAED,MAAM,KAAK,GAAG;AACZ,SAAK,EAAI,gBAAgB;AACzB,UAAM,EAAG,iBAAiB;AAC1B,SAAK,EAAI,yBAAyB;GACnC,CAAA;;AAED,MAAM,SAAS,GAAG;AAChB,S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KAAK,CAAC,IAAI,CAAC,CAAA;SAC1B,CAAA;OACF;;;WAhGG,KAAK;;;;;;;;;AA2GX,GAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CACZ,KAAK,CAAC,KAAK,EACX,QAAQ,CAAC,OAAO,EAChB,KAAK,CAAC,cAAc,CAAC,IAAI,KAAK,EAAE,CAAC,CAClC,CAAA;;;;;;;;AASD,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAe,KAAK,CAAC,gBAAgB,CAAA;AAC/C,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,GAAG,KAAK,CAAA;AAC9B,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,GAAI,YAAY;AACnC,KAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAA;AAC/B,WAAO,KAAK,CAAC,gBAAgB,CAAA;GAC9B,CAAA;;AAED,SAAO,KAAK,CAAA;CAEb,CAAA,CAAE,MAAM,CAAC,CAAA","file":"js/src/alert.js","sourcesContent":["import Util from './util'\n\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): alert.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Alert = (($) => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'alert'\n const VERSION = '4.0.0'\n const DATA_KEY = 'bs.alert'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n const TRANSITION_DURATION = 150\n\n const Selector = {\n DISMISS : '[data-dismiss=\"alert\"]'\n }\n\n const Event = {\n CLOSE : 'close.bs.alert',\n CLOSED : 'closed.bs.alert',\n CLICK : 'click.bs.alert.data-api'\n }\n\n const ClassName = {\n ALERT : 'alert',\n FADE : 'fade',\n IN : 'in'\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Alert {\n\n constructor(element) {\n if (element) {\n this.element = element\n }\n }\n\n\n // public\n\n close(element) {\n element = element || this.element\n\n let rootElement = this._getRootElement(element)\n let customEvent = this._triggerCloseEvent(rootElement)\n\n if (customEvent.isDefaultPrevented()) {\n return\n }\n\n this._removeElement(rootElement)\n }\n\n\n // private\n\n _getRootElement(element) {\n let parent = false\n let selector = Util.getSelectorFromElement(element)\n\n if (selector) {\n parent = $(selector)[0]\n }\n\n if (!parent) {\n parent = $(element).closest('.' + ClassName.ALERT)[0]\n }\n\n return parent\n }\n\n _triggerCloseEvent(element) {\n var closeEvent = $.Event(Event.CLOSE)\n $(element).trigger(closeEvent)\n return closeEvent\n }\n\n _removeElement(element) {\n $(element).removeClass(ClassName.IN)\n\n if (!Util.supportsTransitionEnd() ||\n !$(element).hasClass(ClassName.FADE)) {\n this._destroyElement(element)\n return\n }\n\n $(element)\n .one(Util.TRANSITION_END, this._destroyElement.bind(this, element))\n .emulateTransitionEnd(TRANSITION_DURATION)\n }\n\n _destroyElement(element) {\n $(element)\n .detach()\n .trigger(Event.CLOSED)\n .remove()\n }\n\n\n // static\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let $element = $(this)\n let data = $element.data(DATA_KEY)\n\n if (!data) {\n data = new Alert(this)\n $element.data(DATA_KEY, data)\n }\n\n if (config === 'close') {\n data[config](this)\n }\n })\n }\n\n static _handleDismiss(alertInstance) {\n return function (event) {\n if (event) {\n event.preventDefault()\n }\n\n alertInstance.close(this)\n }\n }\n\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n $(document).on(\n Event.CLICK,\n Selector.DISMISS,\n Alert._handleDismiss(new Alert())\n )\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Alert._jQueryInterface\n $.fn[NAME].Constructor = Alert\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Alert._jQueryInterface\n }\n\n return Alert\n\n})(jQuery)\n\nexport default Alert\n"]} \ No newline at end of file diff --git a/js/dist/button.js b/js/dist/button.js new file mode 100644 index 0000000000..76aa09a7f5 --- /dev/null +++ b/js/dist/button.js @@ -0,0 +1,158 @@ +'use strict'; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): button.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Button = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'button'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.button'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + + var ClassName = { + ACTIVE: 'active', + BUTTON: 'btn', + FOCUS: 'focus' + }; + + var Selector = { + DATA_TOGGLE_CARROT: '[data-toggle^="button"]', + DATA_TOGGLE: '[data-toggle="buttons"]', + INPUT: 'input', + ACTIVE: '.active', + BUTTON: '.btn' + }; + + var Event = { + CLICK: 'click.bs.button.data-api', + FOCUS_BLUR: 'focus.bs.button.data-api blur.bs.button.data-api' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Button = (function () { + function Button(element) { + _classCallCheck(this, Button); + + this.element = element; + } + + _createClass(Button, [{ + key: 'toggle', + + // public + + value: function toggle() { + var triggerChangeEvent = true; + var rootElement = $(this.element).closest(Selector.DATA_TOGGLE)[0]; + + if (rootElement) { + var input = $(this.element).find(Selector.INPUT)[0]; + + if (input) { + if (input.type === 'radio') { + if (input.checked && $(this.element).hasClass(ClassName.ACTIVE)) { + triggerChangeEvent = false; + } else { + var activeElement = $(rootElement).find(Selector.ACTIVE)[0]; + + if (activeElement) { + $(activeElement).removeClass(ClassName.ACTIVE); + } + } + } + + if (triggerChangeEvent) { + input.checked = !$(this.element).hasClass(ClassName.ACTIVE); + $(this.element).trigger('change'); + } + } + } else { + this.element.setAttribute('aria-pressed', !$(this.element).hasClass(ClassName.ACTIVE)); + } + + if (triggerChangeEvent) { + $(this.element).toggleClass(ClassName.ACTIVE); + } + } + }], [{ + key: '_jQueryInterface', + + // static + + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + if (!data) { + data = new Button(this); + $(this).data(DATA_KEY, data); + } + + if (config === 'toggle') { + data[config](); + } + }); + } + }]); + + return Button; + })(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK, Selector.DATA_TOGGLE_CARROT, function (event) { + event.preventDefault(); + + var button = event.target; + + if (!$(button).hasClass(ClassName.BUTTON)) { + button = $(button).closest(Selector.BUTTON); + } + + Button._jQueryInterface.call($(button), 'toggle'); + }).on(Event.FOCUS_BLUR, Selector.DATA_TOGGLE_CARROT, function (event) { + var button = $(event.target).closest(Selector.BUTTON)[0]; + $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Button._jQueryInterface; + $.fn[NAME].Constructor = Button; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Button._jQueryInterface; + }; + + return Button; +})(jQuery); +//# sourceMappingURL=button.js.map \ No newline at end of file diff --git a/js/dist/button.js.map b/js/dist/button.js.map new file mode 100644 index 0000000000..690b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AAC,IAAI,CAAC,CAAC,WAAW,GAAG,MAAM,CAAA;AAC/B,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,GAAI,YAAY;AACnC,KAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAA;AAC/B,WAAO,MAAM,CAAC,gBAAgB,CAAA;GAC/B,CAAA;;AAED,SAAO,MAAM,CAAA;CAEd,CAAA,CAAE,MAAM,CAAC,CAAA","file":"js/src/button.js","sourcesContent":["import Util from './util'\n\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): button.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Button = (($) => {\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'button'\n const VERSION = '4.0.0'\n const DATA_KEY = 'bs.button'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n const TRANSITION_DURATION = 150\n\n const ClassName = {\n ACTIVE : 'active',\n BUTTON : 'btn',\n FOCUS : 'focus'\n }\n\n const Selector = {\n DATA_TOGGLE_CARROT : '[data-toggle^=\"button\"]',\n DATA_TOGGLE : '[data-toggle=\"buttons\"]',\n INPUT : 'input',\n ACTIVE : '.active',\n BUTTON : '.btn'\n }\n\n const Event = {\n CLICK : 'click.bs.button.data-api',\n FOCUS_BLUR : 'focus.bs.button.data-api blur.bs.button.data-api'\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Button {\n\n constructor(element) {\n this.element = element\n }\n\n // public\n\n toggle() {\n let triggerChangeEvent = true\n let rootElement = $(this.element).closest(\n Selector.DATA_TOGGLE\n )[0]\n\n if (rootElement) {\n let input = $(this.element).find(Selector.INPUT)[0]\n\n if (input) {\n if (input.type === 'radio') {\n if (input.checked &&\n $(this.element).hasClass(ClassName.ACTIVE)) {\n triggerChangeEvent = false\n\n } else {\n let activeElement = $(rootElement).find(Selector.ACTIVE)[0]\n\n if (activeElement) {\n $(activeElement).removeClass(ClassName.ACTIVE)\n }\n }\n }\n\n if (triggerChangeEvent) {\n input.checked = !$(this.element).hasClass(ClassName.ACTIVE)\n $(this.element).trigger('change')\n }\n }\n } else {\n this.element.setAttribute('aria-pressed',\n !$(this.element).hasClass(ClassName.ACTIVE))\n }\n\n if (triggerChangeEvent) {\n $(this.element).toggleClass(ClassName.ACTIVE)\n }\n }\n\n\n // static\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let data = $(this).data(DATA_KEY)\n\n if (!data) {\n data = new Button(this)\n $(this).data(DATA_KEY, data)\n }\n\n if (config === 'toggle') {\n data[config]()\n }\n })\n }\n\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n $(document)\n .on(Event.CLICK, Selector.DATA_TOGGLE_CARROT, function (event) {\n event.preventDefault()\n\n let button = event.target\n\n if (!$(button).hasClass(ClassName.BUTTON)) {\n button = $(button).closest(Selector.BUTTON)\n }\n\n Button._jQueryInterface.call($(button), 'toggle')\n })\n .on(Event.FOCUS_BLUR, Selector.DATA_TOGGLE_CARROT, function (event) {\n var button = $(event.target).closest(Selector.BUTTON)[0]\n $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type))\n })\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Button._jQueryInterface\n $.fn[NAME].Constructor = Button\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Button._jQueryInterface\n }\n\n return Button\n\n})(jQuery)\n\nexport default Button\n"]} \ No newline at end of file diff --git a/js/dist/util.js b/js/dist/util.js index 4c8c4e6392..4f25e200da 100644 --- a/js/dist/util.js +++ b/js/dist/util.js @@ -7,7 +7,7 @@ 'use strict'; -var Util = (function () { +var Util = (function ($) { /** * ------------------------------------------------------------------------ @@ -119,5 +119,5 @@ var Util = (function () { setTransitionEndSupport(); return Util; -})(); +})(jQuery); //# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/js/dist/util.js.map b/js/dist/util.js.map index 71ad2163a1..5f640b50e3 100644 --- a/js/dist/util.js.map +++ b/js/dist/util.js.map @@ -1 +1 @@ -{"version":3,"sources":["js/src/util.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAM,IAAI,GAAG,CAAC,YAAM;;;;;;;;AASlB,MAAI,UAAU,GAAG,KAAK,CAAA;;AAEtB,MAAM,kBAAkB,GAAG;AACzB,oBAAgB,EAAG,qBAAqB;AACxC,iBAAa,EAAM,eAAe;AAClC,eAAW,EAAQ,+BAA+B;AAClD,cAAU,EAAS,eAAe;GACnC,CAAA;;AAED,WAAS,4BAA4B,GAAG;AACtC,WAAO;AACL,cAAQ,EAAE,UAAU,CAAC,GAAG;AACxB,kBAAY,EAAE,UAAU,CAAC,GAAG;AAC5B,YAAM,EAAE,gBAAU,KAAK,EAAE;AACvB,YAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;AAC5B,iBAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;SACtD;OACF;KACF,CAAA;GACF;;AAED,WAAS,iBAAiB,GAAG;AAC3B,QAAI,MAAM,CAAC,KAAK,EAAE;AAChB,aAAO,KAAK,CAAA;KACb;;AAED,QAAI,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;;AAE5C,SAAK,IAAI,IAAI,IAAI,kBAAkB,EAAE;AACnC,UAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;AAChC,eAAO,EAAE,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAA;OACzC;KACF;;AAED,WAAO,KAAK,CAAA;GACb;;AAED,WAAS,qBAAqB,CAAC,Q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AAQ,CAAA;KAChB;;AAED,UAAM,EAAA,gBAAC,OAAO,EAAE;AACd,UAAI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;KACtD;;AAED,yBAAqB,EAAA,iCAAG;AACtB,aAAO,CAAC,CAAC,UAAU,CAAA;KACpB;;GAEF,CAAA;;AAED,yBAAuB,EAAE,CAAA;;AAEzB,SAAO,IAAI,CAAA;CAEZ,CAAA,EAAG,CAAA","file":"js/src/util.js","sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): util.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Util = (() => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Private TransitionEnd Helpers\n * ------------------------------------------------------------------------\n */\n\n let transition = false\n\n const TransitionEndEvent = {\n WebkitTransition : 'webkitTransitionEnd',\n MozTransition : 'transitionend',\n OTransition : 'oTransitionEnd otransitionend',\n transition : 'transitionend'\n }\n\n function getSpecialTransitionEndEvent() {\n return {\n bindType: transition.end,\n delegateType: transition.end,\n handle: function (event) {\n if ($(event.target).is(this)) {\n return event.handleObj.handler.apply(this, arguments)\n }\n }\n }\n }\n\n function transitionEndTest() {\n if (window.QUnit) {\n return false\n }\n\n let el = document.createElement('bootstrap')\n\n for (var name in TransitionEndEvent) {\n if (el.style[name] !== undefined) {\n return { end: TransitionEndEvent[name] }\n }\n }\n\n return false\n }\n\n function transitionEndEmulator(duration) {\n let called = false\n\n $(this).one(Util.TRANSITION_END, function () {\n called = true\n })\n\n setTimeout(() => {\n if (!called) {\n $(this).trigger(transition.end)\n }\n }, duration)\n\n return this\n }\n\n function setTransitionEndSupport() {\n transition = transitionEndTest()\n\n $.fn.emulateTransitionEnd = transitionEndEmulator\n\n if (Util.supportsTransitionEnd()) {\n $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()\n }\n }\n\n\n /**\n * --------------------------------------------------------------------------\n * Public Util Api\n * --------------------------------------------------------------------------\n */\n\n let Util = {\n\n TRANSITION_END: 'bsTransitionEnd',\n\n getUID(prefix) {\n do prefix += ~~(Math.random() * 1000000)\n while (document.getElementById(prefix))\n return prefix\n },\n\n getSelectorFromElement(element) {\n let selector = element.getAttribute('data-target')\n\n if (!selector) {\n selector = element.getAttribute('href') || ''\n selector = /^#[a-z]/i.test(selector) ? selector : null\n }\n\n return selector\n },\n\n reflow(element) {\n new Function('bs', 'return bs')(element.offsetHeight)\n },\n\n supportsTransitionEnd() {\n return !!transition\n }\n\n }\n\n setTransitionEndSupport()\n\n return Util\n\n})()\n\nexport default Util\n"]} \ No newline at end of file +{"version":3,"sources":["js/src/util.js"],"names":[],"mappings":";;;;;;;;;AAOA,IAAM,IAAI,GAAG,CAAC,UAAC,CAAC,EAAK;;;;;;;;AASnB,MAAI,UAAU,GAAG,KAAK,CAAA;;AAEtB,MAAM,kBAAkB,GAAG;AACzB,oBAAgB,EAAG,qBAAqB;AACxC,iBAAa,EAAM,eAAe;AAClC,eAAW,EAAQ,+BAA+B;AAClD,cAAU,EAAS,eAAe;GACnC,CAAA;;AAED,WAAS,4BAA4B,GAAG;AACtC,WAAO;AACL,cAAQ,EAAE,UAAU,CAAC,GAAG;AACxB,kBAAY,EAAE,UAAU,CAAC,GAAG;AAC5B,YAAM,EAAE,gBAAU,KAAK,EAAE;AACvB,YAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;AAC5B,iBAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;SACtD;OACF;KACF,CAAA;GACF;;AAED,WAAS,iBAAiB,GAAG;AAC3B,QAAI,MAAM,CAAC,KAAK,EAAE;AAChB,aAAO,KAAK,CAAA;KACb;;AAED,QAAI,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;;A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,YAAY,CAAC,aAAa,CAAC,CAAA;;AAElD,UAAI,CAAC,QAAQ,EAAE;AACb,gBAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;AAC7C,gBAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAA;OACvD;;AAED,aAAO,QAAQ,CAAA;KAChB;;AAED,UAAM,EAAA,gBAAC,OAAO,EAAE;AACd,UAAI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;KACtD;;AAED,yBAAqB,EAAA,iCAAG;AACtB,aAAO,CAAC,CAAC,UAAU,CAAA;KACpB;;GAEF,CAAA;;AAED,yBAAuB,EAAE,CAAA;;AAEzB,SAAO,IAAI,CAAA;CAEZ,CAAA,CAAE,MAAM,CAAC,CAAA","file":"js/src/util.js","sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): util.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Util = (($) => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Private TransitionEnd Helpers\n * ------------------------------------------------------------------------\n */\n\n let transition = false\n\n const TransitionEndEvent = {\n WebkitTransition : 'webkitTransitionEnd',\n MozTransition : 'transitionend',\n OTransition : 'oTransitionEnd otransitionend',\n transition : 'transitionend'\n }\n\n function getSpecialTransitionEndEvent() {\n return {\n bindType: transition.end,\n delegateType: transition.end,\n handle: function (event) {\n if ($(event.target).is(this)) {\n return event.handleObj.handler.apply(this, arguments)\n }\n }\n }\n }\n\n function transitionEndTest() {\n if (window.QUnit) {\n return false\n }\n\n let el = document.createElement('bootstrap')\n\n for (var name in TransitionEndEvent) {\n if (el.style[name] !== undefined) {\n return { end: TransitionEndEvent[name] }\n }\n }\n\n return false\n }\n\n function transitionEndEmulator(duration) {\n let called = false\n\n $(this).one(Util.TRANSITION_END, function () {\n called = true\n })\n\n setTimeout(() => {\n if (!called) {\n $(this).trigger(transition.end)\n }\n }, duration)\n\n return this\n }\n\n function setTransitionEndSupport() {\n transition = transitionEndTest()\n\n $.fn.emulateTransitionEnd = transitionEndEmulator\n\n if (Util.supportsTransitionEnd()) {\n $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()\n }\n }\n\n\n /**\n * --------------------------------------------------------------------------\n * Public Util Api\n * --------------------------------------------------------------------------\n */\n\n let Util = {\n\n TRANSITION_END: 'bsTransitionEnd',\n\n getUID(prefix) {\n do prefix += ~~(Math.random() * 1000000)\n while (document.getElementById(prefix))\n return prefix\n },\n\n getSelectorFromElement(element) {\n let selector = element.getAttribute('data-target')\n\n if (!selector) {\n selector = element.getAttribute('href') || ''\n selector = /^#[a-z]/i.test(selector) ? selector : null\n }\n\n return selector\n },\n\n reflow(element) {\n new Function('bs', 'return bs')(element.offsetHeight)\n },\n\n supportsTransitionEnd() {\n return !!transition\n }\n\n }\n\n setTransitionEndSupport()\n\n return Util\n\n})(jQuery)\n\nexport default Util\n"]} \ No newline at end of file diff --git a/js/script-compiled.js b/js/script-compiled.js deleted file mode 100644 index 2a50eb3b3c..0000000000 --- a/js/script-compiled.js +++ /dev/null @@ -1,305 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -/** - * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): alert.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * -------------------------------------------------------------------------- - */ - -var _util = require('util'); - -var _util2 = _interopRequireDefault(_util); - -/** - * -------------------------------------------------------------------------- - * Constants - * -------------------------------------------------------------------------- - */ - -var NAME = 'alert'; -var VERSION = '4.0.0'; -var DATA_KEY = 'bs.alert'; -var JQUERY_NO_CONFLICT = $.fn[NAME]; -var TRANSITION_DURATION = 150; - -var Selector = { - DISMISS: '[data-dismiss="alert"]' -}; - -var Event = { - CLOSE: 'close.bs.alert', - CLOSED: 'closed.bs.alert', - CLICK: 'click.bs.alert.data-api' -}; - -var ClassName = { - ALERT: 'alert', - FADE: 'fade', - IN: 'in' -}; - -/** - * -------------------------------------------------------------------------- - * Class Definition - * -------------------------------------------------------------------------- - */ - -var Alert = (function () { - function Alert(element) { - _classCallCheck(this, Alert); - - if (element) { - this.element = element; - } - } - - _createClass(Alert, [{ - key: 'close', - - // public - - value: function close(element) { - var rootElement = this._getRootElement(element); - var customEvent = this._triggerCloseEvent(rootElement); - - if (customEvent.isDefaultPrevented()) { - return; - } - - this._removeElement(rootElement); - } - }, { - key: '_getRootElement', - - // private - - value: function _getRootElement(element) { - var parent = false; - var selector = _util2['default'].getSelectorFromElement(element); - - if (selector) { - parent = $(selector)[0]; - } - - if (!parent) { - parent = $(element).closest('.' + ClassName.ALERT)[0]; - } - - return parent; - } - }, { - key: '_triggerCloseEvent', - value: function _triggerCloseEvent(element) { - var closeEvent = $.Event(Event.CLOSE); - $(element).trigger(closeEvent); - return closeEvent; - } - }, { - key: '_removeElement', - value: function _removeElement(element) { - $(element).removeClass(ClassName.IN); - - if (!_util2['default'].supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { - this._destroyElement(element); - return; - } - - $(element).one(_util2['default'].TRANSITION_END, this._destroyElement.bind(this, element)).emulateTransitionEnd(TRANSITION_DURATION); - } - }, { - key: '_destroyElement', - value: function _destroyElement(element) { - $(element).detach().trigger(Event.CLOSED).remove(); - } - }], [{ - key: '_jQueryInterface', - - // static - - value: function _jQueryInterface(config) { - return this.each(function () { - var $element = $(this); - var data = $element.data(DATA_KEY); - - if (!data) { - data = new Alert(this); - $element.data(DATA_KEY, data); - } - - if (config === 'close') { - data[config](this); - } - }); - } - }, { - key: '_handleDismiss', - value: function _handleDismiss(alertInstance) { - return function (event) { - if (event) { - event.preventDefault(); - } - - alertInstance.close(this); - }; - } - }]); - - return Alert; -})(); - -exports.Alert = Alert; - -/** - * -------------------------------------------------------------------------- - * Data Api implementation - * -------------------------------------------------------------------------- - */ - -$(document).on(Event.CLICK, Selector.DISMISS, Alert._handleDismiss(new Alert())); - -/** - * -------------------------------------------------------------------------- - * jQuery - * -------------------------------------------------------------------------- - */ - -$.fn[NAME] = Alert._jQueryInterface; -$.fn[NAME].Constructor = Alert; -$.fn[NAME].noConflict = function () { - $.fn[NAME] = Alert._JQUERY_NO_CONFLICT; - return Alert._jQueryInterface; -}; -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -/** - * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): util.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * -------------------------------------------------------------------------- - */ - -/** - * -------------------------------------------------------------------------- - * Public Util Api - * -------------------------------------------------------------------------- - */ - -var Util = { - - TRANSITION_END: 'bsTransitionEnd', - - getUID: function getUID(prefix) { - do prefix += ~ ~(Math.random() * 1000000); while (document.getElementById(prefix)); - return prefix; - }, - - getSelectorFromElement: function getSelectorFromElement(element) { - var selector = element.getAttribute('data-target'); - - if (!selector) { - selector = element.getAttribute('href') || ''; - selector = /^#[a-z]/i.test(selector) ? selector : null; - } - - return selector; - }, - - reflow: function reflow(element) { - new Function('bs', 'return bs')(element.offsetHeight); - }, - - supportsTransitionEnd: function supportsTransitionEnd() { - return !!transition; - } - -}; - -exports['default'] = Util; - -/** - * -------------------------------------------------------------------------- - * Private TransitionEnd Helpers - * -------------------------------------------------------------------------- - */ - -var transition = false; - -var TransitionEndEvent = { - WebkitTransition: 'webkitTransitionEnd', - MozTransition: 'transitionend', - OTransition: 'oTransitionEnd otransitionend', - transition: 'transitionend' -}; - -function getSpecialTransitionEndEvent() { - return { - bindType: transition.end, - delegateType: transition.end, - handle: function handle(event) { - if ($(event.target).is(this)) { - return event.handleObj.handler.apply(this, arguments); - } - } - }; -} - -function transitionEndTest() { - if (window.QUnit) { - return false; - } - - var el = document.createElement('bootstrap'); - - for (var name in TransitionEndEvent) { - if (el.style[name] !== undefined) { - return { end: TransitionEndEvent[name] }; - } - } - - return false; -} - -function transitionEndEmulator(duration) { - var _this = this; - - var called = false; - - $(this).one(Util.TRANSITION_END, function () { - called = true; - }); - - setTimeout(function () { - if (!called) { - $(_this).trigger(transition.end); - } - }, duration); - - return this; -} - -function setTransitionEndSupport() { - transition = transitionEndTest(); - - $.fn.emulateTransitionEnd = transitionEndEmulator; - - if (Util.supportsTransitionEnd()) { - $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); - } -} - -setTransitionEndSupport(); -module.exports = exports['default']; diff --git a/js/src/alert.js b/js/src/alert.js index d69ad8910d..67a1ceda42 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -8,7 +8,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Alert = (() => { +const Alert = (($) => { /** @@ -58,6 +58,8 @@ const Alert = (() => { // public close(element) { + element = element || this.element + let rootElement = this._getRootElement(element) let customEvent = this._triggerCloseEvent(rootElement) @@ -167,12 +169,12 @@ const Alert = (() => { $.fn[NAME] = Alert._jQueryInterface $.fn[NAME].Constructor = Alert $.fn[NAME].noConflict = function () { - $.fn[NAME] = Alert._JQUERY_NO_CONFLICT + $.fn[NAME] = JQUERY_NO_CONFLICT return Alert._jQueryInterface } return Alert -})() +})(jQuery) export default Alert diff --git a/js/src/button.js b/js/src/button.js new file mode 100644 index 0000000000..7e93449230 --- /dev/null +++ b/js/src/button.js @@ -0,0 +1,158 @@ +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): button.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +const Button = (($) => { + + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + const NAME = 'button' + const VERSION = '4.0.0' + const DATA_KEY = 'bs.button' + const JQUERY_NO_CONFLICT = $.fn[NAME] + const TRANSITION_DURATION = 150 + + const ClassName = { + ACTIVE : 'active', + BUTTON : 'btn', + FOCUS : 'focus' + } + + const Selector = { + DATA_TOGGLE_CARROT : '[data-toggle^="button"]', + DATA_TOGGLE : '[data-toggle="buttons"]', + INPUT : 'input', + ACTIVE : '.active', + BUTTON : '.btn' + } + + const Event = { + CLICK : 'click.bs.button.data-api', + FOCUS_BLUR : 'focus.bs.button.data-api blur.bs.button.data-api' + } + + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + class Button { + + constructor(element) { + this.element = element + } + + // public + + toggle() { + let triggerChangeEvent = true + let rootElement = $(this.element).closest( + Selector.DATA_TOGGLE + )[0] + + if (rootElement) { + let input = $(this.element).find(Selector.INPUT)[0] + + if (input) { + if (input.type === 'radio') { + if (input.checked && + $(this.element).hasClass(ClassName.ACTIVE)) { + triggerChangeEvent = false + + } else { + let activeElement = $(rootElement).find(Selector.ACTIVE)[0] + + if (activeElement) { + $(activeElement).removeClass(ClassName.ACTIVE) + } + } + } + + if (triggerChangeEvent) { + input.checked = !$(this.element).hasClass(ClassName.ACTIVE) + $(this.element).trigger('change') + } + } + } else { + this.element.setAttribute('aria-pressed', + !$(this.element).hasClass(ClassName.ACTIVE)) + } + + if (triggerChangeEvent) { + $(this.element).toggleClass(ClassName.ACTIVE) + } + } + + + // static + + static _jQueryInterface(config) { + return this.each(function () { + let data = $(this).data(DATA_KEY) + + if (!data) { + data = new Button(this) + $(this).data(DATA_KEY, data) + } + + if (config === 'toggle') { + data[config]() + } + }) + } + + } + + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document) + .on(Event.CLICK, Selector.DATA_TOGGLE_CARROT, function (event) { + event.preventDefault() + + let button = event.target + + if (!$(button).hasClass(ClassName.BUTTON)) { + button = $(button).closest(Selector.BUTTON) + } + + Button._jQueryInterface.call($(button), 'toggle') + }) + .on(Event.FOCUS_BLUR, Selector.DATA_TOGGLE_CARROT, function (event) { + var button = $(event.target).closest(Selector.BUTTON)[0] + $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)) + }) + + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Button._jQueryInterface + $.fn[NAME].Constructor = Button + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT + return Button._jQueryInterface + } + + return Button + +})(jQuery) + +export default Button diff --git a/js/src/util.js b/js/src/util.js index 68205edef1..abc548a45f 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -5,7 +5,7 @@ * -------------------------------------------------------------------------- */ -const Util = (() => { +const Util = (($) => { /** @@ -119,6 +119,6 @@ const Util = (() => { return Util -})() +})(jQuery) export default Util diff --git a/js/tests/index.html b/js/tests/index.html index 536e34c747..29c84e2cc7 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -132,9 +132,9 @@ + - diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 691796c428..5648506cf5 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -32,64 +32,6 @@ $(function () { assert.strictEqual($button[0], $el[0], 'collection contains element') }) - QUnit.test('should return set state to loading', function (assert) { - assert.expect(4) - var $btn = $('') - assert.strictEqual($btn.html(), 'mdo', 'btn text equals mdo') - $btn.bootstrapButton('loading') - var done = assert.async() - setTimeout(function () { - assert.strictEqual($btn.html(), 'fat', 'btn text equals fat') - assert.ok($btn[0].hasAttribute('disabled'), 'btn is disabled') - assert.ok($btn.hasClass('disabled'), 'btn has disabled class') - done() - }, 0) - }) - - QUnit.test('should return reset state', function (assert) { - assert.expect(7) - var $btn = $('') - assert.strictEqual($btn.html(), 'mdo', 'btn text equals mdo') - $btn.bootstrapButton('loading') - var doneOne = assert.async() - setTimeout(function () { - assert.strictEqual($btn.html(), 'fat', 'btn text equals fat') - assert.ok($btn[0].hasAttribute('disabled'), 'btn is disabled') - assert.ok($btn.hasClass('disabled'), 'btn has disabled class') - doneOne() - var doneTwo = assert.async() - $btn.bootstrapButton('reset') - setTimeout(function () { - assert.strictEqual($btn.html(), 'mdo', 'btn text equals mdo') - assert.ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled') - assert.ok(!$btn.hasClass('disabled'), 'btn does not have disabled class') - doneTwo() - }, 0) - }, 0) - }) - - QUnit.test('should work with an empty string as reset state', function (assert) { - assert.expect(7) - var $btn = $('') diff --git a/js/tests/visual/button.html b/js/tests/visual/button.html index d92a083296..a6eed7e05a 100644 --- a/js/tests/visual/button.html +++ b/js/tests/visual/button.html @@ -22,10 +22,6 @@

Button Bootstrap Visual Test

- -
@@ -56,8 +52,8 @@ - - + +