Merge pull request #57 from asig2016/add_class_to_dropdown

select-cat widget: add different class per level to allow different …
This commit is contained in:
Ralf Becker 2019-03-12 14:55:30 +01:00 committed by Hadi Nategh
parent 780b7e56b5
commit e1476e4167
2 changed files with 9 additions and 3 deletions

View File

@ -278,8 +278,9 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
* @param {string} _label label of option
* @param {string} _title title attribute of option
* @param {node} dom_element parent of new option
* @param {string} _class specify classes of option
*/
_appendOptionElement: function(_value, _label, _title, dom_element) {
_appendOptionElement: function(_value, _label, _title, dom_element, _class) {
if(_value == "" && (_label == null || _label == "")) {
return; // empty_label is added in set_select_options anyway, ignoring it here to not add it twice
}
@ -292,6 +293,7 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
var option = jQuery(document.createElement("option"))
.attr("value", _value)
.text(_label+"");
option.addClass(_class);
if (this.options.tags)
{
switch (this._type)
@ -938,7 +940,9 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
{
this._appendOptionElement(typeof _options[key].value != 'undefined' ? _options[key].value : key,
_options[key]["label"] ? _options[key]["label"] : "",
_options[key]["title"] ? _options[key]["title"] : "");
_options[key]["title"] ? _options[key]["title"] : "",
'',
_options[key]["class"] ? _options[key]["class"] : "");
}
}
else

View File

@ -618,7 +618,9 @@ class Select extends Etemplate\Widget
// These are extra info for easy dealing with categories
// client side, without extra loading
'main' => (int)$cat['main'],
'children' => $cat['children']
'children' => $cat['children'],
//add different class per level to allow different styling for each category level:
'class' => "cat_level". $cat['level']
);
// Send data too
if(is_array($cat['data']))