Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Replace js alerts for joomla alerts #15315

Merged
merged 13 commits into from Apr 15, 2017
4 changes: 3 additions & 1 deletion libraries/cms/toolbar/button/standard.php
Expand Up @@ -116,12 +116,14 @@ public function fetchId($type = 'Standard', $name = '', $text = '', $task = '',
protected function _getCommand($name, $task, $list)
{
JText::script('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
JText::script('WARNING');

$cmd = "Joomla.submitbutton('" . $task . "');";

if ($list)
{
$alert = "alert(Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'));";
$messages = "{'warning': [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}";
$alert = "Joomla.renderMessages(" . $messages . ")";
$cmd = "if (document.adminForm.boxchecked.value == 0) { " . $alert . " } else { " . $cmd . " }";
}

Expand Down
Expand Up @@ -123,9 +123,7 @@ public function testRender()
{
$type = array('Standard', 'test');

$expected = "\n<button onclick=\"if (document.adminForm.boxchecked.value == 0) { alert(Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')); } else { Joomla.submitbutton(''); }\" class=\"btn btn-sm btn-outline-primary\">\n"
. "\t<span class=\"icon-test\"></span>\n"
. "\t</button>\n";
$expected = "\n<button onclick=\"if (document.adminForm.boxchecked.value == 0) { Joomla.renderMessages({'warning': [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}) } else { Joomla.submitbutton(''); }\" class=\"btn btn-sm btn-outline-primary\">\n\t<span class=\"icon-test\"></span>\n\t</button>\n";

$this->assertEquals(
$expected,
Expand Down