Bug 941109 - use closemenu instead of noautoclose attribute in Australis menupanel, r=mconley

--HG--
extra : rebase_source : 89c32805249cebe4c29e135b1d27b7679eb1fbd8
This commit is contained in:
Gijs Kruitbosch 2014-01-21 19:01:16 +00:00
parent bc8555362f
commit 96f79840a6
6 changed files with 24 additions and 17 deletions

View File

@ -999,7 +999,7 @@ let BookmarkingUI = {
if (widget.overflowed) {
// Don't open a popup in the overflow popup, rather just open the Library.
event.preventDefault();
widget.node.removeAttribute("noautoclose");
widget.node.removeAttribute("closemenu");
PlacesCommandHook.showPlacesOrganizer("BookmarksMenu");
return;
}
@ -1172,7 +1172,7 @@ let BookmarkingUI = {
let view = document.getElementById("PanelUI-bookmarks");
view.addEventListener("ViewShowing", this.onPanelMenuViewShowing);
view.addEventListener("ViewHiding", this.onPanelMenuViewHiding);
widget.node.setAttribute("noautoclose", "true");
widget.node.setAttribute("closemenu", "none");
PanelUI.showSubView("PanelUI-bookmarks", widget.node,
CustomizableUI.AREA_PANEL);
return;
@ -1181,9 +1181,9 @@ let BookmarkingUI = {
// Allow to close the panel if the page is already bookmarked, cause
// we are going to open the edit bookmark panel.
if (this._itemIds.length > 0)
widget.node.removeAttribute("noautoclose");
widget.node.removeAttribute("closemenu");
else
widget.node.setAttribute("noautoclose", "true");
widget.node.setAttribute("closemenu", "none");
}
// Ignore clicks on the star if we are updating its state.

View File

@ -1171,7 +1171,7 @@ SocialStatus = {
if (inMenuPanel) {
panel = document.getElementById("PanelUI-socialapi");
this._attachNotificatonPanel(panel, aToolbarButton, provider);
widget.node.setAttribute("noautoclose", "true");
widget.node.setAttribute("closemenu", "none");
showingEvent = "ViewShowing";
hidingEvent = "ViewHiding";
} else {

View File

@ -23,7 +23,7 @@
let widget = widgetGroup.forWindow(window);
this.inMenuPanel = widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL;
if (this.inMenuPanel) {
widget.node.setAttribute("noautoclose", "true");
widget.node.setAttribute("closemenu", "none");
return document.getElementById("PanelUI-socialapi");
}
return document.getAnonymousElementByAttribute(this, "anonid", "panel");

View File

@ -330,9 +330,15 @@ const PanelUI = {
* so that the panel knows if and when to close itself.
*/
onCommandHandler: function(aEvent) {
if (!aEvent.originalTarget.hasAttribute("noautoclose")) {
PanelUI.hide();
let closemenu = aEvent.originalTarget.getAttribute("closemenu");
if (closemenu == "none") {
return;
}
if (closemenu == "single") {
this.showMainView();
return;
}
this.hide();
},
/**

View File

@ -1230,7 +1230,8 @@ let CustomizableUIInternal = {
}
// If the user hit enter/return, we don't check preventDefault - it makes sense
// that this was prevented, but we probably still want to close the panel.
// If consumers don't want this to happen, they should specify noautoclose.
// If consumers don't want this to happen, they should specify the closemenu
// attribute.
} else if (aEvent.type != "command") { // mouse events:
if (aEvent.defaultPrevented || aEvent.button != 0) {
@ -1243,7 +1244,7 @@ let CustomizableUIInternal = {
}
}
if (aEvent.target.getAttribute("noautoclose") == "true" ||
if (aEvent.target.getAttribute("closemenu") == "none" ||
aEvent.target.getAttribute("widget-type") == "view") {
return;
}

View File

@ -44,12 +44,12 @@ function setAttributes(aNode, aAttrs) {
}
}
function updateCombinedWidgetStyle(aNode, aArea, aModifyAutoclose) {
function updateCombinedWidgetStyle(aNode, aArea, aModifyCloseMenu) {
let inPanel = (aArea == CustomizableUI.AREA_PANEL);
let cls = inPanel ? "panel-combined-button" : "toolbarbutton-1";
let attrs = {class: cls};
if (aModifyAutoclose) {
attrs.noautoclose = inPanel ? true : null;
if (aModifyCloseMenu) {
attrs.closemenu = inPanel ? "none" : null;
}
for (let i = 0, l = aNode.childNodes.length; i < l; ++i) {
if (aNode.childNodes[i].localName == "separator")
@ -311,7 +311,7 @@ const CustomizableWidgets = [{
let areaType = CustomizableUI.getAreaType(this.currentArea);
let inPanel = areaType == CustomizableUI.TYPE_MENU_PANEL;
let inToolbar = areaType == CustomizableUI.TYPE_TOOLBAR;
let noautoclose = inPanel ? "true" : null;
let closeMenu = inPanel ? "none" : null;
let cls = inPanel ? "panel-combined-button" : "toolbarbutton-1";
if (!this.currentArea)
@ -319,20 +319,20 @@ const CustomizableWidgets = [{
let buttons = [{
id: "zoom-out-button",
noautoclose: noautoclose,
closemenu: closeMenu,
command: "cmd_fullZoomReduce",
class: cls,
label: true,
tooltiptext: true
}, {
id: "zoom-reset-button",
noautoclose: noautoclose,
closemenu: closeMenu,
command: "cmd_fullZoomReset",
class: cls,
tooltiptext: true
}, {
id: "zoom-in-button",
noautoclose: noautoclose,
closemenu: closeMenu,
command: "cmd_fullZoomEnlarge",
class: cls,
label: true,