? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
23 Nov 2015

Description

This PR moves the inline JCaption js onload call to the external caption.js file.

How to test

  1. Fresh Joomla install with sample data.
  2. Install the patch
  3. Add an image with caption to a content
  4. Check frontend if image caption is there
  5. Check the HTML page code. JCaption inline js should no longer be there

B/C

None.

avatar andrepereiradasilva andrepereiradasilva - open - 23 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - change - 23 Nov 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Nov 2015
Labels Added: ? ?
avatar Bakual
Bakual - comment - 23 Nov 2015

Due to our B/C policy, the selector has to stay and work.

avatar andrepereiradasilva andrepereiradasilva - change - 24 Nov 2015
The description was changed
avatar andrepereiradasilva
andrepereiradasilva - comment - 24 Nov 2015

Ok @Bakual, reverted the selector changes and is working for B/C.
Can you remove the "Unit/System Tests" label?

329de14 24 Nov 2015 avatar andrepereiradasilva cs
avatar Bakual Bakual - change - 24 Nov 2015
Labels Removed: ?
avatar Bakual
Bakual - comment - 24 Nov 2015

Removed the label.

avatar wilsonge
wilsonge - comment - 24 Nov 2015

There's no way we can merge this as-is. This is really complex now and you are actually initialising the caption on a potentially non-existing class which although it won't break anything seems like it's just going to cause more problems than it solves

avatar Bakual
Bakual - comment - 24 Nov 2015

I would actually prefer to get rid of that JS (deprecate it) and merge #7450 so we have native HTML captions :smile:

avatar andrepereiradasilva
andrepereiradasilva - comment - 24 Nov 2015

hi @wilsonge , thanks for the feedback.
Please tell me what you think of the following suggestion:

This is really complex now

I agree. In my view the best solution for this and other cases with data values (in this case the selector class) is to put them in a HTML5 data-* attributes that can be read form external js and this way simplify the whole thing, and without inline js.

The problem is that there is no function for that in JDocumentHtml.
I'm testing to create one addHTMLData public function.

Update: PR created #8533

And just call it like:
JFactory::getDocument()->addBodyData('caption', 'img.caption', 'body');

That will generate a <body data-caption='img.caption' that can be easy be accesses in jQuery with jQuery('body').data('caption')

This could also be used to put json arrays in data-* attributes which could be useful for plugin development.

you are actually initialising the caption on a potentially non-existing class

Yes i see. I will put a check that element exists before initializing.

avatar zero-24
zero-24 - comment - 24 Nov 2015

Feel free to test there @bakual else it get never in :P

avatar dgt41
dgt41 - comment - 24 Nov 2015
avatar Bakual
Bakual - comment - 24 Nov 2015

@dgt41 Which PR?

avatar dgt41
dgt41 - comment - 24 Nov 2015
avatar Bakual
Bakual - comment - 24 Nov 2015

Why? Captions inserted by the "Images" button from the editor plugins already insert native captions for quite some time. The other PR is only about the images specified in the article item (not the article content), eg the intro and full text images.
We have to keep the caption.js for B/C reasons anyway.

avatar dgt41
dgt41 - comment - 24 Nov 2015

Ok, I got it wrong

avatar andrepereiradasilva
andrepereiradasilva - comment - 24 Nov 2015

Closed as there is already a PR to remove caption.js and make caption in HTML

avatar andrepereiradasilva andrepereiradasilva - change - 24 Nov 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-11-24 22:02:21
Closed_By andrepereiradasilva
avatar andrepereiradasilva andrepereiradasilva - close - 24 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - close - 24 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - head_ref_deleted - 25 Nov 2015

Add a Comment

Login with GitHub to post a comment