Merge pull request #2636 from meglio/color-tags
Show color for values of type:list site settings with word 'colors' in t...
This commit is contained in:
commit
9b4c18baf1
|
@ -13,15 +13,31 @@
|
||||||
Discourse.ListSettingComponent = Ember.Component.extend({
|
Discourse.ListSettingComponent = Ember.Component.extend({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
|
|
||||||
|
|
||||||
|
_select2FormatSelection: function(selectedObject, jqueryWrapper, htmlEscaper) {
|
||||||
|
var text = selectedObject.text;
|
||||||
|
if (text.length <= 6) {
|
||||||
|
jqueryWrapper.closest('li.select2-search-choice').css({"border-bottom": '7px solid #'+text});
|
||||||
|
}
|
||||||
|
return htmlEscaper(text);
|
||||||
|
},
|
||||||
|
|
||||||
didInsertElement: function(){
|
didInsertElement: function(){
|
||||||
this.$("input").select2({
|
|
||||||
multiple: false,
|
var select2_options = {
|
||||||
separator: "|",
|
multiple: false,
|
||||||
tokenSeparators: ["|"],
|
separator: "|",
|
||||||
tags : this.get("choices") || [],
|
tokenSeparators: ["|"],
|
||||||
width: 'off',
|
tags : this.get("choices") || [],
|
||||||
dropdownCss: this.get("choices") ? {} : {display: 'none'}
|
width: 'off',
|
||||||
}).on("change", function(obj) {
|
dropdownCss: this.get("choices") ? {} : {display: 'none'}
|
||||||
|
};
|
||||||
|
|
||||||
|
var settingName = this.get('settingName');
|
||||||
|
if (typeof settingName === 'string' && settingName.indexOf('colors') > -1) {
|
||||||
|
select2_options.formatSelection = this._select2FormatSelection;
|
||||||
|
}
|
||||||
|
this.$("input").select2(select2_options).on("change", function(obj) {
|
||||||
this.set("settingValue", obj.val.join("|"));
|
this.set("settingValue", obj.val.join("|"));
|
||||||
this.refreshSortables();
|
this.refreshSortables();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<h3>{{unbound settingName}}</h3>
|
<h3>{{unbound settingName}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-value">
|
<div class="setting-value">
|
||||||
{{list-setting settingValue=value choices=choices}}
|
{{list-setting settingValue=value choices=choices settingName=setting}}
|
||||||
<div class='desc'>{{unbound description}}</div>
|
<div class='desc'>{{unbound description}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{#if dirty}}
|
{{#if dirty}}
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
# type: email - Must be a valid email address.
|
# type: email - Must be a valid email address.
|
||||||
# type: username - Must match the username of an existing user.
|
# type: username - Must match the username of an existing user.
|
||||||
# type: list - A list of values, chosen from a set of valid values defined in the choices option.
|
# type: list - A list of values, chosen from a set of valid values defined in the choices option.
|
||||||
|
#
|
||||||
|
# A type:list setting with the word 'colors' in its name will make color values have a bold line of the corresponding color
|
||||||
|
#
|
||||||
required:
|
required:
|
||||||
title:
|
title:
|
||||||
client: true
|
client: true
|
||||||
|
|
Loading…
Reference in New Issue