Author: nbelaevski
Date: 2007-03-15 11:34:00 -0400 (Thu, 15 Mar 2007)
New Revision: 75
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
Handling for short-form clientId implemented
Modified:
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-03-14
20:00:52 UTC (rev 74)
+++
trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-03-15
15:34:00 UTC (rev 75)
@@ -31,37 +31,29 @@
}
}
-ModalPanel.ajaxListener = {
+ModalPanel.panels = new Array();
+
+A4J.AJAX.AddListener({
onafterajax: function(req, event, data) {
var i = 0;
- while (i < this.panels.length) {
- var panel = this.panels[i];
+ while (i < ModalPanel.panels.length) {
+ var panel = ModalPanel.panels[i];
var elt = panel.markerId;
if (!Richfaces.isNodeInDOMTree(elt)) {
panel.destroy();
- this.panels.splice(i, 1);
+ ModalPanel.panels.splice(i, 1);
//check all panels again. maybe we've removed parent of any panel just now
i = 0;
} else {
i++;
}
}
- },
-
- panels: new Array(),
-
- addPanel: function(panel) {
- if (panel) {
- this.panels.push(panel);
- }
}
-};
+});
-A4J.AJAX.AddListener(ModalPanel.ajaxListener);
-
ModalPanel.Context = Class.create();
ModalPanel.Context.prototype = {
initialize: function(modalPanel) {
@@ -162,15 +154,18 @@
this.cdiv.mpUseExpr = true;
}
+
+ ModalPanel.panels.push(this);
},
destroy: function() {
- var parent = this.id.parentNode;
-
this.traverseSelects(true);
- if (parent) {
- parent.removeChild(this.id);
+ if (this.floatedToBody) {
+ var parent = this.id.parentNode;
+ if (parent) {
+ parent.removeChild(this.id);
+ }
}
},
@@ -259,9 +254,9 @@
},
show: function(opts) {
- if (this.id.parentNode != document.body) {
+ if (!this.floatedToBody) {
document.body.appendChild(this.id.parentNode.removeChild(this.id));
- ModalPanel.ajaxListener.addPanel(this);
+ this.floatedToBody = true;
}
var options = {};
@@ -543,14 +538,41 @@
}
}
+Richfaces.findModalPanel = function (id) {
+ if (id) {
+ var prefId = (id.charAt(0) == ':' ? id : ':' + id);
+
+ for (var i = 0; i < ModalPanel.panels.length; i++ ) {
+ var pnl = ModalPanel.panels[i];
+ if (pnl && pnl.markerId) {
+ var pnlId = pnl.markerId.id;
+
+ if (pnlId) {
+ //try to match ids
+ if (pnlId.length >= prefId.length) {
+ var substr = pnlId.substring(pnlId.length - prefId.length, pnlId.length);
+ if (substr == prefId) {
+ return pnl.id;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
Richfaces.showModalPanel = function (id, opts) {
var panel = $(id + "Container");
- if (panel && panel.modalPanel)
- panel.modalPanel.show(opts);
+ if (!panel) {
+ panel = Richfaces.findModalPanel(id);
+ }
+ panel.modalPanel.show(opts);
}
Richfaces.hideModalPanel = function (id) {
var panel = $(id + "Container");
- if (panel && panel.modalPanel)
- panel.modalPanel.hide();
+ if (!panel) {
+ panel = Richfaces.findModalPanel(id);
+ }
+ panel.modalPanel.hide();
}
Show replies by date