Skip to content

Commit

Permalink
chore: v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Apr 11, 2019
1 parent d8412fb commit 4a02b0f
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 30 deletions.
84 changes: 70 additions & 14 deletions dist/v-tooltip.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function addClasses(el, classes) {
}
});

if (el instanceof SVGElement) {
if (el.prototype && el instanceof SVGElement) {
el.setAttribute('class', classList.join(' '));
} else {
el.className = classList.join(' ');
Expand Down Expand Up @@ -141,7 +141,7 @@ function removeClasses(el, classes) {
}
});

if (el instanceof SVGElement) {
if (el.prototype && el instanceof SVGElement) {
el.setAttribute('class', classList.join(' '));
} else {
el.className = classList.join(' ');
Expand Down Expand Up @@ -244,7 +244,9 @@ function () {

// apply user options over default ones
_options = _objectSpread({}, DEFAULT_OPTIONS, _options);
_reference.jquery && (_reference = _reference[0]); // cache reference and options
_reference.jquery && (_reference = _reference[0]);
this.show = this.show.bind(this);
this.hide = this.hide.bind(this); // cache reference and options

this.reference = _reference;
this.options = _options; // set initial state
Expand Down Expand Up @@ -375,7 +377,12 @@ function () {
this._isDisposed = false;
this._enableDocumentTouch = events.indexOf('manual') === -1; // set event listeners

this._setEventListeners(this.reference, events, this.options);
this._setEventListeners(this.reference, events, this.options); // title attribute


this.$_originalTitle = this.reference.getAttribute('title');
this.reference.removeAttribute('title');
this.reference.setAttribute('data-original-title', this.$_originalTitle);
}
/**
* Creates a new tooltip node
Expand Down Expand Up @@ -624,22 +631,39 @@ function () {
_this5._tooltipNode.removeEventListener('click', _this5.hide); // Don't remove popper instance, just the HTML element


_this5._tooltipNode.parentNode.removeChild(_this5._tooltipNode);

_this5._tooltipNode = null;
_this5._removeTooltipNode();
}
}, disposeTime);
}

removeClasses(this.reference, ['v-tooltip-open']);
return this;
}
}, {
key: "_removeTooltipNode",
value: function _removeTooltipNode() {
if (!this._tooltipNode) return;
var parentNode = this._tooltipNode.parentNode;

if (parentNode) {
parentNode.removeChild(this._tooltipNode);
this.reference.removeAttribute('aria-describedby');
}

this._tooltipNode = null;
}
}, {
key: "_dispose",
value: function _dispose() {
var _this6 = this;

this._isDisposed = true; // remove event listeners first to prevent any unexpected behaviour
this._isDisposed = true;
this.reference.removeAttribute('data-original-title');

if (this.$_originalTitle) {
this.reference.setAttribute('title', this.$_originalTitle);
} // remove event listeners first to prevent any unexpected behaviour


this._events.forEach(function (_ref) {
var func = _ref.func,
Expand All @@ -661,9 +685,7 @@ function () {
this.popperInstance.destroy(); // destroy tooltipNode if removeOnDestroy is not set, as popperInstance.destroy() already removes the element

if (!this.popperInstance.options.removeOnDestroy) {
this._tooltipNode.parentNode.removeChild(this._tooltipNode);

this._tooltipNode = null;
this._removeTooltipNode();
}
} else {
this._noLongerOpen();
Expand Down Expand Up @@ -1335,6 +1357,9 @@ var script = {
this.show();
}
},
deactivated: function deactivated() {
this.hide();
},
beforeDestroy: function beforeDestroy() {
this.dispose();
},
Expand Down Expand Up @@ -1451,11 +1476,27 @@ var script = {
this.popperInstance = new Popper(reference, popoverNode, popperOptions); // Fix position

requestAnimationFrame(function () {
if (_this3.hidden) {
_this3.hidden = false;

_this3.$_hide();

return;
}

if (!_this3.$_isDisposed && _this3.popperInstance) {
_this3.popperInstance.scheduleUpdate(); // Show the tooltip


requestAnimationFrame(function () {
if (_this3.hidden) {
_this3.hidden = false;

_this3.$_hide();

return;
}

if (!_this3.$_isDisposed) {
_this3.isOpen = true;
} else {
Expand Down Expand Up @@ -1583,6 +1624,7 @@ var script = {
!_this5.$_preventOpen && _this5.show({
event: event
});
_this5.hidden = false;
};

_this5.$_events.push({
Expand All @@ -1602,6 +1644,8 @@ var script = {
_this5.hide({
event: event
});

_this5.hidden = true;
};

_this5.$_events.push({
Expand Down Expand Up @@ -1880,14 +1924,14 @@ var __vue_render__ = function() {
var _c = _vm._self._c || _h;
return _c("div", { staticClass: "v-popover", class: _vm.cssClass }, [
_c(
"span",
"div",
{
ref: "trigger",
staticClass: "trigger",
staticStyle: { display: "inline-block" },
attrs: {
"aria-describedby": _vm.popoverId,
tabindex: _vm.trigger.indexOf("focus") !== -1 ? 0 : -1
tabindex: _vm.trigger.indexOf("focus") !== -1 ? 0 : undefined
}
},
[_vm._t("default")],
Expand All @@ -1904,7 +1948,19 @@ var __vue_render__ = function() {
},
attrs: {
id: _vm.popoverId,
"aria-hidden": _vm.isOpen ? "false" : "true"
"aria-hidden": _vm.isOpen ? "false" : "true",
tabindex: _vm.autoHide ? 0 : undefined
},
on: {
keyup: function($event) {
if (
!$event.type.indexOf("key") &&
_vm._k($event.keyCode, "esc", 27, $event.key, ["Esc", "Escape"])
) {
return null
}
_vm.autoHide && _vm.hide();
}
}
},
[
Expand Down
2 changes: 1 addition & 1 deletion dist/v-tooltip.min.js

Large diffs are not rendered by default.

84 changes: 70 additions & 14 deletions dist/v-tooltip.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@
}
});

if (el instanceof SVGElement) {
if (el.prototype && el instanceof SVGElement) {
el.setAttribute('class', classList.join(' '));
} else {
el.className = classList.join(' ');
Expand Down Expand Up @@ -2745,7 +2745,7 @@
}
});

if (el instanceof SVGElement) {
if (el.prototype && el instanceof SVGElement) {
el.setAttribute('class', classList.join(' '));
} else {
el.className = classList.join(' ');
Expand Down Expand Up @@ -2848,7 +2848,9 @@

// apply user options over default ones
_options = _objectSpread({}, DEFAULT_OPTIONS, _options);
_reference.jquery && (_reference = _reference[0]); // cache reference and options
_reference.jquery && (_reference = _reference[0]);
this.show = this.show.bind(this);
this.hide = this.hide.bind(this); // cache reference and options

this.reference = _reference;
this.options = _options; // set initial state
Expand Down Expand Up @@ -2979,7 +2981,12 @@
this._isDisposed = false;
this._enableDocumentTouch = events.indexOf('manual') === -1; // set event listeners

this._setEventListeners(this.reference, events, this.options);
this._setEventListeners(this.reference, events, this.options); // title attribute


this.$_originalTitle = this.reference.getAttribute('title');
this.reference.removeAttribute('title');
this.reference.setAttribute('data-original-title', this.$_originalTitle);
}
/**
* Creates a new tooltip node
Expand Down Expand Up @@ -3228,22 +3235,39 @@
_this5._tooltipNode.removeEventListener('click', _this5.hide); // Don't remove popper instance, just the HTML element


_this5._tooltipNode.parentNode.removeChild(_this5._tooltipNode);

_this5._tooltipNode = null;
_this5._removeTooltipNode();
}
}, disposeTime);
}

removeClasses(this.reference, ['v-tooltip-open']);
return this;
}
}, {
key: "_removeTooltipNode",
value: function _removeTooltipNode() {
if (!this._tooltipNode) return;
var parentNode = this._tooltipNode.parentNode;

if (parentNode) {
parentNode.removeChild(this._tooltipNode);
this.reference.removeAttribute('aria-describedby');
}

this._tooltipNode = null;
}
}, {
key: "_dispose",
value: function _dispose() {
var _this6 = this;

this._isDisposed = true; // remove event listeners first to prevent any unexpected behaviour
this._isDisposed = true;
this.reference.removeAttribute('data-original-title');

if (this.$_originalTitle) {
this.reference.setAttribute('title', this.$_originalTitle);
} // remove event listeners first to prevent any unexpected behaviour


this._events.forEach(function (_ref) {
var func = _ref.func,
Expand All @@ -3265,9 +3289,7 @@
this.popperInstance.destroy(); // destroy tooltipNode if removeOnDestroy is not set, as popperInstance.destroy() already removes the element

if (!this.popperInstance.options.removeOnDestroy) {
this._tooltipNode.parentNode.removeChild(this._tooltipNode);

this._tooltipNode = null;
this._removeTooltipNode();
}
} else {
this._noLongerOpen();
Expand Down Expand Up @@ -4052,6 +4074,9 @@
this.show();
}
},
deactivated: function deactivated() {
this.hide();
},
beforeDestroy: function beforeDestroy() {
this.dispose();
},
Expand Down Expand Up @@ -4168,11 +4193,27 @@
this.popperInstance = new Popper(reference, popoverNode, popperOptions); // Fix position

requestAnimationFrame(function () {
if (_this3.hidden) {
_this3.hidden = false;

_this3.$_hide();

return;
}

if (!_this3.$_isDisposed && _this3.popperInstance) {
_this3.popperInstance.scheduleUpdate(); // Show the tooltip


requestAnimationFrame(function () {
if (_this3.hidden) {
_this3.hidden = false;

_this3.$_hide();

return;
}

if (!_this3.$_isDisposed) {
_this3.isOpen = true;
} else {
Expand Down Expand Up @@ -4300,6 +4341,7 @@
!_this5.$_preventOpen && _this5.show({
event: event
});
_this5.hidden = false;
};

_this5.$_events.push({
Expand All @@ -4319,6 +4361,8 @@
_this5.hide({
event: event
});

_this5.hidden = true;
};

_this5.$_events.push({
Expand Down Expand Up @@ -4597,14 +4641,14 @@
var _c = _vm._self._c || _h;
return _c("div", { staticClass: "v-popover", class: _vm.cssClass }, [
_c(
"span",
"div",
{
ref: "trigger",
staticClass: "trigger",
staticStyle: { display: "inline-block" },
attrs: {
"aria-describedby": _vm.popoverId,
tabindex: _vm.trigger.indexOf("focus") !== -1 ? 0 : -1
tabindex: _vm.trigger.indexOf("focus") !== -1 ? 0 : undefined
}
},
[_vm._t("default")],
Expand All @@ -4621,7 +4665,19 @@
},
attrs: {
id: _vm.popoverId,
"aria-hidden": _vm.isOpen ? "false" : "true"
"aria-hidden": _vm.isOpen ? "false" : "true",
tabindex: _vm.autoHide ? 0 : undefined
},
on: {
keyup: function($event) {
if (
!$event.type.indexOf("key") &&
_vm._k($event.keyCode, "esc", 27, $event.key, ["Esc", "Escape"])
) {
return null
}
_vm.autoHide && _vm.hide();
}
}
},
[
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.33",
"version": "2.0.0",
"description": "Easy tooltips with Vue 2.x",
"author": "Guillaume Chau <[email protected]>",
"scripts": {
Expand Down

0 comments on commit 4a02b0f

Please sign in to comment.