1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1899× 1899× 97× 97× 97× 97× 97× 97× 97× 3956× 3956× 3956× 3956× 3956× 3956× 58× 97× 96× 1899× 1899× 1× 1× 1897× 1897× 1× 1× 1899× 1× 3796× 1× 1899× 1× 1897× 1× 3956× 3913× 43× 43× 43× 1× 42× 43× 43× 1× 42× 1× 1× 1× 1× 1× 1× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); /* istanbul ignore next */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_base_2) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var keyCode = { 'backspace': 8, 'tab': 9, 'enter': 13, 'shift': 16, 'control': 17, 'alt': 18, 'pause': 19, 'capslock': 20, 'space': 32, 'escape': 27, 'pageup': 33, 'pagedown': 34, 'end': 35, 'home': 36, 'leftarrow': 37, 'uparrow': 38, 'rightarrow': 39, 'downarrow': 40, 'insert': 45, 'delete': 46, 'f1': 112, 'f2': 113, 'f3': 114, 'f4': 115, 'f5': 116, 'f6': 117, 'f7': 118, 'f8': 119, 'f9': 120, 'f10': 121, 'f11': 122, 'f12': 123, 'semicolon': 186, 'plus': 187, 'comma': 188, 'minus': 189, 'dot': 190, 'forwardslash': 191, 'graveaccent': 192, 'openbracket': 219, 'backslash': 220, 'closebracket': 221, 'singlequote': 222, ']': 221, '[': 219, '=': 187, '<': 188, '>': 190, '`': 192 }; var KeyboardEvents = (function (_super) { __extends(KeyboardEvents, _super); function KeyboardEvents(element, options) { var _this = _super.call(this, options, element) || this; _this.keyPressHandler = function (e) { var isAltKey = e.altKey; var isCtrlKey = e.ctrlKey; var isShiftKey = e.shiftKey; var isMetaKey = e.metaKey; var curkeyCode = e.which; var keys = Object.keys(_this.keyConfigs); for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { var key = keys_1[_i]; var configCollection = _this.keyConfigs["" + key].split(','); for (var _a = 0, configCollection_1 = configCollection; _a < configCollection_1.length; _a++) { var rconfig = configCollection_1[_a]; var rKeyObj = KeyboardEvents_1.getKeyConfigData(rconfig.trim()); if (isAltKey === rKeyObj.altKey && (isCtrlKey === rKeyObj.ctrlKey || isMetaKey) && isShiftKey === rKeyObj.shiftKey && curkeyCode === rKeyObj.keyCode) { e.action = key; } } } if (_this.keyAction) { _this.keyAction(e); } }; _this.bind(); return _this; } KeyboardEvents_1 = KeyboardEvents; KeyboardEvents.prototype.destroy = function () { this.unwireEvents(); _super.prototype.destroy.call(this); }; KeyboardEvents.prototype.onPropertyChanged = function (newProp, oldProp) { }; KeyboardEvents.prototype.bind = function () { this.wireEvents(); }; KeyboardEvents.prototype.getModuleName = function () { return 'keyboard'; }; KeyboardEvents.prototype.wireEvents = function () { this.element.addEventListener(this.eventName, this.keyPressHandler); }; KeyboardEvents.prototype.unwireEvents = function () { this.element.removeEventListener(this.eventName, this.keyPressHandler); }; KeyboardEvents.getKeyConfigData = function (config) { if (config in this.configCache) { return this.configCache["" + config]; } var keys = config.toLowerCase().split('+'); var keyData = { altKey: (keys.indexOf('alt') !== -1 ? true : false), ctrlKey: (keys.indexOf('ctrl') !== -1 ? true : false), shiftKey: (keys.indexOf('shift') !== -1 ? true : false), keyCode: null }; if (keys[keys.length - 1].length > 1 && !!Number(keys[keys.length - 1])) { keyData.keyCode = Number(keys[keys.length - 1]); } else { keyData.keyCode = KeyboardEvents_1.getKeyCode(keys[keys.length - 1]); } KeyboardEvents_1.configCache["" + config] = keyData; return keyData; }; KeyboardEvents.getKeyCode = function (keyVal) { return keyCode["" + keyVal] || keyVal.toUpperCase().charCodeAt(0); }; var KeyboardEvents_1; KeyboardEvents.configCache = {}; __decorate([ ej2_base_1.Property({}) ], KeyboardEvents.prototype, "keyConfigs", void 0); __decorate([ ej2_base_1.Property('keyup') ], KeyboardEvents.prototype, "eventName", void 0); __decorate([ ej2_base_1.Event() ], KeyboardEvents.prototype, "keyAction", void 0); KeyboardEvents = KeyboardEvents_1 = __decorate([ ej2_base_1.NotifyPropertyChanges ], KeyboardEvents); return KeyboardEvents; }(ej2_base_2.Base)); exports.KeyboardEvents = KeyboardEvents; }); |