User tests: Successful: Unsuccessful:
This solves #5254
I was checking core.js
and noticed that we have added there some jQuery code in functions:
Joomla.renderMessages
and
Joomla.removeMessages
They are mainly used on install and overrider but also third part developers can be using them.
We officially support jQuery & Mootools even being migrating to jQuery. Adding that code causes that developers that want to use only Mootools are forced to load jQuery.
So we have to convert them to plain JS.
As it's hard to test message rendering in installation & language overrides here is some code that you can use. You have to add this code before applying the patch and test it before and after the patch to be sure that it's working the same.
I will explain how to put testing code in the articles view ( administrator/components/com_content/views/articles/tmpl/default.php
). Around line 54 add:
JText::script('ERROR');
JText::script('MESSAGE');
JFactory::getDocument()->addScriptDeclaration('
jQuery(document).ready(function() {
jQuery(".js-test").click(function(){
var messages = {
"message": ["Message one", "Message two"],
"error": ["Error one", "Error two"]
};
Joomla.renderMessages(messages);
});
jQuery(".js-test-clear").click(function(){
Joomla.removeMessages();
});
});
');
Then before line 66 (after the main container tag) add the buttons that will trigger the actions:
<a class="btn btn-success js-test" href="#">Render messages</a>
<a class="btn btn-danger js-test-clear" href="#">Clear messages</a>
Render messages
button should display the messages.Clear messages
button should remove the messages.View with the messages loaded:
Labels |
Added:
?
|
In fact it was a chrome bug :(
Thanks for testing it should work now.
will retest in the morning
test
works good
Can we remove the call to jQuery in JHtmlBehaviour::core(); as part of this then please?
Can we remove the call to jQuery in JHtmlBehaviour::core(); as part of this then please?
If core.js doesn't need jQuery anymore, then remove the call to jQuery.
But JHtmlBehaviour::core(); is out in the wild and people might use it to load both core+jquery. We can introduce JHtmlBehaviour::joomla(); or something else for clean core.
Nah. JHtmlBehaviour::core();
is supposed to load core.js. It happens to depend on jQuery for now, but if developer depend on it loading jQuery, then they are wrongly doing that.
It's the same thing we have with MooTools. Developers should always load their dependencies and not trust that other code does that for you.
@wilsonge @Bakual Removing https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L88 didn’t broke something, so I guess you are both right here!
@phproberto don’t commit this one yet… I am sending you a PR...
@phproberto you have a pr: phproberto#8
Category | ⇒ | JavaScript |
Merged, thanks!
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-12-04 07:22:27 |
@test success
When deleting the msgs we end up with a lot of white space, I guess this happens only in the test env?