Part of the JavaScript selectors clean-up effort.
#1574470: Selectors clean-up
#1415788: Javascript winter clean-up
Beta phase evaluation
| Issue category | Task, bartik preview functionality code clean up. |
|---|---|
| Issue priority | Normal |
| Prioritized changes | The main goal of this issue is maintainability and performance. Making the code easier to understand (and to follow our jQuery variable naming convention) as well as restricting scope with which DOM elements are selected. |
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | selectors_clean_up-1751436-45.patch | 3.94 KB | droplet |
| #40 | selectors_clean_up-1751436-34.patch | 4.3 KB | sashi.kiran |
| #33 | interdiff.txt | 5.21 KB | pguillard |
| #33 | selectors_clean_up-1751436-33.patch | 4.25 KB | pguillard |
| #27 | selectors_clean_up-1751436-27.patch | 4.05 KB | pguillard |
Comments
Comment #1
nod_horrible selectors
Comment #2
nod_tag
Comment #3
eli-f commentedJSHint complains
Also, when I get D8 up and running I can refactor the selectors to be more efficient.
Comment #4
eli-f commentedFirst revision patch. I need to look at where Drupal.color.callback is called to remove the arguments no longer used in this method.
Comment #5
eli-f commentedI am corrected the patch naming so it can be tested properly.
EDIT
I actually still did not name it correctly... I shall ask around before uploading another.
Comment #6
nod_proper way to send patch is to put it as Need review and someone else not involved in the patch to put it as reviewed and tested by the community. You can't do that on your own for core patches :)
had a quick look, looks ok :)
Comment #7
eli-f commentedGotcha. Thanks for the tip;
Comment #8
rteijeiro commentedI have reviewed the patch and added some improvements. Also added a interdiff.txt for easy reviewing ;)
Comment #10
rteijeiro commented#8: 1751436-bartik-color-js-cleanup-8.patch queued for re-testing.
Comment #11
nod_Only change is for the variable declaration so that they follow core standards.
Comment #12
jgrubb commentedHey, I'm really sorry that I'm late to the party, but is there a reason that the core standards are this way? Most of the javascript coding world has settled on the single var pattern, ala patch #8. If this convention were used everywhere, it would probably add up to a larger than trivial amount over the wire. We also wouldn't have knowledgable JS developers coming to Drupal and wondering what we're doing. I can't find where it's stated that it should be this way, and why.
Thank you...
Comment #13
nod_Yes you're a few months late to the party. #1483396: [policy, no patch] JavaScript coding standards for variable declarations, look at #16
"Most of the javascript coding world has settled on the single var pattern", nodejs is not the javascript world, it's part of it. As a wikipedia editor would say: "need references".
Also if code style is your thing and you want the doc to be updated, check out #1778828: [policy, no patch] Update JS coding standards.
Comment #14
markhalliwelltagging for my reference (component maintainer now)
Comment #17
manuel garcia commentedComment #18
rteijeiro commentedRe-rolled!
Comment #19
pguillard commentedAfter patch application, I played with the Bartik color scheme preview for a while, was silent in the Chrome/FFx console.
Comment #20
nod_we want a "var" for each variable here:
Comment #22
nod_Comment #23
dimaro commentedAdd the proposed changes in #20
Comment #24
rteijeiro commentedLet's wait for testbot and @nod_'s opinion but looks RTBC. Thanks @dimaro!
Comment #25
nod_RTBC++
Comment #26
alexpottPlus this issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.
Comment #27
pguillard commentedCorrected
Comment #28
alexpottComment #29
nod_Beta eval added.
Code lint properly and color preview still works.
Comment #30
xjmThe summary suggests this patch has a performance impact; can someone clarify what that is? (Also in the parent issue at #1574470: Selectors clean-up since I imagine that would apply to other child issues as well.)
Comment #31
xjmAlso, is there any disruption from this to contrib or custom modules or themes? Any JS BC break?
Comment #32
nod_Perf impact is present but not that important. There is no API change, it's internal bartik refactoring. The color api is defined in the color module, bartik is using it like any other contrib module would.
About the perf, we're reducing our selection scope, instead of selecting elements from the wrapping
<form>element, we're selecting elements from inside<div id="preview">only.Do we still to update the IS or does this makes it clear enough?
This needs reroll though.
Comment #33
pguillard commentedPatch re-rolled
Comment #34
xjm@nod_, I'd suggest updating the summary of #1574470: Selectors clean-up, since whether or not this patch has actual performance impact affects whether it can be accepted during the beta. See https://www.drupal.org/core/beta-changes. In general, internal refactorings are no longer allowed during the beta phase, for both PHP and JavaScript. If the performance impact is negligible, it might be better to postpone these cleanups.
Comment #35
droplet commentedIf anyone could help to reroll it. I promise you I will help you review it and get it move forward.
Now, it's only needed some basic caching for selectors,eg
form.find('.color-previewComment #36
droplet commentedComment #37
zeeshan_khan commentedComment #38
zeeshan_khan commentedI couldn't find any more code to cached as I see all selectors are being cached properly. :)
Comment #39
droplet commentedLooking at wrong file ?
http://cgit.drupalcode.org/drupal/tree/core/themes/bartik/color/preview.js
Every lines are needed some work :) Thanks!
Comment #40
sashi.kiran commentedI have updated the patch.
Comment #41
droplet commentedPatch #33 is outdated. You can't reroll it directly. Many code is already removed.
Comment #42
sashi.kiran commented@Droplet: I have just checked the Patch #33 with the latest code and I am able to find all the lines in the Patch.
Following line was mismatching, which I have updated:
form.find('.color-preview .color-preview-header').attr('style', "background-color: " + gradient_start + "; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(" + gradient_start + "), to(" + gradient_end + ")); background-image: -moz-linear-gradient(-90deg, " + gradient_start + ", " + gradient_end + ");");
Please correct me if I am wrong :) Thanks!
Comment #44
droplet commentedComment #45
droplet commented@sashi.kiran,
You may right :) Sadly, I think Patch #34 / #42 are not so reviewable.
Since it's rarely used in other pages, I think only a simple improves is acceptable.
Comment #46
droplet commentedComment #47
dimaro commented@droplet Update this issue to run your patch.
Comment #48
nod_#45 is good to go.
We're going for something simple so while #34/#40 work an are an improvement, the color module needs a refactoring and we can improve that when it'll happen, for now we try to change as little as possible.
Comment #49
zeeshan_khan commentedComment #50
manjit.singhReady to ship .. hu ha
RTBC ++
Comment #52
catchCommitted/pushed to 8.1.x, thanks!