зеркало из https://github.com/mozilla/pjs.git
Fix bug # 39161: when adding a new bookmark, set its default type if it doesn't have one. r=me
This commit is contained in:
Родитель
f253dd79e2
Коммит
f1c8ed55c1
|
@ -20,7 +20,12 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
var NC = "http://home.netscape.com/NC-rdf#";
|
||||
|
||||
|
||||
var NC_NS = "http://home.netscape.com/NC-rdf#";
|
||||
var RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
|
||||
|
||||
|
||||
function debug(msg)
|
||||
{
|
||||
|
@ -149,7 +154,7 @@ function copySelectionToClipboard()
|
|||
var Bookmarks = RDF.GetDataSource("rdf:bookmarks");
|
||||
if (!Bookmarks) return false;
|
||||
|
||||
var nameRes = RDF.GetResource(NC + "Name");
|
||||
var nameRes = RDF.GetResource(NC_NS + "Name");
|
||||
if (!nameRes) return false;
|
||||
|
||||
// Build a url that encodes all the select nodes
|
||||
|
@ -182,7 +187,7 @@ function copySelectionToClipboard()
|
|||
if (node.getAttribute("container") == "true")
|
||||
{
|
||||
var type = node.getAttribute("type");
|
||||
if (type == NC + "BookmarkSeparator")
|
||||
if (type == NC_NS + "BookmarkSeparator")
|
||||
{
|
||||
// Note: can't encode separators in text, just html
|
||||
html += "<hr><p>";
|
||||
|
@ -328,7 +333,7 @@ function doPaste()
|
|||
var Bookmarks = RDF.GetDataSource("rdf:bookmarks");
|
||||
if (!Bookmarks) return false;
|
||||
|
||||
var nameRes = RDF.GetResource(NC + "Name");
|
||||
var nameRes = RDF.GetResource(NC_NS + "Name");
|
||||
if (!nameRes) return false;
|
||||
|
||||
pasteNodeRes = RDF.GetResource(pasteNodeID);
|
||||
|
@ -359,6 +364,11 @@ function doPaste()
|
|||
if (pasteNodeIndex < 0) return false; // how did that happen?
|
||||
}
|
||||
|
||||
var typeRes = RDF.GetResource(RDF_NS + "type");
|
||||
if (!typeRes) return false;
|
||||
var bmTypeRes = RDF.GetResource(NC_NS + "Bookmark");
|
||||
if (!bmTypeRes) return false;
|
||||
|
||||
debug("Loop over strings");
|
||||
|
||||
var dirty = false;
|
||||
|
@ -401,6 +411,15 @@ function doPaste()
|
|||
debug("Pasted at index # " + pasteNodeIndex);
|
||||
}
|
||||
dirty = true;
|
||||
|
||||
// make sure appropriate bookmark type is set
|
||||
var bmTypeNode = Bookmarks.GetTarget( IDRes, typeRes, true );
|
||||
if (!bmTypeNode)
|
||||
{
|
||||
// set default bookmark type
|
||||
Bookmarks.Assert(IDRes, typeRes, bmTypeRes, true);
|
||||
debug("Setting default bookmark type\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dirty == true)
|
||||
|
@ -530,7 +549,7 @@ function BookmarkProperties()
|
|||
if (select_list.length >= 1) {
|
||||
// don't bother showing properties on bookmark separators
|
||||
var type = select_list[0].getAttribute('type');
|
||||
if (type != NC + "BookmarkSeparator") {
|
||||
if (type != NC_NS + "BookmarkSeparator") {
|
||||
window.openDialog("chrome://communicator/content/bookmarks/bm-props.xul",
|
||||
"_blank", "centerscreen,chrome,menubar",
|
||||
select_list[0].getAttribute("id"));
|
||||
|
@ -575,7 +594,7 @@ function getAbsoluteID(root, node)
|
|||
if (rdf && ds)
|
||||
{
|
||||
var src = rdf.GetResource(url, true);
|
||||
var prop = rdf.GetResource(NC + "URL",
|
||||
var prop = rdf.GetResource(NC_NS + "URL",
|
||||
true);
|
||||
var target = ds.GetTarget(src, prop, true);
|
||||
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
|
@ -839,7 +858,7 @@ function fillContextMenu(name)
|
|||
debug("# of Nodes selected: " + treeNode.selectedItems.length + "\n");
|
||||
|
||||
var separatorResource =
|
||||
rdf.GetResource(NC + "BookmarkSeparator");
|
||||
rdf.GetResource(NC_NS + "BookmarkSeparator");
|
||||
if (!separatorResource) return false;
|
||||
|
||||
// perform intersection of commands over selected nodes
|
||||
|
@ -913,7 +932,7 @@ function fillContextMenu(name)
|
|||
}
|
||||
|
||||
// need a resource to ask RDF for each command's name
|
||||
var rdfNameResource = rdf.GetResource(NC + "Name");
|
||||
var rdfNameResource = rdf.GetResource(NC_NS + "Name");
|
||||
if (!rdfNameResource) return false;
|
||||
|
||||
/*
|
||||
|
@ -983,8 +1002,8 @@ function fillContextMenu(name)
|
|||
// and its a bookmark or a bookmark folder (there can be other types,
|
||||
// not just separators, so check explicitly for what we allow)
|
||||
var type = select_list[0].getAttribute("type");
|
||||
if ((type == NC + "Bookmark") ||
|
||||
(type == NC + "Folder"))
|
||||
if ((type == NC_NS + "Bookmark") ||
|
||||
(type == NC_NS + "Folder"))
|
||||
{
|
||||
// then add a menu separator (if necessary)
|
||||
if (popupNode.childNodes.length > 0)
|
||||
|
@ -1024,7 +1043,7 @@ function doContextCmd(cmdName)
|
|||
var nameVal = "";
|
||||
var urlVal = "";
|
||||
|
||||
if (cmdName == NC + "command?cmd=newbookmark")
|
||||
if (cmdName == NC_NS + "command?cmd=newbookmark")
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
@ -1042,21 +1061,21 @@ function doContextCmd(cmdName)
|
|||
nameVal = prompt(promptStr, "");
|
||||
if (!nameVal || nameVal=="") return false;
|
||||
}
|
||||
else if (cmdName == NC + "command?cmd=newfolder")
|
||||
else if (cmdName == NC_NS + "command?cmd=newfolder")
|
||||
{
|
||||
var promptStr = get_localized_string("NewFolderNamePrompt");
|
||||
nameVal = prompt(promptStr, "");
|
||||
if (!nameVal || nameVal=="") return false;
|
||||
}
|
||||
else if ((cmdName == NC + "command?cmd=deletebookmark") ||
|
||||
(cmdName == NC + "command?cmd=deletebookmarkfolder") ||
|
||||
(cmdName == NC + "command?cmd=deletebookmarkseparator"))
|
||||
else if ((cmdName == NC_NS + "command?cmd=deletebookmark") ||
|
||||
(cmdName == NC_NS + "command?cmd=deletebookmarkfolder") ||
|
||||
(cmdName == NC_NS + "command?cmd=deletebookmarkseparator"))
|
||||
{
|
||||
return doDelete(true);
|
||||
//var promptStr = get_localized_string("DeleteItems");
|
||||
//if (!confirm(promptStr)) return false;
|
||||
}
|
||||
else if (cmdName == NC + "command?cmd=import")
|
||||
else if (cmdName == NC_NS + "command?cmd=import")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1079,7 +1098,7 @@ function doContextCmd(cmdName)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if (cmdName == NC + "command?cmd=export")
|
||||
else if (cmdName == NC_NS + "command?cmd=export")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1137,11 +1156,11 @@ function doContextCmd(cmdName)
|
|||
var argumentsArray = argumentsInstance.QueryInterface(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// get various arguments (parent, name)
|
||||
var parentArc = rdf.GetResource(NC + "parent");
|
||||
var parentArc = rdf.GetResource(NC_NS + "parent");
|
||||
if (!parentArc) return false;
|
||||
var nameArc = rdf.GetResource(NC + "Name");
|
||||
var nameArc = rdf.GetResource(NC_NS + "Name");
|
||||
if (!nameArc) return false;
|
||||
var urlArc = rdf.GetResource(NC + "URL");
|
||||
var urlArc = rdf.GetResource(NC_NS + "URL");
|
||||
if (!urlArc) return false;
|
||||
|
||||
var select_list = treeNode.selectedItems;
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
|
||||
|
||||
|
||||
var NC_NS = "http://home.netscape.com/NC-rdf#";
|
||||
var RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
|
||||
|
||||
|
||||
function TopLevelDrag ( event )
|
||||
{
|
||||
dump("TOP LEVEL bookmarks window got a drag");
|
||||
|
@ -92,7 +97,7 @@ function BeginDragTree ( event )
|
|||
|
||||
// make sure its a bookmark, bookmark separator, or bookmark folder
|
||||
var src = rdf.GetResource(id, true);
|
||||
var prop = rdf.GetResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", true);
|
||||
var prop = rdf.GetResource(RDF_NS + "type", true);
|
||||
var target = database.GetTarget(src, prop, true);
|
||||
|
||||
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
@ -100,9 +105,9 @@ function BeginDragTree ( event )
|
|||
if ((!target) || (target == "")) {dump("BAD\n"); return(false);}
|
||||
dump(" Type: '" + target + "'");
|
||||
|
||||
if ((target != "http://home.netscape.com/NC-rdf#BookmarkSeparator") &&
|
||||
(target != "http://home.netscape.com/NC-rdf#Bookmark") &&
|
||||
(target != "http://home.netscape.com/NC-rdf#Folder")) return(false);
|
||||
if ((target != NC_NS + "BookmarkSeparator") &&
|
||||
(target != NC_NS + "Bookmark") &&
|
||||
(target != NC_NS + "Folder")) return(false);
|
||||
|
||||
dump("genData is " + genData.data + " len is " + genData.data.length + "\n");
|
||||
trans.setTransferData ( "moz/rdfitem", genData, genData.data.length * 2); // double byte data
|
||||
|
@ -272,6 +277,11 @@ function DropOnTree ( event )
|
|||
trans.addDataFlavor("moz/rdfitem");
|
||||
trans.addDataFlavor("text/unicode");
|
||||
|
||||
var typeRes = RDF.GetResource(RDF_NS + "type");
|
||||
if (!typeRes) return false;
|
||||
var bmTypeRes = RDF.GetResource(NC_NS + "Bookmark");
|
||||
if (!bmTypeRes) return false;
|
||||
|
||||
var dirty = false;
|
||||
|
||||
for ( var i = 0; i < dragSession.numDropItems; ++i )
|
||||
|
@ -330,6 +340,15 @@ function DropOnTree ( event )
|
|||
|
||||
RDFC.Init(Bookmarks, containerNode);
|
||||
|
||||
// make sure appropriate bookmark type is set
|
||||
var bmTypeNode = Bookmarks.GetTarget( sourceNode, typeRes, true );
|
||||
if (!bmTypeNode)
|
||||
{
|
||||
// set default bookmark type
|
||||
Bookmarks.Assert(sourceNode, typeRes, bmTypeRes, true);
|
||||
dump("Setting default bookmark type\n");
|
||||
}
|
||||
|
||||
if ((dropAction == "before") || (dropAction == "after"))
|
||||
{
|
||||
// drop before or after
|
||||
|
@ -378,7 +397,7 @@ function DropOnTree ( event )
|
|||
// XXX for the moment, if its a text/unicode drop
|
||||
// we may need to synthesize a name (just use the URL)
|
||||
var srcArc = RDF.GetResource(sourceID, true);
|
||||
var propArc = RDF.GetResource("http://home.netscape.com/NC-rdf#Name", true);
|
||||
var propArc = RDF.GetResource(NC_NS + "Name", true);
|
||||
if (srcArc && propArc && treeDatabase)
|
||||
{
|
||||
var targetArc = treeDatabase.GetTarget(srcArc, propArc, true);
|
||||
|
|
|
@ -4901,6 +4901,7 @@ nsBookmarksService::CanAccept(nsIRDFResource* aSource,
|
|||
(aProperty == kWEB_LastVisitDate) ||
|
||||
(aProperty == kNC_BookmarkAddDate) ||
|
||||
(aProperty == kRDF_nextVal) ||
|
||||
(aProperty == kRDF_type) ||
|
||||
(aProperty == kWEB_Schedule))
|
||||
{
|
||||
canAcceptFlag = PR_TRUE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче