Add files
This commit is contained in:
commit
bb80829159
18195 changed files with 2122994 additions and 0 deletions
104
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/index.js
generated
Executable file
104
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/index.js
generated
Executable file
|
@ -0,0 +1,104 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
module.exports = function (element) {
|
||||
var self = this
|
||||
var Combokeys = self.constructor
|
||||
|
||||
/**
|
||||
* a list of all the callbacks setup via Combokeys.bind()
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
self.callbacks = {}
|
||||
|
||||
/**
|
||||
* direct map of string combinations to callbacks used for trigger()
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
self.directMap = {}
|
||||
|
||||
/**
|
||||
* keeps track of what level each sequence is at since multiple
|
||||
* sequences can start out with the same sequence
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
self.sequenceLevels = {}
|
||||
|
||||
/**
|
||||
* variable to store the setTimeout call
|
||||
*
|
||||
* @type {null|number}
|
||||
*/
|
||||
self.resetTimer
|
||||
|
||||
/**
|
||||
* temporary state where we will ignore the next keyup
|
||||
*
|
||||
* @type {boolean|string}
|
||||
*/
|
||||
self.ignoreNextKeyup = false
|
||||
|
||||
/**
|
||||
* temporary state where we will ignore the next keypress
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
self.ignoreNextKeypress = false
|
||||
|
||||
/**
|
||||
* are we currently inside of a sequence?
|
||||
* type of action ("keyup" or "keydown" or "keypress") or false
|
||||
*
|
||||
* @type {boolean|string}
|
||||
*/
|
||||
self.nextExpectedAction = false
|
||||
|
||||
self.element = element
|
||||
|
||||
self.addEvents()
|
||||
|
||||
Combokeys.instances.push(self)
|
||||
return self
|
||||
}
|
||||
|
||||
module.exports.prototype.bind = require('./prototype/bind')
|
||||
module.exports.prototype.bindMultiple = require('./prototype/bindMultiple')
|
||||
module.exports.prototype.unbind = require('./prototype/unbind')
|
||||
module.exports.prototype.trigger = require('./prototype/trigger')
|
||||
module.exports.prototype.reset = require('./prototype/reset.js')
|
||||
module.exports.prototype.stopCallback = require('./prototype/stopCallback')
|
||||
module.exports.prototype.handleKey = require('./prototype/handleKey')
|
||||
module.exports.prototype.addEvents = require('./prototype/addEvents')
|
||||
module.exports.prototype.bindSingle = require('./prototype/bindSingle')
|
||||
module.exports.prototype.getKeyInfo = require('./prototype/getKeyInfo')
|
||||
module.exports.prototype.pickBestAction = require('./prototype/pickBestAction')
|
||||
module.exports.prototype.getReverseMap = require('./prototype/getReverseMap')
|
||||
module.exports.prototype.getMatches = require('./prototype/getMatches')
|
||||
module.exports.prototype.resetSequences = require('./prototype/resetSequences')
|
||||
module.exports.prototype.fireCallback = require('./prototype/fireCallback')
|
||||
module.exports.prototype.bindSequence = require('./prototype/bindSequence')
|
||||
module.exports.prototype.resetSequenceTimer = require('./prototype/resetSequenceTimer')
|
||||
module.exports.prototype.detach = require('./prototype/detach')
|
||||
|
||||
module.exports.instances = []
|
||||
module.exports.reset = require('./reset')
|
||||
|
||||
/**
|
||||
* variable to store the flipped version of MAP from above
|
||||
* needed to check if we should use keypress or not when no action
|
||||
* is specified
|
||||
*
|
||||
* @type {Object|undefined}
|
||||
*/
|
||||
module.exports.REVERSE_MAP = null
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/index.js
|
||||
// module id = 343
|
||||
// module chunks = 4
|
21
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/addEvents.js
generated
vendored
Executable file
21
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/addEvents.js
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
module.exports = function () {
|
||||
var self = this
|
||||
var on = require('./dom-event')
|
||||
var element = self.element
|
||||
|
||||
self.eventHandler = require('./handleKeyEvent').bind(self)
|
||||
|
||||
on(element, 'keypress', self.eventHandler)
|
||||
on(element, 'keydown', self.eventHandler)
|
||||
on(element, 'keyup', self.eventHandler)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/addEvents.js
|
||||
// module id = 1742
|
||||
// module chunks = 4
|
31
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bind.js
generated
vendored
Executable file
31
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bind.js
generated
vendored
Executable file
|
@ -0,0 +1,31 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
/**
|
||||
* binds an event to Combokeys
|
||||
*
|
||||
* can be a single key, a combination of keys separated with +,
|
||||
* an array of keys, or a sequence of keys separated by spaces
|
||||
*
|
||||
* be sure to list the modifier keys first to make sure that the
|
||||
* correct key ends up getting bound (the last key in the pattern)
|
||||
*
|
||||
* @param {string|Array} keys
|
||||
* @param {Function} callback
|
||||
* @param {string=} action - "keypress", "keydown", or "keyup"
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (keys, callback, action) {
|
||||
var self = this
|
||||
|
||||
keys = keys instanceof Array ? keys : [keys]
|
||||
self.bindMultiple(keys, callback, action)
|
||||
return self
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/bind.js
|
||||
// module id = 1743
|
||||
// module chunks = 4
|
26
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bindMultiple.js
generated
vendored
Executable file
26
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bindMultiple.js
generated
vendored
Executable file
|
@ -0,0 +1,26 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* binds multiple combinations to the same callback
|
||||
*
|
||||
* @param {Array} combinations
|
||||
* @param {Function} callback
|
||||
* @param {string|undefined} action
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (combinations, callback, action) {
|
||||
var self = this
|
||||
|
||||
for (var j = 0; j < combinations.length; ++j) {
|
||||
self.bindSingle(combinations[j], callback, action)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/bindMultiple.js
|
||||
// module id = 1744
|
||||
// module chunks = 4
|
86
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bindSequence.js
generated
vendored
Executable file
86
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bindSequence.js
generated
vendored
Executable file
|
@ -0,0 +1,86 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* binds a key sequence to an event
|
||||
*
|
||||
* @param {string} combo - combo specified in bind call
|
||||
* @param {Array} keys
|
||||
* @param {Function} callback
|
||||
* @param {string=} action
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (combo, keys, callback, action) {
|
||||
var self = this
|
||||
|
||||
// start off by adding a sequence level record for this combination
|
||||
// and setting the level to 0
|
||||
self.sequenceLevels[combo] = 0
|
||||
|
||||
/**
|
||||
* callback to increase the sequence level for this sequence and reset
|
||||
* all other sequences that were active
|
||||
*
|
||||
* @param {string} nextAction
|
||||
* @returns {Function}
|
||||
*/
|
||||
function increaseSequence (nextAction) {
|
||||
return function () {
|
||||
self.nextExpectedAction = nextAction
|
||||
++self.sequenceLevels[combo]
|
||||
self.resetSequenceTimer()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wraps the specified callback inside of another function in order
|
||||
* to reset all sequence counters as soon as this sequence is done
|
||||
*
|
||||
* @param {Event} e
|
||||
* @returns void
|
||||
*/
|
||||
function callbackAndReset (e) {
|
||||
var characterFromEvent
|
||||
self.fireCallback(callback, e, combo)
|
||||
|
||||
// we should ignore the next key up if the action is key down
|
||||
// or keypress. this is so if you finish a sequence and
|
||||
// release the key the final key will not trigger a keyup
|
||||
if (action !== 'keyup') {
|
||||
characterFromEvent = require('../../helpers/characterFromEvent')
|
||||
self.ignoreNextKeyup = characterFromEvent(e)
|
||||
}
|
||||
|
||||
// weird race condition if a sequence ends with the key
|
||||
// another sequence begins with
|
||||
setTimeout(
|
||||
function () {
|
||||
self.resetSequences()
|
||||
},
|
||||
10
|
||||
)
|
||||
}
|
||||
|
||||
// loop through keys one at a time and bind the appropriate callback
|
||||
// function. for any key leading up to the final one it should
|
||||
// increase the sequence. after the final, it should reset all sequences
|
||||
//
|
||||
// if an action is specified in the original bind call then that will
|
||||
// be used throughout. otherwise we will pass the action that the
|
||||
// next key in the sequence should match. this allows a sequence
|
||||
// to mix and match keypress and keydown events depending on which
|
||||
// ones are better suited to the key provided
|
||||
for (var j = 0; j < keys.length; ++j) {
|
||||
var isFinal = j + 1 === keys.length
|
||||
var wrappedCallback = isFinal ? callbackAndReset : increaseSequence(action || self.getKeyInfo(keys[j + 1]).action)
|
||||
self.bindSingle(keys[j], wrappedCallback, action, combo, j)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/bindSequence.js
|
||||
// module id = 1745
|
||||
// module chunks = 4
|
64
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bindSingle.js
generated
vendored
Executable file
64
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/bindSingle.js
generated
vendored
Executable file
|
@ -0,0 +1,64 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* binds a single keyboard combination
|
||||
*
|
||||
* @param {string} combination
|
||||
* @param {Function} callback
|
||||
* @param {string=} action
|
||||
* @param {string=} sequenceName - name of sequence if part of sequence
|
||||
* @param {number=} level - what part of the sequence the command is
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (combination, callback, action, sequenceName, level) {
|
||||
var self = this
|
||||
|
||||
// store a direct mapped reference for use with Combokeys.trigger
|
||||
self.directMap[combination + ':' + action] = callback
|
||||
|
||||
// make sure multiple spaces in a row become a single space
|
||||
combination = combination.replace(/\s+/g, ' ')
|
||||
|
||||
var sequence = combination.split(' ')
|
||||
var info
|
||||
|
||||
// if this pattern is a sequence of keys then run through this method
|
||||
// to reprocess each pattern one key at a time
|
||||
if (sequence.length > 1) {
|
||||
self.bindSequence(combination, sequence, callback, action)
|
||||
return
|
||||
}
|
||||
|
||||
info = self.getKeyInfo(combination, action)
|
||||
|
||||
// make sure to initialize array if this is the first time
|
||||
// a callback is added for this key
|
||||
self.callbacks[info.key] = self.callbacks[info.key] || []
|
||||
|
||||
// remove an existing match if there is one
|
||||
self.getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level)
|
||||
|
||||
// add this call back to the array
|
||||
// if it is a sequence put it at the beginning
|
||||
// if not put it at the end
|
||||
//
|
||||
// this is important because the way these are processed expects
|
||||
// the sequence ones to come first
|
||||
self.callbacks[info.key][sequenceName ? 'unshift' : 'push']({
|
||||
callback: callback,
|
||||
modifiers: info.modifiers,
|
||||
action: info.action,
|
||||
seq: sequenceName,
|
||||
level: level,
|
||||
combo: combination
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/bindSingle.js
|
||||
// module id = 1746
|
||||
// module chunks = 4
|
17
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/detach.js
generated
vendored
Executable file
17
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/detach.js
generated
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
var off = require('./dom-event').off
|
||||
module.exports = function () {
|
||||
var self = this
|
||||
var element = self.element
|
||||
|
||||
off(element, 'keypress', self.eventHandler)
|
||||
off(element, 'keydown', self.eventHandler)
|
||||
off(element, 'keyup', self.eventHandler)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/detach.js
|
||||
// module id = 1747
|
||||
// module chunks = 4
|
23
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/dom-event.js
generated
vendored
Executable file
23
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/dom-event.js
generated
vendored
Executable file
|
@ -0,0 +1,23 @@
|
|||
module.exports = on
|
||||
module.exports.on = on
|
||||
module.exports.off = off
|
||||
|
||||
function on (element, event, callback, capture) {
|
||||
!element.addEventListener && (event = 'on' + event)
|
||||
;(element.addEventListener || element.attachEvent).call(element, event, callback, capture)
|
||||
return callback
|
||||
}
|
||||
|
||||
function off (element, event, callback, capture) {
|
||||
!element.removeEventListener && (event = 'on' + event)
|
||||
;(element.removeEventListener || element.detachEvent).call(element, event, callback, capture)
|
||||
return callback
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/dom-event.js
|
||||
// module id = 859
|
||||
// module chunks = 4
|
38
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/fireCallback.js
generated
vendored
Executable file
38
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/fireCallback.js
generated
vendored
Executable file
|
@ -0,0 +1,38 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* actually calls the callback function
|
||||
*
|
||||
* if your callback function returns false this will use the jquery
|
||||
* convention - prevent default and stop propogation on the event
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @param {Event} e
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (callback, e, combo, sequence) {
|
||||
var self = this
|
||||
var preventDefault
|
||||
var stopPropagation
|
||||
|
||||
// if this event should not happen stop here
|
||||
if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (callback(e, combo) === false) {
|
||||
preventDefault = require('../../helpers/preventDefault')
|
||||
preventDefault(e)
|
||||
stopPropagation = require('../../helpers/stopPropagation')
|
||||
stopPropagation(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/fireCallback.js
|
||||
// module id = 1748
|
||||
// module chunks = 4
|
69
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/getKeyInfo.js
generated
vendored
Executable file
69
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/getKeyInfo.js
generated
vendored
Executable file
|
@ -0,0 +1,69 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Gets info for a specific key combination
|
||||
*
|
||||
* @param {string} combination key combination ("command+s" or "a" or "*")
|
||||
* @param {string=} action
|
||||
* @returns {Object}
|
||||
*/
|
||||
module.exports = function (combination, action) {
|
||||
var self = this
|
||||
var keysFromString
|
||||
var keys
|
||||
var key
|
||||
var j
|
||||
var modifiers = []
|
||||
var SPECIAL_ALIASES
|
||||
var SHIFT_MAP
|
||||
var isModifier
|
||||
|
||||
keysFromString = require('../../helpers/keysFromString')
|
||||
// take the keys from this pattern and figure out what the actual
|
||||
// pattern is all about
|
||||
keys = keysFromString(combination)
|
||||
|
||||
SPECIAL_ALIASES = require('../../helpers/special-aliases')
|
||||
SHIFT_MAP = require('../../helpers/shift-map')
|
||||
isModifier = require('../../helpers/isModifier')
|
||||
for (j = 0; j < keys.length; ++j) {
|
||||
key = keys[j]
|
||||
|
||||
// normalize key names
|
||||
if (SPECIAL_ALIASES[key]) {
|
||||
key = SPECIAL_ALIASES[key]
|
||||
}
|
||||
|
||||
// if this is not a keypress event then we should
|
||||
// be smart about using shift keys
|
||||
// this will only work for US keyboards however
|
||||
if (action && action !== 'keypress' && SHIFT_MAP[key]) {
|
||||
key = SHIFT_MAP[key]
|
||||
modifiers.push('shift')
|
||||
}
|
||||
|
||||
// if this key is a modifier then add it to the list of modifiers
|
||||
if (isModifier(key)) {
|
||||
modifiers.push(key)
|
||||
}
|
||||
}
|
||||
|
||||
// depending on what the key combination is
|
||||
// we will try to pick the best event for it
|
||||
action = self.pickBestAction(key, modifiers, action)
|
||||
|
||||
return {
|
||||
key: key,
|
||||
modifiers: modifiers,
|
||||
action: action
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/getKeyInfo.js
|
||||
// module id = 1749
|
||||
// module chunks = 4
|
95
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/getMatches.js
generated
vendored
Executable file
95
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/getMatches.js
generated
vendored
Executable file
|
@ -0,0 +1,95 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* finds all callbacks that match based on the keycode, modifiers,
|
||||
* and action
|
||||
*
|
||||
* @param {string} character
|
||||
* @param {Array} modifiers
|
||||
* @param {Event|Object} e
|
||||
* @param {string=} sequenceName - name of the sequence we are looking for
|
||||
* @param {string=} combination
|
||||
* @param {number=} level
|
||||
* @returns {Array}
|
||||
*/
|
||||
module.exports = function (character, modifiers, e, sequenceName, combination, level) {
|
||||
var self = this
|
||||
var j
|
||||
var callback
|
||||
var matches = []
|
||||
var action = e.type
|
||||
var isModifier
|
||||
var modifiersMatch
|
||||
|
||||
if (
|
||||
action === 'keypress' &&
|
||||
// Firefox fires keypress for arrows
|
||||
!(e.code && e.code.slice(0, 5) === 'Arrow')
|
||||
) {
|
||||
// 'any-character' callbacks are only on `keypress`
|
||||
var anyCharCallbacks = self.callbacks['any-character'] || []
|
||||
anyCharCallbacks.forEach(function (callback) {
|
||||
matches.push(callback)
|
||||
})
|
||||
}
|
||||
|
||||
if (!self.callbacks[character]) { return matches }
|
||||
|
||||
isModifier = require('../../helpers/isModifier')
|
||||
// if a modifier key is coming up on its own we should allow it
|
||||
if (action === 'keyup' && isModifier(character)) {
|
||||
modifiers = [character]
|
||||
}
|
||||
|
||||
// loop through all callbacks for the key that was pressed
|
||||
// and see if any of them match
|
||||
for (j = 0; j < self.callbacks[character].length; ++j) {
|
||||
callback = self.callbacks[character][j]
|
||||
|
||||
// if a sequence name is not specified, but this is a sequence at
|
||||
// the wrong level then move onto the next match
|
||||
if (!sequenceName && callback.seq && self.sequenceLevels[callback.seq] !== callback.level) {
|
||||
continue
|
||||
}
|
||||
|
||||
// if the action we are looking for doesn't match the action we got
|
||||
// then we should keep going
|
||||
if (action !== callback.action) {
|
||||
continue
|
||||
}
|
||||
|
||||
// if this is a keypress event and the meta key and control key
|
||||
// are not pressed that means that we need to only look at the
|
||||
// character, otherwise check the modifiers as well
|
||||
//
|
||||
// chrome will not fire a keypress if meta or control is down
|
||||
// safari will fire a keypress if meta or meta+shift is down
|
||||
// firefox will fire a keypress if meta or control is down
|
||||
modifiersMatch = require('./modifiersMatch')
|
||||
if ((action === 'keypress' && !e.metaKey && !e.ctrlKey) || modifiersMatch(modifiers, callback.modifiers)) {
|
||||
// when you bind a combination or sequence a second time it
|
||||
// should overwrite the first one. if a sequenceName or
|
||||
// combination is specified in this call it does just that
|
||||
//
|
||||
// @todo make deleting its own method?
|
||||
var deleteCombo = !sequenceName && callback.combo === combination
|
||||
var deleteSequence = sequenceName && callback.seq === sequenceName && callback.level === level
|
||||
if (deleteCombo || deleteSequence) {
|
||||
self.callbacks[character].splice(j, 1)
|
||||
}
|
||||
|
||||
matches.push(callback)
|
||||
}
|
||||
}
|
||||
|
||||
return matches
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/getMatches.js
|
||||
// module id = 1750
|
||||
// module chunks = 4
|
39
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/getReverseMap.js
generated
vendored
Executable file
39
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/getReverseMap.js
generated
vendored
Executable file
|
@ -0,0 +1,39 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* reverses the map lookup so that we can look for specific keys
|
||||
* to see what can and can't use keypress
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
module.exports = function () {
|
||||
var self = this
|
||||
var constructor = self.constructor
|
||||
var SPECIAL_KEYS_MAP
|
||||
|
||||
if (!constructor.REVERSE_MAP) {
|
||||
constructor.REVERSE_MAP = {}
|
||||
SPECIAL_KEYS_MAP = require('../../helpers/special-keys-map')
|
||||
for (var key in SPECIAL_KEYS_MAP) {
|
||||
// pull out the numeric keypad from here cause keypress should
|
||||
// be able to detect the keys from the character
|
||||
if (key > 95 && key < 112) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (SPECIAL_KEYS_MAP.hasOwnProperty(key)) {
|
||||
constructor.REVERSE_MAP[SPECIAL_KEYS_MAP[key]] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
return constructor.REVERSE_MAP
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/getReverseMap.js
|
||||
// module id = 1751
|
||||
// module chunks = 4
|
101
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/handleKey.js
generated
vendored
Executable file
101
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/handleKey.js
generated
vendored
Executable file
|
@ -0,0 +1,101 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* handles a character key event
|
||||
*
|
||||
* @param {string} character
|
||||
* @param {Array} modifiers
|
||||
* @param {Event} e
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (character, modifiers, e) {
|
||||
var self = this
|
||||
var callbacks
|
||||
var j
|
||||
var doNotReset = {}
|
||||
var maxLevel = 0
|
||||
var processedSequenceCallback = false
|
||||
var isModifier
|
||||
var ignoreThisKeypress
|
||||
|
||||
callbacks = self.getMatches(character, modifiers, e)
|
||||
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
|
||||
for (j = 0; j < callbacks.length; ++j) {
|
||||
if (callbacks[j].seq) {
|
||||
maxLevel = Math.max(maxLevel, callbacks[j].level)
|
||||
}
|
||||
}
|
||||
|
||||
// loop through matching callbacks for this key event
|
||||
for (j = 0; j < callbacks.length; ++j) {
|
||||
// fire for all sequence callbacks
|
||||
// this is because if for example you have multiple sequences
|
||||
// bound such as "g i" and "g t" they both need to fire the
|
||||
// callback for matching g cause otherwise you can only ever
|
||||
// match the first one
|
||||
if (callbacks[j].seq) {
|
||||
// only fire callbacks for the maxLevel to prevent
|
||||
// subsequences from also firing
|
||||
//
|
||||
// for example 'a option b' should not cause 'option b' to fire
|
||||
// even though 'option b' is part of the other sequence
|
||||
//
|
||||
// any sequences that do not match here will be discarded
|
||||
// below by the resetSequences call
|
||||
if (callbacks[j].level !== maxLevel) {
|
||||
continue
|
||||
}
|
||||
|
||||
processedSequenceCallback = true
|
||||
|
||||
// keep a list of which sequences were matches for later
|
||||
doNotReset[callbacks[j].seq] = 1
|
||||
self.fireCallback(callbacks[j].callback, e, callbacks[j].combo, callbacks[j].seq)
|
||||
continue
|
||||
}
|
||||
|
||||
// if there were no sequence matches but we are still here
|
||||
// that means this is a regular match so we should fire that
|
||||
if (!processedSequenceCallback) {
|
||||
self.fireCallback(callbacks[j].callback, e, callbacks[j].combo)
|
||||
}
|
||||
}
|
||||
|
||||
// if the key you pressed matches the type of sequence without
|
||||
// being a modifier (ie "keyup" or "keypress") then we should
|
||||
// reset all sequences that were not matched by this event
|
||||
//
|
||||
// this is so, for example, if you have the sequence "h a t" and you
|
||||
// type "h e a r t" it does not match. in this case the "e" will
|
||||
// cause the sequence to reset
|
||||
//
|
||||
// modifier keys are ignored because you can have a sequence
|
||||
// that contains modifiers such as "enter ctrl+space" and in most
|
||||
// cases the modifier key will be pressed before the next key
|
||||
//
|
||||
// also if you have a sequence such as "ctrl+b a" then pressing the
|
||||
// "b" key will trigger a "keypress" and a "keydown"
|
||||
//
|
||||
// the "keydown" is expected when there is a modifier, but the
|
||||
// "keypress" ends up matching the nextExpectedAction since it occurs
|
||||
// after and that causes the sequence to reset
|
||||
//
|
||||
// we ignore keypresses in a sequence that directly follow a keydown
|
||||
// for the same character
|
||||
ignoreThisKeypress = e.type === 'keypress' && self.ignoreNextKeypress
|
||||
isModifier = require('../../helpers/isModifier')
|
||||
if (e.type === self.nextExpectedAction && !isModifier(character) && !ignoreThisKeypress) {
|
||||
self.resetSequences(doNotReset)
|
||||
}
|
||||
|
||||
self.ignoreNextKeypress = processedSequenceCallback && e.type === 'keydown'
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/handleKey.js
|
||||
// module id = 1752
|
||||
// module chunks = 4
|
44
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/handleKeyEvent.js
generated
vendored
Executable file
44
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/handleKeyEvent.js
generated
vendored
Executable file
|
@ -0,0 +1,44 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* handles a keydown event
|
||||
*
|
||||
* @param {Event} e
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (e) {
|
||||
var self = this
|
||||
var characterFromEvent
|
||||
var eventModifiers
|
||||
|
||||
// normalize e.which for key events
|
||||
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
|
||||
if (typeof e.which !== 'number') {
|
||||
e.which = e.keyCode
|
||||
}
|
||||
characterFromEvent = require('../../helpers/characterFromEvent')
|
||||
var character = characterFromEvent(e)
|
||||
|
||||
// no character found then stop
|
||||
if (!character) {
|
||||
return
|
||||
}
|
||||
|
||||
// need to use === for the character check because the character can be 0
|
||||
if (e.type === 'keyup' && self.ignoreNextKeyup === character) {
|
||||
self.ignoreNextKeyup = false
|
||||
return
|
||||
}
|
||||
|
||||
eventModifiers = require('../../helpers/eventModifiers')
|
||||
self.handleKey(character, eventModifiers(e), e)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/handleKeyEvent.js
|
||||
// module id = 1753
|
||||
// module chunks = 4
|
21
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/modifiersMatch.js
generated
vendored
Executable file
21
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/modifiersMatch.js
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* checks if two arrays are equal
|
||||
*
|
||||
* @param {Array} modifiers1
|
||||
* @param {Array} modifiers2
|
||||
* @returns {boolean}
|
||||
*/
|
||||
module.exports = function (modifiers1, modifiers2) {
|
||||
return modifiers1.sort().join(',') === modifiers2.sort().join(',')
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/modifiersMatch.js
|
||||
// module id = 1754
|
||||
// module chunks = 4
|
35
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/pickBestAction.js
generated
vendored
Executable file
35
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/pickBestAction.js
generated
vendored
Executable file
|
@ -0,0 +1,35 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* picks the best action based on the key combination
|
||||
*
|
||||
* @param {string} key - character for key
|
||||
* @param {Array} modifiers
|
||||
* @param {string=} action passed in
|
||||
*/
|
||||
module.exports = function (key, modifiers, action) {
|
||||
var self = this
|
||||
|
||||
// if no action was picked in we should try to pick the one
|
||||
// that we think would work best for this key
|
||||
if (!action) {
|
||||
action = self.getReverseMap()[key] ? 'keydown' : 'keypress'
|
||||
}
|
||||
|
||||
// modifier keys don't work as expected with keypress,
|
||||
// switch to keydown
|
||||
if (action === 'keypress' && modifiers.length) {
|
||||
action = 'keydown'
|
||||
}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/pickBestAction.js
|
||||
// module id = 1755
|
||||
// module chunks = 4
|
24
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/reset.js
generated
vendored
Executable file
24
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/reset.js
generated
vendored
Executable file
|
@ -0,0 +1,24 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* resets the library back to its initial state. This is useful
|
||||
* if you want to clear out the current keyboard shortcuts and bind
|
||||
* new ones - for example if you switch to another page
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function () {
|
||||
var self = this
|
||||
self.callbacks = {}
|
||||
self.directMap = {}
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/reset.js
|
||||
// module id = 1756
|
||||
// module chunks = 4
|
29
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/resetSequenceTimer.js
generated
vendored
Executable file
29
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/resetSequenceTimer.js
generated
vendored
Executable file
|
@ -0,0 +1,29 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
/**
|
||||
* called to set a 1 second timeout on the specified sequence
|
||||
*
|
||||
* this is so after each key press in the sequence you have 1 second
|
||||
* to press the next key before you have to start over
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function () {
|
||||
var self = this
|
||||
|
||||
clearTimeout(self.resetTimer)
|
||||
self.resetTimer = setTimeout(
|
||||
function () {
|
||||
self.resetSequences()
|
||||
},
|
||||
1000
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/resetSequenceTimer.js
|
||||
// module id = 1757
|
||||
// module chunks = 4
|
37
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/resetSequences.js
generated
vendored
Executable file
37
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/resetSequences.js
generated
vendored
Executable file
|
@ -0,0 +1,37 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* resets all sequence counters except for the ones passed in
|
||||
*
|
||||
* @param {Object} doNotReset
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (doNotReset) {
|
||||
var self = this
|
||||
|
||||
doNotReset = doNotReset || {}
|
||||
|
||||
var activeSequences = false
|
||||
var key
|
||||
|
||||
for (key in self.sequenceLevels) {
|
||||
if (doNotReset[key]) {
|
||||
activeSequences = true
|
||||
continue
|
||||
}
|
||||
self.sequenceLevels[key] = 0
|
||||
}
|
||||
|
||||
if (!activeSequences) {
|
||||
self.nextExpectedAction = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/resetSequences.js
|
||||
// module id = 1758
|
||||
// module chunks = 4
|
29
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/stopCallback.js
generated
vendored
Executable file
29
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/stopCallback.js
generated
vendored
Executable file
|
@ -0,0 +1,29 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* should we stop this event before firing off callbacks
|
||||
*
|
||||
* @param {Event} e
|
||||
* @param {Element} element
|
||||
* @return {boolean}
|
||||
*/
|
||||
module.exports = function (e, element) {
|
||||
// if the element has the class "combokeys" then no need to stop
|
||||
if ((' ' + element.className + ' ').indexOf(' combokeys ') > -1) {
|
||||
return false
|
||||
}
|
||||
|
||||
var tagName = element.tagName.toLowerCase()
|
||||
|
||||
// stop for input, select, and textarea
|
||||
return tagName === 'input' || tagName === 'select' || tagName === 'textarea' || element.isContentEditable
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/stopCallback.js
|
||||
// module id = 1759
|
||||
// module chunks = 4
|
24
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/trigger.js
generated
vendored
Executable file
24
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/trigger.js
generated
vendored
Executable file
|
@ -0,0 +1,24 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
/**
|
||||
* triggers an event that has already been bound
|
||||
*
|
||||
* @param {string} keys
|
||||
* @param {string=} action
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (keys, action) {
|
||||
var self = this
|
||||
if (self.directMap[keys + ':' + action]) {
|
||||
self.directMap[keys + ':' + action]({}, keys)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/trigger.js
|
||||
// module id = 1760
|
||||
// module chunks = 4
|
32
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/unbind.js
generated
vendored
Executable file
32
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/prototype/unbind.js
generated
vendored
Executable file
|
@ -0,0 +1,32 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
/**
|
||||
* unbinds an event to Combokeys
|
||||
*
|
||||
* the unbinding sets the callback function of the specified key combo
|
||||
* to an empty function and deletes the corresponding key in the
|
||||
* directMap dict.
|
||||
*
|
||||
* TODO: actually remove this from the callbacks dictionary instead
|
||||
* of binding an empty function
|
||||
*
|
||||
* the keycombo+action has to be exactly the same as
|
||||
* it was defined in the bind method
|
||||
*
|
||||
* @param {string|Array} keys
|
||||
* @param {string} action
|
||||
* @returns void
|
||||
*/
|
||||
module.exports = function (keys, action) {
|
||||
var self = this
|
||||
|
||||
return self.bind(keys, function () {}, action)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/prototype/unbind.js
|
||||
// module id = 1761
|
||||
// module chunks = 4
|
18
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/reset.js
generated
Executable file
18
509bba0_unpacked_with_node_modules/~/combokeys/Combokeys/reset.js
generated
Executable file
|
@ -0,0 +1,18 @@
|
|||
/* eslint-env node, browser */
|
||||
'use strict'
|
||||
|
||||
module.exports = function () {
|
||||
var self = this
|
||||
|
||||
self.instances.forEach(function (combokeys) {
|
||||
combokeys.reset()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/combokeys/Combokeys/reset.js
|
||||
// module id = 1762
|
||||
// module chunks = 4
|
Loading…
Add table
Add a link
Reference in a new issue