зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1288558 - Part 8: Remove unnecessary and unused parameters for SortTree and move parameters to the top. r=MattN
MozReview-Commit-ID: CiA6e7vPdyb --HG-- extra : rebase_source : d6358a195e9fed2c5ba4d8f5ec217403e8b14037
This commit is contained in:
Родитель
235e13117e
Коммит
f2f02ac4c8
|
@ -16,6 +16,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||||
|
|
||||||
let kSignonBundle;
|
let kSignonBundle;
|
||||||
|
|
||||||
|
// Default value for signon table sorting
|
||||||
|
let lastSignonSortColumn = "hostname";
|
||||||
|
let lastSignonSortAscending = true;
|
||||||
|
|
||||||
let showingPasswords = false;
|
let showingPasswords = false;
|
||||||
|
|
||||||
// password-manager lists
|
// password-manager lists
|
||||||
|
@ -210,15 +214,12 @@ let signonsTreeView = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending, updateSelection) {
|
function SortTree(tree, column, ascending) {
|
||||||
|
let table = signonsTreeView._filterSet.length ? signonsTreeView._filterSet : signons;
|
||||||
// remember which item was selected so we can restore it after the sort
|
// remember which item was selected so we can restore it after the sort
|
||||||
let selections = GetTreeSelections(tree);
|
let selections = GetTreeSelections(tree);
|
||||||
let selectedNumber = selections.length ? table[selections[0]].number : -1;
|
let selectedNumber = selections.length ? table[selections[0]].number : -1;
|
||||||
|
|
||||||
// determine if sort is to be ascending or descending
|
|
||||||
let ascending = (column == lastSortColumn) ? !lastSortAscending : true;
|
|
||||||
|
|
||||||
function compareFunc(a, b) {
|
function compareFunc(a, b) {
|
||||||
let valA, valB;
|
let valA, valB;
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
@ -251,12 +252,13 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
|
||||||
|
|
||||||
// do the sort
|
// do the sort
|
||||||
table.sort(compareFunc);
|
table.sort(compareFunc);
|
||||||
if (!ascending)
|
if (!ascending) {
|
||||||
table.reverse();
|
table.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
// restore the selection
|
// restore the selection
|
||||||
let selectedRow = -1;
|
let selectedRow = -1;
|
||||||
if (selectedNumber>=0 && updateSelection) {
|
if (selectedNumber >= 0 && false) {
|
||||||
for (let s = 0; s < table.length; s++) {
|
for (let s = 0; s < table.length; s++) {
|
||||||
if (table[s].number == selectedNumber) {
|
if (table[s].number == selectedNumber) {
|
||||||
// update selection
|
// update selection
|
||||||
|
@ -272,10 +274,8 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
|
||||||
// display the results
|
// display the results
|
||||||
tree.treeBoxObject.invalidate();
|
tree.treeBoxObject.invalidate();
|
||||||
if (selectedRow >= 0) {
|
if (selectedRow >= 0) {
|
||||||
tree.treeBoxObject.ensureRowIsVisible(selectedRow)
|
tree.treeBoxObject.ensureRowIsVisible(selectedRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ascending;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadSignons() {
|
function LoadSignons() {
|
||||||
|
@ -502,24 +502,22 @@ function getColumnByName(column) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastSignonSortColumn = "hostname";
|
|
||||||
let lastSignonSortAscending = true;
|
|
||||||
|
|
||||||
function SignonColumnSort(column) {
|
function SignonColumnSort(column) {
|
||||||
// clear out the sortDirection attribute on the old column
|
let sortedCol = getColumnByName(column);
|
||||||
let lastSortedCol = getColumnByName(lastSignonSortColumn);
|
let lastSortedCol = getColumnByName(lastSignonSortColumn);
|
||||||
|
|
||||||
|
// clear out the sortDirection attribute on the old column
|
||||||
lastSortedCol.removeAttribute("sortDirection");
|
lastSortedCol.removeAttribute("sortDirection");
|
||||||
|
|
||||||
|
// determine if sort is to be ascending or descending
|
||||||
|
lastSignonSortAscending = (column == lastSignonSortColumn) ? !lastSignonSortAscending : true;
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
lastSignonSortAscending =
|
|
||||||
SortTree(signonsTree, signonsTreeView,
|
|
||||||
signonsTreeView._filterSet.length ? signonsTreeView._filterSet : signons,
|
|
||||||
column, lastSignonSortColumn, lastSignonSortAscending);
|
|
||||||
lastSignonSortColumn = column;
|
lastSignonSortColumn = column;
|
||||||
|
SortTree(signonsTree, lastSignonSortColumn, lastSignonSortAscending);
|
||||||
|
|
||||||
// set the sortDirection attribute to get the styling going
|
// set the sortDirection attribute to get the styling going
|
||||||
// first we need to get the right element
|
// first we need to get the right element
|
||||||
let sortedCol = getColumnByName(column);
|
|
||||||
sortedCol.setAttribute("sortDirection", lastSignonSortAscending ?
|
sortedCol.setAttribute("sortDirection", lastSignonSortAscending ?
|
||||||
"ascending" : "descending");
|
"ascending" : "descending");
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче