? Success

User tests: Successful: Unsuccessful:

avatar smz
smz
16 Dec 2014

Both component and module search results were affected.
jquery.autocomplete.min.js was loded before jQuery

avatar smz smz - open - 16 Dec 2014
avatar jissues-bot jissues-bot - change - 16 Dec 2014
Labels Added: ?
avatar smz
smz - comment - 16 Dec 2014

See: #5438 for details.

avatar waader
waader - comment - 16 Dec 2014

@test works!

Thanks, smz!

avatar waader waader - test_item - 16 Dec 2014 - Tested successfully
avatar brianteeman brianteeman - change - 16 Dec 2014
Category JavaScript Search
avatar shur
shur - comment - 16 Dec 2014

@smz
jquery.autocomplete.min.js is used for Search Suggestions and it's not always loaded because search suggestions can be disabled in finder component settings or in finder module settings.

Probably the better way is to add JHtml::_('jquery.framework'); line after condition:
if ($params->get('show_autosuggest', 1))
I checked, highlight works in this case fine.

avatar dgt41
dgt41 - comment - 16 Dec 2014

@smz I think the best solution here is to edit behavior.php and add jquery.framework under the function for highlighter.

avatar dgt41
dgt41 - comment - 16 Dec 2014

@smz I was wrong, advanced also needs jquery.

@test OK

avatar smz
smz - comment - 16 Dec 2014

Guys, I'm full of doubts: while it is true that also with my first commit things do works (even autocomplete and that also if highlighting is turned off), it also true that autocomplete needs jQuery, so conceptually we should explicitly load it also for it, even though there are at least "very good odds" that jQuery is loaded somewhere else.

So I think that everything boils down to this: do we want optimized code or safer code?

A possible alternative could be to put the following at the top:

if ($this->params->get('show_advanced', 1) || $this->params->get('show_autosuggest', 1))
{
    JHtml::_('behavior.core');
    JHtml::_('jquery.framework');
}

(@dgt41 core needed in both cases, right?)

Same about @dgt41's proposal of putting JHtml::_('jquery.framework'); inside behavior.php, before the highlighter thing: probably unneeded, but safer...

As @okonomiyaki3000 as shown in #5154, sometimes code optimization can have dramatic results...

avatar smz
smz - comment - 16 Dec 2014

@dgt41 Unrelated. Dimitris, I think that if both autocomplete and highlight are turned off you end up creating an empty jQuery function. Do you want me to fix that too while I'm editing this file?

avatar dgt41
dgt41 - comment - 16 Dec 2014

@smz actually that suggestion for behavior.php is wrong, because the relative code is already there.
The logic needs some improvements, my initial approach here was: don’t break anything, remove mootools where possible. So yes both core and jquery can be selectively loaded only when needed. Just as a remark: the old behavior.framework was always loading core.js, also the behavior.core till very recently was loading jquery also, now it isn’t. Bottom line we have to go through all the views and explicitly call whatever is needed each time. Mootools is mostly out but still there might be room for further improvement (due to the changes in behavior.core)
My 2c

avatar smz
smz - comment - 16 Dec 2014

@dgt41 look at the latest commit: apparently it is a "major" work, but actually I just conditioned the whole script generation (and JS libraries loading) to the existence of at least one of the parameters requiring it...

Is that OK for you?

avatar smz
smz - comment - 16 Dec 2014

If it is OK, can we give this a kick in the butt? @waader can you please re-test? @dgt41 remember the @test in Jissues...

avatar dgt41
dgt41 - comment - 16 Dec 2014

@smz If I clear both core and jquery I still don’t get any errors. Can you give me instructions how you came up with an error here? Both those calls seem unneeded here

avatar smz
smz - comment - 16 Dec 2014

@dgt41 Ehhmm... which error? The initial one?

avatar dgt41
dgt41 - comment - 16 Dec 2014

yeap

avatar smz
smz - comment - 16 Dec 2014

Just a very simple site (Protostar), with "Smart Search" both as a menu item and a module... Skype+TeamViewer come and see?

avatar smz
smz - comment - 16 Dec 2014

Hold on everybody: further commits are probably coming...

avatar smz
smz - comment - 16 Dec 2014

Still hold on, please...

avatar smz
smz - comment - 16 Dec 2014

PR ready for testing: thanks!

avatar waader
waader - comment - 16 Dec 2014

@(re)test works for me, thanks!

avatar smz
smz - comment - 16 Dec 2014

Thanks for testing, @waader !

avatar roland-d
roland-d - comment - 17 Dec 2014

@test Success, after applying the patch the highlighting works. Just need to remove that one duplicate line.

avatar roland-d roland-d - test_item - 17 Dec 2014 - Tested unsuccessfully
avatar smz
smz - comment - 17 Dec 2014

@roland-d Fixed. Thank-you for testing!

avatar dgt41
dgt41 - comment - 17 Dec 2014

@test success

avatar smz
smz - comment - 17 Dec 2014

@dgt41 Thanks, Dimitris!

avatar roland-d roland-d - close - 17 Dec 2014
avatar roland-d roland-d - change - 17 Dec 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-12-17 16:30:27

Add a Comment

Login with GitHub to post a comment