Author: konstantin.mishin
Date: 2010-09-16 14:06:09 -0400 (Thu, 16 Sep 2010)
New Revision: 19224
Added:
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.ecss
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
branches/RF-9151/ui/input/ui/src/main/templates/inputnumberspinner.template.xml
Modified:
branches/RF-9151/ui/input/ui/src/main/config/faces-config.xml
Log:
RF-9193
Modified: branches/RF-9151/ui/input/ui/src/main/config/faces-config.xml
===================================================================
--- branches/RF-9151/ui/input/ui/src/main/config/faces-config.xml 2010-09-16 14:45:37 UTC
(rev 19223)
+++ branches/RF-9151/ui/input/ui/src/main/config/faces-config.xml 2010-09-16 18:06:09 UTC
(rev 19224)
@@ -237,6 +237,104 @@
</cdk:tag>
</component-extension>
</component>
+ <component>
+ <component-type>org.richfaces.InputNumberSpinner</component-type>
+ <component-class>org.richfaces.component.html.HtmlInputNumberSpinner</component-class>
+ <property>
+ <property-name>accesskey</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>disabled</property-name>
+ <property-class>boolean</property-class>
+ <default-value>false</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>enableManualInput</property-name>
+ <property-class>boolean</property-class>
+ <default-value>true</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>inputClass</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>inputSize</property-name>
+ <property-class>int</property-class>
+ <default-value>10</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>maxValue</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>"100"</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>minValue</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>"0"</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>step</property-name>
+ <property-class>java.lang.String</property-class>
+ <default-value>"1"</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>style</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>styleClass</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
+ <property-name>tabindex</property-name>
+ <property-class>int</property-class>
+ <default-value>Integer.MIN_VALUE</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <component-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:base-class>javax.faces.component.UIInput</cdk:base-class>
+ <cdk:component-family>javax.faces.Input</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.InputNumberSpinnerRenderer</cdk:renderer-type>
+ <cdk:tag>
+ <cdk:tag-name>inputNumberSpinner</cdk:tag-name>
+ <cdk:tag-type>Facelets</cdk:tag-type>
+ </cdk:tag>
+ </component-extension>
+ </component>
<faces-config-extension>
<cdk:taglib>
<cdk:shortName>input</cdk:shortName>
Added:
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.ecss
===================================================================
---
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.ecss
(rev 0)
+++
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.ecss 2010-09-16
18:06:09 UTC (rev 19224)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+.rf-insp {
+ border: 1px solid #A6A6A6/*panelBorderColor*/;
+ display: inline-block;
+ background: url("#{resource['bg_field.png']}") top left
repeat-x;/*gradient - from additionalBackgroundColor to controlBackgroundColor,
background-color - controlBackgroundColor*/;
+ white-space: nowrap;
+ font-size: 1px;
+}
+
+input[type="text"].rf-insp-inp {
+ vertical-align: top;
+ color: #000000;/*generalTextColor*/
+ border: 0px;
+ background: none;
+ margin: 0px;
+ padding: 0px;
+}
+
+.rf-insp-btna {
+ vertical-align: top;
+ background: url("#{resource['bg_btn.png']}") top left repeat-x
#C0D1E7/*gradient - from headerGradientColor to headerBackgroundColor, background-color -
headerBackgroundColor*/;
+ border-left: 1px solid #A6A6A6/*panelBorderColor*/;
+ width: 16px;
+ height: 15px;
+ display: inline-block;
+}
+
+.rf-insp-dbtn {
+ display: block;
+ height: 7px;
+ background-image: url("#{resource['button_down.gif']}");
+ width: 15px;
+ padding-top: 1px;
+}
+
+.rf-insp-ibtn {
+ display: block;
+ height: 7px;
+ background-image: url("#{resource['button_up.gif']}");
+ width: 15px;
+ padding-top: 1px;
+}
\ No newline at end of file
Property changes on:
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.ecss
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
===================================================================
---
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
(rev 0)
+++
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-09-16
18:06:09 UTC (rev 19224)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+(function(richfaces, jQuery) {
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.InputNumberSpinner = richfaces.BaseComponent.extendClass({
+
+ name: "InputNumberSpinner",
+
+ delay: 200,
+ maxValue: 100,
+ minValue: 0,
+ step: 1,
+
+ init: function (id, options) {
+ jQuery.extend(this, options);
+ this.id = id;
+ this.element = jQuery(this.attachToDom());
+ this.input = this.element.children(".rf-insp-inp");
+
+ this.__inputHandler();
+
+ if (!this.input.attr("disabled")) {
+ var buttonsArea = this.element.children(".rf-insp-btna");
+ this.decreaseButton = buttonsArea.children(".rf-insp-dbtn");
+ this.increaseButton = buttonsArea.children(".rf-insp-ibtn");
+
+ var proxy = jQuery.proxy(this.__inputHandler, this)
+ this.input.change(proxy);
+ this.input.submit(proxy);
+ this.input.submit(proxy);
+ this.input.keydown(jQuery.proxy(this.__keydownHandler, this));
+ this.decreaseButton.mousedown(jQuery.proxy(this.__decreaseHandler, this));
+ this.increaseButton.mousedown(jQuery.proxy(this.__increaseHandler, this));
+ }
+ },
+
+ decrease: function (event) {
+ this.setValue(this.value - this.step);
+ },
+
+ increase: function (event) {
+ this.setValue(this.value + this.step);
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (value) {
+ if (!this.input.attr("disabled")) {
+ this.__setValue(value);
+ }
+ },
+
+ __setValue: function (value) {
+ if (!isNaN(value)) {
+ value = Math.round(value / this.step) * this.step; //TODO Add normal support of
float values. E.g. '0.3' should be instead of '0.30000000000000004'.
+ if (value > this.maxValue) {
+ value = this.maxValue;
+ } else if (value < this.minValue) {
+ value = this.minValue;
+ }
+ if (value != this.value) {
+ this.input.val(value);
+ this.value = value;
+ }
+ }
+ },
+
+ __inputHandler: function () {
+ var value = Number(this.input.val());
+ if (isNaN(value)) {
+ this.input.val(this.value);
+ } else {
+ this.__setValue(value);
+ }
+ },
+
+ __keydownHandler: function (event) {
+ if (event.keyCode == 40) { //DOWN
+ this.decrease();
+ event.preventDefault();
+ } else if (event.keyCode == 38) { //UP
+ this.increase();
+ event.preventDefault();
+ }
+ },
+
+ __decreaseHandler: function (event) {
+ var component = this;
+ component.decrease();
+ this.intervalId = window.setInterval(function() {
+ component.decrease();
+ }, this.delay);
+ jQuery(document).one("mouseup", true, jQuery.proxy(this.__clearInterval,
this));
+ this.decreaseButton.css("backgroundPosition", "60% 55%");
+ event.preventDefault();
+ },
+
+ __increaseHandler: function (event) {
+ var component = this;
+ component.increase();
+ this.intervalId = window.setInterval(function() {
+ component.increase();
+ }, this.delay);
+ jQuery(document).one("mouseup",jQuery.proxy(this.__clearInterval,
this));
+ this.increaseButton.css("backgroundPosition", "60% 55%");
+ event.preventDefault();
+ },
+
+ __clearInterval: function (event) {
+ window.clearInterval(this.intervalId);
+ if (event.data) { // decreaseButton
+ this.decreaseButton.css("backgroundPosition", "");
+ } else {
+ this.increaseButton.css("backgroundPosition", "");
+ }
+ }
+ });
+}(window.RichFaces, jQuery));
\ No newline at end of file
Property changes on:
branches/RF-9151/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/RF-9151/ui/input/ui/src/main/templates/inputnumberspinner.template.xml
===================================================================
--- branches/RF-9151/ui/input/ui/src/main/templates/inputnumberspinner.template.xml
(rev 0)
+++
branches/RF-9151/ui/input/ui/src/main/templates/inputnumberspinner.template.xml 2010-09-16
18:06:09 UTC (rev 19224)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+<cdk:root
xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+
xmlns:xi="http://www.w3.org/2001/XInclude">
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.InputNumberSpinnerRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.InputRendererBase</cdk:superclass>
+ <cdk:component-family>javax.faces.Input</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.InputNumberSpinnerRenderer</cdk:renderer-type>
+ <cdk:resource-dependency library="org.richfaces"
name="inputNumberSpinner.ecss" />
+ <cdk:resource-dependency library="org.richfaces"
name="base-component.reslib" />
+ <cdk:resource-dependency name="jquery.position.js" />
+ <cdk:resource-dependency library="org.richfaces"
name="inputNumberSpinner.js" />
+ </cc:interface>
+ <cc:implementation>
+ <span id="#{clientId}" class="rf-insp
#{component.attributes['styleClass']}" cdk:passThroughWithExclusions="id
class" >
+ <input name="#{clientId}" type="text"
+ class="rf-insp-inp #{component.attributes['inputClass']}"
value="#{getInputValue(facesContext, component)}"
+ cdk:passThrough="accesskey disabled maxlength size:inputSize tabindex"
readonly="#{!component.attributes['enableManualInput']}" />
+ <span class="rf-insp-btna">
+ <span class="rf-insp-ibtn" />
+ <span class="rf-insp-dbtn" />
+ </span>
+ <script type="text/javascript">new
RichFaces.ui.InputNumberSpinner('#{clientId}', {
+ maxValue: #{component.attributes['maxValue']},
+ minValue: #{component.attributes['minValue']},
+ step: #{component.attributes['step']}
+ });</script>
+ </span>
+ </cc:implementation>
+</cdk:root>