modal.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*!
  2. * Bootstrap modal.js v4.6.2 (https://getbootstrap.com/)
  3. * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
  8. typeof define === 'function' && define.amd ? define(['jquery', './util'], factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.jQuery, global.Util));
  10. })(this, (function ($, Util) { 'use strict';
  11. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  12. var $__default = /*#__PURE__*/_interopDefaultLegacy($);
  13. var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util);
  14. function _defineProperties(target, props) {
  15. for (var i = 0; i < props.length; i++) {
  16. var descriptor = props[i];
  17. descriptor.enumerable = descriptor.enumerable || false;
  18. descriptor.configurable = true;
  19. if ("value" in descriptor) descriptor.writable = true;
  20. Object.defineProperty(target, descriptor.key, descriptor);
  21. }
  22. }
  23. function _createClass(Constructor, protoProps, staticProps) {
  24. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  25. if (staticProps) _defineProperties(Constructor, staticProps);
  26. Object.defineProperty(Constructor, "prototype", {
  27. writable: false
  28. });
  29. return Constructor;
  30. }
  31. function _extends() {
  32. _extends = Object.assign ? Object.assign.bind() : function (target) {
  33. for (var i = 1; i < arguments.length; i++) {
  34. var source = arguments[i];
  35. for (var key in source) {
  36. if (Object.prototype.hasOwnProperty.call(source, key)) {
  37. target[key] = source[key];
  38. }
  39. }
  40. }
  41. return target;
  42. };
  43. return _extends.apply(this, arguments);
  44. }
  45. /**
  46. * Constants
  47. */
  48. var NAME = 'modal';
  49. var VERSION = '4.6.2';
  50. var DATA_KEY = 'bs.modal';
  51. var EVENT_KEY = "." + DATA_KEY;
  52. var DATA_API_KEY = '.data-api';
  53. var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
  54. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  55. var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
  56. var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
  57. var CLASS_NAME_BACKDROP = 'modal-backdrop';
  58. var CLASS_NAME_OPEN = 'modal-open';
  59. var CLASS_NAME_FADE = 'fade';
  60. var CLASS_NAME_SHOW = 'show';
  61. var CLASS_NAME_STATIC = 'modal-static';
  62. var EVENT_HIDE = "hide" + EVENT_KEY;
  63. var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY;
  64. var EVENT_HIDDEN = "hidden" + EVENT_KEY;
  65. var EVENT_SHOW = "show" + EVENT_KEY;
  66. var EVENT_SHOWN = "shown" + EVENT_KEY;
  67. var EVENT_FOCUSIN = "focusin" + EVENT_KEY;
  68. var EVENT_RESIZE = "resize" + EVENT_KEY;
  69. var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY;
  70. var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY;
  71. var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY;
  72. var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY;
  73. var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
  74. var SELECTOR_DIALOG = '.modal-dialog';
  75. var SELECTOR_MODAL_BODY = '.modal-body';
  76. var SELECTOR_DATA_TOGGLE = '[data-toggle="modal"]';
  77. var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
  78. var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  79. var SELECTOR_STICKY_CONTENT = '.sticky-top';
  80. var Default = {
  81. backdrop: true,
  82. keyboard: true,
  83. focus: true,
  84. show: true
  85. };
  86. var DefaultType = {
  87. backdrop: '(boolean|string)',
  88. keyboard: 'boolean',
  89. focus: 'boolean',
  90. show: 'boolean'
  91. };
  92. /**
  93. * Class definition
  94. */
  95. var Modal = /*#__PURE__*/function () {
  96. function Modal(element, config) {
  97. this._config = this._getConfig(config);
  98. this._element = element;
  99. this._dialog = element.querySelector(SELECTOR_DIALOG);
  100. this._backdrop = null;
  101. this._isShown = false;
  102. this._isBodyOverflowing = false;
  103. this._ignoreBackdropClick = false;
  104. this._isTransitioning = false;
  105. this._scrollbarWidth = 0;
  106. } // Getters
  107. var _proto = Modal.prototype;
  108. // Public
  109. _proto.toggle = function toggle(relatedTarget) {
  110. return this._isShown ? this.hide() : this.show(relatedTarget);
  111. };
  112. _proto.show = function show(relatedTarget) {
  113. var _this = this;
  114. if (this._isShown || this._isTransitioning) {
  115. return;
  116. }
  117. var showEvent = $__default["default"].Event(EVENT_SHOW, {
  118. relatedTarget: relatedTarget
  119. });
  120. $__default["default"](this._element).trigger(showEvent);
  121. if (showEvent.isDefaultPrevented()) {
  122. return;
  123. }
  124. this._isShown = true;
  125. if ($__default["default"](this._element).hasClass(CLASS_NAME_FADE)) {
  126. this._isTransitioning = true;
  127. }
  128. this._checkScrollbar();
  129. this._setScrollbar();
  130. this._adjustDialog();
  131. this._setEscapeEvent();
  132. this._setResizeEvent();
  133. $__default["default"](this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
  134. return _this.hide(event);
  135. });
  136. $__default["default"](this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () {
  137. $__default["default"](_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) {
  138. if ($__default["default"](event.target).is(_this._element)) {
  139. _this._ignoreBackdropClick = true;
  140. }
  141. });
  142. });
  143. this._showBackdrop(function () {
  144. return _this._showElement(relatedTarget);
  145. });
  146. };
  147. _proto.hide = function hide(event) {
  148. var _this2 = this;
  149. if (event) {
  150. event.preventDefault();
  151. }
  152. if (!this._isShown || this._isTransitioning) {
  153. return;
  154. }
  155. var hideEvent = $__default["default"].Event(EVENT_HIDE);
  156. $__default["default"](this._element).trigger(hideEvent);
  157. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  158. return;
  159. }
  160. this._isShown = false;
  161. var transition = $__default["default"](this._element).hasClass(CLASS_NAME_FADE);
  162. if (transition) {
  163. this._isTransitioning = true;
  164. }
  165. this._setEscapeEvent();
  166. this._setResizeEvent();
  167. $__default["default"](document).off(EVENT_FOCUSIN);
  168. $__default["default"](this._element).removeClass(CLASS_NAME_SHOW);
  169. $__default["default"](this._element).off(EVENT_CLICK_DISMISS);
  170. $__default["default"](this._dialog).off(EVENT_MOUSEDOWN_DISMISS);
  171. if (transition) {
  172. var transitionDuration = Util__default["default"].getTransitionDurationFromElement(this._element);
  173. $__default["default"](this._element).one(Util__default["default"].TRANSITION_END, function (event) {
  174. return _this2._hideModal(event);
  175. }).emulateTransitionEnd(transitionDuration);
  176. } else {
  177. this._hideModal();
  178. }
  179. };
  180. _proto.dispose = function dispose() {
  181. [window, this._element, this._dialog].forEach(function (htmlElement) {
  182. return $__default["default"](htmlElement).off(EVENT_KEY);
  183. });
  184. /**
  185. * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
  186. * Do not move `document` in `htmlElements` array
  187. * It will remove `EVENT_CLICK_DATA_API` event that should remain
  188. */
  189. $__default["default"](document).off(EVENT_FOCUSIN);
  190. $__default["default"].removeData(this._element, DATA_KEY);
  191. this._config = null;
  192. this._element = null;
  193. this._dialog = null;
  194. this._backdrop = null;
  195. this._isShown = null;
  196. this._isBodyOverflowing = null;
  197. this._ignoreBackdropClick = null;
  198. this._isTransitioning = null;
  199. this._scrollbarWidth = null;
  200. };
  201. _proto.handleUpdate = function handleUpdate() {
  202. this._adjustDialog();
  203. } // Private
  204. ;
  205. _proto._getConfig = function _getConfig(config) {
  206. config = _extends({}, Default, config);
  207. Util__default["default"].typeCheckConfig(NAME, config, DefaultType);
  208. return config;
  209. };
  210. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  211. var _this3 = this;
  212. var hideEventPrevented = $__default["default"].Event(EVENT_HIDE_PREVENTED);
  213. $__default["default"](this._element).trigger(hideEventPrevented);
  214. if (hideEventPrevented.isDefaultPrevented()) {
  215. return;
  216. }
  217. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  218. if (!isModalOverflowing) {
  219. this._element.style.overflowY = 'hidden';
  220. }
  221. this._element.classList.add(CLASS_NAME_STATIC);
  222. var modalTransitionDuration = Util__default["default"].getTransitionDurationFromElement(this._dialog);
  223. $__default["default"](this._element).off(Util__default["default"].TRANSITION_END);
  224. $__default["default"](this._element).one(Util__default["default"].TRANSITION_END, function () {
  225. _this3._element.classList.remove(CLASS_NAME_STATIC);
  226. if (!isModalOverflowing) {
  227. $__default["default"](_this3._element).one(Util__default["default"].TRANSITION_END, function () {
  228. _this3._element.style.overflowY = '';
  229. }).emulateTransitionEnd(_this3._element, modalTransitionDuration);
  230. }
  231. }).emulateTransitionEnd(modalTransitionDuration);
  232. this._element.focus();
  233. };
  234. _proto._showElement = function _showElement(relatedTarget) {
  235. var _this4 = this;
  236. var transition = $__default["default"](this._element).hasClass(CLASS_NAME_FADE);
  237. var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null;
  238. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  239. // Don't move modal's DOM position
  240. document.body.appendChild(this._element);
  241. }
  242. this._element.style.display = 'block';
  243. this._element.removeAttribute('aria-hidden');
  244. this._element.setAttribute('aria-modal', true);
  245. this._element.setAttribute('role', 'dialog');
  246. if ($__default["default"](this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) {
  247. modalBody.scrollTop = 0;
  248. } else {
  249. this._element.scrollTop = 0;
  250. }
  251. if (transition) {
  252. Util__default["default"].reflow(this._element);
  253. }
  254. $__default["default"](this._element).addClass(CLASS_NAME_SHOW);
  255. if (this._config.focus) {
  256. this._enforceFocus();
  257. }
  258. var shownEvent = $__default["default"].Event(EVENT_SHOWN, {
  259. relatedTarget: relatedTarget
  260. });
  261. var transitionComplete = function transitionComplete() {
  262. if (_this4._config.focus) {
  263. _this4._element.focus();
  264. }
  265. _this4._isTransitioning = false;
  266. $__default["default"](_this4._element).trigger(shownEvent);
  267. };
  268. if (transition) {
  269. var transitionDuration = Util__default["default"].getTransitionDurationFromElement(this._dialog);
  270. $__default["default"](this._dialog).one(Util__default["default"].TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  271. } else {
  272. transitionComplete();
  273. }
  274. };
  275. _proto._enforceFocus = function _enforceFocus() {
  276. var _this5 = this;
  277. $__default["default"](document).off(EVENT_FOCUSIN) // Guard against infinite focus loop
  278. .on(EVENT_FOCUSIN, function (event) {
  279. if (document !== event.target && _this5._element !== event.target && $__default["default"](_this5._element).has(event.target).length === 0) {
  280. _this5._element.focus();
  281. }
  282. });
  283. };
  284. _proto._setEscapeEvent = function _setEscapeEvent() {
  285. var _this6 = this;
  286. if (this._isShown) {
  287. $__default["default"](this._element).on(EVENT_KEYDOWN_DISMISS, function (event) {
  288. if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE) {
  289. event.preventDefault();
  290. _this6.hide();
  291. } else if (!_this6._config.keyboard && event.which === ESCAPE_KEYCODE) {
  292. _this6._triggerBackdropTransition();
  293. }
  294. });
  295. } else if (!this._isShown) {
  296. $__default["default"](this._element).off(EVENT_KEYDOWN_DISMISS);
  297. }
  298. };
  299. _proto._setResizeEvent = function _setResizeEvent() {
  300. var _this7 = this;
  301. if (this._isShown) {
  302. $__default["default"](window).on(EVENT_RESIZE, function (event) {
  303. return _this7.handleUpdate(event);
  304. });
  305. } else {
  306. $__default["default"](window).off(EVENT_RESIZE);
  307. }
  308. };
  309. _proto._hideModal = function _hideModal() {
  310. var _this8 = this;
  311. this._element.style.display = 'none';
  312. this._element.setAttribute('aria-hidden', true);
  313. this._element.removeAttribute('aria-modal');
  314. this._element.removeAttribute('role');
  315. this._isTransitioning = false;
  316. this._showBackdrop(function () {
  317. $__default["default"](document.body).removeClass(CLASS_NAME_OPEN);
  318. _this8._resetAdjustments();
  319. _this8._resetScrollbar();
  320. $__default["default"](_this8._element).trigger(EVENT_HIDDEN);
  321. });
  322. };
  323. _proto._removeBackdrop = function _removeBackdrop() {
  324. if (this._backdrop) {
  325. $__default["default"](this._backdrop).remove();
  326. this._backdrop = null;
  327. }
  328. };
  329. _proto._showBackdrop = function _showBackdrop(callback) {
  330. var _this9 = this;
  331. var animate = $__default["default"](this._element).hasClass(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
  332. if (this._isShown && this._config.backdrop) {
  333. this._backdrop = document.createElement('div');
  334. this._backdrop.className = CLASS_NAME_BACKDROP;
  335. if (animate) {
  336. this._backdrop.classList.add(animate);
  337. }
  338. $__default["default"](this._backdrop).appendTo(document.body);
  339. $__default["default"](this._element).on(EVENT_CLICK_DISMISS, function (event) {
  340. if (_this9._ignoreBackdropClick) {
  341. _this9._ignoreBackdropClick = false;
  342. return;
  343. }
  344. if (event.target !== event.currentTarget) {
  345. return;
  346. }
  347. if (_this9._config.backdrop === 'static') {
  348. _this9._triggerBackdropTransition();
  349. } else {
  350. _this9.hide();
  351. }
  352. });
  353. if (animate) {
  354. Util__default["default"].reflow(this._backdrop);
  355. }
  356. $__default["default"](this._backdrop).addClass(CLASS_NAME_SHOW);
  357. if (!callback) {
  358. return;
  359. }
  360. if (!animate) {
  361. callback();
  362. return;
  363. }
  364. var backdropTransitionDuration = Util__default["default"].getTransitionDurationFromElement(this._backdrop);
  365. $__default["default"](this._backdrop).one(Util__default["default"].TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  366. } else if (!this._isShown && this._backdrop) {
  367. $__default["default"](this._backdrop).removeClass(CLASS_NAME_SHOW);
  368. var callbackRemove = function callbackRemove() {
  369. _this9._removeBackdrop();
  370. if (callback) {
  371. callback();
  372. }
  373. };
  374. if ($__default["default"](this._element).hasClass(CLASS_NAME_FADE)) {
  375. var _backdropTransitionDuration = Util__default["default"].getTransitionDurationFromElement(this._backdrop);
  376. $__default["default"](this._backdrop).one(Util__default["default"].TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  377. } else {
  378. callbackRemove();
  379. }
  380. } else if (callback) {
  381. callback();
  382. }
  383. } // ----------------------------------------------------------------------
  384. // the following methods are used to handle overflowing modals
  385. // todo (fat): these should probably be refactored out of modal.js
  386. // ----------------------------------------------------------------------
  387. ;
  388. _proto._adjustDialog = function _adjustDialog() {
  389. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  390. if (!this._isBodyOverflowing && isModalOverflowing) {
  391. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  392. }
  393. if (this._isBodyOverflowing && !isModalOverflowing) {
  394. this._element.style.paddingRight = this._scrollbarWidth + "px";
  395. }
  396. };
  397. _proto._resetAdjustments = function _resetAdjustments() {
  398. this._element.style.paddingLeft = '';
  399. this._element.style.paddingRight = '';
  400. };
  401. _proto._checkScrollbar = function _checkScrollbar() {
  402. var rect = document.body.getBoundingClientRect();
  403. this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
  404. this._scrollbarWidth = this._getScrollbarWidth();
  405. };
  406. _proto._setScrollbar = function _setScrollbar() {
  407. var _this10 = this;
  408. if (this._isBodyOverflowing) {
  409. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  410. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  411. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  412. var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding
  413. $__default["default"](fixedContent).each(function (index, element) {
  414. var actualPadding = element.style.paddingRight;
  415. var calculatedPadding = $__default["default"](element).css('padding-right');
  416. $__default["default"](element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  417. }); // Adjust sticky content margin
  418. $__default["default"](stickyContent).each(function (index, element) {
  419. var actualMargin = element.style.marginRight;
  420. var calculatedMargin = $__default["default"](element).css('margin-right');
  421. $__default["default"](element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  422. }); // Adjust body padding
  423. var actualPadding = document.body.style.paddingRight;
  424. var calculatedPadding = $__default["default"](document.body).css('padding-right');
  425. $__default["default"](document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  426. }
  427. $__default["default"](document.body).addClass(CLASS_NAME_OPEN);
  428. };
  429. _proto._resetScrollbar = function _resetScrollbar() {
  430. // Restore fixed content padding
  431. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  432. $__default["default"](fixedContent).each(function (index, element) {
  433. var padding = $__default["default"](element).data('padding-right');
  434. $__default["default"](element).removeData('padding-right');
  435. element.style.paddingRight = padding ? padding : '';
  436. }); // Restore sticky content
  437. var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT));
  438. $__default["default"](elements).each(function (index, element) {
  439. var margin = $__default["default"](element).data('margin-right');
  440. if (typeof margin !== 'undefined') {
  441. $__default["default"](element).css('margin-right', margin).removeData('margin-right');
  442. }
  443. }); // Restore body padding
  444. var padding = $__default["default"](document.body).data('padding-right');
  445. $__default["default"](document.body).removeData('padding-right');
  446. document.body.style.paddingRight = padding ? padding : '';
  447. };
  448. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  449. // thx d.walsh
  450. var scrollDiv = document.createElement('div');
  451. scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
  452. document.body.appendChild(scrollDiv);
  453. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  454. document.body.removeChild(scrollDiv);
  455. return scrollbarWidth;
  456. } // Static
  457. ;
  458. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  459. return this.each(function () {
  460. var data = $__default["default"](this).data(DATA_KEY);
  461. var _config = _extends({}, Default, $__default["default"](this).data(), typeof config === 'object' && config ? config : {});
  462. if (!data) {
  463. data = new Modal(this, _config);
  464. $__default["default"](this).data(DATA_KEY, data);
  465. }
  466. if (typeof config === 'string') {
  467. if (typeof data[config] === 'undefined') {
  468. throw new TypeError("No method named \"" + config + "\"");
  469. }
  470. data[config](relatedTarget);
  471. } else if (_config.show) {
  472. data.show(relatedTarget);
  473. }
  474. });
  475. };
  476. _createClass(Modal, null, [{
  477. key: "VERSION",
  478. get: function get() {
  479. return VERSION;
  480. }
  481. }, {
  482. key: "Default",
  483. get: function get() {
  484. return Default;
  485. }
  486. }]);
  487. return Modal;
  488. }();
  489. /**
  490. * Data API implementation
  491. */
  492. $__default["default"](document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  493. var _this11 = this;
  494. var target;
  495. var selector = Util__default["default"].getSelectorFromElement(this);
  496. if (selector) {
  497. target = document.querySelector(selector);
  498. }
  499. var config = $__default["default"](target).data(DATA_KEY) ? 'toggle' : _extends({}, $__default["default"](target).data(), $__default["default"](this).data());
  500. if (this.tagName === 'A' || this.tagName === 'AREA') {
  501. event.preventDefault();
  502. }
  503. var $target = $__default["default"](target).one(EVENT_SHOW, function (showEvent) {
  504. if (showEvent.isDefaultPrevented()) {
  505. // Only register focus restorer if modal will actually get shown
  506. return;
  507. }
  508. $target.one(EVENT_HIDDEN, function () {
  509. if ($__default["default"](_this11).is(':visible')) {
  510. _this11.focus();
  511. }
  512. });
  513. });
  514. Modal._jQueryInterface.call($__default["default"](target), config, this);
  515. });
  516. /**
  517. * jQuery
  518. */
  519. $__default["default"].fn[NAME] = Modal._jQueryInterface;
  520. $__default["default"].fn[NAME].Constructor = Modal;
  521. $__default["default"].fn[NAME].noConflict = function () {
  522. $__default["default"].fn[NAME] = JQUERY_NO_CONFLICT;
  523. return Modal._jQueryInterface;
  524. };
  525. return Modal;
  526. }));
  527. //# sourceMappingURL=modal.js.map