From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: 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 --- includes/js/dojox/grid/Grid.js | 363 ++++++++ includes/js/dojox/grid/README | 39 + includes/js/dojox/grid/VirtualGrid.js | 779 +++++++++++++++++ includes/js/dojox/grid/_data/dijitEditors.js | 170 ++++ includes/js/dojox/grid/_data/editors.js | 239 ++++++ includes/js/dojox/grid/_data/fields.js | 104 +++ includes/js/dojox/grid/_data/model.js | 762 +++++++++++++++++ includes/js/dojox/grid/_grid/Grid.css | 201 +++++ .../js/dojox/grid/_grid/Grid.css.commented.css | 258 ++++++ includes/js/dojox/grid/_grid/Grid_rtl.css | 8 + .../js/dojox/grid/_grid/Grid_rtl.css.commented.css | 10 + includes/js/dojox/grid/_grid/builder.js | 522 ++++++++++++ includes/js/dojox/grid/_grid/cell.js | 66 ++ includes/js/dojox/grid/_grid/drag.js | 113 +++ includes/js/dojox/grid/_grid/edit.js | 238 ++++++ includes/js/dojox/grid/_grid/focus.js | 207 +++++ .../dojox/grid/_grid/images/grid_dx_gradient.gif | Bin 0 -> 267 bytes .../js/dojox/grid/_grid/images/grid_sort_down.gif | Bin 0 -> 49 bytes .../js/dojox/grid/_grid/images/grid_sort_up.gif | Bin 0 -> 48 bytes .../dojox/grid/_grid/images/tabEnabled_rotated.png | Bin 0 -> 94 bytes .../dojox/grid/_grid/images/tabHover_rotated.png | Bin 0 -> 106 bytes includes/js/dojox/grid/_grid/layout.js | 75 ++ includes/js/dojox/grid/_grid/lib.js | 254 ++++++ includes/js/dojox/grid/_grid/nihiloGrid.css | 211 +++++ .../dojox/grid/_grid/nihiloGrid.css.commented.css | 275 ++++++ includes/js/dojox/grid/_grid/publicEvents.js | 451 ++++++++++ includes/js/dojox/grid/_grid/rowbar.js | 53 ++ includes/js/dojox/grid/_grid/rows.js | 66 ++ includes/js/dojox/grid/_grid/scroller.js | 489 +++++++++++ includes/js/dojox/grid/_grid/selection.js | 215 +++++ includes/js/dojox/grid/_grid/soriaGrid.css | 212 +++++ .../dojox/grid/_grid/soriaGrid.css.commented.css | 276 ++++++ includes/js/dojox/grid/_grid/tundraGrid.css | 215 +++++ .../dojox/grid/_grid/tundraGrid.css.commented.css | 281 ++++++ includes/js/dojox/grid/_grid/view.js | 336 ++++++++ includes/js/dojox/grid/_grid/views.js | 277 ++++++ includes/js/dojox/grid/resources/GridView.html | 12 + includes/js/dojox/grid/resources/VirtualGrid.html | 5 + includes/js/dojox/grid/tests/databaseModel.js | 337 ++++++++ includes/js/dojox/grid/tests/images/closed.gif | Bin 0 -> 907 bytes includes/js/dojox/grid/tests/images/flatScreen.gif | Bin 0 -> 824 bytes includes/js/dojox/grid/tests/images/open.gif | Bin 0 -> 907 bytes includes/js/dojox/grid/tests/support/books.xml | 103 +++ includes/js/dojox/grid/tests/support/data.php | 379 +++++++++ includes/js/dojox/grid/tests/support/geography.xml | 51 ++ includes/js/dojox/grid/tests/support/json.php | 794 +++++++++++++++++ includes/js/dojox/grid/tests/support/movies.csv | 9 + includes/js/dojox/grid/tests/support/test_data.js | 30 + .../dojox/grid/tests/support/test_data_objects.js | 31 + includes/js/dojox/grid/tests/support/testtbl.sql | 944 +++++++++++++++++++++ .../js/dojox/grid/tests/support/yahoo_search.js | 131 +++ .../js/dojox/grid/tests/test_change_structure.html | 124 +++ includes/js/dojox/grid/tests/test_custom_sort.html | 86 ++ .../js/dojox/grid/tests/test_dojo_data_edit.html | 124 +++ .../js/dojox/grid/tests/test_dojo_data_empty.html | 63 ++ .../js/dojox/grid/tests/test_dojo_data_model.html | 84 ++ .../tests/test_dojo_data_model_EmptyResultSet.html | 57 ++ .../tests/test_dojo_data_model_multiStores.html | 291 +++++++ .../tests/test_dojo_data_model_processError.html | 65 ++ .../grid/tests/test_dojo_data_notification.html | 114 +++ includes/js/dojox/grid/tests/test_edit.html | 149 ++++ .../js/dojox/grid/tests/test_edit_canEdit.html | 156 ++++ includes/js/dojox/grid/tests/test_edit_dijit.html | 137 +++ includes/js/dojox/grid/tests/test_events.html | 174 ++++ includes/js/dojox/grid/tests/test_expand.html | 107 +++ includes/js/dojox/grid/tests/test_grid.html | 69 ++ includes/js/dojox/grid/tests/test_grid_dlg.html | 88 ++ .../dojox/grid/tests/test_grid_headerHeight.html | 84 ++ includes/js/dojox/grid/tests/test_grid_layout.html | 112 +++ .../tests/test_grid_layout_LayoutContainer.html | 87 ++ .../tests/test_grid_layout_borderContainer.html | 98 +++ .../grid/tests/test_grid_object_model_change.html | 86 ++ .../dojox/grid/tests/test_grid_programmatic.html | 65 ++ .../grid/tests/test_grid_programmatic_layout.html | 74 ++ includes/js/dojox/grid/tests/test_grid_rtl.html | 71 ++ includes/js/dojox/grid/tests/test_grid_themes.html | 118 +++ .../dojox/grid/tests/test_grid_tooltip_menu.html | 161 ++++ includes/js/dojox/grid/tests/test_keyboard.html | 90 ++ includes/js/dojox/grid/tests/test_markup.html | 112 +++ includes/js/dojox/grid/tests/test_mysql_edit.html | 155 ++++ includes/js/dojox/grid/tests/test_sizing.html | 175 ++++ .../js/dojox/grid/tests/test_sizing_100rows.html | 168 ++++ .../dojox/grid/tests/test_sizing_ResizeHandle.html | 113 +++ includes/js/dojox/grid/tests/test_styling.html | 131 +++ includes/js/dojox/grid/tests/test_subgrid.html | 179 ++++ includes/js/dojox/grid/tests/test_tundra_edit.html | 139 +++ .../js/dojox/grid/tests/test_yahoo_images.html | 148 ++++ .../js/dojox/grid/tests/test_yahoo_search.html | 141 +++ includes/js/dojox/grid/tests/yahooSearch.js | 137 +++ 89 files changed, 15123 insertions(+) create mode 100644 includes/js/dojox/grid/Grid.js create mode 100644 includes/js/dojox/grid/README create mode 100644 includes/js/dojox/grid/VirtualGrid.js create mode 100644 includes/js/dojox/grid/_data/dijitEditors.js create mode 100644 includes/js/dojox/grid/_data/editors.js create mode 100644 includes/js/dojox/grid/_data/fields.js create mode 100644 includes/js/dojox/grid/_data/model.js create mode 100644 includes/js/dojox/grid/_grid/Grid.css create mode 100644 includes/js/dojox/grid/_grid/Grid.css.commented.css create mode 100644 includes/js/dojox/grid/_grid/Grid_rtl.css create mode 100644 includes/js/dojox/grid/_grid/Grid_rtl.css.commented.css create mode 100644 includes/js/dojox/grid/_grid/builder.js create mode 100644 includes/js/dojox/grid/_grid/cell.js create mode 100644 includes/js/dojox/grid/_grid/drag.js create mode 100644 includes/js/dojox/grid/_grid/edit.js create mode 100644 includes/js/dojox/grid/_grid/focus.js create mode 100644 includes/js/dojox/grid/_grid/images/grid_dx_gradient.gif create mode 100644 includes/js/dojox/grid/_grid/images/grid_sort_down.gif create mode 100644 includes/js/dojox/grid/_grid/images/grid_sort_up.gif create mode 100644 includes/js/dojox/grid/_grid/images/tabEnabled_rotated.png create mode 100644 includes/js/dojox/grid/_grid/images/tabHover_rotated.png create mode 100644 includes/js/dojox/grid/_grid/layout.js create mode 100644 includes/js/dojox/grid/_grid/lib.js create mode 100644 includes/js/dojox/grid/_grid/nihiloGrid.css create mode 100644 includes/js/dojox/grid/_grid/nihiloGrid.css.commented.css create mode 100644 includes/js/dojox/grid/_grid/publicEvents.js create mode 100644 includes/js/dojox/grid/_grid/rowbar.js create mode 100644 includes/js/dojox/grid/_grid/rows.js create mode 100644 includes/js/dojox/grid/_grid/scroller.js create mode 100644 includes/js/dojox/grid/_grid/selection.js create mode 100644 includes/js/dojox/grid/_grid/soriaGrid.css create mode 100644 includes/js/dojox/grid/_grid/soriaGrid.css.commented.css create mode 100644 includes/js/dojox/grid/_grid/tundraGrid.css create mode 100644 includes/js/dojox/grid/_grid/tundraGrid.css.commented.css create mode 100644 includes/js/dojox/grid/_grid/view.js create mode 100644 includes/js/dojox/grid/_grid/views.js create mode 100644 includes/js/dojox/grid/resources/GridView.html create mode 100644 includes/js/dojox/grid/resources/VirtualGrid.html create mode 100644 includes/js/dojox/grid/tests/databaseModel.js create mode 100644 includes/js/dojox/grid/tests/images/closed.gif create mode 100644 includes/js/dojox/grid/tests/images/flatScreen.gif create mode 100644 includes/js/dojox/grid/tests/images/open.gif create mode 100644 includes/js/dojox/grid/tests/support/books.xml create mode 100644 includes/js/dojox/grid/tests/support/data.php create mode 100644 includes/js/dojox/grid/tests/support/geography.xml create mode 100644 includes/js/dojox/grid/tests/support/json.php create mode 100644 includes/js/dojox/grid/tests/support/movies.csv create mode 100644 includes/js/dojox/grid/tests/support/test_data.js create mode 100644 includes/js/dojox/grid/tests/support/test_data_objects.js create mode 100644 includes/js/dojox/grid/tests/support/testtbl.sql create mode 100644 includes/js/dojox/grid/tests/support/yahoo_search.js create mode 100644 includes/js/dojox/grid/tests/test_change_structure.html create mode 100644 includes/js/dojox/grid/tests/test_custom_sort.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_edit.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_empty.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_model.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_model_EmptyResultSet.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_model_multiStores.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_model_processError.html create mode 100644 includes/js/dojox/grid/tests/test_dojo_data_notification.html create mode 100644 includes/js/dojox/grid/tests/test_edit.html create mode 100644 includes/js/dojox/grid/tests/test_edit_canEdit.html create mode 100644 includes/js/dojox/grid/tests/test_edit_dijit.html create mode 100644 includes/js/dojox/grid/tests/test_events.html create mode 100644 includes/js/dojox/grid/tests/test_expand.html create mode 100644 includes/js/dojox/grid/tests/test_grid.html create mode 100644 includes/js/dojox/grid/tests/test_grid_dlg.html create mode 100644 includes/js/dojox/grid/tests/test_grid_headerHeight.html create mode 100644 includes/js/dojox/grid/tests/test_grid_layout.html create mode 100644 includes/js/dojox/grid/tests/test_grid_layout_LayoutContainer.html create mode 100644 includes/js/dojox/grid/tests/test_grid_layout_borderContainer.html create mode 100644 includes/js/dojox/grid/tests/test_grid_object_model_change.html create mode 100644 includes/js/dojox/grid/tests/test_grid_programmatic.html create mode 100644 includes/js/dojox/grid/tests/test_grid_programmatic_layout.html create mode 100644 includes/js/dojox/grid/tests/test_grid_rtl.html create mode 100644 includes/js/dojox/grid/tests/test_grid_themes.html create mode 100644 includes/js/dojox/grid/tests/test_grid_tooltip_menu.html create mode 100644 includes/js/dojox/grid/tests/test_keyboard.html create mode 100644 includes/js/dojox/grid/tests/test_markup.html create mode 100644 includes/js/dojox/grid/tests/test_mysql_edit.html create mode 100644 includes/js/dojox/grid/tests/test_sizing.html create mode 100644 includes/js/dojox/grid/tests/test_sizing_100rows.html create mode 100644 includes/js/dojox/grid/tests/test_sizing_ResizeHandle.html create mode 100644 includes/js/dojox/grid/tests/test_styling.html create mode 100644 includes/js/dojox/grid/tests/test_subgrid.html create mode 100644 includes/js/dojox/grid/tests/test_tundra_edit.html create mode 100644 includes/js/dojox/grid/tests/test_yahoo_images.html create mode 100644 includes/js/dojox/grid/tests/test_yahoo_search.html create mode 100644 includes/js/dojox/grid/tests/yahooSearch.js (limited to 'includes/js/dojox/grid') diff --git a/includes/js/dojox/grid/Grid.js b/includes/js/dojox/grid/Grid.js new file mode 100644 index 0000000..309bb25 --- /dev/null +++ b/includes/js/dojox/grid/Grid.js @@ -0,0 +1,363 @@ +if(!dojo._hasResource["dojox.grid.Grid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid.Grid"] = true; +dojo.provide("dojox.grid.Grid"); +dojo.require("dojox.grid.VirtualGrid"); +dojo.require("dojox.grid._data.model"); +dojo.require("dojox.grid._data.editors"); +dojo.require("dojox.grid._data.dijitEditors"); + +// FIXME: +// we are at the wrong location! + +dojo.declare('dojox.Grid', dojox.VirtualGrid, { + // summary: + // A grid widget with virtual scrolling, cell editing, complex rows, + // sorting, fixed columns, sizeable columns, etc. + // description: + // Grid is a subclass of VirtualGrid, providing binding to a data + // store. + // example: + // define the grid structure: + // | var structure = [ // array of view objects + // | { cells: [// array of rows, a row is an array of cells + // | [ { name: "Alpha", width: 6 }, + // | { name: "Beta" }, + // | { name: "Gamma", get: formatFunction } + // | ] + // | ]} + // | ]; + // + // define a grid data model + // | var model = new dojox.grid.data.table(null, data); + // | + // |
+ // + + // model: + // string or object grid data model + model: 'dojox.grid.data.Table', + + // life cycle + postCreate: function(){ + if(this.model){ + var m = this.model; + if(dojo.isString(m)){ + m = dojo.getObject(m); + } + this.model = (dojo.isFunction(m)) ? new m() : m; + this._setModel(this.model); + } + this.inherited(arguments); + }, + + destroy: function(){ + this.setModel(null); + this.inherited(arguments); + }, + + // structure + _structureChanged: function() { + this.indexCellFields(); + this.inherited(arguments); + }, + + // model + _setModel: function(inModel){ + // if(!inModel){ return; } + this.model = inModel; + if(this.model){ + this.model.observer(this); + this.model.measure(); + this.indexCellFields(); + } + }, + + setModel: function(inModel){ + // summary: + // Set the grid's data model + // inModel: Object + // Model object, usually an instance of a dojox.grid.data.Model + // subclass + if(this.model){ + this.model.notObserver(this); + } + this._setModel(inModel); + }, + + + get: function(inRowIndex){ + // summary: data socket (called in cell's context) + return this.grid.model.getDatum(inRowIndex, this.fieldIndex); + }, + + // model modifications + modelAllChange: function(){ + this.rowCount = (this.model ? this.model.getRowCount() : 0); + this.updateRowCount(this.rowCount); + }, + + modelRowChange: function(inData, inRowIndex){ + this.updateRow(inRowIndex); + }, + + modelDatumChange: function(inDatum, inRowIndex, inFieldIndex){ + this.updateRow(inRowIndex); + }, + + modelFieldsChange: function() { + this.indexCellFields(); + this.render(); + }, + + // model insertion + modelInsertion: function(inRowIndex){ + this.updateRowCount(this.model.getRowCount()); + }, + + // model removal + modelRemoval: function(inKeys){ + this.updateRowCount(this.model.getRowCount()); + }, + + // cells + getCellName: function(inCell){ + var v = this.model.fields.values, i = inCell.fieldIndex; + return i>=0 && i 0 ? 1 : -1); + }, + + sort: function(){ + this.edit.apply(); + this.model.sort(this.getSortField()); + }, + + // row editing + addRow: function(inRowData, inIndex){ + this.edit.apply(); + var i = inIndex || -1; + if(i<0){ + i = this.selection.getFirstSelected() || 0; + } + if(i<0){ + i = 0; + } + this.model.insert(inRowData, i); + this.model.beginModifyRow(i); + // begin editing row + // FIXME: add to edit + for(var j=0, c; ((c=this.getCell(j)) && !c.editor); j++){} + if(c&&c.editor){ + this.edit.setEditCell(c, i); + this.focus.setFocusCell(c, i); + }else{ + this.focus.setFocusCell(this.getCell(0), i); + } + }, + + removeSelectedRows: function(){ + this.edit.apply(); + var s = this.selection.getSelected(); + if(s.length){ + this.model.remove(s); + this.selection.clear(); + } + }, + + //: protected + // editing + canEdit: function(inCell, inRowIndex){ + // summary: + // Determines if a given cell may be edited + // inCell: Object + // A grid cell + // inRowIndex: Integer + // Grid row index + // returns: Boolean + // True if given cell may be edited + return (this.model.canModify ? this.model.canModify(inRowIndex) : true); + }, + + doStartEdit: function(inCell, inRowIndex){ + this.model.beginModifyRow(inRowIndex); + this.onStartEdit(inCell, inRowIndex); + }, + + doApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){ + this.model.setDatum(inValue, inRowIndex, inFieldIndex); + this.onApplyCellEdit(inValue, inRowIndex, inFieldIndex); + }, + + doCancelEdit: function(inRowIndex){ + this.model.cancelModifyRow(inRowIndex); + this.onCancelEdit.apply(this, arguments); + }, + + doApplyEdit: function(inRowIndex){ + this.model.endModifyRow(inRowIndex); + this.onApplyEdit(inRowIndex); + }, + + styleRowState: function(inRow){ + // summary: Perform row styling + if(this.model.getState){ + var states=this.model.getState(inRow.index), c=''; + for(var i=0, ss=["inflight", "error", "inserting"], s; s=ss[i]; i++){ + if(states[s]){ + c = ' dojoxGrid-row-' + s; + break; + } + } + inRow.customClasses += c; + } + }, + + onStyleRow: function(inRow){ + this.styleRowState(inRow); + this.inherited(arguments); + } + +}); + +dojox.Grid.markupFactory = function(props, node, ctor){ + // handle setting up a data model for a store if one + // isn't provided. There are some caveats: + // * we only really handle dojo.data sources well. They're the future + // so it's no big deal, but it's something to be aware of. + // * I'm pretty sure that colgroup introspection is missing some of + // the available settable properties. + // * No handling of cell formatting and content getting is done + var d = dojo; + var widthFromAttr = function(n){ + var w = d.attr(n, "width")||"auto"; + if((w != "auto")&&(w.substr(-2) != "em")){ + w = parseInt(w)+"px"; + } + return w; + } + if(!props.model && d.hasAttr(node, "store")){ + // if a model isn't specified and we point to a store, assume + // we're also folding the definition for a model up into the + // inline ctor for the Grid. This will then take properties + // like "query", "rowsPerPage", and "clientSort" from the grid + // definition. + var mNode = node.cloneNode(false); + d.attr(mNode, { + "jsId": null, + "dojoType": d.attr(node, "dataModelClass") || "dojox.grid.data.DojoData" + }); + props.model = d.parser.instantiate([mNode])[0]; + } + // if(!props.model){ console.debug("no model!"); } + // if a structure isn't referenced, do we have enough + // data to try to build one automatically? + if( !props.structure && + node.nodeName.toLowerCase() == "table"){ + + // try to discover a structure + props.structure = d.query("> colgroup", node).map(function(cg){ + var sv = d.attr(cg, "span"); + var v = { + noscroll: (d.attr(cg, "noscroll") == "true") ? true : false, + __span: (!!sv ? parseInt(sv) : 1), + cells: [] + }; + if(d.hasAttr(cg, "width")){ + v.width = widthFromAttr(cg); + } + return v; // for vendetta + }); + if(!props.structure.length){ + props.structure.push({ + __span: Infinity, + cells: [] // catch-all view + }); + } + // check to see if we're gonna have more than one view + + // for each tr in our th, create a row of cells + d.query("thead > tr", node).forEach(function(tr, tr_idx){ + var cellCount = 0; + var viewIdx = 0; + var lastViewIdx; + var cView = null; + d.query("> th", tr).map(function(th){ + // what view will this cell go into? + + // NOTE: + // to prevent extraneous iteration, we start counters over + // for each row, incrementing over the surface area of the + // structure that colgroup processing generates and + // creating cell objects for each to place into those + // cell groups. There's a lot of state-keepking logic + // here, but it is what it has to be. + if(!cView){ // current view book keeping + lastViewIdx = 0; + cView = props.structure[0]; + }else if(cellCount >= (lastViewIdx+cView.__span)){ + viewIdx++; + // move to allocating things into the next view + lastViewIdx += cView.__span; + lastView = cView; + cView = props.structure[viewIdx]; + } + + // actually define the cell from what markup hands us + var cell = { + name: d.trim(d.attr(th, "name")||th.innerHTML), + field: d.trim(d.attr(th, "field")||""), + colSpan: parseInt(d.attr(th, "colspan")||1) + }; + cellCount += cell.colSpan; + cell.field = cell.field||cell.name; + cell.width = widthFromAttr(th); + if(!cView.cells[tr_idx]){ + cView.cells[tr_idx] = []; + } + cView.cells[tr_idx].push(cell); + }); + }); + // console.debug(dojo.toJson(props.structure, true)); + } + return new dojox.Grid(props, node); +} + + +// alias us to the right location +dojox.grid.Grid = dojox.Grid; + +} diff --git a/includes/js/dojox/grid/README b/includes/js/dojox/grid/README new file mode 100644 index 0000000..f9dade3 --- /dev/null +++ b/includes/js/dojox/grid/README @@ -0,0 +1,39 @@ +------------------------------------------------------------------------------- +dojox.grid +------------------------------------------------------------------------------- +Version 1.00 +Release date: 10/04/2007 +------------------------------------------------------------------------------- +Project state: +beta +------------------------------------------------------------------------------- +Credits + Scott J. Miles (sjmiles@activegrid.com) + Steve Orvell (sorvell@activegrid.com) +------------------------------------------------------------------------------- +Project description + +TurboGrid has been made available in Dojo and is now the dojox.grid! + +------------------------------------------------------------------------------- +Dependencies: + +Dojo Core +Dijit Templated Widget +------------------------------------------------------------------------------- +Documentation + +None available for this version yet. + +See http://www.turboajax.com/products/turbogrid/ for legacy documentation. +------------------------------------------------------------------------------- +Installation instructions + +Grab the following from the Dojo SVN Repository: +http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/grid/* + +Install into the following directory structure: +/dojox/grid/ + +...which should be at the same level as your Dojo checkout. +------------------------------------------------------------------------------- diff --git a/includes/js/dojox/grid/VirtualGrid.js b/includes/js/dojox/grid/VirtualGrid.js new file mode 100644 index 0000000..104054c --- /dev/null +++ b/includes/js/dojox/grid/VirtualGrid.js @@ -0,0 +1,779 @@ +if(!dojo._hasResource["dojox.grid.VirtualGrid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid.VirtualGrid"] = true; +dojo.provide("dojox.grid.VirtualGrid"); + +dojo.require("dojox.grid._grid.lib"); +dojo.require("dojox.grid._grid.scroller"); +dojo.require("dojox.grid._grid.view"); +dojo.require("dojox.grid._grid.views"); +dojo.require("dojox.grid._grid.layout"); +dojo.require("dojox.grid._grid.rows"); +dojo.require("dojox.grid._grid.focus"); +dojo.require("dojox.grid._grid.selection"); +dojo.require("dojox.grid._grid.edit"); +dojo.require("dojox.grid._grid.rowbar"); +dojo.require("dojox.grid._grid.publicEvents"); + +dojo.declare('dojox.VirtualGrid', + [ dijit._Widget, dijit._Templated ], + { + // summary: + // A grid widget with virtual scrolling, cell editing, complex rows, + // sorting, fixed columns, sizeable columns, etc. + // + // description: + // VirtualGrid provides the full set of grid features without any + // direct connection to a data store. + // + // The grid exposes a get function for the grid, or optionally + // individual columns, to populate cell contents. + // + // The grid is rendered based on its structure, an object describing + // column and cell layout. + // + // example: + // A quick sample: + // + // define a get function + // | function get(inRowIndex){ // called in cell context + // | return [this.index, inRowIndex].join(', '); + // | } + // + // define the grid structure: + // | var structure = [ // array of view objects + // | { cells: [// array of rows, a row is an array of cells + // | [ + // | { name: "Alpha", width: 6 }, + // | { name: "Beta" }, + // | { name: "Gamma", get: get }] + // | ]} + // | ]; + // + // |
+ + templateString:"
\n\t
\n\t
\n\t\n
\n", + + // classTag: String + // CSS class applied to the grid's domNode + classTag: 'dojoxGrid', + + get: function(inRowIndex){ + // summary: Default data getter. + // description: + // Provides data to display in a grid cell. Called in grid cell context. + // So this.cell.index is the column index. + // inRowIndex: Integer + // Row for which to provide data + // returns: + // Data to display for a given grid cell. + }, + + // settings + // rowCount: Integer + // Number of rows to display. + rowCount: 5, + + // keepRows: Integer + // Number of rows to keep in the rendering cache. + keepRows: 75, + + // rowsPerPage: Integer + // Number of rows to render at a time. + rowsPerPage: 25, + + // autoWidth: Boolean + // If autoWidth is true, grid width is automatically set to fit the data. + autoWidth: false, + + // autoHeight: Boolean + // If autoHeight is true, grid height is automatically set to fit the data. + autoHeight: false, + + // autoRender: Boolean + // If autoRender is true, grid will render itself after initialization. + autoRender: true, + + // defaultHeight: String + // default height of the grid, measured in any valid css unit. + defaultHeight: '15em', + + // structure: Object|String + // View layout defintion. Can be set to a layout object, or to the (string) name of a layout object. + structure: '', + + // elasticView: Integer + // Override defaults and make the indexed grid view elastic, thus filling available horizontal space. + elasticView: -1, + + // singleClickEdit: boolean + // Single-click starts editing. Default is double-click + singleClickEdit: false, + + // Used to store the last two clicks, to ensure double-clicking occurs based on the intended row + _click: null, + + // private + sortInfo: 0, + themeable: true, + + // initialization + buildRendering: function(){ + this.inherited(arguments); + // reset get from blank function (needed for markup parsing) to null, if not changed + if(this.get == dojox.VirtualGrid.prototype.get){ + this.get = null; + } + if(!this.domNode.getAttribute('tabIndex')){ + this.domNode.tabIndex = "0"; + } + this.createScroller(); + this.createLayout(); + this.createViews(); + this.createManagers(); + dojox.grid.initTextSizePoll(); + this.connect(dojox.grid, "textSizeChanged", "textSizeChanged"); + dojox.grid.funnelEvents(this.domNode, this, 'doKeyEvent', dojox.grid.keyEvents); + this.connect(this, "onShow", "renderOnIdle"); + }, + postCreate: function(){ + // replace stock styleChanged with one that triggers an update + this.styleChanged = this._styleChanged; + this.setStructure(this.structure); + this._click = []; + }, + + destroy: function(){ + this.domNode.onReveal = null; + this.domNode.onSizeChange = null; + this.edit.destroy(); + this.views.destroyViews(); + this.inherited(arguments); + }, + + styleChanged: function(){ + this.setStyledClass(this.domNode, ''); + }, + + _styleChanged: function(){ + this.styleChanged(); + this.update(); + }, + + textSizeChanged: function(){ + setTimeout(dojo.hitch(this, "_textSizeChanged"), 1); + }, + + _textSizeChanged: function(){ + if(this.domNode){ + this.views.forEach(function(v){ + v.content.update(); + }); + this.render(); + } + }, + + sizeChange: function(){ + dojox.grid.jobs.job(this.id + 'SizeChange', 50, dojo.hitch(this, "update")); + }, + + renderOnIdle: function() { + setTimeout(dojo.hitch(this, "render"), 1); + }, + + createManagers: function(){ + // summary: + // create grid managers for various tasks including rows, focus, selection, editing + + // row manager + this.rows = new dojox.grid.rows(this); + // focus manager + this.focus = new dojox.grid.focus(this); + // selection manager + this.selection = new dojox.grid.selection(this); + // edit manager + this.edit = new dojox.grid.edit(this); + }, + + createScroller: function(){ + // summary: Creates a new virtual scroller + this.scroller = new dojox.grid.scroller.columns(); + this.scroller._pageIdPrefix = this.id + '-'; + this.scroller.renderRow = dojo.hitch(this, "renderRow"); + this.scroller.removeRow = dojo.hitch(this, "rowRemoved"); + }, + + createLayout: function(){ + // summary: Creates a new Grid layout + this.layout = new dojox.grid.layout(this); + }, + + // views + createViews: function(){ + this.views = new dojox.grid.views(this); + this.views.createView = dojo.hitch(this, "createView"); + }, + + createView: function(inClass){ + if(dojo.isAIR){ + var obj = window; + var names = inClass.split('.'); + for(var i=0;i 0){ + }else if(this.domNode.clientHeight <= padBorder.h){ + if(this.domNode.parentNode == document.body){ + this.domNode.style.height = this.defaultHeight; + }else{ + this.fitTo = "parent"; + } + } + // if we are given dimensions, size the grid's domNode to those dimensions + if(this._sizeBox){ + dojo.contentBox(this.domNode, this._sizeBox); + }else if(this.fitTo == "parent"){ + var h = dojo._getContentBox(this.domNode.parentNode).h; + dojo.marginBox(this.domNode, { h: Math.max(0, h) }); + } + + var h = dojo._getContentBox(this.domNode).h; + if(h == 0 && !this.autoHeight){ + // We need to hide the header, since the Grid is essentially hidden. + this.viewsHeaderNode.style.display = "none"; + }else{ + // Otherwise, show the header and give it an appropriate height. + this.viewsHeaderNode.style.display = "block"; + } + + // NOTE: it is essential that width be applied before height + // Header height can only be calculated properly after view widths have been set. + // This is because flex column width is naturally 0 in Firefox. + // Therefore prior to width sizing flex columns with spaces are maximally wrapped + // and calculated to be too tall. + this.adaptWidth(); + this.adaptHeight(); + + // default row height (FIXME: use running average(?), remove magic #) + this.scroller.defaultRowHeight = this.rows.getDefaultHeightPx() + 1; + this.postresize(); + }, + + adaptWidth: function() { + // private: sets width and position for views and update grid width if necessary + var + w = this.autoWidth ? 0 : this.domNode.clientWidth || (this.domNode.offsetWidth - this._getPadBorder().w); + vw = this.views.arrange(1, w); + this.views.onEach("adaptWidth"); + if (this.autoWidth) + this.domNode.style.width = vw + "px"; + }, + + adaptHeight: function(){ + // private: measures and normalizes header height, then sets view heights, and then updates scroller + var vns = this.viewsHeaderNode.style, t = vns.display == "none" ? 0 : this.views.measureHeader(); + vns.height = t + 'px'; + // header heights are reset during measuring so must be normalized after measuring. + this.views.normalizeHeaderNodeHeight(); + // content extent + var h = (this.autoHeight ? -1 : Math.max(this.domNode.clientHeight - t, 0) || 0); + this.views.onEach('setSize', [0, h]); + this.views.onEach('adaptHeight'); + this.scroller.windowHeight = h; + }, + + // render + render: function(){ + // summary: + // Render the grid, headers, and views. Edit and scrolling states are reset. To retain edit and + // scrolling states, see Update. + + if(!this.domNode){return;} + + if(!this.hasLayout()) { + this.scroller.init(0, this.keepRows, this.rowsPerPage); + return; + } + // + this.update = this.defaultUpdate; + this.scroller.init(this.rowCount, this.keepRows, this.rowsPerPage); + this.prerender(); + this.setScrollTop(0); + this.postrender(); + }, + + prerender: function(){ + // if autoHeight, make sure scroller knows not to virtualize; everything must be rendered. + this.keepRows = this.autoHeight ? 0 : this.constructor.prototype.keepRows; + this.scroller.setKeepInfo(this.keepRows); + this.views.render(); + this._resize(); + }, + + postrender: function(){ + this.postresize(); + this.focus.initFocusView(); + // make rows unselectable + dojo.setSelectable(this.domNode, false); + }, + + postresize: function(){ + // views are position absolute, so they do not inflate the parent + if(this.autoHeight){ + this.viewsNode.style.height = this.views.measureContent() + 'px'; + } + }, + + renderRow: function(inRowIndex, inNodes){ + // summary: private, used internally to render rows + this.views.renderRow(inRowIndex, inNodes); + }, + + rowRemoved: function(inRowIndex){ + // summary: private, used internally to remove rows + this.views.rowRemoved(inRowIndex); + }, + + invalidated: null, + + updating: false, + + beginUpdate: function(){ + // summary: + // Use to make multiple changes to rows while queueing row updating. + // NOTE: not currently supporting nested begin/endUpdate calls + this.invalidated = []; + this.updating = true; + }, + + endUpdate: function(){ + // summary: + // Use after calling beginUpdate to render any changes made to rows. + this.updating = false; + var i = this.invalidated; + if(i.all){ + this.update(); + }else if(i.rowCount != undefined){ + this.updateRowCount(i.rowCount); + }else{ + for(r in i){ + this.updateRow(Number(r)); + } + } + this.invalidated = null; + }, + + // update + defaultUpdate: function(){ + // note: initial update calls render and subsequently this function. + if(!this.domNode){return;} + if(this.updating){ + this.invalidated.all = true; + return; + } + //this.edit.saveState(inRowIndex); + this.prerender(); + this.scroller.invalidateNodes(); + this.setScrollTop(this.scrollTop); + this.postrender(); + //this.edit.restoreState(inRowIndex); + }, + + update: function(){ + // summary: + // Update the grid, retaining edit and scrolling states. + this.render(); + }, + + updateRow: function(inRowIndex){ + // summary: + // Render a single row. + // inRowIndex: Integer + // Index of the row to render + inRowIndex = Number(inRowIndex); + if(this.updating){ + this.invalidated[inRowIndex]=true; + }else{ + this.views.updateRow(inRowIndex, this.rows.getHeight(inRowIndex)); + this.scroller.rowHeightChanged(inRowIndex); + } + }, + + updateRowCount: function(inRowCount){ + //summary: + // Change the number of rows. + // inRowCount: int + // Number of rows in the grid. + if(this.updating){ + this.invalidated.rowCount = inRowCount; + }else{ + this.rowCount = inRowCount; + if(this.layout.cells.length){ + this.scroller.updateRowCount(inRowCount); + this.setScrollTop(this.scrollTop); + } + this._resize(); + } + }, + + updateRowStyles: function(inRowIndex){ + // summary: + // Update the styles for a row after it's state has changed. + this.views.updateRowStyles(inRowIndex); + }, + + rowHeightChanged: function(inRowIndex){ + // summary: + // Update grid when the height of a row has changed. Row height is handled automatically as rows + // are rendered. Use this function only to update a row's height outside the normal rendering process. + // inRowIndex: Integer + // index of the row that has changed height + + this.views.renormalizeRow(inRowIndex); + this.scroller.rowHeightChanged(inRowIndex); + }, + + // fastScroll: Boolean + // flag modifies vertical scrolling behavior. Defaults to true but set to false for slower + // scroll performance but more immediate scrolling feedback + fastScroll: true, + + delayScroll: false, + + // scrollRedrawThreshold: int + // pixel distance a user must scroll vertically to trigger grid scrolling. + scrollRedrawThreshold: (dojo.isIE ? 100 : 50), + + // scroll methods + scrollTo: function(inTop){ + // summary: + // Vertically scroll the grid to a given pixel position + // inTop: Integer + // vertical position of the grid in pixels + if(!this.fastScroll){ + this.setScrollTop(inTop); + return; + } + var delta = Math.abs(this.lastScrollTop - inTop); + this.lastScrollTop = inTop; + if(delta > this.scrollRedrawThreshold || this.delayScroll){ + this.delayScroll = true; + this.scrollTop = inTop; + this.views.setScrollTop(inTop); + dojox.grid.jobs.job('dojoxGrid-scroll', 200, dojo.hitch(this, "finishScrollJob")); + }else{ + this.setScrollTop(inTop); + } + }, + + finishScrollJob: function(){ + this.delayScroll = false; + this.setScrollTop(this.scrollTop); + }, + + setScrollTop: function(inTop){ + this.scrollTop = this.views.setScrollTop(inTop); + this.scroller.scroll(this.scrollTop); + }, + + scrollToRow: function(inRowIndex){ + // summary: + // Scroll the grid to a specific row. + // inRowIndex: Integer + // grid row index + this.setScrollTop(this.scroller.findScrollTop(inRowIndex) + 1); + }, + + // styling (private, used internally to style individual parts of a row) + styleRowNode: function(inRowIndex, inRowNode){ + if(inRowNode){ + this.rows.styleRowNode(inRowIndex, inRowNode); + } + }, + + // cells + getCell: function(inIndex){ + // summary: + // Retrieves the cell object for a given grid column. + // inIndex: Integer + // Grid column index of cell to retrieve + // returns: + // a grid cell + return this.layout.cells[inIndex]; + }, + + setCellWidth: function(inIndex, inUnitWidth) { + this.getCell(inIndex).unitWidth = inUnitWidth; + }, + + getCellName: function(inCell){ + // summary: Returns the cell name of a passed cell + return "Cell " + inCell.index; // String + }, + + // sorting + canSort: function(inSortInfo){ + // summary: + // Determines if the grid can be sorted + // inSortInfo: Integer + // Sort information, 1-based index of column on which to sort, positive for an ascending sort + // and negative for a descending sort + // returns: Boolean + // True if grid can be sorted on the given column in the given direction + }, + + sort: function(){ + }, + + getSortAsc: function(inSortInfo){ + // summary: + // Returns true if grid is sorted in an ascending direction. + inSortInfo = inSortInfo == undefined ? this.sortInfo : inSortInfo; + return Boolean(inSortInfo > 0); // Boolean + }, + + getSortIndex: function(inSortInfo){ + // summary: + // Returns the index of the column on which the grid is sorted + inSortInfo = inSortInfo == undefined ? this.sortInfo : inSortInfo; + return Math.abs(inSortInfo) - 1; // Integer + }, + + setSortIndex: function(inIndex, inAsc){ + // summary: + // Sort the grid on a column in a specified direction + // inIndex: Integer + // Column index on which to sort. + // inAsc: Boolean + // If true, sort the grid in ascending order, otherwise in descending order + var si = inIndex +1; + if(inAsc != undefined){ + si *= (inAsc ? 1 : -1); + } else if(this.getSortIndex() == inIndex){ + si = -this.sortInfo; + } + this.setSortInfo(si); + }, + + setSortInfo: function(inSortInfo){ + if(this.canSort(inSortInfo)){ + this.sortInfo = inSortInfo; + this.sort(); + this.update(); + } + }, + + // DOM event handler + doKeyEvent: function(e){ + e.dispatch = 'do' + e.type; + this.onKeyEvent(e); + }, + + // event dispatch + //: protected + _dispatch: function(m, e){ + if(m in this){ + return this[m](e); + } + }, + + dispatchKeyEvent: function(e){ + this._dispatch(e.dispatch, e); + }, + + dispatchContentEvent: function(e){ + this.edit.dispatchEvent(e) || e.sourceView.dispatchContentEvent(e) || this._dispatch(e.dispatch, e); + }, + + dispatchHeaderEvent: function(e){ + e.sourceView.dispatchHeaderEvent(e) || this._dispatch('doheader' + e.type, e); + }, + + dokeydown: function(e){ + this.onKeyDown(e); + }, + + doclick: function(e){ + if(e.cellNode){ + this.onCellClick(e); + }else{ + this.onRowClick(e); + } + }, + + dodblclick: function(e){ + if(e.cellNode){ + this.onCellDblClick(e); + }else{ + this.onRowDblClick(e); + } + }, + + docontextmenu: function(e){ + if(e.cellNode){ + this.onCellContextMenu(e); + }else{ + this.onRowContextMenu(e); + } + }, + + doheaderclick: function(e){ + if(e.cellNode){ + this.onHeaderCellClick(e); + }else{ + this.onHeaderClick(e); + } + }, + + doheaderdblclick: function(e){ + if(e.cellNode){ + this.onHeaderCellDblClick(e); + }else{ + this.onHeaderDblClick(e); + } + }, + + doheadercontextmenu: function(e){ + if(e.cellNode){ + this.onHeaderCellContextMenu(e); + }else{ + this.onHeaderContextMenu(e); + } + }, + + // override to modify editing process + doStartEdit: function(inCell, inRowIndex){ + this.onStartEdit(inCell, inRowIndex); + }, + + doApplyCellEdit: function(inValue, inRowIndex, inFieldIndex){ + this.onApplyCellEdit(inValue, inRowIndex, inFieldIndex); + }, + + doCancelEdit: function(inRowIndex){ + this.onCancelEdit(inRowIndex); + }, + + doApplyEdit: function(inRowIndex){ + this.onApplyEdit(inRowIndex); + }, + + // row editing + addRow: function(){ + // summary: + // Add a row to the grid. + this.updateRowCount(this.rowCount+1); + }, + + removeSelectedRows: function(){ + // summary: + // Remove the selected rows from the grid. + this.updateRowCount(Math.max(0, this.rowCount - this.selection.getSelected().length)); + this.selection.clear(); + } + +}); + +dojo.mixin(dojox.VirtualGrid.prototype, dojox.grid.publicEvents); + +} diff --git a/includes/js/dojox/grid/_data/dijitEditors.js b/includes/js/dojox/grid/_data/dijitEditors.js new file mode 100644 index 0000000..695de44 --- /dev/null +++ b/includes/js/dojox/grid/_data/dijitEditors.js @@ -0,0 +1,170 @@ +if(!dojo._hasResource["dojox.grid._data.dijitEditors"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._data.dijitEditors"] = true; +dojo.provide("dojox.grid._data.dijitEditors"); +dojo.require("dojox.grid._data.editors"); +dojo.require("dijit.form.DateTextBox"); +dojo.require("dijit.form.TimeTextBox"); +dojo.require("dijit.form.ComboBox"); +dojo.require("dojo.data.ItemFileReadStore"); +dojo.require("dijit.form.CheckBox"); +dojo.require("dijit.form.TextBox"); +dojo.require("dijit.form.NumberSpinner"); +dojo.require("dijit.form.NumberTextBox"); +dojo.require("dijit.form.CurrencyTextBox"); +dojo.require("dijit.form.Slider"); +dojo.require("dijit.Editor"); + +dojo.declare("dojox.grid.editors.Dijit", dojox.grid.editors.base, { + editorClass: "dijit.form.TextBox", + constructor: function(inCell){ + this.editor = null; + this.editorClass = dojo.getObject(this.cell.editorClass || this.editorClass); + }, + format: function(inDatum, inRowIndex){ + this.needFormatNode(inDatum, inRowIndex); + return "
"; + }, + getValue: function(inRowIndex){ + return this.editor.getValue(); + }, + setValue: function(inRowIndex, inValue){ + if(this.editor&&this.editor.setValue){ + this.editor.setValue(inValue); + }else{ + this.inherited(arguments); + } + }, + getEditorProps: function(inDatum){ + return dojo.mixin({}, this.cell.editorProps||{}, { + constraints: dojo.mixin({}, this.cell.constraint) || {}, //TODO: really just for ValidationTextBoxes + value: inDatum + }); + }, + createEditor: function(inNode, inDatum, inRowIndex){ + return new this.editorClass(this.getEditorProps(inDatum), inNode); + + }, + attachEditor: function(inNode, inDatum, inRowIndex){ + inNode.appendChild(this.editor.domNode); + this.setValue(inRowIndex, inDatum); + }, + formatNode: function(inNode, inDatum, inRowIndex){ + if(!this.editorClass){ + return inDatum; + } + if(!this.editor){ + this.editor = this.createEditor.apply(this, arguments); + }else{ + this.attachEditor.apply(this, arguments); + } + this.sizeEditor.apply(this, arguments); + this.cell.grid.rowHeightChanged(inRowIndex); + this.focus(); + }, + sizeEditor: function(inNode, inDatum, inRowIndex){ + var + p = this.cell.getNode(inRowIndex), + box = dojo.contentBox(p); + dojo.marginBox(this.editor.domNode, {w: box.w}); + }, + focus: function(inRowIndex, inNode){ + if(this.editor){ + setTimeout(dojo.hitch(this.editor, function(){ + dojox.grid.fire(this, "focus"); + }), 0); + } + }, + _finish: function(inRowIndex){ + this.inherited(arguments); + dojox.grid.removeNode(this.editor.domNode); + } +}); + +dojo.declare("dojox.grid.editors.ComboBox", dojox.grid.editors.Dijit, { + editorClass: "dijit.form.ComboBox", + getEditorProps: function(inDatum){ + var items=[]; + dojo.forEach(this.cell.options, function(o){ + items.push({name: o, value: o}); + }); + var store = new dojo.data.ItemFileReadStore({data: {identifier:"name", items: items}}); + return dojo.mixin({}, this.cell.editorProps||{}, { + value: inDatum, + store: store + }); + }, + getValue: function(){ + var e = this.editor; + // make sure to apply the displayed value + e.setDisplayedValue(e.getDisplayedValue()); + return e.getValue(); + } +}); + +dojo.declare("dojox.grid.editors.DateTextBox", dojox.grid.editors.Dijit, { + editorClass: "dijit.form.DateTextBox", + setValue: function(inRowIndex, inValue){ + if(this.editor){ + this.editor.setValue(new Date(inValue)); + }else{ + this.inherited(arguments); + } + }, + getEditorProps: function(inDatum){ + return dojo.mixin(this.inherited(arguments), { + value: new Date(inDatum) + }); + } +}); + + +dojo.declare("dojox.grid.editors.CheckBox", dojox.grid.editors.Dijit, { + editorClass: "dijit.form.CheckBox", + getValue: function(){ + return this.editor.checked; + }, + setValue: function(inRowIndex, inValue){ + if(this.editor&&this.editor.setAttribute){ + this.editor.setAttribute("checked", inValue); + }else{ + this.inherited(arguments); + } + }, + sizeEditor: function(inNode, inDatum, inRowIndex){ + return; + } +}); + + +dojo.declare("dojox.grid.editors.Editor", dojox.grid.editors.Dijit, { + editorClass: "dijit.Editor", + getEditorProps: function(inDatum){ + return dojo.mixin({}, this.cell.editorProps||{}, { + height: this.cell.editorHeight || "100px" + }); + }, + createEditor: function(inNode, inDatum, inRowIndex){ + // editor needs its value set after creation + var editor = new this.editorClass(this.getEditorProps(inDatum), inNode); + dojo.connect(editor, 'onLoad', dojo.hitch(this, 'populateEditor')); + return editor; + }, + formatNode: function(inNode, inDatum, inRowIndex){ + this.content = inDatum; + this.inherited(arguments); + if(dojo.isMoz){ + // FIXME: seem to need to reopen the editor and display the toolbar + var e = this.editor; + e.open(); + if(this.cell.editorToolbar){ + dojo.place(e.toolbar.domNode, e.editingArea, "before"); + } + } + }, + populateEditor: function(){ + this.editor.setValue(this.content); + this.editor.placeCursorAtEnd(); + } +}); + +} diff --git a/includes/js/dojox/grid/_data/editors.js b/includes/js/dojox/grid/_data/editors.js new file mode 100644 index 0000000..48f76cc --- /dev/null +++ b/includes/js/dojox/grid/_data/editors.js @@ -0,0 +1,239 @@ +if(!dojo._hasResource["dojox.grid._data.editors"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._data.editors"] = true; +dojo.provide("dojox.grid._data.editors"); +dojo.provide("dojox.grid.editors"); + +dojo.declare("dojox.grid.editors.Base", null, { + // summary: + // base grid editor class. Other grid editors should inherited from this class. + constructor: function(inCell){ + this.cell = inCell; + }, + //private + _valueProp: "value", + _formatPending: false, + format: function(inDatum, inRowIndex){ + // summary: + // formats the cell for editing + // inDatum: anything + // cell data to edit + // inRowIndex: int + // grid row index + // returns: string of html to place in grid cell + }, + //protected + needFormatNode: function(inDatum, inRowIndex){ + this._formatPending = true; + dojox.grid.whenIdle(this, "_formatNode", inDatum, inRowIndex); + }, + cancelFormatNode: function(){ + this._formatPending = false; + }, + //private + _formatNode: function(inDatum, inRowIndex){ + if(this._formatPending){ + this._formatPending = false; + // make cell selectable + dojo.setSelectable(this.cell.grid.domNode, true); + this.formatNode(this.getNode(inRowIndex), inDatum, inRowIndex); + } + }, + //protected + getNode: function(inRowIndex){ + return (this.cell.getNode(inRowIndex) || 0).firstChild || 0; + }, + formatNode: function(inNode, inDatum, inRowIndex){ + // summary: + // format the editing dom node. Use when editor is a widget. + // inNode: dom node + // dom node for the editor + // inDatum: anything + // cell data to edit + // inRowIndex: int + // grid row index + if(dojo.isIE){ + // IE sux bad + dojox.grid.whenIdle(this, "focus", inRowIndex, inNode); + }else{ + this.focus(inRowIndex, inNode); + } + }, + dispatchEvent: function(m, e){ + if(m in this){ + return this[m](e); + } + }, + //public + getValue: function(inRowIndex){ + // summary: + // returns value entered into editor + // inRowIndex: int + // grid row index + // returns: + // value of editor + return this.getNode(inRowIndex)[this._valueProp]; + }, + setValue: function(inRowIndex, inValue){ + // summary: + // set the value of the grid editor + // inRowIndex: int + // grid row index + // inValue: anything + // value of editor + var n = this.getNode(inRowIndex); + if(n){ + n[this._valueProp] = inValue + }; + }, + focus: function(inRowIndex, inNode){ + // summary: + // focus the grid editor + // inRowIndex: int + // grid row index + // inNode: dom node + // editor node + dojox.grid.focusSelectNode(inNode || this.getNode(inRowIndex)); + }, + save: function(inRowIndex){ + // summary: + // save editor state + // inRowIndex: int + // grid row index + this.value = this.value || this.getValue(inRowIndex); + //console.log("save", this.value, inCell.index, inRowIndex); + }, + restore: function(inRowIndex){ + // summary: + // restore editor state + // inRowIndex: int + // grid row index + this.setValue(inRowIndex, this.value); + //console.log("restore", this.value, inCell.index, inRowIndex); + }, + //protected + _finish: function(inRowIndex){ + // summary: + // called when editing is completed to clean up editor + // inRowIndex: int + // grid row index + dojo.setSelectable(this.cell.grid.domNode, false); + this.cancelFormatNode(this.cell); + }, + //public + apply: function(inRowIndex){ + // summary: + // apply edit from cell editor + // inRowIndex: int + // grid row index + this.cell.applyEdit(this.getValue(inRowIndex), inRowIndex); + this._finish(inRowIndex); + }, + cancel: function(inRowIndex){ + // summary: + // cancel cell edit + // inRowIndex: int + // grid row index + this.cell.cancelEdit(inRowIndex); + this._finish(inRowIndex); + } +}); +dojox.grid.editors.base = dojox.grid.editors.Base; // back-compat + +dojo.declare("dojox.grid.editors.Input", dojox.grid.editors.Base, { + // summary + // grid cell editor that provides a standard text input box + constructor: function(inCell){ + this.keyFilter = this.keyFilter || this.cell.keyFilter; + }, + // keyFilter: object + // optional regex for disallowing keypresses + keyFilter: null, + format: function(inDatum, inRowIndex){ + this.needFormatNode(inDatum, inRowIndex); + return ''; + }, + formatNode: function(inNode, inDatum, inRowIndex){ + this.inherited(arguments); + // FIXME: feels too specific for this interface + this.cell.registerOnBlur(inNode, inRowIndex); + }, + doKey: function(e){ + if(this.keyFilter){ + var key = String.fromCharCode(e.charCode); + if(key.search(this.keyFilter) == -1){ + dojo.stopEvent(e); + } + } + }, + _finish: function(inRowIndex){ + this.inherited(arguments); + var n = this.getNode(inRowIndex); + try{ + dojox.grid.fire(n, "blur"); + }catch(e){} + } +}); +dojox.grid.editors.input = dojox.grid.editors.Input; // back compat + +dojo.declare("dojox.grid.editors.Select", dojox.grid.editors.Input, { + // summary: + // grid cell editor that provides a standard select + // options: text of each item + // values: value for each item + // returnIndex: editor returns only the index of the selected option and not the value + constructor: function(inCell){ + this.options = this.options || this.cell.options; + this.values = this.values || this.cell.values || this.options; + }, + format: function(inDatum, inRowIndex){ + this.needFormatNode(inDatum, inRowIndex); + var h = [ ''); + return h.join(''); + }, + getValue: function(inRowIndex){ + var n = this.getNode(inRowIndex); + if(n){ + var i = n.selectedIndex, o = n.options[i]; + return this.cell.returnIndex ? i : o.value || o.innerHTML; + } + } +}); +dojox.grid.editors.select = dojox.grid.editors.Select; // back compat + +dojo.declare("dojox.grid.editors.AlwaysOn", dojox.grid.editors.Input, { + // summary: + // grid cell editor that is always on, regardless of grid editing state + // alwaysOn: boolean + // flag to use editor to format grid cell regardless of editing state. + alwaysOn: true, + _formatNode: function(inDatum, inRowIndex){ + this.formatNode(this.getNode(inRowIndex), inDatum, inRowIndex); + }, + applyStaticValue: function(inRowIndex){ + var e = this.cell.grid.edit; + e.applyCellEdit(this.getValue(inRowIndex), this.cell, inRowIndex); + e.start(this.cell, inRowIndex, true); + } +}); +dojox.grid.editors.alwaysOn = dojox.grid.editors.AlwaysOn; // back-compat + +dojo.declare("dojox.grid.editors.Bool", dojox.grid.editors.AlwaysOn, { + // summary: + // grid cell editor that provides a standard checkbox that is always on + _valueProp: "checked", + format: function(inDatum, inRowIndex){ + return ''; + }, + doclick: function(e){ + if(e.target.tagName == 'INPUT'){ + this.applyStaticValue(e.rowIndex); + } + } +}); +dojox.grid.editors.bool = dojox.grid.editors.Bool; // back-compat + +} diff --git a/includes/js/dojox/grid/_data/fields.js b/includes/js/dojox/grid/_data/fields.js new file mode 100644 index 0000000..230bede --- /dev/null +++ b/includes/js/dojox/grid/_data/fields.js @@ -0,0 +1,104 @@ +if(!dojo._hasResource["dojox.grid._data.fields"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._data.fields"] = true; +dojo.provide("dojox.grid._data.fields"); + +dojo.declare("dojox.grid.data.Mixer", null, { + // summary: + // basic collection class that provides a default value for items + + constructor: function(){ + this.defaultValue = {}; + this.values = []; + }, + count: function(){ + return this.values.length; + }, + clear: function(){ + this.values = []; + }, + build: function(inIndex){ + var result = dojo.mixin({owner: this}, this.defaultValue); + result.key = inIndex; + this.values[inIndex] = result; + return result; + }, + getDefault: function(){ + return this.defaultValue; + }, + setDefault: function(inField /*[, inField2, ... inFieldN] */){ + for(var i=0, a; (a = arguments[i]); i++){ + dojo.mixin(this.defaultValue, a); + } + }, + get: function(inIndex){ + return this.values[inIndex] || this.build(inIndex); + }, + _set: function(inIndex, inField /*[, inField2, ... inFieldN] */){ + // each field argument can be a single field object of an array of field objects + var v = this.get(inIndex); + for(var i=1; i= this.values.length){ + this.values[inIndex] = inProps; + }else{ + this.values.splice(inIndex, 0, inProps); + } + }, + remove: function(inIndex){ + this.values.splice(inIndex, 1); + }, + swap: function(inIndexA, inIndexB){ + dojox.grid.arraySwap(this.values, inIndexA, inIndexB); + }, + move: function(inFromIndex, inToIndex){ + dojox.grid.arrayMove(this.values, inFromIndex, inToIndex); + } +}); + +dojox.grid.data.compare = function(a, b){ + return (a > b ? 1 : (a == b ? 0 : -1)); +} + +dojo.declare('dojox.grid.data.Field', null, { + constructor: function(inName){ + this.name = inName; + this.compare = dojox.grid.data.compare; + }, + na: dojox.grid.na +}); + +dojo.declare('dojox.grid.data.Fields', dojox.grid.data.Mixer, { + constructor: function(inFieldClass){ + var fieldClass = inFieldClass ? inFieldClass : dojox.grid.data.Field; + this.defaultValue = new fieldClass(); + }, + indexOf: function(inKey){ + for(var i=0; i=0; i--){ + idx = inIndices[i]; + col = Math.abs(idx) - 1; + if(col >= 0){ + field = this.fields.get(col); + result = this.generateComparator(field.compare, field.key, idx > 0, result); + } + } + return result; + }, + sort: null, + dummy: 0 +}); + +dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { + // observer events + allChange: function(){ + this.notify("AllChange", arguments); + this.notify("Change", arguments); + }, + rowChange: function(){ + this.notify("RowChange", arguments); + }, + datumChange: function(){ + this.notify("DatumChange", arguments); + }, + // copyRow: function(inRowIndex); // abstract + // update + beginModifyRow: function(inRowIndex){ + if(!this.cache[inRowIndex]){ + this.cache[inRowIndex] = this.copyRow(inRowIndex); + } + }, + endModifyRow: function(inRowIndex){ + var cache = this.cache[inRowIndex]; + if(cache){ + var data = this.getRow(inRowIndex); + if(!dojox.grid.arrayCompare(cache, data)){ + this.update(cache, data, inRowIndex); + } + delete this.cache[inRowIndex]; + } + }, + cancelModifyRow: function(inRowIndex){ + var cache = this.cache[inRowIndex]; + if(cache){ + this.setRow(cache, inRowIndex); + delete this.cache[inRowIndex]; + } + } +}); + +dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { + // summary: + // Basic grid data model for static data in the form of an array of rows + // that are arrays of cell data + constructor: function(){ + this.cache = []; + }, + colCount: 0, // tables introduce cols + data: null, + cache: null, + // morphology + measure: function(){ + this.count = this.getRowCount(); + this.colCount = this.getColCount(); + this.allChange(); + //this.notify("Measure"); + }, + getRowCount: function(){ + return (this.data ? this.data.length : 0); + }, + getColCount: function(){ + return (this.data && this.data.length ? this.data[0].length : this.fields.count()); + }, + badIndex: function(inCaller, inDescriptor){ + console.debug('dojox.grid.data.Table: badIndex'); + }, + isGoodIndex: function(inRowIndex, inColIndex){ + return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); + }, + // access + getRow: function(inRowIndex){ + return this.data[inRowIndex]; + }, + copyRow: function(inRowIndex){ + return this.getRow(inRowIndex).slice(0); + }, + getDatum: function(inRowIndex, inColIndex){ + return this.data[inRowIndex][inColIndex]; + }, + get: function(){ + throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); + }, + setData: function(inData){ + this.data = (inData || []); + this.allChange(); + }, + setRow: function(inData, inRowIndex){ + this.data[inRowIndex] = inData; + this.rowChange(inData, inRowIndex); + this.change(); + }, + setDatum: function(inDatum, inRowIndex, inColIndex){ + this.data[inRowIndex][inColIndex] = inDatum; + this.datumChange(inDatum, inRowIndex, inColIndex); + }, + set: function(){ + throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); + }, + setRows: function(inData, inRowIndex){ + for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ + dojox.grid.arrayRemove(this.data, inKeys[i]); + } + this.count -= inKeys.length; + return true; + }, + // sort + sort: function(/* (+|-)column_index+1, ... */){ + this.data.sort(this.makeComparator(arguments)); + }, + swap: function(inIndexA, inIndexB){ + dojox.grid.arraySwap(this.data, inIndexA, inIndexB); + this.rowChange(this.getRow(inIndexA), inIndexA); + this.rowChange(this.getRow(inIndexB), inIndexB); + this.change(); + }, + dummy: 0 +}); + +dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { + constructor: function(inFields, inData, inKey){ + if(!inFields){ + this.autoAssignFields(); + } + }, + allChange: function(){ + this.notify("FieldsChange"); + this.inherited(arguments); + }, + autoAssignFields: function(){ + var d = this.data[0], i = 0, field; + for(var f in d){ + field = this.fields.get(i++); + if (!dojo.isString(field.key)){ + field.key = f; + } + } + }, + setData: function(inData){ + this.data = (inData || []); + this.autoAssignFields(); + this.allChange(); + }, + getDatum: function(inRowIndex, inColIndex){ + return this.data[inRowIndex][this.fields.get(inColIndex).key]; + } +}); + +dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { + // summary: + // Grid data model for dynamic data such as data retrieved from a server. + // Retrieves data automatically when requested and provides notification when data is received + constructor: function(){ + this.page = []; + this.pages = []; + }, + page: null, + pages: null, + rowsPerPage: 100, + requests: 0, + bop: -1, + eop: -1, + // data + clearData: function(){ + this.pages = []; + this.bop = this.eop = -1; + this.setData([]); + }, + getRowCount: function(){ + return this.count; + }, + getColCount: function(){ + return this.fields.count(); + }, + setRowCount: function(inCount){ + this.count = inCount; + this.change(); + }, + // paging + requestsPending: function(inBoolean){ + }, + rowToPage: function(inRowIndex){ + return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); + }, + pageToRow: function(inPageIndex){ + return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); + }, + requestRows: function(inRowIndex, inCount){ + // summary: + // stub. Fill in to perform actual data row fetching logic. The + // returning logic must provide the data back to the system via + // setRow + }, + rowsProvided: function(inRowIndex, inCount){ + this.requests--; + if(this.requests == 0){ + this.requestsPending(false); + } + }, + requestPage: function(inPageIndex){ + var row = this.pageToRow(inPageIndex); + var count = Math.min(this.rowsPerPage, this.count - row); + if(count > 0){ + this.requests++; + this.requestsPending(true); + setTimeout(dojo.hitch(this, "requestRows", row, count), 1); + //this.requestRows(row, count); + } + }, + needPage: function(inPageIndex){ + if(!this.pages[inPageIndex]){ + this.pages[inPageIndex] = true; + this.requestPage(inPageIndex); + } + }, + preparePage: function(inRowIndex, inColIndex){ + if(inRowIndex < this.bop || inRowIndex >= this.eop){ + var pageIndex = this.rowToPage(inRowIndex); + this.needPage(pageIndex); + this.bop = pageIndex * this.rowsPerPage; + this.eop = this.bop + (this.rowsPerPage || this.count); + } + }, + isRowLoaded: function(inRowIndex){ + return Boolean(this.data[inRowIndex]); + }, + // removal + removePages: function(inRowIndexes){ + for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ + this.pages[this.rowToPage(r)] = false; + } + this.bop = this.eop =-1; + }, + remove: function(inRowIndexes){ + this.removePages(inRowIndexes); + dojox.grid.data.Table.prototype.remove.apply(this, arguments); + }, + // access + getRow: function(inRowIndex){ + var row = this.data[inRowIndex]; + if(!row){ + this.preparePage(inRowIndex); + } + return row; + }, + getDatum: function(inRowIndex, inColIndex){ + var row = this.getRow(inRowIndex); + return (row ? row[inColIndex] : this.fields.get(inColIndex).na); + }, + setDatum: function(inDatum, inRowIndex, inColIndex){ + var row = this.getRow(inRowIndex); + if(row){ + row[inColIndex] = inDatum; + this.datumChange(inDatum, inRowIndex, inColIndex); + }else{ + console.debug('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on an non-loaded row'); + } + }, + // sort + canSort: function(){ + return false; + } +}); + +// FIXME: deprecated: (included for backward compatibility only) +dojox.grid.data.table = dojox.grid.data.Table; +dojox.grid.data.dynamic = dojox.grid.data.Dynamic; + +// we treat dojo.data stores as dynamic stores because no matter how they got +// here, they should always fill that contract +dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { + // summary: + // A grid data model for dynamic data retreived from a store which + // implements the dojo.data API set. Retrieves data automatically when + // requested and provides notification when data is received + // description: + // This store subclasses the Dynamic grid data object in order to + // provide paginated data access support, notification and view + // updates for stores which support those features, and simple + // field/column mapping for all dojo.data stores. + constructor: function(inFields, inData, args){ + this.count = 1; + this._rowIdentities = {}; + this._currentlyProcessing = []; + if(args){ + dojo.mixin(this, args); + } + if(this.store){ + var f = this.store.getFeatures(); + this._canNotify = f['dojo.data.api.Notification']; + this._canWrite = f['dojo.data.api.Write']; + this._canIdentify = f['dojo.data.api.Identity']; + if(this._canNotify){ + dojo.connect(this.store, "onSet", this, "_storeDatumChange"); + dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); + dojo.connect(this.store, "onNew", this, "_storeDatumNew"); + } + if(this._canWrite) { + dojo.connect(this.store, "revert", this, "refresh"); + } + } + }, + markupFactory: function(args, node){ + return new dojox.grid.data.DojoData(null, null, args); + }, + query: { name: "*" }, // default, stupid query + store: null, + _currentlyProcessing: null, + _canNotify: false, + _canWrite: false, + _canIdentify: false, + _rowIdentities: {}, + clientSort: false, + sortFields: null, + queryOptions: null, + + // data + setData: function(inData){ + this.store = inData; + this.data = []; + this.allChange(); + }, + setRowCount: function(inCount){ + //console.debug("inCount:", inCount); + this.count = inCount; + this.allChange(); + }, + beginReturn: function(inCount){ + if(this.count != inCount){ + // this.setRowCount(0); + // this.clear(); + // console.debug(this.count, inCount); + this.setRowCount(inCount); + } + }, + _setupFields: function(dataItem){ + // abort if we already have setup fields + if(this.fields._nameMaps){ + return; + } + // set up field/index mappings + var m = {}; + //console.debug("setting up fields", m); + var fields = dojo.map(this.store.getAttributes(dataItem), + function(item, idx){ + m[item] = idx; + m[idx+".idx"] = item; + // name == display name, key = property name + return { name: item, key: item }; + }, + this + ); + this.fields._nameMaps = m; + // console.debug("new fields:", fields); + this.fields.set(fields); + this.notify("FieldsChange"); + }, + _getRowFromItem: function(item){ + // gets us the row object (and row index) of an item + }, + _createRow: function(item){ + var row = {}; + row.__dojo_data_item = item; + dojo.forEach(this.fields.values, function(a){ + value = this.store.getValue(item, a.name); + row[a.name] = (value === undefined || value === null)?"":value; + }, this); + return row; + }, + processRows: function(items, request){ + // console.debug(arguments); + if(!items || items.length == 0){ return; } + this._setupFields(items[0]); + dojo.forEach(items, function(item, idx){ + var row = this._createRow(item); + this._setRowId(item, request.start, idx); + this.setRow(row, request.start+idx); + }, this); + // FIXME: + // Q: scott, steve, how the hell do we actually get this to update + // the visible UI for these rows? + // A: the goal is that Grid automatically updates to reflect changes + // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow + }, + // request data + requestRows: function(inRowIndex, inCount){ + var row = inRowIndex || 0; + var params = { + start: row, + count: this.rowsPerPage, + query: this.query, + sort: this.sortFields, + queryOptions: this.queryOptions, + onBegin: dojo.hitch(this, "beginReturn"), + onComplete: dojo.hitch(this, "processRows"), // add to deferred? + onError: dojo.hitch(this, "processError") + }; + this.store.fetch(params); + }, + getDatum: function(inRowIndex, inColIndex){ + //console.debug("getDatum", inRowIndex, inColIndex); + var row = this.getRow(inRowIndex); + var field = this.fields.values[inColIndex]; + return row && field ? row[field.name] : field ? field.na : '?'; + //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; + //return (row ? row[idx] : this.fields.get(inColIndex).na); + }, + setDatum: function(inDatum, inRowIndex, inColIndex){ + var n = this.fields._nameMaps[inColIndex+".idx"]; + // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); + if(n){ + this.data[inRowIndex][n] = inDatum; + this.datumChange(inDatum, inRowIndex, inColIndex); + } + }, + // modification, update and store eventing + copyRow: function(inRowIndex){ + var row = {}; + var backstop = {}; + var src = this.getRow(inRowIndex); + for(var x in src){ + if(src[x] != backstop[x]){ + row[x] = src[x]; + } + } + return row; + }, + _attrCompare: function(cache, data){ + dojo.forEach(this.fields.values, function(a){ + if(cache[a.name] != data[a.name]){ return false; } + }, this); + return true; + }, + endModifyRow: function(inRowIndex){ + var cache = this.cache[inRowIndex]; + if(cache){ + var data = this.getRow(inRowIndex); + if(!this._attrCompare(cache, data)){ + this.update(cache, data, inRowIndex); + } + delete this.cache[inRowIndex]; + } + }, + cancelModifyRow: function(inRowIndex){ + // console.debug("cancelModifyRow", arguments); + var cache = this.cache[inRowIndex]; + if(cache){ + this.setRow(cache, inRowIndex); + delete this.cache[inRowIndex]; + } + }, + _setRowId: function(item, offset, idx){ + // FIXME: where else do we need to keep this in sync? + //Handle stores that implement identity and try to handle those that do not. + if (this._canIdentify) { + this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; + }else{ + var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); + this._rowIdentities[identity] = {rowId: offset+idx, item: item}; + } + }, + _getRowId: function(item, isNotItem){ + // summary: + // Function determine the row index for a particular item + // item: + // The store item to examine to determine row index. + // isNotItem: + // Boolean flag to indicate if the item passed is a store item or not. + var rowId = null; + //Handle identity and nonidentity capable stores. + if(this._canIdentify && !isNotItem){ + rowId = this._rowIdentities[this.store.getIdentity(item)].rowId; + }else{ + //Not efficient, but without identity support, + //not a better way to do it. Basically, do our best to locate it + //This may or may not work, but best we can do here. + var id; + for(id in this._rowIdentities){ + if(this._rowIdentities[id].item === item){ + rowId = this._rowIdentities[id].rowId; + break; + } + } + } + return rowId; + }, + _storeDatumChange: function(item, attr, oldVal, newVal){ + // the store has changed some data under us, need to update the display + var rowId = this._getRowId(item); + var row = this.getRow(rowId); + if(row){ + row[attr] = newVal; + var colId = this.fields._nameMaps[attr]; + this.notify("DatumChange", [ newVal, rowId, colId ]); + } + }, + _storeDatumDelete: function(item){ + if(dojo.indexOf(this._currentlyProcessing, item) != -1) + return; + // the store has deleted some item under us, need to remove that item from + // the view if possible. It may be the deleted item isn't even in the grid. + var rowId = this._getRowId(item, true); + if(rowId != null){ + this._removeItems([rowId]); + } + }, + _storeDatumNew: function(item){ + if(this._disableNew){ + return; + } + // the store has added some item under us, need to add it to the view. + this._insertItem(item, this.data.length); + }, + insert: function(item, index){ + // Push the given item back to the store + this._disableNew = true; + var i = this.store.newItem(item); + this._disableNew = false; + this._insertItem(i, index); + }, + _insertItem: function(storeItem, index){ + // Set up our fields if we haven't already + if(!this.fields._nameMaps){ + this._setupFields(storeItem); + } + var row = this._createRow(storeItem); + for(var i in this._rowIdentities){ //increment all the remaining row ids up one + var rowIdentity = this._rowIdentities[i]; + if(rowIdentity.rowId >= index){ + rowIdentity.rowId++; + } + } + this._setRowId(storeItem, 0, index); + dojox.grid.data.Dynamic.prototype.insert.apply(this, [row, index]); + }, + datumChange: function(value, rowIdx, colIdx){ + if(this._canWrite){ + // we're chaning some data, which means we need to write back + var row = this.getRow(rowIdx); + var field = this.fields._nameMaps[colIdx+".idx"]; + this.store.setValue(row.__dojo_data_item, field, value); + // we don't need to call DatumChange, an eventing store will tell + // us about the row change events + }else{ + // we can't write back, so just go ahead and change our local copy + // of the data + this.notify("DatumChange", arguments); + } + }, + insertion: function(/* index */){ + console.debug("Insertion", arguments); + this.notify("Insertion", arguments); + this.notify("Change", arguments); + }, + removal: function(/* keys */){ + console.debug("Removal", arguments); + this.notify("Removal", arguments); + this.notify("Change", arguments); + }, + remove: function(inRowIndexes){ + // summary: + // Function to remove a set of items from the store based on the row index. + // inRowIndexes: + // An array of row indexes from the grid to remove from the store. + /* Call delete on the store */ + for(var i=inRowIndexes.length-1; i>=0; i--){ + // Need to find the item, then remove each from the data store + var item = this.data[inRowIndexes[i]].__dojo_data_item; + this._currentlyProcessing.push(item); + this.store.deleteItem(item); + } + /* Remove from internal data structure and the view */ + this._removeItems(inRowIndexes); + this._currentlyProcessing = []; + }, + _removeItems: function(inRowIndexes /*array*/){ + // summary: + // Function to remove a set of items from the store based on the row index. + // inRowIndexes: + // An array of row indexes from the grid to remove from the store. + dojox.grid.data.Dynamic.prototype.remove.apply(this, arguments); + // Rebuild _rowIdentities + this._rowIdentities = {}; + for (var i = 0; i < this.data.length; i++){ + this._setRowId(this.data[i].__dojo_data_item, 0, i); + } + }, + canSort: function(){ + // Q: Return true and re-issue the queries? + // A: Return true only. Re-issue the query in 'sort'. + // Note, above are original comments :) + return true; + }, + sort: function(colIndex){ + var col = Math.abs(colIndex) - 1; + this.sortFields = [{'attribute': this.fields.values[col].name, 'descending': (colIndex>0)}]; + + // Since we're relying on the data store to sort, we have to refresh our data. + this.refresh(); + }, + refresh: function(){ + // summary: + // Function to cause the model to re-query the store and rebuild the current viewport. + this.clearData(true); + this.requestRows(); + }, + clearData: function(/* boolean */ keepStore){ + this._rowIdentities = {}; + this.pages = []; + this.bop = this.eop = -1; + this.count = 0; + this.setData((keepStore?this.store:[])); + }, + processError: function(error, request){ + // summary: + // Hook function to trap error messages from the store and emit them. + // Intended for connecting to and handling the error object or at least reporting it. + // + // error: + // The error object returned by the store when a problem occurred. + // request: + // The request object that caused the error. + console.log(error); + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/Grid.css b/includes/js/dojox/grid/_grid/Grid.css new file mode 100644 index 0000000..655be54 --- /dev/null +++ b/includes/js/dojox/grid/_grid/Grid.css @@ -0,0 +1,201 @@ +.dojoxGrid { + position: relative; + background-color: #EBEADB; + font-family: Geneva, Arial, Helvetica, sans-serif; + -moz-outline-style: none; + outline: none; + overflow: hidden; + height: 0; +} +.dojoxGrid table { + padding: 0; +} +.dojoxGrid td { + -moz-outline: none; +} +.dojoxGrid-master-header { + position: relative; +} +.dojoxGrid-master-view { + position: relative; +} +.dojoxGrid-view { + position: absolute; + overflow: hidden; +} +.dojoxGrid-header { + position: absolute; + overflow: hidden; +} +.dojoxGrid-header { + background-color: #E8E1CF; +} +.dojoxGrid-header table { + text-align: center; +} +.dojoxGrid-header .dojoxGrid-cell-content { + text-align: center; +} +.dojoxGrid-header .dojoxGrid-cell { + border: 1px solid; + border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; + background: url(images/grid_dx_gradient.gif) #E8E1CF top repeat-x; + padding-bottom: 2px; +} +.dojoxGrid-header .dojoxGrid-cell-over { + background-image: none; + background-color: white; + border-bottom-color: #FEBE47; + margin-bottom: 0; + padding-bottom: 0; + border-bottom-width: 3px; +} +.dojoxGrid-sort-down { + background: url(images/grid_sort_down.gif) left no-repeat; + padding-left:16px; + margin-left:4px; +} +.dojoxGrid-sort-up { + background: url(images/grid_sort_up.gif) left no-repeat; + padding-left:16px; + margin-left:4px; +} +.dojoxGrid-scrollbox { + position: relative; + overflow: scroll; + background-color: white; + width: 100%; +} +.dojoxGrid-content { + position: relative; + overflow: hidden; + -moz-outline-style: none; + outline: none; +} +.dojoxGrid-rowbar { + border: 1px solid; + border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; + border-top: none; + background: url(images/grid_dx_gradient.gif) #E8E1CF top repeat-x; +} +.dojoxGrid-rowbar-inner { + border-top: 1px solid #F6F4EB; +} +.dojoxGrid-rowbar-over { + background-image: none; + background-color: white; + border-top-color: #FEBE47; + border-bottom-color: #FEBE47; +} +.dojoxGrid-rowbar-selected { + background-color: #D9E8F9; + background-image: none; + + background-position: center; + background-repeat: no-repeat; +} +.dojoxGrid-row { + position: relative; + width: 9000em; +} +.dojoxGrid-row { + + border: 1px solid #E8E4D8; + border-color: #F8F7F1; + + border-left: none; + border-right: none; + background-color: white; + border-top: none; +} +.dojoxGrid-row-over { + border-top-color: #FEBE47; + border-bottom-color: #FEBE47; + + + +} +.dojoxGrid-row-odd { + background-color: #FFFDF3; + +} +.dojoxGrid-row-selected { + background-color: #D9E8F9; +} +.dojoxGrid-row-table { + table-layout: fixed; + width: 0; +} +.dojoxGrid-invisible { + visibility: hidden; +} +.Xdojo-ie .dojoxGrid-invisible { + display: none; +} +.dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td { + border-top-width: 0; + border-bottom-width: 0; + padding-top: 0; + padding-bottom: 0; + height: 0; + overflow: hidden; +} +.dojoxGrid-cell { + border: 1px solid; + border-color: #EBEADB; + border-right-color: #D5CDB5; + padding: 3px 3px 3px 3px; + text-align: left; + overflow: hidden; +} +.dojoxGrid-cell-focus { + border: 1px dashed blue; +} +.dojoxGrid-cell-over { + border: 1px dotted #FEBE47; +} +.dojoxGrid-cell-focus.dojoxGrid-cell-over { + border: 1px dotted green; +} +.dojoxGrid-cell-clip { + width: 100%; + overflow: hidden; + white-space:nowrap; + text-overflow: ellipsis; +} +.dojoxGrid-row-editing td { + background-color: #F4FFF4; +} +.dojoxGrid-row-inserting td { + background-color: #F4FFF4; +} +.dojoxGrid-row-inflight td { + background-color: #F2F7B7; +} +.dojoxGrid-row-error td { + background-color: #F8B8B6; +} +.dojoxGrid-input, .dojoxGrid-select, .dojoxGrid-textarea { + margin: 0; + padding: 0; + border-style: none; + width: 100%; + font-size: 100%; + font-family: inherit; +} +.dojoxGrid-hidden-focus { + position: absolute; + left: -1000px; + top: -1000px; + height: 0px, width: 0px; +} +.gridArrowButtonChar { + display:none !important; +} +.dijit_a11y .gridArrowButtonChar { + display:inline !important; +} +.dijit_a11y .dojoxGrid-sort-down, .dijit_a11y .dojoxGrid-sort-up { + margin-left: 0; + padding-left: 0; +} diff --git a/includes/js/dojox/grid/_grid/Grid.css.commented.css b/includes/js/dojox/grid/_grid/Grid.css.commented.css new file mode 100644 index 0000000..227ffa3 --- /dev/null +++ b/includes/js/dojox/grid/_grid/Grid.css.commented.css @@ -0,0 +1,258 @@ +.dojoxGrid { + position: relative; + background-color: #EBEADB; + font-family: Geneva, Arial, Helvetica, sans-serif; + -moz-outline-style: none; + outline: none; + overflow: hidden; + height: 0; +} + +.dojoxGrid table { + padding: 0; +} + +.dojoxGrid td { + -moz-outline: none; +} + +/* master header */ + +.dojoxGrid-master-header { + position: relative; +} + +/* master view */ + +.dojoxGrid-master-view { + position: relative; +} + +/* views */ + +.dojoxGrid-view { + position: absolute; + overflow: hidden; +} + +/* header */ + +.dojoxGrid-header { + position: absolute; + overflow: hidden; +} + +.dojoxGrid-header { + background-color: #E8E1CF; +} + +.dojoxGrid-header table { + text-align: center; +} + +.dojoxGrid-header .dojoxGrid-cell-content { + text-align: center; +} + +.dojoxGrid-header .dojoxGrid-cell { + border: 1px solid; + border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; + background: url(images/grid_dx_gradient.gif) #E8E1CF top repeat-x; + padding-bottom: 2px; +} + +.dojoxGrid-header .dojoxGrid-cell-over { + background-image: none; + background-color: white; + border-bottom-color: #FEBE47; + margin-bottom: 0; + padding-bottom: 0; + border-bottom-width: 3px; +} + +.dojoxGrid-sort-down { + background: url(images/grid_sort_down.gif) left no-repeat; + padding-left:16px; + margin-left:4px; +} + +.dojoxGrid-sort-up { + background: url(images/grid_sort_up.gif) left no-repeat; + padding-left:16px; + margin-left:4px; +} + +/* content */ + +.dojoxGrid-scrollbox { + position: relative; + overflow: scroll; + background-color: white; + width: 100%; +} + +.dojoxGrid-content { + position: relative; + overflow: hidden; + -moz-outline-style: none; + outline: none; +} + +/* rowbar */ + +.dojoxGrid-rowbar { + border: 1px solid; + border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; + border-top: none; + background: url(images/grid_dx_gradient.gif) #E8E1CF top repeat-x; +} + +.dojoxGrid-rowbar-inner { + border-top: 1px solid #F6F4EB; +} + +.dojoxGrid-rowbar-over { + background-image: none; + background-color: white; + border-top-color: #FEBE47; + border-bottom-color: #FEBE47; +} + +.dojoxGrid-rowbar-selected { + background-color: #D9E8F9; + background-image: none; + /*background-image: url(images/grid_green_dot.gif);*/ + background-position: center; + background-repeat: no-repeat; +} + +/* rows */ + +.dojoxGrid-row { + position: relative; + width: 9000em; +} + +.dojoxGrid-row { + /*border: 1px solid #E8E4D8;*/ + border: 1px solid #E8E4D8; + border-color: #F8F7F1; + /*padding: 0 0 1px 0;*/ + border-left: none; + border-right: none; + background-color: white; + border-top: none; +} + +.dojoxGrid-row-over { + border-top-color: #FEBE47; + border-bottom-color: #FEBE47; + /*border-bottom-width: 2px; + padding-bottom: 0;*/ + /*background-color: #FFDD9D;*/ + /*background-color: #FDFDFD;*/ +} + +.dojoxGrid-row-odd { + background-color: #FFFDF3; + /*background-color: #F9F7E8;*/ +} + +.dojoxGrid-row-selected { + background-color: #D9E8F9; +} + +.dojoxGrid-row-table { + table-layout: fixed; + width: 0; +} + +.dojoxGrid-invisible { + visibility: hidden; +} + +.Xdojo-ie .dojoxGrid-invisible { + display: none; +} + +.dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td { + border-top-width: 0; + border-bottom-width: 0; + padding-top: 0; + padding-bottom: 0; + height: 0; + overflow: hidden; +} + +/* cells */ + +.dojoxGrid-cell { + border: 1px solid; + border-color: #EBEADB; + border-right-color: #D5CDB5; + padding: 3px 3px 3px 3px; + text-align: left; + overflow: hidden; +} + +.dojoxGrid-cell-focus { + border: 1px dashed blue; +} + +.dojoxGrid-cell-over { + border: 1px dotted #FEBE47; +} + +.dojoxGrid-cell-focus.dojoxGrid-cell-over { + border: 1px dotted green; +} + +.dojoxGrid-cell-clip { + width: 100%; + overflow: hidden; + white-space:nowrap; + text-overflow: ellipsis; +} + +/* editing */ + +.dojoxGrid-row-editing td { + background-color: #F4FFF4; +} + +.dojoxGrid-row-inserting td { + background-color: #F4FFF4; +} +.dojoxGrid-row-inflight td { + background-color: #F2F7B7; +} +.dojoxGrid-row-error td { + background-color: #F8B8B6; +} + +.dojoxGrid-input, .dojoxGrid-select, .dojoxGrid-textarea { + margin: 0; + padding: 0; + border-style: none; + width: 100%; + font-size: 100%; + font-family: inherit; +} + +.dojoxGrid-hidden-focus { + position: absolute; + left: -1000px; + top: -1000px; + height: 0px, width: 0px; +} + +.gridArrowButtonChar { + display:none !important; +} +.dijit_a11y .gridArrowButtonChar { + display:inline !important; +} +.dijit_a11y .dojoxGrid-sort-down, .dijit_a11y .dojoxGrid-sort-up { + margin-left: 0; + padding-left: 0; +} diff --git a/includes/js/dojox/grid/_grid/Grid_rtl.css b/includes/js/dojox/grid/_grid/Grid_rtl.css new file mode 100644 index 0000000..88ab215 --- /dev/null +++ b/includes/js/dojox/grid/_grid/Grid_rtl.css @@ -0,0 +1,8 @@ +.dijitRtl .dojoxGrid-header table { +} +.dj_ie .dijitRtl .dojoxGrid-header table { + float:none; +} +.dijitRtl .dojoxGrid-content { + float:left; +} diff --git a/includes/js/dojox/grid/_grid/Grid_rtl.css.commented.css b/includes/js/dojox/grid/_grid/Grid_rtl.css.commented.css new file mode 100644 index 0000000..c240b4c --- /dev/null +++ b/includes/js/dojox/grid/_grid/Grid_rtl.css.commented.css @@ -0,0 +1,10 @@ +.dijitRtl .dojoxGrid-header table { +} + +.dj_ie .dijitRtl .dojoxGrid-header table { + float:none; +} + +.dijitRtl .dojoxGrid-content { + float:left; +} diff --git a/includes/js/dojox/grid/_grid/builder.js b/includes/js/dojox/grid/_grid/builder.js new file mode 100644 index 0000000..dccf7e2 --- /dev/null +++ b/includes/js/dojox/grid/_grid/builder.js @@ -0,0 +1,522 @@ +if(!dojo._hasResource["dojox.grid._grid.builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.builder"] = true; +dojo.provide("dojox.grid._grid.builder"); +dojo.require("dojox.grid._grid.drag"); + +dojo.declare("dojox.grid.Builder", + null, + { + // summary: + // Base class to produce html for grid content. + // Also provide event decoration, providing grid related information inside the event object + // passed to grid events. + constructor: function(inView){ + this.view = inView; + this.grid = inView.grid; + }, + + view: null, + // boilerplate HTML + _table: '', + + // generate starting tags for a cell + generateCellMarkup: function(inCell, inMoreStyles, inMoreClasses, isHeader){ + var result = [], html; + if (isHeader){ + html = [ '' : ''); + for(var i=0, cell, m, cc, cs; (cell=row[i]); i++){ + m = cell.markup, cc = cell.customClasses = [], cs = cell.customStyles = []; + // content (format can fill in cc and cs as side-effects) + m[5] = cell.format(inDataIndex); + // classes + m[1] = cc.join(' '); + // styles + m[3] = cs.join(';'); + // in-place concat + html.push.apply(html, m); + } + html.push(''); + } + html.push('
'); + // result[4] => td postfix + result.push(html.join('')); + // SLOT: result[5] => content + result.push(''); + // result[6] => td closes + result.push(''); + return result; // Array + }, + + // cell finding + isCellNode: function(inNode){ + return Boolean(inNode && inNode.getAttribute && inNode.getAttribute("idx")); + }, + + getCellNodeIndex: function(inCellNode){ + return inCellNode ? Number(inCellNode.getAttribute("idx")) : -1; + }, + + getCellNode: function(inRowNode, inCellIndex){ + for(var i=0, row; row=dojox.grid.getTr(inRowNode.firstChild, i); i++){ + for(var j=0, cell; cell=row.cells[j]; j++){ + if(this.getCellNodeIndex(cell) == inCellIndex){ + return cell; + } + } + } + }, + + findCellTarget: function(inSourceNode, inTopNode){ + var n = inSourceNode; + while(n && (!this.isCellNode(n) || (dojox.grid.gridViewTag in n.offsetParent.parentNode && n.offsetParent.parentNode[dojox.grid.gridViewTag] != this.view.id)) && (n!=inTopNode)){ + n = n.parentNode; + } + return n!=inTopNode ? n : null + }, + + // event decoration + baseDecorateEvent: function(e){ + e.dispatch = 'do' + e.type; + e.grid = this.grid; + e.sourceView = this.view; + e.cellNode = this.findCellTarget(e.target, e.rowNode); + e.cellIndex = this.getCellNodeIndex(e.cellNode); + e.cell = (e.cellIndex >= 0 ? this.grid.getCell(e.cellIndex) : null); + }, + + // event dispatch + findTarget: function(inSource, inTag){ + var n = inSource; + while(n && (n!=this.domNode) && (!(inTag in n) || (dojox.grid.gridViewTag in n && n[dojox.grid.gridViewTag] != this.view.id))){ + n = n.parentNode; + } + return (n != this.domNode) ? n : null; + }, + + findRowTarget: function(inSource){ + return this.findTarget(inSource, dojox.grid.rowIndexTag); + }, + + isIntraNodeEvent: function(e){ + try{ + return (e.cellNode && e.relatedTarget && dojo.isDescendant(e.relatedTarget, e.cellNode)); + }catch(x){ + // e.relatedTarget has permission problem in FF if it's an input: https://bugzilla.mozilla.org/show_bug.cgi?id=208427 + return false; + } + }, + + isIntraRowEvent: function(e){ + try{ + var row = e.relatedTarget && this.findRowTarget(e.relatedTarget); + return !row && (e.rowIndex==-1) || row && (e.rowIndex==row.gridRowIndex); + }catch(x){ + // e.relatedTarget on INPUT has permission problem in FF: https://bugzilla.mozilla.org/show_bug.cgi?id=208427 + return false; + } + }, + + dispatchEvent: function(e){ + if(e.dispatch in this){ + return this[e.dispatch](e); + } + }, + + // dispatched event handlers + domouseover: function(e){ + if(e.cellNode && (e.cellNode!=this.lastOverCellNode)){ + this.lastOverCellNode = e.cellNode; + this.grid.onMouseOver(e); + } + this.grid.onMouseOverRow(e); + }, + + domouseout: function(e){ + if(e.cellNode && (e.cellNode==this.lastOverCellNode) && !this.isIntraNodeEvent(e, this.lastOverCellNode)){ + this.lastOverCellNode = null; + this.grid.onMouseOut(e); + if(!this.isIntraRowEvent(e)){ + this.grid.onMouseOutRow(e); + } + } + }, + + domousedown: function(e){ + if (e.cellNode) + this.grid.onMouseDown(e); + this.grid.onMouseDownRow(e) + } + +}); + +dojo.declare("dojox.grid.contentBuilder", + dojox.grid.Builder, + { + // summary: + // Produces html for grid data content. Owned by grid and used internally + // for rendering data. Override to implement custom rendering. + update: function(){ + this.prepareHtml(); + }, + + // cache html for rendering data rows + prepareHtml: function(){ + var defaultGet=this.grid.get, rows=this.view.structure.rows; + for(var j=0, row; (row=rows[j]); j++){ + for(var i=0, cell; (cell=row[i]); i++){ + cell.get = cell.get || (cell.value == undefined) && defaultGet; + cell.markup = this.generateCellMarkup(cell, cell.cellStyles, cell.cellClasses, false); + } + } + }, + + // time critical: generate html using cache and data source + generateHtml: function(inDataIndex, inRowIndex){ + var + html = [ this._table ], + v = this.view, + obr = v.onBeforeRow, + rows = v.structure.rows; + + obr && obr(inRowIndex, rows); + for(var j=0, row; (row=rows[j]); j++){ + if(row.hidden || row.header){ + continue; + } + html.push(!row.invisible ? '
'); + return html.join(''); // String + }, + + decorateEvent: function(e){ + e.rowNode = this.findRowTarget(e.target); + if(!e.rowNode){return false}; + e.rowIndex = e.rowNode[dojox.grid.rowIndexTag]; + this.baseDecorateEvent(e); + e.cell = this.grid.getCell(e.cellIndex); + return true; // Boolean + } + +}); + +dojo.declare("dojox.grid.headerBuilder", + dojox.grid.Builder, + { + // summary: + // Produces html for grid header content. Owned by grid and used internally + // for rendering data. Override to implement custom rendering. + + bogusClickTime: 0, + overResizeWidth: 4, + minColWidth: 1, + + // FIXME: isn't this getting mixed from dojox.grid.Builder, -1 character? + _table: ''); + dojox.grid.fire(this.view, "onBeforeRow", [-1, rows]); + for(var j=0, row; (row=rows[j]); j++){ + if(row.hidden){ + continue; + } + html.push(!row.invisible ? '' : ''); + for(var i=0, cell, markup; (cell=row[i]); i++){ + cell.customClasses = []; + cell.customStyles = []; + markup = this.generateCellMarkup(cell, cell.headerStyles, cell.headerClasses, true); + // content + markup[5] = (inValue != undefined ? inValue : inGetValue(cell)); + // styles + markup[3] = cell.customStyles.join(';'); + // classes + markup[1] = cell.customClasses.join(' '); //(cell.customClasses ? ' ' + cell.customClasses : ''); + html.push(markup.join('')); + } + html.push(''); + } + html.push('
'); + return html.join(''); + }, + + // event helpers + getCellX: function(e){ + var x = e.layerX; + if(dojo.isMoz){ + var n = dojox.grid.ascendDom(e.target, dojox.grid.makeNotTagName("th")); + x -= (n && n.offsetLeft) || 0; + var t = e.sourceView.getScrollbarWidth(); + if(!dojo._isBodyLtr() && e.sourceView.headerNode.scrollLeft < t) + x -= t; + //x -= getProp(ascendDom(e.target, mkNotTagName("td")), "offsetLeft") || 0; + } + var n = dojox.grid.ascendDom(e.target, function(){ + if(!n || n == e.cellNode){ + return false; + } + // Mozilla 1.8 (FF 1.5) has a bug that makes offsetLeft = -parent border width + // when parent has border, overflow: hidden, and is positioned + // handle this problem here ... not a general solution! + x += (n.offsetLeft < 0 ? 0 : n.offsetLeft); + return true; + }); + return x; + }, + + // event decoration + decorateEvent: function(e){ + this.baseDecorateEvent(e); + e.rowIndex = -1; + e.cellX = this.getCellX(e); + return true; + }, + + // event handlers + // resizing + prepareResize: function(e, mod){ + var i = dojox.grid.getTdIndex(e.cellNode); + e.cellNode = (i ? e.cellNode.parentNode.cells[i+mod] : null); + e.cellIndex = (e.cellNode ? this.getCellNodeIndex(e.cellNode) : -1); + return Boolean(e.cellNode); + }, + + canResize: function(e){ + if(!e.cellNode || e.cellNode.colSpan > 1){ + return false; + } + var cell = this.grid.getCell(e.cellIndex); + return !cell.noresize && !cell.isFlex(); + }, + + overLeftResizeArea: function(e){ + if(dojo._isBodyLtr()){ + return (e.cellIndex>0) && (e.cellX < this.overResizeWidth) && this.prepareResize(e, -1); + } + return t = e.cellNode && (e.cellX < this.overResizeWidth); + }, + + overRightResizeArea: function(e){ + if(dojo._isBodyLtr()){ + return e.cellNode && (e.cellX >= e.cellNode.offsetWidth - this.overResizeWidth); + } + return (e.cellIndex>0) && (e.cellX >= e.cellNode.offsetWidth - this.overResizeWidth) && this.prepareResize(e, -1); + }, + + domousemove: function(e){ + //console.log(e.cellIndex, e.cellX, e.cellNode.offsetWidth); + var c = (this.overRightResizeArea(e) ? 'e-resize' : (this.overLeftResizeArea(e) ? 'w-resize' : '')); + if(c && !this.canResize(e)){ + c = 'not-allowed'; + } + e.sourceView.headerNode.style.cursor = c || ''; //'default'; + if (c) + dojo.stopEvent(e); + }, + + domousedown: function(e){ + if(!dojox.grid.drag.dragging){ + if((this.overRightResizeArea(e) || this.overLeftResizeArea(e)) && this.canResize(e)){ + this.beginColumnResize(e); + }else{ + this.grid.onMouseDown(e); + this.grid.onMouseOverRow(e); + } + //else{ + // this.beginMoveColumn(e); + //} + } + }, + + doclick: function(e) { + if (new Date().getTime() < this.bogusClickTime) { + dojo.stopEvent(e); + return true; + } + }, + + // column resizing + beginColumnResize: function(e){ + dojo.stopEvent(e); + var spanners = [], nodes = this.tableMap.findOverlappingNodes(e.cellNode); + for(var i=0, cell; (cell=nodes[i]); i++){ + spanners.push({ node: cell, index: this.getCellNodeIndex(cell), width: cell.offsetWidth }); + //console.log("spanner: " + this.getCellNodeIndex(cell)); + } + var drag = { + scrollLeft: e.sourceView.headerNode.scrollLeft, + view: e.sourceView, + node: e.cellNode, + index: e.cellIndex, + w: e.cellNode.clientWidth, + spanners: spanners + }; + //console.log(drag.index, drag.w); + dojox.grid.drag.start(e.cellNode, dojo.hitch(this, 'doResizeColumn', drag), dojo.hitch(this, 'endResizeColumn', drag), e); + }, + + doResizeColumn: function(inDrag, inEvent){ + var isLtr = dojo._isBodyLtr(); + if(isLtr){ + var w = inDrag.w + inEvent.deltaX; + }else{ + var w = inDrag.w - inEvent.deltaX; + } + if(w >= this.minColWidth){ + for(var i=0, s, sw; (s=inDrag.spanners[i]); i++){ + if(isLtr){ + sw = s.width + inEvent.deltaX; + }else{ + sw = s.width - inEvent.deltaX; + } + s.node.style.width = sw + 'px'; + inDrag.view.setColWidth(s.index, sw); + //console.log('setColWidth', '#' + s.index, sw + 'px'); + } + inDrag.node.style.width = w + 'px'; + inDrag.view.setColWidth(inDrag.index, w); + if(!isLtr){ + inDrag.view.headerNode.scrollLeft = (inDrag.scrollLeft - inEvent.deltaX); + } + } + if(inDrag.view.flexCells && !inDrag.view.testFlexCells()){ + var t = dojox.grid.findTable(inDrag.node); + t && (t.style.width = ''); + } + }, + + endResizeColumn: function(inDrag){ + this.bogusClickTime = new Date().getTime() + 30; + setTimeout(dojo.hitch(inDrag.view, "update"), 50); + } + +}); + +dojo.declare("dojox.grid.tableMap", + null, + { + // summary: + // Maps an html table into a structure parsable for information about cell row and col spanning. + // Used by headerBuilder + constructor: function(inRows){ + this.mapRows(inRows); + }, + + map: null, + + mapRows: function(inRows){ + // summary: Map table topography + + //console.log('mapRows'); + // # of rows + var rowCount = inRows.length; + if(!rowCount){ + return; + } + // map which columns and rows fill which cells + this.map = [ ]; + for(var j=0, row; (row=inRows[j]); j++){ + this.map[j] = []; + } + for(var j=0, row; (row=inRows[j]); j++){ + for(var i=0, x=0, cell, colSpan, rowSpan; (cell=row[i]); i++){ + while (this.map[j][x]){x++}; + this.map[j][x] = { c: i, r: j }; + rowSpan = cell.rowSpan || 1; + colSpan = cell.colSpan || 1; + for(var y=0; y dgdrag.hysteresis; +} + +dgdrag.mousemove = function(inEvent){ + inEvent = dojo.fixEvent(inEvent); + dojo.stopEvent(inEvent); + dgdrag.calcDelta(inEvent); + if((!dgdrag.started)&&(dgdrag.hasMoved(inEvent))){ + dgdrag.events.start(inEvent); + dgdrag.started = true; + } + if(dgdrag.started){ + dgdrag.events.drag(inEvent); + } +} + +dgdrag.mouseup = function(inEvent){ + //console.debug("dojox.grid.drag.mouseup"); + dojo.stopEvent(dojo.fixEvent(inEvent)); + dgdrag.end(); +} + +dgdrag.click = function(inEvent){ + dojo.stopEvent(dojo.fixEvent(inEvent)); + //dgdrag.end(); +} + +})(); +// end closure + +} diff --git a/includes/js/dojox/grid/_grid/edit.js b/includes/js/dojox/grid/_grid/edit.js new file mode 100644 index 0000000..d918423 --- /dev/null +++ b/includes/js/dojox/grid/_grid/edit.js @@ -0,0 +1,238 @@ +if(!dojo._hasResource["dojox.grid._grid.edit"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.edit"] = true; +dojo.provide("dojox.grid._grid.edit"); + +dojo.declare("dojox.grid.edit", null, { + // summary: + // Controls grid cell editing process. Owned by grid and used internally for editing. + constructor: function(inGrid){ + // inGrid: dojox.Grid + // The dojox.Grid this editor should be attached to + this.grid = inGrid; + this.connections = []; + if(dojo.isIE){ + this.connections.push(dojo.connect(document.body, "onfocus", dojo.hitch(this, "_boomerangFocus"))); + } + }, + + info: {}, + + destroy: function(){ + dojo.forEach(this.connections,dojo.disconnect); + }, + + cellFocus: function(inCell, inRowIndex){ + // summary: + // Invoke editing when cell is focused + // inCell: cell object + // Grid cell object + // inRowIndex: Integer + // Grid row index + if(this.grid.singleClickEdit || this.isEditRow(inRowIndex)){ + // if same row or quick editing, edit + this.setEditCell(inCell, inRowIndex); + }else{ + // otherwise, apply any pending row edits + this.apply(); + } + // if dynamic or static editing... + if(this.isEditing() || (inCell && (inCell.editor||0).alwaysOn)){ + // let the editor focus itself as needed + this._focusEditor(inCell, inRowIndex); + } + }, + + rowClick: function(e){ + if(this.isEditing() && !this.isEditRow(e.rowIndex)){ + this.apply(); + } + }, + + styleRow: function(inRow){ + if(inRow.index == this.info.rowIndex){ + inRow.customClasses += ' dojoxGrid-row-editing'; + } + }, + + dispatchEvent: function(e){ + var c = e.cell, ed = c && c.editor; + return ed && ed.dispatchEvent(e.dispatch, e); + }, + + // Editing + isEditing: function(){ + // summary: + // Indicates editing state of the grid. + // returns: Boolean + // True if grid is actively editing + return this.info.rowIndex !== undefined; + }, + + isEditCell: function(inRowIndex, inCellIndex){ + // summary: + // Indicates if the given cell is being edited. + // inRowIndex: Integer + // Grid row index + // inCellIndex: Integer + // Grid cell index + // returns: Boolean + // True if given cell is being edited + return (this.info.rowIndex === inRowIndex) && (this.info.cell.index == inCellIndex); + }, + + isEditRow: function(inRowIndex){ + // summary: + // Indicates if the given row is being edited. + // inRowIndex: Integer + // Grid row index + // returns: Boolean + // True if given row is being edited + return this.info.rowIndex === inRowIndex; + }, + + setEditCell: function(inCell, inRowIndex){ + // summary: + // Set the given cell to be edited + // inRowIndex: Integer + // Grid row index + // inCell: Object + // Grid cell object + if(!this.isEditCell(inRowIndex, inCell.index) && this.grid.canEdit(inCell, inRowIndex)){ + this.start(inCell, inRowIndex, this.isEditRow(inRowIndex) || inCell.editor); + } + }, + + _focusEditor: function(inCell, inRowIndex){ + dojox.grid.fire(inCell.editor, "focus", [inRowIndex]); + }, + + focusEditor: function(){ + if(this.isEditing()){ + this._focusEditor(this.info.cell, this.info.rowIndex); + } + }, + + // implement fix for focus boomerang effect on IE + _boomerangWindow: 500, + _shouldCatchBoomerang: function(){ + return this._catchBoomerang > new Date().getTime(); + }, + _boomerangFocus: function(){ + //console.log("_boomerangFocus"); + if(this._shouldCatchBoomerang()){ + // make sure we don't utterly lose focus + this.grid.focus.focusGrid(); + // let the editor focus itself as needed + this.focusEditor(); + // only catch once + this._catchBoomerang = 0; + } + }, + _doCatchBoomerang: function(){ + // give ourselves a few ms to boomerang IE focus effects + if(dojo.isIE){this._catchBoomerang = new Date().getTime() + this._boomerangWindow;} + }, + // end boomerang fix API + + start: function(inCell, inRowIndex, inEditing){ + this.grid.beginUpdate(); + this.editorApply(); + if(this.isEditing() && !this.isEditRow(inRowIndex)){ + this.applyRowEdit(); + this.grid.updateRow(inRowIndex); + } + if(inEditing){ + this.info = { cell: inCell, rowIndex: inRowIndex }; + this.grid.doStartEdit(inCell, inRowIndex); + this.grid.updateRow(inRowIndex); + }else{ + this.info = {}; + } + this.grid.endUpdate(); + // make sure we don't utterly lose focus + this.grid.focus.focusGrid(); + // let the editor focus itself as needed + this._focusEditor(inCell, inRowIndex); + // give ourselves a few ms to boomerang IE focus effects + this._doCatchBoomerang(); + }, + + _editorDo: function(inMethod){ + var c = this.info.cell + //c && c.editor && c.editor[inMethod](c, this.info.rowIndex); + c && c.editor && c.editor[inMethod](this.info.rowIndex); + }, + + editorApply: function(){ + this._editorDo("apply"); + }, + + editorCancel: function(){ + this._editorDo("cancel"); + }, + + applyCellEdit: function(inValue, inCell, inRowIndex){ + if(this.grid.canEdit(inCell, inRowIndex)){ + this.grid.doApplyCellEdit(inValue, inRowIndex, inCell.fieldIndex); + } + }, + + applyRowEdit: function(){ + this.grid.doApplyEdit(this.info.rowIndex); + }, + + apply: function(){ + // summary: + // Apply a grid edit + if(this.isEditing()){ + this.grid.beginUpdate(); + this.editorApply(); + this.applyRowEdit(); + this.info = {}; + this.grid.endUpdate(); + this.grid.focus.focusGrid(); + this._doCatchBoomerang(); + } + }, + + cancel: function(){ + // summary: + // Cancel a grid edit + if(this.isEditing()){ + this.grid.beginUpdate(); + this.editorCancel(); + this.info = {}; + this.grid.endUpdate(); + this.grid.focus.focusGrid(); + this._doCatchBoomerang(); + } + }, + + save: function(inRowIndex, inView){ + // summary: + // Save the grid editing state + // inRowIndex: Integer + // Grid row index + // inView: Object + // Grid view + var c = this.info.cell; + if(this.isEditRow(inRowIndex) && (!inView || c.view==inView) && c.editor){ + c.editor.save(c, this.info.rowIndex); + } + }, + + restore: function(inView, inRowIndex){ + // summary: + // Restores the grid editing state + // inRowIndex: Integer + // Grid row index + // inView: Object + // Grid view + var c = this.info.cell; + if(this.isEditRow(inRowIndex) && c.view == inView && c.editor){ + c.editor.restore(c, this.info.rowIndex); + } + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/focus.js b/includes/js/dojox/grid/_grid/focus.js new file mode 100644 index 0000000..8761042 --- /dev/null +++ b/includes/js/dojox/grid/_grid/focus.js @@ -0,0 +1,207 @@ +if(!dojo._hasResource["dojox.grid._grid.focus"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.focus"] = true; +dojo.provide("dojox.grid._grid.focus"); + +// focus management +dojo.declare("dojox.grid.focus", null, { + // summary: + // Controls grid cell focus. Owned by grid and used internally for focusing. + // Note: grid cell actually receives keyboard input only when cell is being edited. + constructor: function(inGrid){ + this.grid = inGrid; + this.cell = null; + this.rowIndex = -1; + dojo.connect(this.grid.domNode, "onfocus", this, "doFocus"); + }, + tabbingOut: false, + focusClass: "dojoxGrid-cell-focus", + focusView: null, + initFocusView: function(){ + this.focusView = this.grid.views.getFirstScrollingView(); + }, + isFocusCell: function(inCell, inRowIndex){ + // summary: + // states if the given cell is focused + // inCell: object + // grid cell object + // inRowIndex: int + // grid row index + // returns: + // true of the given grid cell is focused + return (this.cell == inCell) && (this.rowIndex == inRowIndex); + }, + isLastFocusCell: function(){ + return (this.rowIndex == this.grid.rowCount-1) && (this.cell.index == this.grid.layout.cellCount-1); + }, + isFirstFocusCell: function(){ + return (this.rowIndex == 0) && (this.cell.index == 0); + }, + isNoFocusCell: function(){ + return (this.rowIndex < 0) || !this.cell; + }, + _focusifyCellNode: function(inBork){ + var n = this.cell && this.cell.getNode(this.rowIndex); + if(n){ + dojo.toggleClass(n, this.focusClass, inBork); + if (inBork){ + this.scrollIntoView(); + try{ + if(!this.grid.edit.isEditing()) + dojox.grid.fire(n, "focus"); + }catch(e){} + } + } + }, + scrollIntoView: function() { + if(!this.cell){ + return; + } + var + c = this.cell, + s = c.view.scrollboxNode, + sr = { + w: s.clientWidth, + l: s.scrollLeft, + t: s.scrollTop, + h: s.clientHeight + }, + n = c.getNode(this.rowIndex), + r = c.view.getRowNode(this.rowIndex), + rt = this.grid.scroller.findScrollTop(this.rowIndex); + // place cell within horizontal view + if(n.offsetLeft + n.offsetWidth > sr.l + sr.w){ + s.scrollLeft = n.offsetLeft + n.offsetWidth - sr.w; + }else if(n.offsetLeft < sr.l){ + s.scrollLeft = n.offsetLeft; + } + // place cell within vertical view + if(rt + r.offsetHeight > sr.t + sr.h){ + this.grid.setScrollTop(rt + r.offsetHeight - sr.h); + }else if(rt < sr.t){ + this.grid.setScrollTop(rt); + } + }, + styleRow: function(inRow){ + return; + }, + setFocusIndex: function(inRowIndex, inCellIndex){ + // summary: + // focuses the given grid cell + // inRowIndex: int + // grid row index + // inCellIndex: int + // grid cell index + this.setFocusCell(this.grid.getCell(inCellIndex), inRowIndex); + }, + setFocusCell: function(inCell, inRowIndex){ + // summary: + // focuses the given grid cell + // inCell: object + // grid cell object + // inRowIndex: int + // grid row index + if(inCell && !this.isFocusCell(inCell, inRowIndex)){ + this.tabbingOut = false; + this.focusGridView(); + this._focusifyCellNode(false); + this.cell = inCell; + this.rowIndex = inRowIndex; + this._focusifyCellNode(true); + } + // even if this cell isFocusCell, the document focus may need to be rejiggered + // call opera on delay to prevent keypress from altering focus + if(dojo.isOpera){ + setTimeout(dojo.hitch(this.grid, 'onCellFocus', this.cell, this.rowIndex), 1); + }else{ + this.grid.onCellFocus(this.cell, this.rowIndex); + } + }, + next: function(){ + // summary: + // focus next grid cell + var row=this.rowIndex, col=this.cell.index+1, cc=this.grid.layout.cellCount-1, rc=this.grid.rowCount-1; + if(col > cc){ + col = 0; + row++; + } + if(row > rc){ + col = cc; + row = rc; + } + this.setFocusIndex(row, col); + }, + previous: function(){ + // summary: + // focus previous grid cell + var row=(this.rowIndex || 0), col=(this.cell.index || 0) - 1; + if(col < 0){ + col = this.grid.layout.cellCount-1; + row--; + } + if(row < 0){ + row = 0; + col = 0; + } + this.setFocusIndex(row, col); + }, + move: function(inRowDelta, inColDelta) { + // summary: + // focus grid cell based on position relative to current focus + // inRowDelta: int + // vertical distance from current focus + // inColDelta: int + // horizontal distance from current focus + var + rc = this.grid.rowCount-1, + cc = this.grid.layout.cellCount-1, + r = this.rowIndex, + i = this.cell.index, + row = Math.min(rc, Math.max(0, r+inRowDelta)), + col = Math.min(cc, Math.max(0, i+inColDelta)); + this.setFocusIndex(row, col); + if(inRowDelta){ + this.grid.updateRow(r); + } + }, + previousKey: function(e){ + if(this.isFirstFocusCell()){ + this.tabOut(this.grid.domNode); + }else{ + dojo.stopEvent(e); + this.previous(); + } + }, + nextKey: function(e) { + if(this.isLastFocusCell()){ + this.tabOut(this.grid.lastFocusNode); + }else{ + dojo.stopEvent(e); + this.next(); + } + }, + tabOut: function(inFocusNode){ + this.tabbingOut = true; + inFocusNode.focus(); + }, + focusGridView: function(){ + dojox.grid.fire(this.focusView, "focus"); + }, + focusGrid: function(inSkipFocusCell){ + this.focusGridView(); + this._focusifyCellNode(true); + }, + doFocus: function(e){ + // trap focus only for grid dom node + if(e && e.target != e.currentTarget){ + return; + } + // do not focus for scrolling if grid is about to blur + if(!this.tabbingOut && this.isNoFocusCell()){ + // establish our virtual-focus, if necessary + this.setFocusIndex(0, 0); + } + this.tabbingOut = false; + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/images/grid_dx_gradient.gif b/includes/js/dojox/grid/_grid/images/grid_dx_gradient.gif new file mode 100644 index 0000000..57f67ba Binary files /dev/null and b/includes/js/dojox/grid/_grid/images/grid_dx_gradient.gif differ diff --git a/includes/js/dojox/grid/_grid/images/grid_sort_down.gif b/includes/js/dojox/grid/_grid/images/grid_sort_down.gif new file mode 100644 index 0000000..7a73f82 Binary files /dev/null and b/includes/js/dojox/grid/_grid/images/grid_sort_down.gif differ diff --git a/includes/js/dojox/grid/_grid/images/grid_sort_up.gif b/includes/js/dojox/grid/_grid/images/grid_sort_up.gif new file mode 100644 index 0000000..9452da0 Binary files /dev/null and b/includes/js/dojox/grid/_grid/images/grid_sort_up.gif differ diff --git a/includes/js/dojox/grid/_grid/images/tabEnabled_rotated.png b/includes/js/dojox/grid/_grid/images/tabEnabled_rotated.png new file mode 100644 index 0000000..e326abd Binary files /dev/null and b/includes/js/dojox/grid/_grid/images/tabEnabled_rotated.png differ diff --git a/includes/js/dojox/grid/_grid/images/tabHover_rotated.png b/includes/js/dojox/grid/_grid/images/tabHover_rotated.png new file mode 100644 index 0000000..1a30e10 Binary files /dev/null and b/includes/js/dojox/grid/_grid/images/tabHover_rotated.png differ 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 + })); + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/lib.js b/includes/js/dojox/grid/_grid/lib.js new file mode 100644 index 0000000..3644dbc --- /dev/null +++ b/includes/js/dojox/grid/_grid/lib.js @@ -0,0 +1,254 @@ +if(!dojo._hasResource["dojox.grid._grid.lib"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.lib"] = true; +dojo.provide("dojox.grid._grid.lib"); +// summary: grid utility library +dojo.mixin(dojox.grid,{ + + na: '...', + + nop: function(){ + // summary: a null function? + }, + + getTdIndex: function(td){ + return td.cellIndex >=0 ? td.cellIndex : dojo.indexOf(td.parentNode.cells, td); + }, + + getTrIndex: function(tr){ + return tr.rowIndex >=0 ? tr.rowIndex : dojo.indexOf(tr.parentNode.childNodes, tr); + }, + + getTr: function(rowOwner, index){ + return rowOwner && ((rowOwner.rows||0)[index] || rowOwner.childNodes[index]); + }, + + getTd: function(rowOwner, rowIndex, cellIndex){ + return (dojox.grid.getTr(inTable, rowIndex)||0)[cellIndex]; + }, + + findTable: function(node){ + for (var n=node; n && n.tagName!='TABLE'; n=n.parentNode); + return n; + }, + + ascendDom: function(inNode, inWhile){ + for (var n=inNode; n && inWhile(n); n=n.parentNode); + return n; + }, + + makeNotTagName: function(inTagName){ + var name = inTagName.toUpperCase(); + return function(node){ return node.tagName != name; }; + }, + + fire: function(ob, ev, args){ + var fn = ob && ev && ob[ev]; + return fn && (args ? fn.apply(ob, args) : ob[ev]()); + }, + + // from lib.js + setStyleText: function(inNode, inStyleText){ + if(inNode.style.cssText == undefined){ + inNode.setAttribute("style", inStyleText); + }else{ + inNode.style.cssText = inStyleText; + } + }, + + getStyleText: function(inNode, inStyleText){ + return (inNode.style.cssText == undefined ? inNode.getAttribute("style") : inNode.style.cssText); + }, + + setStyle: function(inElement, inStyle, inValue){ + if(inElement && inElement.style[inStyle] != inValue){ + inElement.style[inStyle] = inValue; + } + }, + + setStyleHeightPx: function(inElement, inHeight){ + if(inHeight >= 0){ + dojox.grid.setStyle(inElement, 'height', inHeight + 'px'); + } + }, + + mouseEvents: [ 'mouseover', 'mouseout', /*'mousemove',*/ 'mousedown', 'mouseup', 'click', 'dblclick', 'contextmenu' ], + + keyEvents: [ 'keyup', 'keydown', 'keypress' ], + + funnelEvents: function(inNode, inObject, inMethod, inEvents){ + var evts = (inEvents ? inEvents : dojox.grid.mouseEvents.concat(dojox.grid.keyEvents)); + for (var i=0, l=evts.length; i'; + }, + renderHeader: function(){ + }, + resize: function(){ + this.adaptHeight(); + }, + adaptWidth: function(){ + }, + // styling + doStyleRowNode: function(inRowIndex, inRowNode){ + var n = [ "dojoxGrid-rowbar" ]; + if(this.grid.rows.isOver(inRowIndex)){ + n.push("dojoxGrid-rowbar-over"); + } + if(this.grid.selection.isSelected(inRowIndex)){ + n.push("dojoxGrid-rowbar-selected"); + } + inRowNode.className = n.join(" "); + }, + // event handlers + domouseover: function(e){ + this.grid.onMouseOverRow(e); + }, + domouseout: function(e){ + if(!this.isIntraRowEvent(e)){ + this.grid.onMouseOutRow(e); + } + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/rows.js b/includes/js/dojox/grid/_grid/rows.js new file mode 100644 index 0000000..37ecbcb --- /dev/null +++ b/includes/js/dojox/grid/_grid/rows.js @@ -0,0 +1,66 @@ +if(!dojo._hasResource["dojox.grid._grid.rows"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.rows"] = true; +dojo.provide("dojox.grid._grid.rows"); + +dojo.declare("dojox.grid.rows", null, { + // Stores information about grid rows. Owned by grid and used internally. + constructor: function(inGrid){ + this.grid = inGrid; + }, + linesToEms: 2, + defaultRowHeight: 1, // lines + overRow: -2, + // metrics + getHeight: function(inRowIndex){ + return ''; + }, + getDefaultHeightPx: function(){ + // summmary: + // retrieves the default row height + // returns: int, default row height + return 32; + //return Math.round(this.defaultRowHeight * this.linesToEms * this.grid.contentPixelToEmRatio); + }, + // styles + prepareStylingRow: function(inRowIndex, inRowNode){ + return { + index: inRowIndex, + node: inRowNode, + odd: Boolean(inRowIndex&1), + selected: this.grid.selection.isSelected(inRowIndex), + over: this.isOver(inRowIndex), + customStyles: "", + customClasses: "dojoxGrid-row" + } + }, + styleRowNode: function(inRowIndex, inRowNode){ + var row = this.prepareStylingRow(inRowIndex, inRowNode); + this.grid.onStyleRow(row); + this.applyStyles(row); + }, + applyStyles: function(inRow){ + with(inRow){ + node.className = customClasses; + var h = node.style.height; + dojox.grid.setStyleText(node, customStyles + ';' + (node._style||'')); + node.style.height = h; + } + }, + updateStyles: function(inRowIndex){ + this.grid.updateRowStyles(inRowIndex); + }, + // states and events + setOverRow: function(inRowIndex){ + var last = this.overRow; + this.overRow = inRowIndex; + if((last!=this.overRow)&&(last >=0)){ + this.updateStyles(last); + } + this.updateStyles(this.overRow); + }, + isOver: function(inRowIndex){ + return (this.overRow == inRowIndex); + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/scroller.js b/includes/js/dojox/grid/_grid/scroller.js new file mode 100644 index 0000000..d331367 --- /dev/null +++ b/includes/js/dojox/grid/_grid/scroller.js @@ -0,0 +1,489 @@ +if(!dojo._hasResource['dojox.grid._grid.scroller']){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource['dojox.grid._grid.scroller'] = true; +dojo.provide('dojox.grid._grid.scroller'); + +dojo.declare('dojox.grid.scroller.base', null, { + // summary: + // virtual scrollbox, abstract class + // Content must in /rows/ + // Rows are managed in contiguous sets called /pages/ + // There are a fixed # of rows per page + // The minimum rendered unit is a page + constructor: function(){ + this.pageHeights = []; + this.stack = []; + }, + // specified + rowCount: 0, // total number of rows to manage + defaultRowHeight: 10, // default height of a row + keepRows: 100, // maximum number of rows that should exist at one time + contentNode: null, // node to contain pages + scrollboxNode: null, // node that controls scrolling + // calculated + defaultPageHeight: 0, // default height of a page + keepPages: 10, // maximum number of pages that should exists at one time + pageCount: 0, + windowHeight: 0, + firstVisibleRow: 0, + lastVisibleRow: 0, + // private + page: 0, + pageTop: 0, + // init + init: function(inRowCount, inKeepRows, inRowsPerPage){ + switch(arguments.length){ + case 3: this.rowsPerPage = inRowsPerPage; + case 2: this.keepRows = inKeepRows; + case 1: this.rowCount = inRowCount; + } + this.defaultPageHeight = this.defaultRowHeight * this.rowsPerPage; + //this.defaultPageHeight = this.defaultRowHeight * Math.min(this.rowsPerPage, this.rowCount); + this.pageCount = Math.ceil(this.rowCount / this.rowsPerPage); + this.setKeepInfo(this.keepRows); + this.invalidate(); + if(this.scrollboxNode){ + this.scrollboxNode.scrollTop = 0; + this.scroll(0); + this.scrollboxNode.onscroll = dojo.hitch(this, 'onscroll'); + } + }, + setKeepInfo: function(inKeepRows){ + this.keepRows = inKeepRows; + this.keepPages = !this.keepRows ? this.keepRows : Math.max(Math.ceil(this.keepRows / this.rowsPerPage), 2); + }, + // updating + invalidate: function(){ + this.invalidateNodes(); + this.pageHeights = []; + this.height = (this.pageCount ? (this.pageCount - 1)* this.defaultPageHeight + this.calcLastPageHeight() : 0); + this.resize(); + }, + updateRowCount: function(inRowCount){ + this.invalidateNodes(); + this.rowCount = inRowCount; + // update page count, adjust document height + oldPageCount = this.pageCount; + this.pageCount = Math.ceil(this.rowCount / this.rowsPerPage); + if(this.pageCount < oldPageCount){ + for(var i=oldPageCount-1; i>=this.pageCount; i--){ + this.height -= this.getPageHeight(i); + delete this.pageHeights[i] + } + }else if(this.pageCount > oldPageCount){ + this.height += this.defaultPageHeight * (this.pageCount - oldPageCount - 1) + this.calcLastPageHeight(); + } + this.resize(); + }, + // abstract interface + pageExists: function(inPageIndex){ + }, + measurePage: function(inPageIndex){ + }, + positionPage: function(inPageIndex, inPos){ + }, + repositionPages: function(inPageIndex){ + }, + installPage: function(inPageIndex){ + }, + preparePage: function(inPageIndex, inPos, inReuseNode){ + }, + renderPage: function(inPageIndex){ + }, + removePage: function(inPageIndex){ + }, + pacify: function(inShouldPacify){ + }, + // pacification + pacifying: false, + pacifyTicks: 200, + setPacifying: function(inPacifying){ + if(this.pacifying != inPacifying){ + this.pacifying = inPacifying; + this.pacify(this.pacifying); + } + }, + startPacify: function(){ + this.startPacifyTicks = new Date().getTime(); + }, + doPacify: function(){ + var result = (new Date().getTime() - this.startPacifyTicks) > this.pacifyTicks; + this.setPacifying(true); + this.startPacify(); + return result; + }, + endPacify: function(){ + this.setPacifying(false); + }, + // default sizing implementation + resize: function(){ + if(this.scrollboxNode){ + this.windowHeight = this.scrollboxNode.clientHeight; + } + dojox.grid.setStyleHeightPx(this.contentNode, this.height); + }, + calcLastPageHeight: function(){ + if(!this.pageCount){ + return 0; + } + var lastPage = this.pageCount - 1; + var lastPageHeight = ((this.rowCount % this.rowsPerPage)||(this.rowsPerPage)) * this.defaultRowHeight; + this.pageHeights[lastPage] = lastPageHeight; + return lastPageHeight; + }, + updateContentHeight: function(inDh){ + this.height += inDh; + this.resize(); + }, + updatePageHeight: function(inPageIndex){ + if(this.pageExists(inPageIndex)){ + var oh = this.getPageHeight(inPageIndex); + var h = (this.measurePage(inPageIndex))||(oh); + this.pageHeights[inPageIndex] = h; + if((h)&&(oh != h)){ + this.updateContentHeight(h - oh) + this.repositionPages(inPageIndex); + } + } + }, + rowHeightChanged: function(inRowIndex){ + this.updatePageHeight(Math.floor(inRowIndex / this.rowsPerPage)); + }, + // scroller core + invalidateNodes: function(){ + while(this.stack.length){ + this.destroyPage(this.popPage()); + } + }, + createPageNode: function(){ + var p = document.createElement('div'); + p.style.position = 'absolute'; + //p.style.width = '100%'; + p.style[dojo._isBodyLtr() ? "left" : "right"] = '0'; + return p; + }, + getPageHeight: function(inPageIndex){ + var ph = this.pageHeights[inPageIndex]; + return (ph !== undefined ? ph : this.defaultPageHeight); + }, + // FIXME: this is not a stack, it's a FIFO list + pushPage: function(inPageIndex){ + return this.stack.push(inPageIndex); + }, + popPage: function(){ + return this.stack.shift(); + }, + findPage: function(inTop){ + var i = 0, h = 0; + for(var ph = 0; i= inTop){ + break; + } + } + this.page = i; + this.pageTop = h; + }, + buildPage: function(inPageIndex, inReuseNode, inPos){ + this.preparePage(inPageIndex, inReuseNode); + this.positionPage(inPageIndex, inPos); + // order of operations is key below + this.installPage(inPageIndex); + this.renderPage(inPageIndex); + // order of operations is key above + this.pushPage(inPageIndex); + }, + needPage: function(inPageIndex, inPos){ + var h = this.getPageHeight(inPageIndex), oh = h; + if(!this.pageExists(inPageIndex)){ + this.buildPage(inPageIndex, this.keepPages&&(this.stack.length >= this.keepPages), inPos); + h = this.measurePage(inPageIndex) || h; + this.pageHeights[inPageIndex] = h; + if(h && (oh != h)){ + this.updateContentHeight(h - oh) + } + }else{ + this.positionPage(inPageIndex, inPos); + } + return h; + }, + onscroll: function(){ + this.scroll(this.scrollboxNode.scrollTop); + }, + scroll: function(inTop){ + this.startPacify(); + this.findPage(inTop); + var h = this.height; + var b = this.getScrollBottom(inTop); + for(var p=this.page, y=this.pageTop; (p= 0 ? inTop + this.windowHeight : -1); + }, + // events + processNodeEvent: function(e, inNode){ + var t = e.target; + while(t && (t != inNode) && t.parentNode && (t.parentNode.parentNode != inNode)){ + t = t.parentNode; + } + if(!t || !t.parentNode || (t.parentNode.parentNode != inNode)){ + return false; + } + var page = t.parentNode; + e.topRowIndex = page.pageIndex * this.rowsPerPage; + e.rowIndex = e.topRowIndex + dojox.grid.indexInParent(t); + e.rowTarget = t; + return true; + }, + processEvent: function(e){ + return this.processNodeEvent(e, this.contentNode); + }, + dummy: 0 +}); + +dojo.declare('dojox.grid.scroller', dojox.grid.scroller.base, { + // summary: + // virtual scroller class, makes no assumption about shape of items being scrolled + constructor: function(){ + this.pageNodes = []; + }, + // virtual rendering interface + renderRow: function(inRowIndex, inPageNode){ + }, + removeRow: function(inRowIndex){ + }, + // page node operations + getDefaultNodes: function(){ + return this.pageNodes; + }, + getDefaultPageNode: function(inPageIndex){ + return this.getDefaultNodes()[inPageIndex]; + }, + positionPageNode: function(inNode, inPos){ + inNode.style.top = inPos + 'px'; + }, + getPageNodePosition: function(inNode){ + return inNode.offsetTop; + }, + repositionPageNodes: function(inPageIndex, inNodes){ + var last = 0; + for(var i=0; i=0 && inBottom>inScrollBottom; i--, row--){ + inBottom -= rows[i].offsetHeight; + } + return row + 1; + }, + getLastVisibleRow: function(inPage, inBottom, inScrollBottom){ + if(!this.pageExists(inPage)){ + return 0; + } + return this.getLastVisibleRowNodes(inPage, inBottom, inScrollBottom, this.getDefaultNodes()); + }, + findTopRowForNodes: function(inScrollTop, inNodes){ + var rows = dojox.grid.divkids(inNodes[this.page]); + for(var i=0,l=rows.length,t=this.pageTop,h; i= inScrollTop){ + this.offset = h - (t - inScrollTop); + return i + this.page * this.rowsPerPage; + } + } + return -1; + }, + findScrollTopForNodes: function(inRow, inNodes){ + var rowPage = Math.floor(inRow / this.rowsPerPage); + var t = 0; + for(var i=0; i= inIndex){ + this.selectedIndex++; + } + }, + + remove: function(inIndex){ + this.selected.splice(inIndex, 1); + if(this.selectedIndex >= inIndex){ + this.selectedIndex--; + } + }, + + unselectAll: function(inExcept){ + for(var i in this.selected){ + if((i!=inExcept)&&(this.selected[i]===true)){ + this.deselect(i); + } + } + }, + + shiftSelect: function(inFrom, inTo){ + var s = (inFrom >= 0 ? inFrom : inTo), e = inTo; + if(s > e){ + e = s; + s = inTo; + } + for(var i=s; i<=e; i++){ + this.addToSelection(i); + } + }, + + clickSelect: function(inIndex, inCtrlKey, inShiftKey){ + this.beginUpdate(); + if(!this.multiSelect){ + this.select(inIndex); + }else{ + var lastSelected = this.selectedIndex; + if(!inCtrlKey){ + this.unselectAll(inIndex); + } + if(inShiftKey){ + this.shiftSelect(lastSelected, inIndex); + }else if(inCtrlKey){ + this.toggleSelect(inIndex); + }else{ + this.addToSelection(inIndex) + } + } + this.endUpdate(); + }, + + clickSelectEvent: function(e){ + this.clickSelect(e.rowIndex, e.ctrlKey, e.shiftKey); + }, + + clear: function(){ + this.beginUpdate(); + this.unselectAll(); + this.endUpdate(); + } + +}); + +} diff --git a/includes/js/dojox/grid/_grid/soriaGrid.css b/includes/js/dojox/grid/_grid/soriaGrid.css new file mode 100644 index 0000000..f244030 --- /dev/null +++ b/includes/js/dojox/grid/_grid/soriaGrid.css @@ -0,0 +1,212 @@ +.soria .dojoxGrid { + position: relative; + background-color: #e9e9e9; + font-size: 0.85em; + -moz-outline-style: none; + outline: none; + overflow: hidden; + height: 0; +} +.soria .dojoxGrid table { + padding: 0; +} +.soria .dojoxGrid td { + -moz-outline: none; +} +.soria .dojoxGrid-master-header { + position: relative; +} +.soria .dojoxGrid-master-view { + position: relative; +} +.soria .dojoxGrid-view { + position: absolute; + overflow: hidden; +} +.soria .dojoxGrid-header { + position: absolute; + overflow: hidden; +} +.soria .dojoxGrid-header { + background-color: #e9e9e9; +} +.soria .dojoxGrid-header table { + text-align: center; +} +.soria .dojoxGrid-header .dojoxGrid-cell-content { + text-align: center; +} +.soria .dojoxGrid-header .dojoxGrid-cell { + border: 1px solid transparent; + + border-color: white #ACA899 #919191 white; + background: url(../../../dijit/themes/soria/images/titleBar.png) #e9e9e9 repeat-x top; + padding-bottom: 2px; + color: #000 !important; +} +.soria .dojoxGrid-header .dojoxGrid-cell-over { + background: url(../../../dijit/themes/soria/images/titleBarActive.png) #e9e9e9 repeat-x top; +} +.soria .dojoxGrid-sort-down { + background: url(images/grid_sort_down.gif) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} +.soria .dojoxGrid-sort-up { + background: url(images/grid_sort_up.gif) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} +.soria .gridArrowButtonChar { + display:none !important; +} +.dijit_a11y .gridArrowButtonChar { + display:inline !important; +} +.soria .dojoxGrid-scrollbox { + position: relative; + overflow: scroll; + background-color: #fefefe; + width: 100%; +} +.soria .dojoxGrid-content { + position: relative; + overflow: hidden; + -moz-outline-style: none; + outline: none; +} +.soria .dojoxGrid-rowbar { + border: none; + + background: url(images/titleBar.png) #e9e9e9 repeat-y right; + border-right: 1px solid #cccccc; + padding: 0px; +} +.soria .dojoxGrid-rowbar-inner { + border: none; + border-bottom: 1px solid #cccccc; +} +.soria .dojoxGrid-rowbar-over { + background: url(images/titleBarActive.png) #e9e9e9 repeat-y right; +} +.soria .dojoxGrid-rowbar-selected { + background-color: #D9E8F9; + background-image: none; + background: url(../../../dijit/themes/soria/images/titleBar.png) #dddddd repeat-x top; + border-right: 1px solid #cccccc; + background-position: center; + background-repeat: no-repeat; +} +.soria .dojoxGrid-row { + position: relative; + width: 9000em; +} +.soria .dojoxGrid-row { + border: none; + border-left: none; + border-right: none; + background-color: white; + border-top: none; +} +.soria .dojoxGrid-row-over { + border-top-color: #cccccc; + border-bottom-color: #cccccc; +} +.soria .dojoxGrid-row-over .dojoxGrid-cell { + background-color: #60a1ea; + color:#fff; +} +.soria .dojoxGrid-row-odd { + background-color: #f2f5f9; + +} +.soria .dojoxGrid-row-selected { + background-color: #aec7e3; +} +.soria .dojoxGrid-row-table { + table-layout: fixed; + width: 0; + border-collapse: collapse; +} +.soria .dojoxGrid-invisible { + visibility: hidden; +} +.soria .Xdojo-ie .dojoxGrid-invisible { + display: none; +} +.soria .dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td { + border-top-width: 0; + border-bottom-width: 0; + padding-top: 0; + padding-bottom: 0; + height: 0; + overflow: hidden; +} +.soria .dojoxGrid-cell { + border: 1px dotted #D5CDB5; + padding: 3px 3px 3px 3px; + text-align: left; + overflow: hidden; +} +.dj_ie6 .soria .dojoxGrid-cell { + border: 1px solid white; + border-right: 1px solid #D5CDB5; +} +.soria .dojoxGrid-cell-focus { + border: 1px dotted #a6a6a6; +} +.soria .dojoxGrid-cell-over { + border: 1px dotted #a6a6a6; +} +.soria .dojoxGrid-cell-focus.dojoxGrid-cell-over { + border: 1px dotted #595959; +} +.soria .dojoxGrid-cell-clip { + width: 100%; + overflow: hidden; + white-space:nowrap; + text-overflow: ellipsis; +} +.soria .dojoxGrid-row-editing td { + + background-color: #60a1ea; + +} +.soria .dojoxGrid-row-inserting td { + background-color: #F4FFF4; +} +.soria .dojoxGrid-row-inflight td { + background-color: #F2F7B7; +} +.soria .dojoxGrid-row-error td { + background-color: #F8B8B6; +} +.soria .dojoxGrid-input, +.soria .dojoxGrid-select, +.soria .dojoxGrid-textarea { + margin: 0; + padding: 0px; + border-style: none; + width: 100%; + font-size: 100%; + font-family: inherit; +} +.dojoxGrid-hidden-focus { + position: absolute; + left: -1000px; + top: -1000px; + height: 0px, width: 0px; +} +.dijit_a11y .dojoxGrid-rowbar-selected { + border-top: 1px solid white; + border-bottom: 1px dashed black; + border-top: 0; + background: none; +} +.dijit_a11y .dojoxGrid-rowbar-selected .dojoxGrid-rowbar-inner { + border: 0; + border-top: 1px solid white; +} +.dijit_a11y .dojoxGrid-row-selected { + border-bottom: 1px dashed black; +} diff --git a/includes/js/dojox/grid/_grid/soriaGrid.css.commented.css b/includes/js/dojox/grid/_grid/soriaGrid.css.commented.css new file mode 100644 index 0000000..06263ad --- /dev/null +++ b/includes/js/dojox/grid/_grid/soriaGrid.css.commented.css @@ -0,0 +1,276 @@ +.soria .dojoxGrid { + position: relative; + background-color: #e9e9e9; + font-size: 0.85em; /* inherit font-family from dojo.css */ + -moz-outline-style: none; + outline: none; + overflow: hidden; + height: 0; +} + +.soria .dojoxGrid table { + padding: 0; +} + +.soria .dojoxGrid td { + -moz-outline: none; +} + +/* master header */ + +.soria .dojoxGrid-master-header { + position: relative; +} + +/* master view */ + +.soria .dojoxGrid-master-view { + position: relative; +} + +/* views */ + +.soria .dojoxGrid-view { + position: absolute; + overflow: hidden; +} + +/* header */ + +.soria .dojoxGrid-header { + position: absolute; + overflow: hidden; +} + +.soria .dojoxGrid-header { + background-color: #e9e9e9; +} + +.soria .dojoxGrid-header table { + text-align: center; +} + +.soria .dojoxGrid-header .dojoxGrid-cell-content { + text-align: center; +} + +.soria .dojoxGrid-header .dojoxGrid-cell { + border: 1px solid transparent; + /* border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; */ + border-color: white #ACA899 #919191 white; + background: url(../../../dijit/themes/soria/images/titleBar.png) #e9e9e9 repeat-x top; + padding-bottom: 2px; + color: #000 !important; +} + +.soria .dojoxGrid-header .dojoxGrid-cell-over { + background: url(../../../dijit/themes/soria/images/titleBarActive.png) #e9e9e9 repeat-x top; +} + +.soria .dojoxGrid-sort-down { + background: url(images/grid_sort_down.gif) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} + +.soria .dojoxGrid-sort-up { + background: url(images/grid_sort_up.gif) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} + +.soria .gridArrowButtonChar { + display:none !important; +} +.dijit_a11y .gridArrowButtonChar { + display:inline !important; +} + +/* content */ + +.soria .dojoxGrid-scrollbox { + position: relative; + overflow: scroll; + background-color: #fefefe; + width: 100%; +} + +.soria .dojoxGrid-content { + position: relative; + overflow: hidden; + -moz-outline-style: none; + outline: none; +} + +/* rowbar */ + +.soria .dojoxGrid-rowbar { + border: none; + /* + border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; + */ + background: url(images/titleBar.png) #e9e9e9 repeat-y right; + border-right: 1px solid #cccccc; + padding: 0px; +} + +.soria .dojoxGrid-rowbar-inner { + border: none; + border-bottom: 1px solid #cccccc; +} + +.soria .dojoxGrid-rowbar-over { + background: url(images/titleBarActive.png) #e9e9e9 repeat-y right; +} + +.soria .dojoxGrid-rowbar-selected { + background-color: #D9E8F9; + background-image: none; + background: url(../../../dijit/themes/soria/images/titleBar.png) #dddddd repeat-x top; + border-right: 1px solid #cccccc; + background-position: center; + background-repeat: no-repeat; +} + +/* rows */ + +.soria .dojoxGrid-row { + position: relative; + width: 9000em; +} + +.soria .dojoxGrid-row { + border: none; + border-left: none; + border-right: none; + background-color: white; + border-top: none; +} + +.soria .dojoxGrid-row-over { + border-top-color: #cccccc; + border-bottom-color: #cccccc; +} + +.soria .dojoxGrid-row-over .dojoxGrid-cell { + background-color: #60a1ea; + color:#fff; +} + +.soria .dojoxGrid-row-odd { + background-color: #f2f5f9; + /*background-color: #F9F7E8;*/ +} + +.soria .dojoxGrid-row-selected { + background-color: #aec7e3; +} + +.soria .dojoxGrid-row-table { + table-layout: fixed; + width: 0; + border-collapse: collapse; +} + +.soria .dojoxGrid-invisible { + visibility: hidden; +} + +.soria .Xdojo-ie .dojoxGrid-invisible { + display: none; +} + +.soria .dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td { + border-top-width: 0; + border-bottom-width: 0; + padding-top: 0; + padding-bottom: 0; + height: 0; + overflow: hidden; +} + +/* cells */ + +.soria .dojoxGrid-cell { + border: 1px dotted #D5CDB5; + padding: 3px 3px 3px 3px; + text-align: left; + overflow: hidden; +} + +.dj_ie6 .soria .dojoxGrid-cell { + border: 1px solid white; + border-right: 1px solid #D5CDB5; +} + +.soria .dojoxGrid-cell-focus { + border: 1px dotted #a6a6a6; +} + +.soria .dojoxGrid-cell-over { + border: 1px dotted #a6a6a6; +} + +.soria .dojoxGrid-cell-focus.dojoxGrid-cell-over { + border: 1px dotted #595959; +} + +.soria .dojoxGrid-cell-clip { + width: 100%; + overflow: hidden; + white-space:nowrap; + text-overflow: ellipsis; +} + +/* editing */ + +/* FIXME: these colors are off! */ +.soria .dojoxGrid-row-editing td { + /* background-color: #F4FFF4; */ + background-color: #60a1ea; + /* padding: 0px 3px 0px 3px; */ +} + +.soria .dojoxGrid-row-inserting td { + background-color: #F4FFF4; +} +.soria .dojoxGrid-row-inflight td { + background-color: #F2F7B7; +} +.soria .dojoxGrid-row-error td { + background-color: #F8B8B6; +} + +.soria .dojoxGrid-input, +.soria .dojoxGrid-select, +.soria .dojoxGrid-textarea { + margin: 0; + padding: 0px; + border-style: none; + width: 100%; + font-size: 100%; + font-family: inherit; +} + +.dojoxGrid-hidden-focus { + position: absolute; + left: -1000px; + top: -1000px; + height: 0px, width: 0px; +} + +.dijit_a11y .dojoxGrid-rowbar-selected { + border-top: 1px solid white; + border-bottom: 1px dashed black; + border-top: 0; + background: none; +} + +.dijit_a11y .dojoxGrid-rowbar-selected .dojoxGrid-rowbar-inner { + border: 0; + border-top: 1px solid white; +} + +.dijit_a11y .dojoxGrid-row-selected { + border-bottom: 1px dashed black; +} diff --git a/includes/js/dojox/grid/_grid/tundraGrid.css b/includes/js/dojox/grid/_grid/tundraGrid.css new file mode 100644 index 0000000..d7b7a5f --- /dev/null +++ b/includes/js/dojox/grid/_grid/tundraGrid.css @@ -0,0 +1,215 @@ +.tundra .dojoxGrid { + position: relative; + background-color: #e9e9e9; + font-size: 0.85em; + -moz-outline-style: none; + outline: none; + overflow: hidden; + height: 0; +} +.tundra .dojoxGrid table { + padding: 0; +} +.tundra .dojoxGrid td { + -moz-outline: none; +} +.tundra .dojoxGrid-master-header { + position: relative; +} +.tundra .dojoxGrid-master-view { + position: relative; +} +.tundra .dojoxGrid-view { + position: absolute; + overflow: hidden; +} +.tundra .dojoxGrid-header { + position: absolute; + overflow: hidden; +} +.tundra .dojoxGrid-header { + background-color: #e9e9e9; +} +.tundra .dojoxGrid-header table { + text-align: center; +} +.tundra .dojoxGrid-header .dojoxGrid-cell-content { + text-align: center; +} +.tundra .dojoxGrid-header .dojoxGrid-cell { + border: 1px solid transparent; + + border-color: white #ACA899 #919191 white; + background: url(../../../dijit/themes/tundra/images/tabEnabled.png) #e9e9e9 repeat-x top; + padding-bottom: 2px; + color: #000 !important; +} +.tundra .dojoxGrid-header .dojoxGrid-cell-over { + background: url(../../../dijit/themes/tundra/images/tabHover.png) #e9e9e9 repeat-x top; + color: #000 !important; +} +.tundra .dojoxGrid-sort-down { + background: url(../../../dijit/themes/tundra/images/arrowDown.png) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} +.tundra .dojoxGrid-sort-up { + background: url(../../../dijit/themes/tundra/images/arrowUp.png) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} +.tundra .gridArrowButtonChar { + display:none !important; +} +.dijit_a11y .gridArrowButtonChar { + display:inline !important; +} +.tundra .dojoxGrid-scrollbox { + position: relative; + overflow: scroll; + background-color: #fefefe; + width: 100%; +} +.tundra .dojoxGrid-content { + position: relative; + overflow: hidden; + -moz-outline-style: none; + outline: none; +} +.tundra .dojoxGrid-rowbar { + border: none; + + background: url(images/tabEnabled_rotated.png) #e9e9e9 repeat-y right; + border-right: 1px solid #cccccc; + padding: 0px; +} +.tundra .dojoxGrid-rowbar-inner { + border: none; + border-bottom: 1px solid #cccccc; +} +.tundra .dojoxGrid-rowbar-over { + background: url(images/tabHover_rotated.png) #e9e9e9 repeat-y right; +} +.tundra .dojoxGrid-rowbar-selected { + background-color: #D9E8F9; + background-image: none; + background: url(../../../dijit/themes/tundra/images/tabDisabled.png) #dddddd repeat-x top; + border-right: 1px solid #cccccc; + background-position: center; + background-repeat: no-repeat; +} +.tundra .dojoxGrid-row { + position: relative; + width: 9000em; +} +.tundra .dojoxGrid-row { + border: none; + border-left: none; + border-right: none; + background-color: white; + border-top: none; +} +.tundra .dojoxGrid-row-over { + border-top-color: #cccccc; + border-bottom-color: #cccccc; +} +.tundra .dojoxGrid-row-over .dojoxGrid-cell { + background-color: #60a1ea; + color:#fff; + +} +.tundra .dojoxGrid-row-odd { + background-color: #f2f5f9; + +} +.tundra .dojoxGrid-row-selected { + background-color: #aec7e3; + +} +.tundra .dojoxGrid-row-table { + table-layout: fixed; + width: 0; + border-collapse: collapse; +} +.tundra .dojoxGrid-invisible { + visibility: hidden; +} +.tundra .Xdojo-ie .dojoxGrid-invisible { + display: none; +} +.tundra .dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td { + border-top-width: 0; + border-bottom-width: 0; + padding-top: 0; + padding-bottom: 0; + height: 0; + overflow: hidden; +} +.tundra .dojoxGrid-cell { + border: 1px dotted #D5CDB5; + padding: 3px 3px 3px 3px; + text-align: left; + overflow: hidden; +} +.dj_ie6 .tundra .dojoxGrid-cell { + border: 1px solid white; + border-right: 1px solid #D5CDB5; +} +.tundra .dojoxGrid-cell-focus { + border: 1px dotted #a6a6a6; +} +.tundra .dojoxGrid-cell-over { + border: 1px dotted #a6a6a6; +} +.tundra .dojoxGrid-cell-focus.dojoxGrid-cell-over { + border: 1px dotted #595959; +} +.tundra .dojoxGrid-cell-clip { + width: 100%; + overflow: hidden; + white-space:nowrap; + text-overflow: ellipsis; +} +.tundra .dojoxGrid-row-editing td { + + background-color: #60a1ea; + +} +.tundra .dojoxGrid-row-inserting td { + background-color: #F4FFF4; +} +.tundra .dojoxGrid-row-inflight td { + background-color: #F2F7B7; +} +.tundra .dojoxGrid-row-error td { + background-color: #F8B8B6; +} +.tundra .dojoxGrid-input, +.tundra .dojoxGrid-select, +.tundra .dojoxGrid-textarea { + margin: 0; + padding: 0px; + border-style: none; + width: 100%; + font-size: 100%; + font-family: inherit; +} +.dojoxGrid-hidden-focus { + position: absolute; + left: -1000px; + top: -1000px; + height: 0px, width: 0px; +} +.dijit_a11y .dojoxGrid-rowbar-selected { + border-top: 1px solid white; + border-bottom: 1px dashed black; + border-top: 0; + background: none; +} +.dijit_a11y .dojoxGrid-rowbar-selected .dojoxGrid-rowbar-inner { + border: 0; + border-top: 1px solid white; +} +.dijit_a11y .dojoxGrid-row-selected { + border-bottom: 1px dashed black; +} diff --git a/includes/js/dojox/grid/_grid/tundraGrid.css.commented.css b/includes/js/dojox/grid/_grid/tundraGrid.css.commented.css new file mode 100644 index 0000000..a282f58 --- /dev/null +++ b/includes/js/dojox/grid/_grid/tundraGrid.css.commented.css @@ -0,0 +1,281 @@ +.tundra .dojoxGrid { + position: relative; + background-color: #e9e9e9; + font-size: 0.85em; /* inherit font-family from dojo.css */ + -moz-outline-style: none; + outline: none; + overflow: hidden; + height: 0; +} + +.tundra .dojoxGrid table { + padding: 0; +} + +.tundra .dojoxGrid td { + -moz-outline: none; +} + +/* master header */ + +.tundra .dojoxGrid-master-header { + position: relative; +} + +/* master view */ + +.tundra .dojoxGrid-master-view { + position: relative; +} + +/* views */ + +.tundra .dojoxGrid-view { + position: absolute; + overflow: hidden; +} + +/* header */ + +.tundra .dojoxGrid-header { + position: absolute; + overflow: hidden; +} + +.tundra .dojoxGrid-header { + background-color: #e9e9e9; +} + +.tundra .dojoxGrid-header table { + text-align: center; +} + +.tundra .dojoxGrid-header .dojoxGrid-cell-content { + text-align: center; +} + +.tundra .dojoxGrid-header .dojoxGrid-cell { + border: 1px solid transparent; + /* border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; */ + border-color: white #ACA899 #919191 white; + background: url(../../../dijit/themes/tundra/images/tabEnabled.png) #e9e9e9 repeat-x top; + padding-bottom: 2px; + color: #000 !important; +} + +.tundra .dojoxGrid-header .dojoxGrid-cell-over { + background: url(../../../dijit/themes/tundra/images/tabHover.png) #e9e9e9 repeat-x top; + color: #000 !important; +} + +.tundra .dojoxGrid-sort-down { + background: url(../../../dijit/themes/tundra/images/arrowDown.png) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} + +.tundra .dojoxGrid-sort-up { + background: url(../../../dijit/themes/tundra/images/arrowUp.png) right no-repeat; + padding-left: 0px; + margin-left: 0px; +} + +.tundra .gridArrowButtonChar { + display:none !important; +} +.dijit_a11y .gridArrowButtonChar { + display:inline !important; +} + +/* content */ + +.tundra .dojoxGrid-scrollbox { + position: relative; + overflow: scroll; + background-color: #fefefe; + width: 100%; +} + +.tundra .dojoxGrid-content { + position: relative; + overflow: hidden; + -moz-outline-style: none; + outline: none; +} + +/* rowbar */ + +.tundra .dojoxGrid-rowbar { + border: none; + /* + border-color: #F6F4EB #ACA899 #ACA899 #F6F4EB; + */ + background: url(images/tabEnabled_rotated.png) #e9e9e9 repeat-y right; + border-right: 1px solid #cccccc; + padding: 0px; +} + +.tundra .dojoxGrid-rowbar-inner { + border: none; + border-bottom: 1px solid #cccccc; +} + +.tundra .dojoxGrid-rowbar-over { + background: url(images/tabHover_rotated.png) #e9e9e9 repeat-y right; +} + +.tundra .dojoxGrid-rowbar-selected { + background-color: #D9E8F9; + background-image: none; + background: url(../../../dijit/themes/tundra/images/tabDisabled.png) #dddddd repeat-x top; + border-right: 1px solid #cccccc; + background-position: center; + background-repeat: no-repeat; +} + +/* rows */ + +.tundra .dojoxGrid-row { + position: relative; + width: 9000em; +} + +.tundra .dojoxGrid-row { + border: none; + border-left: none; + border-right: none; + background-color: white; + border-top: none; +} + +.tundra .dojoxGrid-row-over { + border-top-color: #cccccc; + border-bottom-color: #cccccc; +} + +.tundra .dojoxGrid-row-over .dojoxGrid-cell { + background-color: #60a1ea; + color:#fff; + /*background: url(../../../dijit/themes/tundra/images/tabEnabled.png) #e9e9e9 repeat-x top;*/ +} + +.tundra .dojoxGrid-row-odd { + background-color: #f2f5f9; + /*background-color: #F9F7E8;*/ +} + +.tundra .dojoxGrid-row-selected { + background-color: #aec7e3; + /* + background: url(../../../dijit/themes/tundra/images/tabDisabled.png) #dddddd repeat-x top; + */ +} + +.tundra .dojoxGrid-row-table { + table-layout: fixed; + width: 0; + border-collapse: collapse; +} + +.tundra .dojoxGrid-invisible { + visibility: hidden; +} + +.tundra .Xdojo-ie .dojoxGrid-invisible { + display: none; +} + +.tundra .dojoxGrid-invisible td, .dojoxGrid-header .dojoxGrid-invisible td { + border-top-width: 0; + border-bottom-width: 0; + padding-top: 0; + padding-bottom: 0; + height: 0; + overflow: hidden; +} + +/* cells */ + +.tundra .dojoxGrid-cell { + border: 1px dotted #D5CDB5; + padding: 3px 3px 3px 3px; + text-align: left; + overflow: hidden; +} + +.dj_ie6 .tundra .dojoxGrid-cell { + border: 1px solid white; + border-right: 1px solid #D5CDB5; +} + +.tundra .dojoxGrid-cell-focus { + border: 1px dotted #a6a6a6; +} + +.tundra .dojoxGrid-cell-over { + border: 1px dotted #a6a6a6; +} + +.tundra .dojoxGrid-cell-focus.dojoxGrid-cell-over { + border: 1px dotted #595959; +} + +.tundra .dojoxGrid-cell-clip { + width: 100%; + overflow: hidden; + white-space:nowrap; + text-overflow: ellipsis; +} + +/* editing */ + +/* FIXME: these colors are off! */ +.tundra .dojoxGrid-row-editing td { + /* background-color: #F4FFF4; */ + background-color: #60a1ea; + /* padding: 0px 3px 0px 3px; */ +} + +.tundra .dojoxGrid-row-inserting td { + background-color: #F4FFF4; +} +.tundra .dojoxGrid-row-inflight td { + background-color: #F2F7B7; +} +.tundra .dojoxGrid-row-error td { + background-color: #F8B8B6; +} + +.tundra .dojoxGrid-input, +.tundra .dojoxGrid-select, +.tundra .dojoxGrid-textarea { + margin: 0; + padding: 0px; + border-style: none; + width: 100%; + font-size: 100%; + font-family: inherit; +} + +.dojoxGrid-hidden-focus { + position: absolute; + left: -1000px; + top: -1000px; + height: 0px, width: 0px; +} + +.dijit_a11y .dojoxGrid-rowbar-selected { + border-top: 1px solid white; + border-bottom: 1px dashed black; + border-top: 0; + background: none; +} + +.dijit_a11y .dojoxGrid-rowbar-selected .dojoxGrid-rowbar-inner { + border: 0; + border-top: 1px solid white; +} + +.dijit_a11y .dojoxGrid-row-selected { + border-bottom: 1px dashed black; +} diff --git a/includes/js/dojox/grid/_grid/view.js b/includes/js/dojox/grid/_grid/view.js new file mode 100644 index 0000000..7f669cd --- /dev/null +++ b/includes/js/dojox/grid/_grid/view.js @@ -0,0 +1,336 @@ +if(!dojo._hasResource["dojox.grid._grid.view"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.view"] = true; +dojo.provide("dojox.grid._grid.view"); + +dojo.require("dijit._Widget"); +dojo.require("dijit._Templated"); +dojo.require("dojox.grid._grid.builder"); + +dojo.declare('dojox.GridView', + [dijit._Widget, dijit._Templated], + { + // summary: + // A collection of grid columns. A grid is comprised of a set of views that stack horizontally. + // Grid creates views automatically based on grid's layout structure. + // Users should typically not need to access individual views directly. + // + // defaultWidth: String + // Default widget of the view + defaultWidth: "18em", + + // viewWidth: String + // Width for the view, in valid css unit + viewWidth: "", + + templateString:"
\n\t
\n\t\t
\n\t\t\t
\n\t\t
\n\t
\n\t\n\t\n\t
\n\t\t
\n\t
\n
\n", + + themeable: false, + classTag: 'dojoxGrid', + marginBottom: 0, + rowPad: 2, + + postMixInProperties: function(){ + this.rowNodes = []; + }, + + postCreate: function(){ + this.connect(this.scrollboxNode,"onscroll","doscroll"); + dojox.grid.funnelEvents(this.contentNode, this, "doContentEvent", [ 'mouseover', 'mouseout', 'click', 'dblclick', 'contextmenu', 'mousedown' ]); + dojox.grid.funnelEvents(this.headerNode, this, "doHeaderEvent", [ 'dblclick', 'mouseover', 'mouseout', 'mousemove', 'mousedown', 'click', 'contextmenu' ]); + this.content = new dojox.grid.contentBuilder(this); + this.header = new dojox.grid.headerBuilder(this); + //BiDi: in RTL case, style width='9000em' causes scrolling problem in head node + if(!dojo._isBodyLtr()){ + this.headerNodeContainer.style.width = ""; + } + }, + + destroy: function(){ + dojox.grid.removeNode(this.headerNode); + this.inherited("destroy", arguments); + }, + + // focus + focus: function(){ + if(dojo.isSafari || dojo.isOpera){ + this.hiddenFocusNode.focus(); + }else{ + this.scrollboxNode.focus(); + } + }, + + setStructure: function(inStructure){ + var vs = this.structure = inStructure; + // FIXME: similar logic is duplicated in layout + if(vs.width && !isNaN(vs.width)){ + this.viewWidth = vs.width + 'em'; + }else{ + this.viewWidth = vs.width || this.viewWidth; //|| this.defaultWidth; + } + this.onBeforeRow = vs.onBeforeRow; + this.noscroll = vs.noscroll; + if(this.noscroll){ + this.scrollboxNode.style.overflow = "hidden"; + } + // bookkeeping + this.testFlexCells(); + // accomodate new structure + this.updateStructure(); + }, + + testFlexCells: function(){ + // FIXME: cheater, this function does double duty as initializer and tester + this.flexCells = false; + for(var j=0, row; (row=this.structure.rows[j]); j++){ + for(var i=0, cell; (cell=row[i]); i++){ + cell.view = this; + this.flexCells = this.flexCells || cell.isFlex(); + } + } + return this.flexCells; + }, + + updateStructure: function(){ + // header builder needs to update table map + this.header.update(); + // content builder needs to update markup cache + this.content.update(); + }, + + getScrollbarWidth: function(){ + return (this.noscroll ? 0 : dojox.grid.getScrollbarWidth()); // Integer + }, + + getColumnsWidth: function(){ + return this.headerContentNode.firstChild.offsetWidth; // Integer + }, + + getWidth: function(){ + return this.viewWidth || (this.getColumnsWidth()+this.getScrollbarWidth()) +'px'; // String + }, + + getContentWidth: function(){ + return Math.max(0, dojo._getContentBox(this.domNode).w - this.getScrollbarWidth()) + 'px'; // String + }, + + render: function(){ + this.scrollboxNode.style.height = ''; + this.renderHeader(); + }, + + renderHeader: function(){ + this.headerContentNode.innerHTML = this.header.generateHtml(this._getHeaderContent); + }, + + // note: not called in 'view' context + _getHeaderContent: function(inCell){ + var n = inCell.name || inCell.grid.getCellName(inCell); + if(inCell.index != inCell.grid.getSortIndex()){ + return n; + } + return [ '
', inCell.grid.sortInfo > 0 ? '▼' : '▲', '
', n, '
' ].join(''); + }, + + resize: function(){ + this.adaptHeight(); + this.adaptWidth(); + }, + + hasScrollbar: function(){ + return (this.scrollboxNode.clientHeight != this.scrollboxNode.offsetHeight); // Boolean + }, + + adaptHeight: function(){ + if(!this.grid.autoHeight){ + var h = this.domNode.clientHeight; + if(!this.hasScrollbar()){ // no scrollbar is rendered + h -= dojox.grid.getScrollbarWidth(); + } + dojox.grid.setStyleHeightPx(this.scrollboxNode, h); + } + }, + + adaptWidth: function(){ + if(this.flexCells){ + // the view content width + this.contentWidth = this.getContentWidth(); + this.headerContentNode.firstChild.style.width = this.contentWidth; + } + // FIXME: it should be easier to get w from this.scrollboxNode.clientWidth, + // but clientWidth seemingly does not include scrollbar width in some cases + var w = this.scrollboxNode.offsetWidth - this.getScrollbarWidth(); + w = Math.max(w, this.getColumnsWidth()) + 'px'; + with(this.contentNode){ + style.width = ''; + offsetWidth; + style.width = w; + } + }, + + setSize: function(w, h){ + with(this.domNode.style){ + if(w){ + width = w; + } + height = (h >= 0 ? h + 'px' : ''); + } + with(this.headerNode.style){ + if(w){ + width = w; + } + } + }, + + renderRow: function(inRowIndex, inHeightPx){ + var rowNode = this.createRowNode(inRowIndex); + this.buildRow(inRowIndex, rowNode, inHeightPx); + this.grid.edit.restore(this, inRowIndex); + return rowNode; + }, + + createRowNode: function(inRowIndex){ + var node = document.createElement("div"); + node.className = this.classTag + '-row'; + node[dojox.grid.gridViewTag] = this.id; + node[dojox.grid.rowIndexTag] = inRowIndex; + this.rowNodes[inRowIndex] = node; + return node; + }, + + buildRow: function(inRowIndex, inRowNode){ + this.buildRowContent(inRowIndex, inRowNode); + this.styleRow(inRowIndex, inRowNode); + }, + + buildRowContent: function(inRowIndex, inRowNode){ + inRowNode.innerHTML = this.content.generateHtml(inRowIndex, inRowIndex); + if(this.flexCells){ + // FIXME: accessing firstChild here breaks encapsulation + inRowNode.firstChild.style.width = this.contentWidth; + } + }, + + rowRemoved:function(inRowIndex){ + this.grid.edit.save(this, inRowIndex); + delete this.rowNodes[inRowIndex]; + }, + + getRowNode: function(inRowIndex){ + return this.rowNodes[inRowIndex]; + }, + + getCellNode: function(inRowIndex, inCellIndex){ + var row = this.getRowNode(inRowIndex); + if(row){ + return this.content.getCellNode(row, inCellIndex); + } + }, + + // styling + styleRow: function(inRowIndex, inRowNode){ + inRowNode._style = dojox.grid.getStyleText(inRowNode); + this.styleRowNode(inRowIndex, inRowNode); + }, + + styleRowNode: function(inRowIndex, inRowNode){ + if(inRowNode){ + this.doStyleRowNode(inRowIndex, inRowNode); + } + }, + + doStyleRowNode: function(inRowIndex, inRowNode){ + this.grid.styleRowNode(inRowIndex, inRowNode); + }, + + // updating + updateRow: function(inRowIndex, inHeightPx, inPageNode){ + var rowNode = this.getRowNode(inRowIndex); + if(rowNode){ + rowNode.style.height = ''; + this.buildRow(inRowIndex, rowNode); + } + return rowNode; + }, + + updateRowStyles: function(inRowIndex){ + this.styleRowNode(inRowIndex, this.getRowNode(inRowIndex)); + }, + + // scrolling + lastTop: 0, + firstScroll:0, + + doscroll: function(inEvent){ + //var s = dojo.marginBox(this.headerContentNode.firstChild); + var isLtr = dojo._isBodyLtr(); + if(this.firstScroll < 2){ + if((!isLtr && this.firstScroll == 1) || (isLtr && this.firstScroll == 0)){ + var s = dojo.marginBox(this.headerNodeContainer); + if(dojo.isIE){ + this.headerNodeContainer.style.width = s.w + this.getScrollbarWidth() + 'px'; + }else if(dojo.isMoz){ + //TODO currently only for FF, not sure for safari and opera + this.headerNodeContainer.style.width = s.w - this.getScrollbarWidth() + 'px'; + //this.headerNodeContainer.style.width = s.w + 'px'; + //set scroll to right in FF + if(isLtr){ + this.scrollboxNode.scrollLeft = this.scrollboxNode.scrollWidth - this.scrollboxNode.clientWidth; + }else{ + this.scrollboxNode.scrollLeft = this.scrollboxNode.clientWidth - this.scrollboxNode.scrollWidth; + } + } + } + this.firstScroll++; + } + this.headerNode.scrollLeft = this.scrollboxNode.scrollLeft; + // 'lastTop' is a semaphore to prevent feedback-loop with setScrollTop below + var top = this.scrollboxNode.scrollTop; + if(top != this.lastTop){ + this.grid.scrollTo(top); + } + }, + + setScrollTop: function(inTop){ + // 'lastTop' is a semaphore to prevent feedback-loop with doScroll above + this.lastTop = inTop; + this.scrollboxNode.scrollTop = inTop; + return this.scrollboxNode.scrollTop; + }, + + // event handlers (direct from DOM) + doContentEvent: function(e){ + if(this.content.decorateEvent(e)){ + this.grid.onContentEvent(e); + } + }, + + doHeaderEvent: function(e){ + if(this.header.decorateEvent(e)){ + this.grid.onHeaderEvent(e); + } + }, + + // event dispatch(from Grid) + dispatchContentEvent: function(e){ + return this.content.dispatchEvent(e); + }, + + dispatchHeaderEvent: function(e){ + return this.header.dispatchEvent(e); + }, + + // column resizing + setColWidth: function(inIndex, inWidth){ + this.grid.setCellWidth(inIndex, inWidth + 'px'); + }, + + update: function(){ + var left = this.scrollboxNode.scrollLeft; + this.content.update(); + this.grid.update(); + this.scrollboxNode.scrollLeft = left; + this.headerNode.scrollLeft = left; + } +}); + +} diff --git a/includes/js/dojox/grid/_grid/views.js b/includes/js/dojox/grid/_grid/views.js new file mode 100644 index 0000000..d13bbb7 --- /dev/null +++ b/includes/js/dojox/grid/_grid/views.js @@ -0,0 +1,277 @@ +if(!dojo._hasResource["dojox.grid._grid.views"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid._grid.views"] = true; +dojo.provide("dojox.grid._grid.views"); + +dojo.declare('dojox.grid.views', null, { + // summary: + // A collection of grid views. Owned by grid and used internally for managing grid views. + // description: + // Grid creates views automatically based on grid's layout structure. + // Users should typically not need to access individual views or the views collection directly. + constructor: function(inGrid){ + this.grid = inGrid; + }, + + defaultWidth: 200, + + views: [], + + // operations + resize: function(){ + this.onEach("resize"); + }, + + render: function(){ + this.onEach("render"); + }, + + // views + addView: function(inView){ + inView.idx = this.views.length; + this.views.push(inView); + }, + + destroyViews: function(){ + for (var i=0, v; v=this.views[i]; i++) + v.destroy(); + this.views = []; + }, + + getContentNodes: function(){ + var nodes = []; + for(var i=0, v; v=this.views[i]; i++){ + nodes.push(v.contentNode); + } + return nodes; + }, + + forEach: function(inCallback){ + for(var i=0, v; v=this.views[i]; i++){ + inCallback(v, i); + } + }, + + onEach: function(inMethod, inArgs){ + inArgs = inArgs || []; + for(var i=0, v; v=this.views[i]; i++){ + if(inMethod in v){ + v[inMethod].apply(v, inArgs); + } + } + }, + + // layout + normalizeHeaderNodeHeight: function(){ + var rowNodes = []; + for(var i=0, v; (v=this.views[i]); i++){ + if(v.headerContentNode.firstChild){ + rowNodes.push(v.headerContentNode) + }; + } + this.normalizeRowNodeHeights(rowNodes); + }, + + normalizeRowNodeHeights: function(inRowNodes){ + var h = 0; + for(var i=0, n, o; (n=inRowNodes[i]); i++){ + h = Math.max(h, (n.firstChild.clientHeight)||(n.firstChild.offsetHeight)); + } + h = (h >= 0 ? h : 0); + // + var hpx = h + 'px'; + for(var i=0, n; (n=inRowNodes[i]); i++){ + if(n.firstChild.clientHeight!=h){ + n.firstChild.style.height = hpx; + } + } + // + //console.log('normalizeRowNodeHeights ', h); + // + // querying the height here seems to help scroller measure the page on IE + if(inRowNodes&&inRowNodes[0]){ + inRowNodes[0].parentNode.offsetHeight; + } + }, + + resetHeaderNodeHeight: function(){ + for(var i=0, v, n; (v=this.views[i]); i++){ + n = v.headerContentNode.firstChild; + if(n) + n.style.height = ""; + } + }, + + renormalizeRow: function(inRowIndex){ + var rowNodes = []; + for(var i=0, v, n; (v=this.views[i])&&(n=v.getRowNode(inRowIndex)); i++){ + n.firstChild.style.height = ''; + rowNodes.push(n); + } + this.normalizeRowNodeHeights(rowNodes); + }, + + getViewWidth: function(inIndex){ + return this.views[inIndex].getWidth() || this.defaultWidth; + }, + + // must be called after view widths are properly set or height can be miscalculated + // if there are flex columns + measureHeader: function(){ + // need to reset view header heights so they are properly measured. + this.resetHeaderNodeHeight(); + this.forEach(function(inView){ + inView.headerContentNode.style.height = ''; + }); + var h = 0; + // calculate maximum view header height + this.forEach(function(inView){ + h = Math.max(inView.headerNode.offsetHeight, h); + }); + return h; + }, + + measureContent: function(){ + var h = 0; + this.forEach(function(inView) { + h = Math.max(inView.domNode.offsetHeight, h); + }); + return h; + }, + + findClient: function(inAutoWidth){ + // try to use user defined client + var c = this.grid.elasticView || -1; + // attempt to find implicit client + if(c < 0){ + for(var i=1, v; (v=this.views[i]); i++){ + if(v.viewWidth){ + for(i=1; (v=this.views[i]); i++){ + if(!v.viewWidth){ + c = i; + break; + } + } + break; + } + } + } + // client is in the middle by default + if(c < 0){ + c = Math.floor(this.views.length / 2); + } + return c; + }, + + arrange: function(l, w){ + var i, v, vw, len = this.views.length; + // find the client + var c = (w <= 0 ? len : this.findClient()); + // layout views + var setPosition = function(v, l){ + with(v.domNode.style){ + if(!dojo._isBodyLtr()){ + right = l + 'px'; + }else{ + left = l + 'px'; + } + top = 0 + 'px'; + } + with(v.headerNode.style){ + if(!dojo._isBodyLtr()){ + right = l + 'px'; + }else{ + left = l + 'px'; + } + top = 0; + } + } + // for views left of the client + //BiDi TODO: The left and right should not appear in BIDI environment. Should be replaced with + //leading and tailing concept. + for(i=0; (v=this.views[i])&&(i +
+
+
+
+
+ + +
+
+
+ \ No newline at end of file diff --git a/includes/js/dojox/grid/resources/VirtualGrid.html b/includes/js/dojox/grid/resources/VirtualGrid.html new file mode 100644 index 0000000..7253108 --- /dev/null +++ b/includes/js/dojox/grid/resources/VirtualGrid.html @@ -0,0 +1,5 @@ +
+
+
+ +
diff --git a/includes/js/dojox/grid/tests/databaseModel.js b/includes/js/dojox/grid/tests/databaseModel.js new file mode 100644 index 0000000..3c879eb --- /dev/null +++ b/includes/js/dojox/grid/tests/databaseModel.js @@ -0,0 +1,337 @@ +if(!dojo._hasResource["dojox.grid.tests.databaseModel"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.grid.tests.databaseModel"] = true; +dojo.provide("dojox.grid.tests.databaseModel"); +dojo.require("dojox.grid._data.model"); + +// Provides a sparse array that is also traversable inorder +// with basic Array: +// - iterating by index is slow for large sparse arrays +// - for...in iteration is in order of element creation +// maintains a secondary index for interating +// over sparse elements inorder +dojo.declare("dojox.grid.Sparse", null, { + constructor: function() { + this.clear(); + }, + clear: function() { + this.indices = []; + this.values = []; + }, + length: function() { + return this.indices.length; + }, + set: function(inIndex, inValue) { + for (var i=0,l=this.indices.length; i= inIndex) + break; + } + if (this.indices[i] != inIndex) + this.indices.splice(i, 0, inIndex); + this.values[inIndex] = inValue; + }, + get: function(inIndex) { + return this.values[inIndex]; + }, + remove: function(inIndex) { + for (var i=0,l=this.indices.length; i=0) && ((k=inRowIndexes[i])!=undefined); i--) + this.setState(k, inState, inValue); + }, + clearStateForIndexes: function(inRowIndexes, inState) { + for (var i=inRowIndexes.length-1, k; (i>=0) && ((k=inRowIndexes[i])!=undefined); i--) + this.clearState(k, inState); + }, + //$ Return boolean stating whether or not an operation is in progress that may change row indexing. + isAddRemoving: function() { + return Boolean(this.states['inserting'].length() || this.states['removing'].length()); + }, + isInflight: function() { + return Boolean(this.states['inflight'].length()); + }, + //$ Return boolean stating if the model is currently undergoing any type of edit. + isEditing: function() { + for (var i=0, r={}, s; (s=this.stateNames[i]); i++) + if (this.states[s].length()) + return true; + }, + //$ Return true if ok to modify the given row. Override as needed, using model editing state information. + canModify: function(inRowIndex) { + return !this.getState(inRowIndex).inflight && !(this.isInflight() && this.isAddRemoving()); + }, + // server send / receive + getSendParams: function(inParams) { + var p = { + database: this.database || '', + table: this.table || '' + } + return dojo.mixin(p, inParams || {}); + }, + send: function(inAsync, inParams, inCallbacks) { + //console.log('send', inParams.command); + var p = this.getSendParams(inParams); + var d = dojo.xhrPost({ + url: this.server, + content: p, + handleAs: 'json-comment-filtered', + contentType: "application/x-www-form-urlencoded; charset=utf-8", + sync: !inAsync + }); + d.addCallbacks(dojo.hitch(this, "receive", inCallbacks), dojo.hitch(this, "receiveError", inCallbacks)); + return d; + }, + _callback: function(cb, eb, data) { + try{ cb && cb(data); } + catch(e){ eb && eb(data, e); } + }, + receive: function(inCallbacks, inData) { + inCallbacks && this._callback(inCallbacks.callback, inCallbacks.errback, inData); + }, + receiveError: function(inCallbacks, inErr) { + this._callback(inCallbacks.errback, null, inErr) + }, + encodeRow: function(inParams, inRow, inPrefix) { + for (var i=0, l=inRow.length; i < l; i++) + inParams['_' + (inPrefix ? inPrefix : '') + i] = (inRow[i] ? inRow[i] : ''); + }, + measure: function() { + this.send(true, { command: 'info' }, { callback: dojo.hitch(this, this.callbacks.info) }); + }, + fetchRowCount: function(inCallbacks) { + this.send(true, { command: 'count' }, inCallbacks); + }, + // server commits + commitEdit: function(inOldData, inNewData, inRowIndex, inCallbacks) { + this.setState(inRowIndex, "inflight", true); + var params = {command: 'update'}; + this.encodeRow(params, inOldData, 'o'); + this.encodeRow(params, inNewData); + this.send(true, params, inCallbacks); + }, + commitInsert: function(inRowIndex, inNewData, inCallbacks) { + this.setState(inRowIndex, "inflight", true); + var params = {command: 'insert'}; + this.encodeRow(params, inNewData); + this.send(true, params, inCallbacks); + }, + // NOTE: supported only in tables with pk + commitDelete: function(inRows, inCallbacks) { + var params = { + command: 'delete', + count: inRows.length + } + var pk = this.getPkIndex(); + if (pk < 0) + return; + for (var i=0; i < inRows.length; i++) { + params['_' + i] = inRows[i][pk]; + } + this.send(true, params, inCallbacks); + }, + getUpdateCallbacks: function(inRowIndex) { + return { + callback: dojo.hitch(this, this.callbacks.update, inRowIndex), + errback: dojo.hitch(this, this.callbacks.updateError, inRowIndex) + }; + }, + // primary key from fields + getPkIndex: function() { + for (var i=0, l=this.fields.count(), f; (i + + + 1 + Title of 1 + Author of 1 + + + 2 + Title of 2 + Author of 2 + + + 3 + Title of 3 + Author of 3 + + + 4 + Title of 4 + Author of 4 + + + 5 + Title of 5 + Author of 5 + + + 6 + Title of 6 + Author of 6 + + + 7 + Title of 7 + Author of 7 + + + 8 + Title of 8 + Author of 8 + + + 9 + Title of 9 + Author of 9 + + + 10 + Title of 10 + Author of 10 + + + 11 + Title of 11 + Author of 11 + + + 12 + Title of 12 + Author of 12 + + + 13 + Title of 13 + Author of 13 + + + 14 + Title of 14 + Author of 14 + + + 15 + Title of 15 + Author of 15 + + + 16 + Title of 16 + Author of 16 + + + 17 + Title of 17 + Author of 17 + + + 18 + Title of 18 + Author of 18 + + + 19 + Title of 19 + Author of 19 + + + 20 + Title of 20 + Author of 20 + + diff --git a/includes/js/dojox/grid/tests/support/data.php b/includes/js/dojox/grid/tests/support/data.php new file mode 100644 index 0000000..1beb6f0 --- /dev/null +++ b/includes/js/dojox/grid/tests/support/data.php @@ -0,0 +1,379 @@ +encode($inData) . ' */'; + } + + function error($inMessage) { + $inMessage = str_replace('"', '\\"', $inMessage); + error_log($inMessage); + //echo '/* ({error: true, message: "' . $inMessage . '"}) */'; + echoJson(array('error' => true, 'message' => $inMessage)); + exit; + } + + + function getArray($inResult, $inArray="true") { + $o = Array(); + while ($row = ($inArray ? mysql_fetch_row($inResult) : mysql_fetch_object($inResult))) + $o[] = $row; + return $o; + } + + // connect to DB + mysql_connect($dbserver, $dbuser, $dbpassword); + + // select DB + $database = getPostString("database"); + $database = ($database ? $database : $db); + if (!mysql_select_db($database)) + error('failed to select db: ' . mysql_error()); + + // select table + $table = getPostString("table"); + $table = ($table ? $table : $dbtable); + + // cache + $colCache = NULL; + $pkCache = NULL; + + // set UTF8 output (MySql > 4.0) + mysql_query("SET NAMES UTF8"); + + // server, database, table meta data + function getDatabases() { + $result = mysql_query("SHOW DATABASES"); + $output = Array(); + while ($row = mysql_fetch_row($result)) { + $r = strtolower($row[0]); + if ($r != 'mysql' && $r != 'information_schema') + $output[] = $row[0]; + } + return $output; + } + + function getTables() { + global $database; + $result = mysql_query("SHOW TABLES FROM $database"); + $output = Array(); + while ($row = mysql_fetch_row($result)) + $output[] = $row[0]; + return $output; + } + + function getColumns() { + global $table, $colCache; + if (!$colCache) { + $result = mysql_query("SHOW COLUMNS FROM `$table`"); + return getArray($result, false); + $colCache = getArray($result, false); + } + return $colCache; + } + + // returns object: $this->name, $this->index + function getPk() { + global $pkCache; + if (!$pkCache) { + $k = ''; + $columns = getColumns(); + for ($i=0; $i < count($columns); $i++) { + $c = $columns[$i]; + if ($c->Key == 'PRI') { + $k = $c->Field; + break; + } + } + $pkCache->index = $i; + $pkCache->name = $k; + } + return $pkCache; + } + + function getTableInfo() { + global $table, $database; + $c = getColumns(); + $r = rowcount(); + return array("count" => $r, "columns" => $c, "database" => $database, "table" => $table); + } + + function getOldPostPkValue() { + $pk = getPk(); + return getPostString('_o' . $pk->index); + } + + function getNewPostPkValue() { + $pk = getPk(); + return getPostString('_' . $pk->index); + } + + function getPostColumns() { + $columns = getColumns(); + for ($i=0, $a=array(), $p; (($p=getPostString("_".$i)) != ''); $i++) { + $r = new stdClass(); + $r->name = $columns[$i]->Field; + $r->value = $p; + $a[] = $r; + } + return $a; + } + + function getOrderBy() { + $ob = getPostString("orderby"); + if (is_numeric($ob)) { + $columns = getColumns(); + $ob = $columns[intval($ob)-1]->Field; + } + return $ob; + } + + function getWhere() { + $w = getPostString("where"); + return ($w ? " WHERE $w" : ""); + } + + // basic operations + function rowcount() { + global $table; + $query = "SELECT COUNT(*) FROM `$table`" . getWhere(); + $result = mysql_query($query); + if (!$result) + error("failed to perform query: $query. " . mysql_error()); + if ($row = mysql_fetch_row($result)) + return $row[0]; + else + return 0; + } + + function select($inQuery = '') { + global $table; + // built limit clause + $lim = (int)getPostString("limit"); + $off = (int)getPostString("offset"); + $limit = ($lim || $off ? " LIMIT $off, $lim" : ""); + // build order by clause + $desc = (boolean)getPostString("desc"); + $ob = getOrderBy(); + $orderby = ($ob ? " ORDER BY `" . $ob . "`" . ($desc ? " DESC" : "") : ""); + // build query + $query = ($inQuery ? $inQuery : "SELECT * FROM `$table`" . getWhere() . $orderby . $limit); + // execute query + if (!$result = mysql_query($query)) + error("failed to perform query: $query. " . mysql_error()); + // fetch each result row + return getArray($result); + } + + function reflectRow() { + global $table; + $pk = getPk(); + $key = getNewPostPkValue(); + $where = "`$pk->name`=\"$key\""; + return select("SELECT * FROM `$table` WHERE $where LIMIT 1"); + } + + function update() { + // build set clause + for ($i=0, $set = array(), $cols = getPostColumns(), $v; ($v=$cols[$i]); $i++) + $set[] = "`$v->name` = '$v->value'"; + $set = implode(', ', $set); + // our table + global $table; + // build query + $pk = getPk(); + $pkValue = getOldPostPkValue(); + $query = "UPDATE `$table` SET $set WHERE `$pk->name` = '$pkValue' LIMIT 1"; + // execute query + if (!mysql_query($query)) + error("failed to perform query: [$query]. " . + "MySql says: [" . mysql_error() ."]"); + else { + return reflectRow(); + } + } + + function insert() { + global $table; + // build values clause + for ($i=0, $values = array(), $cols = getPostColumns(), $v; ($v=$cols[$i]); $i++) + $values[] = $v->value; + $values = '"' . implode('", "', $values) . '"'; + // build query + $query = "INSERT INTO `$table` VALUES($values)"; + // execute query + if (!mysql_query($query)) + error("failed to perform query: [$query]. " . + "MySql says: [" . mysql_error() ."]"); + else { + return reflectRow(); + } + } + + function delete() { + global $table; + // build query + $n = getPostString("count"); + $pk = getPk(); + for ($i = 0, $deleted=array(); $i < $n; $i++) { + $key = getPostString("_$i"); + array_push($deleted, $key); + $query = "DELETE FROM `$table` WHERE `$pk->name`=\"$key\" LIMIT 1"; + // execute query + if (!mysql_query($query) || mysql_affected_rows() != 1) + error("failed to perform query: [$query]. " . + "Affected rows: " . mysql_affected_rows() .". " . + "MySql says: [" . mysql_error() ."]"); + } + return $deleted; + } + + // find (full text search) + function findData($inFindCol, $inFind, $inOrderBy, $inFullText) { + global $table; + $where = ($inFullText ? "WHERE MATCH(`$inFindCol`) AGAINST ('$inFind')" : "WHERE $inFindCol LIKE '$inFind'"); + $query = "SELECT * FROM $table $where $inOrderBy"; + $result = mysql_query($query); + // return rows + return getArray($result); + } + + // binary search through sorted data, supports start point ($inFindFrom) and direction ($inFindForward) + function findRow($inData, $inFindFrom=-1, $inFindForward) { + $b = -1; + $l = count($inData); + if (!$inData) + return $b; + if (!$inFindFrom==-1 || $l < 2) + $b = 0; + else { + // binary search + $t = $l-1; + $b = 0; + while ($b <= $t) { + $p = floor(($b+$t)/2); + $d = $inData[$p][0]; + if ($d < $inFindFrom) + $b = $p + 1; + else if ($d > $inFindFrom) + $t = $p - 1; + else { + $b = $p; + break; + } + } + if ($inFindFrom == $inData[$b][0]) { + // add or subtract 1 + $b = ($inFindForward ? ($b+1 > $l-1 ? 0 : $b+1) : ($b-1 < 0 ? $l-1 : $b-1) ); + } + else if (!$inFindForward) + // subtract 1 + $b = ($b-1 < 0 ? $l-1 : $b-1); + } + return $inData[$b][0]; + } + + function buildFindWhere($inFindData, $inKey, $inCol) { + $o = Array(); + foreach($inFindData as $row) + $o[] = $inCol . "='" . $row[$inKey] . "'"; + return (count($o) ? ' WHERE ' . implode(' OR ', $o) : ''); + } + + function find($inFindCol, $inFind='', $inOb='', $inFindFrom=0, $inFindForward=true, $inFullText=true) { + global $table; + // build order by clause + $desc = (boolean)getPostString("desc"); + if (!$inOb) + $inOb = getOrderBy(); + if ($inOb) + $inOb = "`" . $inOb . "`" ; + $orderby = ($inOb ? " ORDER BY $inOb " . ($desc ? " DESC" : "") : ""); + // update inputs from post + if (!$inFind) + $inFind = getPostString('findText'); + if (!$inFindCol) + $inFindCol = getPostString('findCol'); + if (empty($inFindFrom)) + $inFindFrom = getPostString('findFrom'); + $ff = getPostString('findForward'); + if ($ff) + $inFindForward = (strtolower($ff) == 'true' ? true : false); + $ft = getPostString('findFullText'); + if ($ft) + $inFullText = (strtolower($ft) == 'true' ? true : false); + + // get find data + $f = findData($inFindCol, $inFind, $orderby, $inFullText); + $pk = getPk(); + + // execute query + $where = buildFindWhere($f, $pk->index, 'f'); + $query = "SELECT Row, f FROM (SELECT @row := @row + 1 AS Row, $pk->name as f FROM `$table` $orderby) AS tempTable $where"; + mysql_query('SET @row = -1;'); + if (!$result = mysql_query($query)) + error("failed to perform query: $query. " . mysql_error()); + + // return row number + return findRow(getArray($result), $inFindFrom, $inFindForward); + } + + // our command list + $cmds = array( + "count" => "rowcount", + "select" => "select", + "update" => "update", + "insert" => "insert", + "delete" => "delete", + "find" => "find", + "databases" => "getDatabases", + "tables" => "getTables", + "columns" => "getColumns", + "info" => "getTableInfo" + ); + + // process input params + $cmd = @$_POST["command"]; + + //$cmd="select"; + + // dispatch command + $func = @$cmds[$cmd]; + if (function_exists($func)) + echoJson(call_user_func($func)); + else + error("bad command"); +?> diff --git a/includes/js/dojox/grid/tests/support/geography.xml b/includes/js/dojox/grid/tests/support/geography.xml new file mode 100644 index 0000000..070a8c1 --- /dev/null +++ b/includes/js/dojox/grid/tests/support/geography.xml @@ -0,0 +1,51 @@ + + + + geography.opml + 2006-11-10 + 2006-11-13 + Magellan, Ferdinand + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/js/dojox/grid/tests/support/json.php b/includes/js/dojox/grid/tests/support/json.php new file mode 100644 index 0000000..84e3dfa --- /dev/null +++ b/includes/js/dojox/grid/tests/support/json.php @@ -0,0 +1,794 @@ + +* @author Matt Knapp +* @author Brett Stimmerman +* @copyright 2005 Michal Migurski +* @license http://www.opensource.org/licenses/bsd-license.php +* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 +*/ + +/** +* Marker constant for Services_JSON::decode(), used to flag stack state +*/ +define('SERVICES_JSON_SLICE', 1); + +/** +* Marker constant for Services_JSON::decode(), used to flag stack state +*/ +define('SERVICES_JSON_IN_STR', 2); + +/** +* Marker constant for Services_JSON::decode(), used to flag stack state +*/ +define('SERVICES_JSON_IN_ARR', 4); + +/** +* Marker constant for Services_JSON::decode(), used to flag stack state +*/ +define('SERVICES_JSON_IN_OBJ', 8); + +/** +* Marker constant for Services_JSON::decode(), used to flag stack state +*/ +define('SERVICES_JSON_IN_CMT', 16); + +/** +* Behavior switch for Services_JSON::decode() +*/ +define('SERVICES_JSON_LOOSE_TYPE', 10); + +/** +* Behavior switch for Services_JSON::decode() +*/ +define('SERVICES_JSON_STRICT_TYPE', 11); + +/** +* Encodings +*/ +define('SERVICES_JSON_ISO_8859_1', 'iso-8859-1'); +define('SERVICES_JSON_UTF_8', 'utf-8'); + +/** +* Converts to and from JSON format. +* +* Brief example of use: +* +* +* // create a new instance of Services_JSON +* $json = new Services_JSON(); +* +* // convert a complexe value to JSON notation, and send it to the browser +* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); +* $output = $json->encode($value); +* +* print($output); +* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] +* +* // accept incoming POST data, assumed to be in JSON notation +* $input = file_get_contents('php://input', 1000000); +* $value = $json->decode($input); +* +*/ +class Services_JSON +{ + /** + * constructs a new JSON instance + * + //>> SJM2005 + * @param string $encoding Strings are input/output in this encoding + * @param int $encode Encode input is expected in this character encoding + //<< SJM2005 + * + * @param int $use object behavior: when encoding or decoding, + * be loose or strict about object/array usage + * + * possible values: + * - SERVICES_JSON_STRICT_TYPE: strict typing, default. + * "{...}" syntax creates objects in decode(). + * - SERVICES_JSON_LOOSE_TYPE: loose typing. + * "{...}" syntax creates associative arrays in decode(). + */ + function Services_JSON($encoding = SERVICES_JSON_UTF_8, $use = SERVICES_JSON_STRICT_TYPE) + { + //>> SJM2005 + $this->encoding = $encoding; + //<< SJM2005 + + $this->use = $use; + } + + /** + * convert a string from one UTF-16 char to one UTF-8 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf16 UTF-16 character + * @return string UTF-8 character + * @access private + */ + function utf162utf8($utf16) + { + // oh please oh please oh please oh please oh please + if(function_exists('mb_convert_encoding')) + return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); + + $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + + switch(true) { + case ((0x7F & $bytes) == $bytes): + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x7F & $bytes); + + case (0x07FF & $bytes) == $bytes: + // return a 2-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xC0 | (($bytes >> 6) & 0x1F)) + . chr(0x80 | ($bytes & 0x3F)); + + case (0xFFFF & $bytes) == $bytes: + // return a 3-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xE0 | (($bytes >> 12) & 0x0F)) + . chr(0x80 | (($bytes >> 6) & 0x3F)) + . chr(0x80 | ($bytes & 0x3F)); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + function utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if(function_exists('mb_convert_encoding')) + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + + switch(strlen($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return string JSON string representation of input var + * @access public + */ + function encode($var) + { + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + //>> SJM2005 + if ($this->encoding == SERVICES_JSON_UTF_8) + ; + else if ($this->encoding == SERVICES_JSON_ISO_8859_1) + $var = utf8_encode($var); + else if (!function_exists('mb_convert_encoding')) + die('Requested encoding requires mb_strings extension.'); + else + $var = mb_convert_encoding($var, "utf-8", $this->encoding); + //<< SJM2005 + + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = strlen($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\'.$var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2})); + $c += 2; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF8) == 0xF0): + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3})); + $c += 3; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFC) == 0xF8): + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4})); + $c += 4; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFE) == 0xFC): + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4}), + ord($var{$c + 5})); + $c += 5; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + } + } + + return '"'.$ascii.'"'; + + case 'array': + /* + * As per JSON spec if any array key is not an integer + * we must treat the the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ + + // treat as a JSON object + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { + return '{' . + join(',', array_map(array($this, 'name_value'), + array_keys($var), + array_values($var))) + . '}'; + } + + // treat it like a regular array + return '[' . join(',', array_map(array($this, 'encode'), $var)) . ']'; + + case 'object': + $vars = get_object_vars($var); + return '{' . + join(',', array_map(array($this, 'name_value'), + array_keys($vars), + array_values($vars))) + . '}'; + + default: + return ''; + } + } + + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ + function name_value($name, $value) + { + return $this->encode(strval($name)) . ':' . $this->encode($value); + } + + /** + * reduce a string by removing leading and trailing comments and whitespace + * + * @param $str string string value to strip of comments and whitespace + * + * @return string string value stripped of comments and whitespace + * @access private + */ + function reduce_string($str) + { + $str = preg_replace(array( + + // eliminate single line comments in '// ...' form + '#^\s*//(.+)$#m', + + // eliminate multi-line comments in '/* ... */' form, at start of string + '#^\s*/\*(.+)\*/#Us', + + // eliminate multi-line comments in '/* ... */' form, at end of string + '#/\*(.+)\*/\s*$#Us' + + ), '', $str); + + // eliminate extraneous space + return trim($str); + } + + /** + * decodes a JSON string into appropriate variable + * + * @param string $str JSON-formatted string + * + * @return mixed number, boolean, string, array, or object + * corresponding to given JSON input string. + * See argument 1 to Services_JSON() above for object-output behavior. + * Note that decode() always returns strings + * in ASCII or UTF-8 format! + * @access public + */ + function decode($str) + { + $str = $this->reduce_string($str); + + switch (strtolower($str)) { + case 'true': + return true; + + case 'false': + return false; + + case 'null': + return null; + + default: + if (is_numeric($str)) { + // Lookie-loo, it's a number + + // This would work on its own, but I'm trying to be + // good about returning integers where appropriate: + // return (float)$str; + + // Return float or int, as appropriate + return ((float)$str == (integer)$str) + ? (integer)$str + : (float)$str; + + } elseif (preg_match('/^("|\').+(\1)$/s', $str, $m) && $m[1] == $m[2]) { + // STRINGS RETURNED IN UTF-8 FORMAT + $delim = substr($str, 0, 1); + $chrs = substr($str, 1, -1); + $utf8 = ''; + $strlen_chrs = strlen($chrs); + + for ($c = 0; $c < $strlen_chrs; ++$c) { + + $substr_chrs_c_2 = substr($chrs, $c, 2); + $ord_chrs_c = ord($chrs{$c}); + + switch (true) { + case $substr_chrs_c_2 == '\b': + $utf8 .= chr(0x08); + ++$c; + break; + case $substr_chrs_c_2 == '\t': + $utf8 .= chr(0x09); + ++$c; + break; + case $substr_chrs_c_2 == '\n': + $utf8 .= chr(0x0A); + ++$c; + break; + case $substr_chrs_c_2 == '\f': + $utf8 .= chr(0x0C); + ++$c; + break; + case $substr_chrs_c_2 == '\r': + $utf8 .= chr(0x0D); + ++$c; + break; + + case $substr_chrs_c_2 == '\\"': + case $substr_chrs_c_2 == '\\\'': + case $substr_chrs_c_2 == '\\\\': + case $substr_chrs_c_2 == '\\/': + if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || + ($delim == "'" && $substr_chrs_c_2 != '\\"')) { + $utf8 .= $chrs{++$c}; + } + break; + + case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): + //echo ' matching single escaped unicode character from ' . substr($chrs, $c, 6); + // single, escaped unicode character + $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) + . chr(hexdec(substr($chrs, ($c + 4), 2))); + $utf8 .= $this->utf162utf8($utf16); + $c += 5; + break; + + case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): + $utf8 .= $chrs{$c}; + break; + + case ($ord_chrs_c & 0xE0) == 0xC0: + // characters U-00000080 - U-000007FF, mask 110XXXXX + //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 2); + ++$c; + break; + + case ($ord_chrs_c & 0xF0) == 0xE0: + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 3); + $c += 2; + break; + + case ($ord_chrs_c & 0xF8) == 0xF0: + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 4); + $c += 3; + break; + + case ($ord_chrs_c & 0xFC) == 0xF8: + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 5); + $c += 4; + break; + + case ($ord_chrs_c & 0xFE) == 0xFC: + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= substr($chrs, $c, 6); + $c += 5; + break; + + } + + } + + //>> SJM2005 + if ($this->encoding == SERVICES_JSON_UTF_8) + return $utf8; + if ($this->encoding == SERVICES_JSON_ISO_8859_1) + return utf8_decode($utf8); + else if (!function_exists('mb_convert_encoding')) + die('Requested encoding requires mb_strings extension.'); + else + return mb_convert_encoding($utf8, $this->encoding, SERVICES_JSON_UTF_8); + //<< SJM2005 + + return $utf8; + + } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { + // array, or object notation + if ($str{0} == '[') { + $stk = array(SERVICES_JSON_IN_ARR); + $arr = array(); + } else { + if ($this->use == SERVICES_JSON_LOOSE_TYPE) { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = array(); + } else { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = new stdClass(); + } + } + + array_push($stk, array('what' => SERVICES_JSON_SLICE, + 'where' => 0, + 'delim' => false)); + + $chrs = substr($str, 1, -1); + $chrs = $this->reduce_string($chrs); + + if ($chrs == '') { + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } else { + return $obj; + + } + } + + //print("\nparsing {$chrs}\n"); + + $strlen_chrs = strlen($chrs); + for ($c = 0; $c <= $strlen_chrs; ++$c) { + + $top = end($stk); + $substr_chrs_c_2 = substr($chrs, $c, 2); + + if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { + // found a comma that is not inside a string, array, etc., + // OR we've reached the end of the character list + $slice = substr($chrs, $top['where'], ($c - $top['where'])); + array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); + //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + // we are in an array, so just push an element onto the stack + array_push($arr, $this->decode($slice)); + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + // we are in an object, so figure + // out the property name and set an + // element in an associative array, + // for now + if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { + // "name":value pair + $key = $this->decode($parts[1]); + $val = $this->decode($parts[2]); + + if ($this->use == SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { + // name:value pair, where name is unquoted + $key = $parts[1]; + $val = $this->decode($parts[2]); + + if ($this->use == SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } + + } + + } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { + // found a quote, and we are not inside a string + array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + //print("Found start of string at {$c}\n"); + + //>> SAO2006 + /*} elseif (($chrs{$c} == $top['delim']) && + ($top['what'] == SERVICES_JSON_IN_STR) && + (($chrs{$c - 1} != '\\') || + ($chrs{$c - 1} == '\\' && $chrs{$c - 2} == '\\'))) {*/ + } elseif ($chrs{$c} == $top['delim'] && + $top['what'] == SERVICES_JSON_IN_STR) { + //print("Found potential end of string at {$c}\n"); + // verify quote is not escaped: it has no or an even number of \\ before it. + for ($i=0; ($chrs{$c - ($i+1)} == '\\'); $i++); + /*$i = 0; + while ( $chrs{$c - ($i+1)} == '\\') + $i++;*/ + //print("Found {$i} \ before delim\n"); + if ($i % 2 != 0) + { + //print("delim escaped, not end of string\n"); + continue; + } + //>> SAO2006 + // found a quote, we're in a string, and it's not escaped + array_pop($stk); + //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '[') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-bracket, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); + //print("Found start of array at {$c}\n"); + + } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { + // found a right-bracket, and we're in an array + array_pop($stk); + //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '{') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-brace, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); + //print("Found start of object at {$c}\n"); + + } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { + // found a right-brace, and we're in an object + array_pop($stk); + //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($substr_chrs_c_2 == '/*') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a comment start, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); + $c++; + //print("Found start of comment at {$c}\n"); + + } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { + // found a comment end, and we're in one now + array_pop($stk); + $c++; + + for ($i = $top['where']; $i <= $c; ++$i) + $chrs = substr_replace($chrs, ' ', $i, 1); + + //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } + + } + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + return $obj; + + } + + } + } + } + +} + + /*function hex($s) + { + $l = strlen($s); + for ($i=0; $i < $l; $i++) + //echo '['.(ord($s{$i})).']'; + echo '['.bin2hex($s{$i}).']'; + } + + //$d = '["hello world\\""]'; + $d = '["\\\\\\"hello world,\\\\\\""]'; + //$d = '["\\\\", "\\\\"]'; + hex($d); + $test = new Services_JSON(); + echo('
');
+	print_r($d . "\n");
+	print_r($test->decode($d));
+	echo('
'); + */ +?> \ No newline at end of file diff --git a/includes/js/dojox/grid/tests/support/movies.csv b/includes/js/dojox/grid/tests/support/movies.csv new file mode 100644 index 0000000..baf71eb --- /dev/null +++ b/includes/js/dojox/grid/tests/support/movies.csv @@ -0,0 +1,9 @@ +Title, Year, Producer +City of God, 2002, Katia Lund +Rain,, Christine Jeffs +2001: A Space Odyssey, , Stanley Kubrick +"This is a ""fake"" movie title", 1957, Sidney Lumet +Alien, 1979 , Ridley Scott +"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott +"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward" + diff --git a/includes/js/dojox/grid/tests/support/test_data.js b/includes/js/dojox/grid/tests/support/test_data.js new file mode 100644 index 0000000..4707380 --- /dev/null +++ b/includes/js/dojox/grid/tests/support/test_data.js @@ -0,0 +1,30 @@ +// example sample data and code +(function(){ + // some sample data + // global var "data" + data = [ + [ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ], + [ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ], + [ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ], + [ "note", false, "read", 'However the reserved characters', 15.63, 0, true ], + [ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ], + [ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ], + [ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ] + ]; + var rows = 100; + for(var i=0, l=data.length; i{text}', {href: inData[0], text: inData[1] }); +}; + +formatImage = function(inData, inRowIndex) { + if (!inData[0] || !inData[1]) + return ' '; + var o = { + href: inData[0], + src: inData[1].Url, + width: inData[1].Width, + height: inData[1].Height + } + return turbo.supplant('', o); +}; + +formatDate = function(inDatum, inRowIndex) { + if (inDatum == '') + return ' '; + var d = new Date(inDatum * 1000); + return turbo.printf('%s/%s/%s', d.getMonth(), d.getDate(), d.getFullYear()); +}; + +formatDimensions = function(inData, inRowIndex) { + if (!inData[0] || !inData[1]) + return ' '; + return inData[0] + ' x ' + inData[1]; +} diff --git a/includes/js/dojox/grid/tests/test_change_structure.html b/includes/js/dojox/grid/tests/test_change_structure.html new file mode 100644 index 0000000..4ecfa71 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_change_structure.html @@ -0,0 +1,124 @@ + + + + dojox.Grid Change Structure Example + + + + + + + +
dojox.VirtualGrid Change Structure Example
+

+ +

+
+ + + diff --git a/includes/js/dojox/grid/tests/test_custom_sort.html b/includes/js/dojox/grid/tests/test_custom_sort.html new file mode 100644 index 0000000..51b0cf3 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_custom_sort.html @@ -0,0 +1,86 @@ + + + + Custom Sort Test - dojox.Grid + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Custom Sort Test
+
+Column 3's data field has a custom sorter that sorts by the 2nd letter in the string. +

+
+ + diff --git a/includes/js/dojox/grid/tests/test_dojo_data_edit.html b/includes/js/dojox/grid/tests/test_dojo_data_edit.html new file mode 100644 index 0000000..7c9bc5c --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_edit.html @@ -0,0 +1,124 @@ + + + + Test dojox.Grid Editing with DojoData model + + + + + + + + +

+ dojox.Grid Basic Editing test +

+
+     +     +     + +     + +     + + +     + +     +   +
+ + + + +
+
+ + +
+
+ + + + + diff --git a/includes/js/dojox/grid/tests/test_dojo_data_empty.html b/includes/js/dojox/grid/tests/test_dojo_data_empty.html new file mode 100644 index 0000000..3096491 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_empty.html @@ -0,0 +1,63 @@ + + + +dojox.Grid with Dojo.Data via binding + + + + + + + +
dojox.Grid using initially-empty Dojo.Data write stores and then adding an item. Item should show up correctly (no "?"s) when added.
+
+ + +
+
+ + + \ No newline at end of file diff --git a/includes/js/dojox/grid/tests/test_dojo_data_model.html b/includes/js/dojox/grid/tests/test_dojo_data_model.html new file mode 100644 index 0000000..fb8e200 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_model.html @@ -0,0 +1,84 @@ + + + + dojox.Grid with Dojo.Data via binding + + + + + + + +
dojox.Grid using Dojo.Data stores via simple binding
+ + + + +
+
+ + + + + +
+
+ + diff --git a/includes/js/dojox/grid/tests/test_dojo_data_model_EmptyResultSet.html b/includes/js/dojox/grid/tests/test_dojo_data_model_EmptyResultSet.html new file mode 100644 index 0000000..8a9048a --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_model_EmptyResultSet.html @@ -0,0 +1,57 @@ + + + + dojox.Grid with Dojo.Data via binding + + + + + + + +
dojox.Grid using Dojo.Data stores where a query returns no results. No errors should be reported in Firebug and the grid should be empty
+
+ + + + +
+
+ + diff --git a/includes/js/dojox/grid/tests/test_dojo_data_model_multiStores.html b/includes/js/dojox/grid/tests/test_dojo_data_model_multiStores.html new file mode 100644 index 0000000..46554e3 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_model_multiStores.html @@ -0,0 +1,291 @@ + + + + dojox.Grid with Dojo.Data via binding. Multiple Store implementations. + + + + + + + + +

dojox.Grid using Dojo.Data stores via simple binding with multiple store implementations.

+

+ This page demonstrates the Grid can display data accessed by dojo.data implementing Datastores. + Each of the datastores used stores data in a different format, and as this test and demonstration + page shows, the logic for rendering the data is virtually identical. You define your source store, + you define the model for accessing the data, which is ij this case the dojox.grid.data.DojoData model + and then you define the layout, which maps the data attribute names to columns in the grid. You can + even perform cusomization of what is displayed, as demonstrated in the dojox.data.FlickrStore layout. + The image url is displayed as a clickable link that opens a new page. +

+

+ The choice of stores used were ones that did not require back end services to function for sake of + simplicity. There is no reason that dojox.data.QueryReadStore could not be used with grid as well, + it just requires a back end service to send it the query results. +

+

Stores used:

+
    +
  • dojo.data.ItemFileReadStore
  • +
  • dojox.data.CvsStore
  • +
  • dojox.data.XmlStore
  • +
  • dojox.data.FlickrStore
  • +
  • dojox.data.OpmlStore
  • +
  • dojox.data.HtmlTableStore
  • +
+ +

dojo.data.ItemFileReadStore:

+ Displays a list of countries through ItemFileReadStore format. + + + + +
+
+ + +

dojox.data.CsvStore:

+ Displays a list of movies that were stored in CSV format. + + + + +
+ +
+ +

dojox.data.XmlStore:

+ Displays a list of books that were stored in XML format. + + + + +
+
+ + +

dojox.data.FlickrStore:

+ Displays Flickr imformation on 3DNY (Dojo Developer Days, New York) from the flickr public photo feed, accessed via the FlickrStore dojo.data implementation. + + + + +
+
+ + +

dojox.data.OpmlStore:

+ Scans an Opml based document for all items of type 'country' + + + + +
+
+ + +

dojox.data.HtmlStore:

+ Loads the grid from an HTML Table. + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/js/dojox/grid/tests/test_dojo_data_model_processError.html b/includes/js/dojox/grid/tests/test_dojo_data_model_processError.html new file mode 100644 index 0000000..4130043 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_model_processError.html @@ -0,0 +1,65 @@ + + + + dojox.Grid with Dojo.Data model with trapping of data store errors. + + + + + + + + +

dojox.Grid using Dojo.Data stores via simple binding

+ +

dojox.data.CsvStore:

. + This grid does not load data. The data store references a non-existent URL on purpose. It should trigger a failure that we catch and display in an alert + + + + + + +
+
+ + + + diff --git a/includes/js/dojox/grid/tests/test_dojo_data_notification.html b/includes/js/dojox/grid/tests/test_dojo_data_notification.html new file mode 100644 index 0000000..f44c987 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_dojo_data_notification.html @@ -0,0 +1,114 @@ + + + + dojox.Grid with Dojo.Data via binding + + + + + + + +

dojox.Grid using Dojo.Data stores via simple binding

+ +
+

Update some of the types

+ + + + + + + +
+
+ +
+
+ + diff --git a/includes/js/dojox/grid/tests/test_edit.html b/includes/js/dojox/grid/tests/test_edit.html new file mode 100644 index 0000000..7ae1fdb --- /dev/null +++ b/includes/js/dojox/grid/tests/test_edit.html @@ -0,0 +1,149 @@ + + + + +Test dojox.Grid Editing + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ dojox.Grid Basic Editing test +

+
+     + +     + +     + +     +   +
+
+
+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_edit_canEdit.html b/includes/js/dojox/grid/tests/test_edit_canEdit.html new file mode 100644 index 0000000..ed4e919 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_edit_canEdit.html @@ -0,0 +1,156 @@ + + + + +Test dojox.Grid Editing + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ dojox.Grid Basic Editing test +

+
+     + +     + +     + +     +   +
+
+
+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_edit_dijit.html b/includes/js/dojox/grid/tests/test_edit_dijit.html new file mode 100644 index 0000000..484c7e5 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_edit_dijit.html @@ -0,0 +1,137 @@ + + + + + Test dojox.Grid Editing + + + + + + +

dojox.Grid Basic Editing test

+
+
+ + + + + + + + +
+
+
+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_events.html b/includes/js/dojox/grid/tests/test_events.html new file mode 100644 index 0000000..8ea61a4 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_events.html @@ -0,0 +1,174 @@ + + + + Test dojox.Grid Events + + + + + + + +

dojox.Grid Event Tracking

+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_expand.html b/includes/js/dojox/grid/tests/test_expand.html new file mode 100644 index 0000000..220c2a8 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_expand.html @@ -0,0 +1,107 @@ + + + + Test dojox.Grid Expand Rows + + + + + + + +
dojox.Grid Expand Row Example
+ +
+ + + diff --git a/includes/js/dojox/grid/tests/test_grid.html b/includes/js/dojox/grid/tests/test_grid.html new file mode 100644 index 0000000..59d18dc --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid.html @@ -0,0 +1,69 @@ + + + + Test dojox.Grid Basic + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Basic Test
+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_dlg.html b/includes/js/dojox/grid/tests/test_grid_dlg.html new file mode 100644 index 0000000..7479e15 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_dlg.html @@ -0,0 +1,88 @@ + + + + Test dojox.Grid Basic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Basic Test
+ +
+ + + +
+
+ + + diff --git a/includes/js/dojox/grid/tests/test_grid_headerHeight.html b/includes/js/dojox/grid/tests/test_grid_headerHeight.html new file mode 100644 index 0000000..b9960c4 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_headerHeight.html @@ -0,0 +1,84 @@ + + + + Test dojox.Grid Basic + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Basic Test
+
+

+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_layout.html b/includes/js/dojox/grid/tests/test_grid_layout.html new file mode 100644 index 0000000..148025d --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_layout.html @@ -0,0 +1,112 @@ + + + + dojox.Grid in Layout Demo + + + + + + + + + + +
+
+ top bar +
+
+ bottom bar +
+
+
+ Left side +
+ +
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_layout_LayoutContainer.html b/includes/js/dojox/grid/tests/test_grid_layout_LayoutContainer.html new file mode 100644 index 0000000..4cf12ac --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_layout_LayoutContainer.html @@ -0,0 +1,87 @@ + + + + dojox.Grid in Layout Demo + + + + + + + + + + +
+ +
+ top bar +
+
+ bottom bar +
+ +
+ + +
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_layout_borderContainer.html b/includes/js/dojox/grid/tests/test_grid_layout_borderContainer.html new file mode 100644 index 0000000..8f0d8d7 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_layout_borderContainer.html @@ -0,0 +1,98 @@ + + + + Test dojox.Grid Editing + + + + + + + + +
+ +
+ +
+ + + + + + + + +
+
+ +
+
+
+ +
+ + + diff --git a/includes/js/dojox/grid/tests/test_grid_object_model_change.html b/includes/js/dojox/grid/tests/test_grid_object_model_change.html new file mode 100644 index 0000000..54c6808 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_object_model_change.html @@ -0,0 +1,86 @@ + + + + Test dojox.grid.data.Objects model change + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.grid.data.Objects model change
+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_programmatic.html b/includes/js/dojox/grid/tests/test_grid_programmatic.html new file mode 100644 index 0000000..fe0794f --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_programmatic.html @@ -0,0 +1,65 @@ + + + + Test dojox.Grid Programmatic Instantiation + + + + + + + + +
dojox.Grid Programmatic Instantiation Test
+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_programmatic_layout.html b/includes/js/dojox/grid/tests/test_grid_programmatic_layout.html new file mode 100644 index 0000000..b55d975 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_programmatic_layout.html @@ -0,0 +1,74 @@ + + + + Test dojox.Grid Programmatic Instantiation + + + + + + + + +
dojox.Grid Programmatic Instantiation Test
+
+
+ ... stuff ... +
+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_rtl.html b/includes/js/dojox/grid/tests/test_grid_rtl.html new file mode 100644 index 0000000..c1b253d --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_rtl.html @@ -0,0 +1,71 @@ + + + + Test dojox.Grid Basic + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Basic Test
+
+ + diff --git a/includes/js/dojox/grid/tests/test_grid_themes.html b/includes/js/dojox/grid/tests/test_grid_themes.html new file mode 100644 index 0000000..e0f80f6 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_themes.html @@ -0,0 +1,118 @@ + + + + dojox.Grid themes + + + + + + + +
dojox.grid.Grid structure from markup (tundra theme)
+ + + + + + + + + + + + + + +
Title of MovieYear
Producer
+ + + +
Locked views specified with tables and colgroups (soria theme)
+ + + + + + + + + + + + + + + +
Country/Continent NamePopulationLand MassTime ZoneType
+ +
A "regular" Grid from markup (no table defintion, nihilo theme)
+ + + + +
+
+ + + diff --git a/includes/js/dojox/grid/tests/test_grid_tooltip_menu.html b/includes/js/dojox/grid/tests/test_grid_tooltip_menu.html new file mode 100644 index 0000000..52c7726 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_grid_tooltip_menu.html @@ -0,0 +1,161 @@ + + + + Test dojox.Grid Basic + + + + + + + + + + + +
dojox.Grid Basic Test
+

+    +   
+ Note: when the grid menu is disabled, the document's dijit context menu should be shown over the grid. +

+
+ + diff --git a/includes/js/dojox/grid/tests/test_keyboard.html b/includes/js/dojox/grid/tests/test_keyboard.html new file mode 100644 index 0000000..69d4046 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_keyboard.html @@ -0,0 +1,90 @@ + + + + Test dojox.Grid Basic + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Basic Test
+
+ + diff --git a/includes/js/dojox/grid/tests/test_markup.html b/includes/js/dojox/grid/tests/test_markup.html new file mode 100644 index 0000000..7c57710 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_markup.html @@ -0,0 +1,112 @@ + + + + dojox.Grid with Dojo.Data via binding + + + + + + +
dojox.grid.Grid structure from markup
+ + + + + + + + + + + + + +
Title of MovieYear
Producer
+ + + + +
Locked views specified with tables and colgroups
+ + + + + + + + + + + + + +
Country/Continent NamePopulationLand MassTime ZoneType
+ +
A "regular" Grid from markup (no table defintion)
+ + + +
+
+ + + diff --git a/includes/js/dojox/grid/tests/test_mysql_edit.html b/includes/js/dojox/grid/tests/test_mysql_edit.html new file mode 100644 index 0000000..dd6a762 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_mysql_edit.html @@ -0,0 +1,155 @@ + + + + dojox.Grid Test: Mysql Table Editing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

dojox.Grid Test: Mysql Table Editing

+
+    +    +    +    + +

+
+
+

Note: This test requires MySql and PHP and works with the database table available in support/testtbl.sql.

+ + diff --git a/includes/js/dojox/grid/tests/test_sizing.html b/includes/js/dojox/grid/tests/test_sizing.html new file mode 100644 index 0000000..fdd0897 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_sizing.html @@ -0,0 +1,175 @@ + + + + dojox.Grid Sizing Example + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Sizing Test
+ Grid width:   + and height:   +

+   +   + +

+
+ +

Grid fits to a sized container by default:

+
+
+
+ +

Grid is essentially hidden (height of zero) when parent container is unsized + (nothing, including the header, should be displayed):

+
+
+
+ +

Grid is autoHeight and autoWidth via markup

+
+ + diff --git a/includes/js/dojox/grid/tests/test_sizing_100rows.html b/includes/js/dojox/grid/tests/test_sizing_100rows.html new file mode 100644 index 0000000..4ea1aa3 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_sizing_100rows.html @@ -0,0 +1,168 @@ + + + + dojox.Grid Sizing Example + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dojox.Grid Sizing Test
+ Grid width:   + and height:   +

+   +   + +

+
+ +

Grid fits to a sized container by default:

+
+
+
+ +

Grid is essentially hidden (height of zero) when parent container is unsized + (nothing, including the header, should be displayed):

+
+
+
+ +

Grid is autoHeight and autoWidth via markup

+
+ + diff --git a/includes/js/dojox/grid/tests/test_sizing_ResizeHandle.html b/includes/js/dojox/grid/tests/test_sizing_ResizeHandle.html new file mode 100644 index 0000000..d6809df --- /dev/null +++ b/includes/js/dojox/grid/tests/test_sizing_ResizeHandle.html @@ -0,0 +1,113 @@ + + + + dojox.Grid Sizing Example + + + + + + + + +
dojox.Grid Sizing Test w/ the experimental dojox.layout.ResizeHandle
+ +

While this test should work, dojox.layout.ResizeHandle is experimental.

+ +
+
+
+
+ +

Grid fits to a sized container by default:

+
+
+
+
+ +

I am here to take up

+ +

space

+ +

as much as needed.

+ + + diff --git a/includes/js/dojox/grid/tests/test_styling.html b/includes/js/dojox/grid/tests/test_styling.html new file mode 100644 index 0000000..5671f50 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_styling.html @@ -0,0 +1,131 @@ + + + + dojox.Grid Styling Test + + + + + + + + +
dojox.Grid Styling Example
+
+ + diff --git a/includes/js/dojox/grid/tests/test_subgrid.html b/includes/js/dojox/grid/tests/test_subgrid.html new file mode 100644 index 0000000..4e5b8cd --- /dev/null +++ b/includes/js/dojox/grid/tests/test_subgrid.html @@ -0,0 +1,179 @@ + + + +dojox.Grid Subgrid Test + + + + + + + + + +
dojox.Grid showing sub-grid.
+
+ + diff --git a/includes/js/dojox/grid/tests/test_tundra_edit.html b/includes/js/dojox/grid/tests/test_tundra_edit.html new file mode 100644 index 0000000..0aa2eeb --- /dev/null +++ b/includes/js/dojox/grid/tests/test_tundra_edit.html @@ -0,0 +1,139 @@ + + + + Test dojox.Grid Editing + + + + + + +

dojox.Grid Basic Editing test

+
+
+ + + + + + + + +
+
+
+
+
+ + diff --git a/includes/js/dojox/grid/tests/test_yahoo_images.html b/includes/js/dojox/grid/tests/test_yahoo_images.html new file mode 100644 index 0000000..fbab070 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_yahoo_images.html @@ -0,0 +1,148 @@ + + + + dojox.Grid - Image Search Test + + + + + + + + +
dojox.Grid - Image Search Test
+ + +
+
+
+
+
+
+
+
+
+

+

Note: requires PHP for proxy.

+ + diff --git a/includes/js/dojox/grid/tests/test_yahoo_search.html b/includes/js/dojox/grid/tests/test_yahoo_search.html new file mode 100644 index 0000000..063c289 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_yahoo_search.html @@ -0,0 +1,141 @@ + + + + dojox.Grid - Yahoo Search Test + + + + + + + + +
dojox.Grid - Yahoo Search Test
+
+    + +
+   +

+
+
+
+
+
+
+
+
+
+

+

Note: requires PHP for proxy.

+ + diff --git a/includes/js/dojox/grid/tests/yahooSearch.js b/includes/js/dojox/grid/tests/yahooSearch.js new file mode 100644 index 0000000..1d57a8e --- /dev/null +++ b/includes/js/dojox/grid/tests/yahooSearch.js @@ -0,0 +1,137 @@ +dojo.require("dojo.io.script") +dojo.require("dojox.rpc.Service"); + +// model that works with Yahoo Search API +dojo.declare("dojox.grid.data.yahooSearch", dojox.grid.data.Dynamic, { + constructor: function(inFields, inData, inSearchNode){ + this.rowsPerPage = 20; + this.searchNode = inSearchNode; + this.fieldNames = dojo.map(inFields, "return item.name;"); + this.yahoo = new dojox.rpc.Service( + dojo.moduleUrl("dojox.rpc.SMDLibrary", "yahoo.smd") + ); + }, + // server send / receive + send: function(inAsync, inParams, inOnReceive, inOnError){ + var d = this.yahoo.imageSearch( + dojo.mixin({ + results: this.rowsPerPage, + query: this.getQuery() + }, inParams) + ); + d.addCallbacks( + dojo.hitch(this, "receive", inOnReceive, inOnError), + dojo.hitch(this, "error", inOnError) + ); + this.onSend(inParams); + return d; + }, + receive: function(inOnReceive, inOnError, inData){ + try{ + inData = inData.ResultSet; + inOnReceive(inData); + this.onReceive(inData); + }catch(e){ + if(inOnError){ + inOnError(inData); + } + } + }, + error: function(inOnError, inErr) { + var m = 'io error: ' + inErr.message; + alert(m); + if (inOnError) + inOnError(m); + }, + encodeParam: function(inName, inValue) { + return dojo.string.substitute('&${0}=${1}', [inName, inValue]); + }, + getQuery: function(){ + return dojo.byId(this.searchNode).value.replace(/ /g, '+'); + }, + fetchRowCount: function(inCallback){ + this.send(true, inCallback); + }, + // request data + requestRows: function(inRowIndex, inCount){ + inRowIndex = (inRowIndex == undefined ? 0 : inRowIndex); + var params = { + start: inRowIndex + 1 + } + this.send(true, params, dojo.hitch(this, this.processRows)); + }, + // server callbacks + processRows: function(inData){ + for(var i=0, l=inData.totalResultsReturned, s=inData.firstResultPosition; i${text}', + { href: inData, text: text } + ); +}; + +formatImage = function(inData, inRowIndex){ + if(!inData){ return ' '; } + var info = getCellData(this, inRowIndex, this.extraField); + var o = { + href: inData, + src: info.Url, + width: info.Width, + height: info.Height + } + return dojo.string.substitute( + '', o); +}; + +formatDate = function(inDatum, inRowIndex){ + if(!inDatum){ return ' '; } + var d = new Date(inDatum * 1000); + return dojo.string.substitute( + "${0}/${1}/${2}", + [ d.getMonth()+1, d.getDate(), d.getFullYear() ] + ); +}; + +formatDimensions = function(inData, inRowIndex){ + if(!inData){ return ' '; } + var w = inData, h = getCellData(this, inRowIndex, this.extraField); + return w + ' x ' + h; +} -- cgit v1.2.3