mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Fix for 76502 and related bugs. some parts sr=alecf, tested by several people (andred, fabian)
This commit is contained in:
parent
6e911222c9
commit
b58a221f2f
@ -204,14 +204,6 @@ Contributor(s): ______________________________________. -->
|
||||
grippytooltip="aTooltip" grippytooltiptext="&personalBar.tooltip;"
|
||||
tbautostretch="always">
|
||||
|
||||
<button class="button-toolbar bookmark-item" id="home-button" label="&homeButton.label;"
|
||||
tooltip="aTooltip" persist="hidden"
|
||||
ondraggesture="nsDragAndDrop.startDrag(event, homeButtonObserver);"
|
||||
ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);"
|
||||
ondragdrop="nsDragAndDrop.drop(event, homeButtonObserver);"
|
||||
ondragexit="nsDragAndDrop.dragExit(event, homeButtonObserver);"
|
||||
oncommand="BrowserHome(); event.preventBubble();"/>
|
||||
|
||||
<!-- "Bookmarks" button on personal toolbar -->
|
||||
<menubutton class="button-toolbar bookmark-item" id="bookmarks-button"
|
||||
persist="hidden" label="&bookmarksButton.label;" hidden="false"
|
||||
@ -228,6 +220,14 @@ Contributor(s): ______________________________________. -->
|
||||
</menupopup>
|
||||
</menubutton>
|
||||
|
||||
<button class="button-toolbar bookmark-item" id="home-button" label="&homeButton.label;"
|
||||
tooltip="aTooltip" persist="hidden"
|
||||
ondraggesture="nsDragAndDrop.startDrag(event, homeButtonObserver);"
|
||||
ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);"
|
||||
ondragdrop="nsDragAndDrop.drop(event, homeButtonObserver);"
|
||||
ondragexit="nsDragAndDrop.dragExit(event, homeButtonObserver);"
|
||||
oncommand="BrowserHome(); event.preventBubble();"/>
|
||||
|
||||
<toolbarseparator/>
|
||||
|
||||
<!-- Personal toolbar items -->
|
||||
|
@ -61,8 +61,9 @@ BookmarksToolbar.prototype = {
|
||||
const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
var xulElement = document.createElementNS(kXULNS, "menuitem");
|
||||
xulElement.setAttribute("cmd", aCommandName);
|
||||
xulElement.setAttribute("command", "cmd_" + aCommandName.substring(NC_NS_CMD.length));
|
||||
|
||||
var cmd = "cmd_" + aCommandName.substring(NC_NS_CMD.length)
|
||||
xulElement.setAttribute("command", cmd);
|
||||
|
||||
switch (aCommandName) {
|
||||
case NC_NS_CMD + "open":
|
||||
xulElement.setAttribute("label", aDisplayName);
|
||||
@ -153,10 +154,11 @@ BookmarksToolbar.prototype = {
|
||||
if (!gBookmarksShell.commands.validateNameAndTopic(name, aTopic, relativeNode, dummyButton))
|
||||
return;
|
||||
|
||||
var parentNode = relativeNode.parentNode;
|
||||
parentNode = relativeNode.parentNode;
|
||||
if (relativeNode.localName == "hbox") {
|
||||
parentNode = relativeNode;
|
||||
relativeNode = relativeNode.lastChild;
|
||||
relativeNode = (gBookmarksShell.commands.nodeIsValidType(relativeNode) &&
|
||||
relativeNode.lastChild) || relativeNode;
|
||||
}
|
||||
|
||||
var args = [{ property: NC_NS + "parent",
|
||||
@ -168,7 +170,19 @@ BookmarksToolbar.prototype = {
|
||||
NC_NS_CMD + "newfolder", args);
|
||||
// We need to do this because somehow focus shifts and no commands
|
||||
// operate any more.
|
||||
gBookmarksShell._focusElt.focus();
|
||||
//gBookmarksShell._focusElt.focus();
|
||||
},
|
||||
|
||||
nodeIsValidType: function (aNode)
|
||||
{
|
||||
switch (aNode.localName) {
|
||||
case "button":
|
||||
case "menubutton":
|
||||
// case "menu":
|
||||
// case "menuitem":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -318,6 +332,7 @@ BookmarksToolbar.prototype = {
|
||||
case "cmd_setnewsearchfolder":
|
||||
case "cmd_import":
|
||||
case "cmd_export":
|
||||
case "cmd_bm_fileBookmark":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -336,7 +351,7 @@ BookmarksToolbar.prototype = {
|
||||
case "cmd_bm_cut":
|
||||
case "cmd_bm_copy":
|
||||
case "cmd_bm_delete":
|
||||
return document.popupNode != null;
|
||||
return (document.popupNode != null) && (NODE_ID(document.popupNode) != "NC:PersonalToolbarFolder");
|
||||
case "cmd_bm_selectAll":
|
||||
return false;
|
||||
case "cmd_open":
|
||||
@ -371,6 +386,9 @@ BookmarksToolbar.prototype = {
|
||||
if (!seln.length) return false;
|
||||
folderType = seln[0].getAttribute("type") == (NC_NS + "Folder");
|
||||
return document.popupNode != null && !(NODE_ID(seln[0]) == "NC:NewSearchFolder") && folderType;
|
||||
case "cmd_bm_fileBookmark":
|
||||
seln = gBookmarksShell.getSelection();
|
||||
return seln.length > 0;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -400,6 +418,7 @@ BookmarksToolbar.prototype = {
|
||||
case "cmd_find":
|
||||
case "cmd_import":
|
||||
case "cmd_export":
|
||||
case "cmd_bm_fileBookmark":
|
||||
gBookmarksShell.execCommand(aCommand.substring("cmd_".length));
|
||||
break;
|
||||
case "cmd_bm_selectAll":
|
||||
@ -422,6 +441,7 @@ function BM_navigatorLoad(aEvent)
|
||||
if (!gBookmarksShell) {
|
||||
gBookmarksShell = new BookmarksToolbar("innermostBox");
|
||||
controllers.appendController(gBookmarksShell.controller);
|
||||
removeEventListener("load", BM_navigatorLoad, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,12 +106,12 @@
|
||||
<menuitem id="context-bookmarkpage"
|
||||
label="&bookmarkPageCmd.label;"
|
||||
accesskey="&bookmarkPageCmd.accesskey;"
|
||||
oncommand="BookmarksUtils.addBookmarkForBrowser(document.getElementById('content').webNavigation);"/>
|
||||
oncommand="BookmarksUtils.addBookmarkForBrowser(document.getElementById('content').webNavigation, true);"/>
|
||||
<menuitem id="context-bookmarklink"
|
||||
label="&bookmarkLinkCmd.label;"
|
||||
accesskey="&bookmarkLinkCmd.accesskey;"
|
||||
oncommand="BookmarksUtils.addBookmark(contextMenu.linkURL(),
|
||||
contextMenu.linkText());"/>
|
||||
contextMenu.linkText(), true);"/>
|
||||
<menuseparator id="context-sep-bookmark"/>
|
||||
<!-- Save ==================================== -->
|
||||
<menuitem id="context-savepage"
|
||||
|
@ -21,6 +21,62 @@
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add Bookmark Dialog.
|
||||
* ====================
|
||||
*
|
||||
* This is a generic bookmark dialog that allows for bookmark addition
|
||||
* and folder selection. It can be opened with various parameters that
|
||||
* result in appearance/purpose differences and initial state.
|
||||
*
|
||||
* Use: Open with 'openDialog', with the flags
|
||||
* 'centerscreen,chrome,dialog=no,resizable=yes'
|
||||
*
|
||||
* Parameters:
|
||||
* Apart from the standard openDialog parameters, this dialog can
|
||||
* be passed additional information, which gets mapped to the
|
||||
* window.arguments array:
|
||||
*
|
||||
* window.arguments[0]: Bookmark Name. The value to be prefilled
|
||||
* into the "Name: " field (if visible).
|
||||
* window.arguments[1]: Bookmark URL: The location of the bookmark.
|
||||
* The value to be filled in the "Location: "
|
||||
* field (if visible).
|
||||
* window.arguments[2]: Bookmark Folder. The RDF Resource URI of the
|
||||
* folder that this bookmark should be created in.
|
||||
* window.arguments[3]: Bookmark Charset. The charset that should be
|
||||
* used when adding a bookmark to the specified
|
||||
* URL. (Usually the charset of the current
|
||||
* document when launching this window).
|
||||
* window.arguments[4]: The mode of operation. See notes for details.
|
||||
*
|
||||
* Mode of Operation Notes:
|
||||
* ------------------------
|
||||
* This dialog can be opened in four different ways by using a parameter
|
||||
* passed through the call to openDialog. The 'mode' of operation
|
||||
* of the window is expressed in window.arguments[4]. The valid modes are:
|
||||
*
|
||||
* 1) <default> (no fifth open parameter).
|
||||
* Opens this dialog with the bookmark Name, URL and folder selection
|
||||
* components visible, as well as a checkbox which allows the user
|
||||
* to bypass the dialog for future bookmark additions. Only useful
|
||||
* for a browser implementation which users BookmarksUtils methods for
|
||||
* adding bookmarks
|
||||
* 2) "addBookmark" (fifth open parameter = String("addBookmark"))
|
||||
* Opens the dialog as in (1) above but with no checkbox. Useful
|
||||
* in situations where user ability to choose not to see this dialog
|
||||
* is not applicable, or for clients wishing to customize the launch
|
||||
* behaviour.
|
||||
* 3) "newBookmark" (fifth open parameter = String("newBookmark"))
|
||||
* Opens the dialog as in (1) above except the folder selection tree
|
||||
* is hidden. This type of mode is useful when the creation folder
|
||||
* is pre-determined.
|
||||
* 4) "selectFolder" (fifth open parameter = String("selectFolder"))
|
||||
* Opens the dialog as in (1) above except the Name/Location section
|
||||
* is hidden, and the dialog takes on the utility of a Folder chooser.
|
||||
* Used when the user must select a Folder for some purpose.
|
||||
*/
|
||||
|
||||
var gFld_Name = null;
|
||||
var gFld_URL = null;
|
||||
var gFolderTree = null;
|
||||
@ -35,6 +91,8 @@ var gSelectItemObserver = null;
|
||||
|
||||
var gCreateInFolder = "NC:NewBookmarkFolder";
|
||||
|
||||
var gCanBypassDialogMode = true;
|
||||
|
||||
function Startup()
|
||||
{
|
||||
doSetOKCancel(onOK);
|
||||
@ -44,31 +102,69 @@ function Startup()
|
||||
|
||||
var shouldSetOKButton = true;
|
||||
if ("arguments" in window) {
|
||||
// If we're being opened as a folder selection window
|
||||
if (window.arguments[4] == "selectFolder") {
|
||||
document.getElementById("bookmarknamegrid").setAttribute("hidden", "true");
|
||||
toggleCreateIn();
|
||||
switch (window.arguments[4]) {
|
||||
case "selectFolder":
|
||||
// If we're being opened as a folder selection window
|
||||
document.getElementById("dontaskagain").setAttribute("hidden", "true");
|
||||
document.getElementById("bookmarknamegrid").setAttribute("hidden", "true");
|
||||
document.getElementById("createinseparator").setAttribute("hidden", "true");
|
||||
document.getElementById("nameseparator").setAttribute("hidden", "true");
|
||||
sizeToContent();
|
||||
const kWindowNode = document.getElementById("newBookmarkWindow");
|
||||
kWindowNode.setAttribute("title", kWindowNode.getAttribute("title-selectFolder"));
|
||||
var windowNode = document.getElementById("newBookmarkWindow");
|
||||
windowNode.setAttribute("title", windowNode.getAttribute("title-selectFolder"));
|
||||
shouldSetOKButton = false;
|
||||
}
|
||||
else {
|
||||
gFld_Name.value = window.arguments[0] || "";
|
||||
gFld_URL.value = window.arguments[1] || "";
|
||||
gBookmarkCharset = window.arguments [3] || null;
|
||||
if (window.arguments[2])
|
||||
var folderItem = document.getElementById(window.arguments[2]);
|
||||
if (folderItem)
|
||||
gFolderTree.selectItem(folderItem);
|
||||
gCanBypassDialogMode = false;
|
||||
break;
|
||||
case "newBookmark":
|
||||
setupFields();
|
||||
if (window.arguments[2])
|
||||
gCreateInFolder = window.arguments[2];
|
||||
document.getElementById("folderbox").setAttribute("hidden", "true");
|
||||
document.getElementById("dontaskagain").setAttribute("hidden", "true");
|
||||
windowNode = document.getElementById("newBookmarkWindow");
|
||||
windowNode.removeAttribute("persist");
|
||||
windowNode.setAttribute("height", "0");
|
||||
windowNode.setAttribute("width", "0");
|
||||
windowNode.setAttribute("style", windowNode.getAttribute("style"));
|
||||
sizeToContent();
|
||||
gCanBypassDialogMode = false;
|
||||
break;
|
||||
case "addBookmark":
|
||||
// Regular add bookmark window, but for some sinister purpose...
|
||||
document.getElementById("dontaskagain").setAttribute("hidden", "true");
|
||||
gCanBypassDialogMode = false;
|
||||
// Fall through... --->
|
||||
default:
|
||||
// Regular Add Bookmark
|
||||
setupFields();
|
||||
if (window.arguments[2]) {
|
||||
gCreateInFolder = window.arguments[2];
|
||||
var folderItem = document.getElementById(gCreateInFolder);
|
||||
if (folderItem)
|
||||
gFolderTree.selectItem(folderItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSetOKButton)
|
||||
onLocationInput();
|
||||
gFld_Name.focus();
|
||||
gFld_Input
|
||||
}
|
||||
|
||||
function setupFields()
|
||||
{
|
||||
// New bookmark in predetermined folder.
|
||||
gFld_Name.value = window.arguments[0] || "";
|
||||
gFld_URL.value = window.arguments[1] || "";
|
||||
onLocationInput();
|
||||
gFld_Name.select();
|
||||
gFld_Name.focus();
|
||||
gBookmarkCharset = window.arguments [3] || null;
|
||||
}
|
||||
|
||||
function onLocationInput ()
|
||||
{
|
||||
var ok = document.getElementById("ok");
|
||||
@ -77,9 +173,13 @@ function onLocationInput ()
|
||||
|
||||
function onOK()
|
||||
{
|
||||
// In Select Folder Mode, do nothing but tell our caller what
|
||||
// folder was selected.
|
||||
if (window.arguments[4] == "selectFolder")
|
||||
window.arguments[5].selectedFolder = gCreateInFolder;
|
||||
else {
|
||||
// Otherwise add a bookmark to the selected folder.
|
||||
|
||||
const kBMDS = kRDF.GetDataSource("rdf:bookmarks");
|
||||
const kBMSContractID = "@mozilla.org/browser/bookmarks-service;1";
|
||||
const kBMSIID = Components.interfaces.nsIBookmarksService;
|
||||
@ -113,15 +213,17 @@ function onOK()
|
||||
|
||||
kBMS.AddBookmarkToFolder(url, rFolder, gFld_Name.value, gBookmarkCharset);
|
||||
|
||||
// Persist the 'show this dialog again' preference.
|
||||
var checkbox = document.getElementById("dontaskagain");
|
||||
const kPrefContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefContractID].getService(kPrefIID);
|
||||
try {
|
||||
kPrefSvc.SetBoolPref("browser.bookmarks.add_without_dialog", checkbox.checked);
|
||||
}
|
||||
catch (e) {
|
||||
if (gCanBypassDialogMode) {
|
||||
// Persist the 'show this dialog again' preference.
|
||||
var checkbox = document.getElementById("dontaskagain");
|
||||
const kPrefContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefContractID].getService(kPrefIID);
|
||||
try {
|
||||
kPrefSvc.SetBoolPref("browser.bookmarks.add_without_dialog", checkbox.checked);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
close();
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
<keyset id="dialogKeys"/>
|
||||
|
||||
<separator class="thin"/>
|
||||
<separator id="nameseparator" class="thin"/>
|
||||
|
||||
<grid id="bookmarknamegrid">
|
||||
<columns>
|
||||
@ -128,6 +128,7 @@
|
||||
<separator/>
|
||||
</vbox>
|
||||
|
||||
<!-- XXX - need to use an "Add Bookmark" string here -->
|
||||
<box id="okCancelButtonsRight"/>
|
||||
|
||||
|
||||
</window>
|
||||
|
@ -38,13 +38,23 @@ function Startup()
|
||||
const windowNode = document.getElementById("bookmark-window");
|
||||
// If we've been opened with a parameter, root the tree on it.
|
||||
if ("arguments" in window && window.arguments[0]) {
|
||||
bookmarksTree.setAttribute("ref", window.arguments[0]);
|
||||
const krNameArc = gBookmarksShell.RDF.GetResource(NC_NS + "Name");
|
||||
const krRoot = gBookmarksShell.RDF.GetResource(window.arguments[0]);
|
||||
var rName = gBookmarksShell.db.GetTarget(krRoot, krNameArc, true);
|
||||
rName = rName.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
var uri = window.arguments[0];
|
||||
bookmarksTree.setAttribute("ref", uri);
|
||||
var title = "";
|
||||
if (uri.substring(0,5) == "find:") {
|
||||
title = gBookmarksShell.getLocaleString("search_results_title");
|
||||
// Update the windowtype so that future searches are directed
|
||||
// there and the window is not re-used for bookmarks.
|
||||
windowNode.setAttribute("windowtype", "bookmarks:searchresults");
|
||||
}
|
||||
else {
|
||||
const krNameArc = gBookmarksShell.RDF.GetResource(NC_NS + "Name");
|
||||
const krRoot = gBookmarksShell.RDF.GetResource(window.arguments[0]);
|
||||
var rName = gBookmarksShell.db.GetTarget(krRoot, krNameArc, true);
|
||||
title = rName.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
}
|
||||
const titleString = gBookmarksShell.getLocaleString("window_title");
|
||||
windowNode.setAttribute("title", titleString.replace(/%folder_name%/gi, rName));
|
||||
windowNode.setAttribute("title", titleString.replace(/%folder_name%/gi, title));
|
||||
}
|
||||
else {
|
||||
var rootfoldername = gBookmarksShell.getLocaleString("bookmarks_root");
|
||||
@ -58,6 +68,10 @@ function Startup()
|
||||
// Update to the last sort.
|
||||
RefreshSort();
|
||||
|
||||
var kids = document.getElementById("treechildren-bookmarks");
|
||||
if (kids.firstChild)
|
||||
bookmarksTree.selectItem(kids.firstChild);
|
||||
|
||||
bookmarksTree.focus();
|
||||
}
|
||||
|
||||
@ -122,15 +136,26 @@ BookmarksWindowTree.prototype = {
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
else
|
||||
displayValue = LITERAL(this.db, currItem, NC_NS + "URL");
|
||||
else {
|
||||
try {
|
||||
displayValue = LITERAL(this.db, currItem, NC_NS + "URL");
|
||||
}
|
||||
catch (e) {
|
||||
displayValue = "";
|
||||
}
|
||||
}
|
||||
if (displayValue.substring(0, 3) == "NC:")
|
||||
displayValue = "";
|
||||
}
|
||||
kStatusBar.label = displayValue;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
Not used anymore but keeping code around in case it comes in handy for bookmarks button D&D
|
||||
or personal toolbar D&D.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// This will not work properly until drag & drop is asynchronous and allows
|
||||
// events to be processed during a drag.
|
||||
@ -267,3 +292,4 @@ var fileButton = {
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
@ -79,7 +79,8 @@
|
||||
<commandset id="tasksCommands"/>
|
||||
<commandset id="bookmarksItems"/>
|
||||
|
||||
<!-- File Menu -->
|
||||
|
||||
<!-- File Menu -->
|
||||
<command id="cmd_newNavigator"/>
|
||||
<command id="cmd_newEditor"/>
|
||||
<command id="cmd_close" oncommand="close()"/>
|
||||
@ -88,10 +89,8 @@
|
||||
<command id="cmd_undo"/>
|
||||
</commands>
|
||||
|
||||
<popupset id="popupset"/>
|
||||
|
||||
<stringbundleset id="stringbundleset"/>
|
||||
|
||||
|
||||
<keyset id="tasksKeys">
|
||||
<!-- File Menu -->
|
||||
<key id="key_newNavigator"/>
|
||||
@ -100,17 +99,25 @@
|
||||
<key id="key_quit"/>
|
||||
<!-- Edit Menu -->
|
||||
<key id="key_undo"/>
|
||||
<key id="key_cut"/>
|
||||
<key id="key_copy"/>
|
||||
<key id="key_paste"/>
|
||||
<key id="key_bm_delete" keycode="VK_DELETE" observes="cmd_bm_delete"/>
|
||||
<key id="key_selectAll"/>
|
||||
|
||||
<!-- These keybindings do not have a command specified in the overlay,
|
||||
which is good, but we need to specify it ourselves here -->
|
||||
<key id="key_cut" command="cmd_bm_cut"/>
|
||||
<key id="key_copy" command="cmd_bm_copy"/>
|
||||
<key id="key_paste" command="cmd_bm_paste"/>
|
||||
<key id="key_selectAll" command="cmd_bm_selectAll"/>
|
||||
|
||||
<!-- We need to provide our own delete key binding because the key_delete
|
||||
handler in platformGlobalOverlay.xul maps command to "cmd_delete" which
|
||||
is NOT what we want! -->
|
||||
<key id="key_bm_delete" keycode="VK_DELETE" command="cmd_bm_delete"/>
|
||||
|
||||
<key id="bm_key_find"
|
||||
key="&edit.find.keybinding;"
|
||||
observes="cmd_find" modifiers="accel"/>
|
||||
command="cmd_find" modifiers="accel"/>
|
||||
<key id="bm_key_properties"
|
||||
key="&edit.properties.keybinding;"
|
||||
observes="cmd_properties" modifiers="accel"/>
|
||||
command="cmd_properties" modifiers="accel"/>
|
||||
</keyset>
|
||||
|
||||
<toolbox id="bookmarks-toolbox">
|
||||
@ -138,26 +145,20 @@
|
||||
<menupopup>
|
||||
<menuitem id="menu_undo" disabled="true"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_cut"/>
|
||||
<menuitem id="menu_copy"/>
|
||||
<menuitem id="menu_paste"/>
|
||||
<menuitem id="menu_delete"/>
|
||||
<menuitem id="menu_cut" command="cmd_bm_cut"/>
|
||||
<menuitem id="menu_copy" command="cmd_bm_copy"/>
|
||||
<menuitem id="menu_paste" command="cmd_bm_paste"/>
|
||||
<menuitem id="menu_delete" command="cmd_bm_delete"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_selectAll"/>
|
||||
<menuseparator/>
|
||||
<menu id="file-bookmarks-menu" label="&command.fileBookmark.label;"
|
||||
accesskey="&command.fileBookmark.accesskey;"
|
||||
ref="NC:BookmarksRoot" datasources="rdf:bookmarks"
|
||||
template="file-bookmarks-template">
|
||||
<menupopup oncreate="fileButton.createPopupHeader(event);"/>
|
||||
</menu>
|
||||
<menuitem label="&command.fileBookmark.label;"
|
||||
accesskey="&command.fileBookmark.accesskey;"
|
||||
command="cmd_bm_fileBookmark"/>
|
||||
<menuseparator/>
|
||||
<menuitem observes="cmd_find" key="bm_key_find"
|
||||
<menuitem command="cmd_find" key="bm_key_find"
|
||||
label="&menuitem.find.label;"
|
||||
accesskey="&menuitem.find.accesskey;"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_preferences"
|
||||
oncommand="goPreferences('navigator', 'chrome://communicator/content/bookmarks/pref-bookmarks.xul', 'bookmarks')"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
@ -207,41 +208,25 @@
|
||||
|
||||
<toolbar id="command-toolbar" tbautostretch="always" grippy="false">
|
||||
<button class="button-toolbar" id="newfolder" label="&command.newFolder.label;"
|
||||
observes="cmd_newfolder"/>
|
||||
command="cmd_newfolder"/>
|
||||
<button class="button-toolbar" id="newseparator" label="&command.newSeparator.label;"
|
||||
observes="cmd_newseparator"/>
|
||||
command="cmd_newseparator"/>
|
||||
<toolbarseparator/>
|
||||
<menubutton id="file-bookmarks" label="&command.fileBookmark.label;"
|
||||
crop="right" class="button-toolbar"
|
||||
ref="NC:BookmarksRoot" datasources="rdf:bookmarks"
|
||||
template="file-bookmarks-template"
|
||||
ondragover="nsDragAndDrop.dragOver(event, fileButton);"
|
||||
ondragdrop="nsDragAndDrop.drop(event, fileButton);">
|
||||
<template id="file-bookmarks-template">
|
||||
<rule iscontainer="true">
|
||||
<menupopup ondestroy="fileButton.onPopupDestroy(event);">
|
||||
<menu uri="rdf:*" persist="open" class="menu-iconic bookmark-item"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
loading="rdf:http://home.netscape.com/NC-rdf#loading"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup oncreate="fileButton.createPopupHeader(event);"/>
|
||||
</menubutton>
|
||||
<button class="button-toolbar" id="fileBookmark" label="&command.fileBookmark.label;"
|
||||
command="cmd_bm_fileBookmark"/>
|
||||
<toolbarseparator/>
|
||||
<button class="button-toolbar" id="properties" label="&command.properties.label;"
|
||||
observes="cmd_properties"/>
|
||||
command="cmd_properties"/>
|
||||
<button class="button-toolbar" id="rename" label="&command.rename.label;"
|
||||
observes="cmd_rename"/>
|
||||
command="cmd_rename"/>
|
||||
<button class="button-toolbar" id="delete" label="&command.delete.label;"
|
||||
observes="cmd_bm_delete"/>
|
||||
command="cmd_bm_delete"/>
|
||||
</toolbar>
|
||||
</toolbox>
|
||||
|
||||
<tree id="bookmarksTree" class="bookmarks-window-tree" ref="NC:BookmarksRoot"
|
||||
datasources="rdf:bookmarks rdf:localsearch rdf:internetsearch"
|
||||
datasources="rdf:bookmarks rdf:files rdf:localsearch rdf:internetsearch rdf:localsearch"
|
||||
type="http://home.netscape.com/NC-rdf#Folder"
|
||||
multiple="true" flags="dont-test-empty"
|
||||
ondragover="nsDragAndDrop.dragOver(event, bookmarksDNDObserver);"
|
||||
ondraggesture="nsDragAndDrop.startDrag(event, bookmarksDNDObserver);"
|
||||
@ -277,11 +262,11 @@
|
||||
rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
loading="rdf:http://home.netscape.com/NC-rdf#loading">
|
||||
<treerow>
|
||||
<treecell class="treecell-indent treecell-editable"
|
||||
editable="true" label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||
<treecell class="treecell-indent" editable="true"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
web:status="rdf:http://home.netscape.com/WEB-rdf#status"
|
||||
rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
loading="rdf:http://home.netscape.com/NC-rdf#loading" />
|
||||
<treecell crop="right" class="treecell-editable" editable="true"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#URL"/>
|
||||
|
@ -95,34 +95,6 @@ BookmarksUIElement.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/* XXX template problems.
|
||||
listener: null,
|
||||
exDB: ["rdf:files", "rdf:httpindex"],
|
||||
setUpCompositeDataSource: function ()
|
||||
{
|
||||
if (!this.listener)
|
||||
this.listener = new AggregationPrefListener ();
|
||||
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
var bUseExtendedDataViews = false;
|
||||
try {
|
||||
bUseExtendedDataViews = kPrefSvc.GetBoolPref("browser.bookmarks.show_extended_data");
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
var element = document.getElementById(this.id);
|
||||
var db = element.database;
|
||||
|
||||
for (var i = 0; i < this.exDB.length; ++i) {
|
||||
dump("** txxsdflks = " + this.exDB[i] + "\n");
|
||||
db[bUseExtendedDataViews ? "AddDataSource" : "RemoveDataSource"](this.RDF.GetDataSource(this.exDB[i]));
|
||||
}
|
||||
element.builder.rebuild();
|
||||
},
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Fill a context menu popup with menuitems that are appropriate for the current
|
||||
// selection.
|
||||
@ -140,6 +112,7 @@ BookmarksUIElement.prototype = {
|
||||
throw "Clients must implement findRDFNode!";
|
||||
var itemNode = this.findRDFNode(popupNode, true);
|
||||
if (!itemNode || !itemNode.getAttribute("type") || itemNode.getAttribute("mode") == "edit") {
|
||||
aEvent.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -150,6 +123,10 @@ BookmarksUIElement.prototype = {
|
||||
for (var i = 0; i < selection.length; ++i) {
|
||||
var nodeURI = NODE_ID(selection[i]);
|
||||
var commands = this.getAllCmds(nodeURI);
|
||||
if (!commands) {
|
||||
aEvent.preventDefault();
|
||||
return;
|
||||
}
|
||||
commands = this.flattenEnumerator(commands);
|
||||
if (!commonCommands.length) commonCommands = commands;
|
||||
commonCommands = this.findCommonNodes(commands, commonCommands);
|
||||
@ -216,25 +193,34 @@ BookmarksUIElement.prototype = {
|
||||
getAllCmds: function (aNodeID)
|
||||
{
|
||||
var type = this.resolveType(aNodeID);
|
||||
if (!type) {
|
||||
if (aNodeID == "NC:PersonalToolbarFolder" || aNodeID == "NC:BookmarksRoot")
|
||||
type = "http://home.netscape.com/NC-rdf#Folder";
|
||||
else
|
||||
return null;
|
||||
}
|
||||
var commands = [];
|
||||
switch (type) {
|
||||
case "http://home.netscape.com/NC-rdf#BookmarkSeparator":
|
||||
commands = ["find", "separator", "bm_cut", "bm_copy", "bm_paste",
|
||||
"bm_delete", "separator", "newfolder"];
|
||||
"bm_delete", "separator", "bm_fileBookmark", "separator",
|
||||
"newfolder"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#Bookmark":
|
||||
commands = ["open", "find", "separator", "bm_cut", "bm_copy", "bm_paste",
|
||||
"bm_delete", "separator", "rename", "separator", "newfolder",
|
||||
"bm_delete", "separator", "rename", "separator",
|
||||
"bm_fileBookmark", "separator", "newfolder",
|
||||
"separator", "properties"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#Folder":
|
||||
commands = ["openfolder", "openfolderinnewwindow", "find", "separator",
|
||||
"bm_cut", "bm_copy", "bm_paste", "bm_delete", "separator", "rename",
|
||||
"separator", "newfolder", "separator", "properties"];
|
||||
"separator", "bm_fileBookmark", "separator",
|
||||
"newfolder", "separator", "properties"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#IEFavoriteFolder":
|
||||
commands = ["open", "find", "separator", "bm_copy", "separator", "rename",
|
||||
"separator", "properties"];
|
||||
commands = ["open", "find", "separator", "bm_copy", "separator", "rename", "separator",
|
||||
"bm_fileBookmark", "separator", "separator", "properties"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#IEFavorite":
|
||||
commands = ["open", "find", "separator", "bm_copy"];
|
||||
@ -321,29 +307,47 @@ BookmarksUIElement.prototype = {
|
||||
this.findInBookmarks();
|
||||
break;
|
||||
case "bm_cut":
|
||||
this.copySelection (selection);
|
||||
this.deleteSelection (selection);
|
||||
this.copySelection(selection);
|
||||
this.deleteSelection(selection);
|
||||
break;
|
||||
case "bm_copy":
|
||||
this.copySelection (selection);
|
||||
this.copySelection(selection);
|
||||
break;
|
||||
case "bm_paste":
|
||||
this.paste (selection);
|
||||
this.paste(selection);
|
||||
break;
|
||||
case "bm_delete":
|
||||
this.deleteSelection (selection);
|
||||
this.deleteSelection(selection);
|
||||
break;
|
||||
case "bm_fileBookmark":
|
||||
var rv = { selectedFolder: null };
|
||||
openDialog("chrome://communicator/content/bookmarks/addBookmark.xul", "",
|
||||
"centerscreen,chrome,modal=yes,dialog=no,resizable=yes", null, null, folder, null, "selectFolder", rv);
|
||||
if (rv.selectedFolder) {
|
||||
var additiveFlag = false;
|
||||
var selectedItems = [].concat(this.getSelection())
|
||||
for (var i = 0; i < selectedItems.length; ++i) {
|
||||
var currItem = selectedItems[i];
|
||||
var currURI = NODE_ID(currItem);
|
||||
var parent = gBookmarksShell.findRDFNode(currItem, false);
|
||||
gBookmarksShell.moveBookmark(currURI, NODE_ID(parent), rv.selectedFolder);
|
||||
gBookmarksShell.selectFolderItem(rv.selectedFolder, currURI, additiveFlag);
|
||||
if (!additiveFlag) additiveFlag = true;
|
||||
}
|
||||
gBookmarksShell.flushDataSource();
|
||||
}
|
||||
break;
|
||||
case "newfolder":
|
||||
var nfseln = this.getBestItem ();
|
||||
var nfseln = this.getBestItem();
|
||||
this.commands.createBookmarkItem("folder", nfseln);
|
||||
break;
|
||||
case "newbookmark":
|
||||
var folder = this.getSelectedFolder();
|
||||
openDialog("chrome://communicator/content/bookmarks/addBookmark.xul", "",
|
||||
"centerscreen,chrome,dialog=no,resizable=no", null, null, folder, null);
|
||||
"centerscreen,chrome,modal=yes,dialog=no,resizable=no", null, null, folder, null, "newBookmark");
|
||||
break;
|
||||
case "newseparator":
|
||||
nfseln = this.getBestItem ();
|
||||
nfseln = this.getBestItem();
|
||||
var parentNode = this.findRDFNode(nfseln, false);
|
||||
args = [{ property: NC_NS + "parent",
|
||||
resource: NODE_ID(parentNode) }];
|
||||
@ -562,11 +566,20 @@ BookmarksUIElement.prototype = {
|
||||
const kSelectionURI = NODE_ID(aSelection[count]);
|
||||
|
||||
// Disallow the removal of certain 'special' nodes
|
||||
if (kSelectionURI == "NC:BookmarksRoot" ||
|
||||
kSelectionURI == "NC:IEFavoritesRoot") {
|
||||
if (kSelectionURI == "NC:BookmarksRoot") {
|
||||
aSelection.splice(count++,1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the current bookmark is the IE Favorites folder, we have a little
|
||||
// extra work to do - set the pref |browser.bookmarks.import_system_favorites|
|
||||
// to ensure that we don't re-import next time.
|
||||
if (aSelection[count].getAttribute("type") == (NC_NS + "IEFavoriteFolder")) {
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
kPrefSvc.SetBoolPref("browser.bookmarks.import_system_favorites", false);
|
||||
}
|
||||
|
||||
const krParent = this.RDF.GetResource(NODE_ID(currParent));
|
||||
const krBookmark = this.RDF.GetResource(kSelectionURI);
|
||||
@ -629,15 +642,15 @@ BookmarksUIElement.prototype = {
|
||||
{
|
||||
if (aBookmarkItem.getAttribute("type") != NC_NS + "BookmarkSeparator")
|
||||
openDialog("chrome://communicator/content/bookmarks/bm-props.xul",
|
||||
"", "centerscreen,chrome,dialog=no,resizable=no",
|
||||
"BookmarkProperties", "centerscreen,chrome,dialog=no,resizable=no",
|
||||
NODE_ID(aBookmarkItem));
|
||||
},
|
||||
|
||||
findInBookmarks: function ()
|
||||
{
|
||||
openDialog("chrome://communicator/content/bookmarks/bm-find.xul",
|
||||
openDialog("chrome://communicator/content/bookmarks/findBookmark.xul",
|
||||
"FindBookmarksWindow",
|
||||
"centerscreen,chrome,resizable,dialog=no");
|
||||
"centerscreen,chrome,dependent");
|
||||
},
|
||||
|
||||
getLocaleString: function (aStringKey)
|
||||
@ -664,7 +677,12 @@ BookmarksUIElement.prototype = {
|
||||
return type.QueryInterface(Components.interfaces.nsIRDFResource).Value;
|
||||
}
|
||||
catch (e) {
|
||||
return type.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
try {
|
||||
return type.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -776,7 +794,9 @@ var BookmarksUtils = {
|
||||
|
||||
createFolderWithID: function (aTitle, aRelativeItem, aParentFolder)
|
||||
{
|
||||
const krAnonymous = this.RDF.GetAnonymousResource();
|
||||
const krBMDS = this.RDF.GetDataSource("rdf:bookmarks");
|
||||
const kBMSvc = krBMDS.QueryInterface(Components.interfaces.nsIBookmarksService);
|
||||
const krAnonymous = kBMSvc.GetAnonymousResource();
|
||||
|
||||
var args = [{ property: NC_NS + "parent", resource: aParentFolder },
|
||||
{ property: NC_NS + "Name", literal: aTitle },
|
||||
@ -785,7 +805,6 @@ var BookmarksUtils = {
|
||||
|
||||
// Tidy up.
|
||||
const krURL = this.RDF.GetResource(NC_NS + "URL");
|
||||
const krBMDS = this.RDF.GetDataSource("rdf:bookmarks");
|
||||
const krCurrURL = krBMDS.GetTarget(krAnonymous, krURL, true);
|
||||
const krEmpty = this.RDF.GetLiteral("");
|
||||
krBMDS.Change(krAnonymous, krURL, krCurrURL, krEmpty);
|
||||
@ -809,6 +828,17 @@ var BookmarksUtils = {
|
||||
catch (e) {
|
||||
title = url;
|
||||
}
|
||||
|
||||
const kPrefContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefContractID].getService(kPrefIID);
|
||||
try {
|
||||
var temp = kPrefSvc.GetBoolPref("browser.bookmarks.add_without_dialog");
|
||||
aShowDialog = !temp;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
this.addBookmark(url, title, docCharset, aShowDialog);
|
||||
},
|
||||
|
||||
@ -821,7 +851,7 @@ var BookmarksUtils = {
|
||||
|
||||
if (aShowDialog)
|
||||
openDialog("chrome://communicator/content/bookmarks/addBookmark.xul", "",
|
||||
"centerscreen,chrome,dialog=no,resizable=yes", aTitle, aURL, null, aCharset);
|
||||
"centerscreen,chrome,dialog=no,resizable,dependent", aTitle, aURL, null, aCharset);
|
||||
else {
|
||||
// User has elected to override the file dialog and always file bookmarks
|
||||
// into the default bookmark folder.
|
||||
|
@ -34,7 +34,7 @@
|
||||
src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<popupset id="popupset">
|
||||
<popupset id="bookmarksPopupset" appendto="_root">
|
||||
<popup id="bmContext"
|
||||
oncreate="gBookmarksShell.createContextMenu(event);"/>
|
||||
</popupset>
|
||||
@ -55,6 +55,7 @@
|
||||
<command id="cmd_openfolderinnewwindow" oncommand="goDoCommand('cmd_openfolderinnewwindow');"/>
|
||||
<command id="cmd_import" oncommand="goDoCommand('cmd_import');"/>
|
||||
<command id="cmd_export" oncommand="goDoCommand('cmd_export');"/>
|
||||
<command id="cmd_bm_fileBookmark" oncommand="goDoCommand('cmd_bm_fileBookmark');"/>
|
||||
|
||||
<command id="cmd_bm_cut" oncommand="goDoCommand('cmd_bm_cut');"/>
|
||||
<command id="cmd_bm_copy" oncommand="goDoCommand('cmd_bm_copy');"/>
|
||||
|
@ -41,6 +41,7 @@ function BookmarksTree (aID)
|
||||
BookmarksTree.prototype = {
|
||||
__proto__: BookmarksUIElement.prototype,
|
||||
|
||||
// XXX - change this to .element and move into base.
|
||||
get tree ()
|
||||
{
|
||||
return document.getElementById(this.id);
|
||||
@ -82,6 +83,13 @@ BookmarksTree.prototype = {
|
||||
return xulElement;
|
||||
},
|
||||
|
||||
// XXX - ideally this would be in the base. this.tree needs to change to
|
||||
// this.element and then we can do just that.
|
||||
setRoot: function (aRoot)
|
||||
{
|
||||
this.tree.setAttribute("ref", aRoot);
|
||||
},
|
||||
|
||||
// Command implementation
|
||||
commands: {
|
||||
openFolder: function (aSelectedItem)
|
||||
@ -101,6 +109,9 @@ BookmarksTree.prototype = {
|
||||
var editCell = aSelectedItem.firstChild.childNodes[aCell];
|
||||
if (editCell.getAttribute("editable") != "true")
|
||||
return;
|
||||
|
||||
// Cause the inline edit cell binding to be used.
|
||||
editCell.setAttribute("class", "treecell-indent treecell-editable");
|
||||
var editColGroup = document.getElementById("theColumns");
|
||||
var count = 0;
|
||||
var property = "";
|
||||
@ -121,7 +132,7 @@ BookmarksTree.prototype = {
|
||||
if (property) {
|
||||
editCell.setMode("edit");
|
||||
editCell.addObserver(this.postModifyCallback, "accept",
|
||||
[gBookmarksShell, aSelectedItem, property]);
|
||||
[editCell, aSelectedItem, property]);
|
||||
}
|
||||
},
|
||||
|
||||
@ -130,13 +141,16 @@ BookmarksTree.prototype = {
|
||||
// needs to be modified in the datasource.
|
||||
postModifyCallback: function (aParams)
|
||||
{
|
||||
var aShell = aParams[0];
|
||||
var selItemURI = NODE_ID(aParams[1]);
|
||||
aShell.propertySet(selItemURI, aParams[2], aParams[3]);
|
||||
gBookmarksShell.propertySet(selItemURI, aParams[2], aParams[3]);
|
||||
gBookmarksShell.selectFolderItem(NODE_ID(gBookmarksShell.findRDFNode(aParams[1], false)),
|
||||
selItemURI, false);
|
||||
gBookmarksShell.tree.focus();
|
||||
gSelectionTracker.clickCount = 0;
|
||||
|
||||
// Set the cell back to use the standard treecell binding.
|
||||
var editCell = aParams[0];
|
||||
editCell.setAttribute("class", "treecell-indent");
|
||||
},
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -153,7 +167,7 @@ BookmarksTree.prototype = {
|
||||
var shell = gBookmarksShell.commands; // suck
|
||||
var dummyItem = aParams[2];
|
||||
var relativeNode = aParams[1];
|
||||
var parentNode = gBookmarksShell.findRDFNode(relativeNode, false);
|
||||
var parentNode = relativeNode ? gBookmarksShell.findRDFNode(relativeNode, false) : gBookmarksShell.tree;
|
||||
|
||||
dummyItem.parentNode.removeChild(dummyItem);
|
||||
|
||||
@ -163,15 +177,16 @@ BookmarksTree.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If we're attempting to create a folder as a subfolder of an open folder,
|
||||
// we need to set the parentFolder to be relativeNode, which will be the
|
||||
// parent of the new folder, rather than the parent of the relativeNode,
|
||||
// which will result in the folder being created in an incorrect position
|
||||
// (adjacent to the relativeNode).
|
||||
var selKids = ContentUtils.childByLocalName(relativeNode, "treechildren");
|
||||
if (selKids && selKids.hasChildNodes() && selKids.lastChild == dummyItem)
|
||||
parentNode = relativeNode;
|
||||
if (relativeNode) {
|
||||
// If we're attempting to create a folder as a subfolder of an open folder,
|
||||
// we need to set the parentFolder to be relativeNode, which will be the
|
||||
// parent of the new folder, rather than the parent of the relativeNode,
|
||||
// which will result in the folder being created in an incorrect position
|
||||
// (adjacent to the relativeNode).
|
||||
var selKids = ContentUtils.childByLocalName(relativeNode, "treechildren");
|
||||
if (selKids && selKids.hasChildNodes() && selKids.lastChild == dummyItem)
|
||||
parentNode = relativeNode;
|
||||
}
|
||||
|
||||
var args = [{ property: NC_NS + "parent",
|
||||
resource: NODE_ID(parentNode) },
|
||||
@ -180,8 +195,8 @@ BookmarksTree.prototype = {
|
||||
|
||||
const kBMDS = gBookmarksShell.RDF.GetDataSource("rdf:bookmarks");
|
||||
kBMDS.AddObserver(newFolderRDFObserver);
|
||||
BookmarksUtils.doBookmarksCommand(NODE_ID(relativeNode),
|
||||
NC_NS_CMD + "newfolder", args);
|
||||
var relId = relativeNode ? NODE_ID(relativeNode) : "NC:BookmarksRoot";
|
||||
BookmarksUtils.doBookmarksCommand(relId, NC_NS_CMD + "newfolder", args);
|
||||
kBMDS.RemoveObserver(newFolderRDFObserver);
|
||||
var newFolderItem = document.getElementById(newFolderRDFObserver._newFolderURI);
|
||||
gBookmarksShell.tree.focus();
|
||||
@ -206,7 +221,6 @@ BookmarksTree.prototype = {
|
||||
if (aTopic == "reject") {
|
||||
if (aOldSelectedItem)
|
||||
gBookmarksShell.tree.selectItem(aOldSelectedItem);
|
||||
aDummyItem.parentNode.removeChild(aDummyItem);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -217,43 +231,55 @@ BookmarksTree.prototype = {
|
||||
// to create new bookmarks/folders.
|
||||
createBookmarkItem: function (aMode, aSelectedItem)
|
||||
{
|
||||
aSelectedItem.removeAttribute("selected");
|
||||
var dummyItem = aSelectedItem.cloneNode(true);
|
||||
dummyItem.removeAttribute("id");
|
||||
dummyItem.removeAttribute("selected");
|
||||
if (aMode == "folder")
|
||||
dummyItem.setAttribute("container", "true");
|
||||
for (var i = 0; i < dummyItem.firstChild.childNodes.length; ++i)
|
||||
dummyItem.firstChild.childNodes[i].removeAttribute("label");
|
||||
var editCell = dummyItem.firstChild.firstChild;
|
||||
editCell.setAttribute("label",
|
||||
gBookmarksShell.getLocaleString(aMode == "folder" ? "ile_newfolder" :
|
||||
"ile_newbookmark"));
|
||||
editCell.setAttribute("type", NC_NS + (aMode == "folder" ? "Folder" : "Bookmark"));
|
||||
// By default, create adjacent to the selected item
|
||||
var relativeNode = aSelectedItem;
|
||||
if (relativeNode.getAttribute("container") == "true" &&
|
||||
relativeNode.getAttribute("open") == "true") {
|
||||
// But if it's an open container, the relative node should be the last child.
|
||||
var treechildren = ContentUtils.childByLocalName(relativeNode, "treechildren");
|
||||
if (treechildren && treechildren.hasChildNodes())
|
||||
relativeNode = treechildren.lastChild;
|
||||
}
|
||||
if (dummyItem.getAttribute("container") == "true") {
|
||||
for (i = 0; i < dummyItem.childNodes.length; ++i) {
|
||||
if (dummyItem.childNodes[i].localName == "treechildren")
|
||||
dummyItem.removeChild(dummyItem.childNodes[i]);
|
||||
const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
var dummyItem = document.createElementNS(kXULNS, "treeitem");
|
||||
dummyItem = gBookmarksShell.createBookmarkFolderDecorations(dummyItem);
|
||||
dummyItem.setAttribute("class", "bookmark-item");
|
||||
|
||||
var dummyRow = document.createElementNS(kXULNS, "treerow");
|
||||
var dummyCell = document.createElementNS(kXULNS, "treecell");
|
||||
var dummyCell2 = document.createElementNS(kXULNS, "treecell");
|
||||
dummyCell.setAttribute("label", gBookmarksShell.getLocaleString("ile_newfolder") + " ");
|
||||
dummyCell.setAttribute("type", NC_NS + "Folder");
|
||||
dummyCell.setAttribute("editable", "true");
|
||||
dummyCell.setAttribute("class", "treecell-indent treecell-editable");
|
||||
dummyRow.appendChild(dummyCell);
|
||||
dummyItem.appendChild(dummyRow);
|
||||
|
||||
var relativeNode = null;
|
||||
|
||||
// If there are selected items, try to create the dummy item relative to the
|
||||
// best item, and position the bookmark there when created. Otherwise just
|
||||
// append to the root.
|
||||
if (aSelectedItem && aSelectedItem.localName != "tree") {
|
||||
// By default, create adjacent to the selected item
|
||||
relativeNode = aSelectedItem;
|
||||
if (relativeNode.getAttribute("container") == "true" &&
|
||||
relativeNode.getAttribute("open") == "true") {
|
||||
// But if it's an open container, the relative node should be the last child.
|
||||
var treechildren = ContentUtils.childByLocalName(relativeNode, "treechildren");
|
||||
if (treechildren && treechildren.hasChildNodes())
|
||||
relativeNode = treechildren.lastChild;
|
||||
}
|
||||
|
||||
if (dummyItem.getAttribute("open") == "true") {
|
||||
var treechildren = ContentUtils.childByLocalName(aSelectedItem, "treechildren");
|
||||
if (!treechildren) {
|
||||
const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
treechildren = document.createElementNS(kXULNS, "treechildren");
|
||||
aSelectedItem.appendChild(treechildren);
|
||||
if (aSelectedItem.getAttribute("container") == "true") {
|
||||
if (aSelectedItem.getAttribute("open") == "true") {
|
||||
var treechildren = ContentUtils.childByLocalName(aSelectedItem, "treechildren");
|
||||
if (!treechildren) {
|
||||
treechildren = document.createElementNS(kXULNS, "treechildren");
|
||||
aSelectedItem.appendChild(treechildren);
|
||||
}
|
||||
// Insert new item after last item.
|
||||
treechildren.appendChild(dummyItem);
|
||||
}
|
||||
// Insert new item after last item.
|
||||
treechildren.appendChild(dummyItem);
|
||||
else {
|
||||
if (aSelectedItem.nextSibling)
|
||||
aSelectedItem.parentNode.insertBefore(dummyItem, aSelectedItem.nextSibling);
|
||||
else
|
||||
aSelectedItem.parentNode.appendChild(dummyItem);
|
||||
}
|
||||
var index = gBookmarksShell.tree.getIndexOfItem(dummyItem);
|
||||
gBookmarksShell.tree.ensureIndexIsVisible(index);
|
||||
}
|
||||
else {
|
||||
if (aSelectedItem.nextSibling)
|
||||
@ -261,19 +287,16 @@ BookmarksTree.prototype = {
|
||||
else
|
||||
aSelectedItem.parentNode.appendChild(dummyItem);
|
||||
}
|
||||
var index = gBookmarksShell.tree.getIndexOfItem(dummyItem);
|
||||
gBookmarksShell.tree.ensureIndexIsVisible(index);
|
||||
}
|
||||
else {
|
||||
if (aSelectedItem.nextSibling)
|
||||
aSelectedItem.parentNode.insertBefore(dummyItem, aSelectedItem.nextSibling);
|
||||
else
|
||||
aSelectedItem.parentNode.appendChild(dummyItem);
|
||||
// No items in the tree. Append to the root.
|
||||
var rootKids = document.getElementById("treechildren-bookmarks");
|
||||
rootKids.appendChild(dummyItem);
|
||||
}
|
||||
editCell.setMode("edit");
|
||||
var fn = aMode == "folder" ? this.onEditFolderName : this.onEditBookmarkName;
|
||||
editCell.addObserver(fn, "accept", [editCell, relativeNode, dummyItem]);
|
||||
editCell.addObserver(fn, "reject", [editCell, relativeNode, dummyItem]);
|
||||
|
||||
dummyCell.setMode("edit");
|
||||
dummyCell.addObserver(this.onEditFolderName, "accept", [dummyCell, relativeNode, dummyItem]);
|
||||
dummyCell.addObserver(this.onEditFolderName, "reject", [dummyCell, relativeNode, dummyItem]);
|
||||
}
|
||||
},
|
||||
|
||||
@ -335,11 +358,11 @@ BookmarksTree.prototype = {
|
||||
var seln = this.getSelection ();
|
||||
if (seln.length < 1) {
|
||||
var kids = ContentUtils.childByLocalName(this.tree, "treechildren");
|
||||
if (kids) return kids.lastChild;
|
||||
return kids.lastChild || this.tree;
|
||||
}
|
||||
else
|
||||
return seln[0];
|
||||
return null;
|
||||
return this.tree;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -359,18 +382,18 @@ BookmarksTree.prototype = {
|
||||
if (selectedItems[i] == aItemNode)
|
||||
return selectedItems;
|
||||
}
|
||||
this.tree.selectItem(aItemNode);
|
||||
return this.tree.selectedItems;
|
||||
if (aItemNode.localName == "treeitem")
|
||||
this.tree.selectItem(aItemNode);
|
||||
return this.tree.selectedItems.length ? this.tree.selectedItems : [this.tree];
|
||||
},
|
||||
|
||||
getSelectedFolder: function ()
|
||||
{
|
||||
var selectedItem = this.getBestItem();
|
||||
if (!selectedItem) return "NC:BookmarksRoot";
|
||||
// If we don't check for localName we walk the DOM tree up to the window node,
|
||||
// which is Bad.
|
||||
while (selectedItem.localName == "treeitem") {
|
||||
if (selectedItem.getAttribute("container") == "true")
|
||||
while (selectedItem && selectedItem.nodeType == Node.ELEMENT_NODE) {
|
||||
if (selectedItem.getAttribute("container") == "true" &&
|
||||
selectedItem.getAttribute("open") == "true")
|
||||
return NODE_ID(selectedItem);
|
||||
selectedItem = selectedItem.parentNode.parentNode;
|
||||
}
|
||||
@ -388,22 +411,6 @@ BookmarksTree.prototype = {
|
||||
return temp || this.tree;
|
||||
},
|
||||
|
||||
beginBatch: function ()
|
||||
{
|
||||
/*
|
||||
var bo = this.tree.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);
|
||||
bo.beginBatch();
|
||||
*/
|
||||
},
|
||||
|
||||
endBatch: function ()
|
||||
{
|
||||
/*
|
||||
var bo = this.tree.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);
|
||||
bo.endBatch();
|
||||
*/
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Tree click events. This handles when to go into inline-edit mode for
|
||||
// editable cells.
|
||||
@ -418,6 +425,10 @@ BookmarksTree.prototype = {
|
||||
++gSelectionTracker.clickCount;
|
||||
else
|
||||
gSelectionTracker.clickCount = 0;
|
||||
|
||||
if (!this.tree.currentItem)
|
||||
return;
|
||||
|
||||
gSelectionTracker.currentItem = this.tree.currentItem;
|
||||
gSelectionTracker.currentCell = aEvent.target;
|
||||
|
||||
@ -523,6 +534,7 @@ BookmarksTree.prototype = {
|
||||
case "cmd_setnewsearchfolder":
|
||||
case "cmd_import":
|
||||
case "cmd_export":
|
||||
case "cmd_bm_fileBookmark":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -563,19 +575,25 @@ BookmarksTree.prototype = {
|
||||
return numSelectedItems == 1;
|
||||
case "cmd_setnewbookmarkfolder":
|
||||
seln = gBookmarksShell.tree.selectedItems;
|
||||
if (!seln.length) return false;
|
||||
var folderType = seln[0].getAttribute("type") == (NC_NS + "Folder");
|
||||
return numSelectedItems == 1 && !(NODE_ID(seln[0]) == "NC:NewBookmarkFolder") && folderType;
|
||||
var firstSelected = seln.length ? seln[0] : gBookmarksShell.tree;
|
||||
var folderType = firstSelected.getAttribute("type") == (NC_NS + "Folder");
|
||||
var bItemCountCorrect = seln.length ? numSelectedItems == 1 : true;
|
||||
return bItemCountCorrect && !(NODE_ID(firstSelected) == "NC:NewBookmarkFolder") && folderType;
|
||||
case "cmd_setpersonaltoolbarfolder":
|
||||
seln = gBookmarksShell.tree.selectedItems;
|
||||
if (!seln.length) return false;
|
||||
folderType = seln[0].getAttribute("type") == (NC_NS + "Folder");
|
||||
return numSelectedItems == 1 && !(NODE_ID(seln[0]) == "NC:PersonalToolbarFolder") && folderType;
|
||||
var firstSelected = seln.length ? seln[0] : gBookmarksShell.tree;
|
||||
var folderType = firstSelected.getAttribute("type") == (NC_NS + "Folder");
|
||||
var bItemCountCorrect = seln.length ? numSelectedItems == 1 : true;
|
||||
return bItemCountCorrect && !(NODE_ID(firstSelected) == "NC:PersonalToolbarFolder") && folderType;
|
||||
case "cmd_setnewsearchfolder":
|
||||
seln = gBookmarksShell.tree.selectedItems;
|
||||
if (!seln.length) return false;
|
||||
folderType = seln[0].getAttribute("type") == (NC_NS + "Folder");
|
||||
return numSelectedItems == 1 && !(NODE_ID(seln[0]) == "NC:NewSearchFolder") && folderType;
|
||||
var firstSelected = seln.length ? seln[0] : gBookmarksShell.tree;
|
||||
var folderType = firstSelected.getAttribute("type") == (NC_NS + "Folder");
|
||||
var bItemCountCorrect = seln.length ? numSelectedItems == 1 : true;
|
||||
return bItemCountCorrect == 1 && !(NODE_ID(firstSelected) == "NC:NewSearchFolder") && folderType;
|
||||
case "cmd_bm_fileBookmark":
|
||||
var seln = gBookmarksShell.tree.selectedItems;
|
||||
return seln.length > 0;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -605,6 +623,7 @@ BookmarksTree.prototype = {
|
||||
case "cmd_find":
|
||||
case "cmd_import":
|
||||
case "cmd_export":
|
||||
case "cmd_bm_fileBookmark":
|
||||
gBookmarksShell.execCommand(aCommand.substring("cmd_".length));
|
||||
break;
|
||||
case "cmd_bm_selectAll":
|
||||
@ -627,7 +646,8 @@ BookmarksTree.prototype = {
|
||||
var commands = ["cmd_properties", "cmd_rename", "cmd_bm_copy",
|
||||
"cmd_bm_paste", "cmd_bm_cut", "cmd_bm_delete",
|
||||
"cmd_setpersonaltoolbarfolder", "cmd_setnewbookmarkfolder",
|
||||
"cmd_setnewsearchfolder"];
|
||||
"cmd_setnewsearchfolder", "cmd_bm_fileBookmark",
|
||||
"cmd_openfolderinnewwindow", "cmd_openfolder"];
|
||||
for (var i = 0; i < commands.length; ++i)
|
||||
goUpdateCommand(commands[i]);
|
||||
}
|
||||
|
63
xpfe/components/bookmarks/resources/findBookmark.js
Normal file
63
xpfe/components/bookmarks/resources/findBookmark.js
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
function Startup()
|
||||
{
|
||||
doSetOKCancel(find);
|
||||
var bundle = document.getElementById("bookmarksBundle");
|
||||
document.getElementById("ok").label = bundle.getString("search_button_label");
|
||||
document.getElementById("searchField").focus();
|
||||
}
|
||||
|
||||
function find()
|
||||
{
|
||||
// Build up a find URI from the search fields and open a new window
|
||||
// rooted on the URI.
|
||||
var match = document.getElementById("matchList");
|
||||
var method = document.getElementById("methodList");
|
||||
var field = document.getElementById("searchField");
|
||||
var searchURI = "find:datasource=rdf:bookmarks"
|
||||
searchURI += "&match=" + match.selectedItem.value;
|
||||
searchURI += "&method=" + method.selectedItem.value;
|
||||
searchURI += "&text=" + escape(field.value);
|
||||
var bmWindow = findMostRecentWindow("bookmarks:searchresults", "chrome://communicator/content/bookmarks/bookmarks.xul", searchURI);
|
||||
|
||||
// Update the root of the tree if we're using an existing search window.
|
||||
if (!gCreatingNewWindow)
|
||||
bmWindow.gBookmarksShell.setRoot(searchURI);
|
||||
|
||||
bmWindow.focus();
|
||||
close();
|
||||
}
|
||||
|
||||
var gCreatingNewWindow = false;
|
||||
function findMostRecentWindow(aType, aURI, aParam)
|
||||
{
|
||||
var WM = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
||||
WM = WM.QueryInterface(Components.interfaces.nsIWindowMediator);
|
||||
var topWindow = WM.getMostRecentWindow(aType);
|
||||
if (!topWindow) gCreatingNewWindow = true;
|
||||
return topWindow || openDialog("chrome://communicator/content/bookmarks/bookmarks.xul",
|
||||
"", "chrome,all,dialog=no", aParam);
|
||||
}
|
||||
|
74
xpfe/components/bookmarks/resources/findBookmark.xul
Normal file
74
xpfe/components/bookmarks/resources/findBookmark.xul
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- -*- Mode: HTML; indent-tabs-mode: nil; -*- -->
|
||||
<!--
|
||||
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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):
|
||||
Ben Goodger <ben@netscape.com> (Original Author)
|
||||
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://communicator/locale/bookmarks/findBookmark.dtd">
|
||||
|
||||
<window id="findBookmarkWindow" style="width: 36em;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&findBookmark.title;"
|
||||
orient="vertical" class="dialog"
|
||||
onload="Startup();">
|
||||
|
||||
<keyset id="dialogKeys"/>
|
||||
|
||||
<stringbundle id="bookmarksBundle" src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/findBookmark.js"/>
|
||||
|
||||
<text class="label" value="&search.for.label;"/>
|
||||
<hbox autostretch="never" valign="middle">
|
||||
<menulist id="matchList" class="menulist-toolbar">
|
||||
<menupopup>
|
||||
<menuitem value="http://home.netscape.com/NC-rdf#Name" label="&search.name.label;"/>
|
||||
<menuitem value="http://home.netscape.com/NC-rdf#URL" label="&search.url.label;"/>
|
||||
<menuitem value="http://home.netscape.com/NC-rdf#Description" label="&search.description.label;"/>
|
||||
<menuitem value="http://home.netscape.com/NC-rdf#ShortcutURL" label="&search.shortcut.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<menulist id="methodList" class="menulist-toolbar">
|
||||
<menupopup>
|
||||
<menuitem value="contains" label="&search.contains.label;"/>
|
||||
<menuitem value="startswith" label="&search.startswith.label;"/>
|
||||
<menuitem value="endswith" label="&search.endswith.label;"/>
|
||||
<menuitem value="is" label="&search.is.label;"/>
|
||||
<menuitem value="isnot" label="&search.isnot.label;"/>
|
||||
<menuitem value="doesntcontain" label="&search.doesntcontain.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<textbox id="searchField" onkeypress="if (event.keyCode == 13) find();" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
<separator/>
|
||||
|
||||
<box id="okCancelButtonsRight"/>
|
||||
|
||||
</window>
|
@ -32,6 +32,8 @@ comm.jar:
|
||||
content/communicator/bookmarks/bookmarksOverlay.js
|
||||
content/communicator/bookmarks/bookmarksPanel.xul
|
||||
content/communicator/bookmarks/bookmarksPanel.js
|
||||
content/communicator/bookmarks/findBookmark.js
|
||||
content/communicator/bookmarks/findBookmark.xul
|
||||
content/communicator/bookmarks/pref-bookmarks.xul
|
||||
content/communicator/bookmarks/oTest.xul
|
||||
|
||||
@ -42,4 +44,5 @@ en-US.jar:
|
||||
locale/en-US/communicator/bookmarks/bookmarks.dtd (locale/en-US/bookmarks.dtd)
|
||||
locale/en-US/communicator/bookmarks/bookmark.properties (locale/en-US/bookmark.properties)
|
||||
locale/en-US/communicator/bookmarks/bookmarksOverlay.dtd (locale/en-US/bookmarksOverlay.dtd)
|
||||
locale/en-US/communicator/bookmarks/findBookmark.dtd (locale/en-US/findBookmark.dtd)
|
||||
locale/en-US/communicator/bookmarks/pref-bookmarks.dtd (locale/en-US/pref-bookmarks.dtd)
|
||||
|
@ -30,6 +30,7 @@ cmd_bm_selectAll = Select All
|
||||
cmd_rename = Rename...
|
||||
cmd_renamebookmark2 = Change Location...
|
||||
cmd_properties = Properties
|
||||
cmd_bm_fileBookmark = File Bookmark(s)...
|
||||
|
||||
cmd_openfolderinnewwindow = Open in New Window
|
||||
cmd_newfolder = New Folder...
|
||||
@ -43,6 +44,7 @@ ile_newfolder = New Folder
|
||||
ile_newbookmark = New Bookmark
|
||||
|
||||
window_title = %folder_name% - Bookmarks
|
||||
search_results_title = Search Results
|
||||
|
||||
file_in = File in "%folder_name%"
|
||||
|
||||
@ -70,3 +72,5 @@ DefaultPersonalToolbarFolder = Personal Toolbar Folder
|
||||
SelectImport = Import bookmark file:
|
||||
EnterExport = Export bookmark file:
|
||||
|
||||
search_button_label = Find
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
<!ENTITY edit.properties.keybinding "i">
|
||||
<!ENTITY command.rename.label "Rename...">
|
||||
<!ENTITY command.delete.label "Delete">
|
||||
<!ENTITY command.fileBookmark.label "File Bookmark">
|
||||
<!ENTITY command.fileBookmark.label "File Bookmark(s)...">
|
||||
<!ENTITY command.fileBookmark.accesskey "l">
|
||||
<!ENTITY command.addBookmark.label "Add...">
|
||||
<!ENTITY command.manageBookmarks.label "Manage">
|
||||
@ -71,7 +71,3 @@
|
||||
<!ENTITY tree.header.description.label "Description">
|
||||
<!ENTITY bookmarksWindowTitle.label "Bookmarks">
|
||||
|
||||
|
||||
<!ENTITY search.name.label "name">
|
||||
<!ENTITY search.contains.label "contains">
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
|
||||
<!ENTITY search.name.label "name">
|
||||
<!ENTITY search.url.label "location">
|
||||
<!ENTITY search.shortcut.label "keyword">
|
||||
<!ENTITY search.description.label "description">
|
||||
<!ENTITY search.startswith.label "starts with">
|
||||
<!ENTITY search.endswith.label "ends with">
|
||||
<!ENTITY search.is.label "is">
|
||||
<!ENTITY search.isnot.label "is not">
|
||||
<!ENTITY search.contains.label "contains">
|
||||
<!ENTITY search.doesntcontain.label "doesn't contain">
|
||||
<!ENTITY search.for.label "Find Bookmarks whose">
|
||||
<!ENTITY findBookmark.title "Find Bookmarks">
|
||||
|
@ -77,12 +77,42 @@
|
||||
obo.getCoordsForCellItem(row.value, col.value, elt.value, x, y, w, h, crp);
|
||||
dump("*** (x,y) = (" + x.value + "," + y.value + "); (w,h) = (" + w.value + "," + h.value + ");\n");
|
||||
}
|
||||
|
||||
const kRDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
function createContextMenu (aEvent)
|
||||
{
|
||||
var outliner = document.getElementById("outliner-proper");
|
||||
var obo = outliner.boxObject.QueryInterface(Components.interfaces.nsIOutlinerBoxObject);
|
||||
var row = { };
|
||||
var col = { };
|
||||
var elt = { };
|
||||
obo.getCellAt(aEvent.clientX, aEvent.clientY, row, col, elt);
|
||||
dump("*** row.value = " + row.value + "\n")
|
||||
|
||||
var outlinerBody = document.getElementById("tree");
|
||||
var rowResource = outlinerBody.builder.getResourceAtIndex(row.value);
|
||||
|
||||
const kRDFSvcContractID = "@mozilla.org/rdf/rdf-service;1";
|
||||
const kRDFSvcIID = Components.interfaces.nsIRDFService;
|
||||
const kRDFSvc = Components.classes[kRDFSvcContractID].getService(kRDFSvcIID);
|
||||
var database = outlinerBody.database;
|
||||
|
||||
const krType = kRDFSvc.GetResource(kRDF_NS + "type");
|
||||
var typeNode = kDatabase.GetTarget(rowResource, krType, true);
|
||||
typeNode = typeNode.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
dump("*** typeNode = " + typeNode.Value + "\n");
|
||||
aEvent.preventBubble();
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<!-- tooltips -->
|
||||
<popupset id="aTooltipSet"/>
|
||||
|
||||
<popupset id="contextSet">
|
||||
<popup id="bookmarkContextMenu" oncreate="createContextMenu(event);"/>
|
||||
</popupset>
|
||||
|
||||
<toolbox>
|
||||
<toolbar>
|
||||
<button class="button-toolbar-2" label="Foopy Noopy" oncommand="alert('hi');"/>
|
||||
@ -96,7 +126,7 @@
|
||||
</bulletinboard>
|
||||
</stack>
|
||||
|
||||
<outliner flex="1" flags="dont-test-empty" id="outliner-proper" titletiptext="Foopy Noopy!">
|
||||
<outliner flex="1" flags="dont-test-empty" id="outliner-proper">
|
||||
<outlinercol id="NameColumn"
|
||||
class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
flex="1"
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsLocalSearchService.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "xp_core.h"
|
||||
@ -470,84 +471,102 @@ LocalSearchDataSource::dateMatches(nsIRDFDate *aDate,
|
||||
NS_METHOD
|
||||
LocalSearchDataSource::parseFindURL(nsIRDFResource *u, nsISupportsArray *array)
|
||||
{
|
||||
findTokenStruct tokens[5];
|
||||
nsresult rv;
|
||||
findTokenStruct tokens[5];
|
||||
nsresult rv;
|
||||
|
||||
/* build up a token list */
|
||||
tokens[0].token = "datasource";
|
||||
tokens[1].token = "match";
|
||||
tokens[2].token = "method";
|
||||
tokens[3].token = "text";
|
||||
tokens[4].token = NULL;
|
||||
// build up a token list
|
||||
tokens[0].token = "datasource";
|
||||
tokens[1].token = "match";
|
||||
tokens[2].token = "method";
|
||||
tokens[3].token = "text";
|
||||
tokens[4].token = NULL;
|
||||
|
||||
// parse find URI, get parameters, search in appropriate
|
||||
// datasource(s), return results
|
||||
rv = parseResourceIntoFindTokens(u, tokens);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString dsName;
|
||||
dsName.AssignWithConversion(tokens[0].value);
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> datasource;
|
||||
rv = gRDFService->GetDataSource(dsName, getter_AddRefs(datasource));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> cursor;
|
||||
rv = datasource->GetAllResources(getter_AddRefs(cursor));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (PR_TRUE)
|
||||
{
|
||||
PRBool hasMore;
|
||||
rv = cursor->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
if (! hasMore)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
rv = cursor->GetNext(getter_AddRefs(isupports));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> source(do_QueryInterface(isupports));
|
||||
if (!source) continue;
|
||||
|
||||
const char *uri = nsnull;
|
||||
source->GetValueConst(&uri);
|
||||
// parse find URI, get parameters, search in appropriate
|
||||
// datasource(s), return results
|
||||
rv = parseResourceIntoFindTokens(u, tokens);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!uri) continue;
|
||||
|
||||
// never match against a "find:" URI
|
||||
if (PL_strncmp(uri, kFindProtocol, sizeof(kFindProtocol)-1) == 0)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
rv = gRDFService->GetUnicodeResource(tokens[1].value.GetUnicode(),
|
||||
getter_AddRefs(property));
|
||||
|
||||
if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE) || !property)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> value;
|
||||
rv = datasource->GetTarget(source, property,
|
||||
PR_TRUE, getter_AddRefs(value));
|
||||
if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE) || !value)
|
||||
continue;
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
found = matchNode(value, tokens[2].value, tokens[3].value);
|
||||
|
||||
if (found)
|
||||
array->AppendElement(source);
|
||||
}
|
||||
nsCAutoString dsName;
|
||||
dsName.AssignWithConversion(tokens[0].value);
|
||||
|
||||
if (rv == NS_RDF_CURSOR_EMPTY)
|
||||
{
|
||||
rv = NS_OK;
|
||||
}
|
||||
return(rv);
|
||||
nsCOMPtr<nsIRDFDataSource> datasource;
|
||||
rv = gRDFService->GetDataSource(dsName, getter_AddRefs(datasource));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> cursor;
|
||||
rv = datasource->GetAllResources(getter_AddRefs(cursor));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
while (PR_TRUE) {
|
||||
PRBool hasMore;
|
||||
rv = cursor->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
if (!hasMore)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
rv = cursor->GetNext(getter_AddRefs(isupports));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> source(do_QueryInterface(isupports));
|
||||
if (!source)
|
||||
continue;
|
||||
|
||||
const char *uri = nsnull;
|
||||
source->GetValueConst(&uri);
|
||||
|
||||
if (!uri)
|
||||
continue;
|
||||
|
||||
// never match against a "find:" URI
|
||||
if (PL_strncmp(uri, kFindProtocol, sizeof(kFindProtocol)-1) == 0)
|
||||
continue;
|
||||
|
||||
// never match against a container. Searching for folders just isn't
|
||||
// much of a utility, and this fixes an infinite recursion crash. (65063)
|
||||
PRBool isContainer = PR_FALSE;
|
||||
|
||||
// Check to see if this source is an RDF container
|
||||
nsCOMPtr<nsIRDFContainerUtils> cUtils(do_GetService("@mozilla.org/rdf/container-utils;1"));
|
||||
if (cUtils)
|
||||
cUtils->IsContainer(datasource, source, &isContainer);
|
||||
// Check to see if this source is a pseudo-container
|
||||
if (!isContainer)
|
||||
datasource->HasArcOut(source, kNC_Child, &isContainer);
|
||||
|
||||
if (isContainer)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
rv = gRDFService->GetUnicodeResource(tokens[1].value.GetUnicode(),
|
||||
getter_AddRefs(property));
|
||||
|
||||
if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE) || !property)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> value;
|
||||
rv = datasource->GetTarget(source, property,
|
||||
PR_TRUE, getter_AddRefs(value));
|
||||
if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE) || !value)
|
||||
continue;
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
found = matchNode(value, tokens[2].value, tokens[3].value);
|
||||
|
||||
if (found)
|
||||
array->AppendElement(source);
|
||||
}
|
||||
|
||||
if (rv == NS_RDF_CURSOR_EMPTY)
|
||||
rv = NS_OK;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// could speed up date/integer matching signifigantly by caching the
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben "Count XULula" Goodger <ben@netscape.com>
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
/** Presenting widgetStateManager the Third.
|
||||
@ -307,7 +307,11 @@ nsWidgetStateManager.prototype =
|
||||
function ( aElementID, aDataObject )
|
||||
{
|
||||
var element = wsm.contentArea.document.getElementById( aElementID );
|
||||
// Set generic properites.
|
||||
wsm.generic_Set( element, aDataObject );
|
||||
// Handle reversed boolean values.
|
||||
if ( "checked" in aDataObject && element.getAttribute( "reversed" ) == "true" )
|
||||
element.checked = !aDataObject.checked;
|
||||
},
|
||||
|
||||
get_Checkbox:
|
||||
@ -317,7 +321,8 @@ nsWidgetStateManager.prototype =
|
||||
var dataObject = wsm.generic_Get( element );
|
||||
if( dataObject )
|
||||
{
|
||||
dataObject.checked = wsm.contentArea.document.getElementById( aElementID ).checked;
|
||||
var checked = wsm.contentArea.document.getElementById( aElementID ).checked;
|
||||
dataObject.checked = element.getAttribute("reversed") == "true" ? !checked : checked;
|
||||
return dataObject;
|
||||
}
|
||||
return null;
|
||||
@ -341,8 +346,9 @@ nsWidgetStateManager.prototype =
|
||||
}
|
||||
|
||||
|
||||
/* it will be dark soon */
|
||||
/* MANOS MADE ME PERMANENT! */
|
||||
/* there is no way out of here */
|
||||
|
||||
// M:tHoF Greatest Hits Section (Append one line per edit):
|
||||
// it will be dark soon
|
||||
// MANOS MADE ME PERMANENT!
|
||||
// there is no way out of here
|
||||
// [The Master] not dead as you know it. He is with us always.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user