Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Nov 16, 2017
1 parent da52280 commit c5d2d4d
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 36 deletions.
80 changes: 63 additions & 17 deletions dist/v-tooltip.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,8 @@ var DEFAULT_OPTIONS = {
offset: 0
};

var openTooltips = [];

var Tooltip = function () {
/**
* Create a new Tooltip.js instance
Expand Down Expand Up @@ -2828,6 +2830,7 @@ var Tooltip = function () {
return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
}) : [];
this._isDisposed = false;
this._enableDocumentTouch = events.indexOf('manual') === -1;

// set event listeners
this._setEventListeners(this.reference, events, this.options);
Expand Down Expand Up @@ -2920,6 +2923,8 @@ var Tooltip = function () {
}
this._isOpen = true;

openTooltips.push(this);

// if the tooltipNode already exists, just show it
if (this._tooltipNode) {
this._tooltipNode.style.display = '';
Expand Down Expand Up @@ -2988,6 +2993,14 @@ var Tooltip = function () {

return this;
}
}, {
key: '_noLongerOpen',
value: function _noLongerOpen() {
var index = openTooltips.indexOf(this);
if (index !== -1) {
openTooltips.splice(index, 1);
}
}
}, {
key: '_hide',
value: function _hide() /* reference, options */{
Expand All @@ -2999,6 +3012,7 @@ var Tooltip = function () {
}

this._isOpen = false;
this._noLongerOpen();

// hide tooltipNode
this._tooltipNode.style.display = 'none';
Expand Down Expand Up @@ -3052,6 +3066,8 @@ var Tooltip = function () {
this._tooltipNode.parentNode.removeChild(this._tooltipNode);
this._tooltipNode = null;
}
} else {
this._noLongerOpen();
}
return this;
}
Expand Down Expand Up @@ -3131,6 +3147,13 @@ var Tooltip = function () {
reference.addEventListener(event, func);
});
}
}, {
key: '_onDocumentTouch',
value: function _onDocumentTouch(event) {
if (this._enableDocumentTouch) {
this._scheduleHide(this.reference, this.options.delay, this.options, event);
}
}
}, {
key: '_scheduleShow',
value: function _scheduleShow(reference, delay, options /*, evt */) {
Expand Down Expand Up @@ -3178,21 +3201,7 @@ var Tooltip = function () {
return Tooltip;
}();

/**
* Placement function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback PlacementFunction
* @param {HTMLElement} tooltip - tooltip DOM node.
* @param {HTMLElement} reference - reference DOM node.
* @return {String} placement - One of the allowed placement options.
*/

/**
* Title function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback TitleFunction
* @return {String} placement - The desired title.
*/
// Hide tooltips on touch devices


var _initialiseProps = function _initialiseProps() {
Expand Down Expand Up @@ -3248,6 +3257,30 @@ var _initialiseProps = function _initialiseProps() {
};
};

if (typeof document !== 'undefined') {
document.addEventListener('touchstart', function (event) {
for (var i = 0; i < openTooltips.length; i++) {
openTooltips[i]._onDocumentTouch(event);
}
});
}

/**
* Placement function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback PlacementFunction
* @param {HTMLElement} tooltip - tooltip DOM node.
* @param {HTMLElement} reference - reference DOM node.
* @return {String} placement - One of the allowed placement options.
*/

/**
* Title function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback TitleFunction
* @return {String} placement - The desired title.
*/

var state = {
enabled: true
};
Expand Down Expand Up @@ -3532,6 +3565,11 @@ function getDefault(key) {
return value;
}

var isIOS = false;
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
}

var Popover = { render: function render() {
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: {
display: _vm.isOpen ? '' : 'none'
Expand Down Expand Up @@ -3987,11 +4025,19 @@ var Popover = { render: function render() {
},
$_addGlobalEvents: function $_addGlobalEvents() {
if (this.autoHide) {
window.addEventListener('click', this.$_handleWindowClick);
if (isIOS) {
document.addEventListener('touchstart', this.$_handleWindowClick);
} else {
window.addEventListener('click', this.$_handleWindowClick);
}
}
},
$_removeGlobalEvents: function $_removeGlobalEvents() {
window.removeEventListener('click', this.$_handleWindowClick);
if (isIOS) {
document.removeEventListener('touchstart', this.$_handleWindowClick);
} else {
window.removeEventListener('click', this.$_handleWindowClick);
}
},
$_updatePopper: function $_updatePopper(cb) {
if (this.isOpen && this.popperInstance) {
Expand Down
2 changes: 1 addition & 1 deletion dist/v-tooltip.min.js

Large diffs are not rendered by default.

80 changes: 63 additions & 17 deletions dist/v-tooltip.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,8 @@ var DEFAULT_OPTIONS = {
offset: 0
};

var openTooltips = [];

var Tooltip = function () {
/**
* Create a new Tooltip.js instance
Expand Down Expand Up @@ -2834,6 +2836,7 @@ var Tooltip = function () {
return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
}) : [];
this._isDisposed = false;
this._enableDocumentTouch = events.indexOf('manual') === -1;

// set event listeners
this._setEventListeners(this.reference, events, this.options);
Expand Down Expand Up @@ -2926,6 +2929,8 @@ var Tooltip = function () {
}
this._isOpen = true;

openTooltips.push(this);

// if the tooltipNode already exists, just show it
if (this._tooltipNode) {
this._tooltipNode.style.display = '';
Expand Down Expand Up @@ -2994,6 +2999,14 @@ var Tooltip = function () {

return this;
}
}, {
key: '_noLongerOpen',
value: function _noLongerOpen() {
var index = openTooltips.indexOf(this);
if (index !== -1) {
openTooltips.splice(index, 1);
}
}
}, {
key: '_hide',
value: function _hide() /* reference, options */{
Expand All @@ -3005,6 +3018,7 @@ var Tooltip = function () {
}

this._isOpen = false;
this._noLongerOpen();

// hide tooltipNode
this._tooltipNode.style.display = 'none';
Expand Down Expand Up @@ -3058,6 +3072,8 @@ var Tooltip = function () {
this._tooltipNode.parentNode.removeChild(this._tooltipNode);
this._tooltipNode = null;
}
} else {
this._noLongerOpen();
}
return this;
}
Expand Down Expand Up @@ -3137,6 +3153,13 @@ var Tooltip = function () {
reference.addEventListener(event, func);
});
}
}, {
key: '_onDocumentTouch',
value: function _onDocumentTouch(event) {
if (this._enableDocumentTouch) {
this._scheduleHide(this.reference, this.options.delay, this.options, event);
}
}
}, {
key: '_scheduleShow',
value: function _scheduleShow(reference, delay, options /*, evt */) {
Expand Down Expand Up @@ -3184,21 +3207,7 @@ var Tooltip = function () {
return Tooltip;
}();

/**
* Placement function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback PlacementFunction
* @param {HTMLElement} tooltip - tooltip DOM node.
* @param {HTMLElement} reference - reference DOM node.
* @return {String} placement - One of the allowed placement options.
*/

/**
* Title function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback TitleFunction
* @return {String} placement - The desired title.
*/
// Hide tooltips on touch devices


var _initialiseProps = function _initialiseProps() {
Expand Down Expand Up @@ -3254,6 +3263,30 @@ var _initialiseProps = function _initialiseProps() {
};
};

if (typeof document !== 'undefined') {
document.addEventListener('touchstart', function (event) {
for (var i = 0; i < openTooltips.length; i++) {
openTooltips[i]._onDocumentTouch(event);
}
});
}

/**
* Placement function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback PlacementFunction
* @param {HTMLElement} tooltip - tooltip DOM node.
* @param {HTMLElement} reference - reference DOM node.
* @return {String} placement - One of the allowed placement options.
*/

/**
* Title function, its context is the Tooltip instance.
* @memberof Tooltip
* @callback TitleFunction
* @return {String} placement - The desired title.
*/

var state = {
enabled: true
};
Expand Down Expand Up @@ -3538,6 +3571,11 @@ function getDefault(key) {
return value;
}

var isIOS = false;
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
}

var Popover = { render: function render() {
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: {
display: _vm.isOpen ? '' : 'none'
Expand Down Expand Up @@ -3993,11 +4031,19 @@ var Popover = { render: function render() {
},
$_addGlobalEvents: function $_addGlobalEvents() {
if (this.autoHide) {
window.addEventListener('click', this.$_handleWindowClick);
if (isIOS) {
document.addEventListener('touchstart', this.$_handleWindowClick);
} else {
window.addEventListener('click', this.$_handleWindowClick);
}
}
},
$_removeGlobalEvents: function $_removeGlobalEvents() {
window.removeEventListener('click', this.$_handleWindowClick);
if (isIOS) {
document.removeEventListener('touchstart', this.$_handleWindowClick);
} else {
window.removeEventListener('click', this.$_handleWindowClick);
}
},
$_updatePopper: function $_updatePopper(cb) {
if (this.isOpen && this.popperInstance) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v-tooltip",
"version": "2.0.0-rc.20",
"version": "2.0.0-rc.21",
"description": "Easy tooltips with Vue 2.x",
"main": "dist/v-tooltip.umd.js",
"module": "dist/v-tooltip.esm.js",
Expand Down

0 comments on commit c5d2d4d

Please sign in to comment.