Skip to content

Instantly share code, notes, and snippets.

@gcr
Created January 16, 2009 05:22
Show Gist options
  • Save gcr/47829 to your computer and use it in GitHub Desktop.
Save gcr/47829 to your computer and use it in GitHub Desktop.
pagehandler.clearAllActive = function(tlist) {
// tlist is the jQuery list of tabs.
// This function hides all the tabs' user lists and sets them to inactive.
$(tlist).find(".active").each(function (i, tab){ // For each active tab...
if (typeof session.subscribed_docs[$(tab).text()] != undefined) { // If our document still exists...
$(tab).removeClass("active"); // Make it inactive
$(tab).next().slideUp("medium"); // ...and slide up the user list (in the next node)
$(tab).find("img").hide(); // ...and remove all images
// Rebind our click handler.
$(tab).click(function() {
pagehandler.setActive(tab, tlist); // Then, we'll make this tab clickable again
});
// Pretty hover effect. DOESN'T WORK.'
//$(tab).hover(function() {$(tab).addClass("hover");},
// function() {$(tab).removeClass("hover");});
// Now, hide our document itself
// TODO: This is ugly!
$(session.subscribed_docs[$(tab).text()].jqedit).hide(); //hides the editor
}
});
}
pagehandler.setActive = function(tab, tlist) {
if (typeof session.subscribed_docs[$(tab).text()] != undefined) {
// This function sets the tab to active.
// First, clear any other active tabs
pagehandler.clearAllActive(tlist);
// Then, make it active
$(tab).addClass("active");
$(tab).next().slideDown("medium"); // show userlist
$(tab).find("img").fadeIn("slow"); // and the close button
// Now, make sure we can't click it no more.
$(tab).unbind("click"); // Makes it so we can't click on this one
//$(tab).unbind("mouseover").unbind("mouseout"); // Unbinds hover- TODO: Doesn't work in IE6
//$(tab).removeClass("hover");
// Finally, show our document itself
// TODO: This is ugly!
$(session.subscribed_docs[$(tab).text()].jqedit).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment