2005-08-05 04:02:24 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
*
|
|
|
|
* 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):
|
2005-09-13 22:40:56 +04:00
|
|
|
* Marcio S. Galli - mgalli@geckonnection.com
|
2005-08-09 01:32:24 +04:00
|
|
|
*
|
2005-08-05 04:02:24 +04:00
|
|
|
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
const nsCI = Components.interfaces;
|
|
|
|
const nsIWebNavigation = nsCI.nsIWebNavigation;
|
|
|
|
const nsIWebProgressListener = nsCI.nsIWebProgressListener;
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
var gBrowser = null;
|
2005-12-02 23:13:15 +03:00
|
|
|
var gBookmarksDoc=null;
|
2005-08-05 04:02:24 +04:00
|
|
|
var gURLBar = null;
|
2005-12-08 23:07:13 +03:00
|
|
|
var gClickSelectsAll = true;
|
|
|
|
var gIgnoreFocus = false;
|
|
|
|
var gIgnoreClick = false;
|
2005-08-05 04:02:24 +04:00
|
|
|
var gBrowserStatusHandler;
|
|
|
|
var gSelectedTab=null;
|
2005-08-16 23:19:59 +04:00
|
|
|
var gFullScreen=false;
|
2005-09-21 02:38:34 +04:00
|
|
|
var gRSSTag="minimo";
|
2005-08-21 05:17:59 +04:00
|
|
|
var gGlobalHistory = null;
|
|
|
|
var gURIFixup = null;
|
2005-09-30 22:35:53 +04:00
|
|
|
var gShowingMenuPopup=null;
|
2005-11-22 01:45:38 +03:00
|
|
|
var gFocusedElementHREFContextMenu=null;
|
2005-11-24 01:27:03 +03:00
|
|
|
var gDeckMode=0; // 0 = site, 1 = sb, 2= rss. Used for the URLBAR selector, DeckMode impl.
|
|
|
|
var gDeckMenuChecked=null; // to keep the state of the checked URLBAR selector mode.
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-10-06 05:05:51 +04:00
|
|
|
var gPref = null; // so far snav toggles on / off via direct access to pref.
|
|
|
|
// See bugzilla.mozilla.org/show_bug.cgi?id=311287#c1
|
2005-12-03 00:07:25 +03:00
|
|
|
var gPrefAdded=false; // shall be used to flush the pref.
|
2005-11-17 03:44:38 +03:00
|
|
|
|
|
|
|
var gSNAV=-1;
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
function nsBrowserStatusHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBrowserStatusHandler.prototype =
|
|
|
|
{
|
|
|
|
QueryInterface : function(aIID)
|
|
|
|
{
|
2006-01-04 01:40:07 +03:00
|
|
|
if (aIID.equals(nsCI.nsIWebProgressListener) ||
|
|
|
|
aIID.equals(nsCI.nsISupportsWeakReference) ||
|
|
|
|
aIID.equals(nsCI.nsISupports))
|
2005-08-05 04:02:24 +04:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw Components.results.NS_NOINTERFACE;
|
|
|
|
},
|
|
|
|
|
|
|
|
init : function()
|
|
|
|
{
|
|
|
|
this.urlBar = document.getElementById("urlbar");
|
|
|
|
this.stopreloadButton = document.getElementById("reload-stop-button");
|
2005-08-09 01:32:24 +04:00
|
|
|
this.progressBGPosition = 0; /* To be removed, fix in onProgressChange ... */
|
2005-08-05 04:02:24 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy : function()
|
|
|
|
{
|
|
|
|
this.urlBar = null;
|
|
|
|
this.stopreloadButton = null;
|
2005-08-09 01:32:24 +04:00
|
|
|
this.progressBGPosition = null; /* To be removed, fix in onProgressChange ... */
|
2005-08-05 04:02:24 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
|
|
|
{
|
2005-09-15 21:48:14 +04:00
|
|
|
var refBrowser=null;
|
|
|
|
var tabItem=null;
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_START)
|
|
|
|
{
|
2005-12-01 03:03:16 +03:00
|
|
|
document.getElementById("statusbar").hidden=false;
|
|
|
|
|
2005-11-22 07:23:43 +03:00
|
|
|
if(aRequest && aWebProgress.DOMWindow == content) {
|
|
|
|
this.startDocumentLoad(aRequest);
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
this.stopreloadButton.className = "stop-button";
|
2005-09-30 00:21:25 +04:00
|
|
|
this.stopreloadButton.command = "cmd_BrowserStop";
|
2005-09-15 21:48:14 +04:00
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_STOP)
|
|
|
|
{
|
2005-12-01 03:03:16 +03:00
|
|
|
document.getElementById("statusbar").hidden=true;
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
/* To be fixed. We dont want to directly access sytle from here */
|
|
|
|
document.styleSheets[1].cssRules[0].style.backgroundPosition="1000px 100%";
|
|
|
|
|
|
|
|
this.stopreloadButton.className = "reload-button";
|
2005-09-30 00:21:25 +04:00
|
|
|
this.stopreloadButton.command= "cmd_BrowserReload";
|
2005-11-22 01:45:38 +03:00
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT)
|
|
|
|
{
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_START)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_STOP)
|
|
|
|
{
|
2005-12-01 03:03:16 +03:00
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// var imageCache = Components.classes["@mozilla.org/image/cache;1"]
|
2006-01-04 01:40:07 +03:00
|
|
|
// .getService(nsCI.imgICache);
|
2005-12-01 03:03:16 +03:00
|
|
|
// imageCache.clearCache(false);
|
|
|
|
// }
|
|
|
|
// catch(e) {}
|
|
|
|
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
|
|
|
|
{
|
|
|
|
var percentage = parseInt((aCurTotalProgress * 100) / aMaxTotalProgress);
|
|
|
|
document.styleSheets[1].cssRules[0].style.backgroundPosition=percentage+"px 100%";
|
|
|
|
},
|
|
|
|
onLocationChange : function(aWebProgress, aRequest, aLocation)
|
|
|
|
{
|
2005-09-15 21:48:14 +04:00
|
|
|
/* Ideally we dont want to check this here.
|
|
|
|
Better to have some other protocol view-rss in the chrome */
|
|
|
|
|
2005-11-21 22:01:06 +03:00
|
|
|
const rssmask = "chrome://minimo/content/rssview/rssload.xhtml?url=";
|
|
|
|
const sbmask = "chrome://minimo/content/rssview/rssload.xhtml?url=http://del.icio.us/rss/tag/";
|
2005-09-15 21:48:14 +04:00
|
|
|
|
2005-11-21 22:01:06 +03:00
|
|
|
if(aLocation.spec.substr(0, rssmask .length) == rssmask ) {
|
2005-11-19 03:03:34 +03:00
|
|
|
|
2005-11-21 22:01:06 +03:00
|
|
|
if(aLocation.spec.substr(0, sbmask .length) == sbmask ) {
|
|
|
|
/* We trap the URL */
|
|
|
|
this.urlBar.value="sb:"+gRSSTag;
|
2005-11-19 03:03:34 +03:00
|
|
|
|
2005-11-21 22:01:06 +03:00
|
|
|
} else {
|
|
|
|
|
|
|
|
/* We trap the URL */
|
|
|
|
this.urlBar.value="rss:"+gRSSTag;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-09-15 21:48:14 +04:00
|
|
|
} else {
|
2005-12-02 23:27:58 +03:00
|
|
|
domWindow = aWebProgress.DOMWindow;
|
|
|
|
// Update urlbar only if there was a load on the root docshell
|
|
|
|
if (domWindow == domWindow.top) {
|
|
|
|
this.urlBar.value = aLocation.spec;
|
|
|
|
}
|
2005-09-15 21:48:14 +04:00
|
|
|
}
|
2005-12-08 01:21:52 +03:00
|
|
|
|
|
|
|
BrowserUpdateBackForwardState();
|
2005-11-22 01:45:38 +03:00
|
|
|
|
|
|
|
BrowserUpdateFeeds();
|
2005-09-15 21:48:14 +04:00
|
|
|
},
|
2005-08-05 04:02:24 +04:00
|
|
|
|
|
|
|
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
|
|
|
|
{
|
2005-12-01 03:03:16 +03:00
|
|
|
document.getElementById("statusbar-text").label=aMessage;
|
2005-08-05 04:02:24 +04:00
|
|
|
},
|
2005-11-22 07:23:43 +03:00
|
|
|
startDocumentLoad : function(aRequest)
|
|
|
|
{
|
|
|
|
getBrowser().mCurrentBrowser.feeds = null;
|
|
|
|
},
|
2005-08-05 04:02:24 +04:00
|
|
|
onSecurityChange : function(aWebProgress, aRequest, aState)
|
|
|
|
{
|
2005-08-09 01:38:08 +04:00
|
|
|
/* Color is temporary. We shall dynamically assign a new class to the element and or to
|
|
|
|
evaluate access from another class rule, the security identity color has to be with the minimo.css */
|
2005-08-09 02:03:09 +04:00
|
|
|
|
|
|
|
switch (aState) {
|
|
|
|
case nsIWebProgressListener.STATE_IS_SECURE | nsIWebProgressListener.STATE_SECURE_HIGH:
|
|
|
|
//this.urlBar.value="level high";
|
|
|
|
document.styleSheets[1].cssRules[0].style.backgroundColor="yellow";
|
2005-09-21 03:40:20 +04:00
|
|
|
document.getElementById("lock-icon").className="security-notbroken";
|
2005-08-09 02:03:09 +04:00
|
|
|
break;
|
|
|
|
case nsIWebProgressListener.STATE_IS_SECURE | nsIWebProgressListener.STATE_SECURE_LOW:
|
|
|
|
// this.urlBar.value="level low";
|
|
|
|
document.styleSheets[1].cssRules[0].style.backgroundColor="lightyellow";
|
2005-09-21 03:40:20 +04:00
|
|
|
document.getElementById("lock-icon").className="security-notbroken";
|
2005-08-09 02:03:09 +04:00
|
|
|
break;
|
|
|
|
case nsIWebProgressListener.STATE_IS_BROKEN:
|
|
|
|
//this.urlBar.value="level broken";
|
|
|
|
document.styleSheets[1].cssRules[0].style.backgroundColor="lightred";
|
2005-09-21 03:40:20 +04:00
|
|
|
document.getElementById("lock-icon").className="security-broken";
|
2005-08-09 02:03:09 +04:00
|
|
|
break;
|
|
|
|
case nsIWebProgressListener.STATE_IS_INSECURE:
|
|
|
|
default:
|
|
|
|
document.styleSheets[1].cssRules[0].style.backgroundColor="white";
|
2005-09-21 03:40:20 +04:00
|
|
|
document.getElementById("lock-icon").className="security-na";
|
2005-08-09 02:03:09 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initial Minimo Startup
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
|
|
|
/* moved this as global */
|
|
|
|
|
|
|
|
function MiniNavStartup()
|
|
|
|
{
|
2005-09-17 07:26:09 +04:00
|
|
|
var homepage = "http://www.mozilla.org";
|
2005-09-16 06:57:27 +04:00
|
|
|
|
|
|
|
try {
|
2005-11-17 03:44:38 +03:00
|
|
|
|
2005-09-19 09:47:21 +04:00
|
|
|
gURLBar = document.getElementById("urlbar");
|
2005-12-08 23:07:13 +03:00
|
|
|
gURLBar.setAttribute("completedefaultindex", "true");
|
|
|
|
|
2005-09-19 09:47:21 +04:00
|
|
|
var currentTab=getBrowser().selectedTab;
|
|
|
|
browserInit(currentTab);
|
|
|
|
gSelectedTab=currentTab;
|
|
|
|
|
|
|
|
var BrowserStatusHandler = new nsBrowserStatusHandler();
|
|
|
|
BrowserStatusHandler.init();
|
2005-09-17 07:26:09 +04:00
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
window.QueryInterface(nsCI.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
|
|
|
|
|
|
|
|
getBrowser().addProgressListener(BrowserStatusHandler, nsCI.nsIWebProgress.NOTIFY_ALL);
|
2005-09-17 07:26:09 +04:00
|
|
|
|
|
|
|
// Current build was not able to get it. Taking it from the tab browser element.
|
|
|
|
// var webNavigation=getBrowser().webNavigation;
|
|
|
|
|
|
|
|
var refBrowser=getBrowser().getBrowserForTab(currentTab);
|
|
|
|
var webNavigation=refBrowser.webNavigation;
|
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"].createInstance(nsCI.nsISHistory);
|
2005-09-15 21:48:14 +04:00
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
getBrowser().docShell.QueryInterface(nsCI.nsIDocShellHistory).useGlobalHistory = true;
|
2005-09-19 09:47:21 +04:00
|
|
|
|
|
|
|
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;2"]
|
2006-01-04 01:40:07 +03:00
|
|
|
.getService(nsCI.nsIBrowserHistory);
|
2005-09-19 09:47:21 +04:00
|
|
|
|
|
|
|
gURIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
|
2006-01-04 01:40:07 +03:00
|
|
|
.getService(nsCI.nsIURIFixup);
|
2005-09-19 09:47:21 +04:00
|
|
|
|
2005-12-02 23:13:15 +03:00
|
|
|
var bookmarkstore=null;
|
2005-09-19 09:47:21 +04:00
|
|
|
|
|
|
|
try {
|
2005-10-06 05:05:51 +04:00
|
|
|
gPref = Components.classes["@mozilla.org/preferences-service;1"]
|
2006-01-04 01:40:07 +03:00
|
|
|
.getService(nsCI.nsIPrefBranch);
|
2005-09-24 00:05:57 +04:00
|
|
|
|
2005-10-06 05:05:51 +04:00
|
|
|
var page = gPref.getCharPref("browser.startup.homepage");
|
2005-12-02 23:13:15 +03:00
|
|
|
var bookmarkstore = gPref.getCharPref("browser.bookmark.store");
|
2005-09-19 09:47:21 +04:00
|
|
|
|
|
|
|
if (page != null)
|
2005-09-24 00:05:57 +04:00
|
|
|
{
|
|
|
|
var fixedUpURI = gURIFixup.createFixupURI(page, 2 /*fixup url*/ );
|
|
|
|
homepage = fixedUpURI.spec;
|
|
|
|
}
|
2005-09-19 09:47:21 +04:00
|
|
|
} catch (ignore) {}
|
2005-11-17 03:44:38 +03:00
|
|
|
|
2005-09-15 21:48:14 +04:00
|
|
|
} catch (e) {
|
|
|
|
alert("Error trying to startup browser. Please report this as a bug:\n" + e);
|
|
|
|
}
|
|
|
|
|
2005-09-05 11:04:26 +04:00
|
|
|
loadURI(homepage);
|
2005-12-02 23:13:15 +03:00
|
|
|
loadBookmarks(bookmarkstore);
|
2005-09-30 00:21:25 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We add event handler to catch the right and left keys on the main_MenuPopup
|
|
|
|
*/
|
|
|
|
document.addEventListener("keypress",eventHandlerMenu,true);
|
2005-10-21 01:24:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sync UI zoom level
|
|
|
|
*/
|
|
|
|
|
|
|
|
syncUIZoom();
|
|
|
|
|
2005-11-11 22:12:32 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add event clicks to Minimo toolbars and also to the mStrip BOX in the tabbrowser
|
|
|
|
*/
|
2005-11-17 03:44:38 +03:00
|
|
|
getBrowser().mStrip.addEventListener("click",BrowserWithoutSNAV,false);
|
|
|
|
document.getElementById("mini-toolbars").addEventListener("click",BrowserWithoutSNAV,false);
|
2005-11-17 00:26:05 +03:00
|
|
|
|
2005-11-22 01:45:38 +03:00
|
|
|
getBrowser().addEventListener("DOMLinkAdded", BrowserLinkAdded, false);
|
|
|
|
|
2005-09-30 00:21:25 +04:00
|
|
|
}
|
|
|
|
|
2005-11-22 01:45:38 +03:00
|
|
|
/*
|
|
|
|
* Page's new Link tag handlers. This should be able to be smart about RSS, CSS, and maybe other Minimo stuff?
|
|
|
|
* So far we have this here, so we can experience and try some new stuff. To be tabrowsed.
|
|
|
|
*/
|
|
|
|
function BrowserLinkAdded(event) {
|
|
|
|
// ref http://lxr.mozilla.org/mozilla/source/browser/base/content/browser.js#2070
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Taken from browser.js - yes this should be in tabbrowser
|
|
|
|
*/
|
|
|
|
|
|
|
|
var erel = event.target.rel;
|
|
|
|
var etype = event.target.type;
|
|
|
|
var etitle = event.target.title;
|
|
|
|
var ehref = event.target.href;
|
|
|
|
|
|
|
|
const alternateRelRegex = /(^|\s)alternate($|\s)/i;
|
|
|
|
const rssTitleRegex = /(^|\s)rss($|\s)/i;
|
|
|
|
|
|
|
|
if (!alternateRelRegex.test(erel) || !etype) return;
|
|
|
|
|
|
|
|
etype = etype.replace(/^\s+/, "");
|
|
|
|
etype = etype.replace(/\s+$/, "");
|
|
|
|
etype = etype.replace(/\s*;.*/, "");
|
|
|
|
etype = etype.toLowerCase();
|
|
|
|
|
|
|
|
if (etype == "application/rss+xml" || etype == "application/atom+xml" || (etype == "text/xml" || etype == "application/xml" || etype == "application/rdf+xml") && rssTitleRegex.test(etitle))
|
|
|
|
{
|
|
|
|
|
|
|
|
const targetDoc = event.target.ownerDocument;
|
|
|
|
|
|
|
|
var browsers = getBrowser().browsers;
|
|
|
|
var shellInfo = null;
|
|
|
|
|
|
|
|
for (var i = 0; i < browsers.length; i++) {
|
|
|
|
var shell = findChildShell(targetDoc, browsers[i].docShell, null);
|
|
|
|
if (shell) shellInfo = { shell: shell, browser: browsers[i] };
|
|
|
|
}
|
|
|
|
|
|
|
|
//var shellInfo = this._getContentShell(targetDoc);
|
|
|
|
|
|
|
|
var browserForLink = shellInfo.browser;
|
|
|
|
|
|
|
|
if(!browserForLink) return;
|
|
|
|
|
|
|
|
var feeds = [];
|
|
|
|
if (browserForLink.feeds != null) feeds = browserForLink.feeds;
|
|
|
|
var wrapper = event.target;
|
|
|
|
feeds.push({ href: wrapper.href, type: etype, title: wrapper.title});
|
|
|
|
browserForLink.feeds = feeds;
|
|
|
|
|
|
|
|
if (browserForLink == getBrowser() || browserForLink == getBrowser().mCurrentBrowser) {
|
|
|
|
var feedButton = document.getElementById("feed-button");
|
|
|
|
if (feedButton) {
|
|
|
|
feedButton.setAttribute("feeds", "true");
|
|
|
|
// feedButton.setAttribute("tooltiptext", gNavigatorBundle.getString("feedHasFeeds"));
|
|
|
|
document.getElementById("feed-button-menu").setAttribute("onpopupshowing","DoBrowserRSS('"+ehref+"')");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserUpdateFeeds() {
|
|
|
|
var feedButton = document.getElementById("feed-button");
|
|
|
|
if (!feedButton)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var feeds = getBrowser().mCurrentBrowser.feeds;
|
|
|
|
|
|
|
|
if (!feeds || feeds.length == 0) {
|
|
|
|
if (feedButton.hasAttribute("feeds")) feedButton.removeAttribute("feeds");
|
|
|
|
// feedButton.setAttribute("tooltiptext", gNavigatorBundle.getString("feedNoFeeds"));
|
|
|
|
} else {
|
|
|
|
feedButton.setAttribute("feeds", "true");
|
|
|
|
document.getElementById("feed-button-menu").setAttribute("onpopupshowing","DoBrowserRSS('"+feeds[0].href+"')");
|
|
|
|
|
|
|
|
// feedButton.setAttribute("tooltiptext", gNavigatorBundle.getString("feedHasFeeds"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-08 01:21:52 +03:00
|
|
|
/*
|
|
|
|
* For now, this updates via DOM the top menu. Context menu should be here as well.
|
|
|
|
*/
|
|
|
|
function BrowserUpdateBackForwardState() {
|
|
|
|
|
|
|
|
if(getBrowser().webNavigation.canGoBack) {
|
|
|
|
document.getElementById("back-button").setAttribute("disabled","false");
|
|
|
|
} else {
|
|
|
|
document.getElementById("back-button").setAttribute("disabled","true");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(getBrowser().webNavigation.canGoForward) {
|
|
|
|
document.getElementById("forward-button").setAttribute("disabled","false");
|
|
|
|
} else {
|
|
|
|
document.getElementById("forward-button").setAttribute("disabled","true");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-22 01:45:38 +03:00
|
|
|
|
|
|
|
function findChildShell(aDocument, aDocShell, aSoughtURI) {
|
2006-01-04 01:40:07 +03:00
|
|
|
aDocShell.QueryInterface(nsCI.nsIWebNavigation);
|
|
|
|
aDocShell.QueryInterface(nsCI.nsIInterfaceRequestor);
|
|
|
|
var doc = aDocShell.getInterface(nsCI.nsIDOMDocument);
|
2005-11-22 01:45:38 +03:00
|
|
|
if ((aDocument && doc == aDocument) ||
|
|
|
|
(aSoughtURI && aSoughtURI.spec == aDocShell.currentURI.spec))
|
|
|
|
return aDocShell;
|
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
var node = aDocShell.QueryInterface(nsCI.nsIDocShellTreeNode);
|
2005-11-22 01:45:38 +03:00
|
|
|
for (var i = 0; i < node.childCount; ++i) {
|
|
|
|
var docShell = node.getChildAt(i);
|
|
|
|
docShell = findChildShell(aDocument, docShell, aSoughtURI);
|
|
|
|
if (docShell) return docShell;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-11 22:12:32 +03:00
|
|
|
function BrowserWithoutSNAV(e) {
|
2005-11-17 03:44:38 +03:00
|
|
|
if(gSNAV==1||gSNAV==-1) {
|
|
|
|
gSNAV=0;
|
|
|
|
gPref.setBoolPref("snav.enabled", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserWithSNAV(e) {
|
|
|
|
if(gSNAV==0||gSNAV==-1) {
|
|
|
|
gSNAV=1;
|
|
|
|
gPref.setBoolPref("snav.enabled", true);
|
|
|
|
}
|
2005-10-06 05:05:51 +04:00
|
|
|
}
|
|
|
|
|
2005-09-30 22:35:53 +04:00
|
|
|
/*
|
|
|
|
* Focus Shortcut Action. This is just a focus action dispatcher based on certain conditions
|
|
|
|
* defined in the XUL elements. Ideally would be interesting to have this as part of some new
|
|
|
|
* XUL elements that are based on existing XUL elements, or to incorporate, import, this behavior
|
|
|
|
* in the XUL declaration.
|
|
|
|
*/
|
2005-09-30 00:21:25 +04:00
|
|
|
function eventHandlerMenu(e) {
|
2005-09-30 23:08:13 +04:00
|
|
|
|
2005-09-30 00:21:25 +04:00
|
|
|
if( (e.keyCode==39 || e.keyCode==37) && (gShowingMenuPopup) ) {
|
|
|
|
BrowserMenuPopupFalse();
|
2005-10-01 03:01:26 +04:00
|
|
|
document.getElementById("menu-button").focus(); // forcing state back to the menu.
|
2005-09-30 00:21:25 +04:00
|
|
|
}
|
2005-09-30 22:35:53 +04:00
|
|
|
|
2005-11-09 22:04:38 +03:00
|
|
|
if( e.keyCode==70) /*SoftKey1 or HWKey1*/ {
|
2005-10-01 00:24:14 +04:00
|
|
|
document.getElementById("menu-button").focus();
|
2005-11-11 22:12:32 +03:00
|
|
|
e.preventBubble();
|
2005-11-17 03:44:38 +03:00
|
|
|
BrowserWithoutSNAV();
|
|
|
|
|
2005-10-01 00:24:14 +04:00
|
|
|
}
|
|
|
|
|
2005-11-09 22:07:54 +03:00
|
|
|
if(document.commandDispatcher&&document.commandDispatcher.focusedElement) {
|
|
|
|
|
|
|
|
var outnavTarget=document.commandDispatcher.focusedElement.getAttribute("accessrule");
|
2005-11-22 20:50:01 +03:00
|
|
|
|
|
|
|
if(outnavTarget && (e.keyCode==40||e.keyCode==38) && !gShowingMenuPopup) {
|
|
|
|
|
2005-11-09 22:07:54 +03:00
|
|
|
e.preventBubble();
|
|
|
|
if(e.keyCode==40) {
|
|
|
|
|
|
|
|
ruleElement=findRuleById(document.getElementById(outnavTarget).getAttribute("accessnextrule"),"accessnextrule");
|
|
|
|
}
|
|
|
|
if(e.keyCode==38) {
|
|
|
|
|
|
|
|
ruleElement=findRuleById(document.getElementById(outnavTarget).getAttribute("accessprevrule"),"accessprevrule");
|
|
|
|
}
|
|
|
|
var tempElement=ruleElement.getAttribute("accessfocus");
|
|
|
|
if(tempElement.indexOf("#")>-1) {
|
|
|
|
|
|
|
|
if(tempElement=="#tabContainer") {
|
|
|
|
if(getBrowser().tabContainer) {
|
|
|
|
getBrowser().selectedTab.focus();
|
2005-11-11 22:12:32 +03:00
|
|
|
|
2005-11-17 03:48:48 +03:00
|
|
|
if(getBrowser().mStrip.collapsed) {
|
|
|
|
getBrowser().contentWindow.focus();
|
2005-11-11 22:12:32 +03:00
|
|
|
}
|
|
|
|
|
2005-11-09 22:07:54 +03:00
|
|
|
}
|
|
|
|
}
|
2005-11-17 03:48:48 +03:00
|
|
|
if(tempElement=="#tabContent") {
|
2005-11-12 01:49:40 +03:00
|
|
|
getBrowser().contentWindow.focus();
|
2005-11-09 22:07:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
document.getElementById(tempElement).focus();
|
|
|
|
}
|
2005-09-30 23:08:13 +04:00
|
|
|
}
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
2005-09-30 23:18:46 +04:00
|
|
|
function findRuleById(outnavTarget,ruleattribute) {
|
2005-09-30 22:35:53 +04:00
|
|
|
var ruleElement=document.getElementById(outnavTarget);
|
|
|
|
|
2005-10-26 05:47:51 +04:00
|
|
|
if(document.getElementById(ruleElement.getAttribute("target")).collapsed) {
|
2005-10-01 03:01:26 +04:00
|
|
|
return findRuleById(ruleElement.getAttribute(ruleattribute), ruleattribute);
|
2005-09-30 22:35:53 +04:00
|
|
|
} else {
|
|
|
|
return ruleElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-30 23:18:46 +04:00
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
/**
|
|
|
|
* Init stuff
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
function browserInit(refTab)
|
|
|
|
{
|
2005-10-01 02:38:11 +04:00
|
|
|
/*
|
|
|
|
* addRule access navigational rule to each tab
|
|
|
|
*/
|
|
|
|
|
2005-10-26 05:47:51 +04:00
|
|
|
refTab.setAttribute("accessrule","focus_content");
|
2005-10-01 02:38:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2005-09-15 21:48:14 +04:00
|
|
|
var refBrowser=getBrowser().getBrowserForTab(refTab);
|
2005-11-17 03:44:38 +03:00
|
|
|
|
|
|
|
/* New Browser OnFocus SNAV Toggle */
|
|
|
|
|
|
|
|
refBrowser.addEventListener("focus", BrowserWithSNAV , true);
|
|
|
|
|
2005-09-15 21:48:14 +04:00
|
|
|
try {
|
|
|
|
refBrowser.markupDocumentViewer.textZoom = .90;
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
gURLBar = document.getElementById("urlbar");
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function MiniNavShutdown()
|
|
|
|
{
|
|
|
|
if (gBrowserStatusHandler) gBrowserStatusHandler.destroy();
|
2005-12-03 00:07:25 +03:00
|
|
|
if(gPrefAdded) {
|
|
|
|
try {
|
|
|
|
var psvc = Components.classes["@mozilla.org/preferences-service;1"]
|
2006-01-04 01:40:07 +03:00
|
|
|
.getService(nsCI.nsIPrefService);
|
2005-12-03 00:07:25 +03:00
|
|
|
|
|
|
|
psvc.savePrefFile(null);
|
|
|
|
|
|
|
|
} catch (e) { alert(e); }
|
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function getBrowser()
|
|
|
|
{
|
2006-01-04 01:40:07 +03:00
|
|
|
if (!gBrowser)
|
|
|
|
gBrowser = document.getElementById("content");
|
|
|
|
return gBrowser;
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function getWebNavigation()
|
|
|
|
{
|
|
|
|
return getBrowser().webNavigation;
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadURI(uri)
|
|
|
|
{
|
|
|
|
getWebNavigation().loadURI(uri, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserBack()
|
|
|
|
{
|
|
|
|
getWebNavigation().goBack();
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserForward()
|
|
|
|
{
|
|
|
|
getWebNavigation().goForward();
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserStop()
|
|
|
|
{
|
|
|
|
getWebNavigation().stop(nsIWebNavigation.STOP_ALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserReload()
|
|
|
|
{
|
|
|
|
getWebNavigation().reload(nsIWebNavigation.LOAD_FLAGS_NONE);
|
|
|
|
}
|
|
|
|
|
2005-10-25 23:20:32 +04:00
|
|
|
/*
|
|
|
|
* Combine the two following functions in one
|
|
|
|
*/
|
2005-08-05 04:02:24 +04:00
|
|
|
function BrowserOpenTab()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
getBrowser().selectedTab = getBrowser().addTab('about:blank');
|
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
} catch (e) {
|
2005-08-09 01:32:24 +04:00
|
|
|
alert(e);
|
2005-08-05 04:02:24 +04:00
|
|
|
}
|
|
|
|
// if (gURLBar) setTimeout(function() { gURLBar.focus(); }, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-10-25 23:20:32 +04:00
|
|
|
/*
|
|
|
|
* Used by the Context Menu - Open link as Tab
|
|
|
|
*/
|
|
|
|
function BrowserOpenLinkAsTab()
|
|
|
|
{
|
2005-11-22 01:45:38 +03:00
|
|
|
|
|
|
|
if(gFocusedElementHREFContextMenu) {
|
2005-10-25 23:20:32 +04:00
|
|
|
try {
|
2005-11-22 01:45:38 +03:00
|
|
|
getBrowser().selectedTab = getBrowser().addTab(gFocusedElementHREFContextMenu);
|
2005-10-25 23:20:32 +04:00
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
} catch (e) {
|
|
|
|
alert(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-07 00:16:32 +04:00
|
|
|
/**
|
|
|
|
* FOR - keyboard acessibility - context menu for tabbed area ***
|
|
|
|
* Launches the popup for the tabbed area / tabbrowser. Make sure to call this function
|
|
|
|
* when the tabbed panel is available. WARNING somehow need to inform which tab was lack clicked
|
|
|
|
* or mouse over.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
function BrowserLaunchTabbedPopup() {
|
|
|
|
var tabMenu = document.getAnonymousElementByAttribute(document.getElementById("content"),"anonid","tabContextMenu");
|
|
|
|
tabMenu.showPopup(getBrowser().selectedTab,-1,-1,"popup","bottomleft", "topleft");
|
|
|
|
}
|
2005-08-26 01:48:15 +04:00
|
|
|
|
2005-09-01 22:51:07 +04:00
|
|
|
/**
|
|
|
|
* Has to go through some other approach like a XML-based rule system.
|
|
|
|
* Those are constraints conditions and action.
|
|
|
|
**/
|
|
|
|
|
2005-08-26 01:48:15 +04:00
|
|
|
function BrowserViewOptions() {
|
2005-09-01 22:51:07 +04:00
|
|
|
document.getElementById("toolbar-view").collapsed=!document.getElementById("toolbar-view").collapsed;
|
|
|
|
if(document.getElementById("toolbar-view").collapsed && document.getElementById("command_ViewOptions").getAttribute("checked")=="true") {
|
|
|
|
document.getElementById("command_ViewOptions").setAttribute("checked","false");
|
|
|
|
}
|
2005-08-26 01:48:15 +04:00
|
|
|
}
|
2005-08-05 04:02:24 +04:00
|
|
|
|
2005-09-21 02:38:34 +04:00
|
|
|
/**
|
|
|
|
* Has to go through some other approach like a XML-based rule system.
|
|
|
|
* Those are constraints conditions and action.
|
|
|
|
**/
|
|
|
|
|
|
|
|
function BrowserViewRSS() {
|
|
|
|
document.getElementById("toolbar-rss").collapsed=!document.getElementById("toolbar-rss").collapsed;
|
2005-09-21 02:47:29 +04:00
|
|
|
if(document.getElementById("toolbar-rss").collapsed && document.getElementById("command_ViewRSS").getAttribute("checked")=="true") {
|
2005-09-21 02:38:34 +04:00
|
|
|
document.getElementById("command_ViewRSS").setAttribute("checked","false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-24 01:27:03 +03:00
|
|
|
/**
|
|
|
|
* Deckmode urlbar selector.
|
|
|
|
* Toggles menu item and deckmode.
|
|
|
|
*/
|
|
|
|
function BrowserViewDeckSB() {
|
2005-12-23 03:24:46 +03:00
|
|
|
BrowserSetDeck(1,document.getElementById("command_ViewDeckSB"));
|
2005-11-24 01:27:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserViewDeckSearch() {
|
2005-12-23 03:24:46 +03:00
|
|
|
BrowserSetDeck(2,document.getElementById("command_ViewDeckSearch"));
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserViewDeckDefault() {
|
|
|
|
BrowserSetDeck(0,document.getElementById("command_ViewDeckDefault"));
|
2005-11-24 01:27:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-25 23:46:34 +04:00
|
|
|
/**
|
|
|
|
* Has to go through some other approach like a XML-based rule system.
|
|
|
|
* Those are constraints conditions and action.
|
|
|
|
**/
|
|
|
|
|
|
|
|
function BrowserViewSearch() {
|
|
|
|
document.getElementById("toolbar-search").collapsed=!document.getElementById("toolbar-search").collapsed;
|
|
|
|
if(document.getElementById("toolbar-search").collapsed && document.getElementById("command_ViewSearch").getAttribute("checked")=="true") {
|
|
|
|
document.getElementById("command_ViewSearch").setAttribute("checked","false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-17 23:25:29 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Has to go through some other approach like a XML-based rule system.
|
|
|
|
* Those are constraints conditions and action.
|
|
|
|
**/
|
|
|
|
|
|
|
|
function BrowserViewFind() {
|
|
|
|
document.getElementById("toolbar-find").collapsed=!document.getElementById("toolbar-find").collapsed;
|
|
|
|
if(document.getElementById("toolbar-find").collapsed && document.getElementById("command_ViewFind").getAttribute("checked")=="true") {
|
|
|
|
document.getElementById("command_ViewFind").setAttribute("checked","false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 04:02:24 +04:00
|
|
|
/**
|
|
|
|
* urlbar indentity, style, progress indicator.
|
|
|
|
**/
|
|
|
|
function urlbar() {
|
|
|
|
}
|
2005-08-12 05:30:19 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* Reset the text size */
|
|
|
|
function BrowserResetZoomPlus() {
|
|
|
|
getBrowser().selectedBrowser.markupDocumentViewer.textZoom+= .25;
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserResetZoomMinus() {
|
|
|
|
getBrowser().selectedBrowser.markupDocumentViewer.textZoom-= .25;
|
|
|
|
}
|
|
|
|
|
2005-10-18 00:54:05 +04:00
|
|
|
|
|
|
|
/* Reset the UI text size */
|
|
|
|
function BrowserUIResetZoomPlus() {
|
2005-10-21 01:14:54 +04:00
|
|
|
var currentUILevel=gPref.getIntPref("browser.display.zoomui");
|
|
|
|
currentUILevel+=3;
|
|
|
|
gPref.setIntPref("browser.display.zoomui", currentUILevel);
|
|
|
|
syncUIZoom();
|
2005-10-27 00:15:17 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* YES I know.
|
|
|
|
* I do this because somehow the grid does not expand
|
|
|
|
* when the style CSS syncUIzoom kicks in
|
|
|
|
*/
|
|
|
|
document.getElementById("uizoomminusitem").focus();
|
|
|
|
document.getElementById("uizoomplusitem").focus();
|
2005-10-18 00:54:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserUIResetZoomMinus() {
|
2005-10-21 01:14:54 +04:00
|
|
|
var currentUILevel=gPref.getIntPref("browser.display.zoomui");
|
|
|
|
currentUILevel-=3;
|
|
|
|
gPref.setIntPref("browser.display.zoomui", currentUILevel);
|
|
|
|
syncUIZoom();
|
2005-10-27 00:15:17 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* YES I know.
|
|
|
|
* I do this because somehow the grid does not expand
|
|
|
|
* when the style CSS syncUIzoom kicks in
|
|
|
|
*/
|
|
|
|
document.getElementById("uizoomplusitem").focus();
|
|
|
|
document.getElementById("uizoomminusitem").focus();
|
2005-10-18 00:54:05 +04:00
|
|
|
}
|
|
|
|
|
2005-10-27 00:15:17 +04:00
|
|
|
|
2005-08-12 06:09:16 +04:00
|
|
|
/*
|
|
|
|
We want to intercept before it shows,
|
|
|
|
to evaluate when the selected content area is a phone number,
|
|
|
|
thus mutate the popup menu to the right make call item
|
|
|
|
*/
|
2005-11-22 01:45:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-08-12 06:09:16 +04:00
|
|
|
function BrowserPopupShowing () {
|
2005-10-25 23:20:32 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Open Link as New Tab
|
|
|
|
*/
|
2005-11-17 21:50:52 +03:00
|
|
|
|
2005-10-25 23:20:32 +04:00
|
|
|
if(document.commandDispatcher.focusedElement && document.commandDispatcher.focusedElement.href) {
|
2005-11-22 01:45:38 +03:00
|
|
|
gFocusedElementHREFContextMenu=document.commandDispatcher.focusedElement.href;
|
2005-10-25 23:20:32 +04:00
|
|
|
document.getElementById("link_as_new_tab").hidden=false;
|
2005-11-17 21:50:52 +03:00
|
|
|
|
|
|
|
document.getElementById("item-backbutton").hidden=true;
|
|
|
|
document.getElementById("item-forwardbutton").hidden=true;
|
|
|
|
document.getElementById("item-reloadbutton").hidden=true;
|
|
|
|
|
2005-10-25 23:20:32 +04:00
|
|
|
} else {
|
|
|
|
document.getElementById("link_as_new_tab").hidden=true;
|
2005-11-17 21:50:52 +03:00
|
|
|
|
|
|
|
document.getElementById("item-backbutton").hidden=false;
|
|
|
|
document.getElementById("item-forwardbutton").hidden=false;
|
|
|
|
document.getElementById("item-reloadbutton").hidden=false;
|
|
|
|
|
2005-10-25 23:20:32 +04:00
|
|
|
}
|
|
|
|
|
2005-08-23 19:21:09 +04:00
|
|
|
var selectedRange=getBrowser().selectedBrowser.contentDocument.getSelection();
|
2005-11-10 20:54:37 +03:00
|
|
|
|
2005-08-23 19:21:09 +04:00
|
|
|
/* Enable Copy */
|
2005-11-22 01:45:38 +03:00
|
|
|
|
2005-12-23 02:25:59 +03:00
|
|
|
if(selectedRange.toString()) {
|
2005-12-23 03:24:46 +03:00
|
|
|
|
2005-08-23 19:21:09 +04:00
|
|
|
document.getElementById("item-copy").style.display="block";
|
2005-12-23 02:25:59 +03:00
|
|
|
} else {
|
|
|
|
document.getElementById("item-copy").style.display="none";
|
2005-08-23 19:21:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable Paste - Can paste only if the focused element has a value attribute. :)
|
|
|
|
THis may affect XHTML nodes. Users may be able to paste things within XML nodes.
|
|
|
|
*/
|
2005-11-15 03:20:55 +03:00
|
|
|
if (document.commandDispatcher.focusedElement) {
|
|
|
|
if(document.commandDispatcher.focusedElement.nodeName=="INPUT"||document.commandDispatcher.focusedElement.nodeName=="TEXTAREA") {
|
|
|
|
if(DoClipCheckPaste()) {
|
|
|
|
document.getElementById("item-paste").style.display="block";
|
2005-12-23 02:29:36 +03:00
|
|
|
} else {
|
|
|
|
document.getElementById("item-paste").style.display="none";
|
2005-12-23 03:24:46 +03:00
|
|
|
}
|
2005-08-23 19:21:09 +04:00
|
|
|
}
|
|
|
|
}
|
2005-08-12 06:09:16 +04:00
|
|
|
}
|
|
|
|
|
2005-12-02 23:13:15 +03:00
|
|
|
|
|
|
|
/* Bookmarks */
|
|
|
|
|
|
|
|
function BrowserBookmarkThis() {
|
|
|
|
|
|
|
|
var currentURI=getBrowser().selectedBrowser.webNavigation.currentURI.spec;
|
|
|
|
var newLi=gBookmarksDoc.createElement("li");
|
|
|
|
var bmContent=gBookmarksDoc.createTextNode(currentURI);
|
|
|
|
newLi.appendChild(bmContent);
|
|
|
|
gBookmarksDoc.getElementsByTagName("bm")[0].appendChild(newLi);
|
2005-12-03 00:07:25 +03:00
|
|
|
gPrefAdded=true;
|
|
|
|
|
2005-12-02 23:13:15 +03:00
|
|
|
storeBookmarks();
|
2005-12-02 23:57:24 +03:00
|
|
|
refreshBookmarks();
|
2005-12-02 23:13:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserBookmark() {
|
|
|
|
try {
|
|
|
|
getBrowser().selectedTab = getBrowser().addTab('chrome://minimo/content/bookmarks/bmview.xhtml');
|
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-25 23:46:34 +04:00
|
|
|
/* Toolbar specific code - to be removed from here */
|
|
|
|
|
|
|
|
function DoBrowserSearch() {
|
|
|
|
BrowserViewSearch();
|
|
|
|
try {
|
|
|
|
var vQuery=document.getElementById("toolbar-search-tag").value;
|
|
|
|
if(vQuery!="") {
|
|
|
|
getBrowser().selectedTab = getBrowser().addTab('http://www.google.com/xhtml?q='+vQuery+'&hl=en&lr=&safe=off&btnG=Search&site=search&mrestrict=xhtml');
|
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-24 01:27:03 +03:00
|
|
|
/*
|
|
|
|
* Search extension to urlbar, deckmode.
|
|
|
|
* Called form the deckmode urlbar selector
|
|
|
|
*/
|
|
|
|
|
|
|
|
function DoBrowserSearchURLBAR(vQuery) {
|
|
|
|
try {
|
|
|
|
if(vQuery!="") {
|
|
|
|
getBrowser().selectedTab = getBrowser().addTab('http://www.google.com/xhtml?q='+vQuery+'&hl=en&lr=&safe=off&btnG=Search&site=search&mrestrict=xhtml');
|
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-25 23:46:34 +04:00
|
|
|
/* Toolbar specific code - to be removed from here */
|
|
|
|
|
2005-11-19 00:38:25 +03:00
|
|
|
function DoBrowserRSS(sKey) {
|
|
|
|
|
2005-11-19 03:03:34 +03:00
|
|
|
if(!sKey) BrowserViewRSS(); // The toolbar is being used. Otherwise it is via the sb: trap protocol.
|
|
|
|
|
|
|
|
try {
|
2005-11-21 21:48:07 +03:00
|
|
|
|
2005-11-19 03:03:34 +03:00
|
|
|
if(sKey) {
|
|
|
|
gRSSTag=sKey;
|
|
|
|
} else if(document.getElementById("toolbar-rss-rsstag").value!="") {
|
|
|
|
gRSSTag=document.getElementById("toolbar-rss-rsstag").value;
|
|
|
|
}
|
2005-11-19 03:07:49 +03:00
|
|
|
|
2005-11-21 21:48:07 +03:00
|
|
|
getBrowser().selectedTab = getBrowser().addTab('chrome://minimo/content/rssview/rssload.xhtml?url='+gRSSTag);
|
|
|
|
|
2005-11-19 03:03:34 +03:00
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-19 03:07:49 +03:00
|
|
|
|
2005-11-19 03:03:34 +03:00
|
|
|
/* Toolbar specific code - to be removed from here */
|
2005-11-19 00:38:25 +03:00
|
|
|
|
2005-11-19 03:03:34 +03:00
|
|
|
function DoBrowserSB(sKey) {
|
|
|
|
|
|
|
|
if(!sKey) BrowserViewRSS(); // The toolbar is being used. Otherwise it is via the sb: trap protocol.
|
|
|
|
|
|
|
|
try {
|
|
|
|
if(sKey) {
|
|
|
|
gRSSTag=sKey;
|
|
|
|
} else if(document.getElementById("toolbar-rss-rsstag").value!="") {
|
|
|
|
gRSSTag=document.getElementById("toolbar-rss-rsstag").value;
|
|
|
|
}
|
|
|
|
|
2005-11-20 01:13:05 +03:00
|
|
|
getBrowser().selectedTab = getBrowser().addTab('chrome://minimo/content/rssview/rssload.xhtml?url=http://del.icio.us/rss/tag/'+gRSSTag);
|
2005-11-19 03:03:34 +03:00
|
|
|
browserInit(getBrowser().selectedTab);
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
}
|
2005-09-15 21:48:14 +04:00
|
|
|
}
|
2005-08-26 21:21:26 +04:00
|
|
|
|
2005-11-17 23:21:59 +03:00
|
|
|
/* Toolbar specific code - to be removed from here */
|
|
|
|
|
|
|
|
|
|
|
|
function DoBrowserFind() {
|
|
|
|
// BrowserViewFind();
|
|
|
|
try {
|
|
|
|
var vQuery=document.getElementById("toolbar-find-tag").value;
|
|
|
|
if(vQuery!="") {
|
|
|
|
getBrowser().contentWindow.focus();
|
|
|
|
|
|
|
|
/* FIND DOCUMENTATION:
|
|
|
|
41 const FIND_NORMAL = 0;
|
|
|
|
42 const FIND_TYPEAHEAD = 1;
|
|
|
|
43 const FIND_LINKS = 2;
|
|
|
|
http://lxr.mozilla.org/mozilla/source/toolkit/components/typeaheadfind/content/findBar.js
|
|
|
|
*/
|
|
|
|
getBrowser().fastFind.find(vQuery,0);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
alert(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Toolbar specific code - to be removed from here */
|
|
|
|
|
|
|
|
function DoBrowserFindNext() {
|
|
|
|
try {
|
|
|
|
getBrowser().fastFind.findNext();
|
|
|
|
} catch (e) {
|
|
|
|
alert(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-08-26 21:21:26 +04:00
|
|
|
function DoPanelPreferences() {
|
2005-10-21 01:40:51 +04:00
|
|
|
window.openDialog("chrome://minimo/content/preferences/preferences.xul","preferences","modal,centerscreeen,chrome,resizable=no");
|
2005-11-02 07:44:49 +03:00
|
|
|
// BrowserReload();
|
2005-10-21 23:57:18 +04:00
|
|
|
syncUIZoom();
|
2005-10-21 01:40:51 +04:00
|
|
|
}
|
|
|
|
|
2005-08-23 19:21:09 +04:00
|
|
|
/*
|
|
|
|
Testing the SMS and Call Services
|
|
|
|
*/
|
|
|
|
function DoTestSendCall(toCall) {
|
2006-01-04 01:40:07 +03:00
|
|
|
var phoneInterface= Components.classes["@mozilla.org/phone/support;1"].createInstance(nsCI.nsIPhoneSupport);
|
2005-08-23 19:21:09 +04:00
|
|
|
phoneInterface.makeCall(toCall,"");
|
|
|
|
}
|
2005-08-15 19:25:53 +04:00
|
|
|
|
2005-08-16 23:19:59 +04:00
|
|
|
function DoFullScreen()
|
|
|
|
{
|
|
|
|
gFullScreen = !gFullScreen;
|
|
|
|
|
|
|
|
document.getElementById("nav-bar").hidden = gFullScreen;
|
2005-08-17 23:45:42 +04:00
|
|
|
|
2005-11-18 00:29:44 +03:00
|
|
|
// Is this the simpler approach to count tabs?
|
|
|
|
if(getBrowser().mPanelContainer.childNodes.length>1) {
|
2005-11-18 00:28:55 +03:00
|
|
|
getBrowser().setStripVisibilityTo(!gFullScreen);
|
|
|
|
}
|
|
|
|
|
2005-08-16 23:19:59 +04:00
|
|
|
window.fullScreen = gFullScreen;
|
2005-10-25 23:04:29 +04:00
|
|
|
|
|
|
|
document.getElementById("nav-bar-contextual").hidden = !gFullScreen;
|
|
|
|
|
2005-08-16 23:19:59 +04:00
|
|
|
}
|
2005-08-21 05:17:59 +04:00
|
|
|
|
2005-08-23 19:21:09 +04:00
|
|
|
/*
|
2005-08-21 05:17:59 +04:00
|
|
|
|
2005-08-23 19:21:09 +04:00
|
|
|
*/
|
|
|
|
function DoClipCopy()
|
|
|
|
{
|
|
|
|
var copytext=getBrowser().selectedBrowser.contentDocument.getSelection().toString();
|
2006-01-04 01:40:07 +03:00
|
|
|
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(nsCI.nsISupportsString);
|
2005-08-23 19:21:09 +04:00
|
|
|
if (!str) return false;
|
|
|
|
str.data = copytext;
|
2006-01-04 01:40:07 +03:00
|
|
|
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(nsCI.nsITransferable);
|
2005-08-23 19:21:09 +04:00
|
|
|
if (!trans) return false;
|
|
|
|
trans.addDataFlavor("text/unicode");
|
|
|
|
trans.setTransferData("text/unicode",str,copytext.length * 2);
|
2006-01-04 01:40:07 +03:00
|
|
|
var clipid = nsCI.nsIClipboard;
|
2005-08-23 19:21:09 +04:00
|
|
|
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
|
|
|
|
if (!clip) return false;
|
|
|
|
clip.setData(trans,null,clipid.kGlobalClipboard);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Currently supports text/unicode.
|
|
|
|
*/
|
|
|
|
function DoClipCheckPaste()
|
|
|
|
{
|
2006-01-04 01:40:07 +03:00
|
|
|
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(nsCI.nsIClipboard);
|
2005-08-23 19:21:09 +04:00
|
|
|
if (!clip) return false;
|
2006-01-04 01:40:07 +03:00
|
|
|
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(nsCI.nsITransferable);
|
2005-08-23 19:21:09 +04:00
|
|
|
if (!trans) return false;
|
|
|
|
trans.addDataFlavor("text/unicode");
|
|
|
|
clip.getData(trans,clip.kGlobalClipboard);
|
|
|
|
var str = new Object();
|
|
|
|
var strLength = new Object();
|
|
|
|
var pastetext = null;
|
|
|
|
trans.getTransferData("text/unicode",str,strLength);
|
2006-01-04 01:40:07 +03:00
|
|
|
if (str) str = str.value.QueryInterface(nsCI.nsISupportsString);
|
2005-08-23 19:21:09 +04:00
|
|
|
if (str) pastetext = str.data.substring(0,strLength.value / 2);
|
|
|
|
if(pastetext) {
|
|
|
|
return pastetext;
|
|
|
|
} else return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function DoClipPaste()
|
|
|
|
{
|
|
|
|
|
2005-08-24 23:50:07 +04:00
|
|
|
/* 008 note - value is there in the clipboard, however somehow paste action does not happen.
|
|
|
|
If you evaluate the canpaste you get false. */
|
|
|
|
|
|
|
|
var disp = document.commandDispatcher;
|
|
|
|
var cont = disp.getControllerForCommand("cmd_paste");
|
|
|
|
cont.doCommand("cmd_paste");
|
2005-08-23 19:21:09 +04:00
|
|
|
}
|
2005-08-21 05:17:59 +04:00
|
|
|
|
|
|
|
function URLBarEntered()
|
|
|
|
{
|
2005-09-19 09:47:21 +04:00
|
|
|
try
|
|
|
|
{
|
2005-11-11 08:34:34 +03:00
|
|
|
if (!gURLBar)
|
|
|
|
return;
|
|
|
|
|
2005-09-19 09:47:21 +04:00
|
|
|
var url = gURLBar.value;
|
2005-11-11 08:34:34 +03:00
|
|
|
if (gURLBar.value == "" || gURLBar.value == null)
|
|
|
|
return;
|
|
|
|
|
2005-11-19 00:38:25 +03:00
|
|
|
/* Trap to SB 'protocol' */
|
|
|
|
|
|
|
|
if(gURLBar.value.substring(0,3)=="sb:") {
|
2005-11-19 03:07:49 +03:00
|
|
|
DoBrowserSB(gURLBar.value.split("sb:")[1]);
|
|
|
|
return;
|
2005-11-19 00:38:25 +03:00
|
|
|
}
|
|
|
|
|
2005-11-19 03:07:49 +03:00
|
|
|
/* Trap to RSS 'protocol' */
|
|
|
|
|
2005-11-21 21:48:07 +03:00
|
|
|
if(gURLBar.value.substring(0,4)=="rss:") {
|
|
|
|
DoBrowserRSS(gURLBar.value.split("rss:")[1]);
|
2005-11-19 03:07:49 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-24 01:27:03 +03:00
|
|
|
// SB mode
|
|
|
|
if(gDeckMode==1) {
|
|
|
|
DoBrowserSB(gURLBar.value);
|
2005-12-23 04:11:05 +03:00
|
|
|
BrowserSetDeck(0,document.getElementById("command_ViewDeckDefault"));
|
2005-11-24 01:27:03 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(gDeckMode==2) {
|
|
|
|
DoBrowserSearchURLBAR(gURLBar.value);
|
2005-12-23 04:11:05 +03:00
|
|
|
BrowserSetDeck(0,document.getElementById("command_ViewDeckDefault"));
|
2005-11-24 01:27:03 +03:00
|
|
|
return;
|
|
|
|
}
|
2005-11-19 00:38:25 +03:00
|
|
|
/* Other normal cases */
|
|
|
|
|
2005-09-19 09:47:21 +04:00
|
|
|
var fixedUpURI = gURIFixup.createFixupURI(url, 2 /*fixup url*/ );
|
|
|
|
gGlobalHistory.markPageAsTyped(fixedUpURI);
|
|
|
|
|
|
|
|
gURLBar.value = fixedUpURI.spec;
|
|
|
|
|
|
|
|
loadURI(fixedUpURI.spec);
|
|
|
|
|
|
|
|
content.focus();
|
|
|
|
}
|
|
|
|
catch(ex) {alert(ex);}
|
2005-08-21 05:17:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-12-09 21:34:19 +03:00
|
|
|
function PageProxyClickHandler(aEvent) {
|
|
|
|
document.getElementById("urlbarModeSelector").showPopup(document.getElementById("proxy-deck"),-1,-1,"popup","bottomleft", "topleft");
|
|
|
|
}
|
|
|
|
|
2005-12-08 23:07:13 +03:00
|
|
|
|
|
|
|
function URLBarFocusHandler(aEvent, aElt)
|
2005-08-21 05:17:59 +04:00
|
|
|
{
|
2005-12-09 21:34:19 +03:00
|
|
|
|
2005-12-08 23:07:13 +03:00
|
|
|
if (gIgnoreFocus)
|
|
|
|
gIgnoreFocus = false;
|
|
|
|
else if (gClickSelectsAll)
|
|
|
|
aElt.select();
|
|
|
|
|
2005-12-09 21:34:19 +03:00
|
|
|
// gURLBar.setAttribute("open", "true");
|
|
|
|
// gURLBar.showHistoryPopup();
|
|
|
|
|
|
|
|
|
2005-08-21 05:17:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-08 23:07:13 +03:00
|
|
|
function URLBarMouseDownHandler(aEvent, aElt)
|
|
|
|
{
|
2006-01-04 22:52:39 +03:00
|
|
|
if (aElt.hasAttribute("focused")) {
|
|
|
|
gIgnoreClick = true;
|
|
|
|
} else {
|
|
|
|
gIgnoreFocus = true;
|
|
|
|
gIgnoreClick = false;
|
|
|
|
aElt.setSelectionRange(0, 0);
|
|
|
|
}
|
2005-12-08 23:07:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function URLBarClickHandler(aEvent, aElt)
|
|
|
|
{
|
|
|
|
if (!gIgnoreClick && aElt.selectionStart == aElt.selectionEnd)
|
|
|
|
aElt.select();
|
|
|
|
}
|
|
|
|
|
2005-09-03 03:37:10 +04:00
|
|
|
var gRotationDirection = true;
|
|
|
|
|
|
|
|
function BrowserScreenRotate()
|
|
|
|
{
|
|
|
|
try {
|
2006-01-04 01:40:07 +03:00
|
|
|
var deviceSupport = Components.classes["@mozilla.org/device/support;1"].getService(nsCI.nsIDeviceSupport);
|
2005-09-03 03:37:10 +04:00
|
|
|
|
|
|
|
deviceSupport.rotateScreen(gRotationDirection);
|
|
|
|
gRotationDirection != gRotationDirection;
|
|
|
|
}
|
|
|
|
catch (ex)
|
|
|
|
{
|
|
|
|
alert(ex);
|
|
|
|
}
|
|
|
|
}
|
2005-09-30 00:21:25 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Main Menu
|
|
|
|
*/
|
|
|
|
|
|
|
|
function BrowserMenuPopup() {
|
|
|
|
document.getElementById("menu_MainPopup").showPopup(document.getElementById("menu-button"),-1,-1,"popup","bottomleft", "topleft");
|
|
|
|
}
|
2005-10-25 23:09:53 +04:00
|
|
|
|
2005-09-30 00:21:25 +04:00
|
|
|
function BrowserMenuPopupFalse() {
|
|
|
|
document.getElementById("menu_MainPopup").hidePopup();
|
|
|
|
}
|
|
|
|
|
2005-10-25 23:09:53 +04:00
|
|
|
function BrowserMenuPopupContextualMenu() {
|
|
|
|
document.getElementById("contentAreaContextMenu").hidePopup();
|
|
|
|
DoFullScreen();
|
|
|
|
BrowserMenuPopup();
|
|
|
|
}
|
|
|
|
|
2005-09-30 00:21:25 +04:00
|
|
|
function MenuPopupShowing() {
|
2005-10-25 23:09:53 +04:00
|
|
|
gShowingMenuPopup=true;
|
|
|
|
document.getElementById("menu-button").focus();
|
2005-09-30 00:21:25 +04:00
|
|
|
}
|
2005-09-30 22:35:53 +04:00
|
|
|
|
|
|
|
function MenuPopupHidden() {
|
2005-10-25 23:09:53 +04:00
|
|
|
gShowingMenuPopup=false;
|
2005-09-30 22:35:53 +04:00
|
|
|
}
|
|
|
|
|
2005-11-24 01:27:03 +03:00
|
|
|
/* The URLBAR Deck mode selector
|
|
|
|
*/
|
|
|
|
|
|
|
|
function BrowserSetDeck(dMode,menuElement) {
|
|
|
|
|
|
|
|
gDeckMode=dMode;
|
|
|
|
if(dMode==2) document.getElementById("urlbar-deck").className='search';
|
|
|
|
if(dMode==1) document.getElementById("urlbar-deck").className='sb';
|
|
|
|
if(dMode==0) document.getElementById("urlbar-deck").className='';
|
|
|
|
|
|
|
|
}
|
2005-10-08 01:03:55 +04:00
|
|
|
|
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
// ripped from browser.js, this should be shared in toolkit.
|
|
|
|
function nsBrowserAccess()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBrowserAccess.prototype =
|
|
|
|
{
|
|
|
|
QueryInterface : function(aIID)
|
|
|
|
{
|
|
|
|
if (aIID.equals(nsCI.nsIBrowserDOMWindow) ||
|
|
|
|
aIID.equals(nsCI.nsISupports))
|
|
|
|
return this;
|
|
|
|
throw Components.results.NS_NOINTERFACE;
|
|
|
|
},
|
2005-10-08 01:03:55 +04:00
|
|
|
|
2006-01-04 01:40:07 +03:00
|
|
|
openURI : function(aURI, aOpener, aWhere, aContext)
|
|
|
|
{
|
|
|
|
var newWindow = null;
|
|
|
|
var referrer = null;
|
|
|
|
var isExternal = (aContext == nsCI.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
|
|
|
|
|
|
|
if (isExternal && aURI && aURI.schemeIs("chrome")) {
|
|
|
|
dump("use -chrome command-line option to load external chrome urls\n");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var loadflags = isExternal ?
|
|
|
|
nsCI.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
|
|
|
|
nsCI.nsIWebNavigation.LOAD_FLAGS_NONE;
|
|
|
|
var location;
|
|
|
|
if (aWhere == nsCI.nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW) {
|
|
|
|
switch (aContext) {
|
|
|
|
case nsCI.nsIBrowserDOMWindow.OPEN_EXTERNAL :
|
|
|
|
aWhere = gPref.getIntPref("browser.link.open_external");
|
|
|
|
break;
|
|
|
|
default : // OPEN_NEW or an illegal value
|
|
|
|
aWhere = gPref.getIntPref("browser.link.open_newwindow");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var url = aURI ? aURI.spec : "about:blank";
|
|
|
|
switch(aWhere) {
|
|
|
|
case nsCI.nsIBrowserDOMWindow.OPEN_NEWWINDOW :
|
|
|
|
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url);
|
|
|
|
break;
|
|
|
|
case nsCI.nsIBrowserDOMWindow.OPEN_NEWTAB :
|
|
|
|
var newTab = gBrowser.addTab("about:blank");
|
|
|
|
if (!gPref.getBoolPref("browser.tabs.loadDivertedInBackground"))
|
|
|
|
gBrowser.selectedTab = newTab;
|
|
|
|
newWindow = gBrowser.getBrowserForTab(newTab).docShell
|
|
|
|
.QueryInterface(nsCI.nsIInterfaceRequestor)
|
|
|
|
.getInterface(nsCI.nsIDOMWindow);
|
|
|
|
try {
|
|
|
|
if (aOpener) {
|
|
|
|
location = aOpener.location;
|
|
|
|
referrer =
|
|
|
|
Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(nsCI.nsIIOService)
|
|
|
|
.newURI(location, null, null);
|
|
|
|
}
|
|
|
|
newWindow.QueryInterface(nsCI.nsIInterfaceRequestor)
|
|
|
|
.getInterface(nsCI.nsIWebNavigation)
|
|
|
|
.loadURI(url, loadflags, referrer, null, null);
|
|
|
|
} catch(e) {
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default : // OPEN_CURRENTWINDOW or an illegal value
|
|
|
|
try {
|
|
|
|
if (aOpener) {
|
|
|
|
newWindow = aOpener.top;
|
|
|
|
location = aOpener.location;
|
|
|
|
referrer =
|
|
|
|
Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(nsCI.nsIIOService)
|
|
|
|
.newURI(location, null, null);
|
|
|
|
|
|
|
|
newWindow.QueryInterface(nsCI.nsIInterfaceRequestor)
|
|
|
|
.getInterface(nsIWebNavigation)
|
|
|
|
.loadURI(url, loadflags, referrer, null, null);
|
|
|
|
} else {
|
|
|
|
newWindow = gBrowser.selectedBrowser.docShell
|
|
|
|
.QueryInterface(nsCI.nsIInterfaceRequestor)
|
|
|
|
.getInterface(nsCI.nsIDOMWindow);
|
|
|
|
getWebNavigation().loadURI(url, loadflags, null, null, null);
|
|
|
|
}
|
|
|
|
if(!gPref.getBoolPref("browser.tabs.loadDivertedInBackground"))
|
|
|
|
content.focus();
|
|
|
|
} catch(e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newWindow;
|
|
|
|
},
|
|
|
|
|
|
|
|
isTabContentWindow : function(aWindow)
|
|
|
|
{
|
|
|
|
var browsers = gBrowser.browsers;
|
|
|
|
for (var ctr = 0; ctr < browsers.length; ctr++)
|
|
|
|
if (browsers.item(ctr).contentWindow == aWindow)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|