638 lines
26 KiB
JavaScript
638 lines
26 KiB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
module.exports = factory(require("./foundation.core"), require("./foundation.core.plugin"), require("./foundation.core.utils"), require("./foundation.util.imageLoader"), require("./foundation.util.mediaQuery"), require("jquery"));
|
|
else if(typeof define === 'function' && define.amd)
|
|
define(["./foundation.core", "./foundation.core.plugin", "./foundation.core.utils", "./foundation.util.imageLoader", "./foundation.util.mediaQuery", "jquery"], factory);
|
|
else if(typeof exports === 'object')
|
|
exports["foundation.equalizer"] = factory(require("./foundation.core"), require("./foundation.core.plugin"), require("./foundation.core.utils"), require("./foundation.util.imageLoader"), require("./foundation.util.mediaQuery"), require("jquery"));
|
|
else
|
|
root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.equalizer"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.imageLoader"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.mediaQuery"], root["jQuery"]);
|
|
})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_core_plugin__, __WEBPACK_EXTERNAL_MODULE__foundation_core_utils__, __WEBPACK_EXTERNAL_MODULE__foundation_util_imageLoader__, __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__, __WEBPACK_EXTERNAL_MODULE_jquery__) {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __webpack_require__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __webpack_require__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/
|
|
/******/ // create a fake namespace object
|
|
/******/ // mode & 1: value is a module id, require it
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
/******/ // mode & 4: return value when already ns object
|
|
/******/ // mode & 8|1: behave like require
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __webpack_require__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __webpack_require__.p = "";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(__webpack_require__.s = 6);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ "./foundation.core":
|
|
/*!****************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
|
|
\****************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./foundation.core.plugin":
|
|
/*!*************************************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core.plugin","commonjs":"./foundation.core.plugin","commonjs2":"./foundation.core.plugin"} ***!
|
|
\*************************************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core_plugin__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./foundation.core.utils":
|
|
/*!**********************************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core.utils","commonjs":"./foundation.core.utils","commonjs2":"./foundation.core.utils"} ***!
|
|
\**********************************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core_utils__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./foundation.util.imageLoader":
|
|
/*!****************************************************************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.imageLoader"],"amd":"./foundation.util.imageLoader","commonjs":"./foundation.util.imageLoader","commonjs2":"./foundation.util.imageLoader"} ***!
|
|
\****************************************************************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_imageLoader__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./foundation.util.mediaQuery":
|
|
/*!************************************************************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.mediaQuery"],"amd":"./foundation.util.mediaQuery","commonjs":"./foundation.util.mediaQuery","commonjs2":"./foundation.util.mediaQuery"} ***!
|
|
\************************************************************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./js/entries/plugins/foundation.equalizer.js":
|
|
/*!****************************************************!*\
|
|
!*** ./js/entries/plugins/foundation.equalizer.js ***!
|
|
\****************************************************/
|
|
/*! exports provided: Foundation, Equalizer */
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
|
|
/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
|
|
|
|
/* harmony import */ var _foundation_equalizer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.equalizer */ "./js/foundation.equalizer.js");
|
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Equalizer", function() { return _foundation_equalizer__WEBPACK_IMPORTED_MODULE_1__["Equalizer"]; });
|
|
|
|
|
|
|
|
_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_equalizer__WEBPACK_IMPORTED_MODULE_1__["Equalizer"], 'Equalizer');
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./js/foundation.equalizer.js":
|
|
/*!************************************!*\
|
|
!*** ./js/foundation.equalizer.js ***!
|
|
\************************************/
|
|
/*! exports provided: Equalizer */
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Equalizer", function() { return Equalizer; });
|
|
/* 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_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.mediaQuery */ "./foundation.util.mediaQuery");
|
|
/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.imageLoader */ "./foundation.util.imageLoader");
|
|
/* harmony import */ var _foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core.utils");
|
|
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__);
|
|
/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core.plugin");
|
|
/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_4__);
|
|
|
|
|
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Equalizer module.
|
|
* @module foundation.equalizer
|
|
* @requires foundation.util.mediaQuery
|
|
* @requires foundation.util.imageLoader if equalizer contains images
|
|
*/
|
|
|
|
var Equalizer =
|
|
/*#__PURE__*/
|
|
function (_Plugin) {
|
|
_inherits(Equalizer, _Plugin);
|
|
|
|
function Equalizer() {
|
|
_classCallCheck(this, Equalizer);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Equalizer).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Equalizer, [{
|
|
key: "_setup",
|
|
|
|
/**
|
|
* Creates a new instance of Equalizer.
|
|
* @class
|
|
* @name Equalizer
|
|
* @fires Equalizer#init
|
|
* @param {Object} element - jQuery object to add the trigger to.
|
|
* @param {Object} options - Overrides to the default plugin settings.
|
|
*/
|
|
value: function _setup(element, options) {
|
|
this.$element = element;
|
|
this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Equalizer.defaults, this.$element.data(), options);
|
|
this.className = 'Equalizer'; // ie9 back compat
|
|
|
|
this._init();
|
|
}
|
|
/**
|
|
* Initializes the Equalizer plugin and calls functions to get equalizer functioning on load.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_init",
|
|
value: function _init() {
|
|
var eqId = this.$element.attr('data-equalizer') || '';
|
|
var $watched = this.$element.find("[data-equalizer-watch=\"".concat(eqId, "\"]"));
|
|
|
|
_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"]._init();
|
|
|
|
this.$watched = $watched.length ? $watched : this.$element.find('[data-equalizer-watch]');
|
|
this.$element.attr('data-resize', eqId || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'eq'));
|
|
this.$element.attr('data-mutate', eqId || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'eq'));
|
|
this.hasNested = this.$element.find('[data-equalizer]').length > 0;
|
|
this.isNested = this.$element.parentsUntil(document.body, '[data-equalizer]').length > 0;
|
|
this.isOn = false;
|
|
this._bindHandler = {
|
|
onResizeMeBound: this._onResizeMe.bind(this),
|
|
onPostEqualizedBound: this._onPostEqualized.bind(this)
|
|
};
|
|
var imgs = this.$element.find('img');
|
|
var tooSmall;
|
|
|
|
if (this.options.equalizeOn) {
|
|
tooSmall = this._checkMQ();
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('changed.zf.mediaquery', this._checkMQ.bind(this));
|
|
} else {
|
|
this._events();
|
|
}
|
|
|
|
if (typeof tooSmall !== 'undefined' && tooSmall === false || typeof tooSmall === 'undefined') {
|
|
if (imgs.length) {
|
|
Object(_foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_2__["onImagesLoaded"])(imgs, this._reflow.bind(this));
|
|
} else {
|
|
this._reflow();
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* Removes event listeners if the breakpoint is too small.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_pauseEvents",
|
|
value: function _pauseEvents() {
|
|
this.isOn = false;
|
|
this.$element.off({
|
|
'.zf.equalizer': this._bindHandler.onPostEqualizedBound,
|
|
'resizeme.zf.trigger': this._bindHandler.onResizeMeBound,
|
|
'mutateme.zf.trigger': this._bindHandler.onResizeMeBound
|
|
});
|
|
}
|
|
/**
|
|
* function to handle $elements resizeme.zf.trigger, with bound this on _bindHandler.onResizeMeBound
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_onResizeMe",
|
|
value: function _onResizeMe(e) {
|
|
this._reflow();
|
|
}
|
|
/**
|
|
* function to handle $elements postequalized.zf.equalizer, with bound this on _bindHandler.onPostEqualizedBound
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_onPostEqualized",
|
|
value: function _onPostEqualized(e) {
|
|
if (e.target !== this.$element[0]) {
|
|
this._reflow();
|
|
}
|
|
}
|
|
/**
|
|
* Initializes events for Equalizer.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_events",
|
|
value: function _events() {
|
|
var _this = this;
|
|
|
|
this._pauseEvents();
|
|
|
|
if (this.hasNested) {
|
|
this.$element.on('postequalized.zf.equalizer', this._bindHandler.onPostEqualizedBound);
|
|
} else {
|
|
this.$element.on('resizeme.zf.trigger', this._bindHandler.onResizeMeBound);
|
|
this.$element.on('mutateme.zf.trigger', this._bindHandler.onResizeMeBound);
|
|
}
|
|
|
|
this.isOn = true;
|
|
}
|
|
/**
|
|
* Checks the current breakpoint to the minimum required size.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_checkMQ",
|
|
value: function _checkMQ() {
|
|
var tooSmall = !_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].is(this.options.equalizeOn);
|
|
|
|
if (tooSmall) {
|
|
if (this.isOn) {
|
|
this._pauseEvents();
|
|
|
|
this.$watched.css('height', 'auto');
|
|
}
|
|
} else {
|
|
if (!this.isOn) {
|
|
this._events();
|
|
}
|
|
}
|
|
|
|
return tooSmall;
|
|
}
|
|
/**
|
|
* A noop version for the plugin
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_killswitch",
|
|
value: function _killswitch() {
|
|
return;
|
|
}
|
|
/**
|
|
* Calls necessary functions to update Equalizer upon DOM change
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_reflow",
|
|
value: function _reflow() {
|
|
if (!this.options.equalizeOnStack) {
|
|
if (this._isStacked()) {
|
|
this.$watched.css('height', 'auto');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (this.options.equalizeByRow) {
|
|
this.getHeightsByRow(this.applyHeightByRow.bind(this));
|
|
} else {
|
|
this.getHeights(this.applyHeight.bind(this));
|
|
}
|
|
}
|
|
/**
|
|
* Manually determines if the first 2 elements are *NOT* stacked.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_isStacked",
|
|
value: function _isStacked() {
|
|
if (!this.$watched[0] || !this.$watched[1]) {
|
|
return true;
|
|
}
|
|
|
|
return this.$watched[0].getBoundingClientRect().top !== this.$watched[1].getBoundingClientRect().top;
|
|
}
|
|
/**
|
|
* Finds the outer heights of children contained within an Equalizer parent and returns them in an array
|
|
* @param {Function} cb - A non-optional callback to return the heights array to.
|
|
* @returns {Array} heights - An array of heights of children within Equalizer container
|
|
*/
|
|
|
|
}, {
|
|
key: "getHeights",
|
|
value: function getHeights(cb) {
|
|
var heights = [];
|
|
|
|
for (var i = 0, len = this.$watched.length; i < len; i++) {
|
|
this.$watched[i].style.height = 'auto';
|
|
heights.push(this.$watched[i].offsetHeight);
|
|
}
|
|
|
|
cb(heights);
|
|
}
|
|
/**
|
|
* Finds the outer heights of children contained within an Equalizer parent and returns them in an array
|
|
* @param {Function} cb - A non-optional callback to return the heights array to.
|
|
* @returns {Array} groups - An array of heights of children within Equalizer container grouped by row with element,height and max as last child
|
|
*/
|
|
|
|
}, {
|
|
key: "getHeightsByRow",
|
|
value: function getHeightsByRow(cb) {
|
|
var lastElTopOffset = this.$watched.length ? this.$watched.first().offset().top : 0,
|
|
groups = [],
|
|
group = 0; //group by Row
|
|
|
|
groups[group] = [];
|
|
|
|
for (var i = 0, len = this.$watched.length; i < len; i++) {
|
|
this.$watched[i].style.height = 'auto'; //maybe could use this.$watched[i].offsetTop
|
|
|
|
var elOffsetTop = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.$watched[i]).offset().top;
|
|
|
|
if (elOffsetTop != lastElTopOffset) {
|
|
group++;
|
|
groups[group] = [];
|
|
lastElTopOffset = elOffsetTop;
|
|
}
|
|
|
|
groups[group].push([this.$watched[i], this.$watched[i].offsetHeight]);
|
|
}
|
|
|
|
for (var j = 0, ln = groups.length; j < ln; j++) {
|
|
var heights = jquery__WEBPACK_IMPORTED_MODULE_0___default()(groups[j]).map(function () {
|
|
return this[1];
|
|
}).get();
|
|
var max = Math.max.apply(null, heights);
|
|
groups[j].push(max);
|
|
}
|
|
|
|
cb(groups);
|
|
}
|
|
/**
|
|
* Changes the CSS height property of each child in an Equalizer parent to match the tallest
|
|
* @param {array} heights - An array of heights of children within Equalizer container
|
|
* @fires Equalizer#preequalized
|
|
* @fires Equalizer#postequalized
|
|
*/
|
|
|
|
}, {
|
|
key: "applyHeight",
|
|
value: function applyHeight(heights) {
|
|
var max = Math.max.apply(null, heights);
|
|
/**
|
|
* Fires before the heights are applied
|
|
* @event Equalizer#preequalized
|
|
*/
|
|
|
|
this.$element.trigger('preequalized.zf.equalizer');
|
|
this.$watched.css('height', max);
|
|
/**
|
|
* Fires when the heights have been applied
|
|
* @event Equalizer#postequalized
|
|
*/
|
|
|
|
this.$element.trigger('postequalized.zf.equalizer');
|
|
}
|
|
/**
|
|
* Changes the CSS height property of each child in an Equalizer parent to match the tallest by row
|
|
* @param {array} groups - An array of heights of children within Equalizer container grouped by row with element,height and max as last child
|
|
* @fires Equalizer#preequalized
|
|
* @fires Equalizer#preequalizedrow
|
|
* @fires Equalizer#postequalizedrow
|
|
* @fires Equalizer#postequalized
|
|
*/
|
|
|
|
}, {
|
|
key: "applyHeightByRow",
|
|
value: function applyHeightByRow(groups) {
|
|
/**
|
|
* Fires before the heights are applied
|
|
*/
|
|
this.$element.trigger('preequalized.zf.equalizer');
|
|
|
|
for (var i = 0, len = groups.length; i < len; i++) {
|
|
var groupsILength = groups[i].length,
|
|
max = groups[i][groupsILength - 1];
|
|
|
|
if (groupsILength <= 2) {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(groups[i][0][0]).css({
|
|
'height': 'auto'
|
|
});
|
|
continue;
|
|
}
|
|
/**
|
|
* Fires before the heights per row are applied
|
|
* @event Equalizer#preequalizedrow
|
|
*/
|
|
|
|
|
|
this.$element.trigger('preequalizedrow.zf.equalizer');
|
|
|
|
for (var j = 0, lenJ = groupsILength - 1; j < lenJ; j++) {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(groups[i][j][0]).css({
|
|
'height': max
|
|
});
|
|
}
|
|
/**
|
|
* Fires when the heights per row have been applied
|
|
* @event Equalizer#postequalizedrow
|
|
*/
|
|
|
|
|
|
this.$element.trigger('postequalizedrow.zf.equalizer');
|
|
}
|
|
/**
|
|
* Fires when the heights have been applied
|
|
*/
|
|
|
|
|
|
this.$element.trigger('postequalized.zf.equalizer');
|
|
}
|
|
/**
|
|
* Destroys an instance of Equalizer.
|
|
* @function
|
|
*/
|
|
|
|
}, {
|
|
key: "_destroy",
|
|
value: function _destroy() {
|
|
this._pauseEvents();
|
|
|
|
this.$watched.css('height', 'auto');
|
|
}
|
|
}]);
|
|
|
|
return Equalizer;
|
|
}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_4__["Plugin"]);
|
|
/**
|
|
* Default settings for plugin
|
|
*/
|
|
|
|
|
|
Equalizer.defaults = {
|
|
/**
|
|
* Enable height equalization when stacked on smaller screens.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default false
|
|
*/
|
|
equalizeOnStack: false,
|
|
|
|
/**
|
|
* Enable height equalization row by row.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default false
|
|
*/
|
|
equalizeByRow: false,
|
|
|
|
/**
|
|
* String representing the minimum breakpoint size the plugin should equalize heights on.
|
|
* @option
|
|
* @type {string}
|
|
* @default ''
|
|
*/
|
|
equalizeOn: ''
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6:
|
|
/*!**********************************************************!*\
|
|
!*** multi ./js/entries/plugins/foundation.equalizer.js ***!
|
|
\**********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__(/*! /Users/ncoden/Documents/Documents/Projects/Programmation/Web/2016/Foundation/foundation-sites/js/entries/plugins/foundation.equalizer.js */"./js/entries/plugins/foundation.equalizer.js");
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "jquery":
|
|
/*!********************************************************************************************!*\
|
|
!*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
|
|
\********************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
});
|
|
//# sourceMappingURL=foundation.equalizer.js.map
|