diff options
| author | Mark Otto <[email protected]> | 2016-10-31 21:36:10 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-10-31 21:36:10 -0700 |
| commit | cd5c7a2263c33e7c4fe7f5db205ff93fbe17750f (patch) | |
| tree | 3de9c88e47d6000d95375c8a701676e5424b6aa9 /docs/dist/js/bootstrap.js | |
| parent | ffaad0a819c6cf1e21d9a9d313673f9d7a260584 (diff) | |
| download | bootstrap-cd5c7a2263c33e7c4fe7f5db205ff93fbe17750f.tar.xz bootstrap-cd5c7a2263c33e7c4fe7f5db205ff93fbe17750f.zip | |
grunt
Diffstat (limited to 'docs/dist/js/bootstrap.js')
| -rw-r--r-- | docs/dist/js/bootstrap.js | 189 |
1 files changed, 115 insertions, 74 deletions
diff --git a/docs/dist/js/bootstrap.js b/docs/dist/js/bootstrap.js index 8574d0aa4..fe7545490 100644 --- a/docs/dist/js/bootstrap.js +++ b/docs/dist/js/bootstrap.js @@ -282,6 +282,8 @@ var Alert = function ($) { }; Alert.prototype._removeElement = function _removeElement(element) { + var _this2 = this; + $(element).removeClass(ClassName.ACTIVE); if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { @@ -289,7 +291,9 @@ var Alert = function ($) { return; } - $(element).one(Util.TRANSITION_END, $.proxy(this._destroyElement, this, element)).emulateTransitionEnd(TRANSITION_DURATION); + $(element).one(Util.TRANSITION_END, function (event) { + return _this2._destroyElement(element, event); + }).emulateTransitionEnd(TRANSITION_DURATION); }; Alert.prototype._destroyElement = function _destroyElement(element) { @@ -668,12 +672,12 @@ var Carousel = function ($) { } if (this._config.interval && !this._isPaused) { - this._interval = setInterval($.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval); + this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); } }; Carousel.prototype.to = function to(index) { - var _this2 = this; + var _this3 = this; this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; @@ -685,7 +689,7 @@ var Carousel = function ($) { if (this._isSliding) { $(this._element).one(Event.SLID, function () { - return _this2.to(index); + return _this3.to(index); }); return; } @@ -724,12 +728,20 @@ var Carousel = function ($) { }; Carousel.prototype._addEventListeners = function _addEventListeners() { + var _this4 = this; + if (this._config.keyboard) { - $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this)); + $(this._element).on(Event.KEYDOWN, function (event) { + return _this4._keydown(event); + }); } if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) { - $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this)); + $(this._element).on(Event.MOUSEENTER, function (event) { + return _this4.pause(event); + }).on(Event.MOUSELEAVE, function (event) { + return _this4.cycle(event); + }); } }; @@ -798,7 +810,7 @@ var Carousel = function ($) { }; Carousel.prototype._slide = function _slide(direction, element) { - var _this3 = this; + var _this5 = this; var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); @@ -851,10 +863,10 @@ var Carousel = function ($) { $(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName); - _this3._isSliding = false; + _this5._isSliding = false; setTimeout(function () { - return $(_this3._element).trigger(slidEvent); + return $(_this5._element).trigger(slidEvent); }, 0); }).emulateTransitionEnd(TRANSITION_DURATION); } else { @@ -1074,7 +1086,7 @@ var Collapse = function ($) { }; Collapse.prototype.show = function show() { - var _this4 = this; + var _this6 = this; if (this._isTransitioning || $(this._element).hasClass(ClassName.ACTIVE)) { return; @@ -1124,13 +1136,13 @@ var Collapse = function ($) { this.setTransitioning(true); var complete = function complete() { - $(_this4._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.ACTIVE); + $(_this6._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.ACTIVE); - _this4._element.style[dimension] = ''; + _this6._element.style[dimension] = ''; - _this4.setTransitioning(false); + _this6.setTransitioning(false); - $(_this4._element).trigger(Event.SHOWN); + $(_this6._element).trigger(Event.SHOWN); }; if (!Util.supportsTransitionEnd()) { @@ -1147,7 +1159,7 @@ var Collapse = function ($) { }; Collapse.prototype.hide = function hide() { - var _this5 = this; + var _this7 = this; if (this._isTransitioning || !$(this._element).hasClass(ClassName.ACTIVE)) { return; @@ -1177,8 +1189,8 @@ var Collapse = function ($) { this.setTransitioning(true); var complete = function complete() { - _this5.setTransitioning(false); - $(_this5._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + _this7.setTransitioning(false); + $(_this7._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); }; this._element.style[dimension] = ''; @@ -1220,13 +1232,13 @@ var Collapse = function ($) { }; Collapse.prototype._getParent = function _getParent() { - var _this6 = this; + var _this8 = this; var parent = $(this._config.parent)[0]; var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; $(parent).find(selector).each(function (i, element) { - _this6._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + _this8._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); }); return parent; @@ -1700,7 +1712,7 @@ var Modal = function ($) { }; Modal.prototype.show = function show(relatedTarget) { - var _this7 = this; + var _this9 = this; var showEvent = $.Event(Event.SHOW, { relatedTarget: relatedTarget @@ -1722,20 +1734,26 @@ var Modal = function ($) { this._setEscapeEvent(); this._setResizeEvent(); - $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this)); + $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) { + return _this9.hide(event); + }); $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { - $(_this7._element).one(Event.MOUSEUP_DISMISS, function (event) { - if ($(event.target).is(_this7._element)) { - _this7._ignoreBackdropClick = true; + $(_this9._element).one(Event.MOUSEUP_DISMISS, function (event) { + if ($(event.target).is(_this9._element)) { + _this9._ignoreBackdropClick = true; } }); }); - this._showBackdrop($.proxy(this._showElement, this, relatedTarget)); + this._showBackdrop(function () { + return _this9._showElement(relatedTarget); + }); }; Modal.prototype.hide = function hide(event) { + var _this10 = this; + if (event) { event.preventDefault(); } @@ -1762,7 +1780,9 @@ var Modal = function ($) { if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { - $(this._element).one(Util.TRANSITION_END, $.proxy(this._hideModal, this)).emulateTransitionEnd(TRANSITION_DURATION); + $(this._element).one(Util.TRANSITION_END, function (event) { + return _this10._hideModal(event); + }).emulateTransitionEnd(TRANSITION_DURATION); } else { this._hideModal(); } @@ -1796,7 +1816,7 @@ var Modal = function ($) { }; Modal.prototype._showElement = function _showElement(relatedTarget) { - var _this8 = this; + var _this11 = this; var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); @@ -1824,10 +1844,10 @@ var Modal = function ($) { }); var transitionComplete = function transitionComplete() { - if (_this8._config.focus) { - _this8._element.focus(); + if (_this11._config.focus) { + _this11._element.focus(); } - $(_this8._element).trigger(shownEvent); + $(_this11._element).trigger(shownEvent); }; if (transition) { @@ -1838,23 +1858,23 @@ var Modal = function ($) { }; Modal.prototype._enforceFocus = function _enforceFocus() { - var _this9 = this; + var _this12 = this; $(document).off(Event.FOCUSIN) // guard against infinite focus loop .on(Event.FOCUSIN, function (event) { - if (document !== event.target && _this9._element !== event.target && !$(_this9._element).has(event.target).length) { - _this9._element.focus(); + if (document !== event.target && _this12._element !== event.target && !$(_this12._element).has(event.target).length) { + _this12._element.focus(); } }); }; Modal.prototype._setEscapeEvent = function _setEscapeEvent() { - var _this10 = this; + var _this13 = this; if (this._isShown && this._config.keyboard) { $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { if (event.which === ESCAPE_KEYCODE) { - _this10.hide(); + _this13.hide(); } }); } else if (!this._isShown) { @@ -1863,23 +1883,27 @@ var Modal = function ($) { }; Modal.prototype._setResizeEvent = function _setResizeEvent() { + var _this14 = this; + if (this._isShown) { - $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)); + $(window).on(Event.RESIZE, function (event) { + return _this14._handleUpdate(event); + }); } else { $(window).off(Event.RESIZE); } }; Modal.prototype._hideModal = function _hideModal() { - var _this11 = this; + var _this15 = this; this._element.style.display = 'none'; this._element.setAttribute('aria-hidden', 'true'); this._showBackdrop(function () { $(document.body).removeClass(ClassName.OPEN); - _this11._resetAdjustments(); - _this11._resetScrollbar(); - $(_this11._element).trigger(Event.HIDDEN); + _this15._resetAdjustments(); + _this15._resetScrollbar(); + $(_this15._element).trigger(Event.HIDDEN); }); }; @@ -1891,7 +1915,7 @@ var Modal = function ($) { }; Modal.prototype._showBackdrop = function _showBackdrop(callback) { - var _this12 = this; + var _this16 = this; var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; @@ -1908,17 +1932,17 @@ var Modal = function ($) { $(this._backdrop).appendTo(document.body); $(this._element).on(Event.CLICK_DISMISS, function (event) { - if (_this12._ignoreBackdropClick) { - _this12._ignoreBackdropClick = false; + if (_this16._ignoreBackdropClick) { + _this16._ignoreBackdropClick = false; return; } if (event.target !== event.currentTarget) { return; } - if (_this12._config.backdrop === 'static') { - _this12._element.focus(); + if (_this16._config.backdrop === 'static') { + _this16._element.focus(); } else { - _this12.hide(); + _this16.hide(); } }); @@ -1942,7 +1966,7 @@ var Modal = function ($) { $(this._backdrop).removeClass(ClassName.ACTIVE); var callbackRemove = function callbackRemove() { - _this12._removeBackdrop(); + _this16._removeBackdrop(); if (callback) { callback(); } @@ -2058,7 +2082,7 @@ var Modal = function ($) { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - var _this13 = this; + var _this17 = this; var target = void 0; var selector = Util.getSelectorFromElement(this); @@ -2080,8 +2104,8 @@ var Modal = function ($) { } $target.one(Event.HIDDEN, function () { - if ($(_this13).is(':visible')) { - _this13.focus(); + if ($(_this17).is(':visible')) { + _this17.focus(); } }); }); @@ -2178,6 +2202,8 @@ var ScrollSpy = function ($) { var ScrollSpy = function () { function ScrollSpy(element, config) { + var _this18 = this; + _classCallCheck(this, ScrollSpy); this._element = element; @@ -2189,7 +2215,9 @@ var ScrollSpy = function ($) { this._activeTarget = null; this._scrollHeight = 0; - $(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this)); + $(this._scrollElement).on(Event.SCROLL, function (event) { + return _this18._process(event); + }); this.refresh(); this._process(); @@ -2200,7 +2228,7 @@ var ScrollSpy = function ($) { // public ScrollSpy.prototype.refresh = function refresh() { - var _this14 = this; + var _this19 = this; var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET; @@ -2233,8 +2261,8 @@ var ScrollSpy = function ($) { }).sort(function (a, b) { return a[0] - b[0]; }).forEach(function (item) { - _this14._offsets.push(item[0]); - _this14._targets.push(item[1]); + _this19._offsets.push(item[0]); + _this19._targets.push(item[1]); }); }; @@ -2477,7 +2505,7 @@ var Tab = function ($) { // public Tab.prototype.show = function show() { - var _this15 = this; + var _this20 = this; if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE)) { return; @@ -2519,7 +2547,7 @@ var Tab = function ($) { var complete = function complete() { var hiddenEvent = $.Event(Event.HIDDEN, { - relatedTarget: _this15._element + relatedTarget: _this20._element }); var shownEvent = $.Event(Event.SHOWN, { @@ -2527,7 +2555,7 @@ var Tab = function ($) { }); $(previous).trigger(hiddenEvent); - $(_this15._element).trigger(shownEvent); + $(_this20._element).trigger(shownEvent); }; if (target) { @@ -2545,10 +2573,14 @@ var Tab = function ($) { // private Tab.prototype._activate = function _activate(element, container, callback) { + var _this21 = this; + var active = $(container).find(Selector.ACTIVE_CHILD)[0]; var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0])); - var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback); + var complete = function complete() { + return _this21._transitionComplete(element, active, isTransitioning, callback); + }; if (active && isTransitioning) { $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); @@ -2857,8 +2889,11 @@ var Tooltip = function ($) { }; Tooltip.prototype.show = function show() { - var _this16 = this; + var _this22 = this; + if ($(this.element).css('display') === 'none') { + throw new Error('Please use show on visible elements'); + } var showEvent = $.Event(this.constructor.Event.SHOW); if (this.isWithContent() && this._isEnabled) { @@ -2907,13 +2942,13 @@ var Tooltip = function ($) { $(tip).addClass(ClassName.ACTIVE); var complete = function complete() { - var prevHoverState = _this16._hoverState; - _this16._hoverState = null; + var prevHoverState = _this22._hoverState; + _this22._hoverState = null; - $(_this16.element).trigger(_this16.constructor.Event.SHOWN); + $(_this22.element).trigger(_this22.constructor.Event.SHOWN); if (prevHoverState === HoverState.OUT) { - _this16._leave(null, _this16); + _this22._leave(null, _this22); } }; @@ -2927,18 +2962,18 @@ var Tooltip = function ($) { }; Tooltip.prototype.hide = function hide(callback) { - var _this17 = this; + var _this23 = this; var tip = this.getTipElement(); var hideEvent = $.Event(this.constructor.Event.HIDE); var complete = function complete() { - if (_this17._hoverState !== HoverState.ACTIVE && tip.parentNode) { + if (_this23._hoverState !== HoverState.ACTIVE && tip.parentNode) { tip.parentNode.removeChild(tip); } - _this17.element.removeAttribute('aria-describedby'); - $(_this17.element).trigger(_this17.constructor.Event.HIDDEN); - _this17.cleanupTether(); + _this23.element.removeAttribute('aria-describedby'); + $(_this23.element).trigger(_this23.constructor.Event.HIDDEN); + _this23.cleanupTether(); if (callback) { callback(); @@ -3022,18 +3057,24 @@ var Tooltip = function ($) { }; Tooltip.prototype._setListeners = function _setListeners() { - var _this18 = this; + var _this24 = this; var triggers = this.config.trigger.split(' '); triggers.forEach(function (trigger) { if (trigger === 'click') { - $(_this18.element).on(_this18.constructor.Event.CLICK, _this18.config.selector, $.proxy(_this18.toggle, _this18)); + $(_this24.element).on(_this24.constructor.Event.CLICK, _this24.config.selector, function (event) { + return _this24.toggle(event); + }); } else if (trigger !== Trigger.MANUAL) { - var eventIn = trigger === Trigger.HOVER ? _this18.constructor.Event.MOUSEENTER : _this18.constructor.Event.FOCUSIN; - var eventOut = trigger === Trigger.HOVER ? _this18.constructor.Event.MOUSELEAVE : _this18.constructor.Event.FOCUSOUT; - - $(_this18.element).on(eventIn, _this18.config.selector, $.proxy(_this18._enter, _this18)).on(eventOut, _this18.config.selector, $.proxy(_this18._leave, _this18)); + var eventIn = trigger === Trigger.HOVER ? _this24.constructor.Event.MOUSEENTER : _this24.constructor.Event.FOCUSIN; + var eventOut = trigger === Trigger.HOVER ? _this24.constructor.Event.MOUSELEAVE : _this24.constructor.Event.FOCUSOUT; + + $(_this24.element).on(eventIn, _this24.config.selector, function (event) { + return _this24._enter(event); + }).on(eventOut, _this24.config.selector, function (event) { + return _this24._leave(event); + }); } }); |
