Bug 1157789 - Add context menu items Expand All / Collapse to markup view. r=janx

This commit is contained in:
Avik Pal 2015-06-29 00:16:47 -07:00
parent 8f0e1b1c24
commit 1431a44077
3 changed files with 37 additions and 0 deletions

View File

@ -686,6 +686,19 @@ InspectorPanel.prototype = {
let copyInnerHTML = this.panelDoc.getElementById("node-menu-copyinner");
let copyOuterHTML = this.panelDoc.getElementById("node-menu-copyouter");
let scrollIntoView = this.panelDoc.getElementById("node-menu-scrollnodeintoview");
let expandAll = this.panelDoc.getElementById("node-menu-expand");
let collapse = this.panelDoc.getElementById("node-menu-collapse");
expandAll.setAttribute("disabled", "true");
collapse.setAttribute("disabled", "true");
let markUpContainer = this.markup.importNode(this.selection.nodeFront, false);
if (this.selection.isNode() && markUpContainer.hasChildren) {
if (markUpContainer.expanded) {
collapse.removeAttribute("disabled");
}
expandAll.removeAttribute("disabled");
}
this._target.actorHasMethod("domnode", "scrollIntoView").then(value => {
scrollIntoView.hidden = !value;
@ -1121,6 +1134,14 @@ InspectorPanel.prototype = {
}
},
expandNode: function() {
this.markup.expandAll(this.selection.nodeFront);
},
collapseNode: function() {
this.markup.collapseNode(this.selection.nodeFront);
},
/**
* This method is here for the benefit of the node-menu-link-follow menu item
* in the inspector contextual-menu. It's behavior depends on which node was

View File

@ -55,6 +55,12 @@
<menuitem id="node-menu-showdomproperties"
label="&inspectorShowDOMProperties.label;"
oncommand="inspector.showDOMProperties()"/>
<menuitem id="node-menu-expand"
label="&inspectorExpandNode.label;"
oncommand="inspector.expandNode()"/>
<menuitem id="node-menu-collapse"
label="&inspectorCollapseNode.label;"
oncommand="inspector.collapseNode()"/>
<menuseparator/>
<menuitem id="node-menu-pasteinnerhtml"
label="&inspectorHTMLPasteInner.label;"

View File

@ -105,6 +105,16 @@
opens the split Console and displays the properties in its side panel. -->
<!ENTITY inspectorShowDOMProperties.label "Show DOM Properties">
<!-- LOCALIZATION NOTE (inspectorExpandNode.label): This is the label
shown in the inspector contextual-menu for recursively expanding
mark-up elements -->
<!ENTITY inspectorExpandNode.label "Expand All">
<!-- LOCALIZATION NOTE (inspectorCollapseNode.label): This is the label
shown in the inspector contextual-menu for recursively collapsing
mark-up elements -->
<!ENTITY inspectorCollapseNode.label "Collapse">
<!-- LOCALIZATION NOTE (inspectorScreenshotNode.label): This is the label
shown in the inspector contextual-menu for the item that lets users take
a screenshot of the currently selected node. -->