Author: abelevich
Date: 2010-10-11 08:22:58 -0400 (Mon, 11 Oct 2010)
New Revision: 19517
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/inplaceInput.js
Log:
refactor scripts
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-10-11
09:51:48 UTC (rev 19516)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-10-11
12:22:58 UTC (rev 19517)
@@ -32,7 +32,6 @@
this.editEvent = options.editEvent;
this.noneCss = options.noneCss;
this.changedCss = options.changedCss;
- this.showControls = options.showControls;
this.defaultLabel = options.defaultLabel;
this.element = $(document.getElementById(id));
@@ -43,12 +42,6 @@
this.isSaved = false;
this.useDefaultLabel = false;
- if(this.showControls) {
- this.okbtn = $(document.getElementById(options.okbtn));
- this.cancelbtn = $(document.getElementById(options.cancelbtn));
- this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler, this));
- this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler,
this));
- }
};
rf.BaseComponent.extend(rf.ui.InplaceBase);
@@ -84,6 +77,10 @@
getNamespace: function() {
},
+ isValueSaved: function() {
+ return this.isSaved;
+ },
+
save: function() {
var value = this.getValue()
if(value.length > 0) {
@@ -99,14 +96,6 @@
this.__hide();
},
- __applyChangedStyles: function() {
- if(this.isValueChanged()) {
- this.element.addClass(this.changedCss);
- } else {
- this.element.removeClass(this.changedCss);
- }
- },
-
cancel: function(){
var text = "";
if(!this.useDefaultLabel) {
@@ -117,14 +106,14 @@
this.__hide();
},
- isValueSaved: function() {
- return this.isSaved;
+ __applyChangedStyles: function() {
+ if(this.isValueChanged()) {
+ this.element.addClass(this.changedCss);
+ } else {
+ this.element.removeClass(this.changedCss);
+ }
},
- __saveValue: function(value) {
-
- },
-
__show: function() {
this.scrollElements = rf.Event.bindScrollEventHandlers(this.id, this.__scrollHandler,
this);
this.onshow();
@@ -143,18 +132,7 @@
this.isSaved = false;
this.editContainer.removeClass(this.noneCss);
this.__show();
- },
-
- __saveBtnHandler: function(e) {
- this.save();
- return false;
- },
-
- __cancelBtnHandler: function(e) {
- this.cancel();
- return false;
- },
-
+ },
__scrollHandler: function(e) {
this.cancel();
},
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-10-11
09:51:48 UTC (rev 19516)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-11
12:22:58 UTC (rev 19517)
@@ -12,12 +12,20 @@
var inputLabel = this.input.val();
this.initialValue = (label == inputLabel) ? label : "";
this.saveOnBlur = options.saveOnBlur;
+ this.showControls = options.showControls;
this.input.bind("focus", $.proxy(this.__editHandler, this));
this.input.bind("change", $.proxy(this.__changeHandler, this));
this.input.bind("blur", $.proxy(this.__blurHandler, this));
this.input.bind("keydown", $.proxy(this.__keydownHandler, this));
+ if(this.showControls) {
+ this.okbtn = $(document.getElementById(options.okbtn));
+ this.cancelbtn = $(document.getElementById(options.cancelbtn));
+ this.okbtn.bind("mousedown", $.proxy(this.__saveBtnHandler,
this));
+ this.cancelbtn.bind("mousedown", $.proxy(this.__cancelBtnHandler,
this));
+ }
+
this.focusElement = $(document.getElementById(options.focusElement));
};
@@ -73,6 +81,16 @@
this.input.focus();
this.input.bind("focus", $.proxy(this.__editHandler, this));
},
+
+ __saveBtnHandler: function(e) {
+ this.save();
+ return false;
+ },
+
+ __cancelBtnHandler: function(e) {
+ this.cancel();
+ return false;
+ },
getValue: function() {
return this.input.val();