Bug 246827 - Newly added languages should appear on top of the list. r=gavin
authorJavi Rueda <leofigueres@yahoo.com>
Mon, 05 Dec 2011 00:25:24 +0100
changeset 83065 0f4d49ced402704be69debeaa1bc06ddb5a7a716
parent 83064 a0e9e2640477593d07b48f5841a4982dab2315e8
child 83066 de7161dd46203b9132ee5e17d7ef66c8686f8348
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs246827
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 246827 - Newly added languages should appear on top of the list. r=gavin
browser/components/preferences/languages.js
--- a/browser/components/preferences/languages.js
+++ b/browser/components/preferences/languages.js
@@ -204,28 +204,30 @@ var gLanguagesDialog = {
   {
     var selectedID = this._availableLanguages.selectedItem.id;
     var preference = document.getElementById("intl.accept_languages");
     var arrayOfPrefs = preference.value.toLowerCase().split(/\s*,\s*/);
     for (var i = 0; i < arrayOfPrefs.length; ++i ){
       if (arrayOfPrefs[i] == selectedID)
         return;
     }
-      
+
     this._selectedItemID = selectedID;
-    
+
     if (preference.value == "") 
       preference.value = selectedID;
-    else
-      preference.value += "," + selectedID;
+    else {
+      arrayOfPrefs.unshift(selectedID);
+      preference.value = arrayOfPrefs.join(",");
+    }
   
     this._acceptLanguages[selectedID] = true;
     this._availableLanguages.selectedItem = null;
     
-    // Reuild the available list with the added item removed...
+    // Rebuild the available list with the added item removed...
     this._buildAvailableLanguageList(); 
     
     this._availableLanguages.setAttribute("label", this._availableLanguages.getAttribute("label2"));
   },
   
   removeLanguage: function ()
   {
     // Build the new preference value string.