Author: abelevich
Date: 2009-01-29 11:06:47 -0500 (Thu, 29 Jan 2009)
New Revision: 12493
Modified:
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
Log:
RF-5418, RF-5284
Modified:
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
===================================================================
---
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js 2009-01-29
16:06:21 UTC (rev 12492)
+++
trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js 2009-01-29
16:06:47 UTC (rev 12493)
@@ -22,10 +22,9 @@
initHandlers : function($super) {
$super();
this.tempValueKeeper.observe("click",
function(e){this.tempKeeperClickHandler(e);}.bindAsEventListener(this));
- //this.button.observe("click",
function(e){this.tempKeeperClickHandler(e);}.bindAsEventListener(this));
+ this.button.observe("click",
function(e){this.tempKeeperClickHandler(e);}.bindAsEventListener(this));
+ this.button.observe("blur",
function(e){this.tmpValueBlurHandler(e);}.bindAsEventListener(this));
- this.button.observe("mousedown",
function(e){this.buttonClickHandler(e);}.bindAsEventListener(this));
-
this.comboList.listParent.observe("mousedown",
function(e){this.listMousedownHandler(e);}.bindAsEventListener(this));
this.comboList.listParent.observe("mousemove",
function(e){this.listMouseMoveHandler(e)}.bindAsEventListener(this));
this.comboList.listParent.observe("click",
function(e){this.listClickHandler(e);}.bindAsEventListener(this));
@@ -78,12 +77,6 @@
if (this.comboList.activeItem) {
this.comboList.doNormalItem(this.comboList.activeItem);
}
- /*if (!this.attributes.closeOnSelect && !this.attributes.showControls
&& this.comboList.isListOpened) {
- this.comboList.hideWithDelay();
- this.comboList.isList = false;
- this.tempValueKeeper.focus();
- return;
- }*/
this.comboList.hideWithDelay();
}
@@ -93,7 +86,7 @@
this.clickOnScroll = false;
this.tempValueKeeper.focus();
this.comboList.isList = false;
- return;
+ return;
}
if (!this.attributes.showControls) {
@@ -105,7 +98,6 @@
},
listClickHandler : function(event) {
- //this.tempValueKeeper.focus();
this.comboList.hideWithDelay();
},
@@ -180,11 +172,7 @@
this.comboList.hide();
if (((this.attributes.closeOnSelect && !this.attributes.showControls)
&& this.comboList.isList)
|| (this.clickOnBar || !this.comboList.isList)) {
- //bug :
http://jira.jboss.com/jira/browse/RF-2810,
- //will be corrected in a future version (
http://jira.jboss.com/jira/browse/RF-2814)
var unescapedValue = this.currentItemValue;
- // var params = {itemValue: unescapedValue,itemLabel: this.tempValueKeeper.value}
-// var unescapeText = this.tempValueKeeper.value.unescapeHTML();
this.setValue(unescapedValue);
}
},
@@ -201,6 +189,7 @@
setValue : function(e, param) {
var item = {};
item.itemValue = this.getParameters(e,param,"value");
+
if(this.showValueInView) {
item.itemLabel = item.itemValue;
} else {
@@ -214,32 +203,41 @@
var value = this.valueKeeper.value;
if (Richfaces.invokeEvent(this.events.onviewactivation, this.inplaceInput,
"rich:onviewactivation", {oldValue : this.valueKeeper.value, value :
item.itemValue})) {
- this.endEditableState();
- if (item.itemValue == "") {
- this.setDefaultText();
- this.valueKeeper.value = "";
- //this.startViewState();
- } else {
- if (item.itemLabel == "") {
- this.setDefaultText();
- } else {
- this.currentText = item.itemLabel;
+ var proceed = true;
+
+ if(item.itemLabel && value != item.itemValue) {
+ proceed = Richfaces.invokeEvent(this.events.onchange, this.inplaceSelect,
"onchange", item.itemValue);
+ }
+
+ if(proceed) {
+ this.endEditableState();
+
+ if(item.itemValue && item.itemValue.blank()) {
+ item.itemValue = "";
+ }
+
+ if(item.itemLabel && item.itemLabel.blank()) {
+ item.itemLabel = this.attributes.defaultLabel;
}
+
this.valueKeeper.value = item.itemValue;
- }
- if (item.itemValue != this.value) {
- this.startChangedState();
- if (item.itemLabel && value != item.itemValue) {
- this.tempValueKeeper.value = item.itemLabel;
- Richfaces.invokeEvent(this.events.onchange, this.inplaceSelect,
"onchange", item.itemValue);
+ this.currentText = item.itemLabel;
+ this.tempValueKeeper.value = item.itemLabel;
+
+ if (item.itemValue != this.value) {
+ this.startChangedState();
+ } else {
+ this.startViewState();
}
+
+ if (this.events.onviewactivated) {
+ this.inplaceInput.fire("rich:onviewactivated", {oldValue : value, value :
this.valueKeeper.value});
+ }
+
} else {
- this.startViewState();
+ this.cancel();
}
-
- if (this.events.onviewactivated) {
- this.inplaceInput.fire("rich:onviewactivated", {oldValue : value, value :
this.valueKeeper.value});
- }
+
}
},