Author: nbelaevski
Date: 2009-04-13 18:30:30 -0400 (Mon, 13 Apr 2009)
New Revision: 13552
Modified:
trunk/ui/colorPicker/src/main/config/component/colorPicker.xml
trunk/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java
trunk/ui/colorPicker/src/main/resources/org/richfaces/renderkit/html/scripts/ui.colorpicker.js
trunk/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx
Log:
https://jira.jboss.org/jira/browse/RF-6758
Modified: trunk/ui/colorPicker/src/main/config/component/colorPicker.xml
===================================================================
--- trunk/ui/colorPicker/src/main/config/component/colorPicker.xml 2009-04-13 19:37:54 UTC
(rev 13551)
+++ trunk/ui/colorPicker/src/main/config/component/colorPicker.xml 2009-04-13 22:30:30 UTC
(rev 13552)
@@ -73,6 +73,28 @@
<classname>boolean</classname>
<description>localValueSet</description>
</property>
+
+ <property>
+ <name>onchange</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onsubmit</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onbeforeshow</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onshow</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onhide</name>
+ <classname>java.lang.String</classname>
+ </property>
+
</component>
</components>
\ No newline at end of file
Modified:
trunk/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java
===================================================================
---
trunk/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java 2009-04-13
19:37:54 UTC (rev 13551)
+++
trunk/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java 2009-04-13
22:30:30 UTC (rev 13552)
@@ -2,9 +2,12 @@
import java.util.Set;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.UIColorPicker;
public abstract class ColorPickerRendererBase extends InputRendererBase {
@@ -18,4 +21,26 @@
ajaxRenderedAreas.add(clientId + "-colorPicker-script");
}
}
+
+ private static final String[] EVENT_ATTRIBUTES = {
+ "onchange", "onbeforeshow", "onshow", "onhide",
"onsubmit"
+ };
+
+ public String encodeEvents(FacesContext context, UIComponent component) {
+ StringBuilder builder = new StringBuilder();
+ for (String eventName: EVENT_ATTRIBUTES) {
+ JSFunctionDefinition handler = getUtils().getAsEventHandler(context, component,
eventName, null);
+ if (handler != null) {
+ builder.append(".bind(");
+
+ builder.append("'");
+ builder.append("colorPicker");
+ builder.append(eventName.substring(2));
+ builder.append("', ");
+ builder.append(ScriptUtils.toScript(handler));
+ builder.append(")");
+ }
+ }
+ return builder.toString();
+ }
}
\ No newline at end of file
Modified:
trunk/ui/colorPicker/src/main/resources/org/richfaces/renderkit/html/scripts/ui.colorpicker.js
===================================================================
---
trunk/ui/colorPicker/src/main/resources/org/richfaces/renderkit/html/scripts/ui.colorpicker.js 2009-04-13
19:37:54 UTC (rev 13551)
+++
trunk/ui/colorPicker/src/main/resources/org/richfaces/renderkit/html/scripts/ui.colorpicker.js 2009-04-13
22:30:30 UTC (rev 13552)
@@ -423,26 +423,26 @@
},
_show: function(e) {
- this._trigger("beforeShow", e, this._createEventArgument(this.color));
+ if (this._trigger("beforeshow", e, this._createEventArgument(this.color)) !=
false) {
+ var top = 0;
+ var left = 0;
- var top = 0;
- var left = 0;
-
- this.picker.css('visibility', 'hidden').css('display',
'block');
-
- var input = $(this.options.clientId.toString()+' input');
- var inputOffsets = input.offset();
- var elementRect = {left:inputOffsets.left, top: inputOffsets.top, width:
this.element.width(), height:input.outerHeight()};
- Richfaces.jQuery.position(elementRect, this.picker);
-
- this.picker.css('visibility', 'visible');
-
- if (this._trigger("show", e, this._createEventArgument(this.color)) != false)
{
+ this.picker.css('visibility', 'hidden').css('display',
'block');
+
+ var input = $(this.options.clientId.toString()+' input');
+ var inputOffsets = input.offset();
+ var elementRect = {left:inputOffsets.left, top: inputOffsets.top, width:
this.element.width(), height:input.outerHeight()};
+ Richfaces.jQuery.position(elementRect, this.picker);
+
+ this.picker.css('visibility', 'visible');
+
+ this._trigger("show", e, this._createEventArgument(this.color));
this.picker.show();
+
+ var self = this;
+ $(document).bind('mousedown.colorPicker', function(e) { return
self._hide.call(self, e); });
}
- var self = this;
- $(document).bind('mousedown.colorPicker', function(e) { return
self._hide.call(self, e); });
return false;
},
Modified: trunk/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx
===================================================================
--- trunk/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx 2009-04-13
19:37:54 UTC (rev 13551)
+++ trunk/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx 2009-04-13
22:30:30 UTC (rev 13552)
@@ -142,7 +142,7 @@
jQuery('\##{clientIdJquery} input').val('#' + ui.hex);
}
}
- });
+ })#{this:encodeEvents(context, component)};
</script>
</div>