Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
Fixes /issues/79
Browse files Browse the repository at this point in the history
  • Loading branch information
reshadn committed Oct 15, 2015
1 parent 7c00b06 commit a0a8db5
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/scripts/components/header/ContentDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,27 @@ class ContentDropdown extends React.Component {

renderContent(type) {
var condition;
return this.state.options.map((option) => {
if (type === 'en') {
condition = option.language === 'en' && (option.type === 'translation' || option.type === 'transliteration');
} else if (type === '!en') {
condition = option.language !== 'en' && option.type === 'translation';
}
if (condition) {
return this.returnList(option);
}
});
return this.state.options
// Sort all options to ensure translation languages are in alphabetical order
.sort((a, b) => {
return (a.slug < b.slug) ? -1 : (a.slug > b.slug) ? 1 : 0;
})
.map((option) => {
switch(type) {
case 'en':
condition = option.language === 'en' && option.type === 'translation';
break;
case '!en':
condition = option.language !== 'en' && option.type === 'translation';
break;
case 'transliteration':
condition = option.language === 'en' && option.type === 'transliteration';
break;
}
if (condition) {
return this.returnList(option);
}
});
}

render() {
Expand All @@ -103,6 +114,7 @@ class ContentDropdown extends React.Component {
<HeaderDropdown linkContent='Translations' linkIcon='ss-icon ss-globe' className={className}>
<li role="presentation" className="dropdown-header">English</li>
{this.renderContent('en')}
{this.renderContent('transliteration')}
<li role="presentation" className="dropdown-header languages">Other Languages</li>
{this.renderContent('!en')}

Expand Down

0 comments on commit a0a8db5

Please sign in to comment.