зеркало из https://github.com/mozilla/pjs.git
*** empty log message ***
This commit is contained in:
Родитель
1aa345548f
Коммит
2d724bdd80
|
@ -343,7 +343,7 @@ function Startup()
|
|||
gBrandBundle = document.getElementById("bundle_brand");
|
||||
gNavigatorRegionBundle = document.getElementById("bundle_navigator_region");
|
||||
gBrandRegionBundle = document.getElementById("bundle_brand_region");
|
||||
|
||||
registerZoomManager();
|
||||
gBrowser = document.getElementById("content");
|
||||
gURLBar = document.getElementById("urlbar");
|
||||
|
||||
|
|
|
@ -1,336 +0,0 @@
|
|||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*
|
||||
* 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
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Go into online/offline mode
|
||||
**/
|
||||
|
||||
const kIOServiceProgID = "@mozilla.org/network/io-service;1";
|
||||
const kObserverServiceProgID = "@mozilla.org/observer-service;1";
|
||||
|
||||
function toggleOfflineStatus()
|
||||
{
|
||||
var checkfunc;
|
||||
try {
|
||||
checkfunc = document.getElementById("offline-status").getAttribute('checkfunc');
|
||||
}
|
||||
catch (ex) {
|
||||
checkfunc = null;
|
||||
}
|
||||
|
||||
var ioService = Components.classes[kIOServiceProgID]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
if (checkfunc) {
|
||||
if (!eval(checkfunc)) {
|
||||
// the pre-offline check function returned false, so don't go offline
|
||||
return;
|
||||
}
|
||||
}
|
||||
ioService.offline = !ioService.offline;
|
||||
}
|
||||
|
||||
function setOfflineUI(offline)
|
||||
{
|
||||
var broadcaster = document.getElementById("Communicator:WorkMode");
|
||||
var panel = document.getElementById("offline-status");
|
||||
if (!broadcaster || !panel) return;
|
||||
|
||||
//Checking for a preference "network.online", if it's locked, disabling
|
||||
// network icon and menu item
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
prefService = prefService.getService();
|
||||
prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
|
||||
|
||||
var prefBranch = prefService.getBranch(null);
|
||||
|
||||
var offlineLocked = prefBranch.prefIsLocked("network.online");
|
||||
|
||||
if (offlineLocked ) {
|
||||
broadcaster.setAttribute("disabled","true");
|
||||
}
|
||||
|
||||
var bundle = srGetStrBundle("chrome://communicator/locale/utilityOverlay.properties");
|
||||
|
||||
if (offline)
|
||||
{
|
||||
broadcaster.setAttribute("offline", "true");
|
||||
panel.setAttribute("tooltiptext", bundle.GetStringFromName("offlineTooltip"));
|
||||
broadcaster.setAttribute("label", bundle.GetStringFromName("goonline"));
|
||||
}
|
||||
else
|
||||
{
|
||||
broadcaster.removeAttribute("offline");
|
||||
panel.setAttribute("tooltiptext", bundle.GetStringFromName("onlineTooltip"));
|
||||
broadcaster.setAttribute("label", bundle.GetStringFromName("gooffline"));
|
||||
}
|
||||
}
|
||||
|
||||
function getBrowserURL() {
|
||||
return "chrome://browser/content/browser.xul";
|
||||
}
|
||||
|
||||
function goPageSetup(printSettings)
|
||||
{
|
||||
try {
|
||||
// This code calls the printoptions service to bring up the printoptions
|
||||
// dialog. This will be an xp dialog if the platform did not override
|
||||
// the ShowPrintSetupDialog method.
|
||||
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
|
||||
.getService(Components.interfaces.nsIPrintOptions);
|
||||
printOptionsService.ShowPrintSetupDialog(printSettings);
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
function goPreferences(containerID, paneURL, itemID)
|
||||
{
|
||||
//check for an existing pref window and focus it; it's not application modal
|
||||
const kWindowMediatorContractID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
|
||||
const kWindowMediatorIID = Components.interfaces.nsIWindowMediator;
|
||||
const kWindowMediator = Components.classes[kWindowMediatorContractID].getService(kWindowMediatorIID);
|
||||
var lastPrefWindow = kWindowMediator.getMostRecentWindow("mozilla:preferences");
|
||||
if (lastPrefWindow)
|
||||
lastPrefWindow.focus();
|
||||
else {
|
||||
openDialog("chrome://browser/content/pref/pref.xul","PrefWindow",
|
||||
"chrome,titlebar", paneURL, containerID, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
function goToggleToolbar( id, elementID )
|
||||
{
|
||||
var toolbar = document.getElementById( id );
|
||||
var element = document.getElementById( elementID );
|
||||
if ( toolbar )
|
||||
{
|
||||
var attribValue = toolbar.getAttribute("hidden") ;
|
||||
|
||||
if ( attribValue == "true" )
|
||||
{
|
||||
toolbar.setAttribute("hidden", "false" );
|
||||
if ( element )
|
||||
element.setAttribute("checked","true")
|
||||
}
|
||||
else
|
||||
{
|
||||
toolbar.setAttribute("hidden", true );
|
||||
if ( element )
|
||||
element.setAttribute("checked","false")
|
||||
}
|
||||
document.persist(id, 'hidden');
|
||||
document.persist(elementID, 'checked');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function goClickThrobber( urlPref )
|
||||
{
|
||||
var url;
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
url = pref.getComplexValue(urlPref, Components.interfaces.nsIPrefLocalizedString).data;
|
||||
}
|
||||
|
||||
catch(e) {
|
||||
url = null;
|
||||
}
|
||||
|
||||
if ( url )
|
||||
openTopWin(url);
|
||||
}
|
||||
|
||||
function openTopWin( url )
|
||||
{
|
||||
/* note that this chrome url should probably change to not have
|
||||
all of the navigator controls, but if we do this we need to have
|
||||
the option for chrome controls because goClickThrobber() needs to
|
||||
use this function with chrome controls */
|
||||
/* also, do we want to
|
||||
limit the number of help windows that can be spawned? */
|
||||
if ((url == null) || (url == "")) return;
|
||||
|
||||
// xlate the URL if necessary
|
||||
if (url.indexOf("urn:") == 0)
|
||||
{
|
||||
url = xlateURL(url); // does RDF urn expansion
|
||||
}
|
||||
|
||||
// avoid loading "", since this loads a directory listing
|
||||
if (url == "") {
|
||||
url = "about:blank";
|
||||
}
|
||||
|
||||
var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
||||
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
|
||||
|
||||
var topWindowOfType = windowManagerInterface.getMostRecentWindow( "navigator:browser" );
|
||||
if ( topWindowOfType )
|
||||
{
|
||||
topWindowOfType.focus();
|
||||
topWindowOfType._content.location.href = url;
|
||||
return topWindowOfType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );
|
||||
}
|
||||
}
|
||||
|
||||
function goAboutDialog()
|
||||
{
|
||||
window.openDialog("chrome://global/content/about.xul", "About", "modal,chrome,resizable=yes,height=450,width=550");
|
||||
}
|
||||
|
||||
// update menu items that rely on focus
|
||||
function goUpdateGlobalEditMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_undo');
|
||||
goUpdateCommand('cmd_redo');
|
||||
goUpdateCommand('cmd_cut');
|
||||
goUpdateCommand('cmd_copy');
|
||||
goUpdateCommand('cmd_paste');
|
||||
goUpdateCommand('cmd_selectAll');
|
||||
goUpdateCommand('cmd_delete');
|
||||
}
|
||||
|
||||
// update menu items that rely on the current selection
|
||||
function goUpdateSelectEditMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_cut');
|
||||
goUpdateCommand('cmd_copy');
|
||||
goUpdateCommand('cmd_delete');
|
||||
goUpdateCommand('cmd_selectAll');
|
||||
}
|
||||
|
||||
// update menu items that relate to undo/redo
|
||||
function goUpdateUndoEditMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_undo');
|
||||
goUpdateCommand('cmd_redo');
|
||||
}
|
||||
|
||||
// update menu items that depend on clipboard contents
|
||||
function goUpdatePasteMenuItems()
|
||||
{
|
||||
goUpdateCommand('cmd_paste');
|
||||
}
|
||||
|
||||
// Gather all descendent text under given document node.
|
||||
function gatherTextUnder ( root )
|
||||
{
|
||||
var text = "";
|
||||
var node = root.firstChild;
|
||||
var depth = 1;
|
||||
while ( node && depth > 0 ) {
|
||||
// See if this node is text.
|
||||
if ( node.nodeName == "#text" ) {
|
||||
// Add this text to our collection.
|
||||
text += " " + node.data;
|
||||
} else if ( node.nodeType == Node.ELEMENT_NODE
|
||||
&& node.localName.toUpperCase() == "IMG" ) {
|
||||
// If it has an alt= attribute, use that.
|
||||
var altText = node.getAttribute( "alt" );
|
||||
if ( altText && altText != "" ) {
|
||||
text = altText;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Find next node to test.
|
||||
// First, see if this node has children.
|
||||
if ( node.hasChildNodes() ) {
|
||||
// Go to first child.
|
||||
node = node.firstChild;
|
||||
depth++;
|
||||
} else {
|
||||
// No children, try next sibling.
|
||||
if ( node.nextSibling ) {
|
||||
node = node.nextSibling;
|
||||
} else {
|
||||
// Last resort is our next oldest uncle/aunt.
|
||||
node = node.parentNode.nextSibling;
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Strip leading whitespace.
|
||||
text = text.replace( /^\s+/, "" );
|
||||
// Strip trailing whitespace.
|
||||
text = text.replace( /\s+$/, "" );
|
||||
// Compress remaining whitespace.
|
||||
text = text.replace( /\s+/g, " " );
|
||||
return text;
|
||||
}
|
||||
|
||||
var offlineObserver = {
|
||||
observe: function(subject, topic, state) {
|
||||
// sanity checks
|
||||
if (topic != "network:offline-status-changed") return;
|
||||
setOfflineUI(state == "offline");
|
||||
}
|
||||
}
|
||||
|
||||
function utilityOnLoad(aEvent)
|
||||
{
|
||||
var broadcaster = document.getElementById("Communicator:WorkMode");
|
||||
if (!broadcaster) return;
|
||||
|
||||
var observerService = Components.classes[kObserverServiceProgID]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
|
||||
// crude way to prevent registering twice.
|
||||
try {
|
||||
observerService.removeObserver(offlineObserver, "network:offline-status-changed");
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
observerService.addObserver(offlineObserver, "network:offline-status-changed", false);
|
||||
// make sure we remove this observer later
|
||||
|
||||
// set the initial state
|
||||
var ioService = Components.classes[kIOServiceProgID]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
setOfflineUI(ioService.offline);
|
||||
}
|
||||
|
||||
function utilityOnUnload(aEvent)
|
||||
{
|
||||
var observerService = Components.classes[kObserverServiceProgID]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
observerService.removeObserver(offlineObserver, "network:offline-status-changed");
|
||||
}
|
Загрузка…
Ссылка в новой задаче