@ -176,10 +176,10 @@ function rcube_webmail()
}
// enable general commands
this . enable _command ( ' logout', 'mail' , 'addressbook' , 'settings' , 'save-pref' , 'compose' , 'undo' , 'about' , 'switch-task' , true ) ;
this . enable _command ( ' close', ' logout', 'mail' , 'addressbook' , 'settings' , 'save-pref' , 'compose' , 'undo' , 'about' , 'switch-task' , true ) ;
if ( this . env . permaurl )
this . enable _command ( 'permaurl' , true ) ;
this . enable _command ( 'permaurl' , 'extwin' , true ) ;
switch ( this . task ) {
@ -249,7 +249,7 @@ function rcube_webmail()
}
}
else if ( this . env . action == 'compose' ) {
this . env . compose _commands = [ 'send-attachment' , 'remove-attachment' , 'send' , 'cancel' , 'toggle-editor' , 'list-adresses' ];
this . env . compose _commands = [ 'send-attachment' , 'remove-attachment' , 'send' , 'cancel' , 'toggle-editor' , 'list-adresses' , 'extwin' ];
if ( this . env . drafts _mailbox )
this . env . compose _commands . push ( 'savedraft' )
@ -570,6 +570,19 @@ function rcube_webmail()
parent . location . href = this . env . permaurl ;
break ;
case 'extwin' :
if ( this . env . action == 'compose' ) {
var prevstate = this . env . compose _extwin ;
$ ( "input[name='_action']" , this . gui _objects . messageform ) . val ( 'compose' ) ;
this . gui _objects . messageform . action = this . url ( 'mail/compose' , { _id : this . env . compose _id , _extwin : 1 } ) ;
this . gui _objects . messageform . target = this . open _window ( 'about:blank' , 1150 , 900 ) ;
this . gui _objects . messageform . submit ( ) ;
}
else {
this . open _window ( this . env . permaurl , 1000 , 1200 ) ;
}
break ;
case 'menu-open' :
case 'menu-save' :
this . triggerEvent ( command , { props : props } ) ;
@ -582,10 +595,18 @@ function rcube_webmail()
}
break ;
case 'close' :
if ( this . env . extwin )
window . close ( ) ;
break ;
case 'list' :
if ( props && props != '' )
this . reset _qsearch ( ) ;
if ( this . task == 'mail' ) {
if ( this . env . action == 'compose' && this . env . extwin ) {
window . close ( ) ;
}
else if ( this . task == 'mail' ) {
this . list _mailbox ( props ) ;
this . set _button _titles ( ) ;
}
@ -641,7 +662,7 @@ function rcube_webmail()
uid = this . get _single _uid ( ) ;
if ( uid && ( ! this . env . uid || uid != this . env . uid ) ) {
if ( this . env . mailbox == this . env . drafts _mailbox )
this . goto_url ( 'compose' , { _draft _uid : uid , _mbox : this . env . mailbox } , true ) ;
this . open_compose _step ( { _draft _uid : uid , _mbox : this . env . mailbox } ) ;
else
this . show _message ( uid ) ;
}
@ -670,7 +691,7 @@ function rcube_webmail()
else if ( this . task == 'mail' && ( cid = this . get _single _uid ( ) ) ) {
url = { _mbox : this . env . mailbox } ;
url [ this . env . mailbox == this . env . drafts _mailbox && props != 'new' ? '_draft_uid' : '_uid' ] = cid ;
this . goto_url ( 'compose' , url , true ) ;
this . open_compose _step ( url ) ;
}
break ;
@ -863,25 +884,23 @@ function rcube_webmail()
break ;
case 'compose' :
url = this . url ( 'mail/compose' ) ;
url = { } ;
if ( this . task == 'mail' ) {
url += '&_mbox=' + urlencode ( this . env . mailbox ) ;
url . _mbox = this . env . mailbox ;
if ( props )
url += '&_to=' + urlencode ( props ) ;
url . _to = props ;
// also send search request so we can go back to search result after message is sent
if ( this . env . search _request )
url += '&_search=' + this . env . search _request ;
url . _search = this . env . search _request ;
}
// modify url if we're in addressbook
else if ( this . task == 'addressbook' ) {
// switch to mail compose step directly
if ( props && props . indexOf ( '@' ) > 0 ) {
url = this . get _task _url ( 'mail' , url ) ;
this . redirect ( url + '&_to=' + urlencode ( props ) ) ;
break ;
url . _to = props ;
}
else {
// use contact_id passed as command parameter
var n , len , a _cids = [ ] ;
if ( props )
@ -894,16 +913,17 @@ function rcube_webmail()
}
if ( a _cids . length )
this . http _post ( 'mailto' , { _cid : a _cids . join ( ',' ) , _source : this . env . source } , true ) ;
this . http _post ( 'mailto' , { _cid : a _cids . join ( ',' ) , _source : this . env . source , } , true ) ;
else if ( this . env . group )
this . http _post ( 'mailto' , { _gid : this . env . group , _source : this . env . source } , true ) ;
this . http _post ( 'mailto' , { _gid : this . env . group , _source : this . env . source } , true ) ;
break ;
}
}
else if ( props )
url += '&_to=' + urlencode ( props ) ;
url . _to = props ;
this . redirect ( url ) ;
this . open_compose _step ( url ) ;
break ;
case 'spellcheck' :
@ -978,7 +998,7 @@ function rcube_webmail()
else if ( command == 'reply-list' )
url . _all = 'list' ;
this . goto_url ( 'compose' , url , true ) ;
this . open_compose _step ( url ) ;
}
break ;
@ -988,7 +1008,7 @@ function rcube_webmail()
url = { _forward _uid : uid , _mbox : this . env . mailbox } ;
if ( command == 'forward-attachment' || ( ! props && this . env . forward _attachment ) )
url . _attachment = 1 ;
this . goto_url ( 'compose' , url , true ) ;
this . open_compose _step ( url ) ;
}
break ;
@ -1562,7 +1582,7 @@ function rcube_webmail()
var uid = list . get _single _selection ( ) ;
if ( uid && this . env . mailbox == this . env . drafts _mailbox )
this . goto_url ( 'compose' , { _draft _uid : uid , _mbox : this . env . mailbox } , true ) ;
this . open_compose _step ( { _draft _uid : uid , _mbox : this . env . mailbox } ) ;
else if ( uid )
this . show _message ( uid , false , false ) ;
} ;
@ -1644,6 +1664,21 @@ function rcube_webmail()
return allow ? ( copy ? 2 : 1 ) : 0 ;
} ;
this . open _window = function ( url , width , height )
{
var w = Math . min ( width , screen . width - 10 ) ,
h = Math . min ( height , screen . height - 100 ) ,
l = ( screen . width - w ) / 2 + ( screen . left || 0 ) ,
t = Math . max ( 0 , ( screen . height - h ) / 2 + ( screen . top || 0 ) - 20 ) ;
var wname = 'rcmextwin' + new Date ( ) . getTime ( ) ,
extwin = window . open ( url + '&_extwin=1' , wname , 'width=' + w + ',height=' + h + ',top=' + t + ',left=' + l ) ;
extwin . moveTo ( l , t ) ;
window . setTimeout ( function ( ) { extwin . focus ( ) ; } , 10 ) ;
return wname ;
} ;
/*********************************************************/
/********* (message) list functionality *********/
@ -1907,7 +1942,7 @@ function rcube_webmail()
this . list _mailbox ( '' , '' , sort _col + '_' + sort _order , post _data ) ;
} ;
// when user do ble-clicks on a row
// when user do u ble-clicks on a row
this . show _message = function ( id , safe , preview )
{
if ( ! id )
@ -1932,9 +1967,16 @@ function rcube_webmail()
// add browser capabilities, so we can properly handle attachments
url += '&_caps=' + urlencode ( this . browser _capabilities ( ) ) ;
if ( preview && String ( target . location . href ) . indexOf ( url ) >= 0 )
if ( this . env . extwin )
url += '&_extwin=1' ;
if ( preview && String ( target . location . href ) . indexOf ( url ) >= 0 ) {
this . show _contentframe ( true ) ;
}
else {
if ( ! preview && this . env . message _extwin && ! this . env . extwin )
this . open _window ( this . env . comm _path + url , 1000 , 1200 ) ;
else
this . location _href ( this . env . comm _path + url , target , true ) ;
// mark as read and change mbox unread counter
@ -2963,6 +3005,17 @@ function rcube_webmail()
/********* message compose methods *********/
/*********************************************************/
this . open _compose _step = function ( p )
{
var url = this . url ( 'mail/compose' , p ) ;
// open new compose window
if ( this . env . compose _extwin )
this . open _window ( url , 1150 , 900 ) ;
else
this . redirect ( url ) ;
} ;
// init message compose form: set focus and eventhandlers
this . init _messageform = function ( )
{
@ -2977,6 +3030,11 @@ function rcube_webmail()
ac _fields = [ 'cc' , 'bcc' , 'replyto' , 'followupto' ] ,
ac _props ;
// copy contents from opener (after opening in a new window)
if ( window . opener && opener . rcmail && opener . rcmail . env . action == 'compose' ) {
//opener.history.back();
}
// configure parallel autocompletion
if ( this . env . autocomplete _threads > 0 ) {
ac _props = {
@ -3631,8 +3689,16 @@ function rcube_webmail()
this . sent _successfully = function ( type , msg )
{
this . display _message ( msg , type ) ;
if ( this . env . extwin && window . opener && opener . rcmail ) {
this . lock _form ( this . gui _objects . messageform ) ;
opener . rcmail . display _message ( msg , type ) ;
setTimeout ( function ( ) { window . close ( ) } , 1000 ) ;
}
else {
// before redirect we need to wait some time for Chrome (#1486177)
setTimeout ( function ( ) { ref . list _mailbox ( ) ; } , 500 ) ;
}
} ;