web-panels.js
Go to the documentation of this file.
1 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 #
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
9 #
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
14 #
15 # The Original Code is Mozilla.org Code.
16 #
17 # The Initial Developer of the Original Code is
18 # David Hyatt.
19 # Portions created by the Initial Developer are Copyright (C) 2001
20 # the Initial Developer. All Rights Reserved.
21 #
22 # Contributor(s):
23 # David Hyatt <hyatt@mozilla.org>
24 # Asaf Romano <mano@mozilla.com>
25 #
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
37 #
38 # ***** END LICENSE BLOCK *****
39 
40 const NS_ERROR_MODULE_NETWORK = 2152398848;
43 
44 function getPanelBrowser()
45 {
46  return document.getElementById("web-panels-browser");
47 }
48 
50  onProgressChange : function (aWebProgress, aRequest,
51  aCurSelfProgress, aMaxSelfProgress,
52  aCurTotalProgress, aMaxTotalProgress) {
53  },
54 
55  onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
56  {
57  if (!aRequest)
58  return;
59 
60  //ignore local/resource:/chrome: files
61  if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO)
62  return;
63 
64  if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
65  aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
66  window.parent.document.getElementById('sidebar-throbber').setAttribute("loading", "true");
67  }
68  else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
69  aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
70  window.parent.document.getElementById('sidebar-throbber').removeAttribute("loading");
71  }
72  }
73  ,
74 
75  onLocationChange : function(aWebProgress, aRequest, aLocation) {
77  },
78 
79  onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {
80  },
81 
82  onSecurityChange : function(aWebProgress, aRequest, aState) {
83  },
84 
85  QueryInterface : function(aIID)
86  {
87  if (aIID.equals(Ci.nsIWebProgressListener) ||
88  aIID.equals(Ci.nsISupportsWeakReference) ||
89  aIID.equals(Ci.nsISupports))
90  return this;
91  throw Cr.NS_NOINTERFACE;
92  }
93 };
94 
95 var gLoadFired = false;
96 function loadWebPanel(aURI) {
97  var panelBrowser = getPanelBrowser();
98  if (gLoadFired) {
99  panelBrowser.webNavigation
100  .loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
101  null, null, null);
102  }
103  panelBrowser.setAttribute("cachedurl", aURI);
104 }
105 
106 function load()
107 {
108  var panelBrowser = getPanelBrowser();
109  panelBrowser.webProgress.addProgressListener(panelProgressListener,
110  Ci.nsIWebProgress.NOTIFY_ALL);
111  if (panelBrowser.getAttribute("cachedurl")) {
112  panelBrowser.webNavigation
113  .loadURI(panelBrowser.getAttribute("cachedurl"),
114  nsIWebNavigation.LOAD_FLAGS_NONE, null,
115  null, null);
116  }
117 
118  gLoadFired = true;
119 }
120 
121 function unload()
122 {
123  getPanelBrowser().webProgress.removeProgressListener(panelProgressListener);
124 }
125 
127 {
128  getPanelBrowser().webNavigation.stop(nsIWebNavigation.STOP_ALL)
129 }
130 
132 {
133  getPanelBrowser().webNavigation
134  .sessionHistory
135  .QueryInterface(nsIWebNavigation)
136  .reload(nsIWebNavigation.LOAD_FLAGS_NONE);
137 }
function UpdateBackForwardCommands(aWebNavigation)
Definition: browser.js:172
const NS_NET_STATUS_WROTE_TO
Definition: web-panels.js:42
function getPanelBrowser()
Definition: web-panels.js:44
var panelProgressListener
Definition: web-panels.js:49
sbOSDControlService prototype QueryInterface
function load()
Definition: web-panels.js:106
let window
const nsIWebNavigation
Definition: browser.js:71
function loadWebPanel(aURI)
Definition: web-panels.js:96
var gLoadFired
Definition: web-panels.js:95
function PanelBrowserReload()
Definition: web-panels.js:131
return null
Definition: FeedWriter.js:1143
function unload()
Definition: web-panels.js:121
function PanelBrowserStop()
Definition: web-panels.js:126
const Cr
const Ci
ContinuingWebProgressListener prototype onStateChange
const NS_NET_STATUS_READ_FROM
Definition: web-panels.js:41
restoreWindow aState
const NS_ERROR_MODULE_NETWORK
Definition: web-panels.js:40