Skip to content

Commit c5d2d4d

Browse files
author
Guillaume Chau
committed
Version bump
1 parent da52280 commit c5d2d4d

File tree

4 files changed

+128
-36
lines changed

4 files changed

+128
-36
lines changed

dist/v-tooltip.esm.js

+63-17
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,8 @@ var DEFAULT_OPTIONS = {
26582658
offset: 0
26592659
};
26602660

2661+
var openTooltips = [];
2662+
26612663
var Tooltip = function () {
26622664
/**
26632665
* Create a new Tooltip.js instance
@@ -2828,6 +2830,7 @@ var Tooltip = function () {
28282830
return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
28292831
}) : [];
28302832
this._isDisposed = false;
2833+
this._enableDocumentTouch = events.indexOf('manual') === -1;
28312834

28322835
// set event listeners
28332836
this._setEventListeners(this.reference, events, this.options);
@@ -2920,6 +2923,8 @@ var Tooltip = function () {
29202923
}
29212924
this._isOpen = true;
29222925

2926+
openTooltips.push(this);
2927+
29232928
// if the tooltipNode already exists, just show it
29242929
if (this._tooltipNode) {
29252930
this._tooltipNode.style.display = '';
@@ -2988,6 +2993,14 @@ var Tooltip = function () {
29882993

29892994
return this;
29902995
}
2996+
}, {
2997+
key: '_noLongerOpen',
2998+
value: function _noLongerOpen() {
2999+
var index = openTooltips.indexOf(this);
3000+
if (index !== -1) {
3001+
openTooltips.splice(index, 1);
3002+
}
3003+
}
29913004
}, {
29923005
key: '_hide',
29933006
value: function _hide() /* reference, options */{
@@ -2999,6 +3012,7 @@ var Tooltip = function () {
29993012
}
30003013

30013014
this._isOpen = false;
3015+
this._noLongerOpen();
30023016

30033017
// hide tooltipNode
30043018
this._tooltipNode.style.display = 'none';
@@ -3052,6 +3066,8 @@ var Tooltip = function () {
30523066
this._tooltipNode.parentNode.removeChild(this._tooltipNode);
30533067
this._tooltipNode = null;
30543068
}
3069+
} else {
3070+
this._noLongerOpen();
30553071
}
30563072
return this;
30573073
}
@@ -3131,6 +3147,13 @@ var Tooltip = function () {
31313147
reference.addEventListener(event, func);
31323148
});
31333149
}
3150+
}, {
3151+
key: '_onDocumentTouch',
3152+
value: function _onDocumentTouch(event) {
3153+
if (this._enableDocumentTouch) {
3154+
this._scheduleHide(this.reference, this.options.delay, this.options, event);
3155+
}
3156+
}
31343157
}, {
31353158
key: '_scheduleShow',
31363159
value: function _scheduleShow(reference, delay, options /*, evt */) {
@@ -3178,21 +3201,7 @@ var Tooltip = function () {
31783201
return Tooltip;
31793202
}();
31803203

3181-
/**
3182-
* Placement function, its context is the Tooltip instance.
3183-
* @memberof Tooltip
3184-
* @callback PlacementFunction
3185-
* @param {HTMLElement} tooltip - tooltip DOM node.
3186-
* @param {HTMLElement} reference - reference DOM node.
3187-
* @return {String} placement - One of the allowed placement options.
3188-
*/
3189-
3190-
/**
3191-
* Title function, its context is the Tooltip instance.
3192-
* @memberof Tooltip
3193-
* @callback TitleFunction
3194-
* @return {String} placement - The desired title.
3195-
*/
3204+
// Hide tooltips on touch devices
31963205

31973206

31983207
var _initialiseProps = function _initialiseProps() {
@@ -3248,6 +3257,30 @@ var _initialiseProps = function _initialiseProps() {
32483257
};
32493258
};
32503259

3260+
if (typeof document !== 'undefined') {
3261+
document.addEventListener('touchstart', function (event) {
3262+
for (var i = 0; i < openTooltips.length; i++) {
3263+
openTooltips[i]._onDocumentTouch(event);
3264+
}
3265+
});
3266+
}
3267+
3268+
/**
3269+
* Placement function, its context is the Tooltip instance.
3270+
* @memberof Tooltip
3271+
* @callback PlacementFunction
3272+
* @param {HTMLElement} tooltip - tooltip DOM node.
3273+
* @param {HTMLElement} reference - reference DOM node.
3274+
* @return {String} placement - One of the allowed placement options.
3275+
*/
3276+
3277+
/**
3278+
* Title function, its context is the Tooltip instance.
3279+
* @memberof Tooltip
3280+
* @callback TitleFunction
3281+
* @return {String} placement - The desired title.
3282+
*/
3283+
32513284
var state = {
32523285
enabled: true
32533286
};
@@ -3532,6 +3565,11 @@ function getDefault(key) {
35323565
return value;
35333566
}
35343567

3568+
var isIOS = false;
3569+
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
3570+
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
3571+
}
3572+
35353573
var Popover = { render: function render() {
35363574
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { staticClass: "v-popover", class: _vm.cssClass }, [_c('span', { ref: "trigger", staticClass: "trigger", staticStyle: { "display": "inline-block" }, attrs: { "aria-describedby": _vm.popoverId } }, [_vm._t("default")], 2), _vm._v(" "), _c('div', { ref: "popover", staticClass: "tooltip popover", class: [_vm.cssClass, _vm.popoverClass], style: {
35373575
display: _vm.isOpen ? '' : 'none'
@@ -3987,11 +4025,19 @@ var Popover = { render: function render() {
39874025
},
39884026
$_addGlobalEvents: function $_addGlobalEvents() {
39894027
if (this.autoHide) {
3990-
window.addEventListener('click', this.$_handleWindowClick);
4028+
if (isIOS) {
4029+
document.addEventListener('touchstart', this.$_handleWindowClick);
4030+
} else {
4031+
window.addEventListener('click', this.$_handleWindowClick);
4032+
}
39914033
}
39924034
},
39934035
$_removeGlobalEvents: function $_removeGlobalEvents() {
3994-
window.removeEventListener('click', this.$_handleWindowClick);
4036+
if (isIOS) {
4037+
document.removeEventListener('touchstart', this.$_handleWindowClick);
4038+
} else {
4039+
window.removeEventListener('click', this.$_handleWindowClick);
4040+
}
39954041
},
39964042
$_updatePopper: function $_updatePopper(cb) {
39974043
if (this.isOpen && this.popperInstance) {

dist/v-tooltip.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/v-tooltip.umd.js

+63-17
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,8 @@ var DEFAULT_OPTIONS = {
26642664
offset: 0
26652665
};
26662666

2667+
var openTooltips = [];
2668+
26672669
var Tooltip = function () {
26682670
/**
26692671
* Create a new Tooltip.js instance
@@ -2834,6 +2836,7 @@ var Tooltip = function () {
28342836
return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
28352837
}) : [];
28362838
this._isDisposed = false;
2839+
this._enableDocumentTouch = events.indexOf('manual') === -1;
28372840

28382841
// set event listeners
28392842
this._setEventListeners(this.reference, events, this.options);
@@ -2926,6 +2929,8 @@ var Tooltip = function () {
29262929
}
29272930
this._isOpen = true;
29282931

2932+
openTooltips.push(this);
2933+
29292934
// if the tooltipNode already exists, just show it
29302935
if (this._tooltipNode) {
29312936
this._tooltipNode.style.display = '';
@@ -2994,6 +2999,14 @@ var Tooltip = function () {
29942999

29953000
return this;
29963001
}
3002+
}, {
3003+
key: '_noLongerOpen',
3004+
value: function _noLongerOpen() {
3005+
var index = openTooltips.indexOf(this);
3006+
if (index !== -1) {
3007+
openTooltips.splice(index, 1);
3008+
}
3009+
}
29973010
}, {
29983011
key: '_hide',
29993012
value: function _hide() /* reference, options */{
@@ -3005,6 +3018,7 @@ var Tooltip = function () {
30053018
}
30063019

30073020
this._isOpen = false;
3021+
this._noLongerOpen();
30083022

30093023
// hide tooltipNode
30103024
this._tooltipNode.style.display = 'none';
@@ -3058,6 +3072,8 @@ var Tooltip = function () {
30583072
this._tooltipNode.parentNode.removeChild(this._tooltipNode);
30593073
this._tooltipNode = null;
30603074
}
3075+
} else {
3076+
this._noLongerOpen();
30613077
}
30623078
return this;
30633079
}
@@ -3137,6 +3153,13 @@ var Tooltip = function () {
31373153
reference.addEventListener(event, func);
31383154
});
31393155
}
3156+
}, {
3157+
key: '_onDocumentTouch',
3158+
value: function _onDocumentTouch(event) {
3159+
if (this._enableDocumentTouch) {
3160+
this._scheduleHide(this.reference, this.options.delay, this.options, event);
3161+
}
3162+
}
31403163
}, {
31413164
key: '_scheduleShow',
31423165
value: function _scheduleShow(reference, delay, options /*, evt */) {
@@ -3184,21 +3207,7 @@ var Tooltip = function () {
31843207
return Tooltip;
31853208
}();
31863209

3187-
/**
3188-
* Placement function, its context is the Tooltip instance.
3189-
* @memberof Tooltip
3190-
* @callback PlacementFunction
3191-
* @param {HTMLElement} tooltip - tooltip DOM node.
3192-
* @param {HTMLElement} reference - reference DOM node.
3193-
* @return {String} placement - One of the allowed placement options.
3194-
*/
3195-
3196-
/**
3197-
* Title function, its context is the Tooltip instance.
3198-
* @memberof Tooltip
3199-
* @callback TitleFunction
3200-
* @return {String} placement - The desired title.
3201-
*/
3210+
// Hide tooltips on touch devices
32023211

32033212

32043213
var _initialiseProps = function _initialiseProps() {
@@ -3254,6 +3263,30 @@ var _initialiseProps = function _initialiseProps() {
32543263
};
32553264
};
32563265

3266+
if (typeof document !== 'undefined') {
3267+
document.addEventListener('touchstart', function (event) {
3268+
for (var i = 0; i < openTooltips.length; i++) {
3269+
openTooltips[i]._onDocumentTouch(event);
3270+
}
3271+
});
3272+
}
3273+
3274+
/**
3275+
* Placement function, its context is the Tooltip instance.
3276+
* @memberof Tooltip
3277+
* @callback PlacementFunction
3278+
* @param {HTMLElement} tooltip - tooltip DOM node.
3279+
* @param {HTMLElement} reference - reference DOM node.
3280+
* @return {String} placement - One of the allowed placement options.
3281+
*/
3282+
3283+
/**
3284+
* Title function, its context is the Tooltip instance.
3285+
* @memberof Tooltip
3286+
* @callback TitleFunction
3287+
* @return {String} placement - The desired title.
3288+
*/
3289+
32573290
var state = {
32583291
enabled: true
32593292
};
@@ -3538,6 +3571,11 @@ function getDefault(key) {
35383571
return value;
35393572
}
35403573

3574+
var isIOS = false;
3575+
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
3576+
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
3577+
}
3578+
35413579
var Popover = { render: function render() {
35423580
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { staticClass: "v-popover", class: _vm.cssClass }, [_c('span', { ref: "trigger", staticClass: "trigger", staticStyle: { "display": "inline-block" }, attrs: { "aria-describedby": _vm.popoverId } }, [_vm._t("default")], 2), _vm._v(" "), _c('div', { ref: "popover", staticClass: "tooltip popover", class: [_vm.cssClass, _vm.popoverClass], style: {
35433581
display: _vm.isOpen ? '' : 'none'
@@ -3993,11 +4031,19 @@ var Popover = { render: function render() {
39934031
},
39944032
$_addGlobalEvents: function $_addGlobalEvents() {
39954033
if (this.autoHide) {
3996-
window.addEventListener('click', this.$_handleWindowClick);
4034+
if (isIOS) {
4035+
document.addEventListener('touchstart', this.$_handleWindowClick);
4036+
} else {
4037+
window.addEventListener('click', this.$_handleWindowClick);
4038+
}
39974039
}
39984040
},
39994041
$_removeGlobalEvents: function $_removeGlobalEvents() {
4000-
window.removeEventListener('click', this.$_handleWindowClick);
4042+
if (isIOS) {
4043+
document.removeEventListener('touchstart', this.$_handleWindowClick);
4044+
} else {
4045+
window.removeEventListener('click', this.$_handleWindowClick);
4046+
}
40014047
},
40024048
$_updatePopper: function $_updatePopper(cb) {
40034049
if (this.isOpen && this.popperInstance) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "v-tooltip",
3-
"version": "2.0.0-rc.20",
3+
"version": "2.0.0-rc.21",
44
"description": "Easy tooltips with Vue 2.x",
55
"main": "dist/v-tooltip.umd.js",
66
"module": "dist/v-tooltip.esm.js",

0 commit comments

Comments
 (0)