foundation.orbit.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("./foundation.core"), require("./foundation.util.imageLoader"), require("./foundation.util.keyboard"), require("./foundation.util.motion"), require("./foundation.util.timer"), require("./foundation.util.touch"), require("jquery"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["./foundation.core", "./foundation.util.imageLoader", "./foundation.util.keyboard", "./foundation.util.motion", "./foundation.util.timer", "./foundation.util.touch", "jquery"], factory);
  6. else if(typeof exports === 'object')
  7. exports["foundation.orbit"] = factory(require("./foundation.core"), require("./foundation.util.imageLoader"), require("./foundation.util.keyboard"), require("./foundation.util.motion"), require("./foundation.util.timer"), require("./foundation.util.touch"), require("jquery"));
  8. else
  9. root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.orbit"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.imageLoader"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.timer"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.touch"], root["jQuery"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_util_imageLoader__, __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __WEBPACK_EXTERNAL_MODULE__foundation_util_timer__, __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__, __WEBPACK_EXTERNAL_MODULE_jquery__) {
  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 = 10);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "./foundation.core":
  99. /*!****************************************************************************************************************************************************************!*\
  100. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
  101. \****************************************************************************************************************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
  105. /***/ }),
  106. /***/ "./foundation.util.imageLoader":
  107. /*!****************************************************************************************************************************************************************************************************************!*\
  108. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.imageLoader"],"amd":"./foundation.util.imageLoader","commonjs":"./foundation.util.imageLoader","commonjs2":"./foundation.util.imageLoader"} ***!
  109. \****************************************************************************************************************************************************************************************************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports) {
  112. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_imageLoader__;
  113. /***/ }),
  114. /***/ "./foundation.util.keyboard":
  115. /*!****************************************************************************************************************************************************************************************************!*\
  116. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.keyboard"],"amd":"./foundation.util.keyboard","commonjs":"./foundation.util.keyboard","commonjs2":"./foundation.util.keyboard"} ***!
  117. \****************************************************************************************************************************************************************************************************/
  118. /*! no static exports found */
  119. /***/ (function(module, exports) {
  120. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__;
  121. /***/ }),
  122. /***/ "./foundation.util.motion":
  123. /*!********************************************************************************************************************************************************************************************!*\
  124. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
  125. \********************************************************************************************************************************************************************************************/
  126. /*! no static exports found */
  127. /***/ (function(module, exports) {
  128. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
  129. /***/ }),
  130. /***/ "./foundation.util.timer":
  131. /*!****************************************************************************************************************************************************************************************!*\
  132. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.timer"],"amd":"./foundation.util.timer","commonjs":"./foundation.util.timer","commonjs2":"./foundation.util.timer"} ***!
  133. \****************************************************************************************************************************************************************************************/
  134. /*! no static exports found */
  135. /***/ (function(module, exports) {
  136. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_timer__;
  137. /***/ }),
  138. /***/ "./foundation.util.touch":
  139. /*!****************************************************************************************************************************************************************************************!*\
  140. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.touch"],"amd":"./foundation.util.touch","commonjs":"./foundation.util.touch","commonjs2":"./foundation.util.touch"} ***!
  141. \****************************************************************************************************************************************************************************************/
  142. /*! no static exports found */
  143. /***/ (function(module, exports) {
  144. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__;
  145. /***/ }),
  146. /***/ "./js/entries/plugins/foundation.orbit.js":
  147. /*!************************************************!*\
  148. !*** ./js/entries/plugins/foundation.orbit.js ***!
  149. \************************************************/
  150. /*! exports provided: Foundation, Orbit */
  151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  152. "use strict";
  153. __webpack_require__.r(__webpack_exports__);
  154. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
  155. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
  156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
  157. /* harmony import */ var _foundation_orbit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.orbit */ "./js/foundation.orbit.js");
  158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orbit", function() { return _foundation_orbit__WEBPACK_IMPORTED_MODULE_1__["Orbit"]; });
  159. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_orbit__WEBPACK_IMPORTED_MODULE_1__["Orbit"], 'Orbit');
  160. /***/ }),
  161. /***/ "./js/foundation.orbit.js":
  162. /*!********************************!*\
  163. !*** ./js/foundation.orbit.js ***!
  164. \********************************/
  165. /*! exports provided: Orbit */
  166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  167. "use strict";
  168. __webpack_require__.r(__webpack_exports__);
  169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orbit", function() { return Orbit; });
  170. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  171. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  172. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
  173. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__);
  174. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
  175. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
  176. /* harmony import */ var _foundation_util_timer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.timer */ "./foundation.util.timer");
  177. /* harmony import */ var _foundation_util_timer__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_timer__WEBPACK_IMPORTED_MODULE_3__);
  178. /* harmony import */ var _foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.util.imageLoader */ "./foundation.util.imageLoader");
  179. /* harmony import */ var _foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_4__);
  180. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  181. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_5__);
  182. /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./foundation.util.touch */ "./foundation.util.touch");
  183. /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_touch__WEBPACK_IMPORTED_MODULE_6__);
  184. 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); }
  185. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  186. 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); } }
  187. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  188. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  189. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  190. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  191. 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); }
  192. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  193. /**
  194. * Orbit module.
  195. * @module foundation.orbit
  196. * @requires foundation.util.keyboard
  197. * @requires foundation.util.motion
  198. * @requires foundation.util.timer
  199. * @requires foundation.util.imageLoader
  200. * @requires foundation.util.touch
  201. */
  202. var Orbit =
  203. /*#__PURE__*/
  204. function (_Plugin) {
  205. _inherits(Orbit, _Plugin);
  206. function Orbit() {
  207. _classCallCheck(this, Orbit);
  208. return _possibleConstructorReturn(this, _getPrototypeOf(Orbit).apply(this, arguments));
  209. }
  210. _createClass(Orbit, [{
  211. key: "_setup",
  212. /**
  213. * Creates a new instance of an orbit carousel.
  214. * @class
  215. * @name Orbit
  216. * @param {jQuery} element - jQuery object to make into an Orbit Carousel.
  217. * @param {Object} options - Overrides to the default plugin settings.
  218. */
  219. value: function _setup(element, options) {
  220. this.$element = element;
  221. this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Orbit.defaults, this.$element.data(), options);
  222. this.className = 'Orbit'; // ie9 back compat
  223. _foundation_util_touch__WEBPACK_IMPORTED_MODULE_6__["Touch"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a); // Touch init is idempotent, we just need to make sure it's initialied.
  224. this._init();
  225. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].register('Orbit', {
  226. 'ltr': {
  227. 'ARROW_RIGHT': 'next',
  228. 'ARROW_LEFT': 'previous'
  229. },
  230. 'rtl': {
  231. 'ARROW_LEFT': 'next',
  232. 'ARROW_RIGHT': 'previous'
  233. }
  234. });
  235. }
  236. /**
  237. * Initializes the plugin by creating jQuery collections, setting attributes, and starting the animation.
  238. * @function
  239. * @private
  240. */
  241. }, {
  242. key: "_init",
  243. value: function _init() {
  244. // @TODO: consider discussion on PR #9278 about DOM pollution by changeSlide
  245. this._reset();
  246. this.$wrapper = this.$element.find(".".concat(this.options.containerClass));
  247. this.$slides = this.$element.find(".".concat(this.options.slideClass));
  248. var $images = this.$element.find('img'),
  249. initActive = this.$slides.filter('.is-active'),
  250. id = this.$element[0].id || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_5__["GetYoDigits"])(6, 'orbit');
  251. this.$element.attr({
  252. 'data-resize': id,
  253. 'id': id
  254. });
  255. if (!initActive.length) {
  256. this.$slides.eq(0).addClass('is-active');
  257. }
  258. if (!this.options.useMUI) {
  259. this.$slides.addClass('no-motionui');
  260. }
  261. if ($images.length) {
  262. Object(_foundation_util_imageLoader__WEBPACK_IMPORTED_MODULE_4__["onImagesLoaded"])($images, this._prepareForOrbit.bind(this));
  263. } else {
  264. this._prepareForOrbit(); //hehe
  265. }
  266. if (this.options.bullets) {
  267. this._loadBullets();
  268. }
  269. this._events();
  270. if (this.options.autoPlay && this.$slides.length > 1) {
  271. this.geoSync();
  272. }
  273. if (this.options.accessible) {
  274. // allow wrapper to be focusable to enable arrow navigation
  275. this.$wrapper.attr('tabindex', 0);
  276. }
  277. }
  278. /**
  279. * Creates a jQuery collection of bullets, if they are being used.
  280. * @function
  281. * @private
  282. */
  283. }, {
  284. key: "_loadBullets",
  285. value: function _loadBullets() {
  286. this.$bullets = this.$element.find(".".concat(this.options.boxOfBullets)).find('button');
  287. }
  288. /**
  289. * Sets a `timer` object on the orbit, and starts the counter for the next slide.
  290. * @function
  291. */
  292. }, {
  293. key: "geoSync",
  294. value: function geoSync() {
  295. var _this = this;
  296. this.timer = new _foundation_util_timer__WEBPACK_IMPORTED_MODULE_3__["Timer"](this.$element, {
  297. duration: this.options.timerDelay,
  298. infinite: false
  299. }, function () {
  300. _this.changeSlide(true);
  301. });
  302. this.timer.start();
  303. }
  304. /**
  305. * Sets wrapper and slide heights for the orbit.
  306. * @function
  307. * @private
  308. */
  309. }, {
  310. key: "_prepareForOrbit",
  311. value: function _prepareForOrbit() {
  312. var _this = this;
  313. this._setWrapperHeight();
  314. }
  315. /**
  316. * Calulates the height of each slide in the collection, and uses the tallest one for the wrapper height.
  317. * @function
  318. * @private
  319. * @param {Function} cb - a callback function to fire when complete.
  320. */
  321. }, {
  322. key: "_setWrapperHeight",
  323. value: function _setWrapperHeight(cb) {
  324. //rewrite this to `for` loop
  325. var max = 0,
  326. temp,
  327. counter = 0,
  328. _this = this;
  329. this.$slides.each(function () {
  330. temp = this.getBoundingClientRect().height;
  331. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).attr('data-slide', counter); // hide all slides but the active one
  332. if (!/mui/g.test(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)[0].className) && _this.$slides.filter('.is-active')[0] !== _this.$slides.eq(counter)[0]) {
  333. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).css({
  334. 'display': 'none'
  335. });
  336. }
  337. max = temp > max ? temp : max;
  338. counter++;
  339. });
  340. if (counter === this.$slides.length) {
  341. this.$wrapper.css({
  342. 'height': max
  343. }); //only change the wrapper height property once.
  344. if (cb) {
  345. cb(max);
  346. } //fire callback with max height dimension.
  347. }
  348. }
  349. /**
  350. * Sets the max-height of each slide.
  351. * @function
  352. * @private
  353. */
  354. }, {
  355. key: "_setSlideHeight",
  356. value: function _setSlideHeight(height) {
  357. this.$slides.each(function () {
  358. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).css('max-height', height);
  359. });
  360. }
  361. /**
  362. * Adds event listeners to basically everything within the element.
  363. * @function
  364. * @private
  365. */
  366. }, {
  367. key: "_events",
  368. value: function _events() {
  369. var _this = this; //***************************************
  370. //**Now using custom event - thanks to:**
  371. //** Yohai Ararat of Toronto **
  372. //***************************************
  373. //
  374. this.$element.off('.resizeme.zf.trigger').on({
  375. 'resizeme.zf.trigger': this._prepareForOrbit.bind(this)
  376. });
  377. if (this.$slides.length > 1) {
  378. if (this.options.swipe) {
  379. this.$slides.off('swipeleft.zf.orbit swiperight.zf.orbit').on('swipeleft.zf.orbit', function (e) {
  380. e.preventDefault();
  381. _this.changeSlide(true);
  382. }).on('swiperight.zf.orbit', function (e) {
  383. e.preventDefault();
  384. _this.changeSlide(false);
  385. });
  386. } //***************************************
  387. if (this.options.autoPlay) {
  388. this.$slides.on('click.zf.orbit', function () {
  389. _this.$element.data('clickedOn', _this.$element.data('clickedOn') ? false : true);
  390. _this.timer[_this.$element.data('clickedOn') ? 'pause' : 'start']();
  391. });
  392. if (this.options.pauseOnHover) {
  393. this.$element.on('mouseenter.zf.orbit', function () {
  394. _this.timer.pause();
  395. }).on('mouseleave.zf.orbit', function () {
  396. if (!_this.$element.data('clickedOn')) {
  397. _this.timer.start();
  398. }
  399. });
  400. }
  401. }
  402. if (this.options.navButtons) {
  403. var $controls = this.$element.find(".".concat(this.options.nextClass, ", .").concat(this.options.prevClass));
  404. $controls.attr('tabindex', 0) //also need to handle enter/return and spacebar key presses
  405. .on('click.zf.orbit touchend.zf.orbit', function (e) {
  406. e.preventDefault();
  407. _this.changeSlide(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).hasClass(_this.options.nextClass));
  408. });
  409. }
  410. if (this.options.bullets) {
  411. this.$bullets.on('click.zf.orbit touchend.zf.orbit', function () {
  412. if (/is-active/g.test(this.className)) {
  413. return false;
  414. } //if this is active, kick out of function.
  415. var idx = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('slide'),
  416. ltr = idx > _this.$slides.filter('.is-active').data('slide'),
  417. $slide = _this.$slides.eq(idx);
  418. _this.changeSlide(ltr, $slide, idx);
  419. });
  420. }
  421. if (this.options.accessible) {
  422. this.$wrapper.add(this.$bullets).on('keydown.zf.orbit', function (e) {
  423. // handle keyboard event with keyboard util
  424. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].handleKey(e, 'Orbit', {
  425. next: function next() {
  426. _this.changeSlide(true);
  427. },
  428. previous: function previous() {
  429. _this.changeSlide(false);
  430. },
  431. handled: function handled() {
  432. // if bullet is focused, make sure focus moves
  433. if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target).is(_this.$bullets)) {
  434. _this.$bullets.filter('.is-active').focus();
  435. }
  436. }
  437. });
  438. });
  439. }
  440. }
  441. }
  442. /**
  443. * Resets Orbit so it can be reinitialized
  444. */
  445. }, {
  446. key: "_reset",
  447. value: function _reset() {
  448. // Don't do anything if there are no slides (first run)
  449. if (typeof this.$slides == 'undefined') {
  450. return;
  451. }
  452. if (this.$slides.length > 1) {
  453. // Remove old events
  454. this.$element.off('.zf.orbit').find('*').off('.zf.orbit'); // Restart timer if autoPlay is enabled
  455. if (this.options.autoPlay) {
  456. this.timer.restart();
  457. } // Reset all sliddes
  458. this.$slides.each(function (el) {
  459. jquery__WEBPACK_IMPORTED_MODULE_0___default()(el).removeClass('is-active is-active is-in').removeAttr('aria-live').hide();
  460. }); // Show the first slide
  461. this.$slides.first().addClass('is-active').show(); // Triggers when the slide has finished animating
  462. this.$element.trigger('slidechange.zf.orbit', [this.$slides.first()]); // Select first bullet if bullets are present
  463. if (this.options.bullets) {
  464. this._updateBullets(0);
  465. }
  466. }
  467. }
  468. /**
  469. * Changes the current slide to a new one.
  470. * @function
  471. * @param {Boolean} isLTR - if true the slide moves from right to left, if false the slide moves from left to right.
  472. * @param {jQuery} chosenSlide - the jQuery element of the slide to show next, if one is selected.
  473. * @param {Number} idx - the index of the new slide in its collection, if one chosen.
  474. * @fires Orbit#slidechange
  475. */
  476. }, {
  477. key: "changeSlide",
  478. value: function changeSlide(isLTR, chosenSlide, idx) {
  479. if (!this.$slides) {
  480. return;
  481. } // Don't freak out if we're in the middle of cleanup
  482. var $curSlide = this.$slides.filter('.is-active').eq(0);
  483. if (/mui/g.test($curSlide[0].className)) {
  484. return false;
  485. } //if the slide is currently animating, kick out of the function
  486. var $firstSlide = this.$slides.first(),
  487. $lastSlide = this.$slides.last(),
  488. dirIn = isLTR ? 'Right' : 'Left',
  489. dirOut = isLTR ? 'Left' : 'Right',
  490. _this = this,
  491. $newSlide;
  492. if (!chosenSlide) {
  493. //most of the time, this will be auto played or clicked from the navButtons.
  494. $newSlide = isLTR ? //if wrapping enabled, check to see if there is a `next` or `prev` sibling, if not, select the first or last slide to fill in. if wrapping not enabled, attempt to select `next` or `prev`, if there's nothing there, the function will kick out on next step. CRAZY NESTED TERNARIES!!!!!
  495. this.options.infiniteWrap ? $curSlide.next(".".concat(this.options.slideClass)).length ? $curSlide.next(".".concat(this.options.slideClass)) : $firstSlide : $curSlide.next(".".concat(this.options.slideClass)) : //pick next slide if moving left to right
  496. this.options.infiniteWrap ? $curSlide.prev(".".concat(this.options.slideClass)).length ? $curSlide.prev(".".concat(this.options.slideClass)) : $lastSlide : $curSlide.prev(".".concat(this.options.slideClass)); //pick prev slide if moving right to left
  497. } else {
  498. $newSlide = chosenSlide;
  499. }
  500. if ($newSlide.length) {
  501. /**
  502. * Triggers before the next slide starts animating in and only if a next slide has been found.
  503. * @event Orbit#beforeslidechange
  504. */
  505. this.$element.trigger('beforeslidechange.zf.orbit', [$curSlide, $newSlide]);
  506. if (this.options.bullets) {
  507. idx = idx || this.$slides.index($newSlide); //grab index to update bullets
  508. this._updateBullets(idx);
  509. }
  510. if (this.options.useMUI && !this.$element.is(':hidden')) {
  511. _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateIn($newSlide.addClass('is-active'), this.options["animInFrom".concat(dirIn)], function () {
  512. $newSlide.css({
  513. 'display': 'block'
  514. }).attr('aria-live', 'polite');
  515. });
  516. _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut($curSlide.removeClass('is-active'), this.options["animOutTo".concat(dirOut)], function () {
  517. $curSlide.removeAttr('aria-live');
  518. if (_this.options.autoPlay && !_this.timer.isPaused) {
  519. _this.timer.restart();
  520. } //do stuff?
  521. });
  522. } else {
  523. $curSlide.removeClass('is-active is-in').removeAttr('aria-live').hide();
  524. $newSlide.addClass('is-active is-in').attr('aria-live', 'polite').show();
  525. if (this.options.autoPlay && !this.timer.isPaused) {
  526. this.timer.restart();
  527. }
  528. }
  529. /**
  530. * Triggers when the slide has finished animating in.
  531. * @event Orbit#slidechange
  532. */
  533. this.$element.trigger('slidechange.zf.orbit', [$newSlide]);
  534. }
  535. }
  536. /**
  537. * Updates the active state of the bullets, if displayed.
  538. * Move the descriptor of the current slide `[data-slide-active-label]` to the newly active bullet.
  539. * If no `[data-slide-active-label]` is set, will move the exceeding `span` element.
  540. *
  541. * @function
  542. * @private
  543. * @param {Number} idx - the index of the current slide.
  544. */
  545. }, {
  546. key: "_updateBullets",
  547. value: function _updateBullets(idx) {
  548. var $oldBullet = this.$bullets.filter('.is-active');
  549. var $othersBullets = this.$bullets.not('.is-active');
  550. var $newBullet = this.$bullets.eq(idx);
  551. $oldBullet.removeClass('is-active').blur();
  552. $newBullet.addClass('is-active'); // Find the descriptor for the current slide to move it to the new slide button
  553. var activeStateDescriptor = $oldBullet.children('[data-slide-active-label]').last(); // If not explicitely given, search for the last "exceeding" span element (compared to others bullets).
  554. if (!activeStateDescriptor.length) {
  555. var spans = $oldBullet.children('span');
  556. var spanCountInOthersBullets = $othersBullets.toArray().map(function (b) {
  557. return jquery__WEBPACK_IMPORTED_MODULE_0___default()(b).children('span').length;
  558. }); // If there is an exceeding span element, use it as current slide descriptor
  559. if (spanCountInOthersBullets.every(function (count) {
  560. return count < spans.length;
  561. })) {
  562. activeStateDescriptor = spans.last();
  563. activeStateDescriptor.attr('data-slide-active-label', '');
  564. }
  565. } // Move the current slide descriptor to the new slide button
  566. if (activeStateDescriptor.length) {
  567. activeStateDescriptor.detach();
  568. $newBullet.append(activeStateDescriptor);
  569. }
  570. }
  571. /**
  572. * Destroys the carousel and hides the element.
  573. * @function
  574. */
  575. }, {
  576. key: "_destroy",
  577. value: function _destroy() {
  578. this.$element.off('.zf.orbit').find('*').off('.zf.orbit').end().hide();
  579. }
  580. }]);
  581. return Orbit;
  582. }(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_5__["Plugin"]);
  583. Orbit.defaults = {
  584. /**
  585. * Tells the JS to look for and loadBullets.
  586. * @option
  587. * @type {boolean}
  588. * @default true
  589. */
  590. bullets: true,
  591. /**
  592. * Tells the JS to apply event listeners to nav buttons
  593. * @option
  594. * @type {boolean}
  595. * @default true
  596. */
  597. navButtons: true,
  598. /**
  599. * motion-ui animation class to apply
  600. * @option
  601. * @type {string}
  602. * @default 'slide-in-right'
  603. */
  604. animInFromRight: 'slide-in-right',
  605. /**
  606. * motion-ui animation class to apply
  607. * @option
  608. * @type {string}
  609. * @default 'slide-out-right'
  610. */
  611. animOutToRight: 'slide-out-right',
  612. /**
  613. * motion-ui animation class to apply
  614. * @option
  615. * @type {string}
  616. * @default 'slide-in-left'
  617. *
  618. */
  619. animInFromLeft: 'slide-in-left',
  620. /**
  621. * motion-ui animation class to apply
  622. * @option
  623. * @type {string}
  624. * @default 'slide-out-left'
  625. */
  626. animOutToLeft: 'slide-out-left',
  627. /**
  628. * Allows Orbit to automatically animate on page load.
  629. * @option
  630. * @type {boolean}
  631. * @default true
  632. */
  633. autoPlay: true,
  634. /**
  635. * Amount of time, in ms, between slide transitions
  636. * @option
  637. * @type {number}
  638. * @default 5000
  639. */
  640. timerDelay: 5000,
  641. /**
  642. * Allows Orbit to infinitely loop through the slides
  643. * @option
  644. * @type {boolean}
  645. * @default true
  646. */
  647. infiniteWrap: true,
  648. /**
  649. * Allows the Orbit slides to bind to swipe events for mobile, requires an additional util library
  650. * @option
  651. * @type {boolean}
  652. * @default true
  653. */
  654. swipe: true,
  655. /**
  656. * Allows the timing function to pause animation on hover.
  657. * @option
  658. * @type {boolean}
  659. * @default true
  660. */
  661. pauseOnHover: true,
  662. /**
  663. * Allows Orbit to bind keyboard events to the slider, to animate frames with arrow keys
  664. * @option
  665. * @type {boolean}
  666. * @default true
  667. */
  668. accessible: true,
  669. /**
  670. * Class applied to the container of Orbit
  671. * @option
  672. * @type {string}
  673. * @default 'orbit-container'
  674. */
  675. containerClass: 'orbit-container',
  676. /**
  677. * Class applied to individual slides.
  678. * @option
  679. * @type {string}
  680. * @default 'orbit-slide'
  681. */
  682. slideClass: 'orbit-slide',
  683. /**
  684. * Class applied to the bullet container. You're welcome.
  685. * @option
  686. * @type {string}
  687. * @default 'orbit-bullets'
  688. */
  689. boxOfBullets: 'orbit-bullets',
  690. /**
  691. * Class applied to the `next` navigation button.
  692. * @option
  693. * @type {string}
  694. * @default 'orbit-next'
  695. */
  696. nextClass: 'orbit-next',
  697. /**
  698. * Class applied to the `previous` navigation button.
  699. * @option
  700. * @type {string}
  701. * @default 'orbit-previous'
  702. */
  703. prevClass: 'orbit-previous',
  704. /**
  705. * Boolean to flag the js to use motion ui classes or not. Default to true for backwards compatibility.
  706. * @option
  707. * @type {boolean}
  708. * @default true
  709. */
  710. useMUI: true
  711. };
  712. /***/ }),
  713. /***/ 10:
  714. /*!******************************************************!*\
  715. !*** multi ./js/entries/plugins/foundation.orbit.js ***!
  716. \******************************************************/
  717. /*! no static exports found */
  718. /***/ (function(module, exports, __webpack_require__) {
  719. module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.orbit.js */"./js/entries/plugins/foundation.orbit.js");
  720. /***/ }),
  721. /***/ "jquery":
  722. /*!********************************************************************************************!*\
  723. !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
  724. \********************************************************************************************/
  725. /*! no static exports found */
  726. /***/ (function(module, exports) {
  727. module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
  728. /***/ })
  729. /******/ });
  730. });
  731. //# sourceMappingURL=foundation.orbit.js.map