? ? Pending

User tests: Successful: Unsuccessful:

avatar PhilETaylor
PhilETaylor
15 May 2018

Pull Request for Issue #20241 #20240 .

Summary of Changes

Allow Preview toolbar buttons to be used as a modal or a link to target=_blank

Testing Instructions

$toolbar = Toolbar::getInstance();
$toolbar->preview('http://myJoomla.com ','myJoomla.com', true); // NEW- target=_blank link button
$toolbar->preview('http://myJoomla.com ','myJoomla.com', false); // like its always been = modal
$toolbar->preview('http://myJoomla.com ','myJoomla.com'); // like its always been = modal

Also see #20418 for follow up notes

Documentation Changes Required

None

avatar PhilETaylor PhilETaylor - open - 15 May 2018
avatar PhilETaylor PhilETaylor - change - 15 May 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 15 May 2018
Category Libraries
avatar PhilETaylor PhilETaylor - change - 15 May 2018
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 May 2018
avatar PhilETaylor PhilETaylor - change - 15 May 2018
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 May 2018
avatar Septdir
Septdir - comment - 15 May 2018

#20241 - about com_content not only about opening preview in a new window
#20240 - for j3.x Although I will not oppose its closure. If this is realized in j4.

Need Testing Instructions

avatar PhilETaylor PhilETaylor - change - 15 May 2018
Labels Added: ?
avatar PhilETaylor PhilETaylor - change - 15 May 2018
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 May 2018
avatar Septdir Septdir - test_item - 16 May 2018 - Tested successfully
avatar Septdir
Septdir - comment - 16 May 2018

I have tested this item successfully on 63edb82


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

avatar Quy Quy - change - 17 May 2018
Title
Allow Preview to load in new _blank instead of modal
[4.0] Allow Preview to load in new _blank instead of modal
avatar joomla-cms-bot joomla-cms-bot - edited - 17 May 2018
avatar carlitorweb carlitorweb - test_item - 17 May 2018 - Tested successfully
avatar carlitorweb
carlitorweb - comment - 17 May 2018

I have tested this item successfully on 63edb82

@PhilETaylor resolve the branch conflict and will be ready


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20417.
avatar Quy Quy - change - 17 May 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 17 May 2018

RTC


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

avatar PhilETaylor PhilETaylor - change - 18 May 2018
Labels Added: ?
avatar PhilETaylor PhilETaylor - comment - 18 May 2018
avatar Quy Quy - change - 18 May 2018
Status Ready to Commit Pending
avatar Quy
Quy - comment - 18 May 2018

Please retest.


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

avatar Septdir Septdir - test_item - 18 May 2018 - Tested unsuccessfully
avatar Septdir
Septdir - comment - 18 May 2018

I have tested this item ? unsuccessfully on 163b396

			\JLoader::register('ContentHelperPreview', JPATH_ADMINISTRATOR . '/components/com_content/helpers/preview.php');
				$url = \ContentHelperPreview::url($this->item);
				$toolbar->preview($url, \JText::_('JGLOBAL_PREVIEW'))
					->bodyHeight(80)
					->modalWidth(90);

				$toolbar->preview($url,'New window', true); // NEW- target=_blank link button
				$toolbar->preview($url,'always modal', false); // like its always been = modal
				$toolbar->preview($url,'old'); // like its always been = modal

Add two buttons New window (test in com_content)
screenshot_2018-05-18 articles edit - joomla 4 - administration


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20417.
avatar Septdir
Septdir - comment - 18 May 2018

This code

if ($newWindow === true)
		{
			$button = $this->linkButton('link', $text)
				->url($url)
				->attributes(['target' => '_blank'])
				->icon('icon-eye');
		}
		else
		{
			$button = $this->popupButton('preview', $text)
				->url($url)
				->iframeWidth(640)
				->iframeHeight(480)
				->icon('icon-eye');

		}

This code will work correctly (I checked)

avatar PhilETaylor PhilETaylor - change - 18 May 2018
Labels Removed: ?
avatar PhilETaylor PhilETaylor - comment - 18 May 2018
avatar Septdir Septdir - test_item - 18 May 2018 - Tested successfully
avatar Septdir
Septdir - comment - 18 May 2018

I have tested this item successfully on 710e542

Now work correct


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

avatar PhilETaylor PhilETaylor - comment - 18 May 2018
avatar carlitorweb
carlitorweb - comment - 18 May 2018

I have tested this item successfully on 710e542

@PhilETaylor happens to all ;)


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

avatar carlitorweb carlitorweb - test_item - 18 May 2018 - Tested successfully
avatar Quy Quy - change - 18 May 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 18 May 2018

RTC


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

avatar yvesh
yvesh - comment - 19 May 2018

I meant it like that (else is not necessary).. (Just as a note for future PRs)

if ($newWindow === true)
{
	return $this->linkButton('link', $text)
		->url($url)
		->attributes(['target' => '_blank'])
		->icon('icon-eye');
}

return $this->popupButton('preview', $text)
	->url($url)
	->iframeWidth(640)
	->iframeHeight(480)
	->icon('icon-eye');
avatar Septdir
Septdir - comment - 19 May 2018

@yvesh then we can write so

return $newWindow === true ? $this->linkButton('link', $text)->url($url)->attributes(['target' => '_blank'])->icon('icon-eye')
	: $this->popupButton('preview', $text)->url($url)->iframeWidth(640)->iframeHeight(480)->icon('icon-eye');

P.S personally I do not like very much when return gets a few lines. Or two identical. IMHO It's better to return a variable.

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar yvesh
yvesh - comment - 19 May 2018

@PhilETaylor that's why i wrote "for the next PR" :-)

And this is not on preference, else is considered bad style when it can be avoided. (Just google avoid else, return early.. thousands of articles on it).

And it is not meant as critics, it was just a well-intentioned suggestion to improve further..

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar alikon
alikon - comment - 19 May 2018

early return as suggested is not a Code Style preference, is much more a documented "tecnique" to write more clean&manageable code "Object Calisthenics" ...

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar PhilETaylor PhilETaylor - change - 19 May 2018
Labels Added: ?
avatar alikon
alikon - comment - 19 May 2018

it wasn't my intention to discourage contributions...
i'm sorry if you felt that way

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar alikon
alikon - comment - 19 May 2018

challenge accepted see joomla/coding-standards#236

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar alikon
alikon - comment - 19 May 2018

@PhilETaylor i know what you mean, and i've experienced that feelings quite sometimes, but if all of us give up ?...
at least i can tell that i've tried ?
https://www.youtube.com/watch?v=tCZxGG_4ins

avatar infograf768
infograf768 - comment - 19 May 2018

I like if/else.much more readable.

avatar laoneo laoneo - change - 11 Jun 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-06-11 08:13:42
Closed_By laoneo
avatar laoneo laoneo - close - 11 Jun 2018
avatar laoneo laoneo - merge - 11 Jun 2018
avatar laoneo
laoneo - comment - 11 Jun 2018

Thanks @PhilETaylor to make J4 great.

Add a Comment

Login with GitHub to post a comment