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

Add SBS in edit mode, add on/off toggling #2

Merged
merged 12 commits into from
Oct 17, 2015

Conversation

szego
Copy link
Contributor

@szego szego commented Oct 9, 2015

Add the ability to edit existing questions/answers in side-by-side mode.

Also, add the ability to toggle side-by-side editing on an off for each
individual question/answer on the page.

Add the ability to edit existing questions/answers in side-by-side mode.

Also, add the ability to toggle side-by-side editing on an off for each
individual question/answer on the page.
@szego
Copy link
Contributor Author

szego commented Oct 9, 2015

I've tested this on all the pages I could think of and it seems to be working well. I'm not that familiar with javascript/jQuery though and I would definitely appreciate another pair of eyes on it.

@shu8
Copy link
Owner

shu8 commented Oct 9, 2015

@szego firstly: thanks a lot! You must have spent some time doing that! :)

Secondly: I will look at this over the weekend, looking at the code and result. It will probably work, but just to be safe! :)

Thanks again! :)

szego added 10 commits October 9, 2015 11:36
The "previewLength" variable in the sideBySideEditing() function was
mistakenly declared as a global variable. It is now declared as local.
Add a require for version 1.7.1 of the minified jQuery. This is the
version of jQuery used on SE pages.

This script worked on Chrome prior to adding this require, but not on
Firefox. Now it works on Firefox too.

Also made a small change to the description to indicate that the script
is meant to be used on sites on the Stack Exchange network.
Shift the "Toggle Side-By-Side Editing" 6px to the right.

This fixes overlap with the "Redo" buttons on various sites on the SE
network.
The jQuery object returned by $('[id=' + jNode[0].id + ']') will just be
jNode. This fix makes that section of code more readable, at least.
1. Reduces the number of DOM searches that are done on each SBS toggle.

2. Tweak a few element locations to make the UI cleaner.

3. Introduce consistency with quotation marks in the code. Now, single
quotes are used outside, and double quotes are used inside. This is the
new format:

'this is a string with a "double quote part inside" of it'

4. This is pretty much a final update unless there are any unforeseen
bugs that need to be squashed.
Use jQuery's toggleClass() function to toggle the various CSS changes
for side-by-side mode.

This allows all of the CSS changes to be organized nicely near the top
of the script for easy changing.

Previously the script used a boolean dictionary to keep track of which
questions/answers were in side-by-side mode. This is no longer
necessary.

TODO: Fix "draft saved" bumping the side-by-side preview down on the Ask
Question page.
Fixes the behavior of the preview pane on the Ask Question page.

Before, the "draft saved" message would temporarily bump the preview
pane down while it was visible. Now we swap the order of these messages
and the preview pane to prevent this. Some extra css is added to help.

Also, changes the name of the script from "Side By Side Editing" to "SE
Side By Side Editing" to help with identification in the list of scripts
in greasemonkey/tampermonkey.
Adds descriptive comments for the two functions in the code.
Minor fixes to the CSS specific to the "Ask Question" page.
refactor / major / Use toggleClass() to control SBS toggling
@szego
Copy link
Contributor Author

szego commented Oct 12, 2015

@shu8 Just wanted to give you an update. I've refactored the code considerably to make it easier to edit and add to the CSS changes that happen when side-by-side editing is toggled on and off. A summary can be found here: szego#1

Cheers

A few tweaks which were lost somehow. I don't really know how to use
GitHub Desktop yet.
@shu8
Copy link
Owner

shu8 commented Oct 17, 2015

Thanks for that update @szego. I've merged it! :)

shu8 added a commit that referenced this pull request Oct 17, 2015
Add SBS in edit mode, add on/off toggling
@shu8 shu8 merged commit f7ac4ae into shu8:master Oct 17, 2015
@shu8
Copy link
Owner

shu8 commented Oct 17, 2015

BTW I also use this feature in my https://github.com/shu8/SE_OptionalFeatures userscript. I'll update that with this version as well! :) I've done so on my local copy, but I'm ironing out a few other bugs I've got with that before I push it to the develop branch :)

@szego
Copy link
Contributor Author

szego commented Oct 17, 2015

Great :). Would you mind if I add an answer to your post in StackApps to describe the new behavior?

@szego szego deleted the side-by-side/editing-and-toggling branch October 17, 2015 21:17
@shu8
Copy link
Owner

shu8 commented Oct 17, 2015

Sure! It's your code ;) (Just mention that it starts in v1.7 please!)

@shu8
Copy link
Owner

shu8 commented Oct 18, 2015

Sorry -- I thought you were talking about the SE Optional Features one, but yeah -- you can post it on http://stackapps.com/questions/6461/side-by-side-editing, which I think you were actually talking about!
(no need for that version thing!) :)

@shu8
Copy link
Owner

shu8 commented Oct 18, 2015

@szego I've updated my SE Additional Optional Features userscript! It's now in v1.7 (DEV) :) Thanks again!

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