зеркало из https://github.com/mozilla/pjs.git
Fix profile list display issues by using a tree instead b=120410 r=varga sr=jag
This commit is contained in:
Родитель
f3ec0b75bb
Коммит
97b2b7af12
|
@ -56,13 +56,10 @@ function CreateProfileWizard()
|
|||
// update the display to show the additional profile
|
||||
function CreateProfile( aProfName, aProfDir )
|
||||
{
|
||||
var profile = new Profile( aProfName, aProfDir, "yes" );
|
||||
var item = AddItem( "profiles", profile );
|
||||
AddItem(aProfName, "yes");
|
||||
var profileList = document.getElementById( "profiles" );
|
||||
if( item ) {
|
||||
profileList.selectItem( item );
|
||||
profileList.ensureElementIsVisible( item );
|
||||
}
|
||||
profileList.view.selection.select(profileList.view.rowCount - 1);
|
||||
profileList.treeBoxObject.ensureRowIsVisible(profileList.currentIndex);
|
||||
}
|
||||
|
||||
// rename the selected profile
|
||||
|
@ -73,7 +70,7 @@ function RenameProfile()
|
|||
if (renameButton.getAttribute("disabled") == "true" )
|
||||
return false;
|
||||
var profileList = document.getElementById( "profiles" );
|
||||
var selected = profileList.selectedItems[0];
|
||||
var selected = profileList.view.getItemAtIndex(profileList.currentIndex);
|
||||
var profilename = selected.getAttribute("profile_name");
|
||||
if( selected.getAttribute("rowMigrate") == "no" ) {
|
||||
// migrate if the user wants to
|
||||
|
@ -100,7 +97,7 @@ function RenameProfile()
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
oldName = selected.getAttribute("rowName");
|
||||
oldName = selected.getAttribute("profile_name");
|
||||
newName = {value:oldName};
|
||||
var dialogTitle = gProfileManagerBundle.getString("renameprofiletitle");
|
||||
var msg = gProfileManagerBundle.getString("renameProfilePrompt");
|
||||
|
@ -124,8 +121,7 @@ function RenameProfile()
|
|||
var migrate = selected.getAttribute("rowMigrate");
|
||||
try {
|
||||
profile.renameProfile(oldName, newName);
|
||||
selected.setAttribute( "label", newName );
|
||||
selected.setAttribute( "rowName", newName );
|
||||
selected.firstChild.firstChild.setAttribute( "label", newName );
|
||||
selected.setAttribute( "profile_name", newName );
|
||||
}
|
||||
catch(e) {
|
||||
|
@ -151,8 +147,8 @@ function ConfirmDelete()
|
|||
return;
|
||||
var profileList = document.getElementById( "profiles" );
|
||||
|
||||
var selected = profileList.selectedItems[0];
|
||||
var name = selected.getAttribute("rowName");
|
||||
var selected = profileList.view.getItemAtIndex(profileList.currentIndex);
|
||||
var name = selected.getAttribute("profile_name");
|
||||
|
||||
var dialogTitle = gProfileManagerBundle.getString("deletetitle");
|
||||
var dialogText;
|
||||
|
@ -199,18 +195,18 @@ function ConfirmDelete()
|
|||
function DeleteProfile(deleteFiles)
|
||||
{
|
||||
var profileList = document.getElementById("profiles");
|
||||
if (profileList.selectedItems && profileList.selectedItems.length) {
|
||||
var selected = profileList.selectedItems[0];
|
||||
var name = selected.getAttribute("rowName");
|
||||
var previous = profileList.getPreviousItem(selected, 1);
|
||||
if (profileList.view.selection.count) {
|
||||
var selected = profileList.view.getItemAtIndex(profileList.currentIndex);
|
||||
var name = selected.getAttribute("profile_name");
|
||||
var previous = profileList.currentIndex - 1;
|
||||
|
||||
try {
|
||||
profile.deleteProfile(name, deleteFiles);
|
||||
profileList.removeChild(selected);
|
||||
profileList.lastChild.removeChild(selected);
|
||||
|
||||
if (previous) {
|
||||
profileList.selectItem(previous);
|
||||
profileList.ensureElementIsVisible(previous);
|
||||
profileList.view.selection.select(previous);
|
||||
profileList.treeBoxObject.ensureRowIsVisible(previous);
|
||||
}
|
||||
|
||||
// set the button state
|
||||
|
@ -282,7 +278,7 @@ function ChangeCaption( aCaption )
|
|||
window.title = aCaption;
|
||||
}
|
||||
|
||||
// do button enabling based on listbox selection
|
||||
// do button enabling based on tree selection
|
||||
function DoEnabling()
|
||||
{
|
||||
var renbutton = document.getElementById( "renbutton" );
|
||||
|
@ -290,8 +286,7 @@ function DoEnabling()
|
|||
var start = document.getElementById( "ok" );
|
||||
|
||||
var profileList = document.getElementById( "profiles" );
|
||||
var items = profileList.selectedItems;
|
||||
if( items.length != 1 )
|
||||
if (profileList.view.selection.count == 0)
|
||||
{
|
||||
renbutton.setAttribute( "disabled", "true" );
|
||||
delbutton.setAttribute( "disabled", "true" );
|
||||
|
@ -305,7 +300,7 @@ function DoEnabling()
|
|||
|
||||
var canDelete = true;
|
||||
if (!gStartupMode) {
|
||||
var selected = profileList.selectedItems[0];
|
||||
var selected = profileList.view.getItemAtIndex(profileList.currentIndex);
|
||||
var profileName = selected.getAttribute("profile_name");
|
||||
var currentProfile = profile.currentProfile;
|
||||
if (currentProfile && (profileName == currentProfile))
|
||||
|
@ -321,7 +316,7 @@ function DoEnabling()
|
|||
}
|
||||
}
|
||||
|
||||
// handle key event on listboxes
|
||||
// handle key event on tree
|
||||
function HandleKeyEvent( aEvent )
|
||||
{
|
||||
switch( aEvent.keyCode )
|
||||
|
@ -341,7 +336,7 @@ function HandleKeyEvent( aEvent )
|
|||
|
||||
function HandleClickEvent( aEvent )
|
||||
{
|
||||
if( aEvent.detail == 2 && aEvent.button == 0 && aEvent.target.localName == "listitem") {
|
||||
if (aEvent.button == 0 && event.target.parentNode.view.selection.count) {
|
||||
if (!onStart())
|
||||
return false;
|
||||
window.close();
|
||||
|
|
|
@ -128,11 +128,12 @@ function highlightCurrentProfile()
|
|||
var currentProfile = profile.currentProfile;
|
||||
if( !currentProfile )
|
||||
return;
|
||||
var currentProfileItem = document.getElementById( ( "profileName_" + currentProfile ) );
|
||||
var profileList = document.getElementById( "profiles" );
|
||||
var currentProfileItem = profileList.getElementsByAttribute("profile_name", currentProfile).item(0);
|
||||
if( currentProfileItem ) {
|
||||
profileList.selectItem( currentProfileItem );
|
||||
profileList.ensureElementIsVisible( currentProfileItem );
|
||||
var currentProfileIndex = profileList.view.getIndexOfItem(currentProfileItem);
|
||||
profileList.view.selection.select( currentProfileIndex );
|
||||
profileList.treeBoxObject.ensureRowIsVisible( currentProfileIndex );
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
|
@ -141,32 +142,24 @@ function highlightCurrentProfile()
|
|||
}
|
||||
|
||||
// function : <profileSelection.js>::AddItem();
|
||||
// purpose : utility function for adding items to a listbox.
|
||||
function AddItem( aChildren, aProfileObject )
|
||||
// purpose : utility function for adding items to a tree.
|
||||
function AddItem(aName, aMigrated)
|
||||
{
|
||||
var kids = document.getElementById(aChildren);
|
||||
var listitem = document.createElement("listitem");
|
||||
listitem.setAttribute("label", aProfileObject.mName );
|
||||
listitem.setAttribute("rowMigrate", aProfileObject.mMigrated );
|
||||
listitem.setAttribute("class", "listitem-iconic");
|
||||
listitem.setAttribute("profile_name", aProfileObject.mName );
|
||||
listitem.setAttribute("rowName", aProfileObject.mName );
|
||||
listitem.setAttribute("id", ( "profileName_" + aProfileObject.mName ) );
|
||||
// 23/10/99 - no roaming access yet!
|
||||
// var roaming = document.getElementById("roamingitem");
|
||||
// kids.insertBefore(item,roaming);
|
||||
kids.appendChild(listitem);
|
||||
return listitem;
|
||||
}
|
||||
|
||||
function Profile ( aName, aMigrated )
|
||||
{
|
||||
this.mName = aName ? aName : null;
|
||||
this.mMigrated = aMigrated ? aMigrated : null;
|
||||
var tree = document.getElementById("profiles");
|
||||
var treeitem = document.createElement("treeitem");
|
||||
var treerow = document.createElement("treerow");
|
||||
var treecell = document.createElement("treecell");
|
||||
treecell.setAttribute("label", aName);
|
||||
treecell.setAttribute("properties", "rowMigrate-" + aMigrated);
|
||||
treeitem.setAttribute("profile_name", aName);
|
||||
treeitem.setAttribute("rowMigrate", aMigrated);
|
||||
treerow.appendChild(treecell);
|
||||
treeitem.appendChild(treerow);
|
||||
tree.lastChild.appendChild(treeitem);
|
||||
}
|
||||
|
||||
// function : <profileSelection.js>::loadElements();
|
||||
// purpose : load profiles into listbox
|
||||
// purpose : load profiles into tree
|
||||
function loadElements()
|
||||
{
|
||||
try {
|
||||
|
@ -187,7 +180,7 @@ function loadElements()
|
|||
|
||||
var migrated = Registry.getString( node.key, "migrated" );
|
||||
|
||||
AddItem( "profiles", new Profile( node.name, migrated ) );
|
||||
AddItem(node.name, migrated);
|
||||
|
||||
regEnum.next();
|
||||
}
|
||||
|
@ -201,7 +194,7 @@ function loadElements()
|
|||
function onStart()
|
||||
{
|
||||
var profileList = document.getElementById("profiles");
|
||||
var selected = profileList.selectedItems[0];
|
||||
var selected = profileList.view.getItemAtIndex(profileList.currentIndex);
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
|
|
|
@ -98,14 +98,15 @@
|
|||
<separator class="thin" orient="vertical"/>
|
||||
|
||||
<vbox flex="1">
|
||||
<listbox id="profiles" flex="1" style="height: 0px;" seltype="single"
|
||||
onclick="HandleClickEvent( event );"
|
||||
<tree id="profiles" flex="1" style="height: 0px;" seltype="single"
|
||||
hidecolumnpicker="true"
|
||||
onselect="DoEnabling();"
|
||||
onkeypress="HandleKeyEvent( event );">
|
||||
<listhead>
|
||||
<listheader label="&availprofiles.label;"/>
|
||||
</listhead>
|
||||
</listbox>
|
||||
<treecols>
|
||||
<treecol label="&availprofiles.label;" flex="1"/>
|
||||
</treecols>
|
||||
<treechildren ondblclick="HandleClickEvent(event);"/>
|
||||
</tree>
|
||||
<vbox>
|
||||
<checkbox id="offlineState" label="&offlineState.label;" accesskey="&offlineState.accesskey;"/>
|
||||
<checkbox id="autoSelectLastProfile" label="&autoSelectLastProfile.label;" accesskey="&autoSelectLastProfile.accesskey;"/>
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@netscape.com>
|
||||
* Chris Nelson <chrisn@statecollege.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
@import url("chrome://global/skin/global.css");
|
||||
|
||||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
|
||||
window.dialog {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#profiles > listitem {
|
||||
list-style-image: url("chrome://communicator/skin/profile/profileicon-large.gif");
|
||||
}
|
||||
|
||||
#profiles > listitem[rowMigrate="no"] {
|
||||
list-style-image: url("chrome://communicator/skin/profile/migrate.gif");
|
||||
}
|
||||
|
||||
/* profile selection dialog */
|
||||
html#intro {
|
||||
width: 17em;
|
||||
}
|
||||
|
||||
box#managebuttons > button {
|
||||
min-width: 8em;
|
||||
}
|
||||
|
||||
/* display area */
|
||||
box#contentarea {
|
||||
border-top: 2px groove #CCCCCC;
|
||||
border-bottom: 2px groove #CCCCCC;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
/* top border on status area */
|
||||
box#wizardButtons {
|
||||
padding-top: 1px;
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
box.selection {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
description.error {
|
||||
color: #FF0000;
|
||||
}
|
|
@ -47,11 +47,12 @@
|
|||
|
||||
/* ::::: Profile Selection dialog ::::: */
|
||||
|
||||
#profiles > listitem {
|
||||
treechildren::-moz-tree-image {
|
||||
margin-right: 2px;
|
||||
list-style-image: url("chrome://communicator/skin/profile/profile.gif");
|
||||
}
|
||||
|
||||
#profiles > listitem[rowMigrate="no"] {
|
||||
treechildren::-moz-tree-image(rowMigrate-no) {
|
||||
list-style-image: url("chrome://communicator/skin/profile/migrate.gif");
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче