/* ======================================================================== * bootstrap: modal.js v3.4.1 * https://getbootstrap.com/docs/3.4/javascript/#modals * ======================================================================== * copyright 2011-2019 twitter, inc. * licensed under mit (https://github.com/twbs/bootstrap/blob/master/license) * ======================================================================== */ +function ($) { 'use strict'; // modal class definition // ====================== var modal = function (element, options) { this.options = options this.$body = $(document.body) this.$element = $(element) this.$dialog = this.$element.find('.modal-dialog') this.$backdrop = null this.isshown = null this.originalbodypad = null this.scrollbarwidth = 0 this.ignorebackdropclick = false this.fixedcontent = '.navbar-fixed-top, .navbar-fixed-bottom' if (this.options.remote) { this.$element .find('.modal-content') .load(this.options.remote, $.proxy(function () { this.$element.trigger('loaded.bs.modal') }, this)) } } modal.version = '3.4.1' modal.transition_duration = 300 modal.backdrop_transition_duration = 150 modal.defaults = { backdrop: true, keyboard: true, show: true } modal.prototype.toggle = function (_relatedtarget) { return this.isshown ? this.hide() : this.show(_relatedtarget) } modal.prototype.show = function (_relatedtarget) { var that = this var e = $.event('show.bs.modal', { relatedtarget: _relatedtarget }) this.$element.trigger(e) if (this.isshown || e.isdefaultprevented()) return this.isshown = true this.checkscrollbar() this.setscrollbar() this.$body.addclass('modal-open') this.escape() this.resize() this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) this.$dialog.on('mousedown.dismiss.bs.modal', function () { that.$element.one('mouseup.dismiss.bs.modal', function (e) { if ($(e.target).is(that.$element)) that.ignorebackdropclick = true }) }) this.backdrop(function () { var transition = $.support.transition && that.$element.hasclass('fade') if (!that.$element.parent().length) { that.$element.appendto(that.$body) // don't move modals dom position } that.$element .show() .scrolltop(0) that.adjustdialog() if (transition) { that.$element[0].offsetwidth // force reflow } that.$element.addclass('in') that.enforcefocus() var e = $.event('shown.bs.modal', { relatedtarget: _relatedtarget }) transition ? that.$dialog // wait for modal to slide in .one('bstransitionend', function () { that.$element.trigger('focus').trigger(e) }) .emulatetransitionend(modal.transition_duration) : that.$element.trigger('focus').trigger(e) }) } modal.prototype.hide = function (e) { if (e) e.preventdefault() e = $.event('hide.bs.modal') this.$element.trigger(e) if (!this.isshown || e.isdefaultprevented()) return this.isshown = false this.escape() this.resize() $(document).off('focusin.bs.modal') this.$element .removeclass('in') .off('click.dismiss.bs.modal') .off('mouseup.dismiss.bs.modal') this.$dialog.off('mousedown.dismiss.bs.modal') $.support.transition && this.$element.hasclass('fade') ? this.$element .one('bstransitionend', $.proxy(this.hidemodal, this)) .emulatetransitionend(modal.transition_duration) : this.hidemodal() } modal.prototype.enforcefocus = function () { $(document) .off('focusin.bs.modal') // guard against infinite focus loop .on('focusin.bs.modal', $.proxy(function (e) { if (document !== e.target && this.$element[0] !== e.target && !this.$element.has(e.target).length) { this.$element.trigger('focus') } }, this)) } modal.prototype.escape = function () { if (this.isshown && this.options.keyboard) { this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { e.which == 27 && this.hide() }, this)) } else if (!this.isshown) { this.$element.off('keydown.dismiss.bs.modal') } } modal.prototype.resize = function () { if (this.isshown) { $(window).on('resize.bs.modal', $.proxy(this.handleupdate, this)) } else { $(window).off('resize.bs.modal') } } modal.prototype.hidemodal = function () { var that = this this.$element.hide() this.backdrop(function () { that.$body.removeclass('modal-open') that.resetadjustments() that.resetscrollbar() that.$element.trigger('hidden.bs.modal') }) } modal.prototype.removebackdrop = function () { this.$backdrop && this.$backdrop.remove() this.$backdrop = null } modal.prototype.backdrop = function (callback) { var that = this var animate = this.$element.hasclass('fade') ? 'fade' : '' if (this.isshown && this.options.backdrop) { var doanimate = $.support.transition && animate this.$backdrop = $(document.createelement('div')) .addclass('modal-backdrop ' + animate) .appendto(this.$body) this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { if (this.ignorebackdropclick) { this.ignorebackdropclick = false return } if (e.target !== e.currenttarget) return this.options.backdrop == 'static' ? this.$element[0].focus() : this.hide() }, this)) if (doanimate) this.$backdrop[0].offsetwidth // force reflow this.$backdrop.addclass('in') if (!callback) return doanimate ? this.$backdrop .one('bstransitionend', callback) .emulatetransitionend(modal.backdrop_transition_duration) : callback() } else if (!this.isshown && this.$backdrop) { this.$backdrop.removeclass('in') var callbackremove = function () { that.removebackdrop() callback && callback() } $.support.transition && this.$element.hasclass('fade') ? this.$backdrop .one('bstransitionend', callbackremove) .emulatetransitionend(modal.backdrop_transition_duration) : callbackremove() } else if (callback) { callback() } } // these following methods are used to handle overflowing modals modal.prototype.handleupdate = function () { this.adjustdialog() } modal.prototype.adjustdialog = function () { var modalisoverflowing = this.$element[0].scrollheight > document.documentelement.clientheight this.$element.css({ paddingleft: !this.bodyisoverflowing && modalisoverflowing ? this.scrollbarwidth : '', paddingright: this.bodyisoverflowing && !modalisoverflowing ? this.scrollbarwidth : '' }) } modal.prototype.resetadjustments = function () { this.$element.css({ paddingleft: '', paddingright: '' }) } modal.prototype.checkscrollbar = function () { var fullwindowwidth = window.innerwidth if (!fullwindowwidth) { // workaround for missing window.innerwidth in ie8 var documentelementrect = document.documentelement.getboundingclientrect() fullwindowwidth = documentelementrect.right - math.abs(documentelementrect.left) } this.bodyisoverflowing = document.body.clientwidth < fullwindowwidth this.scrollbarwidth = this.measurescrollbar() } modal.prototype.setscrollbar = function () { var bodypad = parseint((this.$body.css('padding-right') || 0), 10) this.originalbodypad = document.body.style.paddingright || '' var scrollbarwidth = this.scrollbarwidth if (this.bodyisoverflowing) { this.$body.css('padding-right', bodypad + scrollbarwidth) $(this.fixedcontent).each(function (index, element) { var actualpadding = element.style.paddingright var calculatedpadding = $(element).css('padding-right') $(element) .data('padding-right', actualpadding) .css('padding-right', parsefloat(calculatedpadding) + scrollbarwidth + 'px') }) } } modal.prototype.resetscrollbar = function () { this.$body.css('padding-right', this.originalbodypad) $(this.fixedcontent).each(function (index, element) { var padding = $(element).data('padding-right') $(element).removedata('padding-right') element.style.paddingright = padding ? padding : '' }) } modal.prototype.measurescrollbar = function () { // thx walsh var scrolldiv = document.createelement('div') scrolldiv.classname = 'modal-scrollbar-measure' this.$body.append(scrolldiv) var scrollbarwidth = scrolldiv.offsetwidth - scrolldiv.clientwidth this.$body[0].removechild(scrolldiv) return scrollbarwidth } // modal plugin definition // ======================= function plugin(option, _relatedtarget) { return this.each(function () { var $this = $(this) var data = $this.data('bs.modal') var options = $.extend({}, modal.defaults, $this.data(), typeof option == 'object' && option) if (!data) $this.data('bs.modal', (data = new modal(this, options))) if (typeof option == 'string') data[option](_relatedtarget) else if (options.show) data.show(_relatedtarget) }) } var old = $.fn.modal $.fn.modal = plugin $.fn.modal.constructor = modal // modal no conflict // ================= $.fn.modal.noconflict = function () { $.fn.modal = old return this } // modal data-api // ============== $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { var $this = $(this) var href = $this.attr('href') var target = $this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 var $target = $(document).find(target) var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) if ($this.is('a')) e.preventdefault() $target.one('show.bs.modal', function (showevent) { if (showevent.isdefaultprevented()) return // only register focus restorer if modal will actually get shown $target.one('hidden.bs.modal', function () { $this.is(':visible') && $this.trigger('focus') }) }) plugin.call($target, option, this) }) }(jquery);