Author: abelevich
Date: 2010-10-05 12:03:16 -0400 (Tue, 05 Oct 2010)
New Revision: 19457
Modified:
branches/RF-8992/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
Log:
support for the saveOnBlur attributes (
https://jira.jboss.org/browse/RF-9347) ,
'Tab' support for the inplaceSelect
Modified:
branches/RF-8992/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
===================================================================
---
branches/RF-8992/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-10-05
16:03:16 UTC (rev 19457)
@@ -9,6 +9,8 @@
public boolean isShowControls();
+ public boolean isSaveOnBlur();
+
public InplaceState getState();
}
Modified:
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-10-05
16:03:16 UTC (rev 19457)
@@ -49,6 +49,9 @@
@Attribute
public abstract String getDefaultLabel();
+ @Attribute(defaultValue="true")
+ public abstract boolean isSaveOnBlur();
+
@Attribute(defaultValue="InplaceState.ready")
public abstract InplaceState getState();
Modified:
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-05
16:03:16 UTC (rev 19457)
@@ -38,6 +38,9 @@
@Attribute
public abstract String getDefaultLabel();
+ @Attribute(defaultValue="true")
+ public abstract boolean isSaveOnBlur();
+
@Attribute(defaultValue="false")
public abstract boolean isShowControls();
Modified:
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-10-05
16:03:16 UTC (rev 19457)
@@ -77,6 +77,8 @@
public static final String OPTIONS_INITIAL_VALUE = "initialValue";
+ public static final String OPTIONS_SAVE_ON_BLUR = "saveOnBlur";
+
private static final Map<String, ComponentAttribute>
INPLACEINPUT_HANDLER_ATTRIBUTES = Collections
.unmodifiableMap(ComponentAttribute.createMap(
@@ -189,6 +191,7 @@
options.put(OPTIONS_LABEL, clientId + ":label");
options.put(OPTIONS_FOCUS, clientId + ":focus");
options.put(OPTIONS_DEFAULT_LABEL, inplaceComponent.getDefaultLabel());
+ options.put(OPTIONS_SAVE_ON_BLUR, inplaceComponent.isSaveOnBlur());
boolean showControls = inplaceComponent.isShowControls();
Modified:
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-05
16:03:16 UTC (rev 19457)
@@ -34,11 +34,12 @@
this.changedCss = options.changedCss;
this.showControls = options.showControls;
this.defaultLabel = options.defaultLabel;
-
+
this.element = $(document.getElementById(id));
this.editContainer = $(document.getElementById(options.editContainer));
this.element.bind(this.editEvent, $.proxy(this.__editHandler, this));
+
if(this.showControls) {
this.okbtn = $(document.getElementById(options.okbtn));
this.cancelbtn = $(document.getElementById(options.cancelbtn));
@@ -93,13 +94,17 @@
isSaved = true;
+ this.__applyChangedStyles();
+ this.__hide();
+ },
+
+ __applyChangedStyles: function() {
if(this.isValueChanged()) {
this.element.addClass(this.changedCss);
} else {
this.element.removeClass(this.changedCss);
}
- this.__hide();
- },
+ },
cancel: function(){
var text = "";
@@ -115,6 +120,10 @@
return isSaved;
},
+ __saveValue: function(value) {
+
+ },
+
__show: function() {
this.scrollElements = rf.Event.bindScrollEventHandlers(this.id, this.__scrollHandler,
this);
this.onshow();
Modified:
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-05
16:03:16 UTC (rev 19457)
@@ -11,6 +11,7 @@
var label = this.label.text();
var inputLabel = this.input.val();
this.initialValue = (label == inputLabel) ? label : "";
+ this.saveOnBlur = options.saveOnBlur;
this.input.bind("focus", $.proxy(this.__editHandler, this));
this.input.bind("change", $.proxy(this.__changeHandler, this));
@@ -49,8 +50,10 @@
},
__blurHandler: function(e) {
- if(!this.isValueSaved()) {
+ if(!this.isValueSaved() && this.__isSaveOnBlur()) {
this.save();
+ } else {
+ this.__hide();
}
return false;
},
@@ -60,6 +63,16 @@
this.save();
}
},
+
+ __isSaveOnBlur: function() {
+ return this.saveOnBlur;
+ },
+
+ __setInputFocus: function() {
+ this.input.unbind("focus", this.__editHandler);
+ this.input.focus();
+ this.input.bind("focus", $.proxy(this.__editHandler, this));
+ },
getValue: function() {
return this.input.val();
@@ -81,10 +94,8 @@
return (this.getValue() != this.initialValue);
},
- onshow: function(){
- this.input.unbind("focus", this.__editHandler);
- this.input.focus();
- this.input.bind("focus", $.proxy(this.__editHandler, this));
+ onshow: function(){
+ this.__setInputFocus();
},
onhide: function() {
Modified:
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-10-05
16:03:16 UTC (rev 19457)
@@ -12,7 +12,7 @@
}
.rf-is-none {
- display: none !important;
+ clip:rect(0px, 0px, 1px, 1px);
}
.insel_font {
Modified:
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-05
16:03:16 UTC (rev 19457)
@@ -36,6 +36,8 @@
if(!openPopup) {
openPopup = true;
}
+
+ $super.onshow.call(this);
},
onhide: function() {
@@ -51,7 +53,9 @@
var label = this.getItemLabel(key);
//inplace label
this.setValue(label);
- this.save();
+ this.select.hide();
+
+ this.__setInputFocus();
},
getItemValue: function(key) {
@@ -74,10 +78,19 @@
return item.label;
}
}
- },
+ },
- __blurHandler: function(e) {
- return false;
+ __blurHandler: function(e) {
+ var target = $(e.originalEvent.explicitOriginalTarget);
+ if(!this.__isPopupList(target)) {
+ $super.__blurHandler.call(this,e);
+ }
+ return false;
+ },
+
+ __isPopupList: function(target) {
+ var parentId =
target.parents(".insel_list_cord").attr("id");
+ return (parentId && (parentId == this.select.__getId()));
}
}
Modified:
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
---
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-05
15:59:16 UTC (rev 19456)
+++
branches/RF-8992/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-05
16:03:16 UTC (rev 19457)
@@ -9,11 +9,11 @@
};
rf.ui.Select = function(id, listener, options) {
+ this.id = id;
this.select = $(document.getElementById(id));
this.itemsCord = $(document.getElementById(options.itemsCord));
this.selectItemCss = options.selectItemCss;
this.itemCss = options.itemCss;
- this.noneCss = options.noneCss;
this.selectListener = listener;
this.select.bind("blur", $.proxy(this.__blurHandler, this));
@@ -41,11 +41,11 @@
name : "select",
show: function() {
- this.select.removeClass(this.noneCss);
+ this.select.css("display", "");
},
hide: function() {
- this.select.addClass(this.noneCss);
+ this.select.css("display", "none");
},
processItem: function(event, element) {
@@ -80,6 +80,10 @@
}
return false;
},
+
+ __getId: function() {
+ return this.id;
+ }
}
})());