public/javascripts/yui/datatable/datatable.js
function(oTrigger) {
    var sMode = this.get("selectionMode");
    var oAnchor = {};
    var oAnchorRecord, nAnchorRecordIndex, nAnchorTrIndex;

    // Cell mode
    if((sMode == "cellblock") || (sMode == "cellrange") || (sMode == "singlecell")) {
        // Validate anchor cell
        var oAnchorCell = this._oAnchorCell;
        if(!oAnchorCell) {
            if(oTrigger) {
                oAnchorCell = this._oAnchorCell = oTrigger.cell;
            }
            else {
                return null;
            }
        }
        oAnchorRecord = this._oAnchorCell.record;
        nAnchorRecordIndex = this._oRecordSet.getRecordIndex(oAnchorRecord);
        nAnchorTrIndex = this.getTrIndex(oAnchorRecord);
        // If anchor cell is not on this page...
        if(nAnchorTrIndex === null) {
            // ...set TR index equal to top TR
            if(nAnchorRecordIndex < this.getRecordIndex(this.getFirstTrEl())) {
                nAnchorTrIndex = 0;
            }
            // ...set TR index equal to bottom TR
            else {
                nAnchorTrIndex = this.getRecordIndex(this.getLastTrEl());
            }
        }

        oAnchor.record = oAnchorRecord;
        oAnchor.recordIndex = nAnchorRecordIndex;
        oAnchor.trIndex = nAnchorTrIndex;
        oAnchor.column = this._oAnchorCell.column;
        oAnchor.colKeyIndex = oAnchor.column.getKeyIndex();
        oAnchor.cell = oAnchorCell;
        return oAnchor;
    }
    // Row mode
    else {
        oAnchorRecord = this._oAnchorRecord;
        if(!oAnchorRecord) {
            if(oTrigger) {
                oAnchorRecord = this._oAnchorRecord = oTrigger.record;
            }
            else {
                return null;
            }
        }

        nAnchorRecordIndex = this.getRecordIndex(oAnchorRecord);
        nAnchorTrIndex = this.getTrIndex(oAnchorRecord);
        // If anchor row is not on this page...
        if(nAnchorTrIndex === null) {
            // ...set TR index equal to top TR
            if(nAnchorRecordIndex < this.getRecordIndex(this.getFirstTrEl())) {
                nAnchorTrIndex = 0;
            }
            // ...set TR index equal to bottom TR
            else {
                nAnchorTrIndex = this.getRecordIndex(this.getLastTrEl());
            }
        }

        oAnchor.record = oAnchorRecord;
        oAnchor.recordIndex = nAnchorRecordIndex;
        oAnchor.trIndex = nAnchorTrIndex;
        return oAnchor;
    }
}
function(oTrigger) {
    var sMode = this.get("selectionMode");
    var oAnchor = {};
    var oAnchorRecord, nAnchorRecordIndex, nAnchorTrIndex;

    // Cell mode
    if((sMode == "cellblock") || (sMode == "cellrange") || (sMode == "singlecell")) {
        // Validate anchor cell
        var oAnchorCell = this._oAnchorCell;
        if(!oAnchorCell) {
            if(oTrigger) {
                oAnchorCell = this._oAnchorCell = oTrigger.cell;
            }
            else {
                return null;
            }
        }
        oAnchorRecord = this._oAnchorCell.record;
        nAnchorRecordIndex = this._oRecordSet.getRecordIndex(oAnchorRecord);
        nAnchorTrIndex = this.getTrIndex(oAnchorRecord);
        // If anchor cell is not on this page...
        if(nAnchorTrIndex === null) {
            // ...set TR index equal to top TR
            if(nAnchorRecordIndex < this.getRecordIndex(this.getFirstTrEl())) {
                nAnchorTrIndex = 0;
            }
            // ...set TR index equal to bottom TR
            else {
                nAnchorTrIndex = this.getRecordIndex(this.getLastTrEl());
            }
        }

        oAnchor.record = oAnchorRecord;
        oAnchor.recordIndex = nAnchorRecordIndex;
        oAnchor.trIndex = nAnchorTrIndex;
        oAnchor.column = this._oAnchorCell.column;
        oAnchor.colKeyIndex = oAnchor.column.getKeyIndex();
        oAnchor.cell = oAnchorCell;
        return oAnchor;
    }
    // Row mode
    else {
        oAnchorRecord = this._oAnchorRecord;
        if(!oAnchorRecord) {
            if(oTrigger) {
                oAnchorRecord = this._oAnchorRecord = oTrigger.record;
            }
            else {
                return null;
            }
        }

        nAnchorRecordIndex = this.getRecordIndex(oAnchorRecord);
        nAnchorTrIndex = this.getTrIndex(oAnchorRecord);
        // If anchor row is not on this page...
        if(nAnchorTrIndex === null) {
            // ...set TR index equal to top TR
            if(nAnchorRecordIndex < this.getRecordIndex(this.getFirstTrEl())) {
                nAnchorTrIndex = 0;
            }
            // ...set TR index equal to bottom TR
            else {
                nAnchorTrIndex = this.getRecordIndex(this.getLastTrEl());
            }
        }

        oAnchor.record = oAnchorRecord;
        oAnchor.recordIndex = nAnchorRecordIndex;
        oAnchor.trIndex = nAnchorTrIndex;
        return oAnchor;
    }
}
function ( oTrigger ) { var sMode = this . get ( "selectionMode" ) ; var oAnchor = { } ; var oAnchorRecord , nAnchorRecordIndex , nAnchorTrIndex ; // Cell mode if ( ( sMode == "cellblock" ) || ( sMode == "cellrange" ) || ( sMode == "singlecell" ) ) { // Validate anchor cell var oAnchorCell = this . _oAnchorCell ; if ( ! oAnchorCell ) { if ( oTrigger ) { oAnchorCell = this . _oAnchorCell = oTrigger . cell ; } else { return null ; } } oAnchorRecord = this . _oAnchorCell . record ; nAnchorRecordIndex = this . _oRecordSet . getRecordIndex ( oAnchorRecord ) ; nAnchorTrIndex = this . getTrIndex ( oAnchorRecord ) ; // If anchor cell is not on this page... if ( nAnchorTrIndex === null ) { // ...set TR index equal to top TR if ( nAnchorRecordIndex < this . getRecordIndex ( this . getFirstTrEl ( ) ) ) { nAnchorTrIndex = 0 ; } // ...set TR index equal to bottom TR else { nAnchorTrIndex = this . getRecordIndex ( this . getLastTrEl ( ) ) ; } } oAnchor . record = oAnchorRecord ; oAnchor . recordIndex = nAnchorRecordIndex ; oAnchor . trIndex = nAnchorTrIndex ; oAnchor . column = this . _oAnchorCell . column ; oAnchor . colKeyIndex = oAnchor . column . getKeyIndex ( ) ; oAnchor . cell = oAnchorCell ; return oAnchor ; } // Row mode else { oAnchorRecord = this . _oAnchorRecord ; if ( ! oAnchorRecord ) { if ( oTrigger ) { oAnchorRecord = this . _oAnchorRecord = oTrigger . record ; } else { return null ; } } nAnchorRecordIndex = this . getRecordIndex ( oAnchorRecord ) ; nAnchorTrIndex = this . getTrIndex ( oAnchorRecord ) ; // If anchor row is not on this page... if ( nAnchorTrIndex === null ) { // ...set TR index equal to top TR if ( nAnchorRecordIndex < this . getRecordIndex ( this . getFirstTrEl ( ) ) ) { nAnchorTrIndex = 0 ; } // ...set TR index equal to bottom TR else { nAnchorTrIndex = this . getRecordIndex ( this . getLastTrEl ( ) ) ; } } oAnchor . record = oAnchorRecord ; oAnchor . recordIndex = nAnchorRecordIndex ; oAnchor . trIndex = nAnchorTrIndex ; return oAnchor ; } }
Returns object literal of values that represent the selection anchor. Used
to determine selection behavior resulting from a user event.

@method _getSelectionAnchor
@param oTrigger {Object} (Optional) Object literal of selection trigger values
(for key events).
@private
Returns object literal of values that represent the selection anchor . Used to determine selection behavior resulting from a user event .