Skip to content

Dropdown Alignment for locale names - Fix #19, #127 #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cb5801d
Language menu alignment
share-with-me Jul 1, 2017
26813c0
Remove trailing space
share-with-me Jul 1, 2017
f0ceb1b
Code style changes
share-with-me Jul 1, 2017
a6a91f5
sass-lint
share-with-me Jul 1, 2017
ac58ded
Travis
share-with-me Jul 1, 2017
0b5212a
Use locales.json to fetch current page name
share-with-me Jul 1, 2017
f56e6cd
Change ID name
share-with-me Jul 1, 2017
bda28d6
Styling the dropdown button
share-with-me Jul 6, 2017
405ab95
Travis
share-with-me Jul 6, 2017
ee1f6b4
Style and align like select
share-with-me Jul 6, 2017
d7a6cbe
padding added to locale button names
share-with-me Jul 11, 2017
3c12e62
Changes
share-with-me Jul 13, 2017
ba1fbd9
Travis
share-with-me Jul 13, 2017
f2a5416
sass-lint disable for !important
share-with-me Jul 13, 2017
3525be4
CHange cursor on hover of button to default
share-with-me Jul 14, 2017
13c48fa
Changes
share-with-me Jul 16, 2017
375fa10
Extract lang info in isRtlLanguage
share-with-me Jul 19, 2017
fac9d09
Restore direction function
share-with-me Jul 21, 2017
c35bc9a
Reduce space between dropdown button and menu
share-with-me Jul 31, 2017
383957a
Travis
share-with-me Jul 31, 2017
388db58
Add CSS to force visible a scrollbar on OSX
share-with-me Aug 10, 2017
bc98919
Travis and rename pageLocales to localeToLanguageMap
share-with-me Aug 10, 2017
cc01036
Space added between paren and selector
share-with-me Aug 12, 2017
f4e7e8d
Remove localeToLanguageMap and append this as key-value data to local…
share-with-me Aug 19, 2017
95abf26
Style only the scrollbar corresponding to language dropdown
share-with-me Aug 19, 2017
8018e6a
Use data method and remove closing option tag
share-with-me Aug 20, 2017
83124bf
Update localization.js
sushain97 Aug 20, 2017
da42d9c
Move styles to css file
share-with-me Aug 20, 2017
a8cba41
Travis
share-with-me Aug 20, 2017
67a3cb5
Travis
share-with-me Aug 20, 2017
449e813
Remove media quey for dropdown scrollbar
share-with-me Aug 21, 2017
32163af
Merge branch 'master' into gsoc-mono-language-menu
share-with-me Sep 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,67 @@ h2 {
margin-top: 7px;
}

#localeDropdown {
height: 300px;
margin-top: -1px;
min-width: 0 !important; /* sass-lint:disable-line no-important */
overflow-y: scroll;
width: 131px;
}

#localeDropdown li > a[dir='rtl'] {
padding-left: 105px;
padding-right: 5px;
text-align: right;
}

#localeDropdown li > a[dir='ltr'] {
padding-left: 5px;
padding-right: 105px;
text-align: left;
}

#localeDropdownSelect:hover {
cursor: default;
}

#localeDropdown li > a:hover {
background-color: #446e9b;
color: #fff;
cursor: default;
}

#localeDropdown::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}

#localeDropdown::-webkit-scrollbar-thumb {
-webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
background-color: rgba(0, 0, 0, .5);
border-radius: 4px;
}

#localeDropdownSelect {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 3px;
color: #000;
margin-top: 5px;
padding: 0;
width: 130px;
}

#localeName {
padding-left: 7px;
padding-right: 7px;
}

#localeDropdownCaret {
position: absolute;
top: 50%;
}

.nav-pills { /* sass-lint:disable-line class-name-format */
cursor: pointer;
}
Expand Down
32 changes: 28 additions & 4 deletions assets/js/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,29 @@ $(document).ready(function () {
console.warn('No config.LOCALES');
}
$('.localeSelect').val(locale);
$('#localeName').text($('#localeDropdown').data(locale));
localizeEverything(localizedHTML);
persistChoices('localization');
});

$('.localeSelect').change(function () {
locale = $(this).val();
$('#localeName').text($('#localeDropdown').data(locale));
localizeCurrentInterface();
});

$('#localeDropdown li > a').click(function () {
locale = $(this).data('locale');
$('.localeSelect').val(locale);
$('#localeName').text(this.text);
localizeCurrentInterface();
});

function localizeCurrentInterface() {
sendEvent('localization', 'localize', locale);
localizeEverything(false);
persistChoices('localization');
});
}

function localizeEverything(stringsFresh) {
localizeInterface();
Expand Down Expand Up @@ -114,6 +127,7 @@ $(document).ready(function () {
window.location.hash;
window.history.replaceState({}, document.title, newURL);
}
$('#localeDropdownCaret').css('left', rtlLanguages.indexOf(locale) !== -1 ? '5%' : '90%');
}
});

Expand Down Expand Up @@ -169,7 +183,6 @@ function getLocale() {
deferred.resolve();
}
}

return deferred.promise();
}

Expand Down Expand Up @@ -212,13 +225,24 @@ function getLocales() {
return a[1].toLowerCase().localeCompare(b[1].toLowerCase());
});
$('.localeSelect').empty();
$('#localeDropdown').empty();
$.each(localePairs, function () {
var isRtlLanguage = (rtlLanguages.indexOf(this[0]) !== -1);
$('.localeSelect').append(
$('<option></option>')
$('<option>')
.val(this[0])
.text(this[1])
.prop('dir', rtlLanguages.indexOf(this[0]) !== -1 ? 'rtl' : 'ltr')
.prop('dir', isRtlLanguage ? 'rtl' : 'ltr')
);

$('#localeDropdown').append(
$('<li></li>').append(
$('<a>')
.data('locale', this[0])
.text(this[1])
.prop('dir', isRtlLanguage ? 'rtl' : 'ltr')
)
).data(this[0], this[1]);
});
}

Expand Down
6 changes: 4 additions & 2 deletions index.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@
<p data-text="tagline" class="tagline"></p>
</div>
<div style="width: 35%" class="pull-right hidden-xs">
<!-- <i class="icon-globe localeGlobe pull-right"></i> -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

<i class="fa fa-globe fa-2x fa-inverse pull-right localeGlobe" style="padding: 5px 5px 0px 0px"></i>
<select class="localeSelect pull-right"><option> </option></select>
<div class="dropdown pull-right">
<button id="localeDropdownSelect" class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"><span id="localeName" class="pull-left"></span><span class="caret" id="localeDropdownCaret"></span></button>
<ul class="dropdown-menu" id="localeDropdown"></ul>
</div>
</div>
<ul class="nav navbar-nav navbar-right collapse navbar-collapse">
<li><a href="#translation" id="translationTarget" data-mode="translation" data-text="Translation" class="hide">Translation</a></li>
Expand Down