Updated to reflect changes request

This commit is contained in:
Amer Almadani 2016-10-07 16:52:13 +03:00 committed by GitHub
parent 9b06b00379
commit e8dda0b0cb
1 changed files with 10 additions and 15 deletions

View File

@ -256,20 +256,16 @@ haste.prototype.lockDocument = function() {
}); });
}; };
haste.prototype.configureButtons = function() { haste.prototype.configureButtons = function() {
var _this = this; var _this = this;
var includeAlt = navigator.appVersion.indexOf("Mac")!== -1;
var includeAlt = navigator.appVersion.indexOf("Mac")!=-1;
function isShortcutFor(evt, keycode) { function isShortcutFor(evt, keycode) {
return includeAlt ? evt.ctrlKey && evt.keyCode === keycode : evt.ctrlKey && evt.altKey && evt.keyCode === keycode return evt.ctrlKey && evt.keyCode === keycode && (!includeAlt || evt.altKey);
};
}
function shortcutDescFor(letter) { function shortcutDescFor(letter) {
return includeAlt ? 'control + ' + letter : 'control + alt + ' + letter return includeAlt ? 'control + ' + letter : 'control + alt + ' + letter;
} };
this.buttons = [ this.buttons = [
{ {
@ -277,7 +273,7 @@ haste.prototype.configureButtons = function() {
label: 'Save', label: 'Save',
shortcutDescription: shortcutDescFor('s'), shortcutDescription: shortcutDescFor('s'),
shortcut: function(evt) { shortcut: function(evt) {
return isShortcutFor(evt, 83); return isShortcutFor(evt, 83);
}, },
action: function() { action: function() {
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') { if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
@ -289,7 +285,7 @@ haste.prototype.configureButtons = function() {
$where: $('#box2 .new'), $where: $('#box2 .new'),
label: 'New', label: 'New',
shortcut: function(evt) { shortcut: function(evt) {
return isShortcutFor(evt, 78); return isShortcutFor(evt, 78);
}, },
shortcutDescription: shortcutDescFor('n'), shortcutDescription: shortcutDescFor('n'),
action: function() { action: function() {
@ -300,7 +296,7 @@ haste.prototype.configureButtons = function() {
$where: $('#box2 .duplicate'), $where: $('#box2 .duplicate'),
label: 'Duplicate & Edit', label: 'Duplicate & Edit',
shortcut: function(evt) { shortcut: function(evt) {
return isShortcutFor(evt, 68); return isShortcutFor(evt, 68);
}, },
shortcutDescription: shortcutDescFor('d'), shortcutDescription: shortcutDescFor('d'),
action: function() { action: function() {
@ -311,7 +307,7 @@ haste.prototype.configureButtons = function() {
$where: $('#box2 .raw'), $where: $('#box2 .raw'),
label: 'Just Text', label: 'Just Text',
shortcut: function(evt) { shortcut: function(evt) {
return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82; return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82;
}, },
shortcutDescription: 'control + shift + r', shortcutDescription: 'control + shift + r',
action: function() { action: function() {
@ -322,7 +318,7 @@ haste.prototype.configureButtons = function() {
$where: $('#box2 .twitter'), $where: $('#box2 .twitter'),
label: 'Twitter', label: 'Twitter',
shortcut: function(evt) { shortcut: function(evt) {
return _this.options.twitter && _this.doc.locked && evt.shiftKey && evt.ctrlKey && evt.keyCode == 84; return _this.options.twitter && _this.doc.locked && evt.shiftKey && evt.ctrlKey && evt.keyCode == 84;
}, },
shortcutDescription: 'control + shift + t', shortcutDescription: 'control + shift + t',
action: function() { action: function() {
@ -406,5 +402,4 @@ $(function() {
} }
} }
}); });
}); });