Subversion Repositories wimsdev

Rev

Rev 14197 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. (function webpackUniversalModuleDefinition(root, factory) {
  2.   if(typeof exports === 'object' && typeof module === 'object')
  3.     module.exports = factory(require("./foundation.core"));
  4.   else if(typeof define === 'function' && define.amd)
  5.     define(["./foundation.core"], factory);
  6.   else if(typeof exports === 'object')
  7.     exports["foundation.util.box"] = factory(require("./foundation.core"));
  8.   else
  9.     root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.util.box"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/   // The module cache
  13. /******/   var installedModules = {};
  14. /******/
  15. /******/   // The require function
  16. /******/   function __webpack_require__(moduleId) {
  17. /******/
  18. /******/     // Check if module is in cache
  19. /******/     if(installedModules[moduleId]) {
  20. /******/       return installedModules[moduleId].exports;
  21. /******/     }
  22. /******/     // Create a new module (and put it into the cache)
  23. /******/     var module = installedModules[moduleId] = {
  24. /******/       i: moduleId,
  25. /******/       l: false,
  26. /******/       exports: {}
  27. /******/     };
  28. /******/
  29. /******/     // Execute the module function
  30. /******/     modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/     // Flag the module as loaded
  33. /******/     module.l = true;
  34. /******/
  35. /******/     // Return the exports of the module
  36. /******/     return module.exports;
  37. /******/   }
  38. /******/
  39. /******/
  40. /******/   // expose the modules object (__webpack_modules__)
  41. /******/   __webpack_require__.m = modules;
  42. /******/
  43. /******/   // expose the module cache
  44. /******/   __webpack_require__.c = installedModules;
  45. /******/
  46. /******/   // define getter function for harmony exports
  47. /******/   __webpack_require__.d = function(exports, name, getter) {
  48. /******/     if(!__webpack_require__.o(exports, name)) {
  49. /******/       Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/     }
  51. /******/   };
  52. /******/
  53. /******/   // define __esModule on exports
  54. /******/   __webpack_require__.r = function(exports) {
  55. /******/     if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/       Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/     }
  58. /******/     Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/   };
  60. /******/
  61. /******/   // create a fake namespace object
  62. /******/   // mode & 1: value is a module id, require it
  63. /******/   // mode & 2: merge all properties of value into the ns
  64. /******/   // mode & 4: return value when already ns object
  65. /******/   // mode & 8|1: behave like require
  66. /******/   __webpack_require__.t = function(value, mode) {
  67. /******/     if(mode & 1) value = __webpack_require__(value);
  68. /******/     if(mode & 8) return value;
  69. /******/     if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/     var ns = Object.create(null);
  71. /******/     __webpack_require__.r(ns);
  72. /******/     Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/     if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/     return ns;
  75. /******/   };
  76. /******/
  77. /******/   // getDefaultExport function for compatibility with non-harmony modules
  78. /******/   __webpack_require__.n = function(module) {
  79. /******/     var getter = module && module.__esModule ?
  80. /******/       function getDefault() { return module['default']; } :
  81. /******/       function getModuleExports() { return module; };
  82. /******/     __webpack_require__.d(getter, 'a', getter);
  83. /******/     return getter;
  84. /******/   };
  85. /******/
  86. /******/   // Object.prototype.hasOwnProperty.call
  87. /******/   __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/   // __webpack_public_path__
  90. /******/   __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/   // Load entry module and return exports
  94. /******/   return __webpack_require__(__webpack_require__.s = 21);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98.  
  99. /***/ "./foundation.core":
  100. /*!****************************************************************************************************************************************************************!*\
  101.   !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
  102.   \****************************************************************************************************************************************************************/
  103. /*! no static exports found */
  104. /***/ (function(module, exports) {
  105.  
  106. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
  107.  
  108. /***/ }),
  109.  
  110. /***/ "./js/entries/plugins/foundation.util.box.js":
  111. /*!***************************************************!*\
  112.   !*** ./js/entries/plugins/foundation.util.box.js ***!
  113.   \***************************************************/
  114. /*! exports provided: Foundation, Box */
  115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116.  
  117. "use strict";
  118. __webpack_require__.r(__webpack_exports__);
  119. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
  120. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
  121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
  122.  
  123. /* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.util.box */ "./js/foundation.util.box.js");
  124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Box", function() { return _foundation_util_box__WEBPACK_IMPORTED_MODULE_1__["Box"]; });
  125.  
  126.  
  127.  
  128. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].Box = _foundation_util_box__WEBPACK_IMPORTED_MODULE_1__["Box"];
  129.  
  130.  
  131. /***/ }),
  132.  
  133. /***/ "./js/foundation.util.box.js":
  134. /*!***********************************!*\
  135.   !*** ./js/foundation.util.box.js ***!
  136.   \***********************************/
  137. /*! exports provided: Box */
  138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  139.  
  140. "use strict";
  141. __webpack_require__.r(__webpack_exports__);
  142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Box", function() { return Box; });
  143. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  144. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_0__);
  145.  
  146.  
  147.  
  148. var Box = {
  149.   ImNotTouchingYou: ImNotTouchingYou,
  150.   OverlapArea: OverlapArea,
  151.   GetDimensions: GetDimensions,
  152.   GetExplicitOffsets: GetExplicitOffsets
  153.   /**
  154.    * Compares the dimensions of an element to a container and determines collision events with container.
  155.    * @function
  156.    * @param {jQuery} element - jQuery object to test for collisions.
  157.    * @param {jQuery} parent - jQuery object to use as bounding container.
  158.    * @param {Boolean} lrOnly - set to true to check left and right values only.
  159.    * @param {Boolean} tbOnly - set to true to check top and bottom values only.
  160.    * @default if no parent object passed, detects collisions with `window`.
  161.    * @returns {Boolean} - true if collision free, false if a collision in any direction.
  162.    */
  163.  
  164. };
  165.  
  166. function ImNotTouchingYou(element, parent, lrOnly, tbOnly, ignoreBottom) {
  167.   return OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) === 0;
  168. }
  169.  
  170. ;
  171.  
  172. function OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) {
  173.   var eleDims = GetDimensions(element),
  174.       topOver,
  175.       bottomOver,
  176.       leftOver,
  177.       rightOver;
  178.  
  179.   if (parent) {
  180.     var parDims = GetDimensions(parent);
  181.     bottomOver = parDims.height + parDims.offset.top - (eleDims.offset.top + eleDims.height);
  182.     topOver = eleDims.offset.top - parDims.offset.top;
  183.     leftOver = eleDims.offset.left - parDims.offset.left;
  184.     rightOver = parDims.width + parDims.offset.left - (eleDims.offset.left + eleDims.width);
  185.   } else {
  186.     bottomOver = eleDims.windowDims.height + eleDims.windowDims.offset.top - (eleDims.offset.top + eleDims.height);
  187.     topOver = eleDims.offset.top - eleDims.windowDims.offset.top;
  188.     leftOver = eleDims.offset.left - eleDims.windowDims.offset.left;
  189.     rightOver = eleDims.windowDims.width - (eleDims.offset.left + eleDims.width);
  190.   }
  191.  
  192.   bottomOver = ignoreBottom ? 0 : Math.min(bottomOver, 0);
  193.   topOver = Math.min(topOver, 0);
  194.   leftOver = Math.min(leftOver, 0);
  195.   rightOver = Math.min(rightOver, 0);
  196.  
  197.   if (lrOnly) {
  198.     return leftOver + rightOver;
  199.   }
  200.  
  201.   if (tbOnly) {
  202.     return topOver + bottomOver;
  203.   } // use sum of squares b/c we care about overlap area.
  204.  
  205.  
  206.   return Math.sqrt(topOver * topOver + bottomOver * bottomOver + leftOver * leftOver + rightOver * rightOver);
  207. }
  208. /**
  209.  * Uses native methods to return an object of dimension values.
  210.  * @function
  211.  * @param {jQuery || HTML} element - jQuery object or DOM element for which to get the dimensions. Can be any element other that document or window.
  212.  * @returns {Object} - nested object of integer pixel values
  213.  * TODO - if element is window, return only those values.
  214.  */
  215.  
  216.  
  217. function GetDimensions(elem) {
  218.   elem = elem.length ? elem[0] : elem;
  219.  
  220.   if (elem === window || elem === document) {
  221.     throw new Error("I'm sorry, Dave. I'm afraid I can't do that.");
  222.   }
  223.  
  224.   var rect = elem.getBoundingClientRect(),
  225.       parRect = elem.parentNode.getBoundingClientRect(),
  226.       winRect = document.body.getBoundingClientRect(),
  227.       winY = window.pageYOffset,
  228.       winX = window.pageXOffset;
  229.   return {
  230.     width: rect.width,
  231.     height: rect.height,
  232.     offset: {
  233.       top: rect.top + winY,
  234.       left: rect.left + winX
  235.     },
  236.     parentDims: {
  237.       width: parRect.width,
  238.       height: parRect.height,
  239.       offset: {
  240.         top: parRect.top + winY,
  241.         left: parRect.left + winX
  242.       }
  243.     },
  244.     windowDims: {
  245.       width: winRect.width,
  246.       height: winRect.height,
  247.       offset: {
  248.         top: winY,
  249.         left: winX
  250.       }
  251.     }
  252.   };
  253. }
  254. /**
  255.  * Returns an object of top and left integer pixel values for dynamically rendered elements,
  256.  * such as: Tooltip, Reveal, and Dropdown. Maintained for backwards compatibility, and where
  257.  * you don't know alignment, but generally from
  258.  * 6.4 forward you should use GetExplicitOffsets, as GetOffsets conflates position and alignment.
  259.  * @function
  260.  * @param {jQuery} element - jQuery object for the element being positioned.
  261.  * @param {jQuery} anchor - jQuery object for the element's anchor point.
  262.  * @param {String} position - a string relating to the desired position of the element, relative to it's anchor
  263.  * @param {Number} vOffset - integer pixel value of desired vertical separation between anchor and element.
  264.  * @param {Number} hOffset - integer pixel value of desired horizontal separation between anchor and element.
  265.  * @param {Boolean} isOverflow - if a collision event is detected, sets to true to default the element to full width - any desired offset.
  266.  * TODO alter/rewrite to work with `em` values as well/instead of pixels
  267.  */
  268.  
  269.  
  270. function GetExplicitOffsets(element, anchor, position, alignment, vOffset, hOffset, isOverflow) {
  271.   var $eleDims = GetDimensions(element),
  272.       $anchorDims = anchor ? GetDimensions(anchor) : null;
  273.   var topVal, leftVal; // set position related attribute
  274.  
  275.   switch (position) {
  276.     case 'top':
  277.       topVal = $anchorDims.offset.top - ($eleDims.height + vOffset);
  278.       break;
  279.  
  280.     case 'bottom':
  281.       topVal = $anchorDims.offset.top + $anchorDims.height + vOffset;
  282.       break;
  283.  
  284.     case 'left':
  285.       leftVal = $anchorDims.offset.left - ($eleDims.width + hOffset);
  286.       break;
  287.  
  288.     case 'right':
  289.       leftVal = $anchorDims.offset.left + $anchorDims.width + hOffset;
  290.       break;
  291.   } // set alignment related attribute
  292.  
  293.  
  294.   switch (position) {
  295.     case 'top':
  296.     case 'bottom':
  297.       switch (alignment) {
  298.         case 'left':
  299.           leftVal = $anchorDims.offset.left + hOffset;
  300.           break;
  301.  
  302.         case 'right':
  303.           leftVal = $anchorDims.offset.left - $eleDims.width + $anchorDims.width - hOffset;
  304.           break;
  305.  
  306.         case 'center':
  307.           leftVal = isOverflow ? hOffset : $anchorDims.offset.left + $anchorDims.width / 2 - $eleDims.width / 2 + hOffset;
  308.           break;
  309.       }
  310.  
  311.       break;
  312.  
  313.     case 'right':
  314.     case 'left':
  315.       switch (alignment) {
  316.         case 'bottom':
  317.           topVal = $anchorDims.offset.top - vOffset + $anchorDims.height - $eleDims.height;
  318.           break;
  319.  
  320.         case 'top':
  321.           topVal = $anchorDims.offset.top + vOffset;
  322.           break;
  323.  
  324.         case 'center':
  325.           topVal = $anchorDims.offset.top + vOffset + $anchorDims.height / 2 - $eleDims.height / 2;
  326.           break;
  327.       }
  328.  
  329.       break;
  330.   }
  331.  
  332.   return {
  333.     top: topVal,
  334.     left: leftVal
  335.   };
  336. }
  337.  
  338.  
  339.  
  340. /***/ }),
  341.  
  342. /***/ 21:
  343. /*!*********************************************************!*\
  344.   !*** multi ./js/entries/plugins/foundation.util.box.js ***!
  345.   \*********************************************************/
  346. /*! no static exports found */
  347. /***/ (function(module, exports, __webpack_require__) {
  348.  
  349. module.exports = __webpack_require__(/*! /Volumes/Data/Development/Foundation/foundation-sites/js/entries/plugins/foundation.util.box.js */"./js/entries/plugins/foundation.util.box.js");
  350.  
  351.  
  352. /***/ })
  353.  
  354. /******/ });
  355. });
  356. //# sourceMappingURL=foundation.util.box.js.map