diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2016-10-22 09:20:53 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2016-10-22 09:20:53 +0300 |
commit | afd171105704c314bf699810875c72a612988a72 (patch) | |
tree | c6045a971c84ef6eadfe7d5b90044bd33f2b7cbe /assets/javascripts/bootstrap/button.js | |
parent | d527714693edb72688eb8c239228b2db66e56ded (diff) |
rake update[v4.0.0-alpha.5]
Diffstat (limited to 'assets/javascripts/bootstrap/button.js')
-rw-r--r-- | assets/javascripts/bootstrap/button.js | 129 |
1 files changed, 61 insertions, 68 deletions
diff --git a/assets/javascripts/bootstrap/button.js b/assets/javascripts/bootstrap/button.js index 910b093..932c68f 100644 --- a/assets/javascripts/bootstrap/button.js +++ b/assets/javascripts/bootstrap/button.js @@ -1,17 +1,15 @@ +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-alpha.4): button.js + * Bootstrap (v4.0.0-alpha.5): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -'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'); } } - -var Button = (function ($) { +var Button = function ($) { /** * ------------------------------------------------------------------------ @@ -20,7 +18,7 @@ var Button = (function ($) { */ var NAME = 'button'; - var VERSION = '4.0.0-alpha.4'; + var VERSION = '4.0.0-alpha.5'; var DATA_KEY = 'bs.button'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; @@ -51,87 +49,76 @@ var Button = (function ($) { * ------------------------------------------------------------------------ */ - var Button = (function () { + var Button = function () { function Button(element) { _classCallCheck(this, Button); this._element = element; } - /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - // getters - _createClass(Button, [{ - key: 'toggle', + // public - // public + Button.prototype.toggle = function toggle() { + var triggerChangeEvent = true; + var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0]; - 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 (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 (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 (activeElement) { + $(activeElement).removeClass(ClassName.ACTIVE); } } + } - if (triggerChangeEvent) { - input.checked = !$(this._element).hasClass(ClassName.ACTIVE); - $(this._element).trigger('change'); - } - - input.focus(); + 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); + input.focus(); } + } else { + this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE)); } - }, { - key: 'dispose', - value: function dispose() { - $.removeData(this._element, DATA_KEY); - this._element = null; + + if (triggerChangeEvent) { + $(this._element).toggleClass(ClassName.ACTIVE); } + }; - // static + Button.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + }; - }], [{ - key: '_jQueryInterface', - value: function _jQueryInterface(config) { - return this.each(function () { - var data = $(this).data(DATA_KEY); + // static - if (!data) { - data = new Button(this); - $(this).data(DATA_KEY, data); - } + Button._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); - if (config === 'toggle') { - data[config](); - } - }); - } - }, { + if (!data) { + data = new Button(this); + $(this).data(DATA_KEY, data); + } + + if (config === 'toggle') { + data[config](); + } + }); + }; + + _createClass(Button, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -139,7 +126,13 @@ var Button = (function ($) { }]); return Button; - })(); + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { event.preventDefault(); @@ -170,4 +163,4 @@ var Button = (function ($) { }; return Button; -})(jQuery); +}(jQuery); |