Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

File Shortcut & Horizontal bar in locked mode #132

Closed
wants to merge 20 commits into from

Conversation

Logic-gate
Copy link

fixes issues #91 and #40

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.
Shortcut keys for Save, New, and Duplicate now include alt
@seejohnrun
Copy link
Contributor

I agree these are annoying - but maybe we can just change the shortcuts for the problematic browsers?

@Logic-gate
Copy link
Author

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.

@seejohnrun
Copy link
Contributor

Are they problematic because they conflict with save, new window, etc?

@Logic-gate
Copy link
Author

Logic-gate commented Sep 19, 2016

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

@seejohnrun
Copy link
Contributor

Cool - maybe on Mac computers we stick with Ctrl+N since there's no
conflict there?

On Mon, Sep 19, 2016 at 1:25 PM, Amer Almadani [email protected]
wrote:

Yes, Control + N for instance creates a new browser window rather than a
new haste.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#132 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAD9xblDoKZYA5FIBvVSC46M2fejGGWtks5qrsV-gaJpZM4Jt_Tc
.

@Logic-gate
Copy link
Author

Do you have a mac? I can't test it.

@seejohnrun
Copy link
Contributor

Yep I do - I decided on the original key combinations (which are natural
for a mac user), because I don't use a PC too often

On Mon, Sep 19, 2016 at 1:32 PM, Amer Almadani [email protected]
wrote:

Do you have a mac? I can't test it.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#132 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAD9xTZwyGerhVQRD6PjEotrQVD_236Wks5qrsc8gaJpZM4Jt_Tc
.

@Logic-gate
Copy link
Author

Logic-gate commented Sep 22, 2016

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.

Copy link
Contributor

@seejohnrun seejohnrun left a 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

@@ -258,13 +258,31 @@ haste.prototype.lockDocument = function() {

haste.prototype.configureButtons = function() {
var _this = this;
var save_desc = "control + alt + s";
Copy link
Contributor

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



/* navigator.appVersion.indexOf("Mac")!=-1; */
if (navigator.appVersion.indexOf("Mac")!=-1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is includeAlt

/* 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)};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would remove this duplication

@@ -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);
Copy link
Contributor

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
@Logic-gate
Copy link
Author

Logic-gate commented Oct 1, 2016

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

Copy link
Contributor

@seejohnrun seejohnrun left a 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%;
Copy link
Contributor

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

Copy link

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

@@ -256,15 +256,28 @@ haste.prototype.lockDocument = function() {
});
};


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline

haste.prototype.configureButtons = function() {
var _this = this;

var includeAlt = navigator.appVersion.indexOf("Mac")!=-1;
Copy link
Contributor

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


function isShortcutFor(evt, keycode) {
return includeAlt ? evt.ctrlKey && evt.keyCode === keycode : evt.ctrlKey && evt.altKey && evt.keyCode === keycode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline here

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semicolons

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
Copy link
Contributor

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)

Copy link
Author

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

Copy link
Author

@Logic-gate Logic-gate Oct 1, 2016

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.

Copy link
Contributor

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)

Copy link
Author

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.

Copy link
Contributor

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

@@ -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;
Copy link
Contributor

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?

@Logic-gate
Copy link
Author

Sure, will get right on it.

Heroku testing
opted for file type due to ease...~lazy~
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Mar 8, 2022
@github-actions
Copy link

This PR was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants