-
Notifications
You must be signed in to change notification settings - Fork 801
File Shortcut & Horizontal bar in locked mode #132
Conversation
As stated in issue toptal#40; ctrl + n creates a new browser window rather than a new file. New shortcut ctlr + alt + n.
As stated in issue toptal#91, the scroll bar(horizontal) appears when in locked mode. The suggested fix does in fact work.
Highlight update
Shortcut keys for Save, New, and Duplicate now include alt
I agree these are annoying - but maybe we can just change the shortcuts for the problematic browsers? |
Fair point, but the problematic browsers are the most popular. Chrome, Firefox, and Safari(Not Tested) and there derivatives(C & FF). Someone needs to test this on Safari. |
Are they problematic because they conflict with save, new window, etc? |
Yes, Control + N for instance creates a new browser window rather than a new haste. Chromium, vivaldi, FF Test the changes here https://ma.tc |
Cool - maybe on Mac computers we stick with Ctrl+N since there's no On Mon, Sep 19, 2016 at 1:25 PM, Amer Almadani [email protected]
|
Do you have a mac? I can't test it. |
Yep I do - I decided on the original key combinations (which are natural On Mon, Sep 19, 2016 at 1:32 PM, Amer Almadani [email protected]
|
Okay...took me awhile. Now, before your head explodes from how bad it is written, keep in mind Python is my forte' I never understood JS... Live test here https://ma.tc EDIT: I tested it on Linux using a User-agent switcher, it does work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thank you! I have some ideas here to simplify things a bit, but otherwise going well
static/application.js
Outdated
@@ -258,13 +258,31 @@ haste.prototype.lockDocument = function() { | |||
|
|||
haste.prototype.configureButtons = function() { | |||
var _this = this; | |||
var save_desc = "control + alt + s"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that instead of having each be a separate case, we could introduce a variable called something like includeAlt
which is a boolean, and then have two functions:
isShortcutFor(evt, keyCode)
which basically is (!includeAlt || evt.ctrlKey) && evt.keyCode === keyCode)
and another that's like shortcutDescFor(letter)
which puts together the string based on includeAlt
like: 'control + ' + (includeAlt ? 'control + ' : '') + ' + ' + letter
This would tighten up your code and make this much more readable
static/application.js
Outdated
|
||
|
||
/* navigator.appVersion.indexOf("Mac")!=-1; */ | ||
if (navigator.appVersion.indexOf("Mac")!=-1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is includeAlt
static/application.js
Outdated
/* 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)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would remove this duplication
static/application.js
Outdated
@@ -276,9 +294,9 @@ haste.prototype.configureButtons = function() { | |||
$where: $('#box2 .new'), | |||
label: 'New', | |||
shortcut: function(evt) { | |||
return evt.ctrlKey && evt.keyCode === 78 | |||
return new_shortcut(evt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing is off here (spaces over tabs)
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
Sorry it took awhile, was a bit busy. Applied the changes you requested, within the boundaries of my JS knowledge. Live version at ma.tc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good, much clearer - a few quick comments (and thank you!)
@@ -38,7 +38,6 @@ textarea { | |||
#box { | |||
padding: 0px; | |||
margin: 0px; | |||
width: 100%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I may have fixed this with #135 but don't know for sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope #135 not fix issue
static/application.js
Outdated
@@ -256,15 +256,28 @@ haste.prototype.lockDocument = function() { | |||
}); | |||
}; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline
static/application.js
Outdated
haste.prototype.configureButtons = function() { | ||
var _this = this; | ||
|
||
var includeAlt = navigator.appVersion.indexOf("Mac")!=-1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good here to use !== -1
for clarity
static/application.js
Outdated
|
||
function isShortcutFor(evt, keycode) { | ||
return includeAlt ? evt.ctrlKey && evt.keyCode === keycode : evt.ctrlKey && evt.altKey && evt.keyCode === keycode | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline here
static/application.js
Outdated
var includeAlt = navigator.appVersion.indexOf("Mac")!=-1; | ||
|
||
function isShortcutFor(evt, keycode) { | ||
return includeAlt ? evt.ctrlKey && evt.keyCode === keycode : evt.ctrlKey && evt.altKey && evt.keyCode === keycode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semicolons
static/application.js
Outdated
var includeAlt = navigator.appVersion.indexOf("Mac")!=-1; | ||
|
||
function isShortcutFor(evt, keycode) { | ||
return includeAlt ? evt.ctrlKey && evt.keyCode === keycode : evt.ctrlKey && evt.altKey && evt.keyCode === keycode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this is duplicative, may be easier to write like:
evt.ctrlKey && evt.keyCode === keyCode && (!includeAlt || evt.altKey)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh...I was looking for this. Thanks. Still cant get my head around JS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming that the latter part is some kind of nested statement, (!condition || if false). I can't seem to test this using the user agent switcher. Could you please test it on ma.tc. It does it does work with 'alt'. I just need confirmation before the I commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be due to the capitalization of keyCode
if you didn't catch that - needs to match between the function param and the use (my code didn't)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did catch it. I think should it work. Because it does catch the non mac condition and assigns altKey
. I cant test it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool - if you push your code I can take a look
static/application.js
Outdated
@@ -298,7 +311,7 @@ haste.prototype.configureButtons = function() { | |||
$where: $('#box2 .raw'), | |||
label: 'Just Text', | |||
shortcut: function(evt) { | |||
return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82; | |||
return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to keep these indentations, right?
Sure, will get right on it. |
did not take into account the format for a singular addon
Heroku testing
opted for file type due to ease...~lazy~
This PR is stale because it has been open for 30 days with no activity. |
This PR was closed because it has been inactive for 14 days since being marked as stale. |
fixes issues #91 and #40