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
2 changes: 1 addition & 1 deletion administrator/language/en-GB/en-GB.lib_joomla.ini
Expand Up @@ -431,7 +431,7 @@ JLIB_HTML_MOVE_UP="Move Up"
JLIB_HTML_NO_PARAMETERS_FOR_THIS_ITEM="There are no parameters for this item."
JLIB_HTML_NO_RECORDS_FOUND="No records found."
JLIB_HTML_PAGE_CURRENT_OF_TOTAL="Page %s of %s"
JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first make a selection from the list."
JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first ' make a selection from the list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be here

JLIB_HTML_PUBLISH_ITEM="Publish Item"
JLIB_HTML_PUBLISHED_EXPIRED_ITEM="Published, but has Expired."
JLIB_HTML_PUBLISHED_FINISHED="Finish: %s"
Expand Down
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,9 @@ 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";
$alert = JText::_('WARNING');

$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