Skip to content

Commit

Permalink
New release
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jan 12, 2018
1 parent 28287e0 commit 12af347
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 278 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -116,10 +116,9 @@ Vue.component('v-popover', VPopover)

## Browser

Include [popper.js](https://popper.js.org/) with [v-tooltip](/dist/v-tooltip.min.js) in the page.
Include [v-tooltip](/dist/v-tooltip.min.js) in the page.

```html
<script src="https://unpkg.com/popper.js"></script>
<script src="https://unpkg.com/v-tooltip"></script>
```

Expand Down Expand Up @@ -229,6 +228,7 @@ Or a reactive property:
- `template` - HTML template of the tooltip.
- `arrowSelector` - CSS selector to get the arrow element in the tooltip template.
- `innerSelector` - CSS selector to get the inner content element in the tooltip template.
- `autoHide` - Boolean: automatically close the tooltip on mouseover.
- `popperOptions` - Other Popper.js options.

You can change the default values in the [Global options](#global-options).
Expand Down
168 changes: 31 additions & 137 deletions dist/v-tooltip.esm.js
@@ -1,6 +1,6 @@
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.12.6
* @version 1.12.9
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
Expand All @@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
var timeoutDuration = 0;
for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
Expand All @@ -39,7 +39,7 @@ function microtaskDebounce(fn) {
return;
}
called = true;
Promise.resolve().then(function () {
window.Promise.resolve().then(function () {
called = false;
fn();
});
Expand Down Expand Up @@ -96,7 +96,7 @@ function getStyleComputedProperty(element, property) {
return [];
}
// NOTE: 1 DOM access here
var css = window.getComputedStyle(element, null);
var css = getComputedStyle(element, null);
return property ? css[property] : css;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ function getParentNode(element) {
function getScrollParent(element) {
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
if (!element) {
return window.document.body;
return document.body;
}

switch (element.nodeName) {
Expand Down Expand Up @@ -166,7 +166,7 @@ function getOffsetParent(element) {
return element.ownerDocument.documentElement;
}

return window.document.documentElement;
return document.documentElement;
}

// .offsetParent will return the closest TD or TABLE in case
Expand Down Expand Up @@ -213,7 +213,7 @@ function getRoot(node) {
function findCommonOffsetParent(element1, element2) {
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
return window.document.documentElement;
return document.documentElement;
}

// Here we make sure to give as "start" the element that comes first in the DOM
Expand Down Expand Up @@ -305,7 +305,7 @@ function getBordersSize(styles, axis) {
var sideA = axis === 'x' ? 'Left' : 'Top';
var sideB = sideA === 'Left' ? 'Right' : 'Bottom';

return +styles['border' + sideA + 'Width'].split('px')[0] + +styles['border' + sideB + 'Width'].split('px')[0];
return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
}

/**
Expand All @@ -328,9 +328,9 @@ function getSize(axis, body, html, computedStyle) {
}

function getWindowSizes() {
var body = window.document.body;
var html = window.document.documentElement;
var computedStyle = isIE10$1() && window.getComputedStyle(html);
var body = document.body;
var html = document.documentElement;
var computedStyle = isIE10$1() && getComputedStyle(html);

return {
height: getSize('Height', body, html, computedStyle),
Expand Down Expand Up @@ -473,8 +473,8 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
var scrollParent = getScrollParent(children);

var styles = getStyleComputedProperty(parent);
var borderTopWidth = +styles.borderTopWidth.split('px')[0];
var borderLeftWidth = +styles.borderLeftWidth.split('px')[0];
var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);

var offsets = getClientRect({
top: childrenRect.top - parentRect.top - borderTopWidth,
Expand All @@ -490,8 +490,8 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
// differently when margins are applied to it. The margins are included in
// the box of the documentElement, in the other cases not.
if (!isIE10 && isHTML) {
var marginTop = +styles.marginTop.split('px')[0];
var marginLeft = +styles.marginLeft.split('px')[0];
var marginTop = parseFloat(styles.marginTop, 10);
var marginLeft = parseFloat(styles.marginLeft, 10);

offsets.top -= borderTopWidth - marginTop;
offsets.bottom -= borderTopWidth - marginTop;
Expand Down Expand Up @@ -570,7 +570,7 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
// Handle other cases based on DOM element used as boundaries
var boundariesNode = void 0;
if (boundariesElement === 'scrollParent') {
boundariesNode = getScrollParent(getParentNode(popper));
boundariesNode = getScrollParent(getParentNode(reference));
if (boundariesNode.nodeName === 'BODY') {
boundariesNode = popper.ownerDocument.documentElement;
}
Expand Down Expand Up @@ -696,7 +696,7 @@ function getReferenceOffsets(state, popper, reference) {
* @returns {Object} object containing width and height properties
*/
function getOuterSizes(element) {
var styles = window.getComputedStyle(element);
var styles = getComputedStyle(element);
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
var result = {
Expand Down Expand Up @@ -913,7 +913,7 @@ function getSupportedPropertyName(property) {
for (var i = 0; i < prefixes.length - 1; i++) {
var prefix = prefixes[i];
var toCheck = prefix ? '' + prefix + upperProp : property;
if (typeof window.document.body.style[toCheck] !== 'undefined') {
if (typeof document.body.style[toCheck] !== 'undefined') {
return toCheck;
}
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ function removeEventListeners(reference, state) {
*/
function disableEventListeners() {
if (this.state.eventsEnabled) {
window.cancelAnimationFrame(this.scheduleUpdate);
cancelAnimationFrame(this.scheduleUpdate);
this.state = removeEventListeners(this.reference, this.state);
}
}
Expand Down Expand Up @@ -1272,6 +1272,8 @@ function isModifierRequired(modifiers, requestingName, requestedName) {
* @returns {Object} The data object, properly modified
*/
function arrow(data, options) {
var _data$offsets$arrow;

// arrow depends on keepTogether in order to work
if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
return data;
Expand Down Expand Up @@ -1323,22 +1325,23 @@ function arrow(data, options) {
if (reference[side] + arrowElementSize > popper[opSide]) {
data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
}
data.offsets.popper = getClientRect(data.offsets.popper);

// compute center of the popper
var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;

// Compute the sideValue using the updated popper offsets
// take popper margin in account because we don't have this info available
var popperMarginSide = getStyleComputedProperty(data.instance.popper, 'margin' + sideCapitalized).replace('px', '');
var sideValue = center - getClientRect(data.offsets.popper)[side] - popperMarginSide;
var css = getStyleComputedProperty(data.instance.popper);
var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;

// prevent arrowElement from being placed not contiguously to its popper
sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);

data.arrowElement = arrowElement;
data.offsets.arrow = {};
data.offsets.arrow[side] = Math.round(sideValue);
data.offsets.arrow[altSide] = ''; // make sure to unset any eventual altSide value from the DOM node
data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);

return data;
}
Expand Down Expand Up @@ -2516,118 +2519,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol



var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}

function AsyncGenerator(gen) {
var front, back;

function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};

if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}

function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;

if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
}

function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;

case "throw":
front.reject(value);
break;

default:
front.resolve({
value: value,
done: false
});
break;
}

front = front.next;

if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}

this._invoke = send;

if (typeof gen.return !== "function") {
this.return = undefined;
}
}

if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}

AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};

AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};

AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};

return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();



Expand Down Expand Up @@ -2904,7 +2796,7 @@ var Tooltip = function () {
allowHtml ? titleNode.innerHTML = title : titleNode.innerText = title;
}

if (directive.options.autoHide && this.options.trigger.indexOf('hover') !== -1) {
if (this.options.autoHide && this.options.trigger.indexOf('hover') !== -1) {
tooltipNode.addEventListener('mouseenter', this.hide);
tooltipNode.addEventListener('click', this.hide);
}
Expand Down Expand Up @@ -3380,6 +3272,7 @@ function getOptions(options) {
offset: typeof options.offset !== 'undefined' ? options.offset : directive.options.defaultOffset,
container: typeof options.container !== 'undefined' ? options.container : directive.options.defaultContainer,
boundariesElement: typeof options.boundariesElement !== 'undefined' ? options.boundariesElement : directive.options.defaultBoundariesElement,
autoHide: typeof options.autoHide !== 'undefined' ? options.autoHide : directive.options.autoHide,
popperOptions: _extends$1({}, typeof options.popperOptions !== 'undefined' ? options.popperOptions : directive.options.defaultPopperOptions)
};

Expand Down Expand Up @@ -3915,7 +3808,8 @@ var Popover = { render: function render() {
},
hide: function hide() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
event = _ref2.event;
event = _ref2.event,
_ref2$skipDelay = _ref2.skipDelay;

this.$_scheduleHide(event);

Expand Down
2 changes: 1 addition & 1 deletion dist/v-tooltip.min.js

Large diffs are not rendered by default.

0 comments on commit 12af347

Please sign in to comment.