summaryrefslogtreecommitdiff
path: root/gstudio/static/gstudio/js/Gnowmacs/test/dl/deprecated/js/gridmodel.js
diff options
context:
space:
mode:
Diffstat (limited to 'gstudio/static/gstudio/js/Gnowmacs/test/dl/deprecated/js/gridmodel.js')
-rw-r--r--gstudio/static/gstudio/js/Gnowmacs/test/dl/deprecated/js/gridmodel.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/gstudio/static/gstudio/js/Gnowmacs/test/dl/deprecated/js/gridmodel.js b/gstudio/static/gstudio/js/Gnowmacs/test/dl/deprecated/js/gridmodel.js
new file mode 100644
index 00000000..44e952ed
--- /dev/null
+++ b/gstudio/static/gstudio/js/Gnowmacs/test/dl/deprecated/js/gridmodel.js
@@ -0,0 +1,3 @@
+// @require eventproxy.js
+// cell model
+(function(){DlGridCellModel.inherits(DlEventProxy);function DlGridCellModel(a){arguments.length>0&&(DlEventProxy.call(this),typeof a!="object"&&(a={value:a}),DlGridCellModel.setDefaults(this,a),this.registerEvents(DEFAULT_EVENTS))}eval(Dynarch.EXPORT("DlGridCellModel"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={_value:["value",null],_style:["style",{}]},P.setValue=function(a){var b=this._value;this._value=a,this.applyHooks("onChange",[this,"value",a,b])},P.getContent=function(){return this._value},P.getStyle=function(a,b){if(a in this._style)return this._style[a];return b},P.getIndex=function(){return this.index},P.getId=function(){return this.model.getColByIndex(this.index).id},P.setStyle=function(a,b){var c=this._style[a];this._style[a]=b,this.applyHooks("onChange",[this,"style",b,c,a])},P.compareTo=function(a){return this._value<a._value?-1:this._value>a._value?1:0}})(),function(){DlGridColModel.inherits(DlEventProxy);function DlGridColModel(args){arguments.length>0&&(DlEventProxy.call(this),DlGridColModel.setDefaults(this,args),this.registerEvents(DEFAULT_EVENTS),typeof this._cellType=="string"&&(this._cellType=eval(this._cellType)))}eval(Dynarch.EXPORT("DlGridColModel"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={width:["width",null],fill:["fill",false],_label:["label",null],id:["id",null],_cellType:["cellType",DlGridCellModel],isResizable:["resizable",false],isScrollable:["scrollable",true],isSortable:["sortable",true],tooltip:["tooltip",null],_style:["style",{}],_iconClass:["iconClass",null]},P.getId=function(){return this.id},P.getIndex=function(){return this.index},P.getIconClass=function(){return this._iconClass},P.setIconClass=function(a){var b=this._iconClass;this._iconClass=a,this.applyHooks("onChange",[this,"iconClass",val,b])},P.getLabel=function(){return this._label},P.setLabel=function(a){var b=this._label;this._label=a,this.applyHooks("onChange",[this,"label",val,b])},P.getCellType=function(){return this._cellType},P.createCell=function(a){var b=new this._cellType(a);return b},P.getStyle=function(a,b){if(a in this._style)return this._style[a];return b},P.setStyle=function(a,b){var c=this._style[a];this._style[a]=b,this.applyHooks("onChange",[this,"style",b,c,a])},P.sort=function(){this.model.sort(this)},P.compareRows=function(a,b){var c=this.getIndex();a=a.getCellByIndex(c),b=b.getCellByIndex(c);return a.compareTo(b)}}(),function(){DlGridRowModel.inherits(DlEventProxy);function DlGridRowModel(a){if(arguments.length>0){if(a instanceof Array){var b={id:a.id,model:a.model,cells:{}};a.model.foreachCol(function(c,d){b.cells[c.getId()]=a[d]}),a=b}DlEventProxy.call(this),D.setDefaults(this,a),this.registerEvents(DEFAULT_EVENTS),this._init()}}eval(Dynarch.EXPORT("DlGridRowModel"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={id:["id",null],userData:["data",null],_cells:["cells",null],_model:["model",null],tooltip:["tooltip",null]},P.reset=function(a){this.id=a.id,this.userData=a.data,this.tooltip=a.tooltip,this.foreachCell(function(b,c){b.setValue(a.cells[c.getId()])})},P.getId=function(){return this.id},P.getIndex=function(){return this.index},P.getCells=function(){return this._cells},P.getCellByIndex=function(a){return this._cells[this.model.getColByIndex(a).getId()]},P.foreachCell=function(a,b){this.model.foreachCol(function(c,d){var e=this._cells[c.getId()];a.apply(b,[e,c,d])},this)},P._onCellChange=function(a,b,c,d){this.applyHooks("onChange",[this,a,b,c,d])},P._init=function(){var a=this._model,b=this._cells;this.model=a,delete this._model;var c=this._onCellChange.$(this);for(var d in b){var e=b[d],f=a.getColById(d);e=b[d]=f.createCell(e),e.model=a,e.colId=d,e.index=f.getIndex(),e.parent=this,e.addEventListener("onChange",c)}}}(),function(){DlGridModel.inherits(DlEventProxy);function DlGridModel(a){arguments.length>0&&(DlEventProxy.call(this),DlGridModel.setDefaults(this,a),this.registerEvents(DEFAULT_EVENTS),this._init())}eval(Dynarch.EXPORT("DlGridModel"));var DEFAULT_EVENTS=["onInsertRow","onDeleteRow","onInsertCol","onInsertCol","onMoveRow","onMoveCol","onRowChange","onColChange","onSort"];D.DEFAULT_ARGS={_rows:["rows",[]],_cols:["cols",null]},P.getRowById=function(a){return this._rowsById[a]},P.getRowByIndex=function(a){return this._rows[a]},P.foreachRow=function(){return this._rows.foreach.apply(this._rows,arguments)},P.foreachCol=function(){return this._cols.foreach.apply(this._cols,arguments)},P.getColById=function(a){return this._colsById[a]},P.getColByIndex=function(a){return this._cols[a]},P._init=function(){this.__sortCol=null,this.__sortDesc=false;var a=this._colsById={},b=this._rowsById={};this._onRowChange=this._onColChange.$(this),this._onRowChange=this._onRowChange.$(this),this._cols.r_assign_each(function(b,c){c=new DlGridColModel(c),c.model=this,c.index=b,c.addEventListener("onChange",this._onColChange),c.id&&(a[c.id]=c);return c},this),this._rows.r_assign_each(function(a,c){c.model=this,c=new DlGridRowModel(c),c.index=a,c.addEventListener("onChange",this._onRowChange),c.id&&(b[c.id]=c);return c},this)},P._onColChange=function(a,b,c,d){this.applyHooks("onColChange",[this,a,b,c,d])},P._onRowChange=function(a,b,c,d,e){this.applyHooks("onRowChange",[this,a,b,c,d,e])},P._getInsertPos=function(a){var b=this.__sortCol;return this._rows.foreach(function(c,d){var e=b.compareRows(c,a);this.__sortDesc&&(e=-e),e>=0&&$RETURN(d)},this)},P.insertRow=function(a,b){a.model=this,a=new DlGridRowModel(a);var c=this._rows,d=c.length;if(b==null||b==-1)b=this.__sortCol?this._getInsertPos(a):d;c.splice(b,0,a),++d;for(var e=b;e<d;++e)c[e].index=e;a.addEventListener("onChange",this._onRowChange),a.id&&(this._rowsById[a.id]=a),this.applyHooks("onInsertRow",[a]);return a},P.deleteRowById=function(a){this.deleteRowByIndex(this.getRowById(a).getIndex())},P.deleteRowByIndex=function(a){var b=this._rows,c=b[a];c.id&&delete this._rowsById[c.id],b.splice(a,1);for(var d=a;d<b.length;++d)b[d].index=d;c.removeEventListener("onChange",this._onRowChange),this.applyHooks("onDeleteRow",[c]),c.destroy();return c},P.setValues=function(a){this.__sortDesc=false,this.applyHooks("onSort",[null,this.__sortCol]),a.foreach(function(a,b){a instanceof Array&&(a={cells:a});var c=this.getRowByIndex(b);c?(c.id&&delete this._rowsById[c.id],a.id&&(this._rowsById[a.id]=c),c.reset(a)):this.insertRow(a,this._rows.length)},this);while(a.length<this._rows.length)this.deleteRowByIndex(this._rows.length-1)},P.sort=function(a){var b=this.__sortCol;b===a?this.__sortDesc=!this.__sortDesc:this.__sortDesc=false,this.__sortCol=a;var c=a.getIndex();this._rows=this._rows.mergeSort(function(b,c){return a.compareRows(b,c)},this.__sortDesc);var d=this._rows.map(function(a,b){var c=a.index;a.index=b;return c});this.applyHooks("onSort",[a,b,this.__sortDesc,d])}}() \ No newline at end of file