gmail.js icon indicating copy to clipboard operation
gmail.js copied to clipboard

Question: toolbar button is appearing, when loading the mail for the first time

Open Debolinap opened this issue 7 years ago • 4 comments

I am adding toolbar button to the gmail view, using gmail.js.

var main = function() { gmail = new Gmail(); // add toolbar gmail.tools.add_toolbar_button('', function()) }

calling this main function on page loading,

refresh(main); function refresh(f) { if( (/in/.test(document.readyState)) || (typeof Gmail === undefined) ) { setTimeout('refresh(' + f + ')', 10); } else { f(); } }

As, I am calling this main() on page loading, this toolbar button is appearing right after we are opening gmail ui. but my requirement is to show the toolbar button only when at least 1 mail is selected, like other toolbar buttons. How to catch the event of mail selection, so that I can call the add_toolbar_button() only when at least one mail is selected from visible label

Debolinap avatar Aug 20 '18 10:08 Debolinap

used display:none style class to hide the button for 1 st time load of gmail. now button is visible only if 1 mail is s elected by checkbox. but button remains hidden if user clicks on the mail and open it

Debolinap avatar Aug 26 '18 17:08 Debolinap

but my requirement is to show the toolbar button only when at least 1 mail is selected, like other toolbar buttons

No idea. You will have to roll your own.

gmail.tools.add_toolbar_button() only provides a means to inject a toolbar into the DOM. It does not help persist or manipulate it.

but button remains hidden if user clicks on the mail and open it

This is a known issue with several duplicate bug-reports. Search closed issues for workarounds.

josteink avatar Aug 27 '18 06:08 josteink

Related to this issue, it looks like gmail on the inbox list is setting the display style to none for the the button if you select and then unselect a thread.

This is the minified code doing that:

if (this.Aa != a) {
    this.Aa = a;
    this.ha.Gc = a;
    b = this.Ea(_.Dm);
    for (var c = this.Ea("mam"), d = _.Lt(this.Na(), _.pd, "nu", this.Ea())[0], e = _.Lt(this.Na(), _.pd, _.nha, this.Ea()), f, h = 0; f = e[h]; h++)
        d && _.Bt(f, d) ? f.style.display = a ? "" : _.Yk : c && _.Bt(f, c) ? (f = _.Lt(this.Na(), _.Ge, "bjy", this.Ea())[0],
        _.Dt(f, _.vja)) : b && _.Bt(f, b) || (f.style.display = a ? _.Yk : "");
    this.dispatchEvent(_.fm)
}

cancan101 avatar May 19 '22 21:05 cancan101

So basically even more pitfalls then? 😅

josteink avatar May 22 '22 07:05 josteink

Old issue is old. Closing.

josteink avatar Oct 11 '23 08:10 josteink