|
@ -1634,6 +1634,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
|
|
|
|
|
|
this._options = options || {}; |
|
|
this._options = options || {}; |
|
|
this._data = {}; // map with data indexed by id
|
|
|
this._data = {}; // map with data indexed by id
|
|
|
|
|
|
this.length = 0; // number of items in the DataSet
|
|
|
this._fieldId = this._options.fieldId || 'id'; // name of the field containing id
|
|
|
this._fieldId = this._options.fieldId || 'id'; // name of the field containing id
|
|
|
this._type = {}; // internal field types (NOTE: this can differ from this._options.type)
|
|
|
this._type = {}; // internal field types (NOTE: this can differ from this._options.type)
|
|
|
|
|
|
|
|
@ -2318,6 +2319,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
if (util.isNumber(id) || util.isString(id)) { |
|
|
if (util.isNumber(id) || util.isString(id)) { |
|
|
if (this._data[id]) { |
|
|
if (this._data[id]) { |
|
|
delete this._data[id]; |
|
|
delete this._data[id]; |
|
|
|
|
|
this.length--; |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -2325,6 +2327,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
var itemId = id[this._fieldId]; |
|
|
var itemId = id[this._fieldId]; |
|
|
if (itemId && this._data[itemId]) { |
|
|
if (itemId && this._data[itemId]) { |
|
|
delete this._data[itemId]; |
|
|
delete this._data[itemId]; |
|
|
|
|
|
this.length--; |
|
|
return itemId; |
|
|
return itemId; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -2340,6 +2343,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
var ids = Object.keys(this._data); |
|
|
var ids = Object.keys(this._data); |
|
|
|
|
|
|
|
|
this._data = {}; |
|
|
this._data = {}; |
|
|
|
|
|
this.length = 0; |
|
|
|
|
|
|
|
|
this._trigger('remove', {items: ids}, senderId); |
|
|
this._trigger('remove', {items: ids}, senderId); |
|
|
|
|
|
|
|
@ -2465,6 +2469,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
this._data[id] = d; |
|
|
this._data[id] = d; |
|
|
|
|
|
this.length++; |
|
|
|
|
|
|
|
|
return id; |
|
|
return id; |
|
|
}; |
|
|
}; |
|
@ -2590,6 +2595,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
function DataView (data, options) { |
|
|
function DataView (data, options) { |
|
|
this._data = null; |
|
|
this._data = null; |
|
|
this._ids = {}; // ids of the items currently in memory (just contains a boolean true)
|
|
|
this._ids = {}; // ids of the items currently in memory (just contains a boolean true)
|
|
|
|
|
|
this.length = 0; // number of items in the DataView
|
|
|
this._options = options || {}; |
|
|
this._options = options || {}; |
|
|
this._fieldId = 'id'; // name of the field containing id
|
|
|
this._fieldId = 'id'; // name of the field containing id
|
|
|
this._subscribers = {}; // event subscribers
|
|
|
this._subscribers = {}; // event subscribers
|
|
@ -2626,6 +2632,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
this._ids = {}; |
|
|
this._ids = {}; |
|
|
|
|
|
this.length = 0; |
|
|
this._trigger('remove', {items: ids}); |
|
|
this._trigger('remove', {items: ids}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2643,6 +2650,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
id = ids[i]; |
|
|
id = ids[i]; |
|
|
this._ids[id] = true; |
|
|
this._ids[id] = true; |
|
|
} |
|
|
} |
|
|
|
|
|
this.length = ids.length; |
|
|
this._trigger('add', {items: ids}); |
|
|
this._trigger('add', {items: ids}); |
|
|
|
|
|
|
|
|
// subscribe to new dataset
|
|
|
// subscribe to new dataset
|
|
@ -2853,6 +2861,8 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.length += added.length - removed.length; |
|
|
|
|
|
|
|
|
if (added.length) { |
|
|
if (added.length) { |
|
|
this._trigger('add', {items: added}, senderId); |
|
|
this._trigger('add', {items: added}, senderId); |
|
|
} |
|
|
} |
|
@ -15408,7 +15418,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
|
|
|
|
|
|
var Emitter = __webpack_require__(56); |
|
|
var Emitter = __webpack_require__(56); |
|
|
var Hammer = __webpack_require__(45); |
|
|
var Hammer = __webpack_require__(45); |
|
|
var keycharm = __webpack_require__(57); |
|
|
|
|
|
|
|
|
var keycharm = __webpack_require__(58); |
|
|
var util = __webpack_require__(1); |
|
|
var util = __webpack_require__(1); |
|
|
var hammerUtil = __webpack_require__(47); |
|
|
var hammerUtil = __webpack_require__(47); |
|
|
var DataSet = __webpack_require__(3); |
|
|
var DataSet = __webpack_require__(3); |
|
@ -21882,7 +21892,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
|
|
|
|
|
|
// first check if moment.js is already loaded in the browser window, if so,
|
|
|
// first check if moment.js is already loaded in the browser window, if so,
|
|
|
// use this instance. Else, load via commonjs.
|
|
|
// use this instance. Else, load via commonjs.
|
|
|
module.exports = (typeof window !== 'undefined') && window['moment'] || __webpack_require__(58); |
|
|
|
|
|
|
|
|
module.exports = (typeof window !== 'undefined') && window['moment'] || __webpack_require__(57); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }, |
|
|
/***/ }, |
|
@ -23548,7 +23558,7 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
/* 53 */ |
|
|
/* 53 */ |
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
|
|
|
|
|
|
var keycharm = __webpack_require__(57); |
|
|
|
|
|
|
|
|
var keycharm = __webpack_require__(58); |
|
|
var Emitter = __webpack_require__(56); |
|
|
var Emitter = __webpack_require__(56); |
|
|
var Hammer = __webpack_require__(45); |
|
|
var Hammer = __webpack_require__(45); |
|
|
var util = __webpack_require__(1); |
|
|
var util = __webpack_require__(1); |
|
@ -24145,205 +24155,6 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
|
|
|
|
|
|
/***/ }, |
|
|
/***/ }, |
|
|
/* 57 */ |
|
|
/* 57 */ |
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
|
|
|
|
|
|
|
|
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;"use strict"; |
|
|
|
|
|
/** |
|
|
|
|
|
* Created by Alex on 11/6/2014. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/umdjs/umd/blob/master/returnExports.js#L40-L60
|
|
|
|
|
|
// if the module has no dependencies, the above pattern can be simplified to
|
|
|
|
|
|
(function (root, factory) { |
|
|
|
|
|
if (true) { |
|
|
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
|
|
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
|
|
|
|
} else if (typeof exports === 'object') { |
|
|
|
|
|
// Node. Does not work with strict CommonJS, but
|
|
|
|
|
|
// only CommonJS-like environments that support module.exports,
|
|
|
|
|
|
// like Node.
|
|
|
|
|
|
module.exports = factory(); |
|
|
|
|
|
} else { |
|
|
|
|
|
// Browser globals (root is window)
|
|
|
|
|
|
root.keycharm = factory(); |
|
|
|
|
|
} |
|
|
|
|
|
}(this, function () { |
|
|
|
|
|
|
|
|
|
|
|
function keycharm(options) { |
|
|
|
|
|
var preventDefault = options && options.preventDefault || false; |
|
|
|
|
|
|
|
|
|
|
|
var container = options && options.container || window; |
|
|
|
|
|
|
|
|
|
|
|
var _exportFunctions = {}; |
|
|
|
|
|
var _bound = {keydown:{}, keyup:{}}; |
|
|
|
|
|
var _keys = {}; |
|
|
|
|
|
var i; |
|
|
|
|
|
|
|
|
|
|
|
// a - z
|
|
|
|
|
|
for (i = 97; i <= 122; i++) {_keys[String.fromCharCode(i)] = {code:65 + (i - 97), shift: false};} |
|
|
|
|
|
// A - Z
|
|
|
|
|
|
for (i = 65; i <= 90; i++) {_keys[String.fromCharCode(i)] = {code:i, shift: true};} |
|
|
|
|
|
// 0 - 9
|
|
|
|
|
|
for (i = 0; i <= 9; i++) {_keys['' + i] = {code:48 + i, shift: false};} |
|
|
|
|
|
// F1 - F12
|
|
|
|
|
|
for (i = 1; i <= 12; i++) {_keys['F' + i] = {code:111 + i, shift: false};} |
|
|
|
|
|
// num0 - num9
|
|
|
|
|
|
for (i = 0; i <= 9; i++) {_keys['num' + i] = {code:96 + i, shift: false};} |
|
|
|
|
|
|
|
|
|
|
|
// numpad misc
|
|
|
|
|
|
_keys['num*'] = {code:106, shift: false}; |
|
|
|
|
|
_keys['num+'] = {code:107, shift: false}; |
|
|
|
|
|
_keys['num-'] = {code:109, shift: false}; |
|
|
|
|
|
_keys['num/'] = {code:111, shift: false}; |
|
|
|
|
|
_keys['num.'] = {code:110, shift: false}; |
|
|
|
|
|
// arrows
|
|
|
|
|
|
_keys['left'] = {code:37, shift: false}; |
|
|
|
|
|
_keys['up'] = {code:38, shift: false}; |
|
|
|
|
|
_keys['right'] = {code:39, shift: false}; |
|
|
|
|
|
_keys['down'] = {code:40, shift: false}; |
|
|
|
|
|
// extra keys
|
|
|
|
|
|
_keys['space'] = {code:32, shift: false}; |
|
|
|
|
|
_keys['enter'] = {code:13, shift: false}; |
|
|
|
|
|
_keys['shift'] = {code:16, shift: undefined}; |
|
|
|
|
|
_keys['esc'] = {code:27, shift: false}; |
|
|
|
|
|
_keys['backspace'] = {code:8, shift: false}; |
|
|
|
|
|
_keys['tab'] = {code:9, shift: false}; |
|
|
|
|
|
_keys['ctrl'] = {code:17, shift: false}; |
|
|
|
|
|
_keys['alt'] = {code:18, shift: false}; |
|
|
|
|
|
_keys['delete'] = {code:46, shift: false}; |
|
|
|
|
|
_keys['pageup'] = {code:33, shift: false}; |
|
|
|
|
|
_keys['pagedown'] = {code:34, shift: false}; |
|
|
|
|
|
// symbols
|
|
|
|
|
|
_keys['='] = {code:187, shift: false}; |
|
|
|
|
|
_keys['-'] = {code:189, shift: false}; |
|
|
|
|
|
_keys[']'] = {code:221, shift: false}; |
|
|
|
|
|
_keys['['] = {code:219, shift: false}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var down = function(event) {handleEvent(event,'keydown');}; |
|
|
|
|
|
var up = function(event) {handleEvent(event,'keyup');}; |
|
|
|
|
|
|
|
|
|
|
|
// handle the actualy bound key with the event
|
|
|
|
|
|
var handleEvent = function(event,type) { |
|
|
|
|
|
if (_bound[type][event.keyCode] !== undefined) { |
|
|
|
|
|
var bound = _bound[type][event.keyCode]; |
|
|
|
|
|
for (var i = 0; i < bound.length; i++) { |
|
|
|
|
|
if (bound[i].shift === undefined) { |
|
|
|
|
|
bound[i].fn(event); |
|
|
|
|
|
} |
|
|
|
|
|
else if (bound[i].shift == true && event.shiftKey == true) { |
|
|
|
|
|
bound[i].fn(event); |
|
|
|
|
|
} |
|
|
|
|
|
else if (bound[i].shift == false && event.shiftKey == false) { |
|
|
|
|
|
bound[i].fn(event); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (preventDefault == true) { |
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// bind a key to a callback
|
|
|
|
|
|
_exportFunctions.bind = function(key, callback, type) { |
|
|
|
|
|
if (type === undefined) { |
|
|
|
|
|
type = 'keydown'; |
|
|
|
|
|
} |
|
|
|
|
|
if (_keys[key] === undefined) { |
|
|
|
|
|
throw new Error("unsupported key: " + key); |
|
|
|
|
|
} |
|
|
|
|
|
if (_bound[type][_keys[key].code] === undefined) { |
|
|
|
|
|
_bound[type][_keys[key].code] = []; |
|
|
|
|
|
} |
|
|
|
|
|
_bound[type][_keys[key].code].push({fn:callback, shift:_keys[key].shift}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bind all keys to a call back (demo purposes)
|
|
|
|
|
|
_exportFunctions.bindAll = function(callback, type) { |
|
|
|
|
|
if (type === undefined) { |
|
|
|
|
|
type = 'keydown'; |
|
|
|
|
|
} |
|
|
|
|
|
for (var key in _keys) { |
|
|
|
|
|
if (_keys.hasOwnProperty(key)) { |
|
|
|
|
|
_exportFunctions.bind(key,callback,type); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// get the key label from an event
|
|
|
|
|
|
_exportFunctions.getKey = function(event) { |
|
|
|
|
|
for (var key in _keys) { |
|
|
|
|
|
if (_keys.hasOwnProperty(key)) { |
|
|
|
|
|
if (event.shiftKey == true && _keys[key].shift == true && event.keyCode == _keys[key].code) { |
|
|
|
|
|
return key; |
|
|
|
|
|
} |
|
|
|
|
|
else if (event.shiftKey == false && _keys[key].shift == false && event.keyCode == _keys[key].code) { |
|
|
|
|
|
return key; |
|
|
|
|
|
} |
|
|
|
|
|
else if (event.keyCode == _keys[key].code && key == 'shift') { |
|
|
|
|
|
return key; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return "unknown key, currently not supported"; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// unbind either a specific callback from a key or all of them (by leaving callback undefined)
|
|
|
|
|
|
_exportFunctions.unbind = function(key, callback, type) { |
|
|
|
|
|
if (type === undefined) { |
|
|
|
|
|
type = 'keydown'; |
|
|
|
|
|
} |
|
|
|
|
|
if (_keys[key] === undefined) { |
|
|
|
|
|
throw new Error("unsupported key: " + key); |
|
|
|
|
|
} |
|
|
|
|
|
if (callback !== undefined) { |
|
|
|
|
|
var newBindings = []; |
|
|
|
|
|
var bound = _bound[type][_keys[key].code]; |
|
|
|
|
|
if (bound !== undefined) { |
|
|
|
|
|
for (var i = 0; i < bound.length; i++) { |
|
|
|
|
|
if (!(bound[i].fn == callback && bound[i].shift == _keys[key].shift)) { |
|
|
|
|
|
newBindings.push(_bound[type][_keys[key].code][i]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
_bound[type][_keys[key].code] = newBindings; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
_bound[type][_keys[key].code] = []; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// reset all bound variables.
|
|
|
|
|
|
_exportFunctions.reset = function() { |
|
|
|
|
|
_bound = {keydown:{}, keyup:{}}; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// unbind all listeners and reset all variables.
|
|
|
|
|
|
_exportFunctions.destroy = function() { |
|
|
|
|
|
_bound = {keydown:{}, keyup:{}}; |
|
|
|
|
|
container.removeEventListener('keydown', down, true); |
|
|
|
|
|
container.removeEventListener('keyup', up, true); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// create listeners.
|
|
|
|
|
|
container.addEventListener('keydown',down,true); |
|
|
|
|
|
container.addEventListener('keyup',up,true); |
|
|
|
|
|
|
|
|
|
|
|
// return the public functions.
|
|
|
|
|
|
return _exportFunctions; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return keycharm; |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }, |
|
|
|
|
|
/* 58 */ |
|
|
|
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
|
|
|
|
|
|
var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global, module) {//! moment.js
|
|
|
var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global, module) {//! moment.js
|
|
@ -27392,6 +27203,205 @@ return /******/ (function(modules) { // webpackBootstrap |
|
|
|
|
|
|
|
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(71)(module))) |
|
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(71)(module))) |
|
|
|
|
|
|
|
|
|
|
|
/***/ }, |
|
|
|
|
|
/* 58 */ |
|
|
|
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
|
|
|
|
|
|
|
|
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;"use strict"; |
|
|
|
|
|
/** |
|
|
|
|
|
* Created by Alex on 11/6/2014. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/umdjs/umd/blob/master/returnExports.js#L40-L60
|
|
|
|
|
|
// if the module has no dependencies, the above pattern can be simplified to
|
|
|
|
|
|
(function (root, factory) { |
|
|
|
|
|
if (true) { |
|
|
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
|
|
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
|
|
|
|
} else if (typeof exports === 'object') { |
|
|
|
|
|
// Node. Does not work with strict CommonJS, but
|
|
|
|
|
|
// only CommonJS-like environments that support module.exports,
|
|
|
|
|
|
// like Node.
|
|
|
|
|
|
module.exports = factory(); |
|
|
|
|
|
} else { |
|
|
|
|
|
// Browser globals (root is window)
|
|
|
|
|
|
root.keycharm = factory(); |
|
|
|
|
|
} |
|
|
|
|
|
}(this, function () { |
|
|
|
|
|
|
|
|
|
|
|
function keycharm(options) { |
|
|
|
|
|
var preventDefault = options && options.preventDefault || false; |
|
|
|
|
|
|
|
|
|
|
|
var container = options && options.container || window; |
|
|
|
|
|
|
|
|
|
|
|
var _exportFunctions = {}; |
|
|
|
|
|
var _bound = {keydown:{}, keyup:{}}; |
|
|
|
|
|
var _keys = {}; |
|
|
|
|
|
var i; |
|
|
|
|
|
|
|
|
|
|
|
// a - z
|
|
|
|
|
|
for (i = 97; i <= 122; i++) {_keys[String.fromCharCode(i)] = {code:65 + (i - 97), shift: false};} |
|
|
|
|
|
// A - Z
|
|
|
|
|
|
for (i = 65; i <= 90; i++) {_keys[String.fromCharCode(i)] = {code:i, shift: true};} |
|
|
|
|
|
// 0 - 9
|
|
|
|
|
|
for (i = 0; i <= 9; i++) {_keys['' + i] = {code:48 + i, shift: false};} |
|
|
|
|
|
// F1 - F12
|
|
|
|
|
|
for (i = 1; i <= 12; i++) {_keys['F' + i] = {code:111 + i, shift: false};} |
|
|
|
|
|
// num0 - num9
|
|
|
|
|
|
for (i = 0; i <= 9; i++) {_keys['num' + i] = {code:96 + i, shift: false};} |
|
|
|
|
|
|
|
|
|
|
|
// numpad misc
|
|
|
|
|
|
_keys['num*'] = {code:106, shift: false}; |
|
|
|
|
|
_keys['num+'] = {code:107, shift: false}; |
|
|
|
|
|
_keys['num-'] = {code:109, shift: false}; |
|
|
|
|
|
_keys['num/'] = {code:111, shift: false}; |
|
|
|
|
|
_keys['num.'] = {code:110, shift: false}; |
|
|
|
|
|
// arrows
|
|
|
|
|
|
_keys['left'] = {code:37, shift: false}; |
|
|
|
|
|
_keys['up'] = {code:38, shift: false}; |
|
|
|
|
|
_keys['right'] = {code:39, shift: false}; |
|
|
|
|
|
_keys['down'] = {code:40, shift: false}; |
|
|
|
|
|
// extra keys
|
|
|
|
|
|
_keys['space'] = {code:32, shift: false}; |
|
|
|
|
|
_keys['enter'] = {code:13, shift: false}; |
|
|
|
|
|
_keys['shift'] = {code:16, shift: undefined}; |
|
|
|
|
|
_keys['esc'] = {code:27, shift: false}; |
|
|
|
|
|
_keys['backspace'] = {code:8, shift: false}; |
|
|
|
|
|
_keys['tab'] = {code:9, shift: false}; |
|
|
|
|
|
_keys['ctrl'] = {code:17, shift: false}; |
|
|
|
|
|
_keys['alt'] = {code:18, shift: false}; |
|
|
|
|
|
_keys['delete'] = {code:46, shift: false}; |
|
|
|
|
|
_keys['pageup'] = {code:33, shift: false}; |
|
|
|
|
|
_keys['pagedown'] = {code:34, shift: false}; |
|
|
|
|
|
// symbols
|
|
|
|
|
|
_keys['='] = {code:187, shift: false}; |
|
|
|
|
|
_keys['-'] = {code:189, shift: false}; |
|
|
|
|
|
_keys[']'] = {code:221, shift: false}; |
|
|
|
|
|
_keys['['] = {code:219, shift: false}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var down = function(event) {handleEvent(event,'keydown');}; |
|
|
|
|
|
var up = function(event) {handleEvent(event,'keyup');}; |
|
|
|
|
|
|
|
|
|
|
|
// handle the actualy bound key with the event
|
|
|
|
|
|
var handleEvent = function(event,type) { |
|
|
|
|
|
if (_bound[type][event.keyCode] !== undefined) { |
|
|
|
|
|
var bound = _bound[type][event.keyCode]; |
|
|
|
|
|
for (var i = 0; i < bound.length; i++) { |
|
|
|
|
|
if (bound[i].shift === undefined) { |
|
|
|
|
|
bound[i].fn(event); |
|
|
|
|
|
} |
|
|
|
|
|
else if (bound[i].shift == true && event.shiftKey == true) { |
|
|
|
|
|
bound[i].fn(event); |
|
|
|
|
|
} |
|
|
|
|
|
else if (bound[i].shift == false && event.shiftKey == false) { |
|
|
|
|
|
bound[i].fn(event); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (preventDefault == true) { |
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// bind a key to a callback
|
|
|
|
|
|
_exportFunctions.bind = function(key, callback, type) { |
|
|
|
|
|
if (type === undefined) { |
|
|
|
|
|
type = 'keydown'; |
|
|
|
|
|
} |
|
|
|
|
|
if (_keys[key] === undefined) { |
|
|
|
|
|
throw new Error("unsupported key: " + key); |
|
|
|
|
|
} |
|
|
|
|
|
if (_bound[type][_keys[key].code] === undefined) { |
|
|
|
|
|
_bound[type][_keys[key].code] = []; |
|
|
|
|
|
} |
|
|
|
|
|
_bound[type][_keys[key].code].push({fn:callback, shift:_keys[key].shift}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bind all keys to a call back (demo purposes)
|
|
|
|
|
|
_exportFunctions.bindAll = function(callback, type) { |
|
|
|
|
|
if (type === undefined) { |
|
|
|
|
|
type = 'keydown'; |
|
|
|
|
|
} |
|
|
|
|
|
for (var key in _keys) { |
|
|
|
|
|
if (_keys.hasOwnProperty(key)) { |
|
|
|
|
|
_exportFunctions.bind(key,callback,type); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// get the key label from an event
|
|
|
|
|
|
_exportFunctions.getKey = function(event) { |
|
|
|
|
|
for (var key in _keys) { |
|
|
|
|
|
if (_keys.hasOwnProperty(key)) { |
|
|
|
|
|
if (event.shiftKey == true && _keys[key].shift == true && event.keyCode == _keys[key].code) { |
|
|
|
|
|
return key; |
|
|
|
|
|
} |
|
|
|
|
|
else if (event.shiftKey == false && _keys[key].shift == false && event.keyCode == _keys[key].code) { |
|
|
|
|
|
return key; |
|
|
|
|
|
} |
|
|
|
|
|
else if (event.keyCode == _keys[key].code && key == 'shift') { |
|
|
|
|
|
return key; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return "unknown key, currently not supported"; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// unbind either a specific callback from a key or all of them (by leaving callback undefined)
|
|
|
|
|
|
_exportFunctions.unbind = function(key, callback, type) { |
|
|
|
|
|
if (type === undefined) { |
|
|
|
|
|
type = 'keydown'; |
|
|
|
|
|
} |
|
|
|
|
|
if (_keys[key] === undefined) { |
|
|
|
|
|
throw new Error("unsupported key: " + key); |
|
|
|
|
|
} |
|
|
|
|
|
if (callback !== undefined) { |
|
|
|
|
|
var newBindings = []; |
|
|
|
|
|
var bound = _bound[type][_keys[key].code]; |
|
|
|
|
|
if (bound !== undefined) { |
|
|
|
|
|
for (var i = 0; i < bound.length; i++) { |
|
|
|
|
|
if (!(bound[i].fn == callback && bound[i].shift == _keys[key].shift)) { |
|
|
|
|
|
newBindings.push(_bound[type][_keys[key].code][i]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
_bound[type][_keys[key].code] = newBindings; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
_bound[type][_keys[key].code] = []; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// reset all bound variables.
|
|
|
|
|
|
_exportFunctions.reset = function() { |
|
|
|
|
|
_bound = {keydown:{}, keyup:{}}; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// unbind all listeners and reset all variables.
|
|
|
|
|
|
_exportFunctions.destroy = function() { |
|
|
|
|
|
_bound = {keydown:{}, keyup:{}}; |
|
|
|
|
|
container.removeEventListener('keydown', down, true); |
|
|
|
|
|
container.removeEventListener('keyup', up, true); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// create listeners.
|
|
|
|
|
|
container.addEventListener('keydown',down,true); |
|
|
|
|
|
container.addEventListener('keyup',up,true); |
|
|
|
|
|
|
|
|
|
|
|
// return the public functions.
|
|
|
|
|
|
return _exportFunctions; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return keycharm; |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }, |
|
|
/***/ }, |
|
|
/* 59 */ |
|
|
/* 59 */ |
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|
/***/ function(module, exports, __webpack_require__) { |
|
|