Author: abelevich
Date: 2010-05-04 10:39:11 -0400 (Tue, 04 May 2010)
New Revision: 16884
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/subtable.js
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
Log:
fix - apply richfacesBaseComponent
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2010-05-04
14:28:59 UTC (rev 16883)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2010-05-04
14:39:11 UTC (rev 16884)
@@ -1,138 +1,24 @@
-(function (jQuery, richfaces) {
+(function ($, richfaces) {
richfaces.ui = richfaces.ui || {};
richfaces.ui.DataTable = function(id, options) {
this.id = id;
- this.options = options;
- this.sortMode = options.sortMode;
- this.initializeColumns(options.columns);
- };
-
- jQuery.extend(richfaces.ui.DataTable, {
- ASCENDING :'ASCENDING',
- DESCENDING : 'DESCENDING',
- UNSORTED : 'UNSORTED',
- SINGLE: 'single',
- MULTI: 'multi'
- });
-
- jQuery.extend(richfaces.ui.DataTable.prototype, ( function () {
-
- var columns = {};
+ this.options = options;
- var convertId = function (id){
- return id.replace(/:/g, "\\:");
- };
-
- var getElement = function (id) {
- return jQuery("#" + convertId(id));
- };
-
- return {
-
- initializeColumns : function(options) {
- for(var property in options) {
- var column = new richfaces.ui.Column(property,
options[property]);
- if(column.sortable) {
- var element = getElement(column.id);
- var _this = this;
-
- element.bind(column.sortEvent, column, function(e) {
- _this.processSortEvent(e);
- });
- }
- columns[property] = column;
- }
- },
-
- processSortEvent: function (e) {
- var column = e.data;
- column.toggleSortControl(e);
-
- if(this.sortMode == richfaces.ui.DataTable.SINGLE) {
- for(var x in columns) {
- if(columns[x].id != column.id) {
- columns[x].resetSortControl();
- }
- }
- }
- }
- }
-
- })());
-
-})(jQuery, window.RichFaces);
-
-
-(function (jQuery, richfaces) {
-
- richfaces.ui = richfaces.ui || {};
-
- richfaces.ui.Column = function(id, options) {
- this.id = id;
- this.sortable = options.sorting.sortable;
- //TODO: anton move to another place???
- if(this.sortable) {
- this.sortOrder = options.sorting.sortOrder;
- this.sortEvent = options.sorting.sortEvent;
- }
- this.initializeControls(id);
+ $super.constructor.call(this,id);
+ $p.attachToDom.call(this, id);
};
- jQuery.extend(richfaces.ui.Column.prototype, ( function () {
-
- var convertId = function (id){
- return id.replace(/:/g, "\\:");
- };
-
- var getElement = function (id) {
- return jQuery("#" + convertId(id));
- };
-
- var saveOrder = function(newOrder) {
- var input = getElement(this.id + ":sorting");
- input.attr("value",newOrder);
- };
-
+ var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.DataTable);
+ var $p =
richfaces.BaseComponent.extend(richfaces.BaseComponent,richfaces.ui.DataTable, {});
+ var $super = richfaces.ui.DataTable.$super;
+
+ $.extend(richfaces.ui.DataTable.prototype, ( function () {
return {
- initializeControls: function(id) {
- this.asc = getElement(id+':ASCENDING');
- this.desc = getElement(id+':DESCENDING');
- this.unsort = getElement(id+':UNSORTED');
- },
-
- toggleSortControl: function(e) {
-
- if(this.sortOrder == richfaces.ui.DataTable.ASCENDING) {
- this.asc.hide();
- this.unsort.hide();
- this.desc.show();
- this.sortOrder = richfaces.ui.DataTable.DESCENDING;
-
- } else if(this.sortOrder == richfaces.ui.DataTable.DESCENDING) {
- this.asc.show();
- this.unsort.hide();
- this.desc.hide();
- this.sortOrder = richfaces.ui.DataTable.ASCENDING;
-
- } else if(this.sortOrder == richfaces.ui.DataTable.UNSORTED) {
- this.asc.hide();
- this.unsort.hide();
- this.desc.show();
- this.sortOrder = richfaces.ui.DataTable.DESCENDING;
- }
-
- saveOrder.call(this, this.sortOrder);
- },
-
- resetSortControl: function(){
- this.asc.hide();
- this.desc.hide();
- this.unsort.show();
- saveOrder.call(this, richfaces.ui.DataTable.UNSORTED);
- }
+
}
})());
})(jQuery, window.RichFaces);
+
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/subtable.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/subtable.js 2010-05-04
14:28:59 UTC (rev 16883)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/subtable.js 2010-05-04
14:39:11 UTC (rev 16884)
@@ -1,4 +1,4 @@
-(function (jQuery, richfaces) {
+(function ($, richfaces) {
richfaces.ui = richfaces.ui || {};
@@ -9,22 +9,24 @@
this.eventOptions = options.eventOptions;
this.formId = f;
- this.element = document.getElementById(this.id);
- this.element.component = this;
- this.element = jQuery(this.element);
+ $super.constructor.call(this, id);
+ $p.attachToDom.call(this, id);
};
- jQuery.extend(richfaces.ui.SubTable, {
+ $.extend(richfaces.ui.SubTable, {
MODE_AJAX: "ajax",
MODE_SRV: "server",
MODE_CLNT: "client"
})
-
- jQuery.extend(richfaces.ui.SubTable.prototype, (function () {
+ var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.SubTable);
+ var $p =
richfaces.BaseComponent.extend(richfaces.BaseComponent,richfaces.ui.SubTable, {});
+ var $super = richfaces.ui.SubTable.$super;
+
+ $.extend(richfaces.ui.SubTable.prototype, (function () {
getElementById = function(id) {
- return jQuery(document.getElementById(id));
+ return $(document.getElementById(id));
}
getState = function() {
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2010-05-04
14:28:59 UTC (rev 16883)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2010-05-04
14:39:11 UTC (rev 16884)
@@ -1,4 +1,4 @@
-(function (jQuery, richfaces) {
+(function ($, richfaces) {
richfaces.ui = richfaces.ui || {};
@@ -12,20 +12,22 @@
richfaces.Event.bindById(this.id, this.eventName, this.toggle, this);
};
- jQuery.extend(richfaces.ui.DataTableToggler.prototype, (function () {
+ $.extend(richfaces.ui.DataTableToggler.prototype, (function () {
getElementById= function(id) {
- jQuery(document.getElementById(id))
+ $(document.getElementById(id))
}
return {
toggle: function(event) {
var element = getElementById(this.forId);
- var subtable = element.attr('component');
- this.toggleControl(subtable.isExpand());
- subtable.toggle(event);
- },
+ var subtable = element.attr('richfaces');
+ if(subtable && subtable.component) {
+ this.toggleControl(subtable.component.isExpand());
+ subtable.component.toggle(event);
+ }
+ },
toggleControl: function(expanded) {
var expandControl = getElementById(this.expandControl);