@ -732,25 +732,13 @@ expand_row: function(e, id)
{
{
var row = this . rows [ id ] ,
var row = this . rows [ id ] ,
evtarget = rcube _event . get _target ( e ) ,
evtarget = rcube _event . get _target ( e ) ,
mod _key = rcube _event . get _modifier ( e ) ;
mod _key = rcube _event . get _modifier ( e ) ,
action = ( row . expanded ? 'collapse' : 'expand' ) + ( mod _key == CONTROL _KEY || this . multiexpand ? '_all' : '' ) ;
// Don't treat double click on the expando as double click on the message.
// Don't treat double click on the expando as double click on the message.
row . clicked = 0 ;
row . clicked = 0 ;
if ( row . expanded ) {
this [ action ] ( row ) ;
evtarget . className = 'collapsed' ;
if ( mod _key == CONTROL _KEY || this . multiexpand )
this . collapse _all ( row ) ;
else
this . collapse ( row ) ;
}
else {
evtarget . className = 'expanded' ;
if ( mod _key == CONTROL _KEY || this . multiexpand )
this . expand _all ( row ) ;
else
this . expand ( row ) ;
}
} ,
} ,
collapse : function ( row )
collapse : function ( row )
@ -759,6 +747,7 @@ collapse: function(row)
new _row = row ? row . obj . nextSibling : null ;
new _row = row ? row . obj . nextSibling : null ;
row . expanded = false ;
row . expanded = false ;
this . update _expando ( row . id ) ;
this . triggerEvent ( 'expandcollapse' , { uid : row . uid , expanded : row . expanded , obj : row . obj } ) ;
this . triggerEvent ( 'expandcollapse' , { uid : row . uid , expanded : row . expanded , obj : row . obj } ) ;
while ( new _row ) {
while ( new _row ) {
@ -814,6 +803,7 @@ expand: function(row)
last _expanded _parent _depth = p . depth ;
last _expanded _parent _depth = p . depth ;
$ ( new _row ) . css ( 'display' , '' ) ;
$ ( new _row ) . css ( 'display' , '' ) ;
r . expanded = true ;
r . expanded = true ;
this . update _expando ( r . id , true ) ;
this . triggerEvent ( 'expandcollapse' , { uid : r . uid , expanded : r . expanded , obj : new _row } ) ;
this . triggerEvent ( 'expandcollapse' , { uid : r . uid , expanded : r . expanded , obj : new _row } ) ;
}
}
}
}
@ -828,6 +818,7 @@ expand: function(row)
this . resize ( ) ;
this . resize ( ) ;
this . triggerEvent ( 'listupdate' ) ;
this . triggerEvent ( 'listupdate' ) ;
return false ;
return false ;
} ,
} ,
@ -843,7 +834,7 @@ collapse_all: function(row)
this . update _expando ( row . id ) ;
this . update _expando ( row . id ) ;
this . triggerEvent ( 'expandcollapse' , { uid : row . uid , expanded : row . expanded , obj : row . obj } ) ;
this . triggerEvent ( 'expandcollapse' , { uid : row . uid , expanded : row . expanded , obj : row . obj } ) ;
// don't collapse sub-root tree in multiexpand mode
// don't collapse sub-root tree in multiexpand mode
if ( depth && this . multiexpand )
if ( depth && this . multiexpand )
return false ;
return false ;
}
}
@ -860,10 +851,12 @@ collapse_all: function(row)
if ( row || r . depth )
if ( row || r . depth )
$ ( new _row ) . css ( 'display' , 'none' ) ;
$ ( new _row ) . css ( 'display' , 'none' ) ;
if ( r . has_children && r . expanded) {
if ( r . expanded) {
r . expanded = false ;
r . expanded = false ;
this . update _expando ( r . id , false ) ;
if ( r . has _children ) {
this . triggerEvent ( 'expandcollapse' , { uid : r . uid , expanded : r . expanded , obj : new _row } ) ;
this . update _expando ( r . id ) ;
this . triggerEvent ( 'expandcollapse' , { uid : r . uid , expanded : r . expanded , obj : new _row } ) ;
}
}
}
}
}
}
}
@ -872,6 +865,7 @@ collapse_all: function(row)
this . resize ( ) ;
this . resize ( ) ;
this . triggerEvent ( 'listupdate' ) ;
this . triggerEvent ( 'listupdate' ) ;
return false ;
return false ;
} ,
} ,
@ -899,10 +893,12 @@ expand_all: function(row)
break ;
break ;
$ ( new _row ) . css ( 'display' , '' ) ;
$ ( new _row ) . css ( 'display' , '' ) ;
if ( r . has _children && ! r . expanded ) {
if ( ! r . expanded ) {
r . expanded = true ;
r . expanded = true ;
this . update _expando ( r . id , true ) ;
if ( r . has _children ) {
this . triggerEvent ( 'expandcollapse' , { uid : r . uid , expanded : r . expanded , obj : new _row } ) ;
this . update _expando ( r . id , true ) ;
this . triggerEvent ( 'expandcollapse' , { uid : r . uid , expanded : r . expanded , obj : new _row } ) ;
}
}
}
}
}
}
}
@ -911,6 +907,7 @@ expand_all: function(row)
this . resize ( ) ;
this . resize ( ) ;
this . triggerEvent ( 'listupdate' ) ;
this . triggerEvent ( 'listupdate' ) ;
return false ;
return false ;
} ,
} ,
@ -1429,29 +1426,20 @@ key_press: function(e)
mod _key = rcube _event . get _modifier ( e ) ;
mod _key = rcube _event . get _modifier ( e ) ;
switch ( keyCode ) {
switch ( keyCode ) {
case 40 :
case 37 : // Left arrow
case 38 :
case 39 : // Right arrow
case 63233 : // "down", in safari keypress
case 40 : // Up arrow
case 63232 : // "up", in safari keypress
case 38 : // Down arrow
case 63233 : // "down" in Safari keypress
case 63232 : // "up" in Safari keypress
// Stop propagation so that the browser doesn't scroll
// Stop propagation so that the browser doesn't scroll
rcube _event . cancel ( e ) ;
rcube _event . cancel ( e ) ;
return this . use _arrow _key ( keyCode , mod _key ) ;
return this . use _arrow _key ( keyCode , mod _key ) ;
case 32 :
case 32 : // Space
rcube _event . cancel ( e ) ;
rcube _event . cancel ( e ) ;
return this . select _row ( this . last _selected , mod _key , true ) ;
return this . select _row ( this . last _selected , mod _key , true ) ;
case 37 : // Left arrow
case 39 : // Right arrow
// Stop propagation
rcube _event . cancel ( e ) ;
var ret = this . use _arrow _key ( keyCode , mod _key ) ;
this . key _pressed = keyCode ;
this . modkey = mod _key ;
this . triggerEvent ( 'keypress' ) ;
this . modkey = 0 ;
return ret ;
case 36 : // Home
case 36 : // Home
this . select _first ( mod _key ) ;
this . select _first ( mod _key ) ;
return rcube _event . cancel ( e ) ;
return rcube _event . cancel ( e ) ;
@ -1506,43 +1494,39 @@ key_press: function(e)
* /
* /
use _arrow _key : function ( keyCode , mod _key )
use _arrow _key : function ( keyCode , mod _key )
{
{
var new _row ,
var new _row , selected _row = this . rows [ this . last _selected ] ;
selected _row = this . rows [ this . last _selected ] ;
// Safari uses the nonstandard keycodes 63232/63233 for up/down, if we're
if ( ! selected _row ) {
// select the first row if none selected yet
this . select _first ( CONTROL _KEY ) ;
}
// Safari uses the non-standard keycodes 63232/63233 for up/down, if we're
// using the keypress event (but not the keydown or keyup event).
// using the keypress event (but not the keydown or keyup event).
if ( keyCode == 40 || keyCode == 63233 ) // down arrow key pressed
else if ( keyCode == 40 || keyCode == 63233 ) // Down arrow
new _row = this . get _next _row ( ) ;
new _row = this . get _next _row ( ) ;
else if ( keyCode == 38 || keyCode == 63232 ) // up arrow key pressed
else if ( keyCode == 38 || keyCode == 63232 ) // Up arrow
new _row = this . get _prev _row ( ) ;
new _row = this . get _prev _row ( ) ;
else {
else if ( keyCode == 39 && selected _row . has _children ) { // Right arrow
if ( ! selected _row || ! selected _row . has _children )
if ( ! selected _row . expanded )
return ;
this . expand _all ( selected _row ) ;
// expand
if ( keyCode == 39 ) {
if ( selected _row . expanded )
return ;
if ( mod _key == CONTROL _KEY || this . multiexpand )
this . expand _all ( selected _row ) ;
else
this . expand ( selected _row ) ;
}
// collapse
else {
else {
if ( ! selected _row . expanded )
// jump to the first child
return ;
new _row = this . get _next _row ( ) ;
mod _key = null ;
if ( mod _key == CONTROL _KEY || this . multiexpand )
this . collapse _all ( selected _row ) ;
else
this . collapse ( selected _row ) ;
}
}
}
else if ( keyCode == 37 ) { // Left arrow
if ( selected _row . expanded && selected _row . has _children && ( ! selected _row . parent _uid || ! this . multiexpand ) )
this . collapse _all ( selected _row ) ;
else if ( selected _row . parent _uid ) {
// jump to the top-most or closest parent
if ( mod _key == CONTROL _KEY )
new _row = this . rows [ this . find _root ( selected _row . uid ) ] ;
else
new _row = this . rows [ selected _row . parent _uid ] ;
this . update _expando ( selected _row . id , selected _row . expanded ) ;
mod _key = null ;
}
return false ;
}
}
if ( new _row ) {
if ( new _row ) {
@ -1553,10 +1537,6 @@ use_arrow_key: function(keyCode, mod_key)
this . select _row ( new _row . uid , mod _key , false ) ;
this . select _row ( new _row . uid , mod _key , false ) ;
this . scrollto ( new _row . uid ) ;
this . scrollto ( new _row . uid ) ;
}
}
else if ( ! new _row && ! selected _row ) {
// select the first row if none selected yet
this . select _first ( CONTROL _KEY ) ;
}
return false ;
return false ;
} ,
} ,