-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathangular-hotkeys.min.js
More file actions
3 lines (3 loc) · 2.14 KB
/
Copy pathangular-hotkeys.min.js
File metadata and controls
3 lines (3 loc) · 2.14 KB
1
2
3
/*! angular-hotkeys v0.2.0 */
!function(){"use strict";var a=angular.module("drahak.hotkeys",[]);a.directive("hotkey",["$parse","$hotkey","HotKeysElement",function(a,b,c){return{restrict:"AE",link:function(d,e,f){var g=d.$eval(f.hotkey||f.bind);if(angular.isUndefined(g)){var h=a(f.invoke);g={},g[f.hotkey||f.bind]=function(a){h(d,{$event:a})}}var i="hotkey"!==e[0].nodeName.toLowerCase(),j=i?c(e):b;angular.forEach(g,function(a,b){j.bind(b,a)})}}}]),a.factory("HotKeysElement",["$window","HotKeys",function(a,b){return function(c){var d=[],e=angular.element(c),f=angular.element(a),g=e.scope(),h=b();return g&&(g.$hotKeys=h),f.bind("blur",function(){d=[]}),e.bind("keydown",function(a){-1===d.indexOf(a.keyCode)&&d.push(a.keyCode),h.trigger(d,[a])}),e.bind("keyup",function(a){d.splice(d.indexOf(a.keyCode),1)}),h}}]),a.factory("HotKeys",["ParseKey","$rootScope",function(a,b){var c=function(){this._hotKeys={}};return c.prototype._getHotKeyIndex=function(b){var c;if(angular.isString(b))c=a(b);else{if(!angular.isArray(b))throw new Error("HotKey expects hot key to be string expression or key codes array, "+typeof b+" given.");c=b}return c.sort().join("+")},c.prototype.bind=function(a,b){return a=this._getHotKeyIndex(a),this._hotKeys[a]||(this._hotKeys[a]=[]),this._hotKeys[a].push(b),this},c.prototype.unbind=function(a){return a=this._getHotKeyIndex(a),this._hotKeys[a]=[],this},c.prototype.trigger=function(a,c){c=c||[],a=this._getHotKeyIndex(a),angular.forEach(this._hotKeys[a],function(a){a.apply(a,c)}),b.$$phase||b.$apply()},function(){return new c}}]),a.factory("$hotkey",["$window","HotKeysElement",function(a,b){return b(a)}]),a.service("ParseKey",function(){var a={backspace:8,"return":8,tab:9,tabulator:9,enter:13,shift:16,ctrl:17,control:17,alt:18,esc:27,escape:27,left:37,up:38,right:39,down:40,insert:45,del:46,"delete":46};return function(b){var c=[],d=b.split("+");return angular.forEach(d,function(b){if(b=b.trim().toLowerCase(),a[b])c.push(a[b]);else{if(1!==b.length)throw new Error('ParseKey expects one character or special expression like "Tab" or "Control", "'+b+'" given');c.push(b.toUpperCase().charCodeAt(0))}}),c}})}();
//# sourceMappingURL=angular-hotkeys.js.map