foundation-sites
Version:
The most advanced responsive front-end framework in the world.
1,136 lines (1,068 loc) • 52.1 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("./foundation.core"), require("jquery"), require("./foundation.util.mediaQuery"), require("./foundation.util.motion"), require("./foundation.util.box"));
else if(typeof define === 'function' && define.amd)
define(["./foundation.core", "jquery", "./foundation.util.mediaQuery", "./foundation.util.motion", "./foundation.util.box"], factory);
else if(typeof exports === 'object')
exports["__FOUNDATION_EXTERNAL__"] = factory(require("./foundation.core"), require("jquery"), require("./foundation.util.mediaQuery"), require("./foundation.util.motion"), require("./foundation.util.box"));
else
root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.tooltip"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["jQuery"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.mediaQuery"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.box"]);
})(self, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE_jquery__, __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __WEBPACK_EXTERNAL_MODULE__foundation_util_box__) {
return /******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./js/foundation.positionable.js":
/*!***************************************!*\
!*** ./js/foundation.positionable.js ***!
\***************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Positionable: function() { return /* binding */ Positionable; }
/* harmony export */ });
/* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.util.box */ "./foundation.util.box");
/* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__);
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var POSITIONS = ['left', 'right', 'top', 'bottom'];
var VERTICAL_ALIGNMENTS = ['top', 'bottom', 'center'];
var HORIZONTAL_ALIGNMENTS = ['left', 'right', 'center'];
var ALIGNMENTS = {
'left': VERTICAL_ALIGNMENTS,
'right': VERTICAL_ALIGNMENTS,
'top': HORIZONTAL_ALIGNMENTS,
'bottom': HORIZONTAL_ALIGNMENTS
};
function nextItem(item, array) {
var currentIdx = array.indexOf(item);
if (currentIdx === array.length - 1) {
return array[0];
} else {
return array[currentIdx + 1];
}
}
var Positionable = /*#__PURE__*/function (_Plugin) {
function Positionable() {
_classCallCheck(this, Positionable);
return _callSuper(this, Positionable, arguments);
}
_inherits(Positionable, _Plugin);
return _createClass(Positionable, [{
key: "_init",
value:
/**
* Abstract class encapsulating the tether-like explicit positioning logic
* including repositioning based on overlap.
* Expects classes to define defaults for vOffset, hOffset, position,
* alignment, allowOverlap, and allowBottomOverlap. They can do this by
* extending the defaults, or (for now recommended due to the way docs are
* generated) by explicitly declaring them.
*
**/
function _init() {
this.triedPositions = {};
this.position = this.options.position === 'auto' ? this._getDefaultPosition() : this.options.position;
this.alignment = this.options.alignment === 'auto' ? this._getDefaultAlignment() : this.options.alignment;
this.originalPosition = this.position;
this.originalAlignment = this.alignment;
}
}, {
key: "_getDefaultPosition",
value: function _getDefaultPosition() {
return 'bottom';
}
}, {
key: "_getDefaultAlignment",
value: function _getDefaultAlignment() {
switch (this.position) {
case 'bottom':
case 'top':
return (0,_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__.rtl)() ? 'right' : 'left';
case 'left':
case 'right':
return 'bottom';
}
}
/**
* Adjusts the positionable possible positions by iterating through alignments
* and positions.
* @function
* @private
*/
}, {
key: "_reposition",
value: function _reposition() {
if (this._alignmentsExhausted(this.position)) {
this.position = nextItem(this.position, POSITIONS);
this.alignment = ALIGNMENTS[this.position][0];
} else {
this._realign();
}
}
/**
* Adjusts the dropdown pane possible positions by iterating through alignments
* on the current position.
* @function
* @private
*/
}, {
key: "_realign",
value: function _realign() {
this._addTriedPosition(this.position, this.alignment);
this.alignment = nextItem(this.alignment, ALIGNMENTS[this.position]);
}
}, {
key: "_addTriedPosition",
value: function _addTriedPosition(position, alignment) {
this.triedPositions[position] = this.triedPositions[position] || [];
this.triedPositions[position].push(alignment);
}
}, {
key: "_positionsExhausted",
value: function _positionsExhausted() {
var isExhausted = true;
for (var i = 0; i < POSITIONS.length; i++) {
isExhausted = isExhausted && this._alignmentsExhausted(POSITIONS[i]);
}
return isExhausted;
}
}, {
key: "_alignmentsExhausted",
value: function _alignmentsExhausted(position) {
return this.triedPositions[position] && this.triedPositions[position].length === ALIGNMENTS[position].length;
}
// When we're trying to center, we don't want to apply offset that's going to
// take us just off center, so wrap around to return 0 for the appropriate
// offset in those alignments. TODO: Figure out if we want to make this
// configurable behavior... it feels more intuitive, especially for tooltips, but
// it's possible someone might actually want to start from center and then nudge
// slightly off.
}, {
key: "_getVOffset",
value: function _getVOffset() {
return this.options.vOffset;
}
}, {
key: "_getHOffset",
value: function _getHOffset() {
return this.options.hOffset;
}
}, {
key: "_setPosition",
value: function _setPosition($anchor, $element, $parent) {
if ($anchor.attr('aria-expanded') === 'false') {
return false;
}
if (!this.options.allowOverlap) {
// restore original position & alignment before checking overlap
this.position = this.originalPosition;
this.alignment = this.originalAlignment;
}
$element.offset(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__.Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
if (!this.options.allowOverlap) {
var minOverlap = 100000000;
// default coordinates to how we start, in case we can't figure out better
var minCoordinates = {
position: this.position,
alignment: this.alignment
};
while (!this._positionsExhausted()) {
var overlap = _foundation_util_box__WEBPACK_IMPORTED_MODULE_0__.Box.OverlapArea($element, $parent, false, false, this.options.allowBottomOverlap);
if (overlap === 0) {
return;
}
if (overlap < minOverlap) {
minOverlap = overlap;
minCoordinates = {
position: this.position,
alignment: this.alignment
};
}
this._reposition();
$element.offset(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__.Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
}
// If we get through the entire loop, there was no non-overlapping
// position available. Pick the version with least overlap.
this.position = minCoordinates.position;
this.alignment = minCoordinates.alignment;
$element.offset(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__.Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
}
}
}]);
}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__.Plugin);
Positionable.defaults = {
/**
* Position of positionable relative to anchor. Can be left, right, bottom, top, or auto.
* @option
* @type {string}
* @default 'auto'
*/
position: 'auto',
/**
* Alignment of positionable relative to anchor. Can be left, right, bottom, top, center, or auto.
* @option
* @type {string}
* @default 'auto'
*/
alignment: 'auto',
/**
* Allow overlap of container/window. If false, dropdown positionable first
* try to position as defined by data-position and data-alignment, but
* reposition if it would cause an overflow.
* @option
* @type {boolean}
* @default false
*/
allowOverlap: false,
/**
* Allow overlap of only the bottom of the container. This is the most common
* behavior for dropdowns, allowing the dropdown to extend the bottom of the
* screen but not otherwise influence or break out of the container.
* @option
* @type {boolean}
* @default true
*/
allowBottomOverlap: true,
/**
* Number of pixels the positionable should be separated vertically from anchor
* @option
* @type {number}
* @default 0
*/
vOffset: 0,
/**
* Number of pixels the positionable should be separated horizontally from anchor
* @option
* @type {number}
* @default 0
*/
hOffset: 0
};
/***/ }),
/***/ "./js/foundation.tooltip.js":
/*!**********************************!*\
!*** ./js/foundation.tooltip.js ***!
\**********************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Tooltip: function() { return /* binding */ Tooltip; }
/* harmony export */ });
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.mediaQuery */ "./foundation.util.mediaQuery");
/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js");
/* harmony import */ var _foundation_positionable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.positionable */ "./js/foundation.positionable.js");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _superPropGet(t, e, o, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), e, o); return 2 & r && "function" == typeof p ? function (t) { return p.apply(o, t); } : p; }
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
/**
* Tooltip module.
* @module foundation.tooltip
* @requires foundation.util.box
* @requires foundation.util.mediaQuery
* @requires foundation.util.triggers
*/
var Tooltip = /*#__PURE__*/function (_Positionable) {
function Tooltip() {
_classCallCheck(this, Tooltip);
return _callSuper(this, Tooltip, arguments);
}
_inherits(Tooltip, _Positionable);
return _createClass(Tooltip, [{
key: "_setup",
value:
/**
* Creates a new instance of a Tooltip.
* @class
* @name Tooltip
* @fires Tooltip#init
* @param {jQuery} element - jQuery object to attach a tooltip to.
* @param {Object} options - object to extend the default configuration.
*/
function _setup(element, options) {
this.$element = element;
this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default().extend({}, Tooltip.defaults, this.$element.data(), options);
this.className = 'Tooltip'; // ie9 back compat
this.isActive = false;
this.isClick = false;
// Triggers init is idempotent, just need to make sure it is initialized
_foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__.Triggers.init((jquery__WEBPACK_IMPORTED_MODULE_0___default()));
this._init();
}
/**
* Initializes the tooltip by setting the creating the tip element, adding it's text, setting private variables and setting attributes on the anchor.
* @private
*/
}, {
key: "_init",
value: function _init() {
_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_2__.MediaQuery._init();
var elemId = this.$element.attr('aria-describedby') || (0,_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__.GetYoDigits)(6, 'tooltip');
this.options.tipText = this.options.tipText || this.$element.attr('title');
this.template = this.options.template ? jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.options.template) : this._buildTemplate(elemId);
if (this.options.allowHtml) {
this.template.appendTo(document.body).html(this.options.tipText).hide();
} else {
this.template.appendTo(document.body).text(this.options.tipText).hide();
}
this.$element.attr({
'title': '',
'aria-describedby': elemId,
'data-yeti-box': elemId,
'data-toggle': elemId,
'data-resize': elemId
}).addClass(this.options.triggerClass);
_superPropGet(Tooltip, "_init", this, 3)([]);
this._events();
}
}, {
key: "_getDefaultPosition",
value: function _getDefaultPosition() {
// handle legacy classnames
var elementClassName = this.$element[0].className;
if (this.$element[0] instanceof SVGElement) {
elementClassName = elementClassName.baseVal;
}
var position = elementClassName.match(/\b(top|left|right|bottom)\b/g);
return position ? position[0] : 'top';
}
}, {
key: "_getDefaultAlignment",
value: function _getDefaultAlignment() {
return 'center';
}
}, {
key: "_getHOffset",
value: function _getHOffset() {
if (this.position === 'left' || this.position === 'right') {
return this.options.hOffset + this.options.tooltipWidth;
} else {
return this.options.hOffset;
}
}
}, {
key: "_getVOffset",
value: function _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
*/
}, {
key: "_buildTemplate",
value: function _buildTemplate(id) {
var templateClasses = "".concat(this.options.tooltipClass, " ").concat(this.options.templateClasses).trim();
var $template = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<div></div>').addClass(templateClasses).attr({
'role': 'tooltip',
'aria-hidden': true,
'data-is-active': false,
'data-is-focus': false,
'id': id
});
return $template;
}
/**
* sets the position class of an element and recursively calls itself until there are no more possible positions to attempt, or the tooltip element is no longer colliding.
* if the tooltip is larger than the screen width, default to full width - any user selected margin
* @private
*/
}, {
key: "_setPosition",
value: function _setPosition() {
_superPropGet(Tooltip, "_setPosition", this, 3)([this.$element, this.template]);
}
/**
* reveals the tooltip, and fires an event to close any other open tooltips on the page
* @fires Tooltip#closeme
* @fires Tooltip#show
* @function
*/
}, {
key: "show",
value: function show() {
if (this.options.showOn !== 'all' && !_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_2__.MediaQuery.is(this.options.showOn)) {
// console.error('The screen is too small to display this tooltip');
return false;
}
var _this = this;
this.template.css('visibility', 'hidden').show();
this._setPosition();
this.template.removeClass('top bottom left right').addClass(this.position);
this.template.removeClass('align-top align-bottom align-left align-right align-center').addClass('align-' + this.alignment);
/**
* Fires to close all other open tooltips on the page
* @event Closeme#tooltip
*/
this.$element.trigger('closeme.zf.tooltip', this.template.attr('id'));
this.template.attr({
'data-is-active': true,
'aria-hidden': false
});
_this.isActive = true;
this.template.stop().hide().css('visibility', '').fadeIn(this.options.fadeInDuration, function () {
//maybe do stuff?
});
/**
* Fires when the tooltip is shown
* @event Tooltip#show
*/
this.$element.trigger('show.zf.tooltip');
}
/**
* Hides the current tooltip, and resets the positioning class if it was changed due to collision
* @fires Tooltip#hide
* @function
*/
}, {
key: "hide",
value: function hide() {
var _this = this;
this.template.stop().attr({
'aria-hidden': true,
'data-is-active': false
}).fadeOut(this.options.fadeOutDuration, function () {
_this.isActive = false;
_this.isClick = false;
});
/**
* fires when the tooltip is hidden
* @event Tooltip#hide
*/
this.$element.trigger('hide.zf.tooltip');
}
/**
* adds event listeners for the tooltip and its anchor
* TODO combine some of the listeners like focus and mouseenter, etc.
* @private
*/
}, {
key: "_events",
value: function _events() {
var _this = this;
var hasTouch = 'ontouchstart' in window || typeof window.ontouchstart !== 'undefined';
var isFocus = false;
// `disableForTouch: Fully disable the tooltip on touch devices
if (hasTouch && this.options.disableForTouch) return;
if (!this.options.disableHover) {
this.$element.on('mouseenter.zf.tooltip', function () {
if (!_this.isActive) {
_this.timeout = setTimeout(function () {
_this.show();
}, _this.options.hoverDelay);
}
}).on('mouseleave.zf.tooltip', (0,_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__.ignoreMousedisappear)(function () {
clearTimeout(_this.timeout);
if (!isFocus || _this.isClick && !_this.options.clickOpen) {
_this.hide();
}
}));
}
if (hasTouch) {
this.$element.on('tap.zf.tooltip touchend.zf.tooltip', function () {
_this.isActive ? _this.hide() : _this.show();
});
}
if (this.options.clickOpen) {
this.$element.on('mousedown.zf.tooltip', function () {
if (_this.isClick) {
//_this.hide();
// _this.isClick = false;
} else {
_this.isClick = true;
if ((_this.options.disableHover || !_this.$element.attr('tabindex')) && !_this.isActive) {
_this.show();
}
}
});
} else {
this.$element.on('mousedown.zf.tooltip', function () {
_this.isClick = true;
});
}
this.$element.on({
// 'toggle.zf.trigger': this.toggle.bind(this),
// 'close.zf.trigger': this.hide.bind(this)
'close.zf.trigger': this.hide.bind(this)
});
this.$element.on('focus.zf.tooltip', function () {
isFocus = true;
if (_this.isClick) {
// If we're not showing open on clicks, we need to pretend a click-launched focus isn't
// a real focus, otherwise on hover and come back we get bad behavior
if (!_this.options.clickOpen) {
isFocus = false;
}
return false;
} else {
_this.show();
}
}).on('focusout.zf.tooltip', function () {
isFocus = false;
_this.isClick = false;
_this.hide();
}).on('resizeme.zf.trigger', function () {
if (_this.isActive) {
_this._setPosition();
}
});
}
/**
* adds a toggle method, in addition to the static show() & hide() functions
* @function
*/
}, {
key: "toggle",
value: function toggle() {
if (this.isActive) {
this.hide();
} else {
this.show();
}
}
/**
* Destroys an instance of tooltip, removes template element from the view.
* @function
*/
}, {
key: "_destroy",
value: function _destroy() {
this.$element.attr('title', this.template.text()).off('.zf.trigger .zf.tooltip').removeClass(this.options.triggerClass).removeClass('top right left bottom').removeAttr('aria-describedby data-disable-hover data-resize data-toggle data-tooltip data-yeti-box');
this.template.remove();
}
}]);
}(_foundation_positionable__WEBPACK_IMPORTED_MODULE_4__.Positionable);
Tooltip.defaults = {
/**
* Time, in ms, before a tooltip should open on hover.
* @option
* @type {number}
* @default 200
*/
hoverDelay: 200,
/**
* Time, in ms, a tooltip should take to fade into view.
* @option
* @type {number}
* @default 150
*/
fadeInDuration: 150,
/**
* Time, in ms, a tooltip should take to fade out of view.
* @option
* @type {number}
* @default 150
*/
fadeOutDuration: 150,
/**
* Disables hover events from opening the tooltip if set to true
* @option
* @type {boolean}
* @default false
*/
disableHover: false,
/**
* Disable the tooltip for touch devices.
* This can be useful to make elements with a tooltip on it trigger their
* action on the first tap instead of displaying the tooltip.
* @option
* @type {booelan}
* @default false
*/
disableForTouch: false,
/**
* Optional addtional classes to apply to the tooltip template on init.
* @option
* @type {string}
* @default ''
*/
templateClasses: '',
/**
* Non-optional class added to tooltip templates. Foundation default is 'tooltip'.
* @option
* @type {string}
* @default 'tooltip'
*/
tooltipClass: 'tooltip',
/**
* Class applied to the tooltip anchor element.
* @option
* @type {string}
* @default 'has-tip'
*/
triggerClass: 'has-tip',
/**
* Minimum breakpoint size at which to open the tooltip.
* @option
* @type {string}
* @default 'small'
*/
showOn: 'small',
/**
* Custom template to be used to generate markup for tooltip.
* @option
* @type {string}
* @default ''
*/
template: '',
/**
* Text displayed in the tooltip template on open.
* @option
* @type {string}
* @default ''
*/
tipText: '',
touchCloseText: 'Tap to close.',
/**
* Allows the tooltip to remain open if triggered with a click or touch event.
* @option
* @type {boolean}
* @default true
*/
clickOpen: true,
/**
* Position of tooltip. Can be left, right, bottom, top, or auto.
* @option
* @type {string}
* @default 'auto'
*/
position: 'auto',
/**
* Alignment of tooltip relative to anchor. Can be left, right, bottom, top, center, or auto.
* @option
* @type {string}
* @default 'auto'
*/
alignment: 'auto',
/**
* Allow overlap of container/window. If false, tooltip will first try to
* position as defined by data-position and data-alignment, but reposition if
* it would cause an overflow. @option
* @type {boolean}
* @default false
*/
allowOverlap: false,
/**
* Allow overlap of only the bottom of the container. This is the most common
* behavior for dropdowns, allowing the dropdown to extend the bottom of the
* screen but not otherwise influence or break out of the container.
* Less common for tooltips.
* @option
* @type {boolean}
* @default false
*/
allowBottomOverlap: false,
/**
* Distance, in pixels, the template should push away from the anchor on the Y axis.
* @option
* @type {number}
* @default 0
*/
vOffset: 0,
/**
* Distance, in pixels, the template should push away from the anchor on the X axis
* @option
* @type {number}
* @default 0
*/
hOffset: 0,
/**
* Distance, in pixels, the template spacing auto-adjust for a vertical tooltip
* @option
* @type {number}
* @default 14
*/
tooltipHeight: 14,
/**
* Distance, in pixels, the template spacing auto-adjust for a horizontal tooltip
* @option
* @type {number}
* @default 12
*/
tooltipWidth: 12,
/**
* Allow HTML in tooltip. Warning: If you are loading user-generated content into tooltips,
* allowing HTML may open yourself up to XSS attacks.
* @option
* @type {boolean}
* @default false
*/
allowHtml: false
};
/**
* TODO utilize resize event trigger
*/
/***/ }),
/***/ "./js/foundation.util.triggers.js":
/*!****************************************!*\
!*** ./js/foundation.util.triggers.js ***!
\****************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Triggers: function() { return /* binding */ Triggers; }
/* harmony export */ });
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var MutationObserver = function () {
var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
for (var i = 0; i < prefixes.length; i++) {
if ("".concat(prefixes[i], "MutationObserver") in window) {
return window["".concat(prefixes[i], "MutationObserver")];
}
}
return false;
}();
var triggers = function triggers(el, type) {
el.data(type).split(' ').forEach(function (id) {
jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]);
});
};
var Triggers = {
Listeners: {
Basic: {},
Global: {}
},
Initializers: {}
};
Triggers.Listeners.Basic = {
openListener: function openListener() {
triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open');
},
closeListener: function closeListener() {
var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close');
if (id) {
triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close');
} else {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger');
}
},
toggleListener: function toggleListener() {
var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
if (id) {
triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle');
} else {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger');
}
},
closeableListener: function closeableListener(e) {
var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable');
// Only close the first closable element. See https://git.io/zf-7833
e.stopPropagation();
if (animation !== '') {
_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__.Motion.animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf');
});
} else {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf');
}
},
toggleFocusListener: function toggleFocusListener() {
var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus');
jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]);
}
};
// Elements with [data-open] will reveal a plugin that supports it when clicked.
Triggers.Initializers.addOpenListener = function ($elem) {
$elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
$elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
};
// Elements with [data-close] will close a plugin that supports it when clicked.
// If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
Triggers.Initializers.addCloseListener = function ($elem) {
$elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
$elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
};
// Elements with [data-toggle] will toggle a plugin that supports it when clicked.
Triggers.Initializers.addToggleListener = function ($elem) {
$elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
$elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
};
// Elements with [data-closable] will respond to close.zf.trigger events.
Triggers.Initializers.addCloseableListener = function ($elem) {
$elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
$elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
};
// Elements with [data-toggle-focus] will respond to coming in and out of focus
Triggers.Initializers.addToggleFocusListener = function ($elem) {
$elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
$elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
};
// More Global/complex listeners and triggers
Triggers.Listeners.Global = {
resizeListener: function resizeListener($nodes) {
if (!MutationObserver) {
//fallback for IE 9
$nodes.each(function () {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger');
});
}
//trigger all listening elements and signal a resize event
$nodes.attr('data-events', "resize");
},
scrollListener: function scrollListener($nodes) {
if (!MutationObserver) {
//fallback for IE 9
$nodes.each(function () {
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger');
});
}
//trigger all listening elements and signal a scroll event
$nodes.attr('data-events', "scroll");
},
closeMeListener: function closeMeListener(e, pluginId) {
var plugin = e.namespace.split('.')[0];
var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]"));
plugins.each(function () {
var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
_this.triggerHandler('close.zf.trigger', [_this]);
});
}
};
// Global, parses whole document.
Triggers.Initializers.addClosemeListener = function (pluginName) {
var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'),
plugNames = ['dropdown', 'tooltip', 'reveal'];
if (pluginName) {
if (typeof pluginName === 'string') {
plugNames.push(pluginName);
} else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') {
plugNames = plugNames.concat(pluginName);
} else {
console.error('Plugin names must be strings');
}
}
if (yetiBoxes.length) {
var listeners = plugNames.map(function (name) {
return "closeme.zf.".concat(name);
}).join(' ');
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
}
};
function debounceGlobalListener(debounce, trigger, listener) {
var timer,
args = Array.prototype.slice.call(arguments, 3);
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on(trigger, function () {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
listener.apply(null, args);
}, debounce || 10); //default time to emit scroll event
});
}
Triggers.Initializers.addResizeListener = function (debounce) {
var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]');
if ($nodes.length) {
debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
}
};
Triggers.Initializers.addScrollListener = function (debounce) {
var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]');
if ($nodes.length) {
debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
}
};
Triggers.Initializers.addMutationEventsListener = function ($elem) {
if (!MutationObserver) {
return false;
}
var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]');
//element callback
var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) {
var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target);
//trigger the event handler for the element depending on type
switch (mutationRecordsList[0].type) {
case "attributes":
if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
$target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
}
if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
$target.triggerHandler('resizeme.zf.trigger', [$target]);
}
if (mutationRecordsList[0].attributeName === "style") {
$target.closest("[data-mutate]").attr("data-events", "mutate");
$target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
}
break;
case "childList":
$target.closest("[data-mutate]").attr("data-events", "mutate");
$target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
break;
default:
return false;
//nothing
}
};
if ($nodes.length) {
//for each element that needs to listen for resizing, scrolling, or mutation add a single observer
for (var i = 0; i <= $nodes.length - 1; i++) {
var elementObserver = new MutationObserver(listeningElementsMutation);
elementObserver.observe($nodes[i], {
attributes: true,
childList: true,
characterData: false,
subtree: true,
attributeFilter: ["data-events", "style"]
});
}
}
};
Triggers.Initializers.addSimpleListeners = function () {
var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
Triggers.Initializers.addOpenListener($document);
Triggers.Initializers.addCloseListener($document);
Triggers.Initializers.addToggleListener($document);
Triggers.Initializers.addCloseableListener($document);
Triggers.Initializers.addToggleFocusListener($document);
};
Triggers.Initializers.addGlobalListeners = function () {
var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
Triggers.Initializers.addMutationEventsListener($document);
Triggers.Initializers.addResizeListener(250);
Triggers.Initializers.addScrollListener();
Triggers.Initializers.addClosemeListener();
};
Triggers.init = function (__, Foundation) {
(0,_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__.onLoad)(jquery__WEBPACK_IMPORTED_MODULE_0___default()(window), function () {
if ((jquery__WEBPACK_IMPORTED_MODULE_0___default().triggersInitialized) !== true) {
Triggers.Initializers.addSimpleListeners();
Triggers.Initializers.addGlobalListeners();
(jquery__WEBPACK_IMPORTED_MODULE_0___default().triggersInitialized) = true;
}
});
if (Foundation) {
Foundation.Triggers = Triggers;
// Legacy included to be backwards compatible for now.
Foundation.IHearYou = Triggers.Initializers.addGlobalListeners;
}
};
/***/ }),
/***/ "./foundation.core":
/*!****************************************************************************************************************************************************************!*\
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
\****************************************************************************************************************************************************************/
/***/ (function(module) {
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
/***/ }),
/***/ "./foundation.util.box":
/*!********************************************************************************************************************************************************************************!*\
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.box"],"amd":"./foundation.util.box","commonjs":"./foundation.util.box","commonjs2":"./foundation.util.box"} ***!
\********************************************************************************************************************************************************************************/
/***/ (function(module) {
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_box__;
/***/ }),
/***/ "./foundation.util.mediaQuery":
/*!************************************************************************************************************************************************************************************************************!*\
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.mediaQuery"],"amd":"./foundation.util.mediaQuery","commonjs":"./foundation.util.mediaQuery","commonjs2":"./foundation.util.mediaQuery"} ***!
\************************************************************************************************************************************************************************************************************/
/***/ (function(module) {
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__;
/***/ }),
/***/ "./foundation.util.motion":
/*!********************************************************************************************************************************************************************************************!*\
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
\********************************************************************************************************************************************************************************************/
/***/ (function(module) {
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
/***/ }),
/***/ "jquery":
/*!********************************************************************************************!*\
!*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
\********************************************************************************************/
/***/ (function(module) {
module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ !function() {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function() { return module['default']; } :
/******/ function() { return module; };
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ !function() {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = function(exports, definition) {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ !function() {
/******/ __webpack_require__.o = fu