Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing jQuery from 7 more functions. #1105

Merged
merged 13 commits into from
Jul 20, 2022
Merged

Conversation

ymeynot45
Copy link
Contributor

@ymeynot45 ymeynot45 commented Jul 5, 2022

Things amended to no longer require jQuery:

  • upvoteComment()
  • upvoteStory()
  • flagComment()
  • flagStory()
  • previewStory()
  • fetchURLTitle()
  • disowning comments
  • comment_replier

Bug Fixes

  • an autosize bug on text areas that load on a new page without user prompting.
  • a bug on the reply button that allowed you to only click it once.

This leaves less than 1/2 dozen things to be replaced before we can remove the jQuery library.

Copy link
Member

@pushcx pushcx left a comment

Choose a reason for hiding this comment

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

Sorry it took a while to get to this one. It looks really good, with only minor tweaks needed.

fetchWithCSRF('/comments/' + li.getAttribute('data-shortid') + '/disown', {
method: 'post'
})
.then(response => response.text())
Copy link
Member

Choose a reason for hiding this comment

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

elsewhere you do response => response.text().then(text => ...

Is there a reason this one's different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, this is easier for me to read,

              .then(response => response.text())
              .then(text => replace(li, text)); 
 with each line independent of the other.  If I was doing a cleanup commit I would convert them all to this formant.  But I will shift it back to the other format.

}

// Inserts "> " on quoted text.
let sel = document.getSelection().toString() || '';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let sel = document.getSelection().toString() || '';
let sel = document.getSelection().toString();

getSelection always returns an object which returns here '' if nothing is selected

let sel = document.getSelection().toString() || '';
if (sel != "") {
sel = sel.split("\n").map(s => "> " + s + '\n').join('');
sel += "\n";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sel += "\n";
sel += "\n\n";

We previously added two newlines after quoted text.

app/assets/javascripts/application.js.erb Outdated Show resolved Hide resolved
app/assets/javascripts/application.js.erb Show resolved Hide resolved
app/views/comments/_comment.html.erb Show resolved Hide resolved
app/views/stories/_form.html.erb Show resolved Hide resolved
@ymeynot45 ymeynot45 force-pushed the jqueryless branch 2 times, most recently from e32f0be to bd35588 Compare July 19, 2022 16:06
@pushcx pushcx merged commit cf52ab9 into lobsters:master Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants