Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build/media_source/legacy/js/toolbar.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Joomla = window.Joomla || {};
* @param {string} scroll The vertical/horizontal scroll bars
*
* @since 4.0.0
*
* @deprecated 5.0.0 Without replacement
*/
Joomla.popupWindow = function (mypage, myname, w, h, scroll) {
const winl = (screen.width - w) / 2;
Expand All @@ -37,6 +39,17 @@ Joomla = window.Joomla || {};
const toolbarHelp = document.getElementById('toolbar-help');
const toolbarInlineHelp = document.getElementById('toolbar-inlinehelp');

// Handle Help buttons
document.querySelectorAll('.js-toolbar-help-btn').forEach((button) => {
button.addEventListener('click', (event) => {
const btn = event.target;
const winprops = `height=${parseInt(btn.dataset.height, 10)},width=${parseInt(btn.dataset.width, 10)},top=${(window.innerHeight - parseInt(btn.dataset.height, 10)) / 2},`
+ `left=${(window.innerWidth - parseInt(btn.dataset.width, 10)) / 2},scrollbars=${btn.dataset.width === 'true'},resizable`;

window.open(btn.dataset.url, btn.dataset.tile, winprops).window.focus();
});
});

if (toolbarInlineHelp) {
toolbarInlineHelp.classList.add('ms-auto');
return;
Expand Down
18 changes: 10 additions & 8 deletions libraries/src/Toolbar/Button/HelpButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ class HelpButton extends BasicButton
*/
protected function prepareOptions(array &$options)
{
$options['text'] = $options['text'] ?: 'JTOOLBAR_HELP';
$options['icon'] = $options['icon'] ?? 'icon-question';
$options['button_class'] = $options['button_class'] ?? 'btn btn-info';
$options['onclick'] = $options['onclick'] ?? $this->_getCommand();
$options['text'] = $options['text'] ?: 'JTOOLBAR_HELP';
$options['icon'] = $options['icon'] ?? 'icon-question';
$options['button_class'] = ($options['button_class'] ?? 'btn btn-info') . ' js-toolbar-help-btn';
$options['attributes']['data-url'] = $this->_getCommand();
$options['attributes']['data-title'] = Text::_('JHELP');
$options['attributes']['data-width'] = 700;
$options['attributes']['data-height'] = 500;
$options['attributes']['data-scroll'] = true;

parent::prepareOptions($options);
}
Expand Down Expand Up @@ -89,10 +93,8 @@ protected function _getCommand()
// Get Help URL
$url = Help::createUrl($this->getRef(), $this->getUseComponent(), $this->getUrl(), $this->getComponent());
$url = json_encode(htmlspecialchars($url, ENT_QUOTES), JSON_HEX_APOS);
$url = substr($url, 1, -1);
$cmd = "Joomla.popupWindow('$url', '" . Text::_('JHELP', true) . "', 700, 500, 1)";

return $cmd;
return substr($url, 1, -1);
}

/**
Expand All @@ -110,7 +112,7 @@ protected static function getAccessors(): array
'ref',
'useComponent',
'component',
'url'
'url',
]
);
}
Expand Down