зеркало из https://github.com/mozilla/pjs.git
fix for 17920, r=hyatt, sr=sfraser, scc.
This commit is contained in:
Родитель
3ad651ca3b
Коммит
9de468a218
|
@ -61,7 +61,7 @@
|
|||
<popupset id="popupset"/>
|
||||
|
||||
<!-- bookmarks string bundle -->
|
||||
<stringbundleset id="bookmarksStringBundles"/>
|
||||
<stringbundleset id="stringbundleset"/>
|
||||
|
||||
<!-- bookmarks & edit commands -->
|
||||
<commands id="commands">
|
||||
|
@ -106,14 +106,14 @@
|
|||
<treechildren>
|
||||
<treeitem uri="rdf:*" persist="open" class="bookmark-item"
|
||||
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">
|
||||
<treerow>
|
||||
<treecell class="treecell-indent treecell-editable"
|
||||
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" />
|
||||
</treerow>
|
||||
</treeitem>
|
||||
|
|
|
@ -47,58 +47,17 @@ function Startup()
|
|||
windowNode.setAttribute("title", titleString.replace(/%folder_name%/gi, rName));
|
||||
}
|
||||
else {
|
||||
// There's a better way of doing this, but for the initial revision just
|
||||
// using the root folder in the bookmarks window will do.
|
||||
// For the next milestone I'd like to move this either into the bookmarks
|
||||
// service or some other higher level datasource so that it can be accessed
|
||||
// from everywhere.
|
||||
const kRDF = gBookmarksShell.RDF;
|
||||
const krNavCenter = kRDF.GetResource("NC:NavCenter");
|
||||
const kRDFCUtilsContractID = "@mozilla.org/rdf/container-utils;1";
|
||||
const kRDFCUtilsIID = Components.interfaces.nsIRDFContainerUtils;
|
||||
const kRDFCUtils = Components.classes[kRDFCUtilsContractID].getService(kRDFCUtilsIID);
|
||||
const kNC_NavCenter = kRDFCUtils.MakeSeq(gBookmarksShell.db, krNavCenter);
|
||||
const krBookmarksRoot = kRDF.GetResource("NC:BookmarksRoot");
|
||||
const krName = kRDF.GetResource(NC_NS + "Name");
|
||||
var rootfoldername = gBookmarksShell.getLocaleString("bookmarks_root");
|
||||
const kProfileContractID = "@mozilla.org/profile/manager;1";
|
||||
const kProfileIID = Components.interfaces.nsIProfile;
|
||||
const kProfile = Components.classes[kProfileContractID].getService(kProfileIID);
|
||||
rootfoldername = rootfoldername.replace(/%user_name%/, kProfile.currentProfile);
|
||||
const klBookmarksRootName = kRDF.GetLiteral(rootfoldername);
|
||||
const kBMDS = kRDF.GetDataSource("rdf:bookmarks");
|
||||
kBMDS.Assert(krBookmarksRoot, krName, klBookmarksRootName, true);
|
||||
kNC_NavCenter.AppendElement(krBookmarksRoot);
|
||||
windowNode.setAttribute("title", rootfoldername);
|
||||
|
||||
/* Blue Sky
|
||||
const krHistoryRoot = kRDF.GetResource("NC:HistoryRoot");
|
||||
const klHistoryRootName = kRDF.GetLiteral("Browsing History");
|
||||
const kHistory = kRDF.GetDataSource("rdf:history");
|
||||
kHistory.Assert(krHistoryRoot, krName, klHistoryRootName, true);
|
||||
kNC_NavCenter.AppendElement(krHistoryRoot);
|
||||
*/
|
||||
|
||||
const krType = kRDF.GetResource(RDF_NS + "type");
|
||||
const krFolderType = kRDF.GetResource(NC_NS + "Folder");
|
||||
gBookmarksShell.db.Assert(krNavCenter, krType, krFolderType, true);
|
||||
}
|
||||
|
||||
// Update to the last sort.
|
||||
RefreshSort();
|
||||
|
||||
// Initialize the tree widget.
|
||||
var children = document.getElementById("treechildren-bookmarks");
|
||||
if (children.firstChild) {
|
||||
bookmarksTree.selectItem(children.firstChild);
|
||||
children.firstChild.setAttribute("open", "true");
|
||||
}
|
||||
|
||||
// XXX templates suck ASS
|
||||
var node = document.getElementById("NC:BookmarksRoot");
|
||||
if (node.localName == "menubutton")
|
||||
node.removeAttribute("open");
|
||||
|
||||
bookmarksTree.focus();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,14 @@
|
|||
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksDD.js"/>
|
||||
|
||||
<commandset id="tasksCommands">
|
||||
<commands id="commands">
|
||||
<commandset id="CommandUpdate_Bookmarks"
|
||||
commandupdater="true"
|
||||
events="focus,tree-select"
|
||||
oncommandupdate="BookmarksTree.prototype.controller.onCommandUpdate()">
|
||||
</commandset>
|
||||
|
||||
<commandset id="tasksCommands"/>
|
||||
<commandset id="bookmarksItems"/>
|
||||
|
||||
<!-- File Menu -->
|
||||
|
@ -78,11 +85,11 @@
|
|||
<command id="cmd_quit"/>
|
||||
<!-- Edit Menu -->
|
||||
<command id="cmd_undo"/>
|
||||
</commandset>
|
||||
</commands>
|
||||
|
||||
<popupset id="popupset"/>
|
||||
|
||||
<stringbundleset id="bookmarksStringBundles"/>
|
||||
<stringbundleset id="stringbundleset"/>
|
||||
|
||||
<keyset id="tasksKeys">
|
||||
<!-- File Menu -->
|
||||
|
@ -232,8 +239,8 @@
|
|||
</toolbar>
|
||||
</toolbox>
|
||||
|
||||
<tree id="bookmarksTree" class="bookmarks-window-tree" context="bmContext" ref="NC:NavCenter"
|
||||
datasources="rdf:bookmarks rdf:files rdf:httpindex rdf:localsearch rdf:internetsearch"
|
||||
<tree id="bookmarksTree" class="bookmarks-window-tree" context="bmContext" ref="NC:BookmarksRoot"
|
||||
datasources="rdf:bookmarks rdf:localsearch rdf:internetsearch"
|
||||
multiple="true" flags="dont-test-empty"
|
||||
ondragover="nsDragAndDrop.dragOver(event, bookmarksDNDObserver);"
|
||||
ondraggesture="nsDragAndDrop.startDrag(event, bookmarksDNDObserver);"
|
||||
|
|
|
@ -25,12 +25,26 @@ var NC_NS = "http://home.netscape.com/NC-rdf#";
|
|||
var RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
const NC_NS_CMD = NC_NS + "command?cmd=";
|
||||
|
||||
/**
|
||||
* XXX - 02/03/2001 - Work In Progress
|
||||
* - some of the methods here and in the derived classes in bookmarksTree.js
|
||||
* and bookmarks.js can probably be broken out into a shared library for RDF
|
||||
* utilities. So far the focus has been on getting this stuff to work, once
|
||||
* I'm done with that I'll look at what can be reorganized.
|
||||
/**
|
||||
* XXX - 04/16/01
|
||||
* ACK! massive command name collision problems are causing big issues
|
||||
* in getting this stuff to work in the Navigator window. For sanity's
|
||||
* sake, we need to rename all the commands to be of the form cmd_bm_*
|
||||
* otherwise there'll continue to be problems. For now, we're just
|
||||
* renaming those that affect the personal toolbar (edit operations,
|
||||
* which were clashing with the textfield controller)
|
||||
*
|
||||
* There are also several places that need to be updated if you need
|
||||
* to change a command name.
|
||||
* 1) the controller in ALL clients (bookmarksTree.js, personalToolbar.js)
|
||||
* 2) the command nodes in the overlay
|
||||
* 3) the command human-readable name key in bookmark.properties
|
||||
* 4) the function 'getAllCmds' in bookmarksOverlay.js
|
||||
* 5) the function 'execCommand' in bookmarksOverlay.js
|
||||
* Yes, this blows crusty dead goats through straws, and I should probably
|
||||
* create some constants somewhere to bring this number down to 3.
|
||||
* However, if you fail to do one of these, you WILL break something
|
||||
* and I WILL come after you with a knife.
|
||||
*/
|
||||
|
||||
function NODE_ID (aElement)
|
||||
|
@ -125,7 +139,9 @@ BookmarksUIElement.prototype = {
|
|||
if (!("findRDFNode" in this))
|
||||
throw "Clients must implement findRDFNode!";
|
||||
var itemNode = this.findRDFNode(popupNode, true);
|
||||
if (!itemNode) return false;
|
||||
if (!itemNode || !itemNode.getAttribute("type") || itemNode.getAttribute("mode") == "edit") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!("getContextSelection" in this))
|
||||
throw "Clients must implement getContextSelection!";
|
||||
|
@ -139,7 +155,10 @@ BookmarksUIElement.prototype = {
|
|||
commonCommands = this.findCommonNodes(commands, commonCommands);
|
||||
}
|
||||
|
||||
if (!commonCommands.length) return false;
|
||||
if (!commonCommands.length) {
|
||||
aEvent.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Now that we should have generated a list of commands that is valid
|
||||
// for the entire selection, build a context menu.
|
||||
|
@ -160,7 +179,7 @@ BookmarksUIElement.prototype = {
|
|||
if (element)
|
||||
popup.appendChild(element);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -200,28 +219,28 @@ BookmarksUIElement.prototype = {
|
|||
var commands = [];
|
||||
switch (type) {
|
||||
case "http://home.netscape.com/NC-rdf#BookmarkSeparator":
|
||||
commands = ["find", "separator", "cut", "copy", "paste",
|
||||
"delete"];
|
||||
commands = ["find", "separator", "bm_cut", "bm_copy", "bm_paste",
|
||||
"bm_delete", "separator", "newfolder"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#Bookmark":
|
||||
commands = ["open", "find", "separator", "cut", "copy", "paste",
|
||||
"delete", "separator", "rename", "separator",
|
||||
"properties"];
|
||||
commands = ["open", "find", "separator", "bm_cut", "bm_copy", "bm_paste",
|
||||
"bm_delete", "separator", "rename", "separator", "newfolder",
|
||||
"separator", "properties"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#Folder":
|
||||
commands = ["openfolder", "openfolderinnewwindow", "find", "separator",
|
||||
"cut", "copy", "paste", "delete", "separator", "rename",
|
||||
"bm_cut", "bm_copy", "bm_paste", "bm_delete", "separator", "rename",
|
||||
"separator", "newfolder", "separator", "properties"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#IEFavoriteFolder":
|
||||
commands = ["open", "find", "separator", "copy", "separator", "rename",
|
||||
commands = ["open", "find", "separator", "bm_copy", "separator", "rename",
|
||||
"separator", "properties"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#IEFavorite":
|
||||
commands = ["open", "find", "separator", "copy"];
|
||||
commands = ["open", "find", "separator", "bm_copy"];
|
||||
break;
|
||||
case "http://home.netscape.com/NC-rdf#FileSystemObject":
|
||||
commands = ["open", "find", "separator", "copy"];
|
||||
commands = ["open", "find", "separator", "bm_copy"];
|
||||
break;
|
||||
default:
|
||||
var source = this.RDF.GetResource(aNodeID);
|
||||
|
@ -244,7 +263,11 @@ BookmarksUIElement.prototype = {
|
|||
return this.getLocaleString ("cmd_" + cmdName);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
// XXX - WORK TO DO HERE! (rjc will cry if we don't fix this)
|
||||
// need to ask the ds for the commands for this node, however we don't
|
||||
// have the right params. This is kind of a problem.
|
||||
dump("*** BAD! EVIL! WICKED! NO! ACK! ARGH! ORGH!\n");
|
||||
const rName = this.RDF.GetResource(NC_NS + "Name");
|
||||
const rSource = this.RDF.GetResource(aNodeID);
|
||||
return this.db.GetTarget(rSource, rName, true).Value;
|
||||
|
@ -267,7 +290,7 @@ BookmarksUIElement.prototype = {
|
|||
var selectedItem = selection[0];
|
||||
switch (aCommandID) {
|
||||
case "open":
|
||||
this.openRDFNode(selectedItem);
|
||||
this.open(null, selectedItem);
|
||||
break;
|
||||
case "openfolder":
|
||||
this.commands.openFolder(selectedItem);
|
||||
|
@ -297,17 +320,17 @@ BookmarksUIElement.prototype = {
|
|||
case "find":
|
||||
this.findInBookmarks();
|
||||
break;
|
||||
case "cut":
|
||||
case "bm_cut":
|
||||
this.copySelection (selection);
|
||||
this.deleteSelection (selection);
|
||||
break;
|
||||
case "copy":
|
||||
case "bm_copy":
|
||||
this.copySelection (selection);
|
||||
break;
|
||||
case "paste":
|
||||
case "bm_paste":
|
||||
this.paste (selection);
|
||||
break;
|
||||
case "delete":
|
||||
case "bm_delete":
|
||||
this.deleteSelection (selection);
|
||||
break;
|
||||
case "newfolder":
|
||||
|
@ -429,7 +452,7 @@ BookmarksUIElement.prototype = {
|
|||
nodes = data.split("\n");
|
||||
break;
|
||||
case "text/x-moz-url":
|
||||
var ix = data.value.indexOf("\n");
|
||||
var ix = data.indexOf("\n");
|
||||
nodes.push(data.substring(0, ix != -1 ? ix : data.length));
|
||||
names.push(data.substring(ix));
|
||||
break;
|
||||
|
@ -447,8 +470,6 @@ BookmarksUIElement.prototype = {
|
|||
const ksRDFC = Components.classes[kRDFCContractID].getService(kRDFCIID);
|
||||
const kBMDS = this.RDF.GetDataSource("rdf:bookmarks");
|
||||
|
||||
if ("beginBatch" in this && nodes.length > 1)
|
||||
this.beginBatch();
|
||||
var additiveFlag = false;
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
if (!nodes[i]) continue;
|
||||
|
@ -459,24 +480,26 @@ BookmarksUIElement.prototype = {
|
|||
rType = rType.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
}
|
||||
catch (e) {
|
||||
rType = rType.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
try {
|
||||
rType = rType.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
}
|
||||
catch (e) {
|
||||
// OK, no type exists, so node does not exist in the graph.
|
||||
// (e.g. user pastes url as text)
|
||||
// Do some housekeeping.
|
||||
const krName = this.RDF.GetResource(names[i]);
|
||||
const krNameProperty = this.RDF.GetResource(NC_NS + "Name");
|
||||
const krBookmark = this.RDF.GetResource(NC_NS + "Bookmark");
|
||||
kBMDS.Assert(rCurrent, krNameProperty, krName, true);
|
||||
kBMDS.Assert(rCurrent, krTypeProperty, krBookmark, true);
|
||||
}
|
||||
}
|
||||
|
||||
// If the node is a folder, then we need to create a new anonymous
|
||||
// resource and copy all the arcs over.
|
||||
if (rType.Value == NC_NS + "Folder")
|
||||
if (rType && rType.Value == NC_NS + "Folder")
|
||||
rCurrent = BookmarksUtils.cloneFolder(rCurrent, krParent, krSource);
|
||||
|
||||
// If we are given names, this implies that the nodes do not already
|
||||
// exist in the graph, and we need to create some additional information
|
||||
// for them.
|
||||
if (names.length) {
|
||||
const krName = this.RDF.GetResource(names[i]);
|
||||
const krNameProperty = this.RDF.GetResource(NC_NS + "Name");
|
||||
const krBookmark = this.RDF.GetResource(NC_NS + "Bookmark");
|
||||
this.db.Assert(rCurrent, krNameProperty, krName, true);
|
||||
this.db.Assert(rCurrent, krTypeProperty, krBookmark, true);
|
||||
}
|
||||
ksRDFC.Init(kBMDS, krParent);
|
||||
ix = ksRDFC.IndexOf(krSource);
|
||||
if (ix != -1)
|
||||
|
@ -485,9 +508,10 @@ BookmarksUIElement.prototype = {
|
|||
ksRDFC.AppendElement(rCurrent);
|
||||
this.selectFolderItem(krSource.Value, rCurrent.Value, additiveFlag);
|
||||
if (!additiveFlag) additiveFlag = true;
|
||||
|
||||
var rds = kBMDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
|
||||
rds.Flush();
|
||||
}
|
||||
if ("endBatch" in this && nodes.length > 1)
|
||||
this.endBatch();
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -526,7 +550,6 @@ BookmarksUIElement.prototype = {
|
|||
|
||||
deleteSelection: function (aSelection)
|
||||
{
|
||||
dump("*** deleteSelection\n");
|
||||
const kRDFCContractID = "@mozilla.org/rdf/container;1";
|
||||
const kRDFCIID = Components.interfaces.nsIRDFContainer;
|
||||
const ksRDFC = Components.classes[kRDFCContractID].getService(kRDFCIID);
|
||||
|
@ -542,17 +565,19 @@ BookmarksUIElement.prototype = {
|
|||
// Disallow the removal of certain 'special' nodes
|
||||
if (kSelectionURI == "NC:BookmarksRoot" ||
|
||||
kSelectionURI == "NC:IEFavoritesRoot") {
|
||||
++count;
|
||||
aSelection.splice(count++,1);
|
||||
continue;
|
||||
}
|
||||
|
||||
const krParent = this.RDF.GetResource(NODE_ID(currParent));
|
||||
const krNode = this.RDF.GetResource(kSelectionURI);
|
||||
const krBookmark = this.RDF.GetResource(kSelectionURI);
|
||||
const kBMDS = this.RDF.GetDataSource("rdf:bookmarks");
|
||||
|
||||
ksRDFC.Init(kBMDS, krParent);
|
||||
nextElement = this.getNextElement(aSelection[count]);
|
||||
ksRDFC.RemoveElement(krNode, true);
|
||||
ksRDFC.RemoveElement(krBookmark, true);
|
||||
// Manipulate the selection array ourselves.
|
||||
aSelection.splice(count,1);
|
||||
|
||||
try {
|
||||
// XXX - UGH. Template builder is NOT removing the element from the
|
||||
|
@ -563,6 +588,8 @@ BookmarksUIElement.prototype = {
|
|||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
this.selectElement(nextElement);
|
||||
},
|
||||
|
@ -582,14 +609,6 @@ BookmarksUIElement.prototype = {
|
|||
kRDFC.RemoveElement(krSrc, true);
|
||||
},
|
||||
|
||||
openRDFNode: function (aRDFNode)
|
||||
{
|
||||
var urlValue = LITERAL(this.db, aRDFNode, NC_NS + "URL");
|
||||
// Ignore "NC:" and empty urls.
|
||||
if (urlValue.substring(0,3) == "NC:" || !urlValue) return;
|
||||
openDialog (getBrowserURL(), "_blank", "chrome,all,dialog=no", urlValue);
|
||||
},
|
||||
|
||||
open: function (aEvent, aRDFNode)
|
||||
{
|
||||
var urlValue = LITERAL(this.db, aRDFNode, NC_NS + "URL");
|
||||
|
@ -597,13 +616,14 @@ BookmarksUIElement.prototype = {
|
|||
// Ignore "NC:" and empty urls.
|
||||
if (urlValue.substring(0,3) == "NC:" || !urlValue) return;
|
||||
|
||||
if (aEvent.altKey)
|
||||
if (aEvent && aEvent.altKey)
|
||||
this.showPropertiesForNode (aRDFNode);
|
||||
else if (this.openNewWindow)
|
||||
openDialog (getBrowserURL(), "_blank", "chrome,all,dialog=no", urlValue);
|
||||
else
|
||||
openTopWin (urlValue);
|
||||
aEvent.preventBubble();
|
||||
if (aEvent)
|
||||
aEvent.preventBubble();
|
||||
},
|
||||
|
||||
showPropertiesForNode: function (aBookmarkItem)
|
||||
|
@ -618,7 +638,7 @@ BookmarksUIElement.prototype = {
|
|||
{
|
||||
openDialog("chrome://communicator/content/bookmarks/bm-find.xul",
|
||||
"FindBookmarksWindow",
|
||||
"centerscreen,chrome,resizable");
|
||||
"centerscreen,chrome,resizable,dialog=no");
|
||||
},
|
||||
|
||||
getLocaleString: function (aStringKey)
|
||||
|
@ -647,6 +667,15 @@ BookmarksUIElement.prototype = {
|
|||
catch (e) {
|
||||
return type.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
}
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// takes a node and adds the appropriate adornments for a bookmark container.
|
||||
createBookmarkFolderDecorations: function (aNode)
|
||||
{
|
||||
aNode.setAttribute("type", "http://home.netscape.com/NC-rdf#Folder");
|
||||
aNode.setAttribute("container", "true");
|
||||
return aNode;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -765,7 +794,7 @@ var BookmarksUtils = {
|
|||
return krAnonymous;
|
||||
},
|
||||
|
||||
addBookmarkForBrowser: function (aDocShell)
|
||||
addBookmarkForBrowser: function (aDocShell, aShowDialog)
|
||||
{
|
||||
// Bug 52536: We obtain the URL and title from the nsIWebNavigation
|
||||
// associated with a <browser/> rather than from a DOMWindow.
|
||||
|
@ -781,29 +810,19 @@ var BookmarksUtils = {
|
|||
catch (e) {
|
||||
title = url;
|
||||
}
|
||||
this.addBookmark(url, title, docCharset);
|
||||
this.addBookmark(url, title, docCharset, aShowDialog);
|
||||
},
|
||||
|
||||
addBookmark: function (aURL, aTitle, aCharset)
|
||||
addBookmark: function (aURL, aTitle, aCharset, aShowDialog)
|
||||
{
|
||||
if (aCharset === undefined) {
|
||||
var fw = document.commandDispatcher.focusedWindow;
|
||||
aCharset = fw.document.characterSet;
|
||||
}
|
||||
|
||||
const kPrefContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefContractID].getService(kPrefIID);
|
||||
var showDialog = true;
|
||||
try {
|
||||
showDialog = !kPrefSvc.GetBoolPref("browser.bookmarks.add_without_dialog");
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
if (showDialog)
|
||||
if (aShowDialog)
|
||||
openDialog("chrome://communicator/content/bookmarks/addBookmark.xul", "",
|
||||
"centerscreen,chrome,dialog=no,resizable=no", aTitle, aURL, null, aCharset);
|
||||
"centerscreen,chrome,dialog=no,resizable=yes", aTitle, aURL, null, aCharset);
|
||||
else {
|
||||
// User has elected to override the file dialog and always file bookmarks
|
||||
// into the default bookmark folder.
|
||||
|
@ -815,24 +834,19 @@ var BookmarksUtils = {
|
|||
}
|
||||
};
|
||||
|
||||
/* XXX Template problems
|
||||
function AggregationPrefListener ()
|
||||
{
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
kPrefSvc.addObserver(this.pref, this);
|
||||
}
|
||||
AggregationPrefListener.prototype = {
|
||||
pref: "browser.bookmarks.show_extended_data",
|
||||
Observe: function (subject, topic, prefName)
|
||||
var ContentUtils = {
|
||||
childByLocalName: function (aSelectedItem, aLocalName)
|
||||
{
|
||||
if (topic != "nsPref:changed") return;
|
||||
if (prefName != this.pref) return;
|
||||
gBookmarksShell.setUpCompositeDataSource();
|
||||
var temp = aSelectedItem.firstChild;
|
||||
while (temp) {
|
||||
if (temp.localName == aLocalName)
|
||||
return temp;
|
||||
temp = temp.nextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<overlay id="bookmarksOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<stringbundleset id="bookmarksStringBundles">
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="bookmarksbundle"
|
||||
src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
|
||||
</stringbundleset>
|
||||
|
@ -39,33 +39,33 @@
|
|||
oncreate="gBookmarksShell.createContextMenu(event);"/>
|
||||
</popupset>
|
||||
|
||||
<commandset id="bookmarksItems">
|
||||
<command id="cmd_open" oncommand="goDoCommand('cmd_open');"/>
|
||||
<command id="cmd_openfolder" oncommand="goDoCommand('cmd_openfolder');"/>
|
||||
<command id="cmd_newfolder" oncommand="goDoCommand('cmd_newfolder');"/>
|
||||
<command id="cmd_newbookmark" oncommand="goDoCommand('cmd_newbookmark');"/>
|
||||
<command id="cmd_newseparator" oncommand="goDoCommand('cmd_newseparator');"/>
|
||||
<command id="cmd_find" oncommand="goDoCommand('cmd_find');"/>
|
||||
<command id="cmd_setnewbookmarkfolder" oncommand="goDoCommand('cmd_setnewbookmarkfolder');"/>
|
||||
<command id="cmd_setpersonaltoolbarfolder" oncommand="goDoCommand('cmd_setpersonaltoolbarfolder');"/>
|
||||
<command id="cmd_setnewsearchfolder" oncommand="goDoCommand('cmd_setnewsearchfolder');"/>
|
||||
<command id="cmd_properties" oncommand="goDoCommand('cmd_properties');"/>
|
||||
<command id="cmd_rename" oncommand="goDoCommand('cmd_rename');"/>
|
||||
<command id="cmd_openfolderinnewwindow" oncommand="goDoCommand('cmd_openfolderinnewwindow');"/>
|
||||
<command id="cmd_import" oncommand="goDoCommand('cmd_import');"/>
|
||||
<command id="cmd_export" oncommand="goDoCommand('cmd_export');"/>
|
||||
<commandset id="CommandUpdate_Bookmarks"
|
||||
commandupdater="true"
|
||||
events="focus,tree-select"
|
||||
oncommandupdate="BookmarksTree.prototype.controller.onCommandUpdate()"/>
|
||||
<commands id="commands">
|
||||
<commandset id="bookmarksItems">
|
||||
<command id="cmd_open" oncommand="goDoCommand('cmd_open');"/>
|
||||
<command id="cmd_openfolder" oncommand="goDoCommand('cmd_openfolder');"/>
|
||||
<command id="cmd_newfolder" oncommand="goDoCommand('cmd_newfolder');"/>
|
||||
<command id="cmd_newbookmark" oncommand="goDoCommand('cmd_newbookmark');"/>
|
||||
<command id="cmd_newseparator" oncommand="goDoCommand('cmd_newseparator');"/>
|
||||
<command id="cmd_find" oncommand="goDoCommand('cmd_find');"/>
|
||||
<command id="cmd_setnewbookmarkfolder" oncommand="goDoCommand('cmd_setnewbookmarkfolder');"/>
|
||||
<command id="cmd_setpersonaltoolbarfolder" oncommand="goDoCommand('cmd_setpersonaltoolbarfolder');"/>
|
||||
<command id="cmd_setnewsearchfolder" oncommand="goDoCommand('cmd_setnewsearchfolder');"/>
|
||||
<command id="cmd_properties" oncommand="goDoCommand('cmd_properties');"/>
|
||||
<command id="cmd_rename" oncommand="goDoCommand('cmd_rename');"/>
|
||||
<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_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>
|
||||
<commandset id="selectEditMenuItems"/>
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
<command id="cmd_cut"/>
|
||||
<command id="cmd_copy"/>
|
||||
<command id="cmd_paste"/>
|
||||
<command id="cmd_delete"/>
|
||||
<command id="cmd_selectAll"/>
|
||||
</commandset>
|
||||
</commands>
|
||||
|
||||
</overlay>
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ BookmarksPanelTree.prototype = {
|
|||
// eventually we can bookmark mail messages and editor documents.
|
||||
var contentArea = top.document.getElementById('content');
|
||||
if (contentArea)
|
||||
BookmarksUtils.addBookmarkForBrowser(contentArea.webNavigation);
|
||||
BookmarksUtils.addBookmarkForBrowser(contentArea.webNavigation, true);
|
||||
},
|
||||
|
||||
manageBookmarks: function ()
|
||||
|
|
|
@ -55,8 +55,7 @@ BookmarksTree.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("observes", "cmd_" + aCommandName.substring(NC_NS_CMD.length));
|
||||
var node = xulElement.getAttribute('observes');
|
||||
xulElement.setAttribute("command", "cmd_" + aCommandName.substring(NC_NS_CMD.length));
|
||||
|
||||
switch (aCommandName) {
|
||||
case NC_NS_CMD + "open":
|
||||
|
@ -156,11 +155,15 @@ BookmarksTree.prototype = {
|
|||
var relativeNode = aParams[1];
|
||||
var parentNode = gBookmarksShell.findRDFNode(relativeNode, false);
|
||||
|
||||
if (!shell.validateNameAndTopic(name, aTopic, relativeNode, dummyItem))
|
||||
return;
|
||||
|
||||
dummyItem.parentNode.removeChild(dummyItem);
|
||||
|
||||
if (!shell.validateNameAndTopic(name, aTopic, relativeNode, dummyItem)) {
|
||||
gBookmarksShell.tree.selectItem(relativeNode);
|
||||
gBookmarksShell.tree.focus();
|
||||
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,
|
||||
|
@ -183,6 +186,9 @@ BookmarksTree.prototype = {
|
|||
var newFolderItem = document.getElementById(newFolderRDFObserver._newFolderURI);
|
||||
gBookmarksShell.tree.focus();
|
||||
gBookmarksShell.tree.selectItem(newFolderItem);
|
||||
// Can't use newFolderItem because it may not have been created yet. Hack, huh?
|
||||
var index = gBookmarksShell.tree.getIndexOfItem(relativeNode);
|
||||
gBookmarksShell.tree.ensureIndexIsVisible(index+1);
|
||||
gSelectionTracker.clickCount = 0;
|
||||
},
|
||||
|
||||
|
@ -220,11 +226,19 @@ BookmarksTree.prototype = {
|
|||
for (var i = 0; i < dummyItem.firstChild.childNodes.length; ++i)
|
||||
dummyItem.firstChild.childNodes[i].removeAttribute("label");
|
||||
var editCell = dummyItem.firstChild.firstChild;
|
||||
editCell.setAttribute("value",
|
||||
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")
|
||||
|
@ -271,7 +285,7 @@ BookmarksTree.prototype = {
|
|||
// others on a single click (sidebar panels).
|
||||
isValidOpenEvent: function (aEvent)
|
||||
{
|
||||
return !(aEvent.type == "click" &&
|
||||
return !(aEvent.type == "click" &&
|
||||
(aEvent.button != 0 || aEvent.detail != this.openClickCount))
|
||||
},
|
||||
|
||||
|
@ -310,7 +324,10 @@ BookmarksTree.prototype = {
|
|||
// popupNode is selected and the new selection returned.
|
||||
getSelection: function ()
|
||||
{
|
||||
return this.tree.selectedItems;
|
||||
// Note that we don't just the selectedItems NodeList here because that
|
||||
// is a reference to a LIVE DOM NODE LIST. We want to maintain control
|
||||
// over what is in the selection array ourselves.
|
||||
return [].concat(this.tree.selectedItems);
|
||||
},
|
||||
|
||||
getBestItem: function ()
|
||||
|
@ -448,7 +465,7 @@ BookmarksTree.prototype = {
|
|||
{
|
||||
if (this.tree.selectedItems.length > 1) return;
|
||||
if (aEvent.keyCode == 113 && aEvent.shiftKey) {
|
||||
const kNodeID = NODE_ID(this.tree.currentItem);
|
||||
const kNodeId = NODE_ID(this.tree.currentItem);
|
||||
if (this.resolveType(kNodeId) == NC_NS + "Bookmark")
|
||||
gBookmarksShell.commands.editCell (this.tree.currentItem, 1);
|
||||
}
|
||||
|
@ -484,11 +501,11 @@ BookmarksTree.prototype = {
|
|||
case "cmd_undo":
|
||||
case "cmd_redo":
|
||||
return false;
|
||||
case "cmd_cut":
|
||||
case "cmd_copy":
|
||||
case "cmd_paste":
|
||||
case "cmd_delete":
|
||||
case "cmd_selectAll":
|
||||
case "cmd_bm_cut":
|
||||
case "cmd_bm_copy":
|
||||
case "cmd_bm_paste":
|
||||
case "cmd_bm_delete":
|
||||
case "cmd_bm_selectAll":
|
||||
return true;
|
||||
case "cmd_open":
|
||||
case "cmd_openfolder":
|
||||
|
@ -499,7 +516,6 @@ BookmarksTree.prototype = {
|
|||
case "cmd_find":
|
||||
case "cmd_properties":
|
||||
case "cmd_rename":
|
||||
case "cmd_delete":
|
||||
case "cmd_setnewbookmarkfolder":
|
||||
case "cmd_setpersonaltoolbarfolder":
|
||||
case "cmd_setnewsearchfolder":
|
||||
|
@ -518,13 +534,13 @@ BookmarksTree.prototype = {
|
|||
case "cmd_undo":
|
||||
case "cmd_redo":
|
||||
return false;
|
||||
case "cmd_paste":
|
||||
case "cmd_bm_paste":
|
||||
return gBookmarksShell.canPaste();
|
||||
case "cmd_cut":
|
||||
case "cmd_copy":
|
||||
case "cmd_delete":
|
||||
case "cmd_bm_cut":
|
||||
case "cmd_bm_copy":
|
||||
case "cmd_bm_delete":
|
||||
return numSelectedItems >= 1;
|
||||
case "cmd_selectAll":
|
||||
case "cmd_bm_selectAll":
|
||||
return true;
|
||||
case "cmd_open":
|
||||
var seln = gBookmarksShell.tree.selectedItems;
|
||||
|
@ -569,10 +585,10 @@ BookmarksTree.prototype = {
|
|||
case "cmd_undo":
|
||||
case "cmd_redo":
|
||||
break;
|
||||
case "cmd_paste":
|
||||
case "cmd_copy":
|
||||
case "cmd_cut":
|
||||
case "cmd_delete":
|
||||
case "cmd_bm_paste":
|
||||
case "cmd_bm_copy":
|
||||
case "cmd_bm_cut":
|
||||
case "cmd_bm_delete":
|
||||
case "cmd_newbookmark":
|
||||
case "cmd_newfolder":
|
||||
case "cmd_newseparator":
|
||||
|
@ -589,7 +605,7 @@ BookmarksTree.prototype = {
|
|||
case "cmd_export":
|
||||
gBookmarksShell.execCommand(aCommand.substring("cmd_".length));
|
||||
break;
|
||||
case "cmd_selectAll":
|
||||
case "cmd_bm_selectAll":
|
||||
gBookmarksShell.tree.selectAll();
|
||||
break;
|
||||
}
|
||||
|
@ -606,8 +622,8 @@ BookmarksTree.prototype = {
|
|||
|
||||
onCommandUpdate: function ()
|
||||
{
|
||||
var commands = ["cmd_properties", "cmd_rename", "cmd_copy",
|
||||
"cmd_paste", "cmd_cut", "cmd_delete",
|
||||
var commands = ["cmd_properties", "cmd_rename", "cmd_bm_copy",
|
||||
"cmd_bm_paste", "cmd_bm_cut", "cmd_bm_delete",
|
||||
"cmd_setpersonaltoolbarfolder", "cmd_setnewbookmarkfolder",
|
||||
"cmd_setnewsearchfolder"];
|
||||
for (var i = 0; i < commands.length; ++i)
|
||||
|
@ -638,17 +654,3 @@ var newFolderRDFObserver = {
|
|||
endUpdateBatch: function (aDS) { }
|
||||
};
|
||||
|
||||
var ContentUtils = {
|
||||
childByLocalName: function (aSelectedItem, aLocalName)
|
||||
{
|
||||
var temp = aSelectedItem.firstChild;
|
||||
while (temp) {
|
||||
if (temp.localName == aLocalName)
|
||||
return temp;
|
||||
temp = temp.nextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,10 +22,11 @@ cmd_open = Open
|
|||
cmd_openfolder = Expand
|
||||
cmd_openfolder2 = Collapse
|
||||
cmd_find = Find a Bookmark...
|
||||
cmd_cut = Cut
|
||||
cmd_copy = Copy
|
||||
cmd_paste = Paste
|
||||
cmd_delete = Delete
|
||||
cmd_bm_cut = Cut
|
||||
cmd_bm_copy = Copy
|
||||
cmd_bm_paste = Paste
|
||||
cmd_bm_delete = Delete
|
||||
cmd_bm_selectAll = Select All
|
||||
cmd_rename = Rename...
|
||||
cmd_renamebookmark2 = Change Location...
|
||||
cmd_properties = Properties
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
<?xml-stylesheet href="chrome://communicator/content/bookmarks/oTest.css"?>
|
||||
|
||||
<window id="bookmarksOutlinerTest"
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
|
||||
<window id="bookmarksOutlinerTest" width="640" height="480"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
orient="vertical"
|
||||
onload="Startup();">
|
||||
|
||||
|
||||
<script>
|
||||
<![CDATA[
|
||||
var bookmarksBuilderObserver = {
|
||||
|
@ -30,7 +33,7 @@
|
|||
|
||||
isEditable: function (aIndex, aColID) {
|
||||
dump("*** isEditable(" + aIndex + ", " + aColID + ");\n");
|
||||
return false;
|
||||
return aColID == "NameColumn";
|
||||
},
|
||||
|
||||
onSetCellText: function (aIndex, aColID, aValue) {
|
||||
|
@ -70,19 +73,30 @@
|
|||
var y = { };
|
||||
var w = { };
|
||||
var h = { };
|
||||
obo.getCoordsForCellItem(row.value, col.value, elt.value, x, y, w, h);
|
||||
var crp = { };
|
||||
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");
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<!-- tooltips -->
|
||||
<popupset id="aTooltipSet"/>
|
||||
|
||||
<toolbox>
|
||||
<toolbar>
|
||||
<button class="button-toolbar-2" label="Foopy Noopy" oncommand="alert('hi');"/>
|
||||
</toolbar>
|
||||
</toolbox>
|
||||
|
||||
<outliner flex="1" flags="dont-test-empty" id="outliner-proper">
|
||||
<stack>
|
||||
<button label="Foopy Noopy" flex="1"/>
|
||||
<bulletinboard flex="1">
|
||||
<textbox value="NerpNerp" left="10" top="50" onblur="this.setAttribute('hidden','true');"/>
|
||||
</bulletinboard>
|
||||
</stack>
|
||||
|
||||
<outliner flex="1" flags="dont-test-empty" id="outliner-proper" titletiptext="Foopy Noopy!">
|
||||
<outlinercol id="NameColumn"
|
||||
class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
flex="1"
|
||||
|
@ -115,4 +129,5 @@
|
|||
</outlinerbody>
|
||||
</outliner>
|
||||
|
||||
</window>
|
||||
</window>
|
||||
|
||||
|
|
|
@ -81,11 +81,6 @@
|
|||
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-history.xul" label="&history.label;"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
<treeitem id="bookmarks">
|
||||
<treerow>
|
||||
<treecell class="treecell-indent" url="chrome://communicator/content/bookmarks/pref-bookmarks.xul" label="&bookmarks.label;"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
<treeitem>
|
||||
<treerow>
|
||||
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-languages.xul" label="&languages.label;"/>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<!--LOCALIZATION NOTE (navigator.label): DONT_TRANSLATE -->
|
||||
<!ENTITY navigator.label "Navigator">
|
||||
<!ENTITY history.label "History">
|
||||
<!ENTITY bookmarks.label "Bookmarks">
|
||||
<!ENTITY languages.label "Languages">
|
||||
<!ENTITY applications.label "Helper Applications">
|
||||
<!--LOCALIZATION NOTE (smartBrowse.label): DONT_TRANSLATE -->
|
||||
|
|
Загрузка…
Ссылка в новой задаче