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