? ? Pending

User tests: Successful: Unsuccessful:

avatar regularlabs
regularlabs
30 Oct 2018

Summary of Changes

To conditionally hide fields or content based on the values of other fields, you can add a showon="" attribute to fields in xml files.

However, this will always use a slideUp/slideDown animation.
There are cases where you do not want to animate the showing/hiding of your content or fields.

This patch adds the ability to switch off the animation by adding a classno-animation or no-animate to the field.
You can also add the class to the surrounding showon container, which can be helpful when creating your own via php.

Testing Instructions

For instance, you can test with the Joomla core configuration:

		<field
			name="page_heading"
			type="text"
			label="COM_MENUS_ITEM_FIELD_PAGE_HEADING_LABEL"
			description="COM_MENUS_ITEM_FIELD_PAGE_HEADING_DESC"
			default=""
			showon="show_page_heading:1"
		/>

And change that to:

		<field
			name="page_heading"
			type="text"
			label="COM_MENUS_ITEM_FIELD_PAGE_HEADING_LABEL"
			description="COM_MENUS_ITEM_FIELD_PAGE_HEADING_DESC"
			default=""
			showon="show_page_heading:1"
			class="no-animation"
		/>

Now go to: administrator/index.php?option=com_config&view=component&component=com_menus and toggle the Show Page Heading setting.
Before the patch it should have the slide animation. After, it should not animate.

Documentation Changes Required

https://docs.joomla.org/Form_field
Optionally add a note somewhere that you can switch off the animation effect via the classname.

avatar regularlabs regularlabs - open - 30 Oct 2018
avatar regularlabs regularlabs - change - 30 Oct 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 30 Oct 2018
Category Administration com_config Layout Libraries JavaScript
avatar regularlabs regularlabs - change - 30 Oct 2018
Labels Added: ?
avatar brianteeman
brianteeman - comment - 30 Oct 2018

It does what it says but I dont see the use case??

avatar regularlabs
regularlabs - comment - 30 Oct 2018

The slide animation is vertical.
There are cases when this messes up the layout during animation.
Especially when using custom fields that have different layouts than the standard label=>field.

avatar brianteeman
brianteeman - comment - 31 Oct 2018

Can you share an example?

avatar regularlabs
regularlabs - comment - 31 Oct 2018

With animation:
with-animation

Without Animation:
no-animation

avatar brianteeman
brianteeman - comment - 31 Oct 2018

Thanks

avatar brianteeman
brianteeman - comment - 31 Oct 2018

I have tested this item successfully on 8f31b56


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar brianteeman brianteeman - test_item - 31 Oct 2018 - Tested successfully
avatar regularlabs
regularlabs - comment - 31 Oct 2018

Also there are cases when you have a LOT of fields hiding/showing based on a single value.
And then animation can cause the page to react very slowly (especially on older browsers).

Also, visually, animation it is not always what you want.
For instance, when you want to toggle 2 fields (same label & options, just different field name) without the user seeing it is actually a different field.
For instance, an active and a readonly (disabled) version of the field.

avatar Quy
Quy - comment - 31 Oct 2018

I have tested this item successfully on 8f31b56


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar Quy Quy - test_item - 31 Oct 2018 - Tested successfully
avatar Quy Quy - change - 31 Oct 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 31 Oct 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar bembelimen
bembelimen - comment - 31 Oct 2018

Any chance to offer more possibilities as value for this parameter? "none", "vertical", "horizontal", ...

avatar dgrammatiko
dgrammatiko - comment - 31 Oct 2018

FWIW in Joomla 4 there ARE NO animations, so introducing this feature in staging means that the project should keep the same API (with the redundant animation part) also in J4. @wilsonge keep a note on this please...

avatar regularlabs
regularlabs - comment - 31 Oct 2018

@bembelimen
There is no ready-to-use horizontal slide effects in the jQuery version included in Joomla 3.
So I think it is beyond the scope of this PR to implement that.

avatar regularlabs
regularlabs - comment - 15 Nov 2018

Any reason why this isn't merged yet?

avatar dgrammatiko
dgrammatiko - comment - 15 Nov 2018

@regularlabs I guess because of
#22870 (comment)

avatar regularlabs
regularlabs - comment - 15 Nov 2018

No, because of:
#22912 (comment)

avatar dgrammatiko
dgrammatiko - comment - 15 Nov 2018

Honestly it will be ultra stupid to introduce an API change in 3.9 and remove it in 4.0...

avatar regularlabs
regularlabs - comment - 15 Nov 2018

It is solving an issue we have in Joomla 3.
If Joomla 4 solves that in another fashion (by having no animations at all), then fine.
Joomla 4 is changing behaviour anyway.

avatar dgrammatiko
dgrammatiko - comment - 15 Nov 2018

@regularlabs I think you miss my point, you can implement this without adding technical debt for J4 by using a class, eg no-animation. This will have minimal impact for J4, in contrary the introduction of another attribute if that needs to be removed in J4 brings a B/C break...

avatar regularlabs regularlabs - change - 15 Nov 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 15 Nov 2018
Category Administration com_config Layout Libraries JavaScript Libraries JavaScript
avatar regularlabs regularlabs - change - 15 Nov 2018
The description was changed
avatar regularlabs regularlabs - edited - 15 Nov 2018
avatar regularlabs
regularlabs - comment - 15 Nov 2018

I totally agree with you!

I have changed the code, which means that only the cms.js file has now changed.
No php changes. Not API changes in the xml elements.

I also updated the description of the PR.

So I guess the RTC tag needs to get removed and we need to do testing again.

If it is better to trash this PR and create a new fresh one, let me know.

avatar zero-24 zero-24 - change - 15 Nov 2018
Status Ready to Commit Pending
Labels
avatar zero-24
zero-24 - comment - 15 Nov 2018

tanking RTC off as requested.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar regularlabs regularlabs - change - 17 Nov 2018
Labels Removed: ?
avatar regularlabs
regularlabs - comment - 17 Nov 2018

@Quy Could you test again? See if it is still working as it should?

avatar Quy
Quy - comment - 17 Nov 2018

I have tested this item successfully on a85f10c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar Quy Quy - test_item - 17 Nov 2018 - Tested successfully
avatar dgrammatiko
dgrammatiko - comment - 20 Nov 2018

I have tested this item successfully on a85f10c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar dgrammatiko dgrammatiko - test_item - 20 Nov 2018 - Tested successfully
avatar Quy Quy - change - 20 Nov 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 20 Nov 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22870.

avatar mbabker mbabker - change - 23 Nov 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-11-23 05:44:55
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 23 Nov 2018
avatar mbabker mbabker - merge - 23 Nov 2018
avatar regularlabs
regularlabs - comment - 23 Nov 2018

?

avatar C-Lodder
C-Lodder - comment - 23 Nov 2018

One thing I would have suggested in this is not to use toggle() as it was deprecated in 1.8 and remove in 1.9. The only reason it works is because you ship jquery-migrate, however there are some optimisation plugins that allow you to unset it from the document and thus toggle() will be undefined.

Should have used .css(...) instead.

avatar regularlabs
regularlabs - comment - 23 Nov 2018

The existing js code there was already using toggle(). This PR hasn't changed that.

Add a Comment

Login with GitHub to post a comment