Author: abelevich
Date: 2008-03-21 09:35:56 -0400 (Fri, 21 Mar 2008)
New Revision: 7046
Modified:
trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2201?page=comments
also onbeforeshow/onbeforehide cancelable events are added
Modified: trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
===================================================================
--- trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2008-03-21 13:20:24 UTC
(rev 7045)
+++ trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2008-03-21 13:35:56 UTC
(rev 7046)
@@ -132,6 +132,20 @@
</property>
<property>
+ <name>onbeforeshow</name>
+ <classname>java.lang.String</classname>
+ <description> Event must occurs before panel is opening </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
+ <property>
+ <name>onbeforehide</name>
+ <classname>java.lang.String</classname>
+ <description> Event must occurs before panel is hiding </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
+ <property>
<name>onresize</name>
<classname>java.lang.String</classname>
<description>Event must occurs than panel is resizing </description>
Modified:
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
===================================================================
---
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2008-03-21
13:20:24 UTC (rev 7045)
+++
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2008-03-21
13:35:56 UTC (rev 7046)
@@ -124,6 +124,8 @@
variables.setVariable("onhide", onhide);
String onbeforeshow =
ScriptUtils.toScript(panel.getAttributes().get("onbeforeshow"));
variables.setVariable("onbeforeshow", onbeforeshow);
+ String onbeforehide =
ScriptUtils.toScript(panel.getAttributes().get("onbeforehide"));
+ variables.setVariable("onbeforehide", onbeforehide);
String onmove =
ScriptUtils.toScript(panel.getAttributes().get("onmove"));
variables.setVariable("onmove", onmove);
}
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-03-21
13:20:24 UTC (rev 7045)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-03-21
13:35:56 UTC (rev 7046)
@@ -422,7 +422,7 @@
show: function(event, opts) {
var element = this.id;
- if(this.invokeEvent("show",event,null,element)){
+ if(this.invokeEvent("beforeshow",event,null,element)){
this.preventFocus();
if (!this.floatedToBody) {
@@ -620,6 +620,7 @@
var event = {};
event.parameters = opts || {};
this.shown = true;
+ this.invokeEvent("show",event,null,element);
}
},
@@ -639,57 +640,60 @@
},
hide: function(event, opts) {
- this.restoreFocus();
-
- this.traverseSelects(true);
-
- var eDiv = $(this.div);
- var eCdiv = $(this.cdiv);
-
- if (eDiv.style.removeExpression) {
- eDiv.style.removeExpression("width");
- eDiv.style.removeExpression("height");
-
- eDiv.style.removeExpression("left");
- eDiv.style.removeExpression("top");
-
- var eCursorDiv = $(this.cursorDiv);
- eCursorDiv.style.removeExpression("width");
- eCursorDiv.style.removeExpression("height");
-
- eCursorDiv.style.removeExpression("left");
- eCursorDiv.style.removeExpression("top");
-
- eCdiv.style.removeExpression("left");
- eCdiv.style.removeExpression("top");
- }
-
- var element = $(this.id);
- Element.hide(element);
-
- if (this.floatedToBody && this.parent) {
-
- document.body.removeChild(element);
- this.parent.appendChild(element);
- this.floatedToBody = false;
- }
- var event = {};
- event.parameters = opts || {};
- if (this.eventOnHide) this.eventOnHide(event);
- var forms = eCdiv.getElementsByTagName("form");
- if (this.options.keepVisualState && forms) {
- for (var i = 0; i < forms.length; i++) {
- Event.stopObserving(forms[i], "submit", this.formOnsubmit);
+ if (this.invokeEvent("beforehide",event,null,element)) {
+ this.restoreFocus();
+ this.traverseSelects(true);
+
+ var eDiv = $(this.div);
+ var eCdiv = $(this.cdiv);
+
+ if (eDiv.style.removeExpression) {
+ eDiv.style.removeExpression("width");
+ eDiv.style.removeExpression("height");
+
+ eDiv.style.removeExpression("left");
+ eDiv.style.removeExpression("top");
+
+ var eCursorDiv = $(this.cursorDiv);
+ eCursorDiv.style.removeExpression("width");
+ eCursorDiv.style.removeExpression("height");
+
+ eCursorDiv.style.removeExpression("left");
+ eCursorDiv.style.removeExpression("top");
+
+ eCdiv.style.removeExpression("left");
+ eCdiv.style.removeExpression("top");
}
+
+ var element = $(this.id);
+ Element.hide(element);
+
+ if (this.floatedToBody && this.parent) {
+
+ document.body.removeChild(element);
+ this.parent.appendChild(element);
+ this.floatedToBody = false;
+ }
+
+ var event = {};
+ event.parameters = opts || {};
+ if (this.eventOnHide) this.eventOnHide(event);
+
+ var forms = eCdiv.getElementsByTagName("form");
+ if (this.options.keepVisualState && forms) {
+ for (var i = 0; i < forms.length; i++) {
+ Event.stopObserving(forms[i], "submit", this.formOnsubmit);
+ }
+ }
+
+ this.shown = false;
+
+ if (this.options.autosized) {
+ window.clearInterval(this.observerSize);
+ }
}
-
- this.shown = false;
-
- if (this.options.autosized) {
- window.clearInterval(this.observerSize);
- }
},
_getStyle: function(elt, name) {
@@ -884,20 +888,15 @@
var eventFunction = this.options['on'+eventName];
var result;
- if (eventFunction)
- {
+ if (eventFunction) {
var eventObj;
-
- if (event)
- {
+ if (event) {
eventObj = event;
}
- else if( document.createEventObject )
- {
+ else if(document.createEventObject) {
eventObj = document.createEventObject();
}
- else if( document.createEvent )
- {
+ else if( document.createEvent ) {
eventObj = document.createEvent('Events');
eventObj.initEvent( eventName, true, false );
}
@@ -905,16 +904,15 @@
eventObj.rich = {component:this};
eventObj.rich.value = value;
- try
- {
+ try {
result = eventFunction.call(element, eventObj);
}
catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName +
"]"); }
-
}
- if (result!=false) result = true;
-
+ if (result!=false) {
+ result = true;
+ }
return result;
}
}
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2008-03-21
13:20:24 UTC (rev 7045)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2008-03-21
13:35:56 UTC (rev 7046)
@@ -176,6 +176,8 @@
<f:call name="writeEventHandlerFunction"><f:parameter
value="onresize" /></f:call>,
<f:call name="writeEventHandlerFunction"><f:parameter
value="onmove" /></f:call>,
<f:call name="writeEventHandlerFunction"><f:parameter
value="onshow" /></f:call>,
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="onbeforeshow"/></f:call>,
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="onbeforehide" /></f:call>,
keepVisualState: #{component.keepVisualState},
showWhenRendered: #{component.showWhenRendered},