471 lines
21 KiB
JavaScript
471 lines
21 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.mediaQuery"), require("jquery"));
|
|
else if(typeof define === 'function' && define.amd)
|
|
define(["./foundation.core", "./foundation.core.plugin", "./foundation.core.utils", "./foundation.util.mediaQuery", "jquery"], factory);
|
|
else if(typeof exports === 'object')
|
|
exports["foundation.interchange"] = factory(require("./foundation.core"), require("./foundation.core.plugin"), require("./foundation.core.utils"), require("./foundation.util.mediaQuery"), require("jquery"));
|
|
else
|
|
root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.interchange"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], 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_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 = 7);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ "./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.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.interchange.js":
|
|
/*!******************************************************!*\
|
|
!*** ./js/entries/plugins/foundation.interchange.js ***!
|
|
\******************************************************/
|
|
/*! exports provided: Foundation, Interchange */
|
|
/***/ (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_interchange__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.interchange */ "./js/foundation.interchange.js");
|
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Interchange", function() { return _foundation_interchange__WEBPACK_IMPORTED_MODULE_1__["Interchange"]; });
|
|
|
|
|
|
|
|
_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_interchange__WEBPACK_IMPORTED_MODULE_1__["Interchange"], 'Interchange');
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./js/foundation.interchange.js":
|
|
/*!**************************************!*\
|
|
!*** ./js/foundation.interchange.js ***!
|
|
\**************************************/
|
|
/*! exports provided: Interchange */
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Interchange", function() { return Interchange; });
|
|
/* 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_core_plugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core.plugin");
|
|
/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__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__);
|
|
|
|
|
|
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); }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Interchange module.
|
|
* @module foundation.interchange
|
|
* @requires foundation.util.mediaQuery
|
|
*/
|
|
|
|
var Interchange =
|
|
/*#__PURE__*/
|
|
function (_Plugin) {
|
|
_inherits(Interchange, _Plugin);
|
|
|
|
function Interchange() {
|
|
_classCallCheck(this, Interchange);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Interchange).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Interchange, [{
|
|
key: "_setup",
|
|
|
|
/**
|
|
* Creates a new instance of Interchange.
|
|
* @class
|
|
* @name Interchange
|
|
* @fires Interchange#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({}, Interchange.defaults, options);
|
|
this.rules = [];
|
|
this.currentPath = '';
|
|
this.className = 'Interchange'; // ie9 back compat
|
|
|
|
this._init();
|
|
|
|
this._events();
|
|
}
|
|
/**
|
|
* Initializes the Interchange plugin and calls functions to get interchange functioning on load.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_init",
|
|
value: function _init() {
|
|
_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"]._init();
|
|
|
|
var id = this.$element[0].id || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'interchange');
|
|
this.$element.attr({
|
|
'data-resize': id,
|
|
'id': id
|
|
});
|
|
|
|
this._addBreakpoints();
|
|
|
|
this._generateRules();
|
|
|
|
this._reflow();
|
|
}
|
|
/**
|
|
* Initializes events for Interchange.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_events",
|
|
value: function _events() {
|
|
var _this2 = this;
|
|
|
|
this.$element.off('resizeme.zf.trigger').on('resizeme.zf.trigger', function () {
|
|
return _this2._reflow();
|
|
});
|
|
}
|
|
/**
|
|
* Calls necessary functions to update Interchange upon DOM change
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_reflow",
|
|
value: function _reflow() {
|
|
var match; // Iterate through each rule, but only save the last match
|
|
|
|
for (var i in this.rules) {
|
|
if (this.rules.hasOwnProperty(i)) {
|
|
var rule = this.rules[i];
|
|
|
|
if (window.matchMedia(rule.query).matches) {
|
|
match = rule;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (match) {
|
|
this.replace(match.path);
|
|
}
|
|
}
|
|
/**
|
|
* Gets the Foundation breakpoints and adds them to the Interchange.SPECIAL_QUERIES object.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_addBreakpoints",
|
|
value: function _addBreakpoints() {
|
|
for (var i in _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].queries) {
|
|
if (_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].queries.hasOwnProperty(i)) {
|
|
var query = _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].queries[i];
|
|
Interchange.SPECIAL_QUERIES[query.name] = query.value;
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* Checks the Interchange element for the provided media query + content pairings
|
|
* @function
|
|
* @private
|
|
* @param {Object} element - jQuery object that is an Interchange instance
|
|
* @returns {Array} scenarios - Array of objects that have 'mq' and 'path' keys with corresponding keys
|
|
*/
|
|
|
|
}, {
|
|
key: "_generateRules",
|
|
value: function _generateRules(element) {
|
|
var rulesList = [];
|
|
var rules;
|
|
|
|
if (this.options.rules) {
|
|
rules = this.options.rules;
|
|
} else {
|
|
rules = this.$element.data('interchange');
|
|
}
|
|
|
|
rules = typeof rules === 'string' ? rules.match(/\[.*?, .*?\]/g) : rules;
|
|
|
|
for (var i in rules) {
|
|
if (rules.hasOwnProperty(i)) {
|
|
var rule = rules[i].slice(1, -1).split(', ');
|
|
var path = rule.slice(0, -1).join('');
|
|
var query = rule[rule.length - 1];
|
|
|
|
if (Interchange.SPECIAL_QUERIES[query]) {
|
|
query = Interchange.SPECIAL_QUERIES[query];
|
|
}
|
|
|
|
rulesList.push({
|
|
path: path,
|
|
query: query
|
|
});
|
|
}
|
|
}
|
|
|
|
this.rules = rulesList;
|
|
}
|
|
/**
|
|
* Update the `src` property of an image, or change the HTML of a container, to the specified path.
|
|
* @function
|
|
* @param {String} path - Path to the image or HTML partial.
|
|
* @fires Interchange#replaced
|
|
*/
|
|
|
|
}, {
|
|
key: "replace",
|
|
value: function replace(path) {
|
|
if (this.currentPath === path) return;
|
|
|
|
var _this = this,
|
|
trigger = 'replaced.zf.interchange'; // Replacing images
|
|
|
|
|
|
if (this.$element[0].nodeName === 'IMG') {
|
|
this.$element.attr('src', path).on('load', function () {
|
|
_this.currentPath = path;
|
|
}).trigger(trigger);
|
|
} // Replacing background images
|
|
else if (path.match(/\.(gif|jpg|jpeg|png|svg|tiff)([?#].*)?/i)) {
|
|
path = path.replace(/\(/g, '%28').replace(/\)/g, '%29');
|
|
this.$element.css({
|
|
'background-image': 'url(' + path + ')'
|
|
}).trigger(trigger);
|
|
} // Replacing HTML
|
|
else {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.get(path, function (response) {
|
|
_this.$element.html(response).trigger(trigger);
|
|
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(response).foundation();
|
|
_this.currentPath = path;
|
|
});
|
|
}
|
|
/**
|
|
* Fires when content in an Interchange element is done being loaded.
|
|
* @event Interchange#replaced
|
|
*/
|
|
// this.$element.trigger('replaced.zf.interchange');
|
|
|
|
}
|
|
/**
|
|
* Destroys an instance of interchange.
|
|
* @function
|
|
*/
|
|
|
|
}, {
|
|
key: "_destroy",
|
|
value: function _destroy() {
|
|
this.$element.off('resizeme.zf.trigger');
|
|
}
|
|
}]);
|
|
|
|
return Interchange;
|
|
}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2__["Plugin"]);
|
|
/**
|
|
* Default settings for plugin
|
|
*/
|
|
|
|
|
|
Interchange.defaults = {
|
|
/**
|
|
* Rules to be applied to Interchange elements. Set with the `data-interchange` array notation.
|
|
* @option
|
|
* @type {?array}
|
|
* @default null
|
|
*/
|
|
rules: null
|
|
};
|
|
Interchange.SPECIAL_QUERIES = {
|
|
'landscape': 'screen and (orientation: landscape)',
|
|
'portrait': 'screen and (orientation: portrait)',
|
|
'retina': 'only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx)'
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 7:
|
|
/*!************************************************************!*\
|
|
!*** multi ./js/entries/plugins/foundation.interchange.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.interchange.js */"./js/entries/plugins/foundation.interchange.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.interchange.js.map
|