Skip to content
This repository was archived by the owner on Sep 17, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions build/webcomponents/js/toolbar-button/toolbar-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

connectedCallback() {
// Check whether we have a form
const formSelector = this.form || '#adminForm';
this.formElement = document.querySelector(formSelector);
const formSelector = this.form || 'adminForm';
this.formElement = document.getElementById(formSelector);

if (this.listSelection) {
if (!this.formElement) {
Expand Down
9 changes: 8 additions & 1 deletion libraries/cms/html/grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,20 @@ public static function checkall($name = 'checkall-toggle', $tip = 'JGLOBAL_CHECK
* @param boolean $checkedOut True if item is checked out
* @param string $name The name of the form element
* @param string $stub The name of stub identifier
* @param string $form An optional form selector.
*
* @return mixed String of html with a checkbox if item is not checked out, null if checked out.
*
* @since 1.5
*/
public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $stub = 'cb')
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add the new parameter at the end or you’re breaking b/c

public static function id($rowNum, $recId, $formId = null, $checkedOut = false, $name = 'cid', $stub = 'cb')
{
if ($formId !== null)
{
return $checkedOut ? '' : '<input type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '" onclick="Joomla.isChecked(this.checked,\'' . $formId . '\');">';
}

return $checkedOut ? '' : '<input type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '" onclick="Joomla.isChecked(this.checked);">';
}
Expand Down
50 changes: 34 additions & 16 deletions libraries/cms/html/jgrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ abstract class JHtmlJGrid
* @param string $inactive_class An optional inactive HTML class
* @param boolean $enabled An optional setting for access control on the action.
* @param boolean $translate An optional setting for translation.
* @param string $checkbox An optional prefix for checkboxes.
* @param string $checkbox An optional prefix for checkboxes.
* @param string $formId An optional form selector.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function action($i, $task, $prefix = '', $text = '', $active_title = '', $inactive_title = '', $tip = false, $active_class = '',
$inactive_class = '', $enabled = true, $translate = true, $checkbox = 'cb')
$inactive_class = '', $enabled = true, $translate = true, $checkbox = 'cb', $formId = null)
{
if (is_array($prefix))
{
Expand All @@ -67,7 +68,16 @@ public static function action($i, $task, $prefix = '', $text = '', $active_title
if ($enabled)
{
$html[] = '<a class="tbody-icon' . ($active_class === 'publish' ? ' active' : '') . ($tip ? ' hasTooltip' : '') . '"';
$html[] = ' href="javascript:void(0);" onclick="return listItemTask(\'' . $checkbox . $i . '\',\'' . $prefix . $task . '\')"';

if ($formId !== null)
{
$html[] = ' href="javascript:void(0);" onclick="return listItemTask(\'' . $checkbox . $i . '\',\'' . $prefix . $task . '\',\'' . $formId . '\')"';
}
else
{
$html[] = ' href="javascript:void(0);" onclick="return listItemTask(\'' . $checkbox . $i . '\',\'' . $prefix . $task . '\')"';
}

$html[] = $tip ? ' title="' . $title . '"' : '';
$html[] = '>';
$html[] = '<span class="icon-' . $active_class . '" aria-hidden="true"></span>';
Expand Down Expand Up @@ -108,12 +118,13 @@ public static function action($i, $task, $prefix = '', $text = '', $active_title
* @param boolean $enabled An optional setting for access control on the action.
* @param boolean $translate An optional setting for translation.
* @param string $checkbox An optional prefix for checkboxes.
* @param string $formId An optional form selector.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function state($states, $value, $i, $prefix = '', $enabled = true, $translate = true, $checkbox = 'cb')
public static function state($states, $value, $i, $prefix = '', $enabled = true, $translate = true, $checkbox = 'cb', $formId = null)
{
if (is_array($prefix))
{
Expand All @@ -135,7 +146,8 @@ public static function state($states, $value, $i, $prefix = '', $enabled = true,

return static::action(
$i, $task, $prefix, $text, $active_title, $inactive_title, $tip,
$active_class, $inactive_class, $enabled, $translate, $checkbox
$active_class, $inactive_class, $enabled, $translate, $checkbox,
$formId
);
}

Expand All @@ -146,6 +158,7 @@ public static function state($states, $value, $i, $prefix = '', $enabled = true,
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param string $formId An optional form selector.
* @param string $checkbox An optional prefix for checkboxes.
* @param string $publish_up An optional start publishing date.
* @param string $publish_down An optional finish publishing date.
Expand All @@ -155,7 +168,7 @@ public static function state($states, $value, $i, $prefix = '', $enabled = true,
* @see JHtmlJGrid::state()
* @since 1.6
*/
public static function published($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb', $publish_up = null, $publish_down = null)
public static function published($value, $i, $prefix = '', $enabled = true, $formId = null, $checkbox = 'cb', $publish_up = null, $publish_down = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

{
if (is_array($prefix))
{
Expand Down Expand Up @@ -229,10 +242,10 @@ public static function published($value, $i, $prefix = '', $enabled = true, $che
}
}

return static::state($states, $value, $i, array('prefix' => $prefix, 'translate' => !$tip), $enabled, true, $checkbox);
return static::state($states, $value, $i, array('prefix' => $prefix, 'translate' => !$tip), $enabled, true, $checkbox, $formId);
}

return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox);
return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox, $formId);
}

/**
Expand All @@ -242,14 +255,15 @@ public static function published($value, $i, $prefix = '', $enabled = true, $che
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param string $formId An optional form selector.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @see JHtmlJGrid::state()
* @since 1.6
*/
public static function isdefault($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb')
public static function isdefault($value, $i, $prefix = '', $enabled = true, $formId = null, $checkbox = 'cb')
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

{
if (is_array($prefix))
{
Expand All @@ -264,7 +278,7 @@ public static function isdefault($value, $i, $prefix = '', $enabled = true, $che
1 => array('unsetDefault', 'JDEFAULT', 'JLIB_HTML_UNSETDEFAULT_ITEM', 'JDEFAULT', 1, 'featured', 'featured'),
);

return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox);
return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox, $formId);
}

/**
Expand Down Expand Up @@ -320,13 +334,14 @@ public static function publishedOptions($config = array())
* @param string $time The time that the object was checked out.
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled True to enable the action.
* @param string $formId An optional form selector.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function checkedout($i, $editorName, $time, $prefix = '', $enabled = false, $checkbox = 'cb')
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

public static function checkedout($i, $editorName, $time, $prefix = '', $enabled = false, $formId = null, $checkbox = 'cb')
{
if (is_array($prefix))
{
Expand All @@ -342,7 +357,8 @@ public static function checkedout($i, $editorName, $time, $prefix = '', $enabled

return static::action(
$i, 'checkin', $prefix, JText::_('JLIB_HTML_CHECKED_OUT'), html_entity_decode($active_title, ENT_QUOTES, 'UTF-8'),
html_entity_decode($inactive_title, ENT_QUOTES, 'UTF-8'), true, 'checkedout', 'checkedout', $enabled, false, $checkbox
html_entity_decode($inactive_title, ENT_QUOTES, 'UTF-8'), true, 'checkedout', 'checkedout', $enabled, false, $checkbox,
$formId
);
}

Expand All @@ -354,13 +370,14 @@ public static function checkedout($i, $editorName, $time, $prefix = '', $enabled
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display
* @param boolean $enabled An optional setting for access control on the action.
* @param string $formId An optional form selector.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLIB_HTML_MOVE_UP', $enabled = true, $checkbox = 'cb')
public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLIB_HTML_MOVE_UP', $enabled = true, $formId = null, $checkbox = 'cb')
{
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

Copy link
Contributor

Choose a reason for hiding this comment

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

nope, it needs to be the last one, otherwise, we have a b/c break!!!

if (is_array($prefix))
{
Expand All @@ -371,7 +388,7 @@ public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLI
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}

return static::action($i, $task, $prefix, $text, $text, $text, false, 'uparrow', 'uparrow_disabled', $enabled, true, $checkbox);
return static::action($i, $task, $prefix, $text, $text, $text, false, 'uparrow', 'uparrow_disabled', $enabled, true, $checkbox, $formId);
}

/**
Expand All @@ -382,13 +399,14 @@ public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLI
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display
* @param boolean $enabled An optional setting for access control on the action.
* @param string $formId An optional form selector.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function orderDown($i, $task = 'orderdown', $prefix = '', $text = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $checkbox = 'cb')
public static function orderDown($i, $task = 'orderdown', $prefix = '', $text = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $formId = null, $checkbox = 'cb')
{
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

if (is_array($prefix))
{
Expand All @@ -399,6 +417,6 @@ public static function orderDown($i, $task = 'orderdown', $prefix = '', $text =
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}

return static::action($i, $task, $prefix, $text, $text, $text, false, 'downarrow', 'downarrow_disabled', $enabled, true, $checkbox);
return static::action($i, $task, $prefix, $text, $text, $text, false, 'downarrow', 'downarrow_disabled', $enabled, true, $checkbox, $formId);
}
}
22 changes: 17 additions & 5 deletions libraries/src/Toolbar/Button/StandardButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,31 @@ protected function prepareOptions(array &$options)
* @param string $text Button text.
* @param string $task Task associated with the button.
* @param boolean $list True to allow lists
* @param string $formId The id of action form.
*
* @return string HTML string for the button
*
* @since 3.0
*
* @deprecated 5.0 Use render() instead.
*/
public function fetchButton($type = 'Standard', $name = '', $text = '', $task = '', $list = true)
public function fetchButton($type = 'Standard', $name = '', $text = '', $task = '', $list = true, $formId = null)
{
$this->name($name)
->text($text)
->task($task)
->listCheck($list);
if ($formId !== null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we save some lines if we do it like this

...
if ($formId !== null)
{
   $this->form($formId);
}
$this->name($name);
$this->text($text);
$this->task($task);
$this->listCheck($list);
...

{
$this->name($name)
->text($text)
->task($task)
->listCheck($list)
->form($formId);
}
else
{
$this->name($name)
->text($text)
->task($task)
->listCheck($list);
}

return $this->renderButton($this->options);
}
Expand Down
5 changes: 3 additions & 2 deletions libraries/src/Toolbar/ToolbarHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,21 @@ public static function divider()
* @param string $iconOver The image to display when moused over.
* @param string $alt The alt text for the icon image.
* @param bool $listSelect True if required to check that a standard list item is checked.
* @param string $formId The id of action form.
*
* @return void
*
* @since 1.5
*/
public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true)
public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true, $formId = null)
{
$bar = Toolbar::getInstance('toolbar');

// Strip extension.
$icon = preg_replace('#\.[^.]*$#', '', $icon);

// Add a standard button.
$bar->appendButton('Standard', $icon, $alt, $task, $listSelect);
$bar->appendButton('Standard', $icon, $alt, $task, $listSelect, $formId);
}

/**
Expand Down
31 changes: 21 additions & 10 deletions media/system/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ Joomla.Modal = {
Joomla.isChecked = function( isitchecked, form ) {
if ( typeof form === 'undefined' ) {
form = document.getElementById( 'adminForm' );
} else if (typeof form === 'string') {
form = document.getElementById(form);
}

form.boxchecked.value = isitchecked ? parseInt(form.boxchecked.value) + 1 : parseInt(form.boxchecked.value) - 1;
Expand Down Expand Up @@ -614,6 +616,8 @@ Joomla.Modal = {
Joomla.tableOrdering = function( order, dir, task, form ) {
if ( typeof form === 'undefined' ) {
form = document.getElementById( 'adminForm' );
} else if ( typeof form === 'string' ) {
form = document.getElementById(form);
}

form.filter_order.value = order;
Expand Down Expand Up @@ -647,12 +651,13 @@ Joomla.Modal = {
*
* @param id
* @param task
* @param form
* @return
*
* @deprecated 4.0 Use Joomla.listItemTask() instead
*/
window.listItemTask = function ( id, task ) {
return Joomla.listItemTask( id, task );
window.listItemTask = function ( id, task, form = null ) {
return Joomla.listItemTask( id, task, form );
};

/**
Expand All @@ -663,9 +668,15 @@ Joomla.Modal = {
*
* @return {boolean}
*/
Joomla.listItemTask = function ( id, task ) {
var f = document.adminForm,
i = 0, cbx,
Joomla.listItemTask = function ( id, task, form = null ) {

if (form !== null) {
var f = document.getElementById(form);
} else {
var f = document.adminForm;
}

var i = 0, cbx,
cb = f[ id ];

if ( !cb ) return false;
Expand All @@ -682,7 +693,7 @@ Joomla.Modal = {

cb.checked = true;
f.boxchecked.value = 1;
window.submitform( task );
window.submitform( task, f );

return false;
};
Expand All @@ -692,17 +703,17 @@ Joomla.Modal = {
*
* @deprecated 4.0 Use Joomla.submitbutton() instead.
*/
window.submitbutton = function ( pressbutton ) {
Joomla.submitbutton( pressbutton );
window.submitbutton = function ( pressbutton, form = null ) {
Joomla.submitbutton( pressbutton, form );
};

/**
* Submit the admin form
*
* @deprecated 4.0 Use Joomla.submitform() instead.
*/
window.submitform = function ( pressbutton ) {
Joomla.submitform(pressbutton);
window.submitform = function ( pressbutton, form = null ) {
Joomla.submitform( pressbutton, form );
};

// needed for Table Column ordering
Expand Down
Loading