From baea36a6f0093e49312bcadba4f4c0cb07ad1303 Mon Sep 17 00:00:00 2001 From: Amer Almadani Date: Thu, 22 Sep 2016 23:07:04 +0300 Subject: [PATCH] Changed Shortcut scheme for Mac --- static/application.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/static/application.js b/static/application.js index b2f90c0..9f34d5e 100644 --- a/static/application.js +++ b/static/application.js @@ -258,13 +258,31 @@ haste.prototype.lockDocument = function() { haste.prototype.configureButtons = function() { 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}; + + +/* navigator.appVersion.indexOf("Mac")!=-1; */ + if (navigator.appVersion.indexOf("Mac")!=-1) { + save_desc = "control + s"; + save_shortcut = function(evt) {return evt.ctrlKey && (evt.keyCode === 83)}; + new_desc = "control + n"; + new_shortcut = function(evt) {return evt.ctrlKey && evt.keyCode === 78}; + duplicate_desc = "control + d"; + duplicate_shortcut = function(evt) {return _this.doc.locked && evt.ctrlKey && evt.keyCode === 68;} + } + this.buttons = [ { $where: $('#box2 .save'), label: 'Save', - shortcutDescription: 'control + alt + s', + shortcutDescription: save_desc, shortcut: function(evt) { - return evt.ctrlKey && evt.altKey && (evt.keyCode === 83); + return save_shortcut(evt); }, action: function() { if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') { @@ -276,9 +294,9 @@ haste.prototype.configureButtons = function() { $where: $('#box2 .new'), label: 'New', shortcut: function(evt) { - return evt.ctrlKey && evt.altKey && evt.keyCode === 78 + return new_shortcut(evt); }, - shortcutDescription: 'control + atl + n', + shortcutDescription: new_desc, action: function() { _this.newDocument(!_this.doc.key); } @@ -287,9 +305,9 @@ haste.prototype.configureButtons = function() { $where: $('#box2 .duplicate'), label: 'Duplicate & Edit', shortcut: function(evt) { - return _this.doc.locked && evt.ctrlKey && evt.altKey && evt.keyCode === 68; + return duplicate_shortcut(evt); }, - shortcutDescription: 'control + alt + d', + shortcutDescription: duplicate_desc, action: function() { _this.duplicateDocument(); }