1 2 3/*Downloaded from https://www.codeseek.co/heychris/bootstrap-4-modal-dMExrG */ 4/** 5 * -------------------------------------------------------------------------- 6 * Bootstrap (v4.0.0-alpha.2): util.js 7 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 8 * -------------------------------------------------------------------------- 9 */ 10 11'use strict'; 12 13var Util = (function ($) { 14 15 /** 16 * ------------------------------------------------------------------------ 17 * Private TransitionEnd Helpers 18 * ------------------------------------------------------------------------ 19 */ 20 21 var transition = false; 22 23 var TransitionEndEvent = { 24 WebkitTransition: 'webkitTransitionEnd', 25 MozTransition: 'transitionend', 26 OTransition: 'oTransitionEnd otransitionend', 27 transition: 'transitionend' 28 }; 29 30 // shoutout AngusCroll (https://goo.gl/pxwQGp) 31 function toType(obj) { 32 return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); 33 } 34 35 function isElement(obj) { 36 return (obj[0] || obj).nodeType; 37 } 38 39 function getSpecialTransitionEndEvent() { 40 return { 41 bindType: transition.end, 42 delegateType: transition.end, 43 handle: function handle(event) { 44 if ($(event.target).is(this)) { 45 return event.handleObj.handler.apply(this, arguments); 46 } 47 } 48 }; 49 } 50 51 function transitionEndTest() { 52 if (window.QUnit) { 53 return false; 54 } 55 56 var el = document.createElement('bootstrap'); 57 58 for (var _name in TransitionEndEvent) { 59 if (el.style[_name] !== undefined) { 60 return { end: TransitionEndEvent[_name] }; 61 } 62 } 63 64 return false; 65 } 66 67 function transitionEndEmulator(duration) { 68 var _this = this; 69 70 var called = false; 71 72 $(this).one(Util.TRANSITION_END, function () { 73 called = true; 74 }); 75 76 setTimeout(function () { 77 if (!called) { 78 Util.triggerTransitionEnd(_this); 79 } 80 }, duration); 81 82 return this; 83 } 84 85 function setTransitionEndSupport() { 86 transition = transitionEndTest(); 87 88 $.fn.emulateTransitionEnd = transitionEndEmulator; 89 90 if (Util.supportsTransitionEnd()) { 91 $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); 92 } 93 } 94 95 /** 96 * -------------------------------------------------------------------------- 97 * Public Util Api 98 * -------------------------------------------------------------------------- 99 */ 100 101 var Util = { 102 103 TRANSITION_END: 'bsTransitionEnd', 104 105 getUID: function getUID(prefix) { 106 do { 107 /* eslint-disable no-bitwise */ 108 prefix += ~ ~(Math.random() * 1000000); // "~~" acts like a faster Math.floor() here 109 /* eslint-enable no-bitwise */ 110 } while (document.getElementById(prefix)); 111 return prefix; 112 }, 113 114 getSelectorFromElement: function getSelectorFromElement(element) { 115 var selector = element.getAttribute('data-target'); 116 117 if (!selector) { 118 selector = element.getAttribute('href') || ''; 119 selector = /^#[a-z]/i.test(selector) ? selector : null; 120 } 121 122 return selector; 123 }, 124 125 reflow: function reflow(element) { 126 new Function('bs', 'return bs')(element.offsetHeight); 127 }, 128 129 triggerTransitionEnd: function triggerTransitionEnd(element) { 130 $(element).trigger(transition.end); 131 }, 132 133 supportsTransitionEnd: function supportsTransitionEnd() { 134 return Boolean(transition); 135 }, 136 137 typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { 138 for (var property in configTypes) { 139 if (configTypes.hasOwnProperty(property)) { 140 var expectedTypes = configTypes[property]; 141 var value = config[property]; 142 var valueType = undefined; 143 144 if (value && isElement(value)) { 145 valueType = 'element'; 146 } else { 147 valueType = toType(value); 148 } 149 150 if (!new RegExp(expectedTypes).test(valueType)) { 151 throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".')); 152 } 153 } 154 } 155 } 156 }; 157 158 setTransitionEndSupport(); 159 160 return Util; 161})(jQuery); 162//# sourceMappingURL=util.js.map 163 164'use strict'; 165 166var _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; }; })(); 167 168function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 169 170/** 171 * -------------------------------------------------------------------------- 172 * Bootstrap (v4.0.0-alpha.2): modal.js 173 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 174 * -------------------------------------------------------------------------- 175 */ 176 177var Modal = (function ($) { 178 179 /** 180 * ------------------------------------------------------------------------ 181 * Constants 182 * ------------------------------------------------------------------------ 183 */ 184 185 var NAME = 'modal'; 186 var VERSION = '4.0.0-alpha.2'; 187 var DATA_KEY = 'bs.modal'; 188 var EVENT_KEY = '.' + DATA_KEY; 189 var DATA_API_KEY = '.data-api'; 190 var JQUERY_NO_CONFLICT = $.fn[NAME]; 191 var TRANSITION_DURATION = 300; 192 var BACKDROP_TRANSITION_DURATION = 150; 193 194 var Default = { 195 backdrop: true, 196 keyboard: true, 197 focus: true, 198 show: true 199 }; 200 201 var DefaultType = { 202 backdrop: '(boolean|string)', 203 keyboard: 'boolean', 204 focus: 'boolean', 205 show: 'boolean' 206 }; 207 208 var Event = { 209 HIDE: 'hide' + EVENT_KEY, 210 HIDDEN: 'hidden' + EVENT_KEY, 211 SHOW: 'show' + EVENT_KEY, 212 SHOWN: 'shown' + EVENT_KEY, 213 FOCUSIN: 'focusin' + EVENT_KEY, 214 RESIZE: 'resize' + EVENT_KEY, 215 CLICK_DISMISS: 'click.dismiss' + EVENT_KEY, 216 KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY, 217 MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY, 218 MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY, 219 CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY 220 }; 221 222 var ClassName = {
223 SCROLLBAR_MEASURER: 'modal-scrollbar-measure', 224 BACKDROP: 'modal-backdrop', 225 OPEN: 'modal-open', 226 FADE: 'fade', 227 IN: 'in' 228 }; 229 230 var Selector = { 231 DIALOG: '.modal-dialog', 232 DATA_TOGGLE: '[data-toggle="modal"]', 233 DATA_DISMISS: '[data-dismiss="modal"]', 234 FIXED_CONTENT: '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed' 235 }; 236 237 /** 238 * ------------------------------------------------------------------------ 239 * Class Definition 240 * ------------------------------------------------------------------------ 241 */ 242 243 var Modal = (function () { 244 function Modal(element, config) { 245 _classCallCheck(this, Modal); 246 247 this._config = this._getConfig(config); 248 this._element = element; 249 this._dialog = $(element).find(Selector.DIALOG)[0]; 250 this._backdrop = null; 251 this._isShown = false; 252 this._isBodyOverflowing = false; 253 this._ignoreBackdropClick = false; 254 this._originalBodyPadding = 0; 255 this._scrollbarWidth = 0; 256 } 257 258 /** 259 * ------------------------------------------------------------------------ 260 * Data Api implementation 261 * ------------------------------------------------------------------------ 262 */ 263 264 // getters 265 266 _createClass(Modal, [{ 267 key: 'toggle', 268 269 // public 270 271 value: function toggle(relatedTarget) { 272 return this._isShown ? this.hide() : this.show(relatedTarget); 273 } 274 }, { 275 key: 'show', 276 value: function show(relatedTarget) { 277 var _this = this; 278 279 var showEvent = $.Event(Event.SHOW, { 280 relatedTarget: relatedTarget 281 }); 282 283 $(this._element).trigger(showEvent); 284 285 if (this._isShown || showEvent.isDefaultPrevented()) { 286 return; 287 } 288 289 this._isShown = true; 290 291 this._checkScrollbar(); 292 this._setScrollbar(); 293 294 $(document.body).addClass(ClassName.OPEN); 295 296 this._setEscapeEvent(); 297 this._setResizeEvent(); 298 299 $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this)); 300 301 $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { 302 $(_this._element).one(Event.MOUSEUP_DISMISS, function (event) { 303 if ($(event.target).is(_this._element)) { 304 _this._ignoreBackdropClick = true; 305 } 306 }); 307 }); 308 309 this._showBackdrop($.proxy(this._showElement, this, relatedTarget)); 310 } 311 }, { 312 key: 'hide', 313 value: function hide(event) { 314 if (event) { 315 event.preventDefault(); 316 } 317 318 var hideEvent = $.Event(Event.HIDE); 319 320 $(this._element).trigger(hideEvent); 321 322 if (!this._isShown || hideEvent.isDefaultPrevented()) { 323 return; 324 } 325 326 this._isShown = false; 327 328 this._setEscapeEvent(); 329 this._setResizeEvent(); 330 331 $(document).off(Event.FOCUSIN); 332 333 $(this._element).removeClass(ClassName.IN); 334 335 $(this._element).off(Event.CLICK_DISMISS); 336 $(this._dialog).off(Event.MOUSEDOWN_DISMISS); 337 338 if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { 339 340 $(this._element).one(Util.TRANSITION_END, $.proxy(this._hideModal, this)).emulateTransitionEnd(TRANSITION_DURATION); 341 } else { 342 this._hideModal(); 343 } 344 } 345 }, { 346 key: 'dispose', 347 value: function dispose() { 348 $.removeData(this._element, DATA_KEY); 349 350 $(window).off(EVENT_KEY); 351 $(document).off(EVENT_KEY); 352 $(this._element).off(EVENT_KEY); 353 $(this._backdrop).off(EVENT_KEY); 354 355 this._config = null; 356 this._element = null; 357 this._dialog = null; 358 this._backdrop = null; 359 this._isShown = null; 360 this._isBodyOverflowing = null; 361 this._ignoreBackdropClick = null; 362 this._originalBodyPadding = null; 363 this._scrollbarWidth = null; 364 } 365 366 // private 367 368 }, { 369 key: '_getConfig', 370 value: function _getConfig(config) { 371 config = $.extend({}, Default, config); 372 Util.typeCheckConfig(NAME, config, DefaultType); 373 return config; 374 } 375 }, {
376 key: '_showElement', 377 value: function _showElement(relatedTarget) { 378 var _this2 = this; 379 380 var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); 381 382 if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { 383 // don't move modals dom position 384 document.body.appendChild(this._element); 385 } 386 387 this._element.style.display = 'block'; 388 this._element.scrollTop = 0; 389 390 if (transition) { 391 Util.reflow(this._element); 392 } 393 394 $(this._element).addClass(ClassName.IN); 395 396 if (this._config.focus) { 397 this._enforceFocus(); 398 } 399 400 var shownEvent = $.Event(Event.SHOWN, { 401 relatedTarget: relatedTarget 402 }); 403 404 var transitionComplete = function transitionComplete() { 405 if (_this2._config.focus) { 406 _this2._element.focus(); 407 } 408 $(_this2._element).trigger(shownEvent); 409 }; 410 411 if (transition) { 412 $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION); 413 } else { 414 transitionComplete(); 415 } 416 } 417 }, { 418 key: '_enforceFocus', 419 value: function _enforceFocus() { 420 var _this3 = this; 421 422 $(document).off(Event.FOCUSIN) // guard against infinite focus loop 423 .on(Event.FOCUSIN, function (event) { 424 if (document !== event.target && _this3._element !== event.target && !$(_this3._element).has(event.target).length) { 425 _this3._element.focus(); 426 } 427 }); 428 } 429 }, { 430 key: '_setEscapeEvent', 431 value: function _setEscapeEvent() { 432 var _this4 = this; 433 434 if (this._isShown && this._config.keyboard) { 435 $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { 436 if (event.which === 27) { 437 _this4.hide(); 438 } 439 }); 440 } else if (!this._isShown) { 441 $(this._element).off(Event.KEYDOWN_DISMISS); 442 } 443 } 444 }, { 445 key: '_setResizeEvent', 446 value: function _setResizeEvent() { 447 if (this._isShown) { 448 $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)); 449 } else { 450 $(window).off(Event.RESIZE); 451 } 452 } 453 }, { 454 key: '_hideModal', 455 value: function _hideModal() { 456 var _this5 = this; 457 458 this._element.style.display = 'none'; 459 this._showBackdrop(function () { 460 $(document.body).removeClass(ClassName.OPEN); 461 _this5._resetAdjustments(); 462 _this5._resetScrollbar(); 463 $(_this5._element).trigger(Event.HIDDEN); 464 }); 465 } 466 }, { 467 key: '_removeBackdrop', 468 value: function _removeBackdrop() { 469 if (this._backdrop) { 470 $(this._backdrop).remove(); 471 this._backdrop = null; 472 } 473 } 474 }, { 475 key: '_showBackdrop', 476 value: function _showBackdrop(callback) { 477 var _this6 = this; 478 479 var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; 480 481 if (this._isShown && this._config.backdrop) { 482 var doAnimate = Util.supportsTransitionEnd() && animate; 483 484 this._backdrop = document.createElement('div'); 485 this._backdrop.className = ClassName.BACKDROP; 486 487 if (animate) { 488 $(this._backdrop).addClass(animate); 489 } 490 491 $(this._backdrop).appendTo(document.body); 492 493 $(this._element).on(Event.CLICK_DISMISS, function (event) { 494 if (_this6._ignoreBackdropClick) { 495 _this6._ignoreBackdropClick = false; 496 return; 497 } 498 if (event.target !== event.currentTarget) { 499 return; 500 } 501 if (_this6._config.backdrop === 'static') { 502 _this6._element.focus(); 503 } else { 504 _this6.hide(); 505 } 506 }); 507 508 if (doAnimate) { 509 Util.reflow(this._backdrop); 510 } 511 512 $(this._backdrop).addClass(ClassName.IN); 513 514 if (!callback) { 515 return; 516 } 517 518 if (!doAnimate) { 519 callback(); 520 return; 521 } 522 523 $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); 524 } else if (!this._isShown && this._backdrop) { 525 $(this._backdrop).removeClass(ClassName.IN); 526 527 var callbackRemove = function callbackRemove() { 528 _this6._removeBackdrop(); 529 if (callback) { 530 callback(); 531 } 532 }; 533 534 if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { 535 $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); 536 } else { 537 callbackRemove(); 538 } 539 } else if (callback) { 540 callback(); 541 } 542 } 543 544 // ---------------------------------------------------------------------- 545 // the following methods are used to handle overflowing modals 546 // todo (fat): these should probably be refactored out of modal.js 547 // ---------------------------------------------------------------------- 548 549 }, {
550 key: '_handleUpdate', 551 value: function _handleUpdate() { 552 this._adjustDialog(); 553 } 554 }, { 555 key: '_adjustDialog', 556 value: function _adjustDialog() { 557 var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; 558 559 if (!this._isBodyOverflowing && isModalOverflowing) { 560 this._element.style.paddingLeft = this._scrollbarWidth + 'px'; 561 } 562 563 if (this._isBodyOverflowing && !isModalOverflowing) { 564 this._element.style.paddingRight = this._scrollbarWidth + 'px~'; 565 } 566 } 567 }, { 568 key: '_resetAdjustments', 569 value: function _resetAdjustments() { 570 this._element.style.paddingLeft = ''; 571 this._element.style.paddingRight = ''; 572 } 573 }, { 574 key: '_checkScrollbar', 575 value: function _checkScrollbar() { 576 this._isBodyOverflowing = document.body.clientWidth < window.innerWidth; 577 this._scrollbarWidth = this._getScrollbarWidth(); 578 } 579 }, { 580 key: '_setScrollbar', 581 value: function _setScrollbar() { 582 var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10); 583 584 this._originalBodyPadding = document.body.style.paddingRight || ''; 585 586 if (this._isBodyOverflowing) { 587 document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px'; 588 } 589 } 590 }, { 591 key: '_resetScrollbar', 592 value: function _resetScrollbar() { 593 document.body.style.paddingRight = this._originalBodyPadding; 594 } 595 }, { 596 key: '_getScrollbarWidth', 597 value: function _getScrollbarWidth() { 598 // thx d.walsh 599 var scrollDiv = document.createElement('div'); 600 scrollDiv.className = ClassName.SCROLLBAR_MEASURER; 601 document.body.appendChild(scrollDiv); 602 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; 603 document.body.removeChild(scrollDiv); 604 return scrollbarWidth; 605 } 606 607 // static 608 609 }], [{ 610 key: '_jQueryInterface', 611 value: function _jQueryInterface(config, relatedTarget) { 612 return this.each(function () { 613 var data = $(this).data(DATA_KEY); 614 var _config = $.extend({}, Modal.Default, $(this).data(), typeof config === 'object' && config); 615 616 if (!data) { 617 data = new Modal(this, _config); 618 $(this).data(DATA_KEY, data); 619 } 620 621 if (typeof config === 'string') { 622 if (data[config] === undefined) { 623 throw new Error('No method named "' + config + '"'); 624 } 625 data[config](relatedTarget); 626 } else if (_config.show) { 627 data.show(relatedTarget); 628 } 629 }); 630 } 631 }, { 632 key: 'VERSION', 633 get: function get() { 634 return VERSION; 635 } 636 }, { 637 key: 'Default', 638 get: function get() { 639 return Default; 640 } 641 }]); 642 643 return Modal; 644 })(); 645 646 $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { 647 var _this7 = this; 648 649 var target = undefined; 650 var selector = Util.getSelectorFromElement(this); 651 652 if (selector) { 653 target = $(selector)[0]; 654 } 655 656 var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()); 657 658 if (this.tagName === 'A') { 659 event.preventDefault(); 660 } 661 662 var $target = $(target).one(Event.SHOW, function (showEvent) { 663 if (showEvent.isDefaultPrevented()) { 664 // only register focus restorer if modal will actually get shown 665 return; 666 } 667 668 $target.one(Event.HIDDEN, function () { 669 if ($(_this7).is(':visible')) { 670 _this7.focus(); 671 } 672 }); 673 }); 674 675 Modal._jQueryInterface.call($(target), config, this); 676 }); 677 678 /** 679 * ------------------------------------------------------------------------ 680 * jQuery 681 * ------------------------------------------------------------------------ 682 */ 683 684 $.fn[NAME] = Modal._jQueryInterface; 685 $.fn[NAME].Constructor = Modal; 686 $.fn[NAME].noConflict = function () { 687 $.fn[NAME] = JQUERY_NO_CONFLICT; 688 return Modal._jQueryInterface; 689 }; 690 691 return Modal; 692})(jQuery); 693//# sourceMappingURL=modal.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.