in uima-ducc-web/src/main/webapp/root/opensources/DataTables-1.10.1/extensions/KeyTable/js/dataTables.keyTable.js [643:823]
function _fnKey ( e )
{
/* If user or system has blocked KeyTable from doing anything, just ignore this event */
if ( _that.block || !_bKeyCapture )
{
return true;
}
/* If a modifier key is pressed (exapct shift), ignore the event */
if ( e.metaKey || e.altKey || e.ctrlKey )
{
return true;
}
var
x, y,
iTableWidth = _nBody.getElementsByTagName('tr')[0].getElementsByTagName('td').length,
iTableHeight;
/* Get table height and width - done here so as to be dynamic (if table is updated) */
if ( _oDatatable )
{
/*
* Locate the current node in the DataTable overriding the old positions - the reason for
* is is that there might have been some DataTables interaction between the last focus and
* now
*/
iTableHeight = _oDatatable.aiDisplay.length;
var aDtPos = _fnFindDtCell( _nOldFocus );
if ( aDtPos === null )
{
/* If the table has been updated such that the focused cell can't be seen - do nothing */
return;
}
_iOldX = aDtPos[ 0 ];
_iOldY = aDtPos[ 1 ];
}
else
{
iTableHeight = _nBody.getElementsByTagName('tr').length;
}
/* Capture shift+tab to match the left arrow key */
var iKey = (e.keyCode == 9 && e.shiftKey) ? -1 : e.keyCode;
switch( iKey )
{
case 13: /* return */
e.preventDefault();
e.stopPropagation();
_fnEventFire( "action", _iOldX, _iOldY );
return true;
case 27: /* esc */
if ( !_fnEventFire( "esc", _iOldX, _iOldY ) )
{
/* Only lose focus if there isn't an escape handler on the cell */
_fnBlur();
return;
}
x = _iOldX;
y = _iOldY;
break;
case -1:
case 37: /* left arrow */
if ( _iOldX > 0 ) {
x = _iOldX - 1;
y = _iOldY;
} else if ( _iOldY > 0 ) {
x = iTableWidth-1;
y = _iOldY - 1;
} else {
/* at start of table */
if ( iKey == -1 && _bForm )
{
/* If we are in a form, return focus to the 'input' element such that tabbing will
* follow correctly in the browser
*/
_bInputFocused = true;
_nInput.focus();
/* This timeout is a little nasty - but IE appears to have some asyhnc behaviour for
* focus
*/
setTimeout( function(){ _bInputFocused = false; }, 0 );
_bKeyCapture = false;
_fnBlur();
return true;
}
else
{
return false;
}
}
break;
case 38: /* up arrow */
if ( _iOldY > 0 ) {
x = _iOldX;
y = _iOldY - 1;
} else {
return false;
}
break;
case 36: /* home */
x = _iOldX;
y = 0;
break;
case 33: /* page up */
x = _iOldX;
y = _iOldY - 10;
if (y < 0) {
y = 0;
}
break;
case 9: /* tab */
case 39: /* right arrow */
if ( _iOldX < iTableWidth-1 ) {
x = _iOldX + 1;
y = _iOldY;
} else if ( _iOldY < iTableHeight-1 ) {
x = 0;
y = _iOldY + 1;
} else {
/* at end of table */
if ( iKey == 9 && _bForm )
{
/* If we are in a form, return focus to the 'input' element such that tabbing will
* follow correctly in the browser
*/
_bInputFocused = true;
_nInput.focus();
/* This timeout is a little nasty - but IE appears to have some asyhnc behaviour for
* focus
*/
setTimeout( function(){ _bInputFocused = false; }, 0 );
_bKeyCapture = false;
_fnBlur();
return true;
}
else
{
return false;
}
}
break;
case 40: /* down arrow */
if ( _iOldY < iTableHeight-1 ) {
x = _iOldX;
y = _iOldY + 1;
} else {
return false;
}
break;
case 35: /* end */
x = _iOldX;
y = iTableHeight-1;
break;
case 34: /* page down */
x = _iOldX;
y = _iOldY+10;
if (y > iTableHeight-1) {
y = iTableHeight-1;
}
break;
default: /* Nothing we are interested in */
return true;
}
_fnSetFocus( _fnCellFromCoords(x, y) );
return false;
}