Skip to content

Instantly share code, notes, and snippets.

@juandopazo
Created December 21, 2013 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juandopazo/8068955 to your computer and use it in GitHub Desktop.
Save juandopazo/8068955 to your computer and use it in GitHub Desktop.
Panel focus patch
Y.Panel.prototype._uiSetHostVisibleModal = function (visible) {
var stack = Y.WidgetModality.STACK,
maskNode = this.get('maskNode'),
isModal = this.get('modal'),
topModal, index;
if (visible) {
Y.Array.each(stack, function (modal) {
modal._detachUIHandlesModal();
modal._blur();
});
// push on top of stack
stack.unshift(this);
this._repositionMask(this);
this._uiSetHostZIndexModal(this.get('zIndex'));
if (isModal) {
maskNode.show();
Y.later(1, this, '_attachUIHandlesModal');
Y.later(1, this, '_focus');
}
} else {
index = Y.Array.indexOf(stack, this);
if (index >= 0) {
// Remove modal widget from global stack.
stack.splice(index, 1);
}
this._detachUIHandlesModal();
this._blur();
if (stack.length) {
topModal = stack[0];
this._repositionMask(topModal);
//topModal._attachUIHandlesModal();
topModal._uiSetHostZIndexModal(topModal.get('zIndex'));
if (topModal.get('modal')) {
//topModal._attachUIHandlesModal();
Y.later(1, topModal, '_attachUIHandlesModal');
topModal._focus();
}
} else {
if (maskNode.getStyle('display') === 'block') {
maskNode.hide();
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment