mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 961165 - Remove inline scripts from scratchpad.xul. r=bbenvie
This commit is contained in:
parent
488eec2432
commit
adbea41542
@ -130,6 +130,99 @@ var Scratchpad = {
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the event listeners for popupshowing events.
|
||||
*/
|
||||
_setupPopupShowingListeners: function SP_setupPopupShowing() {
|
||||
let elementIDs = ['sp-menu_editpopup', 'scratchpad-text-popup'];
|
||||
|
||||
for (let elementID of elementIDs) {
|
||||
let elem = document.getElementById(elementID);
|
||||
if (elem) {
|
||||
elem.addEventListener("popupshowing", function () {
|
||||
goUpdateGlobalEditMenuItems();
|
||||
let commands = ['cmd_undo', 'cmd_redo', 'cmd_delete', 'cmd_findAgain'];
|
||||
commands.forEach(goUpdateCommand);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the event event listeners for command events.
|
||||
*/
|
||||
_setupCommandListeners: function SP_setupCommands() {
|
||||
let commands = {
|
||||
"cmd_gotoLine": () => {
|
||||
goDoCommand('cmd_gotoLine');
|
||||
},
|
||||
"sp-cmd-newWindow": () => {
|
||||
Scratchpad.openScratchpad();
|
||||
},
|
||||
"sp-cmd-openFile": () => {
|
||||
Scratchpad.openFile();
|
||||
},
|
||||
"sp-cmd-clearRecentFiles": () => {
|
||||
Scratchpad.clearRecentFiles();
|
||||
},
|
||||
"sp-cmd-save": () => {
|
||||
Scratchpad.saveFile();
|
||||
},
|
||||
"sp-cmd-saveas": () => {
|
||||
Scratchpad.saveFileAs();
|
||||
},
|
||||
"sp-cmd-revert": () => {
|
||||
Scratchpad.promptRevert();
|
||||
},
|
||||
"sp-cmd-close": () => {
|
||||
Scratchpad.close();
|
||||
},
|
||||
"sp-cmd-run": () => {
|
||||
Scratchpad.run();
|
||||
},
|
||||
"sp-cmd-inspect": () => {
|
||||
Scratchpad.inspect();
|
||||
},
|
||||
"sp-cmd-display": () => {
|
||||
Scratchpad.display();
|
||||
},
|
||||
"sp-cmd-pprint": () => {
|
||||
Scratchpad.prettyPrint();
|
||||
},
|
||||
"sp-cmd-contentContext": () => {
|
||||
Scratchpad.setContentContext();
|
||||
},
|
||||
"sp-cmd-browserContext": () => {
|
||||
Scratchpad.setBrowserContext();
|
||||
},
|
||||
"sp-cmd-reloadAndRun": () => {
|
||||
Scratchpad.reloadAndRun();
|
||||
},
|
||||
"sp-cmd-evalFunction": () => {
|
||||
Scratchpad.evalTopLevelFunction();
|
||||
},
|
||||
"sp-cmd-errorConsole": () => {
|
||||
Scratchpad.openErrorConsole();
|
||||
},
|
||||
"sp-cmd-webConsole": () => {
|
||||
Scratchpad.openWebConsole();
|
||||
},
|
||||
"sp-cmd-documentationLink": () => {
|
||||
Scratchpad.openDocumentationPage();
|
||||
},
|
||||
"sp-cmd-hideSidebar": () => {
|
||||
Scratchpad.sidebar.hide();
|
||||
}
|
||||
}
|
||||
|
||||
for (let command in commands) {
|
||||
let elem = document.getElementById(command);
|
||||
if (elem) {
|
||||
elem.addEventListener("command", commands[command]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The script execution context. This tells Scratchpad in which context the
|
||||
* script shall execute.
|
||||
@ -1168,7 +1261,7 @@ var Scratchpad = {
|
||||
menuitem.setAttribute("disabled", true);
|
||||
}
|
||||
|
||||
menuitem.setAttribute("oncommand", "Scratchpad.openFile(" + i + ");");
|
||||
menuitem.addEventListener("command", Scratchpad.openFile.bind(Scratchpad, i));
|
||||
recentFilesPopup.appendChild(menuitem);
|
||||
}
|
||||
|
||||
@ -1513,6 +1606,8 @@ var Scratchpad = {
|
||||
PreferenceObserver.init();
|
||||
CloseObserver.init();
|
||||
}).then(null, (err) => console.log(err.message));
|
||||
this._setupCommandListeners();
|
||||
this._setupPopupShowingListeners();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -33,41 +33,32 @@
|
||||
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript" src="chrome://browser/content/devtools/scratchpad.js"/>
|
||||
|
||||
|
||||
<script type="application/javascript">
|
||||
function goUpdateSourceEditorMenuItems() {
|
||||
goUpdateGlobalEditMenuItems();
|
||||
let commands = ['cmd_undo', 'cmd_redo', 'cmd_delete', 'cmd_findAgain'];
|
||||
commands.forEach(goUpdateCommand);
|
||||
}
|
||||
</script>
|
||||
|
||||
<commandset id="editMenuCommands"/>
|
||||
|
||||
<commandset id="sourceEditorCommands">
|
||||
<command id="cmd_gotoLine" oncommand="goDoCommand('cmd_gotoLine')"/>
|
||||
<command id="cmd_gotoLine" oncommand=";"/>
|
||||
</commandset>
|
||||
|
||||
<commandset id="sp-commandset">
|
||||
<command id="sp-cmd-newWindow" oncommand="Scratchpad.openScratchpad();"/>
|
||||
<command id="sp-cmd-openFile" oncommand="Scratchpad.openFile();"/>
|
||||
<command id="sp-cmd-clearRecentFiles" oncommand="Scratchpad.clearRecentFiles();"/>
|
||||
<command id="sp-cmd-save" oncommand="Scratchpad.saveFile();"/>
|
||||
<command id="sp-cmd-saveas" oncommand="Scratchpad.saveFileAs();"/>
|
||||
<command id="sp-cmd-revert" oncommand="Scratchpad.promptRevert();" disabled="true"/>
|
||||
<command id="sp-cmd-close" oncommand="Scratchpad.close();"/>
|
||||
<command id="sp-cmd-run" oncommand="Scratchpad.run();"/>
|
||||
<command id="sp-cmd-inspect" oncommand="Scratchpad.inspect();"/>
|
||||
<command id="sp-cmd-display" oncommand="Scratchpad.display();"/>
|
||||
<command id="sp-cmd-pprint" oncommand="Scratchpad.prettyPrint();"/>
|
||||
<command id="sp-cmd-contentContext" oncommand="Scratchpad.setContentContext();"/>
|
||||
<command id="sp-cmd-browserContext" oncommand="Scratchpad.setBrowserContext();" disabled="true"/>
|
||||
<command id="sp-cmd-reloadAndRun" oncommand="Scratchpad.reloadAndRun();"/>
|
||||
<command id="sp-cmd-evalFunction" oncommand="Scratchpad.evalTopLevelFunction();"/>
|
||||
<command id="sp-cmd-errorConsole" oncommand="Scratchpad.openErrorConsole();" disabled="true"/>
|
||||
<command id="sp-cmd-webConsole" oncommand="Scratchpad.openWebConsole();"/>
|
||||
<command id="sp-cmd-documentationLink" oncommand="Scratchpad.openDocumentationPage();"/>
|
||||
<command id="sp-cmd-hideSidebar" oncommand="Scratchpad.sidebar.hide();"/>
|
||||
<command id="sp-cmd-newWindow" oncommand=";"/>
|
||||
<command id="sp-cmd-openFile" oncommand=";"/>
|
||||
<command id="sp-cmd-clearRecentFiles" oncommand=";"/>
|
||||
<command id="sp-cmd-save" oncommand=";"/>
|
||||
<command id="sp-cmd-saveas" oncommand=";"/>
|
||||
<command id="sp-cmd-revert" oncommand=";" disabled="true"/>
|
||||
<command id="sp-cmd-close" oncommand=";"/>
|
||||
<command id="sp-cmd-run" oncommand=";"/>
|
||||
<command id="sp-cmd-inspect" oncommand=";"/>
|
||||
<command id="sp-cmd-display" oncommand=";"/>
|
||||
<command id="sp-cmd-pprint" oncommand=";"/>
|
||||
<command id="sp-cmd-contentContext" oncommand=";"/>
|
||||
<command id="sp-cmd-browserContext" oncommand=";" disabled="true"/>
|
||||
<command id="sp-cmd-reloadAndRun" oncommand=";"/>
|
||||
<command id="sp-cmd-evalFunction" oncommand=";"/>
|
||||
<command id="sp-cmd-errorConsole" oncommand=";" disabled="true"/>
|
||||
<command id="sp-cmd-webConsole" oncommand=";"/>
|
||||
<command id="sp-cmd-documentationLink" oncommand=";"/>
|
||||
<command id="sp-cmd-hideSidebar" oncommand=";"/>
|
||||
</commandset>
|
||||
|
||||
<keyset id="editMenuKeys"/>
|
||||
@ -172,8 +163,7 @@
|
||||
|
||||
<menu id="sp-edit-menu" label="&editMenu.label;"
|
||||
accesskey="&editMenu.accesskey;">
|
||||
<menupopup id="sp-menu_editpopup"
|
||||
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||
<menupopup id="sp-menu_editpopup">
|
||||
<menuitem id="menu_undo"/>
|
||||
<menuitem id="menu_redo"/>
|
||||
<menuseparator/>
|
||||
@ -305,8 +295,7 @@
|
||||
|
||||
|
||||
<popupset id="scratchpad-popups">
|
||||
<menupopup id="scratchpad-text-popup"
|
||||
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||
<menupopup id="scratchpad-text-popup">
|
||||
<menuitem id="cMenu_cut"/>
|
||||
<menuitem id="cMenu_copy"/>
|
||||
<menuitem id="cMenu_paste"/>
|
||||
|
Loading…
Reference in New Issue
Block a user