summaryrefslogtreecommitdiff
path: root/includes/js/dojox/grid/_grid/layout.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/grid/_grid/layout.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/grid/_grid/layout.js')
-rw-r--r--includes/js/dojox/grid/_grid/layout.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/includes/js/dojox/grid/_grid/layout.js b/includes/js/dojox/grid/_grid/layout.js
new file mode 100644
index 0000000..128f486
--- /dev/null
+++ b/includes/js/dojox/grid/_grid/layout.js
@@ -0,0 +1,75 @@
+if(!dojo._hasResource["dojox.grid._grid.layout"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.grid._grid.layout"] = true;
+dojo.provide("dojox.grid._grid.layout");
+dojo.require("dojox.grid._grid.cell");
+
+dojo.declare("dojox.grid.layout", null, {
+ // summary:
+ // Controls grid cell layout. Owned by grid and used internally.
+ constructor: function(inGrid){
+ this.grid = inGrid;
+ },
+ // flat array of grid cells
+ cells: [],
+ // structured array of grid cells
+ structure: null,
+ // default cell width
+ defaultWidth: '6em',
+ // methods
+ setStructure: function(inStructure){
+ this.fieldIndex = 0;
+ this.cells = [];
+ var s = this.structure = [];
+ for(var i=0, viewDef, rows; (viewDef=inStructure[i]); i++){
+ s.push(this.addViewDef(viewDef));
+ }
+ this.cellCount = this.cells.length;
+ },
+ addViewDef: function(inDef){
+ this._defaultCellProps = inDef.defaultCell || {};
+ return dojo.mixin({}, inDef, {rows: this.addRowsDef(inDef.rows || inDef.cells)});
+ },
+ addRowsDef: function(inDef){
+ var result = [];
+ for(var i=0, row; inDef && (row=inDef[i]); i++){
+ result.push(this.addRowDef(i, row));
+ }
+ return result;
+ },
+ addRowDef: function(inRowIndex, inDef){
+ var result = [];
+ for(var i=0, def, cell; (def=inDef[i]); i++){
+ cell = this.addCellDef(inRowIndex, i, def);
+ result.push(cell);
+ this.cells.push(cell);
+ }
+ return result;
+ },
+ addCellDef: function(inRowIndex, inCellIndex, inDef){
+ var w = 0;
+ if(inDef.colSpan > 1){
+ w = 0;
+ }else if(!isNaN(inDef.width)){
+ w = inDef.width + "em";
+ }else{
+ w = inDef.width || this.defaultWidth;
+ }
+ // fieldIndex progresses linearly from the last indexed field
+ // FIXME: support generating fieldIndex based a text field name (probably in Grid)
+ var fieldIndex = inDef.field != undefined ? inDef.field : (inDef.get ? -1 : this.fieldIndex);
+ if((inDef.field != undefined) || !inDef.get){
+ this.fieldIndex = (inDef.field > -1 ? inDef.field : this.fieldIndex) + 1;
+ }
+ return new dojox.grid.cell(
+ dojo.mixin({}, this._defaultCellProps, inDef, {
+ grid: this.grid,
+ subrow: inRowIndex,
+ layoutIndex: inCellIndex,
+ index: this.cells.length,
+ fieldIndex: fieldIndex,
+ unitWidth: w
+ }));
+ }
+});
+
+}