]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Merge branch 'fix-tooltips-svg' of https://github.com/ASethi77/foundation-sites into...
authorkball <kball@zendev.com>
Wed, 24 Jul 2019 22:50:03 +0000 (15:50 -0700)
committerkball <kball@zendev.com>
Wed, 24 Jul 2019 22:50:03 +0000 (15:50 -0700)
1  2 
js/foundation.tooltip.js

index 8abdd881870b7b0f571111a33aaa596e0b23c6ae,99cf1c26c8fae321a27d7afa70fa75ee32fd22d6..1d12ab391d19c07deabccd05a3d85dfb981dbc8b
@@@ -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