aboutsummaryrefslogtreecommitdiffstats
path: root/library/bootstrap/js/bootstrap.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/bootstrap/js/bootstrap.js')
-rw-r--r--library/bootstrap/js/bootstrap.js238
1 files changed, 140 insertions, 98 deletions
diff --git a/library/bootstrap/js/bootstrap.js b/library/bootstrap/js/bootstrap.js
index 4048449a0..086ba45b6 100644
--- a/library/bootstrap/js/bootstrap.js
+++ b/library/bootstrap/js/bootstrap.js
@@ -1107,6 +1107,14 @@ var Collapse = function ($) {
this._element = element;
this._config = this._getConfig(config);
this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]')));
+ var tabToggles = $(Selector.DATA_TOGGLE);
+ for (var i = 0; i < tabToggles.length; i++) {
+ var elem = tabToggles[i];
+ var selector = Util.getSelectorFromElement(elem);
+ if (selector !== null && $(selector).filter(element).length > 0) {
+ this._triggerArray.push(elem);
+ }
+ }
this._parent = this._config.parent ? this._getParent() : null;
@@ -1225,7 +1233,16 @@ var Collapse = function ($) {
$(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW);
if (this._triggerArray.length) {
- $(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
+ for (var i = 0; i < this._triggerArray.length; i++) {
+ var trigger = this._triggerArray[i];
+ var selector = Util.getSelectorFromElement(trigger);
+ if (selector !== null) {
+ var $elem = $(selector);
+ if (!$elem.hasClass(ClassName.SHOW)) {
+ $(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
+ }
+ }
+ }
}
this.setTransitioning(true);
@@ -1353,11 +1370,14 @@ var Collapse = function ($) {
event.preventDefault();
}
- var target = Collapse._getTargetFromElement(this);
- var data = $(target).data(DATA_KEY);
- var config = data ? 'toggle' : $(this).data();
-
- Collapse._jQueryInterface.call($(target), config);
+ var $trigger = $(this);
+ var selector = Util.getSelectorFromElement(this);
+ $(selector).each(function () {
+ var $target = $(this);
+ var data = $target.data(DATA_KEY);
+ var config = data ? 'toggle' : $trigger.data();
+ Collapse._jQueryInterface.call($target, config);
+ });
});
/**
@@ -1475,6 +1495,7 @@ var Dropdown = function ($) {
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
+ this._inNavbar = this._detectNavbar();
this._addEventListeners();
}
@@ -1515,17 +1536,7 @@ var Dropdown = function ($) {
element = parent;
}
}
- this._popper = new Popper(element, this._menu, {
- placement: this._getPlacement(),
- modifiers: {
- offset: {
- offset: this._config.offset
- },
- flip: {
- enabled: this._config.flip
- }
- }
- });
+ this._popper = new Popper(element, this._menu, this._getPopperConfig());
// if this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
@@ -1554,6 +1565,7 @@ var Dropdown = function ($) {
};
Dropdown.prototype.update = function update() {
+ this._inNavbar = this._detectNavbar();
if (this._popper !== null) {
this._popper.scheduleUpdate();
}
@@ -1602,14 +1614,44 @@ var Dropdown = function ($) {
if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
placement = AttachmentMap.TOPEND;
}
- } else {
- if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
- placement = AttachmentMap.BOTTOMEND;
- }
+ } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
+ placement = AttachmentMap.BOTTOMEND;
}
return placement;
};
+ Dropdown.prototype._detectNavbar = function _detectNavbar() {
+ return $(this._element).closest('.navbar').length > 0;
+ };
+
+ Dropdown.prototype._getPopperConfig = function _getPopperConfig() {
+ var _this10 = this;
+
+ var popperConfig = {
+ placement: this._getPlacement(),
+ modifiers: {
+ offset: {
+ offset: this._config.offset
+ },
+ flip: {
+ enabled: this._config.flip
+ }
+ }
+ };
+
+ if (this._inNavbar) {
+ popperConfig.modifiers.AfterApplyStyle = {
+ enabled: true,
+ order: 901, // ApplyStyle order + 1
+ fn: function fn() {
+ // reset Popper styles
+ $(_this10._menu).attr('style', '');
+ }
+ };
+ }
+ return popperConfig;
+ };
+
// static
Dropdown._jQueryInterface = function _jQueryInterface(config) {
@@ -1887,7 +1929,7 @@ var Modal = function ($) {
};
Modal.prototype.show = function show(relatedTarget) {
- var _this10 = this;
+ var _this11 = this;
if (this._isTransitioning) {
return;
@@ -1918,24 +1960,24 @@ var Modal = function ($) {
this._setResizeEvent();
$(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) {
- return _this10.hide(event);
+ return _this11.hide(event);
});
$(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () {
- $(_this10._element).one(Event.MOUSEUP_DISMISS, function (event) {
- if ($(event.target).is(_this10._element)) {
- _this10._ignoreBackdropClick = true;
+ $(_this11._element).one(Event.MOUSEUP_DISMISS, function (event) {
+ if ($(event.target).is(_this11._element)) {
+ _this11._ignoreBackdropClick = true;
}
});
});
this._showBackdrop(function () {
- return _this10._showElement(relatedTarget);
+ return _this11._showElement(relatedTarget);
});
};
Modal.prototype.hide = function hide(event) {
- var _this11 = this;
+ var _this12 = this;
if (event) {
event.preventDefault();
@@ -1974,7 +2016,7 @@ var Modal = function ($) {
if (transition) {
$(this._element).one(Util.TRANSITION_END, function (event) {
- return _this11._hideModal(event);
+ return _this12._hideModal(event);
}).emulateTransitionEnd(TRANSITION_DURATION);
} else {
this._hideModal();
@@ -2009,7 +2051,7 @@ var Modal = function ($) {
};
Modal.prototype._showElement = function _showElement(relatedTarget) {
- var _this12 = this;
+ var _this13 = this;
var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
@@ -2037,11 +2079,11 @@ var Modal = function ($) {
});
var transitionComplete = function transitionComplete() {
- if (_this12._config.focus) {
- _this12._element.focus();
+ if (_this13._config.focus) {
+ _this13._element.focus();
}
- _this12._isTransitioning = false;
- $(_this12._element).trigger(shownEvent);
+ _this13._isTransitioning = false;
+ $(_this13._element).trigger(shownEvent);
};
if (transition) {
@@ -2052,24 +2094,24 @@ var Modal = function ($) {
};
Modal.prototype._enforceFocus = function _enforceFocus() {
- var _this13 = this;
+ var _this14 = this;
$(document).off(Event.FOCUSIN) // guard against infinite focus loop
.on(Event.FOCUSIN, function (event) {
- if (document !== event.target && _this13._element !== event.target && !$(_this13._element).has(event.target).length) {
- _this13._element.focus();
+ if (document !== event.target && _this14._element !== event.target && !$(_this14._element).has(event.target).length) {
+ _this14._element.focus();
}
});
};
Modal.prototype._setEscapeEvent = function _setEscapeEvent() {
- var _this14 = this;
+ var _this15 = this;
if (this._isShown && this._config.keyboard) {
$(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
if (event.which === ESCAPE_KEYCODE) {
event.preventDefault();
- _this14.hide();
+ _this15.hide();
}
});
} else if (!this._isShown) {
@@ -2078,11 +2120,11 @@ var Modal = function ($) {
};
Modal.prototype._setResizeEvent = function _setResizeEvent() {
- var _this15 = this;
+ var _this16 = this;
if (this._isShown) {
$(window).on(Event.RESIZE, function (event) {
- return _this15.handleUpdate(event);
+ return _this16.handleUpdate(event);
});
} else {
$(window).off(Event.RESIZE);
@@ -2090,16 +2132,16 @@ var Modal = function ($) {
};
Modal.prototype._hideModal = function _hideModal() {
- var _this16 = this;
+ var _this17 = this;
this._element.style.display = 'none';
this._element.setAttribute('aria-hidden', true);
this._isTransitioning = false;
this._showBackdrop(function () {
$(document.body).removeClass(ClassName.OPEN);
- _this16._resetAdjustments();
- _this16._resetScrollbar();
- $(_this16._element).trigger(Event.HIDDEN);
+ _this17._resetAdjustments();
+ _this17._resetScrollbar();
+ $(_this17._element).trigger(Event.HIDDEN);
});
};
@@ -2111,7 +2153,7 @@ var Modal = function ($) {
};
Modal.prototype._showBackdrop = function _showBackdrop(callback) {
- var _this17 = this;
+ var _this18 = this;
var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
@@ -2128,17 +2170,17 @@ var Modal = function ($) {
$(this._backdrop).appendTo(document.body);
$(this._element).on(Event.CLICK_DISMISS, function (event) {
- if (_this17._ignoreBackdropClick) {
- _this17._ignoreBackdropClick = false;
+ if (_this18._ignoreBackdropClick) {
+ _this18._ignoreBackdropClick = false;
return;
}
if (event.target !== event.currentTarget) {
return;
}
- if (_this17._config.backdrop === 'static') {
- _this17._element.focus();
+ if (_this18._config.backdrop === 'static') {
+ _this18._element.focus();
} else {
- _this17.hide();
+ _this18.hide();
}
});
@@ -2162,7 +2204,7 @@ var Modal = function ($) {
$(this._backdrop).removeClass(ClassName.SHOW);
var callbackRemove = function callbackRemove() {
- _this17._removeBackdrop();
+ _this18._removeBackdrop();
if (callback) {
callback();
}
@@ -2206,7 +2248,7 @@ var Modal = function ($) {
};
Modal.prototype._setScrollbar = function _setScrollbar() {
- var _this18 = this;
+ var _this19 = this;
if (this._isBodyOverflowing) {
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
@@ -2216,14 +2258,14 @@ var Modal = function ($) {
$(Selector.FIXED_CONTENT).each(function (index, element) {
var actualPadding = $(element)[0].style.paddingRight;
var calculatedPadding = $(element).css('padding-right');
- $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this18._scrollbarWidth + 'px');
+ $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this19._scrollbarWidth + 'px');
});
// Adjust navbar-toggler margin
$(Selector.NAVBAR_TOGGLER).each(function (index, element) {
var actualMargin = $(element)[0].style.marginRight;
var calculatedMargin = $(element).css('margin-right');
- $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) + _this18._scrollbarWidth + 'px');
+ $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) + _this19._scrollbarWidth + 'px');
});
// Adjust body padding
@@ -2312,7 +2354,7 @@ var Modal = function ($) {
*/
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- var _this19 = this;
+ var _this20 = this;
var target = void 0;
var selector = Util.getSelectorFromElement(this);
@@ -2334,8 +2376,8 @@ var Modal = function ($) {
}
$target.one(Event.HIDDEN, function () {
- if ($(_this19).is(':visible')) {
- _this19.focus();
+ if ($(_this20).is(':visible')) {
+ _this20.focus();
}
});
});
@@ -2429,7 +2471,7 @@ var ScrollSpy = function ($) {
var ScrollSpy = function () {
function ScrollSpy(element, config) {
- var _this20 = this;
+ var _this21 = this;
_classCallCheck(this, ScrollSpy);
@@ -2443,7 +2485,7 @@ var ScrollSpy = function ($) {
this._scrollHeight = 0;
$(this._scrollElement).on(Event.SCROLL, function (event) {
- return _this20._process(event);
+ return _this21._process(event);
});
this.refresh();
@@ -2455,7 +2497,7 @@ var ScrollSpy = function ($) {
// public
ScrollSpy.prototype.refresh = function refresh() {
- var _this21 = this;
+ var _this22 = this;
var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET;
@@ -2491,8 +2533,8 @@ var ScrollSpy = function ($) {
}).sort(function (a, b) {
return a[0] - b[0];
}).forEach(function (item) {
- _this21._offsets.push(item[0]);
- _this21._targets.push(item[1]);
+ _this22._offsets.push(item[0]);
+ _this22._targets.push(item[1]);
});
};
@@ -2739,7 +2781,7 @@ var Tab = function ($) {
// public
Tab.prototype.show = function show() {
- var _this22 = this;
+ var _this23 = this;
if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE) || $(this._element).hasClass(ClassName.DISABLED)) {
return;
@@ -2781,7 +2823,7 @@ var Tab = function ($) {
var complete = function complete() {
var hiddenEvent = $.Event(Event.HIDDEN, {
- relatedTarget: _this22._element
+ relatedTarget: _this23._element
});
var shownEvent = $.Event(Event.SHOWN, {
@@ -2789,7 +2831,7 @@ var Tab = function ($) {
});
$(previous).trigger(hiddenEvent);
- $(_this22._element).trigger(shownEvent);
+ $(_this23._element).trigger(shownEvent);
};
if (target) {
@@ -2807,13 +2849,13 @@ var Tab = function ($) {
// private
Tab.prototype._activate = function _activate(element, container, callback) {
- var _this23 = this;
+ var _this24 = this;
var active = $(container).find(Selector.ACTIVE)[0];
var isTransitioning = callback && Util.supportsTransitionEnd() && active && $(active).hasClass(ClassName.FADE);
var complete = function complete() {
- return _this23._transitionComplete(element, active, isTransitioning, callback);
+ return _this24._transitionComplete(element, active, isTransitioning, callback);
};
if (active && isTransitioning) {
@@ -3125,7 +3167,7 @@ var Tooltip = function ($) {
};
Tooltip.prototype.show = function show() {
- var _this24 = this;
+ var _this25 = this;
if ($(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements');
@@ -3183,11 +3225,11 @@ var Tooltip = function ($) {
},
onCreate: function onCreate(data) {
if (data.originalPlacement !== data.placement) {
- _this24._handlePopperPlacementChange(data);
+ _this25._handlePopperPlacementChange(data);
}
},
onUpdate: function onUpdate(data) {
- _this24._handlePopperPlacementChange(data);
+ _this25._handlePopperPlacementChange(data);
}
});
@@ -3202,16 +3244,16 @@ var Tooltip = function ($) {
}
var complete = function complete() {
- if (_this24.config.animation) {
- _this24._fixTransition();
+ if (_this25.config.animation) {
+ _this25._fixTransition();
}
- var prevHoverState = _this24._hoverState;
- _this24._hoverState = null;
+ var prevHoverState = _this25._hoverState;
+ _this25._hoverState = null;
- $(_this24.element).trigger(_this24.constructor.Event.SHOWN);
+ $(_this25.element).trigger(_this25.constructor.Event.SHOWN);
if (prevHoverState === HoverState.OUT) {
- _this24._leave(null, _this24);
+ _this25._leave(null, _this25);
}
};
@@ -3224,20 +3266,20 @@ var Tooltip = function ($) {
};
Tooltip.prototype.hide = function hide(callback) {
- var _this25 = this;
+ var _this26 = this;
var tip = this.getTipElement();
var hideEvent = $.Event(this.constructor.Event.HIDE);
var complete = function complete() {
- if (_this25._hoverState !== HoverState.SHOW && tip.parentNode) {
+ if (_this26._hoverState !== HoverState.SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip);
}
- _this25._cleanTipClass();
- _this25.element.removeAttribute('aria-describedby');
- $(_this25.element).trigger(_this25.constructor.Event.HIDDEN);
- if (_this25._popper !== null) {
- _this25._popper.destroy();
+ _this26._cleanTipClass();
+ _this26.element.removeAttribute('aria-describedby');
+ $(_this26.element).trigger(_this26.constructor.Event.HIDDEN);
+ if (_this26._popper !== null) {
+ _this26._popper.destroy();
}
if (callback) {
@@ -3332,28 +3374,28 @@ var Tooltip = function ($) {
};
Tooltip.prototype._setListeners = function _setListeners() {
- var _this26 = this;
+ var _this27 = this;
var triggers = this.config.trigger.split(' ');
triggers.forEach(function (trigger) {
if (trigger === 'click') {
- $(_this26.element).on(_this26.constructor.Event.CLICK, _this26.config.selector, function (event) {
- return _this26.toggle(event);
+ $(_this27.element).on(_this27.constructor.Event.CLICK, _this27.config.selector, function (event) {
+ return _this27.toggle(event);
});
} else if (trigger !== Trigger.MANUAL) {
- var eventIn = trigger === Trigger.HOVER ? _this26.constructor.Event.MOUSEENTER : _this26.constructor.Event.FOCUSIN;
- var eventOut = trigger === Trigger.HOVER ? _this26.constructor.Event.MOUSELEAVE : _this26.constructor.Event.FOCUSOUT;
+ var eventIn = trigger === Trigger.HOVER ? _this27.constructor.Event.MOUSEENTER : _this27.constructor.Event.FOCUSIN;
+ var eventOut = trigger === Trigger.HOVER ? _this27.constructor.Event.MOUSELEAVE : _this27.constructor.Event.FOCUSOUT;
- $(_this26.element).on(eventIn, _this26.config.selector, function (event) {
- return _this26._enter(event);
- }).on(eventOut, _this26.config.selector, function (event) {
- return _this26._leave(event);
+ $(_this27.element).on(eventIn, _this27.config.selector, function (event) {
+ return _this27._enter(event);
+ }).on(eventOut, _this27.config.selector, function (event) {
+ return _this27._leave(event);
});
}
- $(_this26.element).closest('.modal').on('hide.bs.modal', function () {
- return _this26.hide();
+ $(_this27.element).closest('.modal').on('hide.bs.modal', function () {
+ return _this27.hide();
});
});
@@ -3625,7 +3667,7 @@ var Popover = function ($) {
placement: 'right',
trigger: 'click',
content: '',
- template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>'
+ template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
});
var DefaultType = $.extend({}, Tooltip.DefaultType, {
@@ -3638,8 +3680,8 @@ var Popover = function ($) {
};
var Selector = {
- TITLE: '.popover-title',
- CONTENT: '.popover-content'
+ TITLE: '.popover-header',
+ CONTENT: '.popover-body'
};
var Event = {