Add persistent panel support (iframe's remain loaded even when not visible).

b=106129; r=morse; sr=dveditz
This commit is contained in:
sgehani%netscape.com 2001-11-30 00:10:13 +00:00
Родитель 5374c4f12a
Коммит 6fbc3b7645
4 изменённых файлов: 65 добавлений и 23 удалений

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

@ -33,6 +33,8 @@ interface nsISidebar : nsISupports
void setWindow (in nsIDOMWindowInternal aWindow);
void addPanel(in wstring aTitle, in string aContentURL,
in string aCustomizeURL);
void addPersistentPanel(in wstring aTitle, in string aContentURL,
in string aCustomizeURL);
void addSearchEngine(in string engineURL, in string iconURL,
in wstring suggestedTitle, in wstring suggestedCategory);
};

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

@ -1,8 +0,0 @@
addPanelConfirmTitle=Add Tab to Sidebar
addPanelConfirmMessage=Add the tab '%title%' to the %name%?##Source: %url%
dupePanelAlertTitle=Sidebar
dupePanelAlertMessage=%url% already exists in the %name%.
addEngineConfirmTitle=Add Search Engine
addEngineConfirmMessage=Add the following search engine to the %name% Internet Search tab?##Name: %title%#Search Category: %category%#Source: %url%

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

@ -283,8 +283,10 @@ function (force_reload)
content.removeAttribute('collapsed');
if (sidebarObj.collapsed && panel.is_sandboxed()) {
debug(" set src=about:blank");
iframe.setAttribute('src', 'about:blank');
if (!panel.is_persistent()) {
debug(" set src=about:blank");
iframe.setAttribute('src', 'about:blank');
}
} else {
var saved_src = iframe.getAttribute('content');
var src = iframe.getAttribute('src');
@ -312,15 +314,18 @@ function (force_reload)
header.removeAttribute('selected');
content.setAttribute('collapsed','true');
iframe.setAttribute('src', 'about:blank');
load_state = content.getAttribute('loadstate');
if (load_state == 'loading') {
iframe.removeEventListener("load", panel_loader, true);
content.setAttribute('hidden','true');
iframe.setAttribute('loadstate', 'never loaded');
if (!panel.is_persistent()) {
iframe.setAttribute('src', 'about:blank');
load_state = content.getAttribute('loadstate');
if (load_state == 'loading') {
iframe.removeEventListener("load", panel_loader, true);
content.setAttribute('hidden','true');
iframe.setAttribute('loadstate', 'never loaded');
}
}
if (panel.is_sandboxed()) {
iframe.setAttribute('src', 'about:blank');
if (!panel.is_persistent())
iframe.setAttribute('src', 'about:blank');
}
}
}
@ -425,6 +430,24 @@ function (panel_id)
return 'true' == this.get_header().getAttribute('selected');
}
sbPanel.prototype.is_persistent =
function ()
{
var rv = false;
var datasource = RDF.GetDataSource(sidebarObj.datasource_uri);
var persistNode = datasource.GetTarget(RDF.GetResource(this.id),
RDF.GetResource(NC + "persist"),
true);
if (persistNode)
{
persistNode =
persistNode.QueryInterface(Components.interfaces.nsIRDFLiteral);
rv = persistNode.Value == 'true';
}
return rv;
}
sbPanel.prototype.select =
function (force_reload)
{
@ -879,9 +902,9 @@ function SidebarShowHide() {
if (sidebar_is_hidden()) {
debug("Showing the sidebar");
sidebar_box.removeAttribute('hidden');
sidebar_box.setAttribute('collapsed', 'false');
title_box.removeAttribute('hidden');
sidebar_panels_splitter_box.removeAttribute('hidden');
sidebar_panels_splitter_box.setAttribute('collapsed', 'false');
sidebar_splitter.removeAttribute('hidden');
if (sidebar_box.firstChild != sidebar_panels_splitter) {
debug("Showing the panels splitter");
@ -894,13 +917,13 @@ function SidebarShowHide() {
var hide_everything = sidebar_panels_splitter.getAttribute('hidden') == 'true';
if (hide_everything) {
debug("Hide everything");
sidebar_box.setAttribute('hidden', 'true');
sidebar_box.setAttribute('collapsed', 'true');
sidebar_splitter.setAttribute('hidden', 'true');
} else {
sidebar_panels_splitter.setAttribute('hidden', 'true');
}
title_box.setAttribute('hidden', 'true');
sidebar_panels_splitter_box.setAttribute('hidden', 'true');
sidebar_panels_splitter_box.setAttribute('collapsed', 'true');
sidebar_menu_item.setAttribute('checked', 'false');
}
// Immediately save persistent values

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

@ -99,7 +99,22 @@ function (aTitle, aContentURL, aCustomizeURL)
{
debug("addPanel(" + aTitle + ", " + aContentURL + ", " +
aCustomizeURL + ")");
return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, false);
}
nsSidebar.prototype.addPersistentPanel =
function(aTitle, aContentURL, aCustomizeURL)
{
debug("addPersistentPanel(" + aTitle + ", " + aContentURL + ", " +
aCustomizeURL + ")\n");
return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, true);
}
nsSidebar.prototype.addPanelInternal =
function (aTitle, aContentURL, aCustomizeURL, aPersist)
{
if (!this.window)
{
debug ("no window object set, bailing out.");
@ -116,7 +131,7 @@ function (aTitle, aContentURL, aCustomizeURL)
} else {
// Datasource is busted. Start over.
debug("Sidebar datasource is busted\n");
}
}
var container = Components.classes[CONTAINER_CONTRACTID].createInstance(nsIRDFContainer);
container.Init(this.datasource, panel_list);
@ -160,10 +175,15 @@ function (aTitle, aContentURL, aCustomizeURL)
sidebarName = brandStringBundle.GetStringFromName("sidebarName");
titleMessage = stringBundle.GetStringFromName("addPanelConfirmTitle");
dialogMessage = stringBundle.GetStringFromName("addPanelConfirmMessage");
if (aPersist)
{
var warning = stringBundle.GetStringFromName("persistentPanelWarning");
dialogMessage += "\n" + warning;
}
dialogMessage = dialogMessage.replace(/%title%/, aTitle);
dialogMessage = dialogMessage.replace(/%url%/, aContentURL);
dialogMessage = dialogMessage.replace(/#/g, "\n");
dialogMessage = dialogMessage.replace(/%name%/, sidebarName);
dialogMessage = dialogMessage.replace(/%name%/g, sidebarName);
}
}
catch (e) {
@ -192,6 +212,11 @@ function (aTitle, aContentURL, aCustomizeURL)
this.rdf.GetResource(this.nc + "customize"),
this.rdf.GetLiteral(aCustomizeURL),
true);
var persistValue = aPersist ? "true" : "false";
this.datasource.Assert(panel_resource,
this.rdf.GetResource(this.nc + "persist"),
this.rdf.GetLiteral(persistValue),
true);
container.AppendElement(panel_resource);