diff options
| author | Mark Otto <[email protected]> | 2016-06-12 21:17:14 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-06-12 21:17:14 -0700 |
| commit | aaad85bc306ccf35bd749ea43d2aa768e4ebabeb (patch) | |
| tree | 8011d6e04d1bb4c87356036eba55cc13639bc96a /docs/dist/js/umd/button.js | |
| parent | 8feae9075ae55be4e6cd0e884fbfa006a6639ceb (diff) | |
| parent | ce2e944aa6957528f23f1f7e680ac0cb4a75dcac (diff) | |
| download | bootstrap-aaad85bc306ccf35bd749ea43d2aa768e4ebabeb.tar.xz bootstrap-aaad85bc306ccf35bd749ea43d2aa768e4ebabeb.zip | |
Merge branch 'v4-dev' of https://github.com/twbs/bootstrap into v4-dev
Diffstat (limited to 'docs/dist/js/umd/button.js')
| -rw-r--r-- | docs/dist/js/umd/button.js | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/docs/dist/js/umd/button.js b/docs/dist/js/umd/button.js deleted file mode 100644 index dd6c5f7af..000000000 --- a/docs/dist/js/umd/button.js +++ /dev/null @@ -1,189 +0,0 @@ -(function (global, factory) { - if (typeof define === 'function' && define.amd) { - define(['exports', 'module'], factory); - } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') { - factory(exports, module); - } else { - var mod = { - exports: {} - }; - factory(mod.exports, mod); - global.button = mod.exports; - } -})(this, function (exports, module) { - /** - * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): 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 ($) { - - /** - * ------------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------------ - */ - - var NAME = 'button'; - var VERSION = '4.0.0-alpha.2'; - var DATA_KEY = 'bs.button'; - var EVENT_KEY = '.' + DATA_KEY; - var DATA_API_KEY = '.data-api'; - var JQUERY_NO_CONFLICT = $.fn[NAME]; - - 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_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY, - FOCUS_BLUR_DATA_API: 'focus' + EVENT_KEY + DATA_API_KEY + ' ' + ('blur' + EVENT_KEY + DATA_API_KEY) - }; - - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - var Button = (function () { - function Button(element) { - _classCallCheck(this, Button); - - this._element = element; - } - - /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - - // getters - - _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'); - } - - input.focus(); - } - } else { - this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE)); - } - - if (triggerChangeEvent) { - $(this._element).toggleClass(ClassName.ACTIVE); - } - } - }, { - key: 'dispose', - value: function dispose() { - $.removeData(this._element, DATA_KEY); - this._element = null; - } - - // static - - }], [{ - key: '_jQueryInterface', - 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](); - } - }); - } - }, { - key: 'VERSION', - get: function get() { - return VERSION; - } - }]); - - return Button; - })(); - - $(document).on(Event.CLICK_DATA_API, 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_DATA_API, 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); - - module.exports = Button; -}); |
