Implement the Add Page button in the Web Panels sidebar.

git-svn-id: svn://10.0.0.236/trunk@145508 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hyatt%mozilla.org
2003-08-03 08:25:19 +00:00
parent 9105310b16
commit 6b0d40ba1a
9 changed files with 31 additions and 10 deletions

View File

@@ -21,6 +21,7 @@
#
# Contributor(s):
# Blake Ross <blaker@netscape.com>
# David Hyatt <hyatt@mozilla.org>
# Peter Annema <disttsc@bart.nl>
# Dean Tessman <dean_tessman@hotmail.com>
# Kevin Puetz (puetzk@iastate.edu)
@@ -772,13 +773,13 @@ function updateGoMenu(goMenu)
endSep.hidden = false;
}
function addBookmarkAs(aBrowser)
function addBookmarkAs(aBrowser, aIsWebPanel)
{
const browsers = aBrowser.browsers;
if (browsers.length > 1)
if (browsers && browsers.length > 1)
addBookmarkForTabBrowser(aBrowser);
else
addBookmarkForBrowser(aBrowser.webNavigation);
addBookmarkForBrowser(aBrowser.webNavigation, aIsWebPanel);
}
function addBookmarkForTabBrowser(aTabBrowser, aSelect)
@@ -810,7 +811,7 @@ function addBookmarkForTabBrowser(aTabBrowser, aSelect)
currentTabInfo.charset, "addGroup" + (aSelect ? ",group" : ""), tabsInfo);
}
function addBookmarkForBrowser(aDocShell)
function addBookmarkForBrowser(aDocShell, aIsWebPanel)
{
// Bug 52536: We obtain the URL and title from the nsIWebNavigation
// associated with a <browser/> rather than from a DOMWindow.
@@ -826,7 +827,7 @@ function addBookmarkForBrowser(aDocShell)
catch (e) {
title = url;
}
BookmarksUtils.addBookmark(url, title, charSet);
BookmarksUtils.addBookmark(url, title, charSet, aIsWebPanel);
}
function openLocation()

View File

@@ -53,3 +53,7 @@ function grabPage()
} catch (e) {}
}
function addWebPanel()
{
window.parent.addBookmarkAs(document.getElementById('webpanels-browser'), true);
}

View File

@@ -6,6 +6,9 @@
<link rel="stylesheet" href="chrome://browser/skin/web-panels-drop-page.css"/>
</head>
<body>
Drag a link into this area to view it here.
Drop a link here to view it.
You can also click on the <i>Grab Page</i> button above to
view the current page.
</body>
</html>

View File

@@ -17,6 +17,7 @@
<script type="application/x-javascript" src="chrome://browser/content/web-panels.js"/>
<hbox align="center">
<toolbarbutton label="&addPanel.label;" oncommand="addWebPanel()"/>
<spacer flex="1"/>
<toolbarbutton label="&viewPage.label;" oncommand="grabPage()"/>
</hbox>
<browser id="webpanels-browser" type="content" flex="1"

View File

@@ -67,6 +67,7 @@
* window.arguments[5]: If the mode is "addGroup", this is an array
* of objects with name, URL and charset
* properties, one for each group member.
* window.arguments[6]: If the bookmark should become a web panel.
*
* Mode of Operation Notes:
* ------------------------
@@ -253,7 +254,7 @@ function onOK()
}
} else {
url = getNormalizedURL(gFld_URL.value);
rSource = BMDS.createBookmark(gFld_Name.value, url, null, null, gBookmarkCharset);
rSource = BMDS.createBookmark(gFld_Name.value, url, null, null, gBookmarkCharset, false);
if (window.arguments.length > 4 && window.arguments[4] == "newBookmark") {
window.arguments[5].newBookmark = rSource;
}

View File

@@ -21,6 +21,7 @@
#
# Contributor(s):
# Ben Goodger <ben@netscape.com> (Original Author)
# David Hyatt <hyatt@mozilla.org>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -67,6 +68,7 @@
* window.arguments[5]: If the mode is "addGroup", this is an array
* of objects with name, URL and charset
* properties, one for each group member.
* window.arguments[6]: If the bookmark should become a web panel.
*/
var gSelectedFolder;
@@ -125,6 +127,13 @@ function onOK()
var selection = BookmarksUtils.getSelectionFromResource(rSource);
var target = BookmarksUtils.getTargetFromFolder(rFolder);
BookmarksUtils.insertSelection("newbookmark", selection, target);
if (window.arguments[6] && rSource) {
// Assert that we're a web panel.
BMDS.Assert(rSource, RDF.GetResource(NC_NS+"WebPanel"),
RDF.GetLiteral("true"), true);
}
// in insertSelection, the ds flush is delayed. It will never be performed,
// since this dialog is destroyed before.
// We have to flush manually

View File

@@ -65,7 +65,7 @@
<separator class="thin"/>
<script type="application/x-javascript"><![CDATA[
if (window.arguments.length < 6)
if (!window.arguments[5])
document.getElementById("addgroup").setAttribute("hidden", "true");
]]></script>

View File

@@ -1464,10 +1464,11 @@ var BookmarksUtils = {
},
// should update the caller, aShowDialog is no more necessary
addBookmark: function (aURL, aTitle, aCharset)
addBookmark: function (aURL, aTitle, aCharset, aIsWebPanel)
{
openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
"centerscreen,chrome,dialog=yes,resizable=no,dependent", aTitle, aURL, null, aCharset);
"centerscreen,chrome,dialog=yes,resizable=no,dependent", aTitle, aURL, null, aCharset,
null, null, aIsWebPanel);
},
getBrowserTargetFromEvent: function (aEvent)

View File

@@ -21,6 +21,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com>
* David Hyatt <hyatt@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or