123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("./foundation.core"));
- else if(typeof define === 'function' && define.amd)
- define(["./foundation.core"], factory);
- else if(typeof exports === 'object')
- exports["foundation.util.box"] = factory(require("./foundation.core"));
- else
- root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.util.box"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"]);
- })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__) {
- 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 = 21);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ "./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__;
- /***/ }),
- /***/ "./js/entries/plugins/foundation.util.box.js":
- /*!***************************************************!*\
- !*** ./js/entries/plugins/foundation.util.box.js ***!
- \***************************************************/
- /*! exports provided: Foundation, Box */
- /***/ (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_util_box__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.util.box */ "./js/foundation.util.box.js");
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Box", function() { return _foundation_util_box__WEBPACK_IMPORTED_MODULE_1__["Box"]; });
- _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].Box = _foundation_util_box__WEBPACK_IMPORTED_MODULE_1__["Box"];
- /***/ }),
- /***/ "./js/foundation.util.box.js":
- /*!***********************************!*\
- !*** ./js/foundation.util.box.js ***!
- \***********************************/
- /*! exports provided: Box */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Box", function() { return Box; });
- var Box = {
- ImNotTouchingYou: ImNotTouchingYou,
- OverlapArea: OverlapArea,
- GetDimensions: GetDimensions,
- GetExplicitOffsets: GetExplicitOffsets
- /**
- * Compares the dimensions of an element to a container and determines collision events with container.
- * @function
- * @param {jQuery} element - jQuery object to test for collisions.
- * @param {jQuery} parent - jQuery object to use as bounding container.
- * @param {Boolean} lrOnly - set to true to check left and right values only.
- * @param {Boolean} tbOnly - set to true to check top and bottom values only.
- * @default if no parent object passed, detects collisions with `window`.
- * @returns {Boolean} - true if collision free, false if a collision in any direction.
- */
- };
- function ImNotTouchingYou(element, parent, lrOnly, tbOnly, ignoreBottom) {
- return OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) === 0;
- }
- function OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) {
- var eleDims = GetDimensions(element),
- topOver,
- bottomOver,
- leftOver,
- rightOver;
- if (parent) {
- var parDims = GetDimensions(parent);
- bottomOver = parDims.height + parDims.offset.top - (eleDims.offset.top + eleDims.height);
- topOver = eleDims.offset.top - parDims.offset.top;
- leftOver = eleDims.offset.left - parDims.offset.left;
- rightOver = parDims.width + parDims.offset.left - (eleDims.offset.left + eleDims.width);
- } else {
- bottomOver = eleDims.windowDims.height + eleDims.windowDims.offset.top - (eleDims.offset.top + eleDims.height);
- topOver = eleDims.offset.top - eleDims.windowDims.offset.top;
- leftOver = eleDims.offset.left - eleDims.windowDims.offset.left;
- rightOver = eleDims.windowDims.width - (eleDims.offset.left + eleDims.width);
- }
- bottomOver = ignoreBottom ? 0 : Math.min(bottomOver, 0);
- topOver = Math.min(topOver, 0);
- leftOver = Math.min(leftOver, 0);
- rightOver = Math.min(rightOver, 0);
- if (lrOnly) {
- return leftOver + rightOver;
- }
- if (tbOnly) {
- return topOver + bottomOver;
- } // use sum of squares b/c we care about overlap area.
- return Math.sqrt(topOver * topOver + bottomOver * bottomOver + leftOver * leftOver + rightOver * rightOver);
- }
- /**
- * Uses native methods to return an object of dimension values.
- * @function
- * @param {jQuery || HTML} element - jQuery object or DOM element for which to get the dimensions. Can be any element other that document or window.
- * @returns {Object} - nested object of integer pixel values
- * TODO - if element is window, return only those values.
- */
- function GetDimensions(elem) {
- elem = elem.length ? elem[0] : elem;
- if (elem === window || elem === document) {
- throw new Error("I'm sorry, Dave. I'm afraid I can't do that.");
- }
- var rect = elem.getBoundingClientRect(),
- parRect = elem.parentNode.getBoundingClientRect(),
- winRect = document.body.getBoundingClientRect(),
- winY = window.pageYOffset,
- winX = window.pageXOffset;
- return {
- width: rect.width,
- height: rect.height,
- offset: {
- top: rect.top + winY,
- left: rect.left + winX
- },
- parentDims: {
- width: parRect.width,
- height: parRect.height,
- offset: {
- top: parRect.top + winY,
- left: parRect.left + winX
- }
- },
- windowDims: {
- width: winRect.width,
- height: winRect.height,
- offset: {
- top: winY,
- left: winX
- }
- }
- };
- }
- /**
- * Returns an object of top and left integer pixel values for dynamically rendered elements,
- * such as: Tooltip, Reveal, and Dropdown. Maintained for backwards compatibility, and where
- * you don't know alignment, but generally from
- * 6.4 forward you should use GetExplicitOffsets, as GetOffsets conflates position and alignment.
- * @function
- * @param {jQuery} element - jQuery object for the element being positioned.
- * @param {jQuery} anchor - jQuery object for the element's anchor point.
- * @param {String} position - a string relating to the desired position of the element, relative to it's anchor
- * @param {Number} vOffset - integer pixel value of desired vertical separation between anchor and element.
- * @param {Number} hOffset - integer pixel value of desired horizontal separation between anchor and element.
- * @param {Boolean} isOverflow - if a collision event is detected, sets to true to default the element to full width - any desired offset.
- * TODO alter/rewrite to work with `em` values as well/instead of pixels
- */
- function GetExplicitOffsets(element, anchor, position, alignment, vOffset, hOffset, isOverflow) {
- var $eleDims = GetDimensions(element),
- $anchorDims = anchor ? GetDimensions(anchor) : null;
- var topVal, leftVal;
- if ($anchorDims !== null) {
- // set position related attribute
- switch (position) {
- case 'top':
- topVal = $anchorDims.offset.top - ($eleDims.height + vOffset);
- break;
- case 'bottom':
- topVal = $anchorDims.offset.top + $anchorDims.height + vOffset;
- break;
- case 'left':
- leftVal = $anchorDims.offset.left - ($eleDims.width + hOffset);
- break;
- case 'right':
- leftVal = $anchorDims.offset.left + $anchorDims.width + hOffset;
- break;
- } // set alignment related attribute
- switch (position) {
- case 'top':
- case 'bottom':
- switch (alignment) {
- case 'left':
- leftVal = $anchorDims.offset.left + hOffset;
- break;
- case 'right':
- leftVal = $anchorDims.offset.left - $eleDims.width + $anchorDims.width - hOffset;
- break;
- case 'center':
- leftVal = isOverflow ? hOffset : $anchorDims.offset.left + $anchorDims.width / 2 - $eleDims.width / 2 + hOffset;
- break;
- }
- break;
- case 'right':
- case 'left':
- switch (alignment) {
- case 'bottom':
- topVal = $anchorDims.offset.top - vOffset + $anchorDims.height - $eleDims.height;
- break;
- case 'top':
- topVal = $anchorDims.offset.top + vOffset;
- break;
- case 'center':
- topVal = $anchorDims.offset.top + vOffset + $anchorDims.height / 2 - $eleDims.height / 2;
- break;
- }
- break;
- }
- }
- return {
- top: topVal,
- left: leftVal
- };
- }
- /***/ }),
- /***/ 21:
- /*!*********************************************************!*\
- !*** multi ./js/entries/plugins/foundation.util.box.js ***!
- \*********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.util.box.js */"./js/entries/plugins/foundation.util.box.js");
- /***/ })
- /******/ });
- });
- //# sourceMappingURL=foundation.util.box.js.map
|