Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Gentry <blakesgentry@gmail.com>2017-01-06 21:10:24 +0300
committerBlake Gentry <blakesgentry@gmail.com>2017-01-06 21:10:24 +0300
commitf82164992580fca0c3e3dde7d6d097784a514e5b (patch)
treebb3ff36c326d696623203563a53cab5982970ad8 /assets/javascripts/bootstrap/tooltip.js
parent023043a2da9098e7b8521a2ac62b7b5a470c40d9 (diff)
rake update[v4.0.0-alpha.6]
Diffstat (limited to 'assets/javascripts/bootstrap/tooltip.js')
-rw-r--r--assets/javascripts/bootstrap/tooltip.js76
1 files changed, 54 insertions, 22 deletions
diff --git a/assets/javascripts/bootstrap/tooltip.js b/assets/javascripts/bootstrap/tooltip.js
index 2d3f6b4..d261eab 100644
--- a/assets/javascripts/bootstrap/tooltip.js
+++ b/assets/javascripts/bootstrap/tooltip.js
@@ -6,7 +6,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.5): tooltip.js
+ * Bootstrap (v4.0.0-alpha.6): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -17,7 +17,7 @@ var Tooltip = function ($) {
* Check for Tether dependency
* Tether - http://tether.io/
*/
- if (window.Tether === undefined) {
+ if (typeof Tether === 'undefined') {
throw new Error('Bootstrap tooltips require Tether (http://tether.io/)');
}
@@ -28,7 +28,7 @@ var Tooltip = function ($) {
*/
var NAME = 'tooltip';
- var VERSION = '4.0.0-alpha.5';
+ var VERSION = '4.0.0-alpha.6';
var DATA_KEY = 'bs.tooltip';
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
@@ -45,7 +45,8 @@ var Tooltip = function ($) {
selector: false,
placement: 'top',
offset: '0 0',
- constraints: []
+ constraints: [],
+ container: false
};
var DefaultType = {
@@ -58,7 +59,8 @@ var Tooltip = function ($) {
selector: '(string|boolean)',
placement: '(string|function)',
offset: 'string',
- constraints: 'array'
+ constraints: 'array',
+ container: '(string|element|boolean)'
};
var AttachmentMap = {
@@ -69,7 +71,7 @@ var Tooltip = function ($) {
};
var HoverState = {
- IN: 'in',
+ SHOW: 'show',
OUT: 'out'
};
@@ -88,7 +90,7 @@ var Tooltip = function ($) {
var ClassName = {
FADE: 'fade',
- IN: 'in'
+ SHOW: 'show'
};
var Selector = {
@@ -123,6 +125,7 @@ var Tooltip = function ($) {
this._timeout = 0;
this._hoverState = '';
this._activeTrigger = {};
+ this._isTransitioning = false;
this._tether = null;
// protected
@@ -168,7 +171,7 @@ var Tooltip = function ($) {
}
} else {
- if ($(this.getTipElement()).hasClass(ClassName.IN)) {
+ if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
this._leave(null, this);
return;
}
@@ -185,6 +188,7 @@ var Tooltip = function ($) {
$.removeData(this.element, this.constructor.DATA_KEY);
$(this.element).off(this.constructor.EVENT_KEY);
+ $(this.element).closest('.modal').off('hide.bs.modal');
if (this.tip) {
$(this.tip).remove();
@@ -204,9 +208,15 @@ var Tooltip = function ($) {
Tooltip.prototype.show = function show() {
var _this = this;
- var showEvent = $.Event(this.constructor.Event.SHOW);
+ 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) {
+ if (this._isTransitioning) {
+ throw new Error('Tooltip is transitioning');
+ }
$(this.element).trigger(showEvent);
var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
@@ -231,7 +241,9 @@ var Tooltip = function ($) {
var attachment = this._getAttachment(placement);
- $(tip).data(this.constructor.DATA_KEY, this).appendTo(document.body);
+ var container = this.config.container === false ? document.body : $(this.config.container);
+
+ $(tip).data(this.constructor.DATA_KEY, this).appendTo(container);
$(this.element).trigger(this.constructor.Event.INSERTED);
@@ -249,11 +261,12 @@ var Tooltip = function ($) {
Util.reflow(tip);
this._tether.position();
- $(tip).addClass(ClassName.IN);
+ $(tip).addClass(ClassName.SHOW);
var complete = function complete() {
var prevHoverState = _this._hoverState;
_this._hoverState = null;
+ _this._isTransitioning = false;
$(_this.element).trigger(_this.constructor.Event.SHOWN);
@@ -263,6 +276,7 @@ var Tooltip = function ($) {
};
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
+ this._isTransitioning = true;
$(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
return;
}
@@ -276,13 +290,17 @@ var Tooltip = function ($) {
var tip = this.getTipElement();
var hideEvent = $.Event(this.constructor.Event.HIDE);
+ if (this._isTransitioning) {
+ throw new Error('Tooltip is transitioning');
+ }
var complete = function complete() {
- if (_this2._hoverState !== HoverState.IN && tip.parentNode) {
+ if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip);
}
_this2.element.removeAttribute('aria-describedby');
$(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
+ _this2._isTransitioning = false;
_this2.cleanupTether();
if (callback) {
@@ -296,10 +314,14 @@ var Tooltip = function ($) {
return;
}
- $(tip).removeClass(ClassName.IN);
+ $(tip).removeClass(ClassName.SHOW);
- if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
+ this._activeTrigger[Trigger.CLICK] = false;
+ this._activeTrigger[Trigger.FOCUS] = false;
+ this._activeTrigger[Trigger.HOVER] = false;
+ if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
+ this._isTransitioning = true;
$(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
} else {
complete();
@@ -323,7 +345,7 @@ var Tooltip = function ($) {
this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle());
- $tip.removeClass(ClassName.FADE).removeClass(ClassName.IN);
+ $tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW);
this.cleanupTether();
};
@@ -373,13 +395,23 @@ var Tooltip = function ($) {
triggers.forEach(function (trigger) {
if (trigger === 'click') {
- $(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, $.proxy(_this3.toggle, _this3));
+ $(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, function (event) {
+ return _this3.toggle(event);
+ });
} else if (trigger !== Trigger.MANUAL) {
var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
- $(_this3.element).on(eventIn, _this3.config.selector, $.proxy(_this3._enter, _this3)).on(eventOut, _this3.config.selector, $.proxy(_this3._leave, _this3));
+ $(_this3.element).on(eventIn, _this3.config.selector, function (event) {
+ return _this3._enter(event);
+ }).on(eventOut, _this3.config.selector, function (event) {
+ return _this3._leave(event);
+ });
}
+
+ $(_this3.element).closest('.modal').on('hide.bs.modal', function () {
+ return _this3.hide();
+ });
});
if (this.config.selector) {
@@ -414,14 +446,14 @@ var Tooltip = function ($) {
context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
}
- if ($(context.getTipElement()).hasClass(ClassName.IN) || context._hoverState === HoverState.IN) {
- context._hoverState = HoverState.IN;
+ if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
+ context._hoverState = HoverState.SHOW;
return;
}
clearTimeout(context._timeout);
- context._hoverState = HoverState.IN;
+ context._hoverState = HoverState.SHOW;
if (!context.config.delay || !context.config.delay.show) {
context.show();
@@ -429,7 +461,7 @@ var Tooltip = function ($) {
}
context._timeout = setTimeout(function () {
- if (context._hoverState === HoverState.IN) {
+ if (context._hoverState === HoverState.SHOW) {
context.show();
}
}, context.config.delay.show);
@@ -513,7 +545,7 @@ var Tooltip = function ($) {
Tooltip._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
- var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' ? config : null;
+ var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config;
if (!data && /dispose|hide/.test(config)) {
return;