Bug 1039540 - In-content preferences: Disable the sorting of rows of sub-dialogs when right clicking; r=MattN

Review comments applied by MattN
This commit is contained in:
Deepak Koli 2015-03-26 18:02:49 -07:00
parent 6f584fe969
commit dabbd94919
7 changed files with 44 additions and 17 deletions

View File

@ -1,4 +1,3 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -232,6 +231,20 @@ var gPermissionManager = {
var urlLabel = document.getElementById("urlLabel");
urlLabel.hidden = !urlFieldVisible;
let treecols = document.getElementsByTagName("treecols")[0];
treecols.addEventListener("click", event => {
if (event.target.nodeName != "treecol" || event.button != 0) {
return;
}
let sortField = event.target.getAttribute("data-field-name");
if (!sortField) {
return;
}
gPermissionManager.onPermissionSort(sortField);
});
Services.obs.notifyObservers(null, NOTIFICATION_FLUSH_PERMISSIONS, this._type);
Services.obs.addObserver(this, "perm-changed", false);

View File

@ -53,10 +53,10 @@
onselect="gPermissionManager.onPermissionSelected();">
<treecols>
<treecol id="siteCol" label="&treehead.sitename.label;" flex="3"
onclick="gPermissionManager.onPermissionSort('rawHost');" persist="width"/>
data-field-name="rawHost" persist="width"/>
<splitter class="tree-splitter"/>
<treecol id="statusCol" label="&treehead.status.label;" flex="1"
onclick="gPermissionManager.onPermissionSort('capability');" persist="width"/>
data-field-name="capability" persist="width"/>
</treecols>
<treechildren/>
</tree>

View File

@ -1,5 +1,3 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -19,6 +17,10 @@ function SignonsStartup() {
document.getElementById("togglePasswords").label = kSignonBundle.getString("showPasswords");
document.getElementById("togglePasswords").accessKey = kSignonBundle.getString("showPasswordsAccessKey");
document.getElementById("signonsIntro").textContent = kSignonBundle.getString("loginsSpielAll");
let treecols = document.getElementsByTagName("treecols")[0];
treecols.addEventListener("click", HandleTreeColumnClick.bind(null, SignonColumnSort));
LoadSignons();
// filter the table if requested by caller

View File

@ -63,31 +63,31 @@
context="signonsTreeContextMenu">
<treecols>
<treecol id="siteCol" label="&treehead.site.label;" flex="40"
onclick="SignonColumnSort('hostname');" persist="width"
data-field-name="hostname" persist="width"
ignoreincolumnpicker="true"
sortDirection="ascending"/>
<splitter class="tree-splitter"/>
<treecol id="userCol" label="&treehead.username.label;" flex="25"
ignoreincolumnpicker="true"
onclick="SignonColumnSort('username');" persist="width"/>
data-field-name="username" persist="width"/>
<splitter class="tree-splitter"/>
<treecol id="passwordCol" label="&treehead.password.label;" flex="15"
ignoreincolumnpicker="true"
onclick="SignonColumnSort('password');" persist="width"
data-field-name="password" persist="width"
hidden="true"/>
<splitter class="tree-splitter"/>
<treecol id="timeCreatedCol" label="&treehead.timeCreated.label;" flex="10"
onclick="SignonColumnSort('timeCreated');" persist="width hidden"
data-field-name="timeCreated" persist="width hidden"
hidden="true"/>
<splitter class="tree-splitter"/>
<treecol id="timeLastUsedCol" label="&treehead.timeLastUsed.label;" flex="20"
onclick="SignonColumnSort('timeLastUsed');" persist="width hidden"/>
data-field-name="timeLastUsed" persist="width hidden"/>
<splitter class="tree-splitter"/>
<treecol id="timePasswordChangedCol" label="&treehead.timePasswordChanged.label;" flex="10"
onclick="SignonColumnSort('timePasswordChanged');" persist="width hidden"/>
data-field-name="timePasswordChanged" persist="width hidden"/>
<splitter class="tree-splitter"/>
<treecol id="timesUsedCol" label="&treehead.timesUsed.label;" flex="1"
onclick="SignonColumnSort('timesUsed');" persist="width hidden"
data-field-name="timesUsed" persist="width hidden"
hidden="true"/>
<splitter class="tree-splitter"/>
</treecols>

View File

@ -1,5 +1,3 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -160,6 +158,19 @@ function GetTreeSelections(tree) {
return selections;
}
function HandleTreeColumnClick(sortFunction, event) {
if (event.target.nodeName != "treecol" || event.button != 0) {
return;
}
let sortField = event.target.getAttribute("data-field-name");
if (!sortField) {
return;
}
sortFunction(sortField);
}
function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending, updateSelection) {
// remember which item was selected so we can restore it after the sort

View File

@ -1,5 +1,3 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -8,6 +6,9 @@
function RejectsStartup() {
LoadRejects();
let treecols = document.getElementsByTagName("treecols")[0];
treecols.addEventListener("click", HandleTreeColumnClick.bind(null, RejectColumnSort));
}
var rejectsTreeView = {

View File

@ -30,7 +30,7 @@
onselect="RejectSelected();">
<treecols>
<treecol id="rejectCol" label="&treehead.site.label;" flex="5"
onclick="RejectColumnSort('host');" sortDirection="ascending"/>
data-field-name="host" sortDirection="ascending"/>
</treecols>
<treechildren/>
</tree>