Skip to content

Instantly share code, notes, and snippets.

@sdesai
Created January 15, 2010 18:31
Show Gist options
  • Save sdesai/278288 to your computer and use it in GitHub Desktop.
Save sdesai/278288 to your computer and use it in GitHub Desktop.
YAHOO.widget.Overlay.prototype.configVisible = function (type, args, obj) {
var visible = args[0],
currentVis = Dom.getStyle(this.element, "visibility"),
effect = this.cfg.getProperty("effect"),
effectInstances = [],
isMacGecko = (this.platform == "mac" && UA.gecko),
alreadySubscribed = Config.alreadySubscribed,
eff, ei, e, i, j, k, h,
nEffects,
nEffectInstances;
if (currentVis == "inherit") {
e = this.element.parentNode;
while (e.nodeType != 9 && e.nodeType != 11) {
currentVis = Dom.getStyle(e, "visibility");
if (currentVis != "inherit") {
break;
}
e = e.parentNode;
}
if (currentVis == "inherit") {
currentVis = "visible";
}
}
if (effect) {
if (effect instanceof Array) {
nEffects = effect.length;
for (i = 0; i < nEffects; i++) {
eff = effect[i];
effectInstances[effectInstances.length] =
eff.effect(this, eff.duration);
}
} else {
effectInstances[effectInstances.length] =
effect.effect(this, effect.duration);
}
}
if (visible) { // Show
if (isMacGecko) {
this.showMacGeckoScrollbars();
}
if (effect) { // Animate in
if (visible) { // Animate in if not showing
if (currentVis != "visible" || currentVis === "") {
this.beforeShowEvent.fire();
nEffectInstances = effectInstances.length;
for (j = 0; j < nEffectInstances; j++) {
ei = effectInstances[j];
if (j === 0 && !alreadySubscribed(
ei.animateInCompleteEvent,
this.showEvent.fire, this.showEvent)) {
/*
Delegate showEvent until end
of animateInComplete
*/
ei.animateInCompleteEvent.subscribe(
this.showEvent.fire, this.showEvent, true);
}
ei.animateIn();
}
}
}
} else { // Show
if (currentVis != "visible" || currentVis === "") {
this.beforeShowEvent.fire();
this._setDomVisibility(true);
this.cfg.refireEvent("iframe");
this.showEvent.fire();
} else {
this._setDomVisibility(true);
}
}
} else { // Hide
if (isMacGecko) {
this.hideMacGeckoScrollbars();
}
if (effect) { // Animate out if showing
if (currentVis == "visible") {
// NEW: Wrap in "if", so subscribers can return false to prevent hide
if (this.beforeHideEvent.fire()) {
nEffectInstances = effectInstances.length;
for (k = 0; k < nEffectInstances; k++) {
h = effectInstances[k];
if (k === 0 && !alreadySubscribed(
h.animateOutCompleteEvent, this.hideEvent.fire,
this.hideEvent)) {
/*
Delegate hideEvent until end
of animateOutComplete
*/
h.animateOutCompleteEvent.subscribe(
this.hideEvent.fire, this.hideEvent, true);
}
h.animateOut();
}
}
} else if (currentVis === "") {
this._setDomVisibility(false);
}
} else { // Simple hide
if (currentVis == "visible" || currentVis === "") {
// NEW: Wrap in "if", so subscribers can return false to prevent hide.
if (this.beforeHideEvent.fire()) {
this._setDomVisibility(false);
this.hideEvent.fire();
}
} else {
this._setDomVisibility(false);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment