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

Preview refactor #1346

Merged
merged 8 commits into from
Jan 18, 2018
Merged

Preview refactor #1346

merged 8 commits into from
Jan 18, 2018

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Jan 18, 2018

Refactors the preview window JS code and adds a nice little UX feature.

The preview window JS code we inject into the page we are previewing was using jQuery for DOM querying and manipulating. For that to work on pages not using jQuery (very common these days) we have our oen custom jQuery loader that loads jQuery on demand. Javascript of modern browsers widely supports ES5 features that makes jQuery nearly obsolote. This change drops support for IE (even 11), but we never supported IE anyways and the market share is very low. Edge, IEs succesor supports all of the used features. Firefox and Chrome as well. Long story short: We can remove lots of custom code and the jQuery dependency from the code we inject into the DOM of a page we do not own.

Includes a feature that blurs the elements (aka. removes the frame of selected elements) in preview and element editors if user clicks somewhere else than the element editor body. Before the "selected element frame" could never be removed after the user clicks the element in the preview or on the element editors head. Also the element itself now gets highlighted if the user clicks anywhere on the element body, not only on click of the element head. Nice little UI enhancement that will help users better understand which element she currently is working with.

@tvdeyen
Copy link
Member Author

tvdeyen commented Jan 18, 2018

Fixes two code quality issues \o/

alchemy_cms - code climate 2018-01-18 09-56-17

@tvdeyen
Copy link
Member Author

tvdeyen commented Jan 18, 2018

Dang, we should switch to headless chrome. The tests fail because phantomjs does not support modern javascript 😩

@tvdeyen tvdeyen self-assigned this Jan 18, 2018
@tvdeyen
Copy link
Member Author

tvdeyen commented Jan 18, 2018

Builds will be fixed once we merge #1347

@tvdeyen tvdeyen removed their assignment Jan 18, 2018
@tvdeyen tvdeyen force-pushed the preview-refactor branch 2 times, most recently from 8d5b67c to 36121ae Compare January 18, 2018 13:14
@tvdeyen tvdeyen requested a review from mamhoff January 18, 2018 13:15
@tvdeyen
Copy link
Member Author

tvdeyen commented Jan 18, 2018

@mamhoff builds on top of #1347 now

@tvdeyen tvdeyen force-pushed the preview-refactor branch 2 times, most recently from 264780b to 1df9a19 Compare January 18, 2018 14:40
We used to rely on jQuery being present in the preview window. If it's not present we loaded jQuery via our custon jQuery loader. This removes support for IE (even 11), but we never officially supported IE anyways and Edge should work as any other modern browser.

We can now remove the custom jQuery loader and lower the page load we inject into the preview window dom.
As we do not use jQuery in the preview window js anymore, we can now remove the custom jQuery loader.
Outline is widley supported nowadays and we don't need vendor specific prefixes anymore. This let us remove the browser sniffing module from the JS we inject into the preview frame.
In order to be able to provide better UI we focus the element editor (aka. highlighting it) on click anywhere on the element, not only on the header like we did before.
Blurs (deselects) the element editor and the element preview if user clicks on somewhere else as the element body.
If we stop event propagation then the event does not bubble up the dom and will never reach other event handlers, like the blur elements event on the body. Still prevents default browser click event handler.
The reload preview button always caused the whole page to be reloaded because the event was never told to stop default event.
Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@tvdeyen tvdeyen merged commit 8d81d9e into AlchemyCMS:master Jan 18, 2018
@tvdeyen tvdeyen deleted the preview-refactor branch January 18, 2018 16:58
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