mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 935823 - UITour: Add a close button to info panels. r=Unfocused
This commit is contained in:
parent
316891bb1b
commit
dd6388f495
@ -325,7 +325,12 @@ this.UITour = {
|
||||
}
|
||||
}
|
||||
|
||||
this.showInfo(contentDocument, target, data.title, data.text, iconURL, buttons);
|
||||
let infoOptions = {};
|
||||
|
||||
if (typeof data.closeButtonCallbackID == "string")
|
||||
infoOptions.closeButtonCallbackID = data.closeButtonCallbackID;
|
||||
|
||||
this.showInfo(contentDocument, target, data.title, data.text, iconURL, buttons, infoOptions);
|
||||
}).then(null, Cu.reportError);
|
||||
break;
|
||||
}
|
||||
@ -508,14 +513,6 @@ this.UITour = {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "command": {
|
||||
if (aEvent.target.id == "UITourTooltipClose") {
|
||||
let window = aEvent.target.ownerDocument.defaultView;
|
||||
this.hideInfo(window);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -870,7 +867,20 @@ this.UITour = {
|
||||
this._setAppMenuStateForAnnotation(aWindow, "highlight", false);
|
||||
},
|
||||
|
||||
showInfo: function(aContentDocument, aAnchor, aTitle = "", aDescription = "", aIconURL = "", aButtons = []) {
|
||||
/**
|
||||
* Show an info panel.
|
||||
*
|
||||
* @param {Document} aContentDocument
|
||||
* @param {Node} aAnchor
|
||||
* @param {String} [aTitle=""]
|
||||
* @param {String} [aDescription=""]
|
||||
* @param {String} [aIconURL=""]
|
||||
* @param {Object[]} [aButtons=[]]
|
||||
* @param {Object} [aOptions={}]
|
||||
* @param {String} [aOptions.closeButtonCallbackID]
|
||||
*/
|
||||
showInfo: function(aContentDocument, aAnchor, aTitle = "", aDescription = "", aIconURL = "",
|
||||
aButtons = [], aOptions = {}) {
|
||||
function showInfoPanel(aAnchorEl) {
|
||||
aAnchorEl.focus();
|
||||
|
||||
@ -914,7 +924,16 @@ this.UITour = {
|
||||
tooltipButtons.hidden = !aButtons.length;
|
||||
|
||||
let tooltipClose = document.getElementById("UITourTooltipClose");
|
||||
tooltipClose.addEventListener("command", this);
|
||||
let closeButtonCallback = (event) => {
|
||||
this.hideInfo(document.defaultView);
|
||||
if (aOptions && aOptions.closeButtonCallbackID)
|
||||
this.sendPageCallback(aContentDocument, aOptions.closeButtonCallbackID);
|
||||
};
|
||||
tooltipClose.addEventListener("command", closeButtonCallback);
|
||||
tooltip.addEventListener("popuphiding", function tooltipHiding(event) {
|
||||
tooltip.removeEventListener("popuphiding", tooltipHiding);
|
||||
tooltipClose.removeEventListener("command", closeButtonCallback);
|
||||
});
|
||||
|
||||
tooltip.setAttribute("targetName", aAnchor.targetName);
|
||||
tooltip.hidden = false;
|
||||
|
@ -122,4 +122,21 @@ let tests = [
|
||||
let buttons = gContentWindow.makeButtons();
|
||||
gContentAPI.showInfo("urlbar", "another title", "moar text", "./image.png", buttons);
|
||||
},
|
||||
|
||||
function test_info_close_button(done) {
|
||||
let popup = document.getElementById("UITourTooltip");
|
||||
let closeButton = document.getElementById("UITourTooltipClose");
|
||||
|
||||
popup.addEventListener("popupshown", function onPopupShown() {
|
||||
popup.removeEventListener("popupshown", onPopupShown);
|
||||
EventUtils.synthesizeMouseAtCenter(closeButton, {}, window);
|
||||
executeSoon(function() {
|
||||
is(gContentWindow.callbackResult, "closeButton", "Close button callback called");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
let infoOptions = gContentWindow.makeInfoOptions();
|
||||
gContentAPI.showInfo("urlbar", "Close me", "X marks the spot", null, null, infoOptions);
|
||||
}
|
||||
];
|
||||
|
@ -20,6 +20,12 @@
|
||||
{label: "Button 2", callback: makeCallback("button2"), icon: "image.png"}
|
||||
];
|
||||
}
|
||||
|
||||
function makeInfoOptions() {
|
||||
return {
|
||||
closeButtonCallback: makeCallback("closeButton")
|
||||
};
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -77,7 +77,7 @@ if (typeof Mozilla == 'undefined') {
|
||||
_sendEvent('hideHighlight');
|
||||
};
|
||||
|
||||
Mozilla.UITour.showInfo = function(target, title, text, icon, buttons) {
|
||||
Mozilla.UITour.showInfo = function(target, title, text, icon, buttons, options) {
|
||||
var buttonData = [];
|
||||
if (Array.isArray(buttons)) {
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
@ -90,12 +90,17 @@ if (typeof Mozilla == 'undefined') {
|
||||
}
|
||||
}
|
||||
|
||||
var closeButtonCallbackID;
|
||||
if (options && options.closeButtonCallback)
|
||||
closeButtonCallbackID = _waitForCallback(options.closeButtonCallback);
|
||||
|
||||
_sendEvent('showInfo', {
|
||||
target: target,
|
||||
title: title,
|
||||
text: text,
|
||||
icon: icon,
|
||||
buttons: buttonData
|
||||
buttons: buttonData,
|
||||
closeButtonCallbackID: closeButtonCallbackID
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
||||
}
|
||||
|
||||
#UITourTooltipClose {
|
||||
visibility: hidden; /* XXX Temporarily disabled by bug 966913 */
|
||||
-moz-appearance: none;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
|
Loading…
Reference in New Issue
Block a user