@ -13,7 +13,6 @@
$Id$
$Id$
* /
* /
// Constants
// Constants
var CONTROL _KEY = 1 ;
var CONTROL _KEY = 1 ;
var SHIFT _KEY = 2 ;
var SHIFT _KEY = 2 ;
@ -29,6 +28,7 @@ function rcube_webmail()
this . gui _objects = new Object ( ) ;
this . gui _objects = new Object ( ) ;
this . commands = new Object ( ) ;
this . commands = new Object ( ) ;
this . selection = new Array ( ) ;
this . selection = new Array ( ) ;
this . last _selected = 0 ;
// create public reference to myself
// create public reference to myself
rcube _webmail _client = this ;
rcube _webmail _client = this ;
@ -288,26 +288,17 @@ function rcube_webmail()
this . use _arrow _key = function ( keyCode , mod _key , msg _list _frame ) {
this . use _arrow _key = function ( keyCode , mod _key , msg _list _frame ) {
var scroll _to = 0 ;
var scroll _to = 0 ;
var last _selected _row = this . list _rows [ this . last _selected ] ;
if ( keyCode == 40 ) { // down arrow key pressed
if ( keyCode == 40 ) { // down arrow key pressed
var new _row = last _selected _row . obj . nextSibling ;
new _row = this . get _next _row ( ) ;
while ( new _row && new _row . nodeType != 1 ) {
new _row = new _row . nextSibling ;
}
if ( ! new _row ) return false ;
if ( ! new _row ) return false ;
scroll _to = ( Number ( new _row . offsetTop ) + Number ( new _row . offsetHeight ) ) - Number ( msg _list _frame . offsetHeight ) ;
scroll _to = ( Number ( new _row . offsetTop ) + Number ( new _row . offsetHeight ) ) - Number ( msg _list _frame . offsetHeight ) ;
} else if ( keyCode == 38 ) { // up arrow key pressed
} else if ( keyCode == 38 ) { // up arrow key pressed
var new _row = last _selected _row . obj . previousSibling ;
new _row = this . get _prev _row ( ) ;
while ( new _row && new _row . nodeType != 1 ) {
new _row = new _row . previousSibling ;
}
if ( ! new _row ) return false ;
if ( ! new _row ) return false ;
scroll _to = new _row . offsetTop ;
scroll _to = new _row . offsetTop ;
} else { return true ; }
} else { return true ; }
if ( mod _key != CONTROL _KEY )
this . select _row ( new _row . uid , mod _key , true ) ;
this . select _row ( new _row . uid , mod _key ) ;
if ( ( ( Number ( new _row . offsetTop ) ) < ( Number ( msg _list _frame . scrollTop ) ) ) ||
if ( ( ( Number ( new _row . offsetTop ) ) < ( Number ( msg _list _frame . scrollTop ) ) ) ||
( ( Number ( new _row . offsetTop ) + Number ( new _row . offsetHeight ) ) > ( Number ( msg _list _frame . scrollTop ) + Number ( msg _list _frame . offsetHeight ) ) ) ) {
( ( Number ( new _row . offsetTop ) + Number ( new _row . offsetHeight ) ) > ( Number ( msg _list _frame . scrollTop ) + Number ( msg _list _frame . offsetHeight ) ) ) ) {
@ -1111,7 +1102,7 @@ function rcube_webmail()
if ( ! this . in _selection _before )
if ( ! this . in _selection _before )
{
{
var mod _key = this . get _modifier ( e ) ;
var mod _key = this . get _modifier ( e ) ;
this . select _row ( id , mod _key );
this . select _row ( id , mod _key ,false );
}
}
if ( this . selection . length )
if ( this . selection . length )
@ -1139,7 +1130,7 @@ function rcube_webmail()
// unselects currently selected row
// unselects currently selected row
if ( ! this . drag _active && this . in _selection _before == id )
if ( ! this . drag _active && this . in _selection _before == id )
this . select _row ( id , mod _key );
this . select _row ( id , mod _key ,false );
this . drag _start = false ;
this . drag _start = false ;
this . in _selection _before = false ;
this . in _selection _before = false ;
@ -1213,6 +1204,25 @@ function rcube_webmail()
/********* (message) list functionality *********/
/********* (message) list functionality *********/
/*********************************************************/
/*********************************************************/
// get next and previous rows that are not hidden
this . get _next _row = function ( ) {
var last _selected _row = this . list _rows [ this . last _selected ] ;
var new _row = last _selected _row . obj . nextSibling ;
while ( new _row && ( new _row . nodeType != 1 || new _row . style . display == 'none' ) ) {
new _row = new _row . nextSibling ;
}
return new _row ;
}
this . get _prev _row = function ( ) {
var last _selected _row = this . list _rows [ this . last _selected ] ;
var new _row = last _selected _row . obj . previousSibling ;
while ( new _row && ( new _row . nodeType != 1 || new _row . style . display == 'none' ) ) {
new _row = new _row . previousSibling ;
}
return new _row ;
}
// highlight/unhighlight a row
// highlight/unhighlight a row
this . highlight _row = function ( id , multiple )
this . highlight _row = function ( id , multiple )
{
{
@ -1231,7 +1241,7 @@ function rcube_webmail()
if ( ! this . in _selection ( id ) ) // select row
if ( ! this . in _selection ( id ) ) // select row
{
{
this . selection [ this . selection . length ] = id ;
this . selection [ this . selection . length ] = id ;
this . set _classname ( this . list _rows [ id ] . obj , 'selected' , true ) ;
this . set _classname ( this . list _rows [ id ] . obj , 'selected' , true ) ;
}
}
else // unselect row
else // unselect row
{
{
@ -1259,7 +1269,7 @@ function rcube_webmail()
// selects or unselects the proper row depending on the modifier key pressed
// selects or unselects the proper row depending on the modifier key pressed
this . select _row = function ( id , mod _key ) {
this . select _row = function ( id , mod _key ,with _arrow ) {
if ( ! mod _key ) {
if ( ! mod _key ) {
this . shift _start = id ;
this . shift _start = id ;
this . highlight _row ( id , false ) ;
this . highlight _row ( id , false ) ;
@ -1270,7 +1280,8 @@ function rcube_webmail()
break ; }
break ; }
case CONTROL _KEY : {
case CONTROL _KEY : {
this . shift _start = id ;
this . shift _start = id ;
this . highlight _row ( id , true ) ;
if ( ! with _arrow )
this . highlight _row ( id , true ) ;
break ;
break ;
}
}
case CONTROL _SHIFT _KEY : {
case CONTROL _SHIFT _KEY : {
@ -1283,7 +1294,9 @@ function rcube_webmail()
}
}
}
}
}
}
this . last _selected = id ;
if ( this . last _selected > 0 ) this . set _classname ( this . list _rows [ this . last _selected ] . obj , 'focused' , false ) ;
this . set _classname ( this . list _rows [ id ] . obj , 'focused' , true ) ;
this . last _selected = id ;
} ;
} ;
this . shift _select = function ( id , control ) {
this . shift _select = function ( id , control ) {
@ -1525,6 +1538,8 @@ function rcube_webmail()
// 'remove' message row from list (just hide it)
// 'remove' message row from list (just hide it)
if ( this . message _rows [ id ] . obj )
if ( this . message _rows [ id ] . obj )
this . message _rows [ id ] . obj . style . display = 'none' ;
this . message _rows [ id ] . obj . style . display = 'none' ;
new _row = this . get _next _row ( ) ;
this . select _row ( new _row . uid , false , false ) ;
}
}
}
}