Skip to content

Commit

Permalink
Displaying all possible keys for a combo in the cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
rerodrigues committed Jul 13, 2016
1 parent 0725137 commit aa8ffa0
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 21 deletions.
14 changes: 14 additions & 0 deletions build/hotkeys.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
}

.cfp-hotkeys-key {
position: relative;
display: inline-block;
color: #fff;
background-color: #333;
Expand All @@ -73,6 +74,19 @@
font-size: 1em;
}

.cfp-hotkeys-key:not(:last-child) {
margin-right: 16px;
}

.cfp-hotkeys-key:not(:last-child)::after {
position: absolute;
content: ',';
font-size: 28px;
color: #000;
right: -8px;
bottom: -7px;
}

.cfp-hotkeys-text {
padding-left: 10px;
font-size: 1em;
Expand Down
24 changes: 14 additions & 10 deletions build/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,19 @@
*/
Hotkey.prototype.format = function() {
if (this._formated === null) {
// Don't show all the possible key combos, just the first one. Not sure
// of usecase here, so open a ticket if my assumptions are wrong
var combo = this.combo[0];

var sequence = combo.split(/[\s]/);
for (var i = 0; i < sequence.length; i++) {
sequence[i] = symbolize(sequence[i]);
}
this._formated = sequence;
// Show all the possible key combos, formatted.
// A possible use case could be a combo with keys that differ from platform to platform.
// ex. combo: ['home','alt+left'] could be used for PC/Mac key bindings
var _formated = [];

angular.forEach(this.combo, function(combo) {
var sequence = combo.split(/[\s]/);
for (var i = 0; i < sequence.length; i++) {
sequence[i] = symbolize(sequence[i]);
}
_formated.push(sequence.join(' '));
});
this._formated = _formated;
}

return this._formated;
Expand Down Expand Up @@ -1050,7 +1054,7 @@
}

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

Expand Down
2 changes: 1 addition & 1 deletion build/hotkeys.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/hotkeys.min.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/hotkeys.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
}

.cfp-hotkeys-key {
position: relative;
display: inline-block;
color: #fff;
background-color: #333;
Expand All @@ -67,6 +68,19 @@
font-size: 1em;
}

.cfp-hotkeys-key:not(:last-child) {
margin-right: 16px;
}

.cfp-hotkeys-key:not(:last-child)::after {
position: absolute;
content: ',';
font-size: 28px;
color: #000;
right: -8px;
bottom: -7px;
}

.cfp-hotkeys-text {
padding-left: 10px;
font-size: 1em;
Expand Down
22 changes: 13 additions & 9 deletions src/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,19 @@
*/
Hotkey.prototype.format = function() {
if (this._formated === null) {
// Don't show all the possible key combos, just the first one. Not sure
// of usecase here, so open a ticket if my assumptions are wrong
var combo = this.combo[0];

var sequence = combo.split(/[\s]/);
for (var i = 0; i < sequence.length; i++) {
sequence[i] = symbolize(sequence[i]);
}
this._formated = sequence;
// Show all the possible key combos, formatted.
// A possible use case could be a combo with keys that differ from platform to platform.
// ex. combo: ['home','alt+left'] could be used for PC/Mac key bindings
var _formated = [];

angular.forEach(this.combo, function(combo) {
var sequence = combo.split(/[\s]/);
for (var i = 0; i < sequence.length; i++) {
sequence[i] = symbolize(sequence[i]);
}
_formated.push(sequence.join(' '));
});
this._formated = _formated;
}

return this._formated;
Expand Down

0 comments on commit aa8ffa0

Please sign in to comment.