Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the key labels to be configurable. #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions build/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@

angular.module('cfp.hotkeys', []).provider('hotkeys', ['$injector', function($injector) {

var symbols = {
command : '⌘',
shift : '⇧',
left : '←',
right : '→',
up : '↑',
down : '↓',
'return' : '↩',
backspace : '⌫'
};

/**
* Configurable setting to disable the cheatsheet entirely
* @type {Boolean}
Expand All @@ -38,6 +49,12 @@

this.templateTitle = 'Keyboard Shortcuts:';

/**
* Configurable setting for keyboard labels
* @type {Object}
*/
this.symbols = symbols;

/**
* Configurable settings for the cheat sheet header and footer. Both are HTML, and the header
* overrides the normal title if specified.
Expand Down Expand Up @@ -97,16 +114,6 @@
* @return {String} The key combination with symbols
*/
function symbolize (combo) {
var map = {
command : '⌘',
shift : '⇧',
left : '←',
right : '→',
up : '↑',
down : '↓',
'return' : '↩',
backspace : '⌫'
};
combo = combo.split('+');

for (var i = 0; i < combo.length; i++) {
Expand All @@ -119,7 +126,7 @@
}
}

combo[i] = map[combo[i]] || combo[i];
combo[i] = symbols[combo[i]] || combo[i];
}

return combo.join(' + ');
Expand Down Expand Up @@ -329,7 +336,7 @@
// these elements are prevented by the default Mousetrap.stopCallback():
var preventIn = ['INPUT', 'SELECT', 'TEXTAREA'];

// Determine if object format was given:
// Determine if object foxrmat was given:
var objType = Object.prototype.toString.call(combo);

if (objType === '[object Object]') {
Expand Down Expand Up @@ -572,6 +579,7 @@
template : this.template,
toggleCheatSheet : toggleCheatSheet,
includeCheatSheet : this.includeCheatSheet,
symbols : symbols,
cheatSheetHotkey : this.cheatSheetHotkey,
cheatSheetDescription : this.cheatSheetDescription,
useNgRoute : this.useNgRoute,
Expand Down Expand Up @@ -1034,7 +1042,7 @@
}

function _belongsTo(element, ancestor) {
if (element === document) {
if (element === null || element === document) {
return false;
}

Expand Down
Loading