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

Commit

Permalink
Merge pull request #8163 from crdlc/bug-841082
Browse files Browse the repository at this point in the history
Bug 841082 - [Contacts] The "sort by last name" switcher is not initiali...
  • Loading branch information
jmcanterafonseca committed Feb 18, 2013
2 parents dac3c41 + e10364a commit fddf445
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions apps/communications/contacts/js/contacts_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var contacts = window.contacts || {};
**/
contacts.Settings = (function() {

var orderItem,
var orderCheckBox,
orderByLastName,
simImportLink,
fbImportOption,
Expand Down Expand Up @@ -44,12 +44,13 @@ contacts.Settings = (function() {
var updateOrderingUI = function updateOrderingUI() {
var value = newOrderByLastName === null ? orderByLastName :
newOrderByLastName;
orderItem.checked = value;
orderCheckBox.checked = value;
};

// Initialises variables and listener for the UI
var initContainers = function initContainers() {
orderItem = document.getElementById('settingsOrder');
var orderItem = document.getElementById('settingsOrder');
orderCheckBox = orderItem.querySelector('[name="order.lastname"]');
orderItem.addEventListener('click', onOrderingChange.bind(this));

simImportLink = document.querySelector('[data-l10n-id="importSim"]');
Expand Down Expand Up @@ -318,11 +319,9 @@ contacts.Settings = (function() {

// Listens for any change in the ordering preferences
var onOrderingChange = function onOrderingChange(evt) {
var checkBox = evt.target.querySelector('[name="order.lastname"]');
checkBox.checked = !checkBox.checked;
newOrderByLastName = checkBox.checked;
asyncStorage.setItem(ORDER_KEY, newOrderByLastName);
newOrderByLastName = !orderCheckBox.checked;
updateOrderingUI();
asyncStorage.setItem(ORDER_KEY, newOrderByLastName);
};

// Import contacts from SIM card and updates ui
Expand Down

0 comments on commit fddf445

Please sign in to comment.