Source for file formbehavior.php
Documentation is available at formbehavior.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
* Utility class for form related behaviors
* @package Joomla.Libraries
* @var array Array containing information for loaded files
protected static $loaded =
array();
* Method to load the Chosen JavaScript framework and supporting CSS into the document head
* If debugging mode is on an uncompressed version of Chosen is included for easier debugging.
* @param string $selector Class for Chosen elements.
* @param mixed $debug Is debugging mode on? [optional]
public static function chosen($selector =
'.advancedSelect', $debug =
null)
if (isset
(static::$loaded[__METHOD__
][$selector]))
JHtml::_('jquery.framework');
// Add chosen.jquery.js language strings
JText::script('JGLOBAL_SELECT_SOME_OPTIONS');
JText::script('JGLOBAL_SELECT_AN_OPTION');
JText::script('JGLOBAL_SELECT_NO_RESULTS_MATCH');
// If no debugging value is set, use the configuration setting
$config =
JFactory::getConfig();
$debug = (boolean)
$config->get('debug');
JHtml::_('script', 'jui/chosen.jquery.min.js', false, true, false, false, $debug);
JHtml::_('stylesheet', 'jui/chosen.css', false, true);
jQuery(document).ready(function (){
jQuery('" .
$selector .
"').chosen({
disable_search_threshold : 10,
allow_single_deselect : true
static::$loaded[__METHOD__
][$selector] =
true;
* Method to load the AJAX Chosen library
* If debugging mode is on an uncompressed version of AJAX Chosen is included for easier debugging.
* @param JRegistry $options Options in a JRegistry object
* @param mixed $debug Is debugging mode on? [optional]
public static function ajaxchosen(JRegistry $options, $debug =
null)
// Retrieve options/defaults
$selector =
$options->get('selector', '.tagfield');
$type =
$options->get('type', 'GET');
$url =
$options->get('url', null);
$dataType =
$options->get('dataType', 'json');
$jsonTermKey =
$options->get('jsonTermKey', 'term');
$afterTypeDelay =
$options->get('afterTypeDelay', '500');
$minTermLength =
$options->get('minTermLength', '3');
if (isset
(static::$loaded[__METHOD__
][$selector]))
// Requires chosen to work
static::chosen($selector, $debug);
JHtml::_('script', 'jui/ajax-chosen.min.js', false, true, false, false, $debug);
$(document).ready(function () {
$('" .
$selector .
"').ajaxChosen({
dataType: '" .
$dataType .
"',
jsonTermKey: '" .
$jsonTermKey .
"',
afterTypeDelay: '" .
$afterTypeDelay .
"',
minTermLength: '" .
$minTermLength .
"'
$.each(data, function (i, val) {
results.push({ value: val.value, text: val.text });
static::$loaded[__METHOD__
][$selector] =
true;
Documentation generated on Tue, 19 Nov 2013 15:03:45 +0100 by phpDocumentor 1.4.3