- selecting a folder in the tree selects the menulist selectedItem if it is already in the dropdown
- unselect it if the folder is not in it
- make sure that a row is always selected.
- ensure that the row of a folder selected in the menulist is visible when the tree is expanded.
- cleanup, consolidate logic
This commit is contained in:
chanial%noos.fr 2003-12-15 07:44:11 +00:00
Родитель 74114b62d1
Коммит bce365ab6b
2 изменённых файлов: 41 добавлений и 20 удалений

Просмотреть файл

@ -174,20 +174,31 @@ function getNormalizedURL(url)
function selectMenulistFolder(aEvent)
{
gSelectedFolder = RDF.GetResource(aEvent.target.id);
if (!gBookmarksTree.collapsed) {
gBookmarksTree.treeBoxObject.selection.selectEventsSuppressed = true;
gBookmarksTree.treeBoxObject.selection.clearSelection();
gBookmarksTree.selectResource(gSelectedFolder);
var index = gBookmarksTree.treeBuilder.getIndexOfResource(gSelectedFolder);
gBookmarksTree.treeBoxObject.ensureRowIsVisible(index);
gBookmarksTree.treeBoxObject.selection.selectEventsSuppressed = false;
}
if (!gBookmarksTree.collapsed)
selectFolder(gSelectedFolder);
}
function selectTreeFolder()
{
gSelectedFolder = gBookmarksTree._selection.item[0];
gMenulist.label = BookmarksUtils.getProperty(gSelectedFolder, NC_NS+"Name");
var resource = gBookmarksTree.currentResource;
if (resource == gSelectedFolder)
return;
gSelectedFolder = resource;
var menuitem = document.getElementById(gSelectedFolder.Value);
gMenulist.selectedItem = menuitem;
if (!menuitem)
gMenulist.label = BookmarksUtils.getProperty(gSelectedFolder, NC_NS+"Name");
}
function selectFolder(aFolder)
{
gBookmarksTree.treeBoxObject.selection.selectEventsSuppressed = true;
gBookmarksTree.treeBoxObject.selection.clearSelection();
gBookmarksTree.selectResource(aFolder);
var index = gBookmarksTree.currentIndex;
gBookmarksTree.treeBoxObject.ensureRowIsVisible(index);
gBookmarksTree.treeBoxObject.selection.selectEventsSuppressed = false;
# triggers a select event that will provoke a call to selectTreeFolder()
}
function expandTree()
@ -199,10 +210,11 @@ function expandTree()
document.documentElement.buttons = "accept,cancel";
else {
document.documentElement.buttons = "accept,cancel,extra2";
gBookmarksTree.focus();
# always open the bookmark root folder
if (!gBookmarksTree.treeBoxObject.view.isContainerOpen(0))
gBookmarksTree.treeBoxObject.view.toggleOpenState(0);
selectFolder(gSelectedFolder);
gBookmarksTree.focus();
}
gBookmarksTree.collapsed = willCollapse;
sizeToContent();
@ -221,10 +233,9 @@ function newFolder()
// we should use goDoCommand, but the current way of inserting
// resources do not insert in folders.
//goDoCommand("cmd_bm_newfolder");
gBookmarksTree.treeBoxObject.selection.selectEventsSuppressed = true;
gBookmarksTree.treeBoxObject.selection.clearSelection();
var target = BookmarksUtils.getTargetFromFolder(gSelectedFolder);
var folder = BookmarksCommand.createNewFolder(target);
gBookmarksTree.selectResource(folder);
gBookmarksTree.treeBoxObject.selection.selectEventsSuppressed = false;
if (!BMSVC.isBookmarkedResource(folder))
return; // new folder cancelled
selectFolder(folder);
}

Просмотреть файл

@ -261,7 +261,19 @@
return this._type;
]]></getter>
</property>
<property name="currentIndex">
<getter><![CDATA[
return this.treeBoxObject.selection.currentIndex;
]]></getter>
</property>
<property name="currentResource">
<getter><![CDATA[
return this.treeBuilder.getResourceAtIndex(this.currentIndex);
]]></getter>
</property>
<method name="getRowResource">
<parameter name="aRow"/>
<body><![CDATA[
@ -555,10 +567,8 @@
<method name="searchBookmarks">
<parameter name="aInput"/>
<body><![CDATA[
this.treeBoxObject.selection.currentIndex=-1;
if (!aInput) {
if (!aInput)
this.tree.setAttribute("ref", this.originalRef);
}
else {
if (!this.originalRef) {
this.originalRef = this.tree.getAttribute("ref");
@ -612,7 +622,7 @@
this.mOuter.treeBoxObject.selection.selectAll();
break;
case "cmd_bm_expandfolder":
this.mOuter.treeBoxObject.view.toggleOpenState(this.mOuter.treeBoxObject.selection.currentIndex);
this.mOuter.treeBoxObject.view.toggleOpenState(this.mOuter.currentIndex);
break;
default:
this.mOuter.saveSelection();