|
From: Thyamad c. <th...@us...> - 2006-01-23 03:35:41
|
Update of /cvsroot/thyapi/thyapi/thywidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31976/thywidgets Added Files: thygrid_ie.js thygridcell_ie.js thygridcontents_ie.js thygridrow_ie.js Log Message: Commiting file additions and modification from SVN revision 2700 to 2701... Changes made by vinicius on 2006-01-23 05:39:18 +0100 (Mon, 23 Jan 2006) corresponding to SVN revision 2701 with message: --- NEW FILE: thygridcontents_ie.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Table Grid Contents Element, with * * optimizations to Internet Explorer - http://www.thyamad.com * * * * Copyright (C) 2005, 2006 - The Thyamad Crew * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published * * by the Free Software Foundation; either version 2.1 of the License, * * or any later version. * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License for more details. * \***************************************************************************/ /** * Class: thyGridContents * * This is the Grid Contents class. It is a <thyPanel> that creates a TABLE * element and overload some of it methods to guarantee that the TABLE will * be constructed correctly * * CSS Classes: * * - .thyGridContents * * - .<object name> * * See Also: * * - <thyGrid> * * - <thyPanel> * */ function thyGridContents(name) { this.thyPanel = thyPanel; this.thyPanel(name); } p = dynapi.setPrototype('thyGridContents','thyPanel'); /** * Method: getOuterHTML * * Overwritten method that draws TABLE element instead of DIV * */ p.getOuterHTML = function () { var html = [ '<table id="'+this.id+'"', (this.disabled ? 'disabled' : ''), (this.readOnly?'readonly':''), 'cellpadding="0"', 'cellspacing="0"', 'border="0"', 'width="100%"', 'style="', 'width:100%;', '"><tbody>', this.getInnerHTML(), //(this.contentRelative ? '</div></div>' : '</div>') '</tbody></table>' ].join(''); //alert(html); return html; } /** * Method: invokeEvent * * Overloaded method that calls the invokeEvent of <thyGrid> instead * of this. * */ p.invokeEvent = function (eventName, eventObj) { if (!this.parent || !this.parent.parent) return; this.parent.parent.invokeEvent(eventName, eventObj); } --- NEW FILE: thygridcell_ie.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Table Grid Cell Element, with * * optimizations to Internet Explorer - http://www.thyamad.com * * * * Copyright (C) 2005, 2006 - The Thyamad Crew * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published * * by the Free Software Foundation; either version 2.1 of the License, * * or any later version. * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License for more details. * \***************************************************************************/ /** * Class: thyGridCell * * This is the basic Cell element. It should provides all functionalities * that a Table Cell element should have. * * CSS Classes: * * - .thyGridCell_edit - when in simple edit mode * - .thyGridCell_editFull - when in full edit mode * - .thyGridCell_selected - when selected * - .thyGridCell_header - when type is header * - .thyGridCell_header_selected - when type is header and it is selected * * - .<object name>_edit - when in simple edit mode * - .<object name>_editFull - when in full edit mode * - .<object name>_selected - when selected * - .<object name>_header - when type is header * - .<object name>_header_selected - when type is header and it is selected * * Package: ThyAPI * * Namespace: ThyWidgets * * See Also: * - <thyGrid> * - <thyPanel> * */ function thyGridCell(name, html) { this.thyPanel = thyPanel; this.thyPanel(name,null); // Atributes this.cellMode = 0; this.cellType = 0; this.cellSelected = false; this.setRelativeness(false); this.cssClasses = { 'default': ['default'], selected : ['default', 'selected'], header : ['header'], header_selected : ['header', 'header_selected'] }; this.addCSSClass('thyGridCell'); var self = this; this.addEventListener({ onclick: function(e){ if (e.getOrigin() == self.cellContents) self._selectEvent() }}); } p = dynapi.setPrototype('thyGridCell', 'thyPanel'); /** * Method: populate * * Sets the contents of the cell. * * Parameter: * * data - The contents of the Cell, that can be: * * - A non-object data (will be included as HTML to the contents of the cell) * - A <thyPanel> or derivate class object that will be added as child. * - A <thyCollection> of <thyPanel> or derivate classe objects, that will * be added sequentially as children. * */ p.populate = function (data) { if (typeof(data) != 'object') this.setHTML(data); else if (typeof(data.isFromClass) == 'function') { if(data.isFromClass('thyPanel')) { this._destroyAllChildren(); this.addChild(data); } else if (data.isFromClass('thyCollection')) { try { this._destroyAllChildren(); var i,nData = data.getElementsCount(); for (i=0; i<nData; i++) { this.addChild(data.getElementById(i)); } } catch(e) { return; } } } else { try { this.setHTML(data); } catch(e) { return; } } } /** * Method: sweepOut * * Gets the contents of the cell. * * If the contents of the cell is simply HTML, it is returned, otherwise * in case the cell has children, their sweepOut() returned values are * grouped in a <thyCollection> and returned. * */ p.sweepOut = function () { if (!this.children.length) return this.getHTML(); try { var i,contents = new thyCollection(); for (i=0; i<this.children.length; i++) { contents.add(this.children[i].sweepOut(), this.children[i].name); } return contents; } catch(e) { return; } } p._thyPanelAddChild = p.addChild; /** * Method: addChild * * Adds a widget inside the cell * */ p.addChild = function (child) { if (this.children.length == 0) this._thyPanelSetHTML(''); this._thyPanelAddChild(child); } p._thyPanelSetHTML = p.setHTML; /** * Method: setHTML * * Overloaded method that sets HTML of Contents, never putting empty HTML * inside box (otherwise it would not be visible). * * Parameter: * * html - The HTML code to be inserted * */ p.setHTML = function (html) { if (!html && typeof(html) != 'number') html = ' '; this._thyPanelSetHTML(html); } p._thyPanelGetHTML = p.getHTML; /** * Method: getHTML * * Overloaded method that returns the HTML of Contents and not the HTML * of cell. Besides that, it garantees that the return is not ' ', which * is set as HTML when setHTML receives a null parameter. * */ p.getHTML = function () { var rSpace = new RegExp(' [;]', 'g'); var html = this._thyPanelGetHTML(); if (html == ' ' || html == ' ') { return ''; } if (typeof(html) == 'string') { return html.replace(rSpace, ' '); } if (typeof(html) == 'object' && typeof(html.isFromClass) && html.isFromClass('thyPanel')) { return html.sweepOut(); } return html; } /** * Method: setMode * * Sets the onclick exchange mode of the grid. This can be: * * - r (Read Only) * - rws (Simple Read/Write) * - rwf (Full Read/Write) * * Parameters: * * mode - The mode * * - *Note* - The only supported mode now is Read Only * */ p.setMode = function(mode) { if (this.cellType == 1) return; if (this.readOnly) return; switch (mode) { case 'r' : mode = 0; break; case 'rws': mode = 1; break; case 'rwf': mode = 2; break; default: return; } this.cellMode = mode; this._processMode(); } /** * Method: setType * * Change this object type to one of: * * - Normal * - Header * * Parameters: * * type - The type. 'n' for Normal, 'h' for header * */ p.setType = function(type) { switch (type) { case 'n': type = 0; break; case 'h': type = 1; break; default : return; } this.cellType = type; this._processType(); } /** * Method: setSelected * * Sets the selected state of this Cell * * Parameters: * * state - true/false * */ p.setSelected = function(state) { state = (state) ? true : false; if (this.cellSelected == state) return; this.cellSelected = state; this._processType(); } /** * Method: switchSelectedState * * Switches the actual selected state, turning the cell into selected if it is * not and vice-versa * */ p.switchSelectedState = function() { this.setSelected(!this.cellSelected); } /** * Method: isSelected * * Returns the selected state of this Cell * * Returns: * * Boolean */ p.isSelected = function() { return this.cellSelected; } /** * Method: getOuterHTML * * Overwritten method that draws TD element instead of DIV * */ p.getOuterHTML = function () { var html = [ '<td '+this._cssClass+' id="'+this.id+'" '+(this.disabled ? 'disabled' : '')+' '+(this.readOnly?'readonly':'')+' style="', ((this.x!=null)? ' left: '+((typeof(this.x)=='string')?this.x+';':this.x+'px;') : ''), ((this.y!=null)? ' top: '+((typeof(this.y)=='string')?this.y+';':this.y+'px;') : ''), ((this.w)? ' width:'+((typeof(this.w)=='string')?this.w+';':(this.w+fixBw)+'px;'):''), ((this.h)? ' height:'+((typeof(this.h)=='string')?this.h+';':(this.h+fixBh)+'px;'):''), ((this.z)? ' z-index: '+this.z+';':''), ((this._cursor!=null)? ' cursor:'+this._cursor+';':''), ((this.visible==false)? ' visibility:hidden;': ''), ((this.display) ? ' display: '+this.display+';' : ''), this._cssBorder, ((this._overflow)? this._cssOverflow : ''), ((this.x != null || this.y != null) ? this._cssPosition+';' : ''), (this._float ? this._cssFloat : ''), '">', this.getInnerHTML(), '</td>' ].join(''); //alert(html); return html; } /*************************************************************************\ * Private Methods * \*************************************************************************/ p._create = function () { if (this.parent && !this.elm) { var elm = this._createDOMElement(); DynLayer._assignElement(this,elm); DynElement._flagCreate(this); } } // FIXME: this should be on browser specific methods! p._createDOMElement = function () { if (this.parent) { var elm, parentElm; parentElm = this.parent.elm; if (!this.elm) { elm = this.parent.doc.createElement('td'); elm._className = this._cssClass; elm.id = this.id; var css = elm.style; if (this.w) css.width = this.w; if (this.h) css.height = this.h; if (this.bgColor != null) css.backgroundColor = this.bgColor; if (this.z) css.zIndex = this.z; if (this._cursor != null) css.cursor = this._cursor; if (this._overflow) css.overflow = this._overflow; css.visibility=(this.visible==false)? 'hidden':''; if(this.display) css.display = this.display; if(this.disabled) elm.disabled = true; elm.innerText = this.getInnerHTML(); } else { elm = this.elm; } parentElm.appendChild(elm); return elm; } } /** * Method: _processMode * * Process the modifications needed to achieve the selected mode. * */ p._processMode = function() { switch (this.cellMode) { case 0: this.setHTML(this.cellEditBox.sweepOut()); return; case 1: this.cellEditBox.populate(this.getHTML()); this.cellEditBox.setDisplay(true); this.cellEditBox.focus(); } return; } /** * Method: _processType * * Process the modifications needed to achieve the type mode. */ p._processType = function() { switch (this.cellType) { case 0: this.setCSSClass(this.cellSelected ? 'selected' : 'default'); return; case 1: this.setCSSClass(this.cellSelected ? 'header_selected' : 'header'); return; } } /** * Method: _selectEvent * * Method that handles onclick events * */ p._selectEvent = function() { this.setSelected(!this.cellSelected); } --- NEW FILE: thygrid_ie.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Table Grid Element, with optimizations * * to Internet Explorer - http://www.thyamad.com * * * * Copyright (C) 2005, 2006 - The Thyamad Crew * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published * * by the Free Software Foundation; either version 2.1 of the License, * * or any later version. * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License for more details. * \***************************************************************************/ /** [...965 lines suppressed...] * */ p._sweepOutContents = function () { var i,nRows = this.getRowsCount(); data = {rows: [ ], selectedRows: {}}; for (i=0; i<nRows; i++) { data.rows[i] = this.getRow(i).getIndexedElements(); } data.selectedRows = this.getSelectedRowsIndexes().getIndexedElements(); return data; } /****************************************************************************\ * Events * \****************************************************************************/ --- NEW FILE: thygridrow_ie.js --- /***************************************************************************\ * ThyAPI - Thyamad Javascript API - Table Grid Row Element, with * * optimizations to Internet Explorer - http://www.thyamad.com * * * * Copyright (C) 2005, 2006 - The Thyamad Crew * * Based on DynAPI v3.0b1 * * ------------------------------------------------------------------------- * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published * * by the Free Software Foundation; either version 2.1 of the License, * * or any later version. * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License for more details. * \***************************************************************************/ /** * Class: thyGridRow * * This is the Grid Row class. It is just a <thyPanel> with a * <thyVisualCollection> of <thyGridCell> elements. * * CSS Classes: * * - .thyGridRow * * - .<object name> * * See Also: * * - <thyGrid> * * - <thyPanel> * */ function thyGridRow(name, index) { this.thyPanel = thyPanel; this.thyPanel(name); // Attributes \\ this.cells = new thyVisualCollection(this.name+'_cells', this); this.selected = false; this.selCellSelRow = false; this.cellCSSClasses = new thyCollection(); this.cellIndexedCSSClasses = new thyCollection(); this.rowIndex = index || 0; this.setRelativeness(false); this.cells.setDefaultName('Cell'+index); this.insertCell(this.rowIndex == -1 ? '' : this.rowIndex, -1, 'h'); this.addCSSClass('thyGridRow'); //if (!this.thyGridRow) this.onPreCreate(this.initThyGridRow); } p = dynapi.setPrototype('thyGridRow', 'thyPanel'); /** * Method: initThyGridRow * * Initialization Method. Inserts the Row header Cell * */ p.initThyGridRow = function () { } /** * Method: addCellCSSClass * * Append a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow> * * Parameter: * * cssClass - The CSS class * */ p.addCellCSSClass = function (cssClass) { this._addCellCSSClass(cssClass); this._updateAllClasses(); } /** * Method: addCellIndexedCSSClass * * Append a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow>. This classes will * be appended with the Cell column index * * Parameter: * * cssClass - The CSS class * */ p.addCellIndexedCSSClass = function (cssClass) { this._addCellIndexedCSSClass(cssClass); this._updateAllClasses(); } /** * Method: removeCellCSSClass * * Remove a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow> * * Parameter: * * cssClass - The CSS class * */ p.removeCellCSSClass = function (cssClass) { this._removeAllClasses(); this._removeCellCSSClass(cssClass); this._updateAllClasses(); } /** * Method: removeCellIndexedCSSClass * * Remove a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow>. This classes will * be appended with the Cell column index * * Parameter: * * cssClass - The CSS class * */ p.removeCellIndexedCSSClass = function (cssClass) { this._removeAllClasses(); this._removeCellIndexedCSSClass(cssClass); this._updateAllClasses(); } /** * Method: removeAllCellClasses * * Removes all CSS classes from both cellCSSClasses and cellIndexedCSSClasses * */ p.removeAllCellClasses = function () { this._removeAllClasses(); this._removeAllCellClasses(); this._updateAllClasses(); } /** * Method: setIndex * * Sets the Index of this Row * * Parameter: * * index - The new Row index * */ p.setIndex = function (index) { if (index == null || this.rowIndex == index) return; this.rowIndex = index; this.cells.setDefaultName('Cell'+index); this.cells.getElementByIndex(0).setHTML(this.rowIndex == -1 ? '' : this.rowIndex); this._updateNames(); } /** * Method: getIndex * * Returns the index of this Row * */ p.getIndex = function () { return this.rowIndex; } /** * Method: insertCell * * Inserts a Cell into the specified column * * Parameters: * * content - The cell content * column - The column index * type - The cell type (n - normal, h - header) * */ p.insertCell = function (content, column, type) { var col; if (content == null) content = ''; if (column == null || typeof(column) != 'number') col = this.cells.getElementsCount()-1; else col = column; var cell = this._createCell(col, type); cell.populate(content); this.cells.add(cell, cell.name); this._updateClasses(cell, col+1); if (column != null && column != (col-1)) this.moveCell(col-1, column); return col+1; } /** * Method: getCell * * Returns the contents of the Cell that resides on the specified * column * * Parameter: * * column - The column index * */ p.getCell = function (column) { if (column == null || typeof(column) != 'number') column = 0; column++; var cell = this.cells.getElementByIndex(column); return cell ? cell.sweepOut() : ''; } /** * Method: getCellElement * * Returns the <thyGridCell> element that resides on the specified position * * If what you want is just the cell contents, please use <thyGridRow>::getCell * * This method should *ONLY* be used if developer wants to manipulate cell * properties! Be warned that messing with wrong property may break encapsulation * and thus produce undesired effects on <thyGridRow> * * Parameter: * * column - The column index * */ p.getCellElement = function (column) { if (column == null || typeof(column) != 'number') return; var col = column+1; return this.cells.getElementByIndex(col); } /** * Method: getSelectedCells * * Returns a <thyCollection> with the contents of the Selected Cells * */ p.getSelectedCells = function () { var cells = new thyCollection(); var i,cell,nCells = this.cells.getElementsCount(); for (i=1; i<nCells; i++) { cell = this.cells.getElementByIndex(i); if (cell.isSelected()) cells.add(cell.sweepOut()); } return cells; } /** * Method: getCellsCount * * Returns the number of cells this row has * */ p.getCellsCount = function () { return this.cells.getElementsCount()-1; } /** * Method: removeCell * * Removes the Cell on the specified column * * Parameter: * * column - The column index * * Returns: * * The Cell contents * */ p.removeCell = function (column) { if (column == null || typeof(column) != 'number') column = 0; column++; var cell = this.cells.getElementByIndex(column); this.cells.remove(cell, cell.name, column); this._updateNames(); this._updateAllClasses(); return cell.sweepOut(); } /** * Method: moveCell * * Changes the position of a Cell to a new place * * Parameters: * * orig - The original column * dest - The destination column * */ p.moveCell = function (orig, dest) { if (orig == null || typeof(orig) != 'number' || dest == null || typeof(dest) != 'number') throw({result: 'Invalid Indexes', location: 'thyGridRow.moveCell'}); orig++; dest++; var cell = this.cells.getElementByIndex(orig); if (!cell) return; var nClasses = this.cellIndexedCSSClasses.getElementsCount(); for (i=0; i<nClasses; i++) { cell.removeCSSClass(this.cellIndexedCSSClasses.getElementByIndex(i)+orig); } if (this.cells.changeElementIndex({oldIndex: orig, index: dest}) == null) return; this._updateNames(); this._updateAllClasses(); } /** * Method: isSelected * * Used to check if the cell is selected or not * * Returns: * * Boolean - True if selected, False if not selected * */ p.isSelected = function () { return this.selected; } /** * Method: selectOnly * * Selects the whole row, BUT DO NOT CALL event 'onselectrow' * */ p.selectOnly = function () { if (this.isSelected()) { return; } this.selected = true; var i,cell,nCells = this.cells.getElementsCount(); for (i=0; i<nCells; i++) { cell = this.cells.getElementByIndex(i); cell.setSelected(true); } } /** * Method: select * * Selects the whole Row, that means, all Cells and calls * event handler 'onselectrow' and 'onselectrow<n>' where <n> * is the row index. * */ p.select = function () { if (this.isSelected()) { return; } this.selectOnly(); if (this.parent) { var eventName = this.getIndex() == -1 ? 'selectheaderrow' : 'selectrow'; this.parent.invokeEvent(eventName, new DynEvent(eventName, this)); this.parent.invokeEvent(eventName+this.rowIndex, new DynEvent(eventName+this.rowIndex, this)); } } /** * Method: unselectOnly * * Unselects the whole row, BUT DO NOT CALL event 'onunselectrow' * */ p.unselectOnly = function () { if (!this.isSelected()) { return; } this.selected = false; var i,cell,nCells = this.cells.getElementsCount(); for (i=0; i<nCells; i++) { cell = this.cells.getElementByIndex(i); cell.setSelected(false); } } /** * Method: unselect * * Unselectes the whole Row, that means, all Cells and calls * event handler 'onselectrow' and 'onselectrow<n>' where <n> * is the row index. * */ p.unselect = function () { if (!this.isSelected()) { return; } this.unselectOnly(); if (this.parent) { var eventName = this.getIndex() == -1 ? 'unselectheaderrow' : 'unselectrow'; this.parent.invokeEvent(eventName, new DynEvent(eventName, this)); this.parent.invokeEvent(eventName+this.rowIndex, new DynEvent(eventName, this)); } } /** * Method: switchSelectedState * * Changes the selected state to its oposit state * */ p.switchSelectedState = function () { this.selected ? this.unselect() : this.select(); } /** * Method: setSelectCellSelectRow * * Selects all cells if any cell is selected * * */ p.setSelectCellSelectRow = function () { this.selCellSelRow = true; } /** * Method: unsetSelectCellSelectRow * * Selects all cells only if clicking on row header * */ p.unsetSelectCellSelectRow = function () { this.selCellSelRow = false; } /** * Method: getOuterHTML * * Overwritten method that draws TR element instead of DIV * */ p.getOuterHTML = function () { var html = [ '<tr '+this._cssClass+' id="'+this.id+'" '+(this.disabled ? 'disabled' : '')+' '+(this.readOnly?'readonly':'')+' style="', ((this.x!=null)? ' left: '+((typeof(this.x)=='string')?this.x+';':this.x+'px;') : ''), ((this.y!=null)? ' top: '+((typeof(this.y)=='string')?this.y+';':this.y+'px;') : ''), ((this.w)? ' width:'+((typeof(this.w)=='string')?this.w+';':(this.w+fixBw)+'px;'):''), ((this.h)? ' height:'+((typeof(this.h)=='string')?this.h+';':(this.h+fixBh)+'px;'):''), ((this.z)? ' z-index: '+this.z+';':''), ((this._cursor!=null)? ' cursor:'+this._cursor+';':''), ((this.visible==false)? ' visibility:hidden;': ''), ((this.display) ? ' display: '+this.display+';' : ''), this._cssBorder, ((this._overflow)? this._cssOverflow : ''), ((this.x != null || this.y != null) ? this._cssPosition+';' : ''), (this._float ? this._cssFloat : ''), '">', this.getInnerHTML(), '</tr>' ].join(''); //alert(html); return html; } /*************************************************************************\ * Group: Private Methods * \*************************************************************************/ /** * Method: _create * * Overloaded method that creates the TR element and inserts it into parent * */ p._create = function () { if (this.parent && !this.elm) { var elm, parentElm; // Parent MUST be thyGridContents \\ if (typeof(this.parent.isFromClass) != 'function' || !this.parent.isFromClass('thyGridContents')) { throw({result: 'thyGridRow MUST be child of thyGridContents', location: 'thyGridRow._create'}); } elm = this._createDOMElement(); this.elm = elm; this.doc = this.parent.doc; this._created = true; for (var i=0; i<this.children.length; i++) this.children[i]._createDOMElement(); DynLayer._assignElement(this,elm); DynElement._flagCreate(this); } } p._createDOMElement = function () { if (this.parent && !this.elm) { var elm, parentElm; parentElm = this.parent._getDOMChildrenHolder(); elm = this.parent.doc.createElement('tr'); elm._className = this._cssClass; elm.id = this.id; var css = elm.style; if (this.w) css.width = this.w; if (this.h) css.height = this.h; if (this.bgColor != null) css.backgroundColor = this.bgColor; if (this.z) css.zIndex = this.z; if (this._cursor != null) css.cursor = this._cursor; if (this._overflow) css.overflow = this._overflow; css.visibility=(this.visible==false)? 'hidden':''; if(this.display) css.display = this.display; if(this.disabled) elm.disabled = true; parentElm.appendChild(elm); return elm; } } /** * Method: _addCellCSSClass * * Append a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow> * * Parameter: * * cssClass - The CSS class * */ p._addCellCSSClass = function (cssClass) { this.cellCSSClasses.add(cssClass, cssClass); } /** * Method: _addCellIndexedCSSClass * * Append a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow>. This classes will * be appended with the Cell column index * * Parameter: * * cssClass - The CSS class * */ p._addCellIndexedCSSClass = function (cssClass) { this.cellIndexedCSSClasses.add(cssClass, cssClass); } /** * Method: _removeCellCSSClass * * Remove a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow> * * Parameter: * * cssClass - The CSS class * */ p._removeCellCSSClass = function (cssClass) { this.cellCSSClasses.remove(cssClass, cssClass); } /** * Method: _removeCellIndexedCSSClass * * Remove a CSS class to the list of classes that will be added to * all Cells created/manipulated by <thyGridRow>. This classes will * be appended with the Cell column index * * Parameter: * * cssClass - The CSS class * */ p._removeCellIndexedCSSClass = function (cssClass) { this.cellIndexedCSSClasses.remove(cssClass, cssClass); } /** * Method: removeAllCellClasses * * Removes all CSS classes from both cellCSSClasses and cellIndexedCSSClasses * */ p._removeAllCellClasses = function () { this.cellCSSClasses.cleanUp(); this.cellIndexedCSSClasses.cleanUp(); } /** * Method: _createCell * * Creates a Cell and sets all CSS Classes that has been passed to * <thyGridRow> * * Parameters: * * colIndex - The column index of this cell * type - The Cell type. Can be 'n' for normal or 'h' for header * */ p._createCell = function (colIndex, type) { if (!type) type = 'n'; var cell = new thyGridCell('Cell'+this.rowIndex+colIndex); cell.setType(type); var self = this; if (type == 'n') { cell.addEventListener({ onclick: function(e) { if (self.selCellSelRow) self.switchSelectedState(); }}); } else { cell.addEventListener({ onclick: function(e) { self.switchSelectedState(); }}); } return cell; } /** * Method: _updateNames * * Updates the names of all Cells to reflect their real positions and * also updates all CSS indexed classes * */ p._updateNames = function () { var i,name,cell,cellPos,nCells = this.cells.getElementsCount(); for (i=0; i<nCells; i++) { cellPos = ''+this.rowIndex+(i-1); cell = this.cells.getElementByIndex(i); this.cells.changeElementName({elm: cell, name: 'Cell'+cellPos, index: i}); cell.setName('Cell'+cellPos); } } /** * Method: _updateClasses * * Updates the classes of the specified cell * * Parameter: * * cell - The specific cell * cellIdx - The index of the cell */ p._updateClasses = function (cell, cellIdx) { var i,nClasses = this.cellCSSClasses.getElementsCount(); for (i=0; i<nClasses; i++) { cell._addCSSClass(this.cellCSSClasses.getElementByIndex(i)); } nClasses = this.cellIndexedCSSClasses.getElementsCount(); for (i=0; i<nClasses; i++) { cell._addCSSClass(this.cellIndexedCSSClasses.getElementByIndex(i)+(cellIdx-1)); } cell.setCSSClass(cell.cssActualSelection); } /** * Method: _updateAllClasses * * Updates the classes of every cell * */ p._updateAllClasses = function () { var i,cell,nClasses,nCells = this.cells.getElementsCount(); for (i=0; i<nCells; i++) { cell = this.cells.getElementByIndex(i); this._updateClasses(cell,i); } } /** * Method: _removeAllClasses * * Removes the classes of every cell * */ p._removeAllClasses = function () { } |