diff --git a/build/media_source/legacy/js/toolbar.es5.js b/build/media_source/legacy/js/toolbar.es5.js index 04026ff9b76e4..0c7156f53a89e 100644 --- a/build/media_source/legacy/js/toolbar.es5.js +++ b/build/media_source/legacy/js/toolbar.es5.js @@ -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; @@ -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; diff --git a/libraries/src/Toolbar/Button/HelpButton.php b/libraries/src/Toolbar/Button/HelpButton.php index 13c48de33531f..acecffb17ebcd 100644 --- a/libraries/src/Toolbar/Button/HelpButton.php +++ b/libraries/src/Toolbar/Button/HelpButton.php @@ -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); } @@ -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); } /** @@ -110,7 +112,7 @@ protected static function getAccessors(): array 'ref', 'useComponent', 'component', - 'url' + 'url', ] ); }