Since the number of tabs is dynamic, I'd probably use an attribute on the tab's header/label/whatever indicating that it has not been read, and then when the tab's header/label/whatever is clicked, I'd change that attribute to indicate that it had been read and then trigger a function that may enable the button depending on whether all the other tabs had been read.
I'm not a MooTools person, but IIRC it's a fork of Prototype (although it's been a while and they've probably diverged). The click handler could look something like this in Prototype:
$$('.tabClass').invoke('observe', 'click', function(event) {
this.setAttribute("data-read", "Y");
if ($$('.tabClass[data-read=N]').length == 0) {
$('buttonId').disabled = false;
}
});
...where $$
is Prototype's "search the DOM for elements matching this CSS selector" function and $
is Prototype's "get me the element with this ID". The invoke
there just calls observe
for each matching element (you could do this with event delegation instead), and I think observe
is fairly self-evident. :-)
The code above makes these assumptions:
- Your tab header or whatever has the class "tabClass".
- You've created the tables with the attribute "data-read" set to "N" (e.g.,
<div class="tabClass" data=read="N">
or similar). The data-
prefix is to be HTML5-friendly. (Yes, we're finally allowed to put any old arbitrary attribute name on elements if we want to! We just have to prefix them with data-
.)
- The button has an ID, "buttonId"
- The button starts off disabled
Edit Or use a marker class if you prefer, all tabs start out with class="tabClass unread"
:
$$('.tabClass').invoke('observe', 'click', function(event) {
this.removeClassName("unread");
if ($$('.tabClass.unread').length == 0) {
$('buttonId').disabled = false;
}
});
Double-check that MooTools supports the ".tabClass.unread" selector (it really should, I'm just saying, check). Some implementations may work more quickly with class-based selectors than attribute-based ones.