5 Visual effects handler. We will want to sub-class this heavily, as there will exist a myriad of effects. Singleton object.
7 Exports object 'Effects' to window namespace
11 Chris Carpita <csc32@cornell.edu>
17 JSAN.use("MochiKit.Logging");
20 //Here's an example of a function which should exist in a subclass:
21 switchHotlistButton: function(buttonId, switchTo, content, clearOnClick){
22 var button = document.getElementById(buttonId);
23 var imgAdd = document.getElementById(buttonId + ":imgAdd");
24 var imgRemove = document.getElementById(buttonId + ":imgRemove");
26 var optionalText = "All AGIs on this Page ";
27 if(!content.match(/:/)) {optionalText = "";}
28 if(switchTo == 'remove'){
29 imgAdd.style.display = "none";
30 imgRemove.style.display = "inline";
31 button.firstChild.nodeValue = "Remove " + optionalText + "from Hotlist";
33 button.setAttribute("onClick", "alert('some')");
36 button.setAttribute("onClick", "Hotlist.remove('" + buttonId + "', '" + content + "'); return false;");
39 else if (switchTo == 'add'){
40 imgAdd.style.display = "inline";
41 imgRemove.style.display = "none";
42 button.firstChild.nodeValue = "Add " + optionalText + "to Hotlist";
44 button.setAttribute("onClick", "alert('some')");
47 button.setAttribute("onClick", "Hotlist.add('" + buttonId + "', '" + content + "'); return false;");
50 else { alert("You sent a bad switchTo variable to switchHotlistButton"); }
52 //These, on the other hand, are generic and belong in CXGN.Effects:
53 showElement: function(elementId, displayMethod) {
54 var element = document.getElementById(elementId);
57 dispMethod = displayMethod;
59 else { dispMethod = "inline"; }
60 element.style.display = dispMethod;
62 hideElement: function(elementId, displayMethod) {
63 var element = document.getElementById(elementId);
66 dispMethod = displayMethod;
68 else { dispMethod = "none"; } //alternative is "hidden", which causes it to continue occupying space on the page
69 element.style.display = dispMethod;
71 swapElements: function(elementIdFrom, elementIdTo, displayMethod){
73 var dispMethod = displayMethod || "inline";
74 var elementFrom = document.getElementById(elementIdFrom);
75 var elementTo = document.getElementById(elementIdTo);
76 elementFrom.style.display = "none";
77 elementTo.style.display = dispMethod;
79 catch(e) { MochiKit.Logging.logError("CXGN.Effects.swapElements: " + e); }