Author: vmolotkov
Date: 2008-04-09 06:28:10 -0400 (Wed, 09 Apr 2008)
New Revision: 7686
Modified:
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
Log:
http://jira.jboss.com/jira/browse/RF-2680
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-04-09
09:03:49 UTC (rev 7685)
+++
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-04-09
10:28:10 UTC (rev 7686)
@@ -120,16 +120,14 @@
}
}
- if (this.events.oneditactivation) {
- this.inplaceInput.fire("rich:oneditactivation", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
- }
- var textSize = this.inplaceInput.offsetWidth;
+ 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);
- //this.endViewState();
+ this.startEditableState(textSize);
- if (this.events.oneditactivated) {
- this.inplaceInput.fire("rich:oneditactivated", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
+ if (this.events.oneditactivated) {
+ this.inplaceInput.fire("rich:oneditactivated", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
+ }
}
}
},
@@ -293,52 +291,75 @@
saveValue : function(userValue, currentText) {
var value = this.valueKeeper.value;
- if (this.events.onviewactivation) {
- this.inplaceInput.fire("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.valueKeeper.value = userValue;
- }
- if (userValue != this.value) {
- this.startChangedState();
- } else {
- this.startViewState();
- }
- /*if (userValue != this.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();
+ //this.startViewState();
} else {
- this.currentText = userValue;
+ if (currentText == "") {
+ this.setDefaultText();
+ } else {
+ this.currentText = currentText;
+ }
this.valueKeeper.value = userValue;
}
- this.startChangedState();
- } else {
- if (userValue == "") {
- this.setDefaultText();
- this.valueKeeper.value = "";
+ if (userValue != this.value) {
+ this.startChangedState();
} else {
- this.currentText = userValue;
- this.valueKeeper.value = userValue;
+ this.startViewState();
}
- this.startViewState();
- } */
- if (this.events.onviewactivated) {
- this.inplaceInput.fire("rich:onviewactivated", {oldValue :
this.valueKeeper.value, value : this.tempValueKeeper.value});
+ /*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});
+ }
}
},
+ invokeEvent : function(eventFunc, element, eventName, memo) {
+ var result = false;
+ if (eventFunc) {
+ element = $(element);
+ if (element == document && document.createEvent &&
!element.dispatchEvent)
+ element = document.documentElement;
+
+ var event;
+ if (document.createEvent) {
+ event = document.createEvent("HTMLEvents");
+ event.initEvent("dataavailable", true, true);
+ } else {
+ event = document.createEventObject();
+ event.eventType = "ondataavailable";
+ }
+
+ event.eventName = eventName;
+ event.memo = memo || { };
+
+ var result = eventFunc.call(event);
+ }
+ return result;
+ },
+
setDefaultText : function() {
this.currentText = this.attributes.defaultLabel;
},
@@ -440,7 +461,6 @@
}
}
}
-
};
Richfaces.InplaceInput.STATES = [0, 1, 2];// 0 - view, 1- editable, 2 - changed