/**
* Method to load the AJAX Chosen library
*
* If debugging mode is on an uncompressed version of AJAX Chosen is included for easier debugging.
*
* @param Registry $options Options in a Registry object
* @param mixed $debug Is debugging mode on? [optional]
*
* @return void
*
* @since 3.0
*/
public static function ajaxchosen(Registry $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');
// Ajax URL is mandatory
if (!empty($url)) {
if (isset(static::$loaded[__METHOD__][$selector])) {
return;
}
// Requires chosen to work
static::chosen($selector, $debug);
Text::script('JGLOBAL_KEEP_TYPING');
Text::script('JGLOBAL_LOOKING_FOR');
// Include scripts
HTMLHelper::_('behavior.core');
HTMLHelper::_('jquery.framework');
HTMLHelper::_('script', 'legacy/ajax-chosen.min.js', ['version' => 'auto', 'relative' => true, 'detectDebug' => $debug]);
Factory::getDocument()->addScriptOptions('ajax-chosen', array('url' => $url, 'debug' => $debug, 'options' => $options, 'selector' => $selector, 'type' => $type, 'dataType' => $dataType, 'jsonTermKey' => $jsonTermKey, 'afterTypeDelay' => $afterTypeDelay, 'minTermLength' => $minTermLength));
static::$loaded[__METHOD__][$selector] = true;
}
}