Source for file dropdown.php
Documentation is available at dropdown.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* HTML utility class for building a dropdown menu
* @package Joomla.Libraries
* @var array Array containing information for loaded files
protected static $loaded =
array();
* @var string HTML markup for the dropdown list
protected static $dropDownList =
null;
* Method to inject needed script
public static function init()
if (isset
(static::$loaded[__METHOD__
]))
JHtml::_('bootstrap.framework');
JFactory::getDocument()->addScriptDeclaration("
$(document).ready(function (){
$('.btn-group',$(this)).show();
$('.btn-group',$(this)).hide();
$('.btn-group',$(this)).removeClass('open');
contextAction =function (cbId, task)
$('input[name=\"cid[]\"]').removeAttr('checked');
$('#' + cbId).attr('checked','checked');
Joomla.submitbutton(task);
static::$loaded[__METHOD__
] =
true;
* Method to start a new dropdown menu
public static function start()
if (isset
(static::$loaded[__METHOD__
]) &&
static::$loaded[__METHOD__
] ==
true)
$dropDownList =
'<div class="btn-group" style="margin-left:6px;display:none">
<a href="#" data-toggle="dropdown" class="dropdown-toggle btn btn-mini">
<span class="caret"></span>
<ul class="dropdown-menu">';
static::$dropDownList =
$dropDownList;
static::$loaded[__METHOD__
] =
true;
* Method to render current dropdown menu
* @return string HTML markup for the dropdown list
public static function render()
$dropDownList =
static::$dropDownList;
$dropDownList .=
'</ul></div>';
static::$dropDownList =
null;
static::$loaded['JHtmlDropdown::start'] =
false;
* Append an edit item to the current dropdown menu
* @param integer $id Record ID
* @param string $prefix Task prefix
* @param string $customLink The custom link if dont use default Joomla action format
public static function edit($id, $prefix =
'', $customLink =
'')
$link =
'index.php?option=' .
$option;
$link .=
'&task=' .
$prefix .
'edit&id=' .
$id;
static::addCustomItem(JText::_('JACTION_EDIT'), $link);
* Append a publish item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function publish($checkboxId, $prefix =
'')
$task =
$prefix .
'publish';
static::addCustomItem(JText::_('JTOOLBAR_PUBLISH'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append an unpublish item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function unpublish($checkboxId, $prefix =
'')
$task =
$prefix .
'unpublish';
static::addCustomItem(JText::_('JTOOLBAR_UNPUBLISH'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append a featured item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function featured($checkboxId, $prefix =
'')
$task =
$prefix .
'featured';
static::addCustomItem(JText::_('JFEATURED'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append an unfeatured item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function unfeatured($checkboxId, $prefix =
'')
$task =
$prefix .
'unfeatured';
static::addCustomItem(JText::_('JUNFEATURED'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append an archive item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function archive($checkboxId, $prefix =
'')
$task =
$prefix .
'archive';
static::addCustomItem(JText::_('JTOOLBAR_ARCHIVE'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append an unarchive item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function unarchive($checkboxId, $prefix =
'')
$task =
$prefix .
'unpublish';
static::addCustomItem(JText::_('JTOOLBAR_UNARCHIVE'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append a trash item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function trash($checkboxId, $prefix =
'')
$task =
$prefix .
'trash';
static::addCustomItem(JText::_('JTOOLBAR_TRASH'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append an untrash item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function untrash($checkboxId, $prefix =
'')
$task =
$prefix .
'publish';
static::addCustomItem(JText::_('JTOOLBAR_UNTRASH'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Append a checkin item to the current dropdown menu
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
public static function checkin($checkboxId, $prefix =
'')
$task =
$prefix .
'checkin';
static::addCustomItem(JText::_('JTOOLBAR_CHECKIN'), 'javascript:void(0)', 'onclick="contextAction(\'' .
$checkboxId .
'\', \'' .
$task .
'\')"');
* Writes a divider between dropdown items
static::$dropDownList .=
'<li class="divider"></li>';
* Append a custom item to current dropdown menu
* @param string $label The label of item
* @param string $link The link of item
* @param string $linkAttributes Custom link attributes
* @param string $className Class name of item
* @param boolean $ajaxLoad True if using ajax load when item clicked
* @param string $jsCallBackFunc Javascript function name, called when ajax load successfully
public static function addCustomItem($label, $link =
'javascript:void(0)', $linkAttributes =
'', $className =
'', $ajaxLoad =
false,
$href =
' href = "javascript:void(0)" onclick="loadAjax(\'' .
$link .
'\', \'' .
$jsCallBackFunc .
'\')"';
$href =
' href = "' .
$link .
'" ';
$dropDownList =
static::$dropDownList;
$dropDownList .=
'<li class="' .
$className .
'"><a ' .
$linkAttributes .
$href .
' >';
$dropDownList .=
'</a></li>';
static::$dropDownList =
$dropDownList;
Documentation generated on Tue, 19 Nov 2013 15:01:45 +0100 by phpDocumentor 1.4.3