Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #76 from dgt41/_chosen
Browse files Browse the repository at this point in the history
Clean up chosen, tag
  • Loading branch information
C-Lodder committed Oct 27, 2016
2 parents 53da08d + 710bf84 commit 7423ef7
Show file tree
Hide file tree
Showing 27 changed files with 203 additions and 2,104 deletions.
1 change: 1 addition & 0 deletions dev/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ module.exports = function(grunt) {
{ src: ['assets/tmp/codemirror/LICENSE'], dest: '../media/vendor/codemirror/LICENSE'},
{ src: ['assets/tmp/jcrop/jcrop-MIT-LICENSE.txt'], dest: '../media/vendor/jcrop/jcrop-MIT-LICENSE.txt'},
{ src: ['assets/node_modules/dragula/license'], dest: '../media/vendor/dragula/license'},
{ src: ['assets/node_modules/awesomplete/LICENSE'], dest: '../media/vendor/awesomplete/LICENSE'},
]
}
},
Expand Down
3 changes: 1 addition & 2 deletions dev/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ public static function getCoreAssets() {
'bootstrap' => array('version' => '~4.0.0-alpha.5','dependencies' => 'jquery, tether'),
'tether' => array('version' => '1.3.7','dependencies' => 'jquery, tether'),
'font-awesome' => array('version' => '4.6.3','dependencies' => ''),
'chosenjs' => array('version' => '1.4.3','dependencies' => 'jquery, tether'),
'jquery-minicolors' => array('version' => '2.1.10','dependencies' => 'jquery'),
'jquery-sortable' => array('version' => '0.9.13','dependencies' => 'jquery'),
'jquery-ui' => array('version' => '1.12.1','dependencies' => 'jquery'),
'mediaelement' => array('version' => '2.22.0','dependencies' => 'jquery'),
'punycode' => array('version' => '1.4.1','dependencies' => ''),
'tinymce' => array('version' => '4.4.3','dependencies' => ''),
'awesomplete' => array('version' => '1.1.1','dependencies' => ''),
'dragula' => array('version' => '3.7.2','dependencies' => ''),
'codemirror' => array('version' => '5.19.0','dependencies' => ''),
'jcrop' => array('version' => '2.0.4','dependencies' => ''),
'autocomplete' => array('version' => '1.2.26','dependencies' => ''),
'dragula' => array('version' => '3.7.2','dependencies' => ''),

);
}
Expand Down
9 changes: 3 additions & 6 deletions dev/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ vendors:
'font-awesome':
'version': '4.6.3'
'dependencies': ''
'chosenjs':
'version': '1.4.3'
'dependencies': 'jquery, tether'
'jquery-minicolors':
'version': '2.1.10'
'dependencies': 'jquery'
Expand All @@ -40,6 +37,9 @@ vendors:
'awesomplete':
'version': '1.1.1'
'dependencies': ''
'dragula':
'version': '3.7.2'
'dependencies': ''

### These are always fetced with curl ###
'codemirror':
Expand All @@ -51,9 +51,6 @@ vendors:
'autocomplete':
'version': '1.2.26'
'dependencies': ''
'dragula':
'version': '3.7.2'
'dependencies': ''

### The javascript polyfills
polyfills:
Expand Down
57 changes: 0 additions & 57 deletions layouts/joomla/html/formbehavior/ajaxchosen.php

This file was deleted.

38 changes: 0 additions & 38 deletions layouts/joomla/html/formbehavior/chosen.php

This file was deleted.

100 changes: 0 additions & 100 deletions layouts/joomla/html/tag.php

This file was deleted.

58 changes: 36 additions & 22 deletions libraries/cms/html/formbehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,24 @@ public static function chosen($selector = '.advancedSelect', $debug = null, $opt
$options['no_results_text'] = JText::_('JGLOBAL_SELECT_NO_RESULTS_MATCH');
}

$displayData = array(
'debug' => $debug,
'options' => $options,
'selector' => $selector,
);
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'system/legacy/chosen.jquery.min.js', false, true, false, false, $debug);
JHtml::_('stylesheet', 'system/legacy/chosen.css', false, true);

JLayoutHelper::render('joomla.html.formbehavior.chosen', $displayData);
// Options array to json options string
$options_str = json_encode($options, ($debug && defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false));

static::$loaded[__METHOD__][$selector] = true;

return;
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(document).ready(function (){
jQuery('" . $selector . "').chosen(" . $options_str . ");
});
"
);

static::$loaded[__METHOD__][$selector] = true;
}

/**
Expand Down Expand Up @@ -129,23 +136,30 @@ public static function ajaxchosen(Registry $options, $debug = null)
// Requires chosen to work
static::chosen($selector, $debug);

$displayData = array(
'url' => $url,
'debug' => $debug,
'options' => $options,
'selector' => $selector,
'type' => $type,
'dataType' => $dataType,
'jsonTermKey' => $jsonTermKey,
'afterTypeDelay' => $afterTypeDelay,
'minTermLength' => $minTermLength,
JText::script('JGLOBAL_KEEP_TYPING');
JText::script('JGLOBAL_LOOKING_FOR');

// Include scripts
JHtml::_('behavior.core');
JHtml::_('jquery.framework');
JHtml::_('script', 'system/legacy/ajax-chosen.min.js', false, true, false, false, $debug);

JFactory::getDocument()->addScriptOptions(
'ajax-chosen',
array(
'url' => $url,
'debug' => $debug,
'options' => $options,
'selector' => $selector,
'type' => $type,
'dataType' => $dataType,
'jsonTermKey' => $jsonTermKey,
'afterTypeDelay' => $afterTypeDelay,
'minTermLength' => $minTermLength,
)
);

JLayoutHelper::render('joomla.html.formbehavior.ajaxchosen', $displayData);

static::$loaded[__METHOD__][$selector] = true;
}

return;
}
}
40 changes: 33 additions & 7 deletions libraries/cms/html/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,40 @@ public static function ajaxfield($selector = '#jform_tags', $allowCustom = true)
$params = JComponentHelper::getParams("com_tags");
$minTermLength = (int) $params->get("min_term_length", 3);

$displayData = array(
'minTermLength' => $minTermLength,
'selector' => $selector,
'allowCustom' => JFactory::getUser()->authorise('core.create', 'com_tags') ? $allowCustom : false,
JText::script('JGLOBAL_KEEP_TYPING');
JText::script('JGLOBAL_LOOKING_FOR');

// Include scripts
JHtml::_('behavior.core');
JHtml::_('jquery.framework');
JHtml::_('script', 'system/legacy/ajax-chosen.min.js', false, true, false, false, JDEBUG);

JFactory::getDocument()->addScriptOptions(
'ajax-chosen',
array(
'url' => JUri::root() . 'index.php?option=com_tags&task=tags.searchAjax',
'debug' => JDEBUG,
'selector' => $selector,
'type' => 'GET',
'dataType' => 'json',
'jsonTermKey' => 'like',
'afterTypeDelay' => 500,
'minTermLength' => $minTermLength
)
);

JLayoutHelper::render('joomla.html.tag', $displayData);

return;
// Allow custom values ?
if ($allowCustom)
{
JHtml::_('script', 'system/fields/tag.min.js', false, true, false, false, JDEBUG);
JFactory::getDocument()->addScriptOptions(
'field-tag-custom',
array(
'minTermLength' => $minTermLength,
'selector' => $selector,
'allowCustom' => JFactory::getUser()->authorise('core.create', 'com_tags') ? $allowCustom : false,
)
);
}
}
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7423ef7

Please sign in to comment.