Applied requested changes
In the original version `duplicate` called `_this.doc.locked`. this was removed. Is this really necessary?? Also please test `control + n` on Mac. FF kept opening a new window
This commit is contained in:
parent
d494833f67
commit
a884e097f8
|
@ -256,33 +256,28 @@ haste.prototype.lockDocument = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
haste.prototype.configureButtons = function() {
|
haste.prototype.configureButtons = function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var save_desc = "control + alt + s";
|
|
||||||
var save_shortcut = function(evt) {return evt.ctrlKey && evt.altKey &&(evt.keyCode === 83)};
|
|
||||||
var new_desc = "control + alt + n";
|
|
||||||
var new_shortcut = function(evt) {return evt.ctrlKey && evt.altKey && evt.keyCode === 78};
|
|
||||||
var duplicate_desc = "control + alt + d";
|
|
||||||
var duplicate_shortcut = function(evt) {return _this.doc.locked && evt.ctrlKey && evt.altKey && evt.keyCode === 68};
|
|
||||||
|
|
||||||
|
var includeAlt = navigator.appVersion.indexOf("Mac")!=-1;
|
||||||
|
|
||||||
/* navigator.appVersion.indexOf("Mac")!=-1; */
|
function isShortcutFor(evt, keycode) {
|
||||||
if (navigator.appVersion.indexOf("Mac")!=-1) {
|
return includeAlt ? evt.ctrlKey && evt.keyCode === keycode : evt.ctrlKey && evt.altKey && evt.keyCode === keycode
|
||||||
save_desc = "control + s";
|
|
||||||
save_shortcut = function(evt) {return evt.ctrlKey && (evt.keyCode === 83)};
|
}
|
||||||
new_desc = "control + n";
|
function shortcutDescFor(letter) {
|
||||||
new_shortcut = function(evt) {return evt.ctrlKey && evt.keyCode === 78};
|
return includeAlt ? 'control + ' + letter : 'control + alt + ' + letter
|
||||||
duplicate_desc = "control + d";
|
|
||||||
duplicate_shortcut = function(evt) {return _this.doc.locked && evt.ctrlKey && evt.keyCode === 68;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.buttons = [
|
this.buttons = [
|
||||||
{
|
{
|
||||||
$where: $('#box2 .save'),
|
$where: $('#box2 .save'),
|
||||||
label: 'Save',
|
label: 'Save',
|
||||||
shortcutDescription: save_desc,
|
shortcutDescription: shortcutDescFor('s'),
|
||||||
shortcut: function(evt) {
|
shortcut: function(evt) {
|
||||||
return save_shortcut(evt);
|
return isShortcutFor(evt, 83);
|
||||||
},
|
},
|
||||||
action: function() {
|
action: function() {
|
||||||
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
|
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
|
||||||
|
@ -294,9 +289,9 @@ haste.prototype.configureButtons = function() {
|
||||||
$where: $('#box2 .new'),
|
$where: $('#box2 .new'),
|
||||||
label: 'New',
|
label: 'New',
|
||||||
shortcut: function(evt) {
|
shortcut: function(evt) {
|
||||||
return new_shortcut(evt);
|
return isShortcutFor(evt, 78);
|
||||||
},
|
},
|
||||||
shortcutDescription: new_desc,
|
shortcutDescription: shortcutDescFor('n'),
|
||||||
action: function() {
|
action: function() {
|
||||||
_this.newDocument(!_this.doc.key);
|
_this.newDocument(!_this.doc.key);
|
||||||
}
|
}
|
||||||
|
@ -305,9 +300,9 @@ haste.prototype.configureButtons = function() {
|
||||||
$where: $('#box2 .duplicate'),
|
$where: $('#box2 .duplicate'),
|
||||||
label: 'Duplicate & Edit',
|
label: 'Duplicate & Edit',
|
||||||
shortcut: function(evt) {
|
shortcut: function(evt) {
|
||||||
return duplicate_shortcut(evt);
|
return isShortcutFor(evt, 68);
|
||||||
},
|
},
|
||||||
shortcutDescription: duplicate_desc,
|
shortcutDescription: shortcutDescFor('d'),
|
||||||
action: function() {
|
action: function() {
|
||||||
_this.duplicateDocument();
|
_this.duplicateDocument();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue