2012-08-10 20:20:25 +00:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-12-03 05:37:53 +00:00
|
|
|
|
2007-03-25 03:41:16 +00:00
|
|
|
const NS_ERROR_MODULE_NETWORK = 2152398848;
|
|
|
|
const NS_NET_STATUS_READ_FROM = NS_ERROR_MODULE_NETWORK + 8;
|
|
|
|
const NS_NET_STATUS_WROTE_TO = NS_ERROR_MODULE_NETWORK + 9;
|
|
|
|
|
2007-01-31 18:10:02 +00:00
|
|
|
function getPanelBrowser()
|
|
|
|
{
|
|
|
|
return document.getElementById("web-panels-browser");
|
|
|
|
}
|
|
|
|
|
2003-08-03 09:10:49 +00:00
|
|
|
var panelProgressListener = {
|
|
|
|
onProgressChange : function (aWebProgress, aRequest,
|
2007-01-31 18:10:02 +00:00
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
aCurTotalProgress, aMaxTotalProgress) {
|
2003-08-03 09:10:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
|
|
|
{
|
|
|
|
if (!aRequest)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//ignore local/resource:/chrome: files
|
|
|
|
if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO)
|
|
|
|
return;
|
|
|
|
|
2007-01-31 18:10:02 +00:00
|
|
|
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
|
|
|
|
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
|
2003-08-04 03:40:27 +00:00
|
|
|
window.parent.document.getElementById('sidebar-throbber').setAttribute("loading", "true");
|
2003-08-03 09:10:49 +00:00
|
|
|
}
|
2007-01-31 18:10:02 +00:00
|
|
|
else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
|
|
|
|
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
|
2003-08-04 03:40:27 +00:00
|
|
|
window.parent.document.getElementById('sidebar-throbber').removeAttribute("loading");
|
2003-08-03 09:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
,
|
|
|
|
|
2011-11-10 14:01:11 +00:00
|
|
|
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) {
|
2007-01-31 18:10:02 +00:00
|
|
|
UpdateBackForwardCommands(getPanelBrowser().webNavigation);
|
2003-08-03 09:10:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {
|
|
|
|
},
|
|
|
|
|
|
|
|
onSecurityChange : function(aWebProgress, aRequest, aState) {
|
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface : function(aIID)
|
|
|
|
{
|
2007-01-31 18:10:02 +00:00
|
|
|
if (aIID.equals(Ci.nsIWebProgressListener) ||
|
|
|
|
aIID.equals(Ci.nsISupportsWeakReference) ||
|
|
|
|
aIID.equals(Ci.nsISupports))
|
|
|
|
return this;
|
|
|
|
throw Cr.NS_NOINTERFACE;
|
2003-08-03 09:10:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-08-04 07:20:01 +00:00
|
|
|
var gLoadFired = false;
|
2003-08-03 01:58:52 +00:00
|
|
|
function loadWebPanel(aURI) {
|
2007-01-31 18:10:02 +00:00
|
|
|
var panelBrowser = getPanelBrowser();
|
|
|
|
if (gLoadFired) {
|
|
|
|
panelBrowser.webNavigation
|
|
|
|
.loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
|
|
|
|
null, null, null);
|
|
|
|
}
|
2003-08-04 04:29:35 +00:00
|
|
|
panelBrowser.setAttribute("cachedurl", aURI);
|
2003-08-03 01:58:52 +00:00
|
|
|
}
|
|
|
|
|
2003-08-03 09:10:49 +00:00
|
|
|
function load()
|
|
|
|
{
|
2007-01-31 18:10:02 +00:00
|
|
|
var panelBrowser = getPanelBrowser();
|
|
|
|
panelBrowser.webProgress.addProgressListener(panelProgressListener,
|
|
|
|
Ci.nsIWebProgress.NOTIFY_ALL);
|
2011-05-08 18:14:16 +00:00
|
|
|
var cachedurl = panelBrowser.getAttribute("cachedurl")
|
|
|
|
if (cachedurl) {
|
2007-01-31 18:10:02 +00:00
|
|
|
panelBrowser.webNavigation
|
2011-05-08 18:14:16 +00:00
|
|
|
.loadURI(cachedurl, nsIWebNavigation.LOAD_FLAGS_NONE, null,
|
2007-01-31 18:10:02 +00:00
|
|
|
null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
gLoadFired = true;
|
2003-08-03 09:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function unload()
|
|
|
|
{
|
2007-01-31 18:10:02 +00:00
|
|
|
getPanelBrowser().webProgress.removeProgressListener(panelProgressListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
function PanelBrowserStop()
|
|
|
|
{
|
|
|
|
getPanelBrowser().webNavigation.stop(nsIWebNavigation.STOP_ALL)
|
|
|
|
}
|
|
|
|
|
|
|
|
function PanelBrowserReload()
|
|
|
|
{
|
|
|
|
getPanelBrowser().webNavigation
|
|
|
|
.sessionHistory
|
|
|
|
.QueryInterface(nsIWebNavigation)
|
|
|
|
.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
|
2003-08-03 08:25:19 +00:00
|
|
|
}
|