Skip to content

Commit

Permalink
bump version 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chieffancypants committed Feb 18, 2016
1 parent c6fbb7c commit 0725137
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
4 changes: 2 additions & 2 deletions build/hotkeys.css
@@ -1,7 +1,7 @@
/*!
* angular-hotkeys v1.6.0
* angular-hotkeys v1.7.0
* https://chieffancypants.github.io/angular-hotkeys
* Copyright (c) 2015 Wes Cruver
* Copyright (c) 2016 Wes Cruver
* License: MIT
*/
.cfp-hotkeys-container {
Expand Down
54 changes: 35 additions & 19 deletions build/hotkeys.js
@@ -1,15 +1,15 @@
/*!
* angular-hotkeys v1.6.0
* angular-hotkeys v1.7.0
* https://chieffancypants.github.io/angular-hotkeys
* Copyright (c) 2015 Wes Cruver
* Copyright (c) 2016 Wes Cruver
* License: MIT
*/
/*
* angular-hotkeys
*
* Automatic keyboard shortcuts for your angular apps
*
* (c) 2014 Wes Cruver
* (c) 2016 Wes Cruver
* License: MIT
*/

Expand Down Expand Up @@ -62,7 +62,7 @@
'</tr>' +
'</tbody></table>' +
'<div ng-bind-html="footer" ng-if="footer"></div>' +
'<div class="cfp-hotkeys-close" ng-click="toggleCheatSheet()">×</div>' +
'<div class="cfp-hotkeys-close" ng-click="toggleCheatSheet()">&#215;</div>' +
'</div></div>';

/**
Expand All @@ -79,10 +79,24 @@

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

var mouseTrapEnabled = true;

function pause() {
mouseTrapEnabled = false;
}

function unpause() {
mouseTrapEnabled = true;
}

// monkeypatch Mousetrap's stopCallback() function
// this version doesn't return true when the element is an INPUT, SELECT, or TEXTAREA
// (instead we will perform this check per-key in the _add() method)
Mousetrap.prototype.stopCallback = function(event, element) {
if (!mouseTrapEnabled) {
return true;
}

// if the element has the class "mousetrap" then no need to stop
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
return false;
Expand All @@ -98,14 +112,14 @@
*/
function symbolize (combo) {
var map = {
command : '⌘',
shift : '⇧',
left : '←',
right : '→',
up : '↑',
down : '↓',
'return' : '↩',
backspace : '⌫'
command : '\u2318', // ⌘
shift : '\u21E7', // ⇧
left : '\u2190', // ←
right : '\u2192', // →
up : '\u2191', // ↑
down : '\u2193', // ↓
'return' : '\u23CE', // ⏎
backspace : '\u232B' // ⌫
};
combo = combo.split('+');

Expand Down Expand Up @@ -221,9 +235,9 @@
* attached. This is useful to catch when the scopes are `$destroy`d and
* then automatically unbind the hotkey.
*
* @type {Array}
* @type {Object}
*/
var boundScopes = [];
var boundScopes = {};

if (this.useNgRoute) {
$rootScope.$on('$routeChangeSuccess', function (event, route) {
Expand Down Expand Up @@ -563,7 +577,6 @@
};
}


var publicApi = {
add : _add,
del : _del,
Expand All @@ -576,7 +589,9 @@
cheatSheetDescription : this.cheatSheetDescription,
useNgRoute : this.useNgRoute,
purgeHotkeys : purgeHotkeys,
templateTitle : this.templateTitle
templateTitle : this.templateTitle,
pause : pause,
unpause : unpause
};

return publicApi;
Expand All @@ -590,13 +605,14 @@
return {
restrict: 'A',
link: function (scope, el, attrs) {
var key, allowIn;
var keys = [],
allowIn;

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

key = hotkey;
keys.push(hotkey);

hotkeys.add({
combo: hotkey,
Expand All @@ -609,7 +625,7 @@

// remove the hotkey if the directive is destroyed:
el.bind('$destroy', function() {
hotkeys.del(key);
angular.forEach(keys, hotkeys.del);
});
}
};
Expand Down

0 comments on commit 0725137

Please sign in to comment.