Author: abelevich
Date: 2007-11-21 14:04:08 -0500 (Wed, 21 Nov 2007)
New Revision: 4157
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/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
remove onresizing, onbefareshow events, fix onshow,onresize, onmove events
Modified: trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
===================================================================
--- trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2007-11-21 19:03:03 UTC
(rev 4156)
+++ trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2007-11-21 19:04:08 UTC
(rev 4157)
@@ -134,36 +134,28 @@
<description> Event must occurs after panel closed </description>
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
+
<property>
<name>onmove</name>
<classname>java.lang.String</classname>
- <description> Event must occurs before panel moved </description>
+ <description> Event must occurs before panel is moving </description>
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
+
<property>
<name>onresize</name>
<classname>java.lang.String</classname>
- <description>Event must occurs after panel resized </description>
+ <description>Event must occurs than panel is resizing </description>
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
+
<property>
- <name>onresizing</name>
- <classname>java.lang.String</classname>
- <description>Event must occurs before panel resized </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
- <property>
- <name>onbeforeshow</name>
- <classname>java.lang.String</classname>
- <description> Event must occurs before panel opened</description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
- <property>
<name>showWhenRendered</name>
<classname>boolean</classname>
<description> If "true" value for this attribute makes a modal panel
opened as default. </description>
<defaultvalue>false</defaultvalue>
</property>
+
<property>
<name>keepVisualState</name>
<classname>boolean</classname>
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 2007-11-21
19:03:03 UTC (rev 4156)
+++
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2007-11-21
19:04:08 UTC (rev 4157)
@@ -33,6 +33,7 @@
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.UIModalPanel;
@@ -123,13 +124,7 @@
String onbeforeshow =
ScriptUtils.toScript(panel.getAttributes().get("onbeforeshow"));
variables.setVariable("onbeforeshow", onbeforeshow);
String onmove =
ScriptUtils.toScript(panel.getAttributes().get("onmove"));
- variables.setVariable("onmove", onmove);
- String onresize =
ScriptUtils.toScript(panel.getAttributes().get("onresize"));
- variables.setVariable("onresize", onresize);
- String onresizing =
ScriptUtils.toScript(panel.getAttributes().get("onresizing"));
- variables.setVariable("onresizing", onresizing);
-
-
+
}
@@ -161,4 +156,8 @@
}
return result.toString();
}
+
+ public void writeEventHandlerFunction(FacesContext context, UIComponent component,
String eventName) throws IOException{
+ RendererUtils.writeEventHandlerFunction(context, component, eventName);
+ }
}
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 2007-11-21
19:03:03 UTC (rev 4156)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-11-21
19:04:08 UTC (rev 4157)
@@ -205,26 +205,10 @@
eCdiv.mpUseExpr = true;
}
- if (this.options.onshow && this.options.onshow != ""){
- this.eventOnShow = new
Function("event",this.options.onshow).bindAsEventListener(this);
- }
if (this.options.onhide && this.options.onhide != ""){
this.eventOnHide = new
Function("event",this.options.onhide).bindAsEventListener(this);
}
- if(this.options.onbeforeshow){
- this.eventOnBeforeShow = new
Function("event",this.options.onbeforeshow).bindAsEventListener(this);
- }
- if(this.options.onmove){
- this.eventOnMove = new
Function("event",this.options.onmove).bindAsEventListener(this);
- }
- if(this.options.onresize){
- this.eventOnResize = new
Function("event",this.options.onresize).bindAsEventListener(this);
- }
- if(this.options.onresizing){
- this.eventOnResizing = new
Function("event",this.options.onresizing).bindAsEventListener(this);
- }
-
ModalPanel.panels.push(this);
this.eventFirstOnfocus = this.firstOnfocus.bindAsEventListener(this);
@@ -468,209 +452,209 @@
},
show: function(opts) {
- if(this.eventOnBeforeShow) this.eventOnBeforeShow(event);
- this.preventFocus();
var element = $(this.id);
- if (!this.floatedToBody) {
- this.parent = element.parentNode;
- document.body.insertBefore(this.parent.removeChild(element), null);
- this.floatedToBody = true;
- }
-
- var eCdiv = $(this.cdiv);
- var forms = eCdiv.getElementsByTagName("form");
-
- if (this.options.keepVisualState && forms) {
- this.formOnsubmit = this.setStateInput.bindAsEventListener(this);
- for (var i = 0; i < forms.length; i++) {
- Event.observe(forms[i], "submit", this.formOnsubmit);
- }
- }
-
- var eIframe;
- if (ModalPanel.disableSelects && !this.iframe) {
- new Insertion.Top(eCdiv,
- "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.id + "IFrame\"" +
- "style=\"position: absolute; width: 1px; height: 1px; background-color:
white; overflow-y: hidden; z-index: 1;\">" +
- "</iframe>");
-
- this.iframe = this.id + "IFrame";
+ if(this.invokeEvent("show",event,null,element)){
+ this.preventFocus();
- eIframe = $(this.iframe);
-
- //alert("IFrame:" + eIframe + "created!");
-
- //eIframe.onload = this.initIframe.bind(eIframe);
- Event.observe(eIframe, 'load', this.initIframe.bindAsEventListener(eIframe));
- }
-
- var options = {};
- this.userOptions = {};
-
- if (!eCdiv.mpSet) {
- Object.extend(options, this.options);
- }
-
- if (opts) {
- Object.extend(options, opts);
- Object.extend(this.userOptions, opts);
- }
-
- var eContentDiv = $(this.contentDiv);
-
- if (this.options.autosized) {
- eContentDiv.style.overflow = "";
- options.width = -1;
- options.height = -1;
- eContentDiv.style.width="100%";
- eContentDiv.style.height="100%";
-
- } else {
- if (options.width && options.width == -1)
- options.width = 300;
- if (options.height && options.height == -1)
- options.height = 200;
- }
-
- if (options.width && options.width != -1) {
- if (this.minWidth > options.width) {
- options.width = this.minWidth;
+ if (!this.floatedToBody) {
+ this.parent = element.parentNode;
+ document.body.insertBefore(this.parent.removeChild(element), null);
+ this.floatedToBody = true;
}
-
- eContentDiv.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
- }
-
- if (options.height && options.height != -1) {
- if (this.minHeight > options.height) {
- options.height = this.minHeight;
+
+ var eCdiv = $(this.cdiv);
+ var forms = eCdiv.getElementsByTagName("form");
+
+ if (this.options.keepVisualState && forms) {
+ this.formOnsubmit = this.setStateInput.bindAsEventListener(this);
+ for (var i = 0; i < forms.length; i++) {
+ Event.observe(forms[i], "submit", this.formOnsubmit);
+ }
}
-
- eContentDiv.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
- }
-
- eCdiv.mpSet = true;
-
- //Element.setStyle(this.dialogWindow.document.body, { "margin" : "0px
0px 0px 0px" });
- //if("transparent" == Element.getStyle(document.body,
"background-color")) {
- // eIframe.allowTransparency = true;
- //}
-
-
- this.traverseSelects();
-
- //this.shape.init(eCdiv, this.options);
-
- var eDiv = $(this.div);
- if (eDiv.style.position == "absolute")
- {
- var we = "getSizeElement().clientWidth + \"px\"";
- var he = "getSizeElement().clientHeight + \"px\"";
- eDiv.style.setExpression("width", we);
- eDiv.style.setExpression("height", he);
-
- var eCursorDiv = $(this.cursorDiv);
- eCursorDiv.style.setExpression("width", we);
- eCursorDiv.style.setExpression("height", he);
-
- var le = "-Position.cumulativeOffset(this.parentNode)[0] +
getSizeElement().scrollLeft + \"px\"";
- var te = "-Position.cumulativeOffset(this.parentNode)[1] +
getSizeElement().scrollTop + \"px\"";
-
- eDiv.style.setExpression("left", le);
- eDiv.style.setExpression("top", te);
-
- eCursorDiv.style.setExpression("left", le);
- eCursorDiv.style.setExpression("top", te);
-
-
- var leftExpr = "(this.mpLeft || 0) +
-Position.cumulativeOffset(this.parentNode)[0] + getSizeElement().scrollLeft +
\"px\"";
- var topExpr = "(this.mpTop || 0) + -Position.cumulativeOffset(this.parentNode)[1]
+ getSizeElement().scrollTop + \"px\"";
-
- eCdiv.style.setExpression("left", leftExpr);
- eCdiv.style.setExpression("top", topExpr);
-
-
- /* That's how we output debug info - DOM inspector rulez */
- /*
- document.body.setExpression("_clientLeft",
"getSizeElement().clientLeft");
- document.body.setExpression("_clientTop",
"getSizeElement().clientTop");
- document.body.setExpression("_scrollLeft",
"getSizeElement().scrollLeft");
- document.body.setExpression("_scrollTop",
"getSizeElement().scrollTop");
- */
- /* */
- }
-
- element.style.visibility = "hidden";
-
- Element.show(element);
- this.correctShadowSizeEx(eContentDiv);
-
- if (options.left) {
- var _left;
- if (options.left != "auto") {
- _left = parseInt(options.left, 10);
+
+ var eIframe;
+ if (ModalPanel.disableSelects && !this.iframe) {
+ new Insertion.Top(eCdiv,
+ "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.id + "IFrame\"" +
+ "style=\"position: absolute; width: 1px; height: 1px; background-color:
white; overflow-y: hidden; z-index: 1;\">" +
+ "</iframe>");
+
+ this.iframe = this.id + "IFrame";
+
+ eIframe = $(this.iframe);
+
+ //alert("IFrame:" + eIframe + "created!");
+
+ //eIframe.onload = this.initIframe.bind(eIframe);
+ Event.observe(eIframe, 'load',
this.initIframe.bindAsEventListener(eIframe));
+ }
+
+ var options = {};
+ this.userOptions = {};
+
+ if (!eCdiv.mpSet) {
+ Object.extend(options, this.options);
+ }
+
+ if (opts) {
+ Object.extend(options, opts);
+ Object.extend(this.userOptions, opts);
+ }
+
+ var eContentDiv = $(this.contentDiv);
+
+ if (this.options.autosized) {
+ eContentDiv.style.overflow = "";
+ options.width = -1;
+ options.height = -1;
+ eContentDiv.style.width="100%";
+ eContentDiv.style.height="100%";
+
} else {
- var cw = getSizeElement().clientWidth;
- if (RichFaces.navigatorType() == RichFaces.OPERA)
- {
- _left = (cw - eContentDiv.parentNode.getWidth()) / 2;
+ if (options.width && options.width == -1)
+ options.width = 300;
+ if (options.height && options.height == -1)
+ options.height = 200;
+ }
+
+ if (options.width && options.width != -1) {
+ if (this.minWidth > options.width) {
+ options.width = this.minWidth;
}
- else {
- var _width = Richfaces.getComputedStyleSize(eContentDiv.parentNode,
"width");
- if (isNaN(_width))
- _width = eContentDiv.parentNode.clientWidth;
- _left = (cw - _width) / 2;
- }
-
+
+ eContentDiv.style.width = options.width + (/px/.test(options.width) ? '' :
'px');
}
-
- this.setLeft(_left);
- }
-
- if (options.top) {
- var _top;
- if (options.top != "auto") {
- _top = parseInt(options.top, 10);
- } else {
- var cw = getSizeElement().clientHeight;
- if (RichFaces.navigatorType() == RichFaces.OPERA)
- {
- _top = (cw - eContentDiv.parentNode.getHeight()) / 2;
+
+ if (options.height && options.height != -1) {
+ if (this.minHeight > options.height) {
+ options.height = this.minHeight;
}
- else {
- var _height = Richfaces.getComputedStyleSize(eContentDiv.parentNode,
"height");
- if (isNaN(_height))
- _height = eContentDiv.parentNode.clientHeight;
- _top = (cw - _height) / 2;
+
+ eContentDiv.style.height = options.height + (/px/.test(options.height) ? '' :
'px');
+ }
+
+ eCdiv.mpSet = true;
+
+ //Element.setStyle(this.dialogWindow.document.body, { "margin" : "0px
0px 0px 0px" });
+ //if("transparent" == Element.getStyle(document.body,
"background-color")) {
+ // eIframe.allowTransparency = true;
+ //}
+
+
+ this.traverseSelects();
+
+ //this.shape.init(eCdiv, this.options);
+
+ var eDiv = $(this.div);
+ if (eDiv.style.position == "absolute")
+ {
+ var we = "getSizeElement().clientWidth + \"px\"";
+ var he = "getSizeElement().clientHeight + \"px\"";
+ eDiv.style.setExpression("width", we);
+ eDiv.style.setExpression("height", he);
+
+ var eCursorDiv = $(this.cursorDiv);
+ eCursorDiv.style.setExpression("width", we);
+ eCursorDiv.style.setExpression("height", he);
+
+ var le = "-Position.cumulativeOffset(this.parentNode)[0] +
getSizeElement().scrollLeft + \"px\"";
+ var te = "-Position.cumulativeOffset(this.parentNode)[1] +
getSizeElement().scrollTop + \"px\"";
+
+ eDiv.style.setExpression("left", le);
+ eDiv.style.setExpression("top", te);
+
+ eCursorDiv.style.setExpression("left", le);
+ eCursorDiv.style.setExpression("top", te);
+
+
+ var leftExpr = "(this.mpLeft || 0) +
-Position.cumulativeOffset(this.parentNode)[0] + getSizeElement().scrollLeft +
\"px\"";
+ var topExpr = "(this.mpTop || 0) +
-Position.cumulativeOffset(this.parentNode)[1] + getSizeElement().scrollTop +
\"px\"";
+
+ eCdiv.style.setExpression("left", leftExpr);
+ eCdiv.style.setExpression("top", topExpr);
+
+
+ /* That's how we output debug info - DOM inspector rulez */
+ /*
+ document.body.setExpression("_clientLeft",
"getSizeElement().clientLeft");
+ document.body.setExpression("_clientTop",
"getSizeElement().clientTop");
+ document.body.setExpression("_scrollLeft",
"getSizeElement().scrollLeft");
+ document.body.setExpression("_scrollTop",
"getSizeElement().scrollTop");
+ */
+ /* */
+ }
+
+ element.style.visibility = "hidden";
+
+ Element.show(element);
+ this.correctShadowSizeEx(eContentDiv);
+
+ if (options.left) {
+ var _left;
+ if (options.left != "auto") {
+ _left = parseInt(options.left, 10);
+ } else {
+ var cw = getSizeElement().clientWidth;
+ if (RichFaces.navigatorType() == RichFaces.OPERA)
+ {
+ _left = (cw - eContentDiv.parentNode.getWidth()) / 2;
+ }
+ else {
+ var _width = Richfaces.getComputedStyleSize(eContentDiv.parentNode,
"width");
+ if (isNaN(_width))
+ _width = eContentDiv.parentNode.clientWidth;
+ _left = (cw - _width) / 2;
+ }
+
}
+
+ this.setLeft(_left);
}
-
- this.setTop(_top);
- }
-
- if (this.options.autosized) {
- this.observerSize =
- window.setInterval(this.correctShadowSize.bindAsEventListener(this), 500);
- }
-
- this.doResizeOrMove(ModalPanel.Sizer.Diff.EMPTY);
-
- for (var k = 0; k < this.borders.length; k++ ) {
- this.borders[k].doPosition();
- }
-
- if (this.header) {
- this.header.doPosition();
- }
-
- element.style.visibility = "";
-
- this.lastOnfocus();
-
- var event = {};
- event.parameters = opts || {};
- if (this.eventOnShow) this.eventOnShow(event);
-
- this.shown = true;
+
+ if (options.top) {
+ var _top;
+ if (options.top != "auto") {
+ _top = parseInt(options.top, 10);
+ } else {
+ var cw = getSizeElement().clientHeight;
+ if (RichFaces.navigatorType() == RichFaces.OPERA)
+ {
+ _top = (cw - eContentDiv.parentNode.getHeight()) / 2;
+ }
+ else {
+ var _height = Richfaces.getComputedStyleSize(eContentDiv.parentNode,
"height");
+ if (isNaN(_height))
+ _height = eContentDiv.parentNode.clientHeight;
+ _top = (cw - _height) / 2;
+ }
+ }
+
+ this.setTop(_top);
+ }
+
+ if (this.options.autosized) {
+ this.observerSize =
+ window.setInterval(this.correctShadowSize.bindAsEventListener(this), 500);
+ }
+
+ this.doResizeOrMove(ModalPanel.Sizer.Diff.EMPTY);
+
+ for (var k = 0; k < this.borders.length; k++ ) {
+ this.borders[k].doPosition();
+ }
+
+ if (this.header) {
+ this.header.doPosition();
+ }
+
+ element.style.visibility = "";
+
+ this.lastOnfocus();
+
+ var event = {};
+ event.parameters = opts || {};
+ this.shown = true;
+ }
},
startDrag: function(border) {
@@ -933,7 +917,46 @@
eIframe.style.width = w+"px";
eIframe.style.height = h+"px";
}
- }
+ },
+
+ invokeEvent: function(eventName, event, value, element) {
+
+ var eventFunction = this.options['on'+eventName];
+ var result;
+
+ if (eventFunction)
+ {
+ var eventObj;
+
+ if (event)
+ {
+ eventObj = event;
+ }
+ else if( document.createEventObject )
+ {
+ eventObj = document.createEventObject();
+ }
+ else if( document.createEvent )
+ {
+ eventObj = document.createEvent('Events');
+ eventObj.initEvent( eventName, true, false );
+ }
+
+ eventObj.rich = {component:this};
+ eventObj.rich.value = value;
+
+ try
+ {
+ result = eventFunction.call(element, eventObj);
+ }
+ catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName +
"]"); }
+
+ }
+
+ if (result!=false) result = true;
+
+ return result;
+ }
}
Richfaces.findModalPanel = function (id) {
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js 2007-11-21
19:03:03 UTC (rev 4156)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanelBorders.js 2007-11-21
19:04:08 UTC (rev 4157)
@@ -80,36 +80,43 @@
var id = this.id;
+ var diff = this.sizer.doDiff(dx, dy);
+ var doResize;
+
+ var element = $(this.modalPanel.cdiv);
if (id.indexOf('panelHeader') > 0) {
- var eventOnMove = this.modalPanel.eventOnMove;
- if(eventOnMove) eventOnMove(event);
+ doResize = this.modalPanel.invokeEvent("move",event,null,element);
} else{
- var eventOnResizing = this.modalPanel.eventOnResizing;
- if(eventOnResizing) eventOnResizing(event);
+ doResize = this.modalPanel.invokeEvent("resize",event,null,element);
}
-
- var diff = this.sizer.doDiff(dx, dy);
- var vetoes = this.modalPanel.doResizeOrMove(diff);
-
- if (!vetoes.x) {
- this.dragX = evtX;
- } else {
- if (!diff.deltaX) {
- this.dragX -= vetoes.vx || 0;
+
+ var vetoes;
+
+ if (doResize) {
+ vetoes = this.modalPanel.doResizeOrMove(diff);
+ }
+
+ if(vetoes){
+ if (!vetoes.x) {
+ this.dragX = evtX;
} else {
- this.dragX += vetoes.vx || 0;
+ if (!diff.deltaX) {
+ this.dragX -= vetoes.vx || 0;
+ } else {
+ this.dragX += vetoes.vx || 0;
+ }
}
- }
-
- if (!vetoes.y) {
- this.dragY = evtY;
- } else {
- if (!diff.deltaY) {
- this.dragY -= vetoes.vy || 0;
+
+ if (!vetoes.y) {
+ this.dragY = evtY;
} else {
- this.dragY += vetoes.vy || 0;
+ if (!diff.deltaY) {
+ this.dragY -= vetoes.vy || 0;
+ } else {
+ this.dragY += vetoes.vy || 0;
+ }
}
- }
+ }
}
},
@@ -128,10 +135,6 @@
this.onselectStartHandler = null;
var id = this.id;
- if (id.indexOf('panelHeader') < 0) {
- var eventOnResize = this.modalPanel.eventOnResize;
- if(eventOnResize) eventOnResize(event);
- }
},
doPosition: function() {
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-11-21
19:03:03 UTC (rev 4156)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-11-21
19:04:08 UTC (rev 4157)
@@ -131,14 +131,13 @@
top: "#{component.top}",
zindex: #{component.zindex},
-
- onshow: #{onshow},
+
onhide: #{onhide},
- onmove: #{onmove},
- onresize: #{onresize},
- onresizing: #{onresizing},
- onbeforeshow: #{onbeforeshow},
-
+
+ <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>,
+
keepVisualState: #{component.keepVisualState},
showWhenRendered: #{component.showWhenRendered},
selectBehavior: "#{component.tridentIVEngineSelectBehavior}",