prototype.getParent = function() {
return this._parent;
};
/**
* Public accessor returns Column's calculated COLSPAN value.
*
* @method getColspan
* @return {Number} Column's COLSPAN value.
*/
YAHOO.widget.Column.prototype.getColspan = function() {
return this._colspan;
};
// Backward compatibility
YAHOO.widget.Column.prototype.getColSpan = function() {
YAHOO.log("The method getColSpan() has been" +
" deprecated in favor of getColspan()", "warn", this.toString());
return this.getColspan();
};
/**
* Public accessor returns Column's calculated ROWSPAN value.
*
* @method getRowspan
* @return {Number} Column's ROWSPAN value.
*/
YAHOO.widget.Column.prototype.getRowspan = function() {
return this._rowspan;
};
// Backward compatibility
YAHOO.widget.Column.prototype.getIndex = function() {
YAHOO.log("The method getIndex() has been" +
" deprecated in favor of getKeyIndex()", "warn",
this.toString());
return this.getKeyIndex();
};
YAHOO.widget.Column.prototype.format = function() {
YAHOO.log("The method format() has been deprecated in favor of the " +
"DataTable method formatCell()", "error", this.toString());
};
YAHOO.widget.Column.formatCheckbox = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatCheckbox() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatCheckbox()", "warn",
"YAHOO.widget.Column.formatCheckbox");
YAHOO.widget.DataTable.formatCheckbox(elCell, oRecord, oColumn, oData);
};
YAHOO.widget.Column.formatCurrency = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatCurrency() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatCurrency()", "warn",
"YAHOO.widget.Column.formatCurrency");
YAHOO.widget.DataTable.formatCurrency(elCell, oRecord, oColumn, oData);
};
YAHOO.widget.Column.formatDate = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatDate() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatDate()", "warn",
"YAHOO.widget.Column.formatDate");
YAHOO.widget.DataTable.formatDate(elCell, oRecord, oColumn, oData);
};
YAHOO.widget.Column.formatEmail = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatEmail() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatEmail()", "warn",
"YAHOO.widget.Column.formatEmail");
YAHOO.widget.DataTable.formatEmail(elCell, oRecord, oColumn, oData);
};
YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatLink() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatLink()", "warn",
"YAHOO.widget.Column.formatLink");
YAHOO.widget.DataTable.formatLink(elCell, oRecord, oColumn, oData);
};
YAHOO.widget.Column.formatNumber = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatNumber() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatNumber()", "warn",
"YAHOO.widget.Column.formatNumber");
YAHOO.widget.DataTable.formatNumber(elCell, oRecord, oColumn, oData);
};
YAHOO.widget.Column.formatSelect = function(elCell, oRecord, oColumn, oData) {
YAHOO.log("The method YAHOO.widget.Column.formatSelect() has been" +
" deprecated in favor of YAHOO.widget.DataTable.formatDropdown()", "warn",
"YAHOO.widget.Column.formatSelect");
YAHOO.widget.DataTable.formatDropdown(elCell, oRecord, oColumn, oData);
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* Sort static utility to support Column sorting.
*
* @namespace YAHOO.util
* @class Sort
* @static
*/
YAHOO.util.Sort = {
/////////////////////////////////////////////////////////////////////////////
//
// Public methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Comparator function for simple case-insensitive string sorting.
*
* @method compare
* @param a {Object} First sort argument.
* @param b {Object} Second sort argument.
* @param desc {Boolean} True if sort direction is descending, false if
* sort direction is ascending.
*/
compare: function(a, b, desc) {
if((a === null) || (typeof a == "undefined")) {
if((b === null) || (typeof b == "undefined")) {
return 0;
}
else {
return 1;
}
}
else if((b === null) || (typeof b == "undefined")) {
return -1;
}
if(a.constructor == String) {
a = a.toLowerCase();
}
if(b.constructor == String) {
b = b.toLowerCase();
}
if(a < b) {
return (desc) ? 1 : -1;
}
else if (a > b) {
return (desc) ? -1 : 1;
}
else {
return 0;
}
}
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* ColumnResizer subclasses DragDrop to support resizeable Columns.
*
* @namespace YAHOO.util
* @class ColumnResizer
* @extends YAHOO.util.DragDrop
* @constructor
* @param oDataTable {YAHOO.widget.DataTable} DataTable instance.
* @param oColumn {YAHOO.widget.Column} Column instance.
* @param elThead {HTMLElement} TH element reference.
* @param sHandleElId {String} DOM ID of the handle element that causes the resize.
* @param sGroup {String} Group name of related DragDrop items.
* @param oConfig {Object} (Optional) Object literal of config values.
*/
YAHOO.util.ColumnResizer = function(oDataTable, oColumn, elThead, sHandleId, sGroup, oConfig) {
if(oDataTable && oColumn && elThead && sHandleId) {
this.datatable = oDataTable;
this.column = oColumn;
this.cell = elThead;
this.init(sHandleId, sGroup, oConfig);
//this.initFrame();
this.setYConstraint(0,0);
}
else {
YAHOO.log("Column resizer could not be created due to invalid colElId","warn");
}
};
if(YAHOO.util.DD) {
YAHOO.extend(YAHOO.util.ColumnResizer, YAHOO.util.DD);
}
/////////////////////////////////////////////////////////////////////////////
//
// Public DOM event handlers
//
/////////////////////////////////////////////////////////////////////////////
/**
* Handles mousedown events on the Column resizer.
*
* @method onMouseDown
* @param e {string} The mousedown event
*/
YAHOO.util.ColumnResizer.prototype.onMouseDown = function(e) {
this.startWidth = this.cell.offsetWidth;
this.startPos = YAHOO.util.Dom.getX(this.getDragEl());
if(this.datatable.fixedWidth) {
var cellLabel = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_LABEL,"span",this.cell)[0];
this.minWidth = cellLabel.offsetWidth + 6;
var sib = this.cell.nextSibling;
var sibCellLabel = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_LABEL,"span",sib)[0];
this.sibMinWidth = sibCellLabel.offsetWidth + 6;
//!!
var left = ((this.startWidth - this.minWidth) < 0) ? 0 : (this.startWidth - this.minWidth);
var right = ((sib.offsetWidth - this.sibMinWidth) < 0) ? 0 : (sib.offsetWidth - this.sibMinWidth);
this.setXConstraint(left, right);
YAHOO.log("cellstartwidth:" + this.startWidth,"time");
YAHOO.log("cellminwidth:" + this.minWidth,"time");
YAHOO.log("sibstartwidth:" + sib.offsetWidth,"time");
YAHOO.log("sibminwidth:" + this.sibMinWidth,"time");
YAHOO.log("l:" + left + " AND r:" + right,"time");
}
};
/**
* Handles mouseup events on the Column resizer.
*
* @method onMouseUp
* @param e {string} The mouseup event
*/
YAHOO.util.ColumnResizer.prototype.onMouseUp = function(e) {
//TODO: replace the resizer where it belongs:
var resizeStyle = YAHOO.util.Dom.get(this.handleElId).style;
resizeStyle.left = "auto";
resizeStyle.right = 0;
resizeStyle.marginRight = "-6px";
resizeStyle.width = "6px";
//.yui-dt-headresizer {position:absolute;margin-right:-6px;right:0;bottom:0;width:6px;height:100%;cursor:w-resize;cursor:col-resize;}
//var cells = this.datatable._elTable.tHead.rows[this.datatable._elTable.tHead.rows.length-1].cells;
//for(var i=0; i<cells.length; i++) {
//cells[i].style.width = "5px";
//}
//TODO: set new ColumnSet width values
this.datatable.fireEvent("columnResizeEvent", {column:this.column,target:this.cell});
};
/**
* Handles drag events on the Column resizer.
*
* @method onDrag
* @param e {string} The drag event
*/
YAHOO.util.ColumnResizer.prototype.onDrag = function(e) {
var newPos = YAHOO.util.Dom.getX(this.getDragEl());
//YAHOO.log("newpos:"+newPos,"warn");//YAHOO.util.Event.getPageX(e);
var offsetX = newPos - this.startPos;
//YAHOO.log("offset:"+offsetX,"warn");
//YAHOO.log("startwidth:"+this.startWidth + " and offset:"+offsetX,"warn");
var newWidth = this.startWidth + offsetX;
//YAHOO.log("newwidth:"+newWidth,"warn");
if(newWidth < this.minWidth) {
newWidth = this.minWidth;
}
// Resize the Column
var oDataTable = this.datatable;
var elCell = this.cell;
//YAHOO.log("newwidth" + newWidth,"warn");
//YAHOO.log(newWidth + " AND "+ elColumn.offsetWidth + " AND " + elColumn.id,"warn");
// Resize the other Columns
if(oDataTable.fixedWidth) {
// Moving right or left?
var sib = elCell.nextSibling;
//var sibIndex = elCell.index + 1;
var sibnewwidth = sib.offsetWidth - offsetX;
if(sibnewwidth < this.sibMinWidth) {
sibnewwidth = this.sibMinWidth;
}
//TODO: how else to cycle through all the Columns without having to use an index property?
for(var i=0; i<oDataTable._oColumnSet.length; i++) {
//if((i != elCell.index) && (i!=sibIndex)) {
// YAHOO.util.Dom.get(oDataTable._oColumnSet.keys[i].id).style.width = oDataTable._oColumnSet.keys[i].width + "px";
//}
}
sib.style.width = sibnewwidth;
elCell.style.width = newWidth + "px";
//oDataTable._oColumnSet.flat[sibIndex].width = sibnewwidth;
//oDataTable._oColumnSet.flat[elCell.index].width = newWidth;
}
else {
elCell.style.width = newWidth + "px";
}
};
Copyright © 2007 Yahoo! Inc. All rights reserved.