Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit 0725137

Browse files
bump version 1.7.0
1 parent c6fbb7c commit 0725137

5 files changed

Lines changed: 42 additions & 26 deletions

File tree

build/hotkeys.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* angular-hotkeys v1.6.0
2+
* angular-hotkeys v1.7.0
33
* https://chieffancypants.github.io/angular-hotkeys
4-
* Copyright (c) 2015 Wes Cruver
4+
* Copyright (c) 2016 Wes Cruver
55
* License: MIT
66
*/
77
.cfp-hotkeys-container {

build/hotkeys.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/*!
2-
* angular-hotkeys v1.6.0
2+
* angular-hotkeys v1.7.0
33
* https://chieffancypants.github.io/angular-hotkeys
4-
* Copyright (c) 2015 Wes Cruver
4+
* Copyright (c) 2016 Wes Cruver
55
* License: MIT
66
*/
77
/*
88
* angular-hotkeys
99
*
1010
* Automatic keyboard shortcuts for your angular apps
1111
*
12-
* (c) 2014 Wes Cruver
12+
* (c) 2016 Wes Cruver
1313
* License: MIT
1414
*/
1515

@@ -62,7 +62,7 @@
6262
'</tr>' +
6363
'</tbody></table>' +
6464
'<div ng-bind-html="footer" ng-if="footer"></div>' +
65-
'<div class="cfp-hotkeys-close" ng-click="toggleCheatSheet()">×</div>' +
65+
'<div class="cfp-hotkeys-close" ng-click="toggleCheatSheet()">&#215;</div>' +
6666
'</div></div>';
6767

6868
/**
@@ -79,10 +79,24 @@
7979

8080
this.$get = ['$rootElement', '$rootScope', '$compile', '$window', '$document', function ($rootElement, $rootScope, $compile, $window, $document) {
8181

82+
var mouseTrapEnabled = true;
83+
84+
function pause() {
85+
mouseTrapEnabled = false;
86+
}
87+
88+
function unpause() {
89+
mouseTrapEnabled = true;
90+
}
91+
8292
// monkeypatch Mousetrap's stopCallback() function
8393
// this version doesn't return true when the element is an INPUT, SELECT, or TEXTAREA
8494
// (instead we will perform this check per-key in the _add() method)
8595
Mousetrap.prototype.stopCallback = function(event, element) {
96+
if (!mouseTrapEnabled) {
97+
return true;
98+
}
99+
86100
// if the element has the class "mousetrap" then no need to stop
87101
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
88102
return false;
@@ -98,14 +112,14 @@
98112
*/
99113
function symbolize (combo) {
100114
var map = {
101-
command : '⌘',
102-
shift : '⇧',
103-
left : '←',
104-
right : '→',
105-
up : '↑',
106-
down : '↓',
107-
'return' : '↩',
108-
backspace : '⌫'
115+
command : '\u2318', // ⌘
116+
shift : '\u21E7', // ⇧
117+
left : '\u2190', // ←
118+
right : '\u2192', // →
119+
up : '\u2191', // ↑
120+
down : '\u2193', // ↓
121+
'return' : '\u23CE', // ⏎
122+
backspace : '\u232B' // ⌫
109123
};
110124
combo = combo.split('+');
111125

@@ -221,9 +235,9 @@
221235
* attached. This is useful to catch when the scopes are `$destroy`d and
222236
* then automatically unbind the hotkey.
223237
*
224-
* @type {Array}
238+
* @type {Object}
225239
*/
226-
var boundScopes = [];
240+
var boundScopes = {};
227241

228242
if (this.useNgRoute) {
229243
$rootScope.$on('$routeChangeSuccess', function (event, route) {
@@ -563,7 +577,6 @@
563577
};
564578
}
565579

566-
567580
var publicApi = {
568581
add : _add,
569582
del : _del,
@@ -576,7 +589,9 @@
576589
cheatSheetDescription : this.cheatSheetDescription,
577590
useNgRoute : this.useNgRoute,
578591
purgeHotkeys : purgeHotkeys,
579-
templateTitle : this.templateTitle
592+
templateTitle : this.templateTitle,
593+
pause : pause,
594+
unpause : unpause
580595
};
581596

582597
return publicApi;
@@ -590,13 +605,14 @@
590605
return {
591606
restrict: 'A',
592607
link: function (scope, el, attrs) {
593-
var key, allowIn;
608+
var keys = [],
609+
allowIn;
594610

595611
angular.forEach(scope.$eval(attrs.hotkey), function (func, hotkey) {
596612
// split and trim the hotkeys string into array
597613
allowIn = typeof attrs.hotkeyAllowIn === "string" ? attrs.hotkeyAllowIn.split(/[\s,]+/) : [];
598614

599-
key = hotkey;
615+
keys.push(hotkey);
600616

601617
hotkeys.add({
602618
combo: hotkey,
@@ -609,7 +625,7 @@
609625

610626
// remove the hotkey if the directive is destroyed:
611627
el.bind('$destroy', function() {
612-
hotkeys.del(key);
628+
angular.forEach(keys, hotkeys.del);
613629
});
614630
}
615631
};

0 commit comments

Comments
 (0)