public/javascripts/yui/datatable/datatable.js
function(oArgs) {
    var elTarget = oArgs.target;

    // Validate target row
    var elTargetRow = this.getTrEl(elTarget);
    if(elTargetRow) {
        var e = oArgs.event;
        var bSHIFT = e.shiftKey;
        var bCTRL = e.ctrlKey || ((navigator.userAgent.toLowerCase().indexOf("mac") != -1) && e.metaKey);

        var oTargetRecord = this.getRecord(elTargetRow);
        var nTargetRecordIndex = this._oRecordSet.getRecordIndex(oTargetRecord);

        var oAnchor = this._getSelectionAnchor();

        var i;

        // Both SHIFT and CTRL
        if(bSHIFT && bCTRL) {
            // Validate anchor
            if(oAnchor) {
                if(this.isSelected(oAnchor.record)) {
                    // Select all rows between anchor row and target row, including target row
                    if(oAnchor.recordIndex < nTargetRecordIndex) {
                        for(i=oAnchor.recordIndex+1; i<=nTargetRecordIndex; i++) {
                            if(!this.isSelected(i)) {
                                this.selectRow(i);
                            }
                        }
                    }
                    // Select all rows between target row and anchor row, including target row
                    else {
                        for(i=oAnchor.recordIndex-1; i>=nTargetRecordIndex; i--) {
                            if(!this.isSelected(i)) {
                                this.selectRow(i);
                            }
                        }
                    }
                }
                else {
                    // Unselect all rows between anchor row and target row
                    if(oAnchor.recordIndex < nTargetRecordIndex) {
                        for(i=oAnchor.recordIndex+1; i<=nTargetRecordIndex-1; i++) {
                            if(this.isSelected(i)) {
                                this.unselectRow(i);
                            }
                        }
                    }
                    // Unselect all rows between target row and anchor row
                    else {
                        for(i=nTargetRecordIndex+1; i<=oAnchor.recordIndex-1; i++) {
                            if(this.isSelected(i)) {
                                this.unselectRow(i);
                            }
                        }
                    }
                    // Select the target row
                    this.selectRow(oTargetRecord);
                }
            }
            // Invalid anchor
            else {
                // Set anchor
                this._oAnchorRecord = oTargetRecord;

                // Toggle selection of target
                if(this.isSelected(oTargetRecord)) {
                    this.unselectRow(oTargetRecord);
                }
                else {
                    this.selectRow(oTargetRecord);
                }
            }
        }
         // Only SHIFT
        else if(bSHIFT) {
            this.unselectAllRows();

            // Validate anchor
            if(oAnchor) {
                // Select all rows between anchor row and target row,
                // including the anchor row and target row
                if(oAnchor.recordIndex < nTargetRecordIndex) {
                    for(i=oAnchor.recordIndex; i<=nTargetRecordIndex; i++) {
                        this.selectRow(i);
                    }
                }
                // Select all rows between target row and anchor row,
                // including the target row and anchor row
                else {
                    for(i=oAnchor.recordIndex; i>=nTargetRecordIndex; i--) {
                        this.selectRow(i);
                    }
                }
            }
            // Invalid anchor
            else {
                // Set anchor
                this._oAnchorRecord = oTargetRecord;

                // Select target row only
                this.selectRow(oTargetRecord);
            }
        }
        // Only CTRL
        else if(bCTRL) {
            // Set anchor
            this._oAnchorRecord = oTargetRecord;

            // Toggle selection of target
            if(this.isSelected(oTargetRecord)) {
                this.unselectRow(oTargetRecord);
            }
            else {
                this.selectRow(oTargetRecord);
            }
        }
        // Neither SHIFT nor CTRL
        else {
            this._handleSingleSelectionByMouse(oArgs);
            return;
        }
    }
}
function(oArgs) {
    var elTarget = oArgs.target;

    // Validate target row
    var elTargetRow = this.getTrEl(elTarget);
    if(elTargetRow) {
        var e = oArgs.event;
        var bSHIFT = e.shiftKey;
        var bCTRL = e.ctrlKey || ((navigator.userAgent.toLowerCase().indexOf("mac") != -1) && e.metaKey);

        var oTargetRecord = this.getRecord(elTargetRow);
        var nTargetRecordIndex = this._oRecordSet.getRecordIndex(oTargetRecord);

        var oAnchor = this._getSelectionAnchor();

        var i;

        // Both SHIFT and CTRL
        if(bSHIFT && bCTRL) {
            // Validate anchor
            if(oAnchor) {
                if(this.isSelected(oAnchor.record)) {
                    // Select all rows between anchor row and target row, including target row
                    if(oAnchor.recordIndex < nTargetRecordIndex) {
                        for(i=oAnchor.recordIndex+1; i<=nTargetRecordIndex; i++) {
                            if(!this.isSelected(i)) {
                                this.selectRow(i);
                            }
                        }
                    }
                    // Select all rows between target row and anchor row, including target row
                    else {
                        for(i=oAnchor.recordIndex-1; i>=nTargetRecordIndex; i--) {
                            if(!this.isSelected(i)) {
                                this.selectRow(i);
                            }
                        }
                    }
                }
                else {
                    // Unselect all rows between anchor row and target row
                    if(oAnchor.recordIndex < nTargetRecordIndex) {
                        for(i=oAnchor.recordIndex+1; i<=nTargetRecordIndex-1; i++) {
                            if(this.isSelected(i)) {
                                this.unselectRow(i);
                            }
                        }
                    }
                    // Unselect all rows between target row and anchor row
                    else {
                        for(i=nTargetRecordIndex+1; i<=oAnchor.recordIndex-1; i++) {
                            if(this.isSelected(i)) {
                                this.unselectRow(i);
                            }
                        }
                    }
                    // Select the target row
                    this.selectRow(oTargetRecord);
                }
            }
            // Invalid anchor
            else {
                // Set anchor
                this._oAnchorRecord = oTargetRecord;

                // Toggle selection of target
                if(this.isSelected(oTargetRecord)) {
                    this.unselectRow(oTargetRecord);
                }
                else {
                    this.selectRow(oTargetRecord);
                }
            }
        }
         // Only SHIFT
        else if(bSHIFT) {
            this.unselectAllRows();

            // Validate anchor
            if(oAnchor) {
                // Select all rows between anchor row and target row,
                // including the anchor row and target row
                if(oAnchor.recordIndex < nTargetRecordIndex) {
                    for(i=oAnchor.recordIndex; i<=nTargetRecordIndex; i++) {
                        this.selectRow(i);
                    }
                }
                // Select all rows between target row and anchor row,
                // including the target row and anchor row
                else {
                    for(i=oAnchor.recordIndex; i>=nTargetRecordIndex; i--) {
                        this.selectRow(i);
                    }
                }
            }
            // Invalid anchor
            else {
                // Set anchor
                this._oAnchorRecord = oTargetRecord;

                // Select target row only
                this.selectRow(oTargetRecord);
            }
        }
        // Only CTRL
        else if(bCTRL) {
            // Set anchor
            this._oAnchorRecord = oTargetRecord;

            // Toggle selection of target
            if(this.isSelected(oTargetRecord)) {
                this.unselectRow(oTargetRecord);
            }
            else {
                this.selectRow(oTargetRecord);
            }
        }
        // Neither SHIFT nor CTRL
        else {
            this._handleSingleSelectionByMouse(oArgs);
            return;
        }
    }
}
function ( oArgs ) { var elTarget = oArgs . target ; // Validate target row var elTargetRow = this . getTrEl ( elTarget ) ; if ( elTargetRow ) { var e = oArgs . event ; var bSHIFT = e . shiftKey ; var bCTRL = e . ctrlKey || ( ( navigator . userAgent . toLowerCase ( ) . indexOf ( "mac" ) != - 1 ) && e . metaKey ) ; var oTargetRecord = this . getRecord ( elTargetRow ) ; var nTargetRecordIndex = this . _oRecordSet . getRecordIndex ( oTargetRecord ) ; var oAnchor = this . _getSelectionAnchor ( ) ; var i ; // Both SHIFT and CTRL if ( bSHIFT && bCTRL ) { // Validate anchor if ( oAnchor ) { if ( this . isSelected ( oAnchor . record ) ) { // Select all rows between anchor row and target row, including target row if ( oAnchor . recordIndex < nTargetRecordIndex ) { for ( i = oAnchor . recordIndex + 1 ; i <= nTargetRecordIndex ; i ++ ) { if ( ! this . isSelected ( i ) ) { this . selectRow ( i ) ; } } } // Select all rows between target row and anchor row, including target row else { for ( i = oAnchor . recordIndex - 1 ; i >= nTargetRecordIndex ; i -- ) { if ( ! this . isSelected ( i ) ) { this . selectRow ( i ) ; } } } } else { // Unselect all rows between anchor row and target row if ( oAnchor . recordIndex < nTargetRecordIndex ) { for ( i = oAnchor . recordIndex + 1 ; i <= nTargetRecordIndex - 1 ; i ++ ) { if ( this . isSelected ( i ) ) { this . unselectRow ( i ) ; } } } // Unselect all rows between target row and anchor row else { for ( i = nTargetRecordIndex + 1 ; i <= oAnchor . recordIndex - 1 ; i ++ ) { if ( this . isSelected ( i ) ) { this . unselectRow ( i ) ; } } } // Select the target row this . selectRow ( oTargetRecord ) ; } } // Invalid anchor else { // Set anchor this . _oAnchorRecord = oTargetRecord ; // Toggle selection of target if ( this . isSelected ( oTargetRecord ) ) { this . unselectRow ( oTargetRecord ) ; } else { this . selectRow ( oTargetRecord ) ; } } } // Only SHIFT else if ( bSHIFT ) { this . unselectAllRows ( ) ; // Validate anchor if ( oAnchor ) { // Select all rows between anchor row and target row, // including the anchor row and target row if ( oAnchor . recordIndex < nTargetRecordIndex ) { for ( i = oAnchor . recordIndex ; i <= nTargetRecordIndex ; i ++ ) { this . selectRow ( i ) ; } } // Select all rows between target row and anchor row, // including the target row and anchor row else { for ( i = oAnchor . recordIndex ; i >= nTargetRecordIndex ; i -- ) { this . selectRow ( i ) ; } } } // Invalid anchor else { // Set anchor this . _oAnchorRecord = oTargetRecord ; // Select target row only this . selectRow ( oTargetRecord ) ; } } // Only CTRL else if ( bCTRL ) { // Set anchor this . _oAnchorRecord = oTargetRecord ; // Toggle selection of target if ( this . isSelected ( oTargetRecord ) ) { this . unselectRow ( oTargetRecord ) ; } else { this . selectRow ( oTargetRecord ) ; } } // Neither SHIFT nor CTRL else { this . _handleSingleSelectionByMouse ( oArgs ) ; return ; } } }
Determines selection behavior resulting from a mouse event when selection mode
is set to "standard".

@method _handleStandardSelectionByMouse
@param oArgs.event {HTMLEvent} Event object.
@param oArgs.target {HTMLElement} Target element.
@private
Determines selection behavior resulting from a mouse event when selection mode is set to standard .