commit db991743cdd7552ccf379b30206465ee9f08de25
parent 41fc082f6d0e5ea323c4a71b5c09cb26367beaa0
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 6 Jul 2015 00:41:42 -0400
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.)
Diffstat:
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/chrome/content/zotero/bindings/guidancepanel.xml b/chrome/content/zotero/bindings/guidancepanel.xml
@@ -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>