Trigger forward action with click anywhere on guidance panel

Previously, clicking directly on a noautohide guidance panel closed it, even if
there was a forward nav button. (In the case of the main and save button
guidance panels, the save button would appear on the next Firefox restart, but
this ensures that the save guidance panel will be shown to new users even if
they click on the panel instead of the not-particularly-noticeable forward
button.)
This commit is contained in:
Dan Stillman 2015-07-06 00:41:42 -04:00
parent 41fc082f6d
commit db991743cd

View file

@ -34,6 +34,8 @@
</resources>
<implementation>
<property name="panel" onget="return document.getAnonymousNodes(this)[0]"/>
<!--
@param {Object} [options]
@param {String} [options.text] - Text to use in place of firstRunGuidance.<about>
@ -77,8 +79,7 @@
var x = this.getAttribute("x"),
y = this.getAttribute("y"),
position = this.getAttribute("position"),
panel = document.getAnonymousNodes(this)[0];
position = this.getAttribute("position");
if (!useLastText) {
if (!text) {
@ -137,7 +138,7 @@
}
self.hidden = false;
panel.openPopup(forEl, position ? position : "after_start",
self.panel.openPopup(forEl, position ? position : "after_start",
x ? parseInt(x, 10) : 0, y ? parseInt(y, 10) : 0, false, false, null);
if (pref) {
Zotero.Prefs.set(pref, true);
@ -150,12 +151,13 @@
f();
}
if (this.hasAttribute("noautohide")) {
if (this.getAttribute("noautohide") == 'true'
&& !this.hasAttribute('forward')) {
let listener = function () {
panel.removeEventListener("click", listener);
panel.hidePopup();
};
panel.addEventListener("click", listener);
this.panel.removeEventListener("click", listener);
this.panel.hidePopup();
}.bind(this);
this.panel.addEventListener("click", listener);
}
]]>
</body>
@ -182,8 +184,18 @@
var nextElem = document.getElementById(nextID);
button = this.id(dir + '-button');
button.hidden = false;
var target;
// If there's a forward action and no back action, the whole panel triggers
// the forward in noautohide mode
if (dir == 'forward' && !this.hasAttribute('back')
&& this.getAttribute('noautohide') == 'true') {
target = this.panel;
}
else {
target = button;
}
var listener = function (event) {
button.removeEventListener("click", listener);
target.removeEventListener("click", listener);
this.hide();
var data = {
force: true
@ -197,7 +209,7 @@
nextElem.show(data);
event.stopPropagation();
}.bind(this);
button.addEventListener("click", listener);
target.addEventListener("click", listener);
]]></body>
</method>