Author: pyaschenko
Date: 2010-12-03 11:16:57 -0500 (Fri, 03 Dec 2010)
New Revision: 20366
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
Log:
http://jira.jboss.com/jira/browse/RF-9858
input components code refactoring
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-12-03
16:00:27 UTC (rev 20365)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-12-03
16:16:57 UTC (rev 20366)
@@ -98,7 +98,7 @@
this.options = {};
// call constructor of parent class
$super.constructor.call(this, componentId, componentId+ID.SELECT, fieldId, options);
- this.attachToDom(componentId);
+ this.attachToDom();
this.options = $.extend(this.options, defaultOptions, options);
this.value = this.__getSubValue();
this.index = -1;
@@ -460,6 +460,7 @@
var itemsContainer = rf.getDomElement(this.id+ID.ITEMS);
$(itemsContainer).removeData();
rf.Event.unbind(itemsContainer.parentNode, this.namespace);
+ this.detach()
$super.destroy.call(this);
}
};
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-12-03
16:00:27 UTC (rev 20365)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-12-03
16:16:57 UTC (rev 20366)
@@ -480,7 +480,7 @@
var div = rf.getDomElement(this.CALENDAR_CONTENT);
div =
$(div).replaceWith(htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar.join('')+htmlTextWeek.join('')+htmlControlsFooter+htmlFooterOptional+htmlTextFooter);
- this.attachToDom(this.id); // TODO: optimize double $
+ this.attachToDom(); // TODO: optimize double $
// memory leaks fix // from old 3.3.x code, may be not needed now
div = null;
@@ -530,7 +530,7 @@
*/
$.extend(rf.ui.Calendar.prototype, {
name: "Calendar",
- destructor: function()
+ destroy: function()
{
if (this.params.popup && this.isVisible)
{
@@ -538,6 +538,8 @@
this.scrollElements = null;
rf.Event.unbind(window.document, "click"+this.namespace);
}
+ this.detach();
+ $super.destroy.call(this);
},
dateEditorSelectYear: function(value)
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js 2010-12-03
16:00:27 UTC (rev 20365)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js 2010-12-03
16:16:57 UTC (rev 20366)
@@ -6,17 +6,22 @@
$super.constructor.call(this, id);
this.namespace = this.getNamespace() || "." +
rf.Event.createNamespace(this.getName(), this.getId());
- this.id = id;
+ this.namespace = this.namespace ||
"."+rf.Event.createNamespace(this.name, this.id);
+
this.input = $(document.getElementById(id + "Input"));
- this.attachToDom(id);
-
- this.input.bind("keydown", $.proxy(this.__keydownHandler, this));
- this.input.bind("blur", $.proxy(this.__blurHandler, this));
- this.input.bind("change", $.proxy(this.__changeHandler, this));
- this.input.bind("focus", $.proxy(this.__focusHandler, this));
+ this.attachToDom();
+
+ var inputEventHandlers = {};
+ inputEventHandlers["keydown"+this.namespace] = this.__keydownHandler;
+ inputEventHandlers["blur"+this.namespace] = this.__blurHandler;
+ inputEventHandlers["change"+this.namespace] = this.__changeHandler;
+ inputEventHandlers["focus"+this.namespace] = this.__focusHandler;
+ rf.Event.bind(this.input, inputEventHandlers, this);
};
rf.BaseComponent.extend(rf.ui.InputBase);
+
+ // define super class link
var $super = rf.ui.InputBase.$super;
$.extend(rf.ui.InputBase.prototype, ( function () {
@@ -64,7 +69,13 @@
getId: function() {
return this.id;
- }
+ },
+ destroy: function() {
+ rf.Event.unbindById(this.input, this.namespace);
+ this.input = null;
+ this.detach();
+ $super.destroy.call(this);
+ }
}
})());
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-12-03
16:00:27 UTC (rev 20365)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-12-03
16:16:57 UTC (rev 20366)
@@ -33,8 +33,8 @@
step: 1,
init: function (id, options) {
- jQuery.extend(this, options);
- this.id = id;
+ $super.constructor.call(this, id);
+ jQuery.extend(this, options);
this.element = jQuery(this.attachToDom());
this.input = this.element.children(".rf-insp-inp");
@@ -94,6 +94,8 @@
.unbind("mouseup", this.destroy);
this.intervalId = null;
}
+ this.detach();
+ $super.destroy.call(this);
},
__setValue: function (value, event, skipOnchange) {
@@ -157,4 +159,7 @@
event.preventDefault();
}
});
+
+ // define super class link
+ var $super = richfaces.ui.InputNumberSpinner.$super;
}(window.RichFaces, jQuery));
\ No newline at end of file