Author: abelevich
Date: 2008-06-16 09:09:17 -0400 (Mon, 16 Jun 2008)
New Revision: 9053
Modified:
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
Log:
http://jira.jboss.com/jira/browse/RF-3257
Modified:
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
===================================================================
---
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-06-16
13:01:13 UTC (rev 9052)
+++
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-06-16
13:09:17 UTC (rev 9053)
@@ -124,21 +124,19 @@
return;
}
}
-
-//DONT TUCH THIZ CODE
-
- if (this.invokeEvent(this.events.oneditactivation, this.inplaceInput,
"rich:oneditactivation", {oldValue : this.valueKeeper.value, value :
this.tempValueKeeper.value})) {
- var textSize = this.inplaceInput.offsetWidth;
-
- this.startEditableState(textSize);
-
- if (this.events.oneditactivated) {
- this.inplaceInput.fire("rich:oneditactivated", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
- }
- }
+ this.edit();
}
},
+ edit: function (){
+ if (this.invokeEvent(this.events.oneditactivation, this.inplaceInput,
"rich:oneditactivation", {oldValue : this.valueKeeper.value, value :
this.tempValueKeeper.value})) {
+ this.startEditableState();
+ if (this.events.oneditactivated) {
+ this.inplaceInput.fire("rich:oneditactivated", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
+ }
+ }
+ },
+
tmpValueBlurHandler : function() {
if (this.clickOnBar || this.byTab) {
this.clickOnBar = false;
@@ -201,11 +199,11 @@
this.deleteViewArtifacts();
},*/
- startEditableState : function(textSize) {
+ startEditableState : function() {
this.inplaceInput.style.position = "relative";
-
this.changeState(Richfaces.InplaceInput.STATES[1]);
- var inputSize = this.setInputWidth(textSize);
+ var textWidth= this.inplaceInput.offsetWidth;
+ var inputSize = this.setInputWidth(textWidth);
this.tabber.hide();
@@ -248,7 +246,7 @@
*/
//TODO: rename parameter to textWidth?
- setInputWidth : function(textSize) {
+ setInputWidth : function(textWidth) {
//TODO: use constants here
if (this.currentState != 1) {
return;
@@ -257,12 +255,12 @@
if (!width) {
var max = parseInt(this.attributes.maxInputWidth);
var min = parseInt(this.attributes.minInputWidth);
- if (textSize > max) {
+ if (textWidth > max) {
width = max;
- } else if (textSize < min) {
+ } else if (textWidth < min) {
width = min;
} else {
- width = textSize;
+ width = textWidth;
}
}
this.tempValueKeeper.style.width = width + "px";
@@ -297,55 +295,38 @@
save : function() {
var userValue = this.tempValueKeeper.value;
var currentText = userValue;
- this.saveValue(userValue, currentText);
+ this.saveValue(userValue);
},
- saveValue : function(userValue, currentText) {
+ saveValue : function(userValue) {
var value = this.valueKeeper.value;
if (this.invokeEvent(this.events.onviewactivation, this.inplaceInput,
"rich:onviewactivation", {oldValue : this.valueKeeper.value, value :
this.tempValueKeeper.value})) {
this.endEditableState();
+
if (userValue == "") {
this.setDefaultText();
this.valueKeeper.value = "";
- //this.startViewState();
} else {
- if (currentText == "") {
- this.setDefaultText();
- } else {
- this.currentText = currentText;
- }
+ this.currentText = userValue;
this.valueKeeper.value = userValue;
}
+
if (userValue != this.value) {
this.startChangedState();
} else {
this.startViewState();
}
- /*if (userValue != this.value) {
- if (userValue == "") {
- this.setDefaultText();
- this.valueKeeper.value = "";
- //this.startViewState();
- } else {
- this.currentText = userValue;
- this.valueKeeper.value = userValue;
- }
- this.startChangedState();
- } else {
- if (userValue == "") {
- this.setDefaultText();
- this.valueKeeper.value = "";
- } else {
- this.currentText = userValue;
- this.valueKeeper.value = userValue;
- }
- this.startViewState();
- } */
+
if (this.events.onviewactivated) {
this.inplaceInput.fire("rich:onviewactivated", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
}
}
},
+
+ getValue : function() {
+ return this.valueKeeper.value;
+ },
+
//TODO: remove Bucks
//TODO: to shared library
invokeEvent : function(eventFunc, element, eventName, memo) {