Fix some issues with select-country widget:

- Country selection in preferences does not respect selected value
- Fix missing empty labels in country selection in preferences
- Remove flag image from empty labels
This commit is contained in:
Hadi Nategh 2018-09-25 11:24:09 +02:00
parent 1e98a89bbd
commit 13f3cc5260
4 changed files with 24 additions and 1 deletions

View File

@ -237,8 +237,9 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
change: function(_node, _widget, _value) { change: function(_node, _widget, _value) {
var valid = this._super.apply(this, arguments); var valid = this._super.apply(this, arguments);
if (!this.input) return valid;
var selected = this.input.siblings().find('a.chzn-single'); var selected = this.input.siblings().find('a.chzn-single');
var val = _value && _value.selected ? _value.selected : this.value; var val = _value && _value.selected ? _value.selected : this.input.val();
switch (this._type) switch (this._type)
{ {
case 'select-country': case 'select-country':
@ -551,6 +552,19 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
chosen.addClass('cat_'+this.value); chosen.addClass('cat_'+this.value);
} }
} }
if (this._type == 'select-country' && this.options.tags)
{
var selected = this.input.siblings().find('a.chzn-single');
if (selected && selected.length == 1 && _value)
{
selected.removeClass (function (index, className) {
return (className.match (/(^|\s)flag-\S+/g) || []).join(' ');
});
selected.find('span.img').remove();
selected.prepend('<span class="img"></span>');
selected.addClass('et2_country-select flag-'+ _value.toLowerCase());
}
}
this._oldValue = this.value; this._oldValue = this.value;
if(this.input !== null && (this.options.tags || this.options.search)) if(this.input !== null && (this.options.tags || this.options.search))
{ {

View File

@ -9,6 +9,8 @@
margin-right: 10px; margin-right: 10px;
} }
.et2_country-select.flag-0 span.img,
.et2_country-select.flag- span.img,
.et2_country-select.flag--custom- span.img{ .et2_country-select.flag--custom- span.img{
background-image: none; background-image: none;
} }

View File

@ -2881,6 +2881,12 @@ tr.dialogHeader2 td {padding-top:15px;}
box-shadow: 0px 0px 10px 2px #888888; box-shadow: 0px 0px 10px 2px #888888;
} }
/*Posion the selected flag better*/
a.chzn-single.et2_country-select span.img {
color: transparent;
top: -4px;
}
.et2_avatar { .et2_avatar {
} }

View File

@ -261,6 +261,7 @@ class preferences_hooks
'help' => 'In which country are you. This is used to set certain defaults for you.', 'help' => 'In which country are you. This is used to set certain defaults for you.',
'xmlrpc' => True, 'xmlrpc' => True,
'admin' => False, 'admin' => False,
'values' => array(''),
'default'=> strtoupper($country), 'default'=> strtoupper($country),
'attributes' => array ( 'attributes' => array (
'tags' => true 'tags' => true