bootstrap.js
416 lines
| 1 | /*! |
| 2 | * Bootstrap v3.3.7 (http://getbootstrap.com) |
| 3 | * Copyright 2011-2016 Twitter, Inc. |
| 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
| 5 | */ |
| 6 | |
| 7 | /*! |
| 8 | * Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3388789be7b7c807ff47acdc21b4ef8f) |
| 9 | * Config saved to config.json and https://gist.github.com/3388789be7b7c807ff47acdc21b4ef8f |
| 10 | */ |
| 11 | if (typeof jQuery === 'undefined') { |
| 12 | throw new Error('Bootstrap\'s JavaScript requires jQuery'); |
| 13 | } |
| 14 | +function ($) { |
| 15 | 'use strict'; |
| 16 | var version = $.fn.jquery.split(' ')[0].split('.'); |
| 17 | if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) { |
| 18 | throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4'); |
| 19 | } |
| 20 | }(jQuery); |
| 21 | |
| 22 | /* ======================================================================== |
| 23 | * Bootstrap: modal.js v3.3.7 |
| 24 | * http://getbootstrap.com/javascript/#modals |
| 25 | * ======================================================================== |
| 26 | * Copyright 2011-2016 Twitter, Inc. |
| 27 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
| 28 | * ======================================================================== */ |
| 29 | |
| 30 | +function ($) { |
| 31 | 'use strict'; |
| 32 | |
| 33 | // MODAL CLASS DEFINITION |
| 34 | // ====================== |
| 35 | |
| 36 | var Modal = function (element, options) { |
| 37 | this.options = options; |
| 38 | this.$body = $(document.body); |
| 39 | this.$element = $(element); |
| 40 | this.$dialog = this.$element.find('.modal-dialog'); |
| 41 | this.$backdrop = null; |
| 42 | this.isShown = null; |
| 43 | this.originalBodyPad = null; |
| 44 | this.scrollbarWidth = 0; |
| 45 | this.ignoreBackdropClick = false; |
| 46 | |
| 47 | if (this.options.remote) { |
| 48 | this.$element |
| 49 | .find('.modal-content') |
| 50 | .load(this.options.remote, $.proxy(function () { |
| 51 | this.$element.trigger('loaded.bs.modal'); |
| 52 | }, this)); |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | Modal.VERSION = '3.3.7'; |
| 57 | |
| 58 | Modal.TRANSITION_DURATION = 300; |
| 59 | Modal.BACKDROP_TRANSITION_DURATION = 150; |
| 60 | |
| 61 | Modal.DEFAULTS = { |
| 62 | backdrop: true, |
| 63 | keyboard: true, |
| 64 | show: true |
| 65 | }; |
| 66 | |
| 67 | Modal.prototype.toggle = function (_relatedTarget) { |
| 68 | return this.isShown ? this.hide() : this.show(_relatedTarget); |
| 69 | }; |
| 70 | |
| 71 | Modal.prototype.show = function (_relatedTarget) { |
| 72 | var that = this; |
| 73 | var e = $.Event('show.bs.modal', {relatedTarget: _relatedTarget}); |
| 74 | |
| 75 | this.$element.trigger(e); |
| 76 | |
| 77 | if (this.isShown || e.isDefaultPrevented()) return; |
| 78 | |
| 79 | this.isShown = true; |
| 80 | |
| 81 | this.checkScrollbar(); |
| 82 | this.setScrollbar(); |
| 83 | this.$body.addClass('modal-open'); |
| 84 | |
| 85 | this.escape(); |
| 86 | this.resize(); |
| 87 | |
| 88 | this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)); |
| 89 | |
| 90 | this.$dialog.on('mousedown.dismiss.bs.modal', function () { |
| 91 | that.$element.one('mouseup.dismiss.bs.modal', function (e) { |
| 92 | if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true; |
| 93 | }); |
| 94 | }); |
| 95 | |
| 96 | this.backdrop(function () { |
| 97 | var transition = $.support.transition && that.$element.hasClass('fade'); |
| 98 | |
| 99 | if (!that.$element.parent().length) { |
| 100 | that.$element.appendTo(that.$body); // don't move modals dom position |
| 101 | } |
| 102 | |
| 103 | that.$element |
| 104 | .show() |
| 105 | .scrollTop(0); |
| 106 | |
| 107 | that.adjustDialog(); |
| 108 | |
| 109 | if (transition) { |
| 110 | that.$element[0].offsetWidth; // force reflow |
| 111 | } |
| 112 | |
| 113 | that.$element.addClass('in'); |
| 114 | |
| 115 | that.enforceFocus(); |
| 116 | |
| 117 | var e = $.Event('shown.bs.modal', {relatedTarget: _relatedTarget}); |
| 118 | |
| 119 | transition ? |
| 120 | that.$dialog // wait for modal to slide in |
| 121 | .one('bsTransitionEnd', function () { |
| 122 | that.$element.trigger('focus').trigger(e); |
| 123 | }) |
| 124 | .emulateTransitionEnd(Modal.TRANSITION_DURATION) : |
| 125 | that.$element.trigger('focus').trigger(e); |
| 126 | }); |
| 127 | }; |
| 128 | |
| 129 | Modal.prototype.hide = function (e) { |
| 130 | if (e) e.preventDefault(); |
| 131 | |
| 132 | e = $.Event('hide.bs.modal'); |
| 133 | |
| 134 | this.$element.trigger(e); |
| 135 | |
| 136 | if (!this.isShown || e.isDefaultPrevented()) return; |
| 137 | |
| 138 | this.isShown = false; |
| 139 | |
| 140 | this.escape(); |
| 141 | this.resize(); |
| 142 | |
| 143 | $(document).off('focusin.bs.modal'); |
| 144 | |
| 145 | this.$element |
| 146 | .removeClass('in') |
| 147 | .off('click.dismiss.bs.modal') |
| 148 | .off('mouseup.dismiss.bs.modal'); |
| 149 | |
| 150 | this.$dialog.off('mousedown.dismiss.bs.modal'); |
| 151 | |
| 152 | $.support.transition && this.$element.hasClass('fade') ? |
| 153 | this.$element |
| 154 | .one('bsTransitionEnd', $.proxy(this.hideModal, this)) |
| 155 | .emulateTransitionEnd(Modal.TRANSITION_DURATION) : |
| 156 | this.hideModal(); |
| 157 | }; |
| 158 | |
| 159 | Modal.prototype.enforceFocus = function () { |
| 160 | $(document) |
| 161 | .off('focusin.bs.modal') // guard against infinite focus loop |
| 162 | .on('focusin.bs.modal', $.proxy(function (e) { |
| 163 | if (document !== e.target && |
| 164 | this.$element[0] !== e.target && |
| 165 | !this.$element.has(e.target).length) { |
| 166 | this.$element.trigger('focus'); |
| 167 | } |
| 168 | }, this)); |
| 169 | }; |
| 170 | |
| 171 | Modal.prototype.escape = function () { |
| 172 | if (this.isShown && this.options.keyboard) { |
| 173 | this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { |
| 174 | e.which == 27 && this.hide(); |
| 175 | }, this)); |
| 176 | } else if (!this.isShown) { |
| 177 | this.$element.off('keydown.dismiss.bs.modal'); |
| 178 | } |
| 179 | }; |
| 180 | |
| 181 | Modal.prototype.resize = function () { |
| 182 | if (this.isShown) { |
| 183 | $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)); |
| 184 | } else { |
| 185 | $(window).off('resize.bs.modal'); |
| 186 | } |
| 187 | }; |
| 188 | |
| 189 | Modal.prototype.hideModal = function () { |
| 190 | var that = this; |
| 191 | this.$element.hide(); |
| 192 | this.backdrop(function () { |
| 193 | that.$body.removeClass('modal-open'); |
| 194 | that.resetAdjustments(); |
| 195 | that.resetScrollbar(); |
| 196 | that.$element.trigger('hidden.bs.modal'); |
| 197 | }); |
| 198 | }; |
| 199 | |
| 200 | Modal.prototype.removeBackdrop = function () { |
| 201 | this.$backdrop && this.$backdrop.remove(); |
| 202 | this.$backdrop = null; |
| 203 | }; |
| 204 | |
| 205 | Modal.prototype.backdrop = function (callback) { |
| 206 | var that = this; |
| 207 | var animate = this.$element.hasClass('fade') ? 'fade' : ''; |
| 208 | |
| 209 | if (this.isShown && this.options.backdrop) { |
| 210 | var doAnimate = $.support.transition && animate; |
| 211 | |
| 212 | this.$backdrop = $(document.createElement('div')) |
| 213 | .addClass('modal-backdrop ' + animate) |
| 214 | .appendTo(this.$body); |
| 215 | |
| 216 | this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { |
| 217 | if (this.ignoreBackdropClick) { |
| 218 | this.ignoreBackdropClick = false; |
| 219 | return; |
| 220 | } |
| 221 | if (e.target !== e.currentTarget) return; |
| 222 | this.options.backdrop == 'static' |
| 223 | ? this.$element[0].focus() |
| 224 | : this.hide(); |
| 225 | }, this)); |
| 226 | |
| 227 | if (doAnimate) this.$backdrop[0].offsetWidth; // force reflow |
| 228 | |
| 229 | this.$backdrop.addClass('in'); |
| 230 | |
| 231 | if (!callback) return; |
| 232 | |
| 233 | doAnimate ? |
| 234 | this.$backdrop |
| 235 | .one('bsTransitionEnd', callback) |
| 236 | .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : |
| 237 | callback(); |
| 238 | |
| 239 | } else if (!this.isShown && this.$backdrop) { |
| 240 | this.$backdrop.removeClass('in'); |
| 241 | |
| 242 | var callbackRemove = function () { |
| 243 | that.removeBackdrop(); |
| 244 | callback && callback(); |
| 245 | }; |
| 246 | $.support.transition && this.$element.hasClass('fade') ? |
| 247 | this.$backdrop |
| 248 | .one('bsTransitionEnd', callbackRemove) |
| 249 | .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : |
| 250 | callbackRemove(); |
| 251 | |
| 252 | } else if (callback) { |
| 253 | callback(); |
| 254 | } |
| 255 | }; |
| 256 | |
| 257 | // these following methods are used to handle overflowing modals |
| 258 | |
| 259 | Modal.prototype.handleUpdate = function () { |
| 260 | this.adjustDialog(); |
| 261 | }; |
| 262 | |
| 263 | Modal.prototype.adjustDialog = function () { |
| 264 | var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight; |
| 265 | |
| 266 | this.$element.css({ |
| 267 | paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', |
| 268 | paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' |
| 269 | }); |
| 270 | }; |
| 271 | |
| 272 | Modal.prototype.resetAdjustments = function () { |
| 273 | this.$element.css({ |
| 274 | paddingLeft: '', |
| 275 | paddingRight: '' |
| 276 | }); |
| 277 | }; |
| 278 | |
| 279 | Modal.prototype.checkScrollbar = function () { |
| 280 | var fullWindowWidth = window.innerWidth; |
| 281 | if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 |
| 282 | var documentElementRect = document.documentElement.getBoundingClientRect(); |
| 283 | fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left); |
| 284 | } |
| 285 | this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth; |
| 286 | this.scrollbarWidth = this.measureScrollbar(); |
| 287 | }; |
| 288 | |
| 289 | Modal.prototype.setScrollbar = function () { |
| 290 | var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10); |
| 291 | this.originalBodyPad = document.body.style.paddingRight || ''; |
| 292 | if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth); |
| 293 | }; |
| 294 | |
| 295 | Modal.prototype.resetScrollbar = function () { |
| 296 | this.$body.css('padding-right', this.originalBodyPad); |
| 297 | }; |
| 298 | |
| 299 | Modal.prototype.measureScrollbar = function () { // thx walsh |
| 300 | var scrollDiv = document.createElement('div'); |
| 301 | scrollDiv.className = 'modal-scrollbar-measure'; |
| 302 | this.$body.append(scrollDiv); |
| 303 | var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; |
| 304 | this.$body[0].removeChild(scrollDiv); |
| 305 | return scrollbarWidth; |
| 306 | }; |
| 307 | |
| 308 | // MODAL PLUGIN DEFINITION |
| 309 | // ======================= |
| 310 | |
| 311 | function Plugin (option, _relatedTarget) { |
| 312 | return this.each(function () { |
| 313 | var $this = $(this); |
| 314 | var data = $this.data('bs.modal'); |
| 315 | var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option); |
| 316 | |
| 317 | if (!data) $this.data('bs.modal', (data = new Modal(this, options))); |
| 318 | if (typeof option == 'string') data[option](_relatedTarget); |
| 319 | else if (options.show) data.show(_relatedTarget); |
| 320 | }); |
| 321 | } |
| 322 | |
| 323 | var old = $.fn.modal; |
| 324 | |
| 325 | $.fn.modal = Plugin; |
| 326 | $.fn.modal.Constructor = Modal; |
| 327 | |
| 328 | // MODAL NO CONFLICT |
| 329 | // ================= |
| 330 | |
| 331 | $.fn.modal.noConflict = function () { |
| 332 | $.fn.modal = old; |
| 333 | return this; |
| 334 | }; |
| 335 | |
| 336 | // MODAL DATA-API |
| 337 | // ============== |
| 338 | |
| 339 | $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { |
| 340 | var $this = $(this); |
| 341 | var href = $this.attr('href'); |
| 342 | var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))); // strip for ie7 |
| 343 | var option = $target.data('bs.modal') ? 'toggle' : $.extend({remote: !/#/.test(href) && href}, $target.data(), $this.data()); |
| 344 | |
| 345 | if ($this.is('a')) e.preventDefault(); |
| 346 | |
| 347 | $target.one('show.bs.modal', function (showEvent) { |
| 348 | if (showEvent.isDefaultPrevented()) return; // only register focus restorer if modal will actually get shown |
| 349 | $target.one('hidden.bs.modal', function () { |
| 350 | $this.is(':visible') && $this.trigger('focus'); |
| 351 | }); |
| 352 | }); |
| 353 | Plugin.call($target, option, this); |
| 354 | }); |
| 355 | |
| 356 | }(jQuery); |
| 357 | |
| 358 | /* ======================================================================== |
| 359 | * Bootstrap: transition.js v3.3.7 |
| 360 | * http://getbootstrap.com/javascript/#transitions |
| 361 | * ======================================================================== |
| 362 | * Copyright 2011-2016 Twitter, Inc. |
| 363 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
| 364 | * ======================================================================== */ |
| 365 | |
| 366 | +function ($) { |
| 367 | 'use strict'; |
| 368 | |
| 369 | // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) |
| 370 | // ============================================================ |
| 371 | |
| 372 | function transitionEnd () { |
| 373 | var el = document.createElement('bootstrap'); |
| 374 | |
| 375 | var transEndEventNames = { |
| 376 | WebkitTransition: 'webkitTransitionEnd', |
| 377 | MozTransition: 'transitionend', |
| 378 | OTransition: 'oTransitionEnd otransitionend', |
| 379 | transition: 'transitionend' |
| 380 | }; |
| 381 | |
| 382 | for (var name in transEndEventNames) { |
| 383 | if (el.style[name] !== undefined) { |
| 384 | return {end: transEndEventNames[name]}; |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | return false; // explicit for ie8 ( ._.) |
| 389 | } |
| 390 | |
| 391 | // http://blog.alexmaccaw.com/css-transitions |
| 392 | $.fn.emulateTransitionEnd = function (duration) { |
| 393 | var called = false; |
| 394 | var $el = this; |
| 395 | $(this).one('bsTransitionEnd', function () { called = true; }); |
| 396 | var callback = function () { if (!called) $($el).trigger($.support.transition.end); }; |
| 397 | setTimeout(callback, duration); |
| 398 | return this; |
| 399 | }; |
| 400 | |
| 401 | $(function () { |
| 402 | $.support.transition = transitionEnd(); |
| 403 | |
| 404 | if (!$.support.transition) return; |
| 405 | |
| 406 | $.event.special.bsTransitionEnd = { |
| 407 | bindType: $.support.transition.end, |
| 408 | delegateType: $.support.transition.end, |
| 409 | handle: function (e) { |
| 410 | if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments); |
| 411 | } |
| 412 | }; |
| 413 | }); |
| 414 | |
| 415 | }(jQuery); |
| 416 |