2018-11-13 07:41:12 +01:00
|
|
|
/*!
|
2020-05-13 21:36:00 +02:00
|
|
|
* Bootstrap button.js v5.0.0-alpha1 (https://getbootstrap.com/)
|
2020-03-28 11:29:08 +01:00
|
|
|
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2020-06-16 20:50:01 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2018-11-13 07:41:12 +01:00
|
|
|
*/
|
2018-07-24 02:51:14 +02:00
|
|
|
(function (global, factory) {
|
2020-06-16 20:50:01 +02:00
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js')) :
|
|
|
|
typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js'], factory) :
|
|
|
|
(global = global || self, global.Button = factory(global.Data, global.EventHandler));
|
|
|
|
}(this, (function (Data, EventHandler) { 'use strict';
|
2018-07-24 02:51:14 +02:00
|
|
|
|
2020-03-28 11:29:08 +01:00
|
|
|
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
|
|
|
|
EventHandler = EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default') ? EventHandler['default'] : EventHandler;
|
2018-07-24 02:51:14 +02:00
|
|
|
|
2019-03-01 17:31:34 +01:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2020-05-13 21:36:00 +02:00
|
|
|
* Bootstrap (v5.0.0-alpha1): util/index.js
|
2020-06-16 20:50:01 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2019-03-01 17:31:34 +01:00
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2019-08-27 15:03:21 +02:00
|
|
|
|
|
|
|
var getjQuery = function getjQuery() {
|
|
|
|
var _window = window,
|
|
|
|
jQuery = _window.jQuery;
|
|
|
|
|
|
|
|
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
|
|
|
|
return jQuery;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
2019-03-01 17:31:34 +01:00
|
|
|
|
2020-06-14 00:40:28 +02:00
|
|
|
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); } }
|
|
|
|
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
2018-11-13 07:41:12 +01:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Constants
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
var NAME = 'button';
|
2020-05-13 21:36:00 +02:00
|
|
|
var VERSION = '5.0.0-alpha1';
|
2018-11-13 07:41:12 +01:00
|
|
|
var DATA_KEY = 'bs.button';
|
|
|
|
var EVENT_KEY = "." + DATA_KEY;
|
|
|
|
var DATA_API_KEY = '.data-api';
|
2020-03-28 11:29:08 +01:00
|
|
|
var CLASS_NAME_ACTIVE = 'active';
|
2020-06-16 20:50:01 +02:00
|
|
|
var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
|
2020-03-28 11:29:08 +01:00
|
|
|
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
2019-10-08 08:39:10 +02:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Class Definition
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-08 02:07:38 +02:00
|
|
|
|
2020-03-28 11:29:08 +01:00
|
|
|
var Button = /*#__PURE__*/function () {
|
2018-11-13 07:41:12 +01:00
|
|
|
function Button(element) {
|
|
|
|
this._element = element;
|
2019-03-01 17:31:34 +01:00
|
|
|
Data.setData(element, DATA_KEY, this);
|
2018-11-13 07:41:12 +01:00
|
|
|
} // Getters
|
2015-08-13 06:12:03 +02:00
|
|
|
|
2017-09-06 06:05:12 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
var _proto = Button.prototype;
|
2017-09-06 06:05:12 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
// Public
|
|
|
|
_proto.toggle = function toggle() {
|
2020-06-16 20:50:01 +02:00
|
|
|
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
|
|
|
|
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
|
2018-11-13 07:41:12 +01:00
|
|
|
};
|
2015-05-08 02:07:38 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
_proto.dispose = function dispose() {
|
2019-03-01 17:31:34 +01:00
|
|
|
Data.removeData(this._element, DATA_KEY);
|
2018-11-13 07:41:12 +01:00
|
|
|
this._element = null;
|
2019-01-04 17:29:45 +01:00
|
|
|
} // Static
|
|
|
|
;
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2019-08-27 15:03:21 +02:00
|
|
|
Button.jQueryInterface = function jQueryInterface(config) {
|
2018-11-13 07:41:12 +01:00
|
|
|
return this.each(function () {
|
2019-03-01 17:31:34 +01:00
|
|
|
var data = Data.getData(this, DATA_KEY);
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
if (!data) {
|
|
|
|
data = new Button(this);
|
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
if (config === 'toggle') {
|
|
|
|
data[config]();
|
2017-09-30 23:28:03 +02:00
|
|
|
}
|
2018-11-13 07:41:12 +01:00
|
|
|
});
|
|
|
|
};
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2019-08-27 15:03:21 +02:00
|
|
|
Button.getInstance = function getInstance(element) {
|
2019-03-01 17:31:34 +01:00
|
|
|
return Data.getData(element, DATA_KEY);
|
|
|
|
};
|
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
_createClass(Button, null, [{
|
|
|
|
key: "VERSION",
|
|
|
|
get: function get() {
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
}]);
|
2015-05-08 02:07:38 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
return Button;
|
|
|
|
}();
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Data Api implementation
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-08 02:07:38 +02:00
|
|
|
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2020-06-16 20:50:01 +02:00
|
|
|
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
2018-11-13 07:41:12 +01:00
|
|
|
event.preventDefault();
|
2020-06-16 20:50:01 +02:00
|
|
|
var button = event.target.closest(SELECTOR_DATA_TOGGLE);
|
2019-03-01 17:31:34 +01:00
|
|
|
var data = Data.getData(button, DATA_KEY);
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
data = new Button(button);
|
|
|
|
}
|
|
|
|
|
|
|
|
data.toggle();
|
|
|
|
});
|
2019-08-27 15:03:21 +02:00
|
|
|
var $ = getjQuery();
|
2018-11-13 07:41:12 +01:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* jQuery
|
|
|
|
* ------------------------------------------------------------------------
|
2019-03-01 17:31:34 +01:00
|
|
|
* add .button to jQuery only if jQuery is present
|
2018-11-13 07:41:12 +01:00
|
|
|
*/
|
2015-05-08 02:07:38 +02:00
|
|
|
|
2019-07-24 08:13:50 +02:00
|
|
|
/* istanbul ignore if */
|
|
|
|
|
2019-08-27 15:03:21 +02:00
|
|
|
if ($) {
|
|
|
|
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
|
|
|
$.fn[NAME] = Button.jQueryInterface;
|
|
|
|
$.fn[NAME].Constructor = Button;
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2019-08-27 15:03:21 +02:00
|
|
|
$.fn[NAME].noConflict = function () {
|
|
|
|
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
|
|
|
return Button.jQueryInterface;
|
2019-03-01 17:31:34 +01:00
|
|
|
};
|
|
|
|
}
|
2015-05-08 02:07:38 +02:00
|
|
|
|
|
|
|
return Button;
|
2018-07-24 02:51:14 +02:00
|
|
|
|
2019-11-08 09:11:23 +01:00
|
|
|
})));
|
2018-07-24 02:51:14 +02:00
|
|
|
//# sourceMappingURL=button.js.map
|