@ -44,11 +44,13 @@ function rcube_mail_ui()
this . show _header _row = show _header _row ;
this . hide _header _row = hide _header _row ;
this . update _quota = update _quota ;
this . get _pref = get _pref ;
this . save _pref = save _pref ;
// set minimal mode on small screens (don't wait for document.ready)
if ( window . $ && document . body ) {
var minmode = rcmail. get _cookie ( 'minimalmode' ) ;
var minmode = get_pref ( 'minimalmode' ) ;
if ( parseInt ( minmode ) || ( minmode === null && $ ( window ) . height ( ) < 850 ) ) {
$ ( document . body ) . addClass ( 'minimal' ) ;
}
@ -67,6 +69,24 @@ function rcube_mail_ui()
env [ key ] = val ;
}
/ * *
* Get preference stored in browser
* /
function get _pref ( key )
{
return rcmail . get _cookie ( key ) ;
}
/ * *
* Saves preference value to browser storage
* /
function save _pref ( key , val )
{
var exp = new Date ( ) ;
exp . setYear ( exp . getFullYear ( ) + 1 ) ;
rcmail . set _cookie ( key , val , exp ) ;
}
/ * *
* Initialize UI
* Called on document . ready
@ -82,7 +102,7 @@ function rcube_mail_ui()
$ ( '#taskbar .minmodetoggle' ) . click ( function ( e ) {
var ismin = $ ( document . body ) . toggleClass ( 'minimal' ) . hasClass ( 'minimal' ) ;
rcmail. set _cookie ( 'minimalmode' , ismin ? 1 : 0 ) ;
save_pref ( 'minimalmode' , ismin ? 1 : 0 ) ;
$ ( window ) . resize ( ) ;
} ) ;
@ -133,9 +153,14 @@ function rcube_mail_ui()
$ ( '#composeoptionstoggle' ) . toggleClass ( 'remove' ) ;
$ ( '#composeoptions' ) . toggle ( ) ;
layout _composeview ( ) ;
save _pref ( 'composeoptions' , $ ( '#composeoptions' ) . is ( ':visible' ) ? '1' : '0' ) ;
return false ;
} ) . css ( 'cursor' , 'pointer' ) ;
if ( get _pref ( 'composeoptions' ) !== '0' ) {
$ ( '#composeoptionstoggle' ) . click ( ) ;
}
// adjust hight when textarea starts to scroll
$ ( "textarea[name='_to'], textarea[name='_cc'], textarea[name='_bcc']" ) . change ( function ( e ) { adjust _compose _editfields ( this ) ; } ) . change ( ) ;
rcmail . addEventListener ( 'autocomplete_insert' , function ( p ) { adjust _compose _editfields ( p . field ) ; } ) ;
@ -605,7 +630,7 @@ function rcube_mail_ui()
var button = $ ( e . target ) ,
frame = $ ( '#mailpreviewframe' ) ,
visible = ! frame . is ( ':visible' ) ,
splitter = mailviewsplit . pos || parseInt ( rcmail. get _cookie ( 'mailviewsplitter' ) || 320 ) ,
splitter = mailviewsplit . pos || parseInt ( get_pref ( 'mailviewsplitter' ) || 320 ) ,
topstyles , bottomstyles , uid ;
frame . toggle ( ) ;
@ -1178,7 +1203,7 @@ function rcube_splitter(p)
$ ( window ) . resize ( onResize ) ;
// read saved position from cookie
var cookie = rcmail . get _cookie ( this . id ) ;
var cookie = this . get _cookie ( ) ;
if ( cookie && ! isNaN ( cookie ) ) {
this . pos = parseFloat ( cookie ) ;
this . resize ( ) ;
@ -1332,14 +1357,21 @@ function rcube_splitter(p)
}
} ;
/ * *
* Get saved splitter position from cookie
* /
this . get _cookie = function ( )
{
return window . UI ? UI . get _pref ( this . id ) : null ;
} ;
/ * *
* Saves splitter position in cookie
* /
this . set _cookie = function ( )
{
var exp = new Date ( ) ;
exp . setYear ( exp . getFullYear ( ) + 1 ) ;
rcmail . set _cookie ( this . id , this . pos , exp ) ;
if ( window . UI )
UI . save _pref ( this . id , this . pos ) ;
} ;
} // end class rcube_splitter