Author: SergeySmirnov
Date: 2007-08-08 01:08:26 -0400 (Wed, 08 Aug 2007)
New Revision: 2134
Modified:
trunk/samples/effect-sample/src/main/webapp/effect.xhtml
trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java
trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js
trunk/ui/effect/src/main/templates/effect.jspx
Log:
added ability to attach to the non-jsf element.
Modified: trunk/samples/effect-sample/src/main/webapp/effect.xhtml
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/effect.xhtml 2007-08-08 01:14:09 UTC (rev
2133)
+++ trunk/samples/effect-sample/src/main/webapp/effect.xhtml 2007-08-08 05:08:26 UTC (rev
2134)
@@ -70,10 +70,21 @@
<e:effect name="Richfaces.showItP" />
+ <div id="dpanel"
style="width:100px;height:100px;background-color:lightgreen"> </div>
+
+ <e:effect event="click" for="dpanel" type="Fade"
params="duration:0.8, id:'my'" />
+
<div style="margin:10px;"><a
href='javascript:void(0)'
onclick='new Effect["Opacity"](
document.getElementById("mynewpanel"),{duration:0.8, from:1.0, to:0.2}
);'>Click for Demo!</a><br /></div>
+<!--
+ <script>
+ Event.observe(window,'click', mess, false );
+ function mess() {
+ alert('aaaaa');
+ }
+ </script>
+-->
-
</body>
</f:view>
</html>
Modified: trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java
===================================================================
--- trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java 2007-08-08
01:14:09 UTC (rev 2133)
+++ trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java 2007-08-08
05:08:26 UTC (rev 2134)
@@ -70,11 +70,11 @@
}
public abstract String getEvent();
+ public abstract void setEvent(String event);
public abstract String getFor();
public abstract void setFor(String value);
- public abstract void setEvent(String event);
public abstract String getType();
public abstract void setType(String value);
@@ -110,7 +110,7 @@
public void setParentProperties(UIComponent parent){
- if (getFor() == null || getFor() == "" ) {
+ if (getFor() == "" && getEvent() !="" ) {
parent.setValueBinding(getEvent(), new EventValueBinding(this));
}
}
Modified:
trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js
===================================================================
---
trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js 2007-08-08
01:14:09 UTC (rev 2133)
+++
trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js 2007-08-08
05:08:26 UTC (rev 2134)
@@ -4,3 +4,15 @@
Richfaces.processEffect = new
Function("cid","etype","aparam","param",
"var h=Object.extend(param.evalJSON(), aparam);"+
"new Effect[h.type||etype]($(h.id||cid),h);");
+
+
+/*
+Richfaces.addEffectObserve= new Function("oid",
"oevent","otype","oparams","useCapture",
+"var funcpart='{}';"+
+"var func='Richfaces.processEffect(oid,otype,
oparams,'+funcpart+')';"+
+"func='Function('+func+')';"+
+"alert(func);"+
+"Event.observe($(oid),oevent,"+func+",useCapture);");
+*/
+// Function("Richfaces.processEffect('#{forid}','#{type}',{},
'{#{params}}');"),false);
+
Modified: trunk/ui/effect/src/main/templates/effect.jspx
===================================================================
--- trunk/ui/effect/src/main/templates/effect.jspx 2007-08-08 01:14:09 UTC (rev 2133)
+++ trunk/ui/effect/src/main/templates/effect.jspx 2007-08-08 05:08:26 UTC (rev 2134)
@@ -20,31 +20,42 @@
<jsp:scriptlet>
- <![CDATA[
- String sid = (String)variables.getVariable("for");
- if (! "".equals(sid)) {
- UIComponent forcomp =
getUtils().findComponentFor(context, (UIComponent)component,sid);
- if (forcomp != null) {
- variables.setVariable("forid",forcomp.getClientId(context));
- } else {
- // if no corresponded component id, may be it is
non-jsf id.
- // So, returning the id as is
- variables.setVariable("forid",sid);
- }
- }
- String name =
(String)variables.getVariable("name");
- variables.setVariable("needsFunction",new
Boolean(! "".equals(name)));
- ]]>
-
+<![CDATA[
+ String sid = (String)variables.getVariable("for");
+ String event = (String)variables.getVariable("event");
+
+ if (! "".equals(sid)) {
+ UIComponent forcomp = getUtils().findComponentFor(context,
(UIComponent)component,sid);
+ if (forcomp != null) {
+ variables.setVariable("forid",forcomp.getClientId(context));
+ } else {
+ // if no corresponded component id, may be it is non-jsf id.
+ // So, returning the id as is
+ variables.setVariable("forid",sid);
+ }
+ }
+ String name = (String)variables.getVariable("name");
+ Boolean needsFunction = new Boolean(! "".equals(name) &&
"".equals(event));
+ variables.setVariable("needsFunction",needsFunction);
+
+ Boolean needsObserver = new Boolean(! "".equals(event) && !
"".equals(sid) );
+ variables.setVariable("needsObserver",needsObserver);
+]]>
</jsp:scriptlet>
<c:if test="#{needsFunction}">
-
-<script type="text/javascript"
- x:passThruWithExclusions="name,type,for"
- >
+<script type="text/javascript"
x:passThruWithExclusions="name,type,for">
//<![CDATA[
#{name} = new
Function("Richfaces.processEffect('#{forid}','#{type}',arguments[0]||{},
'{#{params}}');");
//]]>
</script>
</c:if>
+<c:if test="#{needsObserver}">
+<script type="text/javascript"
x:passThruWithExclusions="name,type,for">
+ //<![CDATA[
+var pm ="{"+"#{params}"+"}";
+Event.observe($('#{forid}'),'#{event}',
Function("Richfaces.processEffect('#{forid}','#{type}',{},pm
);"),false);
+//]]>
+</script>
+</c:if>
+
</f:root>
\ No newline at end of file