- md5
- 4c79c8525514117d074ce897d0439399
- sha1
- 08852bfa86d9143c0090ba84c2d09b5a65e09cb9
- sha256
- 37cbcba995722e01f10f75ed25564193a32e3bf4a4a9a306eaf69536bf119662
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Session\Session;
/**
* HTML utility class for creating a sortable table list
*
* @since 4.0.0
*/
abstract class JHtmlDraggablelist
{
/**
* Array containing information for loaded files
*
* @var array
* @since 4.0.0
*/
protected static $loaded = array();
/**
* Method to load the Dragula script and make table sortable
*
* @param string $tableId DOM id of the table
* @param string $formId DOM id of the form
* @param string $sortDir Sort direction
* @param string $saveOrderingUrl Save ordering url, ajax-load after an item dropped
* @param string $redundant Not used
* @param boolean $nestedList Set whether the list is a nested list
*
* @return void
*
* @since 4.0.0
*
* @throws InvalidArgumentException
*/
public static function draggable(string $tableId = '', string $formId = '', string $sortDir = 'asc', string $saveOrderingUrl = '',
$redundant = null, bool $nestedList = false
)
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
$doc = Factory::getDocument();
// Please consider using data attributes instead of passing arguments here!
if (!empty($tableId) && !empty($saveOrderingUrl) && !empty($formId) && !empty($sortDir))
{
$doc->addScriptOptions(
'draggable-list',
[
'id' => '#' . $tableId . ' tbody',
'formId' => $formId,
'direction' => $sortDir,
'url' => $saveOrderingUrl . '&' . Session::getFormToken() . '=1',
'nested' => $nestedList,
]
);
}
// Depends on Joomla.getOptions()
HTMLHelper::_('behavior.core');
// Attach draggable to document
HTMLHelper::_('script', 'vendor/dragula/dragula.min.js', ['framework' => false, 'relative' => true]);
HTMLHelper::_('script', 'system/draggable.min.js', ['framework' => false, 'relative' => true]);
HTMLHelper::_('stylesheet', 'vendor/dragula/dragula.min.css', ['framework' => false, 'relative' => true, 'pathOnly' => false]);
// Set static array
static::$loaded[__METHOD__] = true;
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha11 to 4.0.0-alpha12. See them all, or every version of this file.