Bookmark Panel landing + its own Quick Search

Workaround for the hang using QS (bug 167167)
Conflicting accesskey for QS (bug 171545)
Focus the content after loading bm from the panel (bug 171584)
key enter not working in the manager/panel (bug 171610)
and other bugs/tweaks not reported
This commit is contained in:
chanial%noos.fr 2002-09-30 01:06:30 +00:00
Родитель 8b7e89cc3e
Коммит bb3ed3ed6b
7 изменённых файлов: 86 добавлений и 76 удалений

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

@ -475,6 +475,7 @@ var BookmarksCommand = {
// requires utilityOverlay.js if opening in new window for getTopWin() // requires utilityOverlay.js if opening in new window for getTopWin()
openOneBookmark: function (aURI, aTargetBrowser, aDS) openOneBookmark: function (aURI, aTargetBrowser, aDS)
{ {
var w, browser
var url = BookmarksUtils.getProperty(aURI, NC_NS+"URL", aDS) var url = BookmarksUtils.getProperty(aURI, NC_NS+"URL", aDS)
// Ignore "NC:" and empty urls. // Ignore "NC:" and empty urls.
if (url == "" || url.substring(0,3) == "NC:") if (url == "" || url.substring(0,3) == "NC:")
@ -484,19 +485,23 @@ var BookmarksCommand = {
openTopWin(url); openTopWin(url);
break; break;
case "tab": case "tab":
var w = getTopWin(); w = getTopWin();
if (!w) { if (!w) {
openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url); openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url);
break; break;
} }
w.focus(); browser = w.document.getElementById("content");
var browser = w.document.getElementById("content"); var tab = browser.addTab(url);
var tab = browser.addTab(url);
browser.selectedTab = tab; browser.selectedTab = tab;
browser.focus();
break; break;
case "window": case "window":
openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url); openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url);
break; break;
case "properties":
openDialog("chrome://browser/content/bookmarks/bookmarksProperties.xul",
"", "centerscreen,chrome,resizable=no", url);
} }
}, },
@ -536,8 +541,7 @@ var BookmarksCommand = {
showProperties: function (aSelection) showProperties: function (aSelection)
{ {
openDialog("chrome://browser/content/bookmarks/bookmarksProperties.xul", this.openBookmark(aSelection, "properties");
"", "centerscreen,chrome,resizable=no", aSelection.item[0].Value);
}, },
findBookmark: function () findBookmark: function ()
@ -1537,7 +1541,7 @@ var BookmarksUtils = {
getBrowserTargetFromEvent: function (aEvent) getBrowserTargetFromEvent: function (aEvent)
{ {
// note: modifier keys are ignored in menuitems (bug 126189) // note: modifier keys are ignored in menuitems (bug 126189)
var button = aEvent.type == "command"? 0:aEvent.button; var button = aEvent.type == "command" || aEvent.type == "keypress"? 0:aEvent.button;
if (button == 2) if (button == 2)
return ""; return "";
if (aEvent.metaKey || aEvent.ctrlKey || button == 1) if (aEvent.metaKey || aEvent.ctrlKey || button == 1)
@ -1545,6 +1549,8 @@ var BookmarksUtils = {
return "window"; return "window";
else else
return "tab"; return "tab";
else if (aEvent.altKey)
return "properties"
else else
return "current"; return "current";
}, },

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

@ -23,6 +23,7 @@
*/ */
var gSearchBox; var gSearchBox;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Initialize the command controllers, set focus, tree root, // Initialize the command controllers, set focus, tree root,
// window title state, etc. // window title state, etc.
@ -217,14 +218,3 @@ function onViewMenuColumnItemSelected(aEvent)
aEvent.preventBubble(); aEvent.preventBubble();
} }
function searchBookmarks(aInput)
{
var bookmarksView = document.getElementById("bookmarks-view");
if (!aInput)
bookmarksView.tree.setAttribute("ref", "NC:BookmarksRoot");
else
bookmarksView.tree.setAttribute("ref",
"find:datasource=rdf:bookmarks&match=http://home.netscape.com/NC-rdf#Name&method=contains&text=" + escape(aInput));
}

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

@ -57,7 +57,6 @@
<!-- Shared Libraries --> <!-- Shared Libraries -->
<script type="application/x-javascript" src="chrome://global/content/strres.js"></script> <script type="application/x-javascript" src="chrome://global/content/strres.js"></script>
<!-- XXX - This should SO become an XBL widget --> <!-- XXX - This should SO become an XBL widget -->
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"></script> <script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"></script>
@ -66,12 +65,10 @@
<!-- Bookmarks Window --> <!-- Bookmarks Window -->
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarksManager.js"/> <script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarksManager.js"/>
<!-- Bookmarks Window Drag & Drop --> <!-- Bookmarks Window Drag and Drop -->
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/> <script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/> <script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<popupset id="bookmarksPopupset"/>
<commands id="commands"> <commands id="commands">
<commandset id="CommandUpdate_Bookmarks" <commandset id="CommandUpdate_Bookmarks"
commandupdater="true" commandupdater="true"
@ -270,7 +267,7 @@
<label value="&find.label;" accesskey="&find.accesskey;" control="search-box"/> <label value="&find.label;" accesskey="&find.accesskey;" control="search-box"/>
<textbox id="search-box" flex="1" <textbox id="search-box" flex="1"
type="timed" timeout="500" type="timed" timeout="500"
callback="searchBookmarks(gSearchBox.value);"/> callback="document.getElementById('bookmarks-view').searchBookmarks(gSearchBox.value);"/>
</toolbar> </toolbar>
</toolbox> </toolbox>

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

@ -36,6 +36,7 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
var gSearchBox;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Get the two bookmarks utility libraries running, attach controllers, focus // Get the two bookmarks utility libraries running, attach controllers, focus
@ -44,10 +45,11 @@ function Startup()
{ {
var bookmarksView = document.getElementById("bookmarks-view"); var bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.treeBoxObject.selection.select(0); bookmarksView.treeBoxObject.selection.select(0);
gSearchBox = document.getElementById("search-box");
} }
function manageBookmarks() { function manageBookmarks() {
openDialog("chrome://communicator/content/bookmarks/bookmarksManager.xul", "", "chrome,dialog=no,resizable=yes"); openDialog("chrome://browser/content/bookmarks/bookmarksManager.xul", "", "chrome,dialog=no,resizable=yes");
} }
function addBookmark() { function addBookmark() {

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

@ -23,65 +23,67 @@
--> -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?> <?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/sidebar/sidebarListView.css" type="text/css"?> <?xml-stylesheet href="chrome://communicator/skin/sidebar/sidebarListView.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/bookmarks/bookmarksWindow.css" type="text/css"?> <?xml-stylesheet href="chrome://browser/content/bookmarks/bookmarks.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/content/bookmarks/bookmarks.css" type="text/css"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?> <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?> <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/bookmarks/bookmarksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/bookmarks/bookmarks.dtd"> <!DOCTYPE window SYSTEM "chrome://browser/locale/bookmarks/bookmarks.dtd">
<page id="bookmarksPanel" <page id="bookmarksPanel"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Startup();" elementtofocus="bookmarks-view"> onload="Startup();" elementtofocus="bookmarks-view">
<!-- XXX - would like to cut this dependency out --> <!-- Shared libraries XXX - would like to cut this dependency out -->
<script type="application/x-javascript" src="chrome://global/content/strres.js"/> <script type="application/x-javascript" src="chrome://global/content/strres.js"/>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<!-- Bookmarks Shell --> <!-- Shared Bookmarks Utility Library -->
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/> <script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksPanel.js"/> <!-- Bookmarks Panel -->
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarksPanel.js"/>
<!-- Drag and Drop --> <!-- Bookmarks Panel Drag and Drop -->
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/> <script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/> <script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksDD.js"/>
<!-- context menu, tooltips, etc -->
<popupset id="bookmarksPopupset"/>
<!-- bookmarks string bundle -->
<stringbundleset id="stringbundleset"/>
<!-- bookmarks & edit commands --> <!-- bookmarks & edit commands -->
<commands id="commands"> <commands id="commands">
<commandset id="CommandUpdate_Bookmarks" <commandset id="CommandUpdate_Bookmarks"
commandupdater="true" commandupdater="true"
events="click,focus" events="click,focus"
oncommandupdate="document.getElementById('bookmarks-view').onCommandUpdate();"> oncommandupdate="document.getElementById('bookmarks-view').onCommandUpdate();">
</commandset> </commandset>
<commandset id="bookmarksItems"/> <commandset id="bookmarksItems">
<command id="cmd_bm_open" oncommand="goDoCommand('cmd_bm_open');"/>
<command id="cmd_bm_openinnewwindow" oncommand="goDoCommand('cmd_bm_openinnewwindow');"/>
<command id="cmd_bm_openinnewtab" oncommand="goDoCommand('cmd_bm_openinnewtab');"/>
<command id="cmd_bm_expandfolder" oncommand="goDoCommand('cmd_bm_expandfolder');"/>
<command id="cmd_bm_managefolder" oncommand="goDoCommand('cmd_bm_managefolder');"/>
<command id="cmd_bm_newfolder" oncommand="goDoCommand('cmd_bm_newfolder');"/>
<command id="cmd_bm_newbookmark" oncommand="goDoCommand('cmd_bm_newbookmark');"/>
<command id="cmd_bm_newseparator" oncommand="goDoCommand('cmd_bm_newseparator');"/>
<command id="cmd_bm_find" oncommand="goDoCommand('cmd_bm_find');"/>
<command id="cmd_bm_properties" oncommand="goDoCommand('cmd_bm_properties');"/>
<command id="cmd_bm_cut" oncommand="goDoCommand('cmd_bm_cut');"/>
<command id="cmd_bm_copy" oncommand="goDoCommand('cmd_bm_copy');"/>
<command id="cmd_bm_paste" oncommand="goDoCommand('cmd_bm_paste');"/>
<command id="cmd_bm_delete" oncommand="goDoCommand('cmd_bm_delete');"/>
<command id="cmd_bm_selectAll" oncommand="goDoCommand('cmd_bm_selectAll');"/>
</commandset>
</commands> </commands>
<hbox id="panel-bar" class="toolbar"> <hbox id="panel-bar" align="center" pack="center" class="toolbar">
<toolbarbutton id="btnAddBookmark" label="&command.addBookmark.label;" <toolbarbutton id="btnAddBookmark" label="&command.addBookmark.label;"
oncommand="addBookmark();"/> oncommand="addBookmark();"/>
<toolbarbutton id="btnManageBookmarks" label="&command.manageBookmarks.label;" <label value="&find.label;" accesskey="&find.accesskey;" control="search-box"/>
oncommand="manageBookmarks();"/> <textbox id="search-box" flex="1"
<spacer flex="1"/> type="timed" timeout="500"
<toolbarseparator/> callback="document.getElementById('bookmarks-view').searchBookmarks(gSearchBox.value);"/>
<toolbarbutton id="btnFindBookmarks" label="&command.findBookmarks.label;"
oncommand="document.getElementById('bookmarks-view').openFindDialog();"/>
</hbox> </hbox>
<bookmarks-tree id="bookmarks-view" class="sidebar" type="single-column" flex="1"/> <bookmarks-tree id="bookmarks-view" class="sidebar" type="single-column" flex="1"/>
</page> </page>

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

@ -427,6 +427,7 @@ dump("error in refresh sort:"+e)
return; return;
if (aClickCount == 1 && this.clickCount == 2 && aEvent.button != 1) if (aClickCount == 1 && this.clickCount == 2 && aEvent.button != 1)
return; return;
var row = {}; var row = {};
var col = {}; var col = {};
var obj = {}; var obj = {};
@ -435,11 +436,9 @@ dump("error in refresh sort:"+e)
if (row == -1 || obj.value == "twisty") if (row == -1 || obj.value == "twisty")
return; return;
var browserTarget = BookmarksUtils.getBrowserTargetFromEvent(aEvent); var browserTarget = BookmarksUtils.getBrowserTargetFromEvent(aEvent);
if (browserTarget != "current" && this.clickCount == aClickCount) { if (this.clickCount == 1 || browserTarget != "current" &&
if (!this.treeBoxObject.selection.isSelected(row)) { this.clickCount == aClickCount && !this.treeBoxObject.selection.isSelected(row))
this.treeBoxObject.selection.select(row) this.treeBoxObject.selection.select(row)
}
}
var selection = this.getTreeSelection(); var selection = this.getTreeSelection();
this._selection = selection; this._selection = selection;
@ -447,24 +446,37 @@ dump("error in refresh sort:"+e)
if (!isFolderGroup && selection.isContainer[0]) { if (!isFolderGroup && selection.isContainer[0]) {
if (this.clickCount == 1) { if (this.clickCount == 1) {
if (row.value >= 0) { if (row >= 0) {
this.treeBoxObject.view.toggleOpenState(row.value); this.treeBoxObject.view.toggleOpenState(row);
} }
} }
if (selection.protocol[0] == "file") if (selection.protocol[0] != "file")
BookmarksCommand.openBookmark(selection, browserTarget, this.db); return;
return; }
}
if (aEvent.altKey) {
BookmarksCommand.showProperties(selection);
return
}
BookmarksCommand.openBookmark(selection, browserTarget, this.db); BookmarksCommand.openBookmark(selection, browserTarget, this.db);
]]></body> ]]></body>
</method> </method>
<method name="loadBookmarkBrowser">
<parameter name="aEvent"/>
<body><![CDATA[
var browserTarget = BookmarksUtils.getBrowserTargetFromEvent(aEvent);
BookmarksCommand.openBookmark(this._selection, browserTarget, this.db)
]]></body>
</method>
<method name="searchBookmarks">
<parameter name="aInput"/>
<body><![CDATA[
this.treeBoxObject.selection.currentIndex=-1;
if (!aInput)
this.tree.setAttribute("ref", "NC:BookmarksRoot");
else
this.tree.setAttribute("ref",
"find:datasource=rdf:bookmarks&match=http://home.netscape.com/NC-rdf#Name&method=contains&text=" + escape(aInput));
]]></body>
</method>
<!-- observer --> <!-- observer -->
<field name="DNDObserver" readonly="true"><![CDATA[( <field name="DNDObserver" readonly="true"><![CDATA[(
{ {
@ -583,6 +595,7 @@ dump("error in refresh sort:"+e)
else else
BookmarksUtils.moveSelection ("drag", selection, target); BookmarksUtils.moveSelection ("drag", selection, target);
observer.endUpdateBatch(this.db); observer.endUpdateBatch(this.db);
this.mOuter.treeBoxObject.selection.currentIndex=-1;
this.mOuter.treeBuilder.rebuild(); this.mOuter.treeBuilder.rebuild();
// temporary hack: for an unknown reason, rebuilding cause a scroll to the bottom // temporary hack: for an unknown reason, rebuilding cause a scroll to the bottom
// if the first visible row is not 0 // if the first visible row is not 0
@ -711,7 +724,7 @@ dump("ONSELECTION CHANGED\n")
<vbox flex="1"> <vbox flex="1">
<tree anonid="bookmarks-tree" flex="1" class="plain" enableColumnDrag="true" <tree anonid="bookmarks-tree" flex="1" class="plain" enableColumnDrag="true"
datasources="rdf:bookmarks rdf:internetsearch rdf:files rdf:localsearch" ref="NC:BookmarksRoot" flags="dont-build-content" datasources="rdf:bookmarks rdf:internetsearch rdf:files rdf:localsearch" ref="NC:BookmarksRoot" flags="dont-build-content"
onkeypress="if (event.keyCode == 13) this.parentNode.parentNode.openItem(event);" onkeypress="if (event.keyCode == 13) this.parentNode.parentNode.loadBookmarkBrowser(event);"
onclick="this.parentNode.parentNode.openItem(event, 1);" onclick="this.parentNode.parentNode.openItem(event, 1);"
ondblclick="this.parentNode.parentNode.openItem(event, 2);" ondblclick="this.parentNode.parentNode.openItem(event, 2);"
ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, this.parentNode.parentNode.DNDObserver);" ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, this.parentNode.parentNode.DNDObserver);"
@ -819,9 +832,9 @@ dump("ONSELECTION CHANGED\n")
onpopuphidden ="if (content) content.focus()"/> onpopuphidden ="if (content) content.focus()"/>
<tree anonid="bookmarks-tree" flex="1" hidecolumnpicker="true" class="plain" <tree anonid="bookmarks-tree" flex="1" hidecolumnpicker="true" class="plain"
datasources="rdf:bookmarks rdf:internetsearch rdf:files rdf:localsearch" ref="NC:BookmarksRoot" flags="dont-build-content" datasources="rdf:bookmarks rdf:internetsearch rdf:files rdf:localsearch" ref="NC:BookmarksRoot" flags="dont-build-content"
onkeypress="if (event.keyCode == 13) this.parentNode.openItem(event); event.preventBubble();" onkeypress="if (event.keyCode == 13) this.parentNode.loadBookmarkBrowser(event); if (content) content.focus()"
ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, this.parentNode.DNDObserver);" ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, this.parentNode.DNDObserver);"
onclick="this.parentNode.openItem(event);" onclick="this.parentNode.openItem(event, 1); if (content) content.focus()"
onselect="this.parentNode.treeBoxObject.view.selectionChanged();"> onselect="this.parentNode.treeBoxObject.view.selectionChanged();">
<template xmlns:nc="http://home.netscape.com/NC-rdf#"> <template xmlns:nc="http://home.netscape.com/NC-rdf#">
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator"> <rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">

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

@ -84,7 +84,7 @@
<!ENTITY bookmarksWindowTitle.label "Bookmark Manager"> <!ENTITY bookmarksWindowTitle.label "Bookmark Manager">
<!ENTITY find.label "Find"> <!ENTITY find.label "Find">
<!ENTITY find.accesskey "F"> <!ENTITY find.accesskey "n">
<!ENTITY fileMenu.label "File"> <!ENTITY fileMenu.label "File">
<!ENTITY fileMenu.accesskey "F"> <!ENTITY fileMenu.accesskey "F">