diff options
Diffstat (limited to 'js/dist/modal.js')
-rw-r--r-- | js/dist/modal.js | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/js/dist/modal.js b/js/dist/modal.js index be13da5519..4e16de65db 100644 --- a/js/dist/modal.js +++ b/js/dist/modal.js @@ -4,8 +4,8 @@ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', './dom/selector-engine.js'], factory) : + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/data.js'), require('../dom/event-handler.js'), require('../dom/manipulator.js'), require('../dom/selector-engine.js')) : + typeof define === 'function' && define.amd ? define(['../dom/data.js', '../dom/event-handler.js', '../dom/manipulator.js', '../dom/selector-engine.js'], factory) : (global = global || self, global.Modal = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine)); }(this, function (Data, EventHandler, Manipulator, SelectorEngine) { 'use strict'; @@ -45,20 +45,35 @@ return obj; } - function _objectSpread(target) { + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); + if (i % 2) { + ownKeys(source, true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(source).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); } - - ownKeys.forEach(function (key) { - _defineProperty(target, key, source[key]); - }); } return target; @@ -326,7 +341,7 @@ var hideEvent = EventHandler.trigger(this._element, Event.HIDE); - if (!this._isShown || hideEvent.defaultPrevented) { + if (hideEvent.defaultPrevented) { return; } @@ -389,7 +404,7 @@ ; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, Default, config); + config = _objectSpread2({}, Default, {}, config); typeCheckConfig(NAME, config, DefaultType); return config; }; @@ -469,7 +484,7 @@ _this5.hide(); } }); - } else if (!this._isShown) { + } else { EventHandler.off(this._element, Event.KEYDOWN_DISMISS); } }; @@ -478,8 +493,8 @@ var _this6 = this; if (this._isShown) { - EventHandler.on(window, Event.RESIZE, function (event) { - return _this6.handleUpdate(event); + EventHandler.on(window, Event.RESIZE, function () { + return _this6._adjustDialog(); }); } else { EventHandler.off(window, Event.RESIZE); @@ -509,11 +524,9 @@ }; _proto._removeBackdrop = function _removeBackdrop() { - if (this._backdrop) { - this._backdrop.parentNode.removeChild(this._backdrop); + this._backdrop.parentNode.removeChild(this._backdrop); - this._backdrop = null; - } + this._backdrop = null; }; _proto._showBackdrop = function _showBackdrop(callback) { @@ -553,10 +566,6 @@ this._backdrop.classList.add(ClassName.SHOW); - if (!callback) { - return; - } - if (!animate) { callback(); return; @@ -571,9 +580,7 @@ var callbackRemove = function callbackRemove() { _this8._removeBackdrop(); - if (callback) { - callback(); - } + callback(); }; if (this._element.classList.contains(ClassName.FADE)) { @@ -584,7 +591,7 @@ } else { callbackRemove(); } - } else if (callback) { + } else { callback(); } } // ---------------------------------------------------------------------- @@ -690,7 +697,7 @@ return this.each(function () { var data = Data.getData(this, DATA_KEY); - var _config = _objectSpread({}, Default, Manipulator.getDataAttributes(this), typeof config === 'object' && config ? config : {}); + var _config = _objectSpread2({}, Default, {}, Manipulator.getDataAttributes(this), {}, typeof config === 'object' && config ? config : {}); if (!data) { data = new Modal(this, _config); @@ -736,14 +743,8 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { var _this10 = this; - var target; var selector = getSelectorFromElement(this); - - if (selector) { - target = SelectorEngine.findOne(selector); - } - - var config = Data.getData(target, DATA_KEY) ? 'toggle' : _objectSpread({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this)); + var target = SelectorEngine.findOne(selector); if (this.tagName === 'A' || this.tagName === 'AREA') { event.preventDefault(); @@ -764,6 +765,8 @@ var data = Data.getData(target, DATA_KEY); if (!data) { + var config = _objectSpread2({}, Manipulator.getDataAttributes(target), {}, Manipulator.getDataAttributes(this)); + data = new Modal(target, config); } @@ -773,8 +776,11 @@ * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .modal to jQuery only if jQuery is present */ + /* istanbul ignore if */ + if (typeof jQuery !== 'undefined') { var JQUERY_NO_CONFLICT = jQuery.fn[NAME]; jQuery.fn[NAME] = Modal._jQueryInterface; |