/*! * bespoke-jumpy v1.0.1 * * Copyright 2021, Joel Purra * This content is released under the MIT license * https://joelpurra.mit-license.org/2013-2014 */ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self);var o=n;o=o.bespoke||(o.bespoke={}),o=o.plugins||(o.plugins={}),o.jumpy=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0x9) { result -= 0x30; } return result; }, isDigitKey = function(which) { var result = (which >= 0x30 && which <= 0x39) || (which >= 0x60 && which <= 0x69); return result; }, unboundDeckMethods = { // Plugin functions expect to be executed in a deck context firstIndex: function() { var index = 0; return index; }, lastIndex: function() { var index = Math.max(0, this.slides.length - 1); return index; }, first: function(customData) { var index = this.firstIndex(), result = cv.fire(this, "first", null, index, customData) && this.slide(index, customData); return result; }, last: function(customData) { var index = this.lastIndex(), result = cv.fire(this, "last", null, index, customData) && this.slide(index, customData); return result; } }, plugin = function(options) { var decker = function(deck) { var publicDeckMethods = ["firstIndex", "lastIndex", "first", "last"], original = {}, registerDeckExtensions = function() { // Bind fire to the deck instance, so it doesn't have to be passed all the time. // Works in the browser, but doesn't pass jasmine tests. // Could be another problem with phantom-polyfill.js. // TODO: re-test bound fire in the future. //original.fire = cv.fire; //cv.fire = cv.fire.bind(cv, deck); publicDeckMethods.forEach(function(methodName) { original[methodName] = deck[methodName]; deck[methodName] = unboundDeckMethods[methodName].bind(deck); }); }, keyDownListener = function(e) { var eventHandled = false, digit, index; if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return false; } eventHandled = eventHandled || (e.which === KeyConstants.END && cv.fire(deck, "end", e) && !deck.last()); eventHandled = eventHandled || (e.which === KeyConstants.HOME && cv.fire(deck, "home", e) && !deck.first()); if (isDigitKey(e.which)) { // TODO: support multi-digit slide numbers with a timeout digit = getDigit(e.which); index = (digit - 1 + 10) % 10; eventHandled = eventHandled || (cv.fire(deck, "jump", e, index) && !deck.slide(index)); } if (eventHandled) { e.preventDefault(); } return !eventHandled; }, enable = function() { document.addEventListener("keydown", keyDownListener, false); }, init = function() { registerDeckExtensions(); enable(); }; init(); }; return decker; }; module.exports = plugin; },{}]},{},[1]) (1) });