зеркало из https://github.com/mozilla/gecko-dev.git
really fix bug 220067, and add license from nsWalletTreeUtils.js (the source of this code)
This commit is contained in:
Родитель
55adbb6571
Коммит
3515d16faa
|
@ -1,3 +1,25 @@
|
|||
# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
function DeleteAllFromTree
|
||||
(tree, view, table, deletedTable, removeButton, removeAllButton) {
|
||||
|
||||
|
@ -103,19 +125,11 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
|
|||
var compareFunc;
|
||||
if (ascending) {
|
||||
compareFunc = function compare(first, second) {
|
||||
if (first[column] < second[column])
|
||||
return -1;
|
||||
if (first[column] > second[column])
|
||||
return 1;
|
||||
return 0;
|
||||
return CompareLowerCase(first[column], second[column]);
|
||||
}
|
||||
} else {
|
||||
compareFunc = function compare(first, second) {
|
||||
if (first[column] < second[column])
|
||||
return 1;
|
||||
if (first[column] > second[column])
|
||||
return -1;
|
||||
return 0;
|
||||
return CompareLowerCase(second[column], first[column]);
|
||||
}
|
||||
}
|
||||
table.sort(compareFunc);
|
||||
|
@ -143,3 +157,22 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
|
|||
|
||||
return ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive string comparator.
|
||||
*/
|
||||
function CompareLowerCase(first, second) {
|
||||
|
||||
var firstLower = first.toLowerCase();
|
||||
var secondLower = second.toLowerCase();
|
||||
|
||||
if (firstLower < secondLower) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (firstLower > secondLower) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче