Skip to content

Commit

Permalink
[#2700] Add flags to language box
Browse files Browse the repository at this point in the history
  • Loading branch information
aron committed Aug 2, 2012
1 parent f7d2c67 commit 06257ac
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 13 deletions.
90 changes: 84 additions & 6 deletions ckan/public/base/css/main.css
Expand Up @@ -6740,7 +6740,7 @@ li .icon-large:before {
clear: both;
}
.masthead hgroup h1,
.masthead hgroup p {
.masthead hgroup h2 {
font-size: 34px;
line-height: 1.5;
float: left;
Expand All @@ -6749,13 +6749,15 @@ li .icon-large:before {
font-family: "Arial Black", "Arial Bold", Gadget, sans-serif;
letter-spacing: -2px;
}
.masthead hgroup p {
.masthead hgroup h2 {
position: absolute;
bottom: -3px;
right: 0;
font-size: 15px;
margin: 0;
font-size: 15px;
font-weight: normal;
line-height: 1.2;
white-space: nowrap;
}
.masthead hgroup a {
text-decoration: none;
Expand Down Expand Up @@ -7000,16 +7002,92 @@ li .icon-large:before {
background: url("../images/ckan-logo-footer.png") no-repeat top left;
text-indent: -900em;
}
.site-footer .select2-drop {
.lang-dropdown {
color: #000;
}
.site-footer .select2-drop li {
.lang-dropdown li {
width: auto;
}
.ie .site-footer .select2-container {
.ie .lang-dropdown {
position: relative;
top: -20px;
}
.lang-dropdown .select2-result-label[data-value]:before {
content: "";
display: inline-block;
background-image: url("../images/flags.png");
width: 17px;
height: 11px;
position: relative;
top: 1px;
}
.lang-dropdown .select2-result-label[data-value*=en]:before {
background-position: 0 0;
}
.lang-dropdown .select2-result-label[data-value*=de]:before {
background-position: 0 -11px;
}
.lang-dropdown .select2-result-label[data-value*=fr]:before {
background-position: 0 -22px;
}
.lang-dropdown .select2-result-label[data-value*=it]:before {
background-position: 0 -33px;
}
.lang-dropdown .select2-result-label[data-value*=es]:before {
background-position: 0 -44px;
}
.lang-dropdown .select2-result-label[data-value*=pl]:before {
background-position: 0 -55px;
}
.lang-dropdown .select2-result-label[data-value*=ru]:before,
.lang-dropdown .select2-result-label[data-value*=sk]:before {
background-position: 0 -66px;
}
.lang-dropdown .select2-result-label[data-value*=nl]:before {
background-position: 0 -77px;
}
.lang-dropdown .select2-result-label[data-value*=sv]:before {
background-position: 0 -88px;
}
.lang-dropdown .select2-result-label[data-value*=no]:before {
background-position: 0 -99px;
}
.lang-dropdown .select2-result-label[data-value*=cs]:before {
background-position: 0 -110px;
}
.lang-dropdown .select2-result-label[data-value*=hu]:before {
background-position: 0 -121px;
}
.lang-dropdown .select2-result-label[data-value*=pt_BR]:before {
background-position: 0 -132px;
}
.lang-dropdown .select2-result-label[data-value*=fi]:before {
background-position: 0 -143px;
}
.lang-dropdown .select2-result-label[data-value*=bg]:before {
background-position: 0 -154px;
}
.lang-dropdown .select2-result-label[data-value*=ca]:before {
background-position: 0 -165px;
}
.lang-dropdown .select2-result-label[data-value*=sq]:before {
background-position: 0 -176px;
}
.lang-dropdown .select2-result-label[data-value*=sr]:before {
background-position: 0 -187px;
}
.lang-dropdown .select2-result-label[data-value*=sv]:before {
background-position: 0 -198px;
}
.lang-dropdown .select2-result-label[data-value*=lv]:before {
background-position: 0 -209px;
}
.lang-dropdown .select2-result-label[data-value*=zh_TW]:before {
background-position: 0 -198px;
}
.lang-dropdown .select2-result-label[data-value*=pt_BR]:before {
background-position: 0 -132px;
}
.profile-info {
*zoom: 1;
-webkit-border-radius: 3px 3px 0 0;
Expand Down
Binary file added ckan/public/base/images/flags.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions ckan/public/base/javascript/modules/autocomplete.js
Expand Up @@ -19,6 +19,8 @@ this.ckan.module('autocomplete', function (jQuery, _) {
items: 10,
source: null,
interval: 1000,
dropdownClass: '',
containerClass: '',
i18n: {
noMatches: _('No matches found'),
emptySearch: _('Start typing…'),
Expand Down Expand Up @@ -48,7 +50,9 @@ this.ckan.module('autocomplete', function (jQuery, _) {
width: 'resolve',
formatResult: this.formatResult,
formatNoMatches: this.formatNoMatches,
formatInputTooShort: this.formatInputTooShort
formatInputTooShort: this.formatInputTooShort,
dropdownCssClass: this.options.dropdownClass,
containerCssClass: this.options.containerClass
};

// Different keys are required depending on whether the select is
Expand Down Expand Up @@ -144,10 +148,21 @@ this.ckan.module('autocomplete', function (jQuery, _) {
/* Formatter for the select2 plugin that returns a string for use in the
* results list with the current term emboldened.
*
* state - The current object that is being rendered.
* container - The element the content will be added to (added in 3.0)
* query - The query object (added in select2 3.0).
*
*
* Returns a text string.
*/
formatResult: function (state) {
var term = this._lastTerm || null;
formatResult: function (state, container, query) {
var term = this._lastTerm || null; // same as query.term

if (container) {
// Append the select id to the element for styling.
container.attr('data-value', state.id);
}

return state.text.split(term).join(term && term.bold());
},

Expand Down
109 changes: 106 additions & 3 deletions ckan/public/base/less/footer.less
Expand Up @@ -46,15 +46,118 @@
text-indent: -900em;
}

.site-footer .select2-drop {
.lang-dropdown {
color: #000;
}

.site-footer .select2-drop li {
.lang-dropdown li {
width: auto;
}

.ie .site-footer .select2-container {
.ie .lang-dropdown {
position: relative;
top: -20px;
}

// Apply flags to the items in browsers that support :before
.lang-dropdown .select2-result-label {
&[data-value]:before {
content: "";
display: inline-block;
background-image: url("@{imagePath}/flags.png");
width: 17px;
height: 11px;
position: relative;
top: 1px;
}

&[data-value*=en]:before {
background-position: 0 0;
}

&[data-value*=de]:before {
background-position: 0 -11px;
}

&[data-value*=fr]:before {
background-position: 0 -22px;
}

&[data-value*=it]:before {
background-position: 0 -33px;
}

&[data-value*=es]:before {
background-position: 0 -44px;
}

&[data-value*=pl]:before {
background-position: 0 -55px;
}

&[data-value*=ru]:before,
&[data-value*=sk]:before {
background-position: 0 -66px;
}

&[data-value*=nl]:before {
background-position: 0 -77px;
}

&[data-value*=sv]:before {
background-position: 0 -88px;
}

&[data-value*=no]:before {
background-position: 0 -99px;
}

&[data-value*=cs]:before {
background-position: 0 -110px;
}

&[data-value*=hu]:before {
background-position: 0 -121px;
}

&[data-value*=pt_BR]:before {
background-position: 0 -132px;
}

&[data-value*=fi]:before {
background-position: 0 -143px;
}

&[data-value*=bg]:before {
background-position: 0 -154px;
}

&[data-value*=ca]:before {
background-position: 0 -165px;
}

&[data-value*=sq]:before {
background-position: 0 -176px;
}

&[data-value*=sr]:before {
background-position: 0 -187px;
}

&[data-value*=sv]:before {
background-position: 0 -198px;
}

&[data-value*=lv]:before {
background-position: 0 -209px;
}

&[data-value*=zh_TW]:before {
background-position: 0 -198px;
}

&[data-value*=pt_BR]:before {
background-position: 0 -132px;
}

}
2 changes: 1 addition & 1 deletion ckan/templates/snippets/language_selector.html
Expand Up @@ -2,7 +2,7 @@
{% set current_lang = request.environ.CKAN_LANG %}
<form class="form-inline form-select" action="{% url_for controller='util', action='redirect' %}" data-module="select-switch" method="POST">
<label for="field-lang-select">{{ _('Language') }}</label>
<select id="field-lang-select" name="url" data-module="autocomplete">
<select id="field-lang-select" name="url" data-module="autocomplete" data-module-dropdown-class="lang-dropdown">
{% for locale in h.get_available_locales() %}
<option value="{% url_for current_url, locale=locale %}" {% if locale == current_lang %}selected="selected"{% endif %}>
{{ locale.display_name or locale.english_name }}
Expand Down

0 comments on commit 06257ac

Please sign in to comment.