From: kball Date: Wed, 24 Jul 2019 22:50:03 +0000 (-0700) Subject: Merge branch 'fix-tooltips-svg' of https://github.com/ASethi77/foundation-sites into... X-Git-Tag: v6.6.0~3^2~23^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57cffd0e0d07345c28dca39d912e1ea7f9dfa923;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Merge branch 'fix-tooltips-svg' of https://github.com/ASethi77/foundation-sites into ASethi77-fix-tooltips-svg --- 57cffd0e0d07345c28dca39d912e1ea7f9dfa923 diff --cc js/foundation.tooltip.js index 8abdd8818,99cf1c26c..1d12ab391 --- a/js/foundation.tooltip.js +++ b/js/foundation.tooltip.js @@@ -71,32 -66,22 +71,38 @@@ class Tooltip extends Positionable this._events(); } - /** - * Grabs the current positioning class, if present, and returns the value or an empty string. - * @private - */ - _getPositionClass(element) { - if (!element) { return ''; } - - var elementClassName = element[0].className; - if (element[0] instanceof SVGElement) { + _getDefaultPosition() { + // handle legacy classnames + var position = this.$element[0].className.match(/\b(top|left|right|bottom)\b/g); ++ var elementClassName = this.$element[0].className; ++ if (this.$element[0] instanceof SVGElement) { + elementClassName = elementClassName.baseVal; + } - + return position ? position[0] : 'top'; + var position = elementClassName.match(/\b(top|left|right)\b/g); - position = position ? position[0] : ''; - return position; - }; ++ position = position ? position[0] : 'tp'; + } + + _getDefaultAlignment() { + return 'center'; + } + + _getHOffset() { + if(this.position === 'left' || this.position === 'right') { + return this.options.hOffset + this.options.tooltipWidth; + } else { + return this.options.hOffset + } + } + + _getVOffset() { + if(this.position === 'top' || this.position === 'bottom') { + return this.options.vOffset + this.options.tooltipHeight; + } else { + return this.options.vOffset + } + } + /** * builds the tooltip element, adds attributes, and returns the template. * @private