зеркало из https://github.com/mozilla/pjs.git
Fix bug 78419; move Find-related JS into a new file, used in navigator and viewsource. sr=sspitzer, r=jag
This commit is contained in:
Родитель
8e797dde66
Коммит
56263eae28
|
@ -783,52 +783,21 @@ function BrowserFind()
|
|||
if (!focusedWindow || focusedWindow == window)
|
||||
focusedWindow = window._content;
|
||||
|
||||
var findInst = getBrowser().webBrowserFind;
|
||||
// set up the find to search the focussedWindow, bounded by the content window.
|
||||
var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames);
|
||||
findInFrames.rootSearchFrame = window._content;
|
||||
findInFrames.currentSearchFrame = focusedWindow;
|
||||
|
||||
// always search in frames for now. We could add a checkbox to the dialog for this.
|
||||
findInst.searchFrames = true;
|
||||
|
||||
// is the dialog up already?
|
||||
if (window.findDialog)
|
||||
window.findDialog.focus();
|
||||
else
|
||||
window.findDialog = window.openDialog("chrome://global/content/finddialog.xul", "Find on Page", "chrome,resizable=no,dependent=yes", findInst);
|
||||
findInPage(getBrowser(), window._content, focusedWindow)
|
||||
}
|
||||
|
||||
function BrowserFindAgain()
|
||||
{
|
||||
if (window.findDialog)
|
||||
window.findDialog.focus();
|
||||
else
|
||||
{
|
||||
// since the page may have been reloaded, reset stuff
|
||||
var focusedWindow = document.commandDispatcher.focusedWindow;
|
||||
if (!focusedWindow || focusedWindow == window)
|
||||
focusedWindow = window._content;
|
||||
|
||||
var findInst = getBrowser().webBrowserFind;
|
||||
// set up the find to search the focussedWindow, bounded by the content window.
|
||||
var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames);
|
||||
findInFrames.rootSearchFrame = window._content;
|
||||
findInFrames.currentSearchFrame = focusedWindow;
|
||||
|
||||
// always search in frames for now. We could add a checkbox to the dialog for this.
|
||||
findInst.searchFrames = true;
|
||||
|
||||
var found = findInst.findNext();
|
||||
}
|
||||
findAgainInPage(getBrowser(), window._content, focusedWindow)
|
||||
}
|
||||
|
||||
function BrowserCanFindAgain()
|
||||
{
|
||||
var findInst = getBrowser().webBrowserFind;
|
||||
var findString = findInst.searchString;
|
||||
|
||||
return (findString.length > 0);
|
||||
return canFindAgainInPage();
|
||||
}
|
||||
|
||||
function loadURI(uri)
|
||||
|
|
|
@ -69,6 +69,7 @@ Contributor(s): ______________________________________. -->
|
|||
<script type="application/x-javascript" src="chrome://navigator/content/nsBrowserContentListener.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/findUtils.js"/>
|
||||
|
||||
<!-- Shared Bookmarks Utility Library -->
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/findUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://navigator/content/viewsource.js"/>
|
||||
|
||||
<commandset id="commands"/>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
var gBrowser = null;
|
||||
var appCore = null;
|
||||
|
||||
function onLoadViewSource()
|
||||
|
@ -6,6 +7,13 @@ function onLoadViewSource()
|
|||
viewSource(window.arguments[0]);
|
||||
}
|
||||
|
||||
function getBrowser()
|
||||
{
|
||||
if (!gBrowser)
|
||||
gBrowser = document.getElementById("content");
|
||||
return gBrowser;
|
||||
}
|
||||
|
||||
function viewSource(url)
|
||||
{
|
||||
if (!url)
|
||||
|
@ -23,8 +31,6 @@ function viewSource(url)
|
|||
return false;
|
||||
}
|
||||
|
||||
var docShellElement = document.getElementById("content");
|
||||
|
||||
try {
|
||||
if ("arguments" in window && window.arguments.length >= 2) {
|
||||
if (window.arguments[1].indexOf('charset=') != -1) {
|
||||
|
@ -39,7 +45,7 @@ function viewSource(url)
|
|||
|
||||
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
||||
var viewSrcUrl = "view-source:" + url;
|
||||
docShellElement.webNavigation.loadURI(viewSrcUrl, loadFlags);
|
||||
getBrowser().webNavigation.loadURI(viewSrcUrl, loadFlags);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -50,19 +56,28 @@ function BrowserClose()
|
|||
|
||||
function getMarkupDocumentViewer()
|
||||
{
|
||||
return document.getElementById("content").markupDocumentViewer;
|
||||
return getBrowser().markupDocumentViewer;
|
||||
}
|
||||
|
||||
function BrowserFind()
|
||||
{
|
||||
if (appCore)
|
||||
appCore.find();
|
||||
}
|
||||
var focusedWindow = document.commandDispatcher.focusedWindow;
|
||||
if (!focusedWindow || focusedWindow == window)
|
||||
focusedWindow = window._content;
|
||||
|
||||
findInPage(getBrowser(), window._content, focusedWindow)
|
||||
}
|
||||
|
||||
function BrowserFindAgain()
|
||||
{
|
||||
if (appCore)
|
||||
appCore.findNext();
|
||||
var focusedWindow = document.commandDispatcher.focusedWindow;
|
||||
if (!focusedWindow || focusedWindow == window)
|
||||
focusedWindow = window._content;
|
||||
|
||||
findAgainInPage(getBrowser(), window._content, focusedWindow)
|
||||
}
|
||||
|
||||
function BrowserCanFindAgain()
|
||||
{
|
||||
return canFindAgainInPage();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче