Author: abelevich
Date: 2010-12-10 11:49:06 -0500 (Fri, 10 Dec 2010)
New Revision: 20504
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
trunk/ui/input/ui/src/main/templates/select.template.xml
Log:
RF-9868, RF-9869, RF-9872
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-12-10
16:49:06 UTC (rev 20504)
@@ -65,7 +65,7 @@
public abstract String getInputWidth();
@Attribute
- public abstract String getTabIndex();
+ public abstract int getTabindex();
@Attribute
public abstract String getReadyStateClass();
@@ -85,18 +85,12 @@
@Attribute
public abstract String getNoneClass();
- @Attribute(events=@EventName("blur"))
- public abstract String getOnblur();
-
@Attribute(events=@EventName("click"))
public abstract String getOnclick();
@Attribute(events=@EventName("ondblclick"))
public abstract String getOndblclick();
- @Attribute(events=@EventName("focus"))
- public abstract String getOnfocus();
-
@Attribute(events=@EventName("keydown"))
public abstract String getOnkeydown();
@@ -151,17 +145,18 @@
@Attribute(events=@EventName("inputkeyup"))
public abstract String getOninputkeyup();
- @Attribute(events=@EventName("inputfocus"))
- public abstract String getOninputfocus();
-
- @Attribute(events=@EventName("inputblur"))
- public abstract String getOninputblur();
-
@Attribute(events=@EventName("inputselect"))
public abstract String getOninputselect();
- @Attribute(events=@EventName("inputchange"))
- public abstract String getOninputchange();
+ @Attribute(events=@EventName("change"))
+ public abstract String getOnchange();
+ @Attribute(events=@EventName("focus"))
+ public abstract String getOnfocus();
+
+ @Attribute(events=@EventName("blur"))
+ public abstract String getOnblur();
+
+
//TODO: what is default event?, add onViewActivated, onEditActivated events support
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-12-10
16:49:06 UTC (rev 20504)
@@ -62,6 +62,9 @@
@Attribute(defaultValue="false")
public abstract boolean isShowControls();
+ @Attribute
+ public abstract int getTabindex();
+
@Override
@Attribute
public abstract String getItemClass();
@@ -107,16 +110,6 @@
@Attribute(events=@EventName("inputkeyup"))
public abstract String getOninputkeyup();
- @Attribute(events=@EventName("inputfocus"))
- public abstract String getOninputfocus();
-
- @Attribute(events=@EventName("inputblur"))
- public abstract String getOninputblur();
-
@Attribute(events=@EventName("inputselect"))
public abstract String getOninputselect();
-
- @Attribute(events=@EventName("inputchange"))
- public abstract String getOnchange();
-
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java 2010-12-10
16:49:06 UTC (rev 20504)
@@ -58,6 +58,9 @@
@Attribute(events=@EventName("click"))
public abstract String getOnclick();
+ @Attribute(events=@EventName("change"))
+ public abstract String getOnchange();
+
@Attribute(events=@EventName("dblclick"))
public abstract String getOndblclick();
@@ -120,8 +123,5 @@
@Attribute(events=@EventName("selectitem"))
public abstract String getOnselectitem();
-
- @Attribute(events=@EventName("change"))
- public abstract String getOnchange();
-
+
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-12-10
16:49:06 UTC (rev 20504)
@@ -115,15 +115,6 @@
new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
.setEventNames("inputkeyup")
.setComponentAttributeName("oninputkeyup"),
- new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE)
- .setEventNames("inputblur")
- .setComponentAttributeName("oninputblur"),
- new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE)
- .setEventNames("inputfocus")
- .setComponentAttributeName("oninputfocus"),
- new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE)
-
.setEventNames("inputchange").setComponentAttributeName(
- "oninputchange"),
new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE)
.setEventNames("inputselect").setComponentAttributeName(
"oninputselect")));
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-12-10
16:49:06 UTC (rev 20504)
@@ -10,6 +10,9 @@
this.changedCss = mergedOptions.changedCss;
this.defaultLabel = mergedOptions.defaultLabel;
this.state = mergedOptions.state;
+
+ this.options = mergedOptions;
+
this.element = $(document.getElementById(id));
this.editContainer = $(document.getElementById(id+"Edit"));
this.element.bind(this.editEvent, $.proxy(this.__editHandler, this));
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-12-10
16:49:06 UTC (rev 20504)
@@ -66,7 +66,7 @@
},
__blurHandler: function(e) {
- this.onblur();
+ this.onblur(e);
},
__changeHandler: function(e) {
@@ -85,14 +85,21 @@
},
__saveBtnHandler: function(e) {
+ this.cancelButton = false;
this.save();
- return false;
+ this.onblur(e);
},
__cancelBtnHandler: function(e) {
+ this.cancelButton = true;
this.cancel();
- return false;
+ this.onblur(e);
},
+
+ __editHandler: function(e){
+ $super.__editHandler.call(this,e);
+ this.onfocus(e);
+ },
getLabel: function() {
return this.label.text();
@@ -114,15 +121,45 @@
this.focusElement.focus();
},
- onblur: function() {
- if(!this.isValueSaved() && this.__isSaveOnBlur()) {
- this.save();
- } else {
- this.__hide();
- }
- this.getInput().bind("focus", $.proxy(this.__editHandler,
this));
+ onfocus: function(e) {
+ if(!this.__isFocused()) {
+ this.__setFocused(true);
+ this.focusValue = this.getValue();
+ this.invokeEvent.call(this, "focus", document.getElementById(this.id +
'Input'), e);
+ }
+ },
+
+ onblur: function(e) {
+ if(this.__isFocused()) {
+ this.__setFocused(false);
+ this.invokeEvent.call(this, "blur", document.getElementById(this.id +
'Input'), e);
+
+ if(!this.isValueSaved() && this.__isSaveOnBlur()) {
+ this.save();
+ } else {
+ this.__hide();
+ }
+
+ if(!this.cancelButton) {
+ if(this.__isValueChanged()) {
+ this.invokeEvent.call(this, "change",
document.getElementById(this.id + 'Input'), e);
+ }
+ }
+ this.getInput().bind("focus", $.proxy(this.__editHandler,
this));
+ }
+ },
+
+ __isValueChanged: function() {
+ return (this.focusValue != this.getValue());
+ },
+
+ __setFocused: function(focused) {
+ this.focused = focused;
+ },
+
+ __isFocused: function() {
+ return this.focused;
}
-
}
})());
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-12-10
16:49:06 UTC (rev 20504)
@@ -85,10 +85,18 @@
}
},
- onblur: function() {
+ onblur: function(e) {
this.hidePopup();
$super.onblur.call(this);
},
+
+ onfocus: function(e) {
+ if(!this.__isFocused()) {
+ this.__setFocused(true);
+ this.focusValue = this.selValueInput.val();
+ this.invokeEvent.call(this, "focus", document.getElementById(this.id +
'Input'), e);
+ }
+ },
processItem: function(item) {
var label = this.getItemLabel(item);
@@ -100,6 +108,8 @@
if(this.saveOnSelect) {
this.save();
}
+
+ this.invokeEvent.call(this,"selectitem",
document.getElementById(this.id + 'Input'));
},
getItemValue: function(item) {
@@ -133,6 +143,10 @@
return label;
},
+ __isValueChanged: function() {
+ return (this.focusValue != this.selValueInput.val());
+ },
+
__keydownHandler: function(e) {
var code;
@@ -170,10 +184,10 @@
},
__blurHandler: function(e) {
- if(!this.isMouseDown) {
+ if(this.saveOnSelect || !this.isMouseDown) {
if(this.isEditState()) {
this.timeoutId = window.setTimeout($.proxy(function(){
- this.onblur();
+ this.onblur(e);
}, this), 200);
}
} else {
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-12-10
16:49:06 UTC (rev 20504)
@@ -23,7 +23,7 @@
var defaultOptions = {
attachToBody: true,
positionType: "DROPDOWN",
- positionOffset: [0,20]
+ positionOffset: [0,0]
};
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-12-10
16:41:15 UTC (rev 20503)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-12-10
16:49:06 UTC (rev 20504)
@@ -367,7 +367,7 @@
this.hidePopup();
this.__setInputFocus();
- this.invokeEvent.call(this,"selectitem",
document.getElementById(this.id + 'Input'), e);
+ this.invokeEvent.call(this,"selectitem",
document.getElementById(this.id + 'Input'));
},
onblur: function(e) {
Modified: trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-12-10 16:41:15 UTC
(rev 20503)
+++ trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-12-10 16:49:06 UTC
(rev 20504)
@@ -51,7 +51,7 @@
<input id="#{clientId}Focus" type="image"
style="position: absolute; top: 0px; left: 0px; outline-style: none;"
class="rf-ii-none"/>
<span id="#{clientId}Edit" class="#{getEditStyleClass(component,
inplaceState)}">
<input id="#{clientId}Input" autocomplete="off"
name="#{clientId}"
- type="text" value="#{getInputValue(facesContext,
component)}" class="rf-ii-fld" style="width:
#{component.attributes['inputWidth']};"
cdk:passThrough="tabIndex">
+ type="text" value="#{getInputValue(facesContext,
component)}" class="rf-ii-fld" style="width:
#{component.attributes['inputWidth']};"
cdk:passThrough="tabindex">
<cdk:call expression="renderInputHandlers(facesContext,
component);"/>
</input>
<c:if test="#{component.attributes['showControls']}">
@@ -87,6 +87,7 @@
<cdk:scriptOption name="changedCss"
value="#{concatClasses('rf-ii-c-s',
component.attributes['changedClass'])}"/>
<cdk:scriptOption name="editCss"
value="#{concatClasses('rf-ii-e-s',
component.attributes['editClass'])}"/>
<cdk:scriptOption attributes="editEvent state defaultLabel saveOnBlur
showControls" />
+ <cdk:scriptOption attributes="onbegin oncomplete onerror
onbeforedomupdate onselectitem onchange onblur onfocus"
wrapper="eventHandler"/>
</cdk:scriptObject>
new RichFaces.ui.InplaceInput("#{clientId}", #{toScriptArgs(options)});
</script>
Modified: trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-12-10 16:41:15
UTC (rev 20503)
+++ trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-12-10 16:49:06
UTC (rev 20504)
@@ -51,7 +51,7 @@
<input id="#{clientId}Input" name="#{clientId}Input"
autocomplete="off"
type="text" value="#{getSelectInputLabel(facesContext,
component)}"
class="rf-is-fld" style="width:
#{component.attributes['inputWidth']};" readonly="readonly"
- cdk:passThrough="tabIndex">
+ cdk:passThrough="tabindex">
<cdk:call expression="renderInputHandlers(facesContext, component);"
/>
</input>
<c:if test="#{component.attributes['showControls']}">
@@ -104,6 +104,7 @@
<cdk:scriptOption name="changedCss"
value="#{concatClasses('rf-is-c-s',
component.attributes['changedClass'])}"/>
<cdk:scriptOption name="editCss"
value="#{concatClasses('rf-is-e-s',
component.attributes['editClass'])}"/>
<cdk:scriptOption attributes="editEvent state defaultLabel saveOnBlur
showControls openOnEdit saveOnSelect" />
+ <cdk:scriptOption attributes="onbegin oncomplete onerror
onbeforedomupdate onselectitem onchange onblur onfocus"
wrapper="eventHandler"/>
</cdk:scriptObject>
new RichFaces.ui.InplaceSelect("#{clientId}", #{toScriptArgs(options)});
</script>
Modified: trunk/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/select.template.xml 2010-12-10 16:41:15 UTC (rev
20503)
+++ trunk/ui/input/ui/src/main/templates/select.template.xml 2010-12-10 16:49:06 UTC (rev
20504)
@@ -23,7 +23,7 @@
<div style="position : relative; overflow : hidden; text-align :
left; padding-right : 18px;">
<input id="#{clientId}selValue" name="#{clientId}"
type="hidden" value="#{getInputValue(facesContext, component)}"/>
<div id="#{clientId}Field" class="rf-sel-fld">
- <input cdk:passThroughWithExclusions="class autocomplete id value
disabled name type readonly onchange onblur"
+ <input cdk:passThroughWithExclusions="class autocomplete id value
disabled name type readonly onchange onblur onfocus"
id="#{clientId}Input"
value="#{getSelectLabel(facesContext, component)}"
disabled="#{disabled}"
@@ -70,7 +70,7 @@
<cdk:scriptOption name="itemCss"
value="#{concatClasses('rf-sel-opt',
component.attributes['itemClass'])}" />
<cdk:scriptOption name="selectItemCss"
value="#{concatClasses('rf-sel-sel',
component.attributes['selectItemClass'])}" />
<cdk:scriptOption name="listCss"
value="#{concatClasses('rf-sel-lst-cord',
component.attributes['listClass'])}" />
- <cdk:scriptOption attributes="onbegin oncomplete onerror
onbeforedomupdate onchange onblur onselectitem"
wrapper="eventHandler"/>
+ <cdk:scriptOption attributes="onbegin oncomplete onerror
onbeforedomupdate onchange onblur onselectitem onfocus"
wrapper="eventHandler"/>
<cdk:scriptOption attributes="showControl defaultLabel enableManualInput
selectFirst" />
</cdk:scriptObject>
new RichFaces.ui.Select("#{clientId}", #{toScriptArgs(options)});