User tests: Successful: Unsuccessful:
Pull Request for Issue #20241 #20240 .
Allow Preview toolbar buttons to be used as a modal or a link to target=_blank
$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
None
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
I have tested this item
Title |
|
I have tested this item
@PhilETaylor resolve the branch conflict and will be ready
Status | Pending | ⇒ | Ready to Commit |
RTC
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Pending |
Please retest.
I have tested this item
\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)
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)
Labels |
Removed:
?
|
I have tested this item
Now work correct
I have tested this item
@PhilETaylor happens to all ;)
Status | Pending | ⇒ | Ready to Commit |
RTC
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');
@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.
@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..
early return as suggested is not a Code Style preference, is much more a documented "tecnique" to write more clean&manageable code "Object Calisthenics" ...
Labels |
Added:
?
|
it wasn't my intention to discourage contributions...
i'm sorry if you felt that way
challenge accepted see joomla/coding-standards#236
@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
I like if/else.much more readable.
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 |
Thanks @PhilETaylor to make J4 great.
#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