? Failure

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
7 Oct 2014

As most of the javascripts are now based on jQuery some calls to load mootools framework are redundant.
This is a response to #4473
This PR removes it from

formvalidate https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L151
combobox https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L215
tooltip https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L257
modal https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L326
noframes https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L701

The only case I left the moo tools framework is for tree.

B/C
Shouldn’t break something, as the scripts are NOT moo tools dependent.

Test
Try different navigation on a site (admin will be easier) and check that form validate, compobox, tooltip, modal and noframes still function as usual. Please check 3PD code with this, let’s NOT break things here!!!

EDIT
Except libraries/joomla/cms/html/behavior.php

I found out that toolbar is always loading mootools, for no particular reason so removed it from the files confirm, standard, help in libraries/joomla/cms/toolbar/button

Also almost all backend views have a basic check for the form where the code expects mootools

document.id('banner-form’)

This can be done also with vanilla document.getElementById('banner-form’)
So most of the changes are document.id -> document.getElementById

Thanks @fedik for the heads up!!!

avatar dgt41 dgt41 - open - 7 Oct 2014
avatar jissues-bot jissues-bot - change - 7 Oct 2014
Labels Added: ?
avatar dgt41
dgt41 - comment - 7 Oct 2014

Tests are failing as the required framework is absent, some help here will be nice ;)

avatar wilsonge
wilsonge - comment - 7 Oct 2014

dgt41#6 help is at hand :)

avatar dgt41
dgt41 - comment - 7 Oct 2014

@wilsonge Thanks for the unit tests code :100: About tooltips: Yes something funny happening there I think is got to do with this code

echo JHtml::tooltipText('COM_CHECKIN_FILTER_SEARCH_DESC’);

Which I think is useless, just a class and a JText::_(’TOOLTIP_TEXT’); is all needed.

I am investigating the (spaghetti code) and hopefully I’ll come up with some changes…

The thing is that you can call tooltips in 2 ways:

JHtml::('bootstrap.tooltip');

And

JHtml::('behavior.tooltip');

The last one needs mootools (legacy staff), but is not used in admin or front end any more...

avatar brianteeman brianteeman - change - 7 Oct 2014
Category JavaScript
67d1b2e 7 Oct 2014 avatar dgt41 CS
avatar dgt41 dgt41 - change - 7 Oct 2014
The description was changed
avatar dgt41
dgt41 - comment - 7 Oct 2014

Travis fails here JHtmlBehaviorTest::testTooltip and here JHtmlBehaviorTest::testNoFrames
But I guess he still expects to find mootools or he doesn’t like jQuery… ????

avatar dgt41 dgt41 - change - 8 Oct 2014
The description was changed
avatar dgt41 dgt41 - change - 8 Oct 2014
The description was changed
avatar dgt41
dgt41 - comment - 8 Oct 2014

Executive summary:

First of all don’t be afraid of the number of files this PR touches.
The changes in all files are straight forward and are grouped in two categories:

  • remove unnecessary calls JHtml::_('behavior.framework’); in
    libraries/cms/html/behavior.php
    libraries/cms/toolbar/button/confirm.php
    libraries/cms/toolbar/button/help.php
    libraries/cms/toolbar/button/standard.php
    But also adding the call, for the time being, at layouts/joomla/toolbar/base.php for not breaking B/C

  • replace all the document.id(’some-form’) in edit views in administrator with native javascript document.getElementById(’some-form’) as suggested by @fedik

  • Update the ut tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php. @wilsonge Thanks for that!!

So although many changes applied the functionality remains the same, but this will ease our way to drop mootools down the road…

avatar Fedik
Fedik - comment - 8 Oct 2014

@dgt41 you mean this #L56-L86 ?
yes there a lot mootools :smile:
vanilla will be a bit complicated there, but jQuery should be good

and maybe better make this in separate pull, cause there need not a trivial changes

avatar dgt41
dgt41 - comment - 8 Oct 2014
avatar dgt41
dgt41 - comment - 9 Oct 2014

Update as more tests was conducted:
On behavior.php there are some calls to mootools except from the JHtml_(‘behavior.framework’);
the first flag true should be false in these occasions:
https://github.com/dgt41/joomla-cms/blob/mootools/libraries/cms/html/behavior.php#L215
https://github.com/dgt41/joomla-cms/blob/mootools/libraries/cms/html/behavior.php#L651
and
https://github.com/dgt41/joomla-cms/blob/mootools/libraries/cms/html/behavior.php#L394
The last one multiselect uses mootools code for the initialization call

"window.addEvent('domready', function() {
                new Joomla.JMultiSelect('" . $id . "');
            });”

which obviously has to become jquery (or vanilla)

avatar 810
810 - comment - 9 Oct 2014

On Global Configuration is mootools-more and mootools-core still loaded

avatar dgt41
dgt41 - comment - 9 Oct 2014

Yes, which is correct because there is a modal window there, and modal is a mootools script. Unless somebody comes up with new code for modal.js there is nothing more that we can do about it.

PS the modal in @: Offline Image on the select button

avatar 810
810 - comment - 9 Oct 2014

do you know the code to show mootools-core. Because its also loaded on sysinfo, I can't find the mootools loading

avatar dgt41
dgt41 - comment - 9 Oct 2014

You can comment this line dgt41@4ce723d#diff-22d356c612b1a6ccbefdcdd05cd81a88R12
But this will most probably break all third party components.

avatar dgt41
dgt41 - comment - 9 Oct 2014

In most pages motools load because of the toolbar buttons removing that will break B/C

avatar dgt41
dgt41 - comment - 9 Oct 2014

@810 I just pushed some corrections that are more appropriate for toolbar, please try...

avatar 810
810 - comment - 9 Oct 2014

@dgt41 looks good for me, but is it b/c proof?

avatar dgt41
dgt41 - comment - 9 Oct 2014

No, we don’t want to totally remove mootools. Basically this is a clean up and preparing the code for jquery. But even if I provide all the code that is needed for core components, mootools unfortunately cannot go away because almost all code from 3PD is still using it. This is not a way to TOTALLY REMOVE mootools as this cannot be done in 3.x. But will ease the way for 4.x. And yes it should be 100% safe.

6e55529 10 Oct 2014 avatar dgt41 WRONG
avatar roland-d
roland-d - comment - 10 Oct 2014

@dgt41 good points and well done. Indeed it will be good to completely move all core code to jQuery. Mootools can stay in the package and be used by 3rd parties as they see fit. At least it will be ready for removal when Joomla 4 comes around.

avatar Fedik
Fedik - comment - 11 Oct 2014

@dgt41 there #4517 for menu editing

avatar dgt41
dgt41 - comment - 11 Oct 2014

@Fedik Nice! ???? Patch tester clash those 2 PRs so I have to copy paste your code. Will do it later. Thanks

0580ee4 11 Oct 2014 avatar dgt41 Ooops
avatar dgt41
dgt41 - comment - 21 Oct 2014

Closing this one, as I break it to two separate and easier to review PRs.

avatar dgt41 dgt41 - close - 21 Oct 2014
avatar dgt41 dgt41 - close - 21 Oct 2014
avatar dgt41 dgt41 - change - 21 Oct 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-10-21 14:58:02
avatar dgt41 dgt41 - head_ref_deleted - 8 Nov 2014

Add a Comment

Login with GitHub to post a comment