Skip to content

Commit

Permalink
Duplicate code.. Make a function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Nefzaoui authored and jdm committed Nov 3, 2014
1 parent 4d72ba1 commit ae9713b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions foopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
var currentLang = "en"; // Default lang
var rtlLangs = {"ar": "","fa": ""};

function detectRtl(value) {
if (value in rtlLangs) {
document.documentElement.dir = "rtl";
} else {
document.documentElement.dir = "ltr";
}
}

function chooseNegativeResponse() {
var responses = $('.negative').not('.visible');

Expand Down Expand Up @@ -127,11 +135,7 @@

function onLangChange() {
document.webL10n.setLanguage(this.value);
if (this.value in rtlLangs) {
document.documentElement.dir = "rtl";
} else {
document.documentElement.dir = "ltr";
}
detectRtl(this.value);
setLangQueryString(this.value)
}

Expand Down Expand Up @@ -204,11 +208,7 @@
// If the browser language is supported, select the good option

document.webL10n.setLanguage(value);
if (value in rtlLangs) {
document.documentElement.dir = "rtl";
} else {
document.documentElement.dir = "ltr";
}
detectRtl(value);
option.prop('selected', 'selected');

currentLang = value;
Expand Down

0 comments on commit ae9713b

Please sign in to comment.