W.I.P of cats, versions or trackers categories color code

This commit is contained in:
Hadi Nategh 2019-02-06 18:39:24 +01:00
parent 2405d8f2d3
commit 7f57a4f4aa
2 changed files with 18 additions and 9 deletions

View File

@ -2494,7 +2494,8 @@ var et2_nextmatch_header_bar = (function(){ "use strict"; return et2_DOMWidget.e
'select' : 'select-cat', settings.cat_id, settings.cat_is_select !== true, { 'select' : 'select-cat', settings.cat_id, settings.cat_is_select !== true, {
multiple: false, multiple: false,
tags: true, tags: true,
class: "select-cat" class: "select-cat",
value_class: settings.cat_id_class
}); });
} }
@ -2509,7 +2510,8 @@ var et2_nextmatch_header_bar = (function(){ "use strict"; return et2_DOMWidget.e
settings.filter2_no_lang, { settings.filter2_no_lang, {
multiple: false, multiple: false,
tags: settings.filter2_tags, tags: settings.filter2_tags,
class: "select-cat" class: "select-cat",
value_class: settings.filter2_class
}); });
} }

View File

@ -95,6 +95,12 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
"other": { "other": {
"ignore": true, "ignore": true,
"type": "any" "type": "any"
},
value_class: {
name: "Value class",
type: "string",
default: "",
description: "Allow to set a custom css class combined with selected value. (e.g. cat_23)"
} }
}, },
@ -298,7 +304,7 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
option.addClass('et2_country-select flag-'+_value.toLowerCase()) option.addClass('et2_country-select flag-'+_value.toLowerCase())
break; break;
} }
if (this.value_class != '') option.addClass(this.value_class+_value);
} }
if (typeof _title != "undefined" && _title) if (typeof _title != "undefined" && _title)
{ {
@ -545,13 +551,14 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
this.set_select_options(this.options.select_options); this.set_select_options(this.options.select_options);
} }
// select-cat set/unset right cat_ color for selected value // select-cat set/unset right cat_ color for selected value
if (this._type == 'select-cat' && this.options.tags) { if ((this._type == 'select-cat' || this.value_class) && this.options.tags) {
var chosen = this.input.siblings(); var chosen = this.input.next();
this.input.removeClass('cat_'+this._oldValue); var prefix_c = this.value_class ? this.value_class : 'cat_';
this.input.addClass('cat_'+this.value); this.input.removeClass(prefix_c+this._oldValue);
this.input.addClass(prefix_c+this.value);
if (chosen.length > 0) { if (chosen.length > 0) {
chosen.removeClass('cat_'+this._oldValue); chosen.removeClass(prefix_c+this._oldValue);
chosen.addClass('cat_'+this.value); chosen.addClass(prefix_c+this.value);
} }
} }
if (this._type == 'select-country' && this.options.tags) if (this._type == 'select-country' && this.options.tags)