зеркало из https://github.com/mozilla/pjs.git
Add line-wrapping capability to the view source window. Bug 22022,
r=bzbarsky, sr=alecf
This commit is contained in:
Родитель
870953feae
Коммит
8b64c9aa55
|
@ -64,6 +64,9 @@
|
||||||
<commandset id="globalEditMenuItems"/>
|
<commandset id="globalEditMenuItems"/>
|
||||||
<commandset id="selectEditMenuItems"/>
|
<commandset id="selectEditMenuItems"/>
|
||||||
<commandset id="clipboardEditMenuItems"/>
|
<commandset id="clipboardEditMenuItems"/>
|
||||||
|
<commandset id="viewSourceMenuItems">
|
||||||
|
<command id="cmdWrapLongLines" oncommand="wrapLongLines()"/>
|
||||||
|
</commandset>
|
||||||
</commandset>
|
</commandset>
|
||||||
|
|
||||||
<stringbundleset id="stringbundleset">
|
<stringbundleset id="stringbundleset">
|
||||||
|
@ -144,6 +147,7 @@
|
||||||
<!-- <menuitem accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" key="key_viewInfo" observes="View:PageInfo"/>
|
<!-- <menuitem accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" key="key_viewInfo" observes="View:PageInfo"/>
|
||||||
<menuseparator id="file_moduleSeparator"/>-->
|
<menuseparator id="file_moduleSeparator"/>-->
|
||||||
<menu id = "charsetMenu"/>
|
<menu id = "charsetMenu"/>
|
||||||
|
<menuitem id="menu_wrapLongLines" label="&menu_wrapLongLines.title;" type="checkbox" command="cmdWrapLongLines"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,16 @@
|
||||||
|
|
||||||
var gBrowser = null;
|
var gBrowser = null;
|
||||||
var appCore = null;
|
var appCore = null;
|
||||||
|
var gPrefs = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var prefsService = Components.classes["@mozilla.org/preferences;1"];
|
||||||
|
if (prefsService)
|
||||||
|
prefsService = prefsService.getService();
|
||||||
|
if (prefsService)
|
||||||
|
var gPrefs = prefsService.QueryInterface(Components.interfaces.nsIPref);
|
||||||
|
} catch (ex) {
|
||||||
|
}
|
||||||
|
|
||||||
function onLoadViewSource()
|
function onLoadViewSource()
|
||||||
{
|
{
|
||||||
|
@ -68,6 +78,18 @@ function viewSource(url)
|
||||||
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
||||||
var viewSrcUrl = "view-source:" + url;
|
var viewSrcUrl = "view-source:" + url;
|
||||||
getBrowser().webNavigation.loadURI(viewSrcUrl, loadFlags);
|
getBrowser().webNavigation.loadURI(viewSrcUrl, loadFlags);
|
||||||
|
|
||||||
|
//check the view_source.wrap_long_lines pref and set the menuitem's checked attribute accordingly
|
||||||
|
if (gPrefs){
|
||||||
|
try {
|
||||||
|
var wraplonglinesPrefValue = gPrefs.GetBoolPref("view_source.wrap_long_lines");
|
||||||
|
|
||||||
|
if (wraplonglinesPrefValue)
|
||||||
|
document.getElementById('menu_wrapLongLines').setAttribute("checked", "true");
|
||||||
|
} catch (ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
window._content.focus();
|
window._content.focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -84,3 +106,30 @@ function ViewSourceEditPage()
|
||||||
url = url.substring(12,url.length);
|
url = url.substring(12,url.length);
|
||||||
editPage(url,window, false);
|
editPage(url,window, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//function to toggle long-line wrapping and set the view_source.wrap_long_lines
|
||||||
|
//pref to persist the last state
|
||||||
|
function wrapLongLines()
|
||||||
|
{
|
||||||
|
//get the first pre tag which surrounds the entire viewsource content
|
||||||
|
var myWrap = window._content.document.getElementById('viewsource');
|
||||||
|
|
||||||
|
if (myWrap.className == '')
|
||||||
|
myWrap.className = 'wrap';
|
||||||
|
else myWrap.className = '';
|
||||||
|
|
||||||
|
//since multiple viewsource windows are possible, another window could have
|
||||||
|
//affected the pref, so instead of determining the new pref value via the current
|
||||||
|
//pref value, we use myWrap.className
|
||||||
|
if (gPrefs){
|
||||||
|
try {
|
||||||
|
if (myWrap.className == ''){
|
||||||
|
gPrefs.SetBoolPref("view_source.wrap_long_lines", false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gPrefs.SetBoolPref("view_source.wrap_long_lines", true);
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,3 +7,5 @@
|
||||||
<!-- LOCALIZATION NOTE (mainWindow.titlemodifierseperator) : DONT_TRANSLATE -->
|
<!-- LOCALIZATION NOTE (mainWindow.titlemodifierseperator) : DONT_TRANSLATE -->
|
||||||
<!ENTITY mainWindow.titlemodifierseperator " - ">
|
<!ENTITY mainWindow.titlemodifierseperator " - ">
|
||||||
<!ENTITY mainWindow.preface "Source of: ">
|
<!ENTITY mainWindow.preface "Source of: ">
|
||||||
|
|
||||||
|
<!ENTITY menu_wrapLongLines.title "Wrap Long Lines">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче