Thomas Bruederli
2013-10-30 1723f9225182712d87d28eec998540069dba1cef
commit | author | age
c7dcb3 1 /**
T 2  * Roundcube functions for default skin interface
74d4c7 3  *
f5aecf 4  * Copyright (c) 2013, The Roundcube Dev Team
74d4c7 5  *
T 6  * The contents are subject to the Creative Commons Attribution-ShareAlike
7  * License. It is allowed to copy, distribute, transmit and to adapt the work
8  * by keeping credits to the original autors in the README file.
9  * See http://creativecommons.org/licenses/by-sa/3.0/ for details.
c7dcb3 10  */
T 11
12
13 function rcube_mail_ui()
14 {
68e13c 15   var env = {};
c7dcb3 16   var popups = {};
T 17   var popupconfig = {
18     forwardmenu:        { editable:1 },
19     searchmenu:         { editable:1, callback:searchmenu },
bc2c43 20     attachmentmenu:     { },
c7dcb3 21     listoptions:        { editable:1 },
a45f9b 22     dragmenu:           { sticky:1 },
c7dcb3 23     groupmenu:          { above:1 },
T 24     mailboxmenu:        { above:1 },
4be86f 25     spellmenu:          { callback: spellmenu },
c7dcb3 26     // toggle: #1486823, #1486930
T 27     'attachment-form':  { editable:1, above:1, toggle:!bw.ie&&!bw.linux },
28     'upload-form':      { editable:1, toggle:!bw.ie&&!bw.linux }
29   };
30
31   var me = this;
918bb9 32   var mailviewsplit;
74d4c7 33   var compose_headers = {};
c7dcb3 34
T 35   // export public methods
68e13c 36   this.set = setenv;
c7dcb3 37   this.init = init;
bab043 38   this.init_tabs = init_tabs;
68e13c 39   this.show_about = show_about;
c7dcb3 40   this.show_popup = show_popup;
443b92 41   this.add_popup = add_popup;
c7dcb3 42   this.set_searchmod = set_searchmod;
74d4c7 43   this.show_uploadform = show_uploadform;
T 44   this.show_header_row = show_header_row;
45   this.hide_header_row = hide_header_row;
de1584 46   this.update_quota = update_quota;
68e13c 47
T 48
542415 49   // set minimal mode on small screens (don't wait for document.ready)
TB 50   if (window.$ && document.body) {
51     var minmode = rcmail.get_cookie('minimalmode');
52     if (parseInt(minmode) || (minmode === null && $(window).height() < 850)) {
53       $(document.body).addClass('minimal');
54     }
4910b0 55
TB 56     if (bw.tablet) {
57       $('#viewport').attr('content', "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0");
58     }
542415 59   }
TB 60
61
68e13c 62   /**
T 63    *
64    */
65   function setenv(key, val)
66   {
67     env[key] = val;
68   }
c7dcb3 69
T 70   /**
5ff7ba 71    * Initialize UI
T 72    * Called on document.ready
c7dcb3 73    */
T 74   function init()
75   {
0e530b 76     rcmail.addEventListener('message', message_displayed);
5ff7ba 77
542415 78     /*** prepare minmode functions ***/
TB 79     $('#taskbar a').each(function(i,elem){
80       $(elem).append('<span class="tooltip">' + $('.button-inner', this).html() + '</span>')
81     });
82
83     $('#taskbar .minmodetoggle').click(function(e){
84       var ismin = $(document.body).toggleClass('minimal').hasClass('minimal');
85       rcmail.set_cookie('minimalmode', ismin?1:0);
86       $(window).resize();
87     });
88
5ff7ba 89     /***  mail task  ***/
c7dcb3 90     if (rcmail.env.task == 'mail') {
bc2c43 91       rcmail.addEventListener('menu-open', menu_open);
AM 92       rcmail.addEventListener('menu-save', menu_save);
836549 93       rcmail.addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') });
74d4c7 94
T 95       var dragmenu = $('#dragmessagemenu');
96       if (dragmenu.length) {
a45f9b 97         rcmail.gui_object('dragmenu', 'dragmessagemenu');
AM 98         popups.dragmenu = dragmenu;
74d4c7 99       }
918bb9 100
c7dcb3 101       if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') {
235504 102         rcmail.addEventListener('enable-command', enable_command);
c23aad 103         rcmail.addEventListener('aftershow-headers', function() { layout_messageview(); });
TB 104         rcmail.addEventListener('afterhide-headers', function() { layout_messageview(); });
ef3f1d 105         $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(); return false });
bc2c43 106
AM 107         // add menu link for each attachment
108         $('#attachment-list > li').each(function() {
109           $(this).append($('<a class="drop">').click(function() { attachmentmenu(this); }));
110         });
74d4c7 111       }
T 112       else if (rcmail.env.action == 'compose') {
071c78 113         rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 200); });
68e13c 114         rcmail.addEventListener('aftersend-attachment', show_uploadform);
7961f8 115         rcmail.addEventListener('add-recipient', function(p){ show_header_row(p.field, true); });
74d4c7 116         layout_composeview();
T 117
b4e41f 118         // Show input elements with non-empty value
15482b 119         var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto'];
AM 120         for (f=0; f < fields.length; f++) {
121           v = fields[f]; field = $('#_'+v);
122           if (field.length) {
123             field.on('change', {v: v}, function(e) { if (this.value) show_header_row(e.data.v, true); });
124             if (field.val() != '')
125               show_header_row(v, true);
126           }
b4e41f 127         }
T 128
edfe79 129         $('#composeoptionstoggle').click(function(){
TB 130           $('#composeoptionstoggle').toggleClass('remove');
74d4c7 131           $('#composeoptions').toggle();
T 132           layout_composeview();
133           return false;
bab043 134         }).css('cursor', 'pointer');
74d4c7 135
eb5147 136         // toggle compose options if opened in new window and they were visible before
32da69 137         var opener_rc = rcmail.opener();
AM 138         if (opener_rc && opener_rc.env.action == 'compose' && $('#composeoptionstoggle', opener.document).hasClass('remove'))
eb5147 139           $('#composeoptionstoggle').click();
TB 140
74d4c7 141         new rcube_splitter({ id:'composesplitterv', p1:'#composeview-left', p2:'#composeview-right',
071c78 142           orientation:'v', relative:true, start:248, min:170, size:12, render:layout_composeview }).init();
918bb9 143       }
T 144       else if (rcmail.env.action == 'list' || !rcmail.env.action) {
5ff7ba 145         var previewframe = $('#mailpreviewframe').is(':visible');
T 146         $('#mailpreviewtoggle').addClass(previewframe ? 'enabled' : 'closed').click(function(e){ toggle_preview_pane(e); return false });
147         $('#maillistmode').addClass(rcmail.env.threading ? '' : 'selected').click(function(e){ switch_view_mode('list'); return false });
148         $('#mailthreadmode').addClass(rcmail.env.threading ? 'selected' : '').click(function(e){ switch_view_mode('thread'); return false });
847d31 149
5ff7ba 150         mailviewsplit = new rcube_splitter({ id:'mailviewsplitter', p1:'#mailview-top', p2:'#mailview-bottom',
c8dc07 151           orientation:'h', relative:true, start:310, min:150, size:12, offset:4 });
5ff7ba 152         if (previewframe)
T 153           mailviewsplit.init();
154
efaf2e 155         new rcube_scroller('#folderlist-content', '#folderlist-header', '#folderlist-footer');
A 156
5ff7ba 157         rcmail.addEventListener('setquota', update_quota);
235504 158         rcmail.addEventListener('enable-command', enable_command);
4f53ab 159         rcmail.addEventListener('afterimport-messages', show_uploadform);
918bb9 160       }
049428 161       else if (rcmail.env.action == 'get') {
AM 162         new rcube_splitter({ id:'mailpartsplitterv', p1:'#messagepartheader', p2:'#messagepartcontainer',
163           orientation:'v', relative:true, start:226, min:150, size:12}).init();
164       }
847d31 165
918bb9 166       if ($('#mailview-left').length) {
T 167         new rcube_splitter({ id:'mailviewsplitterv', p1:'#mailview-left', p2:'#mailview-right',
f45a97 168           orientation:'v', relative:true, start:226, min:150, size:12, callback:render_mailboxlist, render:resize_leftcol }).init();
c7dcb3 169       }
28e18c 170     }
5ff7ba 171     /***  settings task  ***/
28e18c 172     else if (rcmail.env.task == 'settings') {
4f1b7a 173       rcmail.addEventListener('init', function(){
T 174         var tab = '#settingstabpreferences';
175         if (rcmail.env.action)
176           tab = '#settingstab' + (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action.replace(/\./g, ''));
28e18c 177
4f1b7a 178         $(tab).addClass('selected')
T 179           .children().first().removeAttr('onclick').click(function() { return false; });
180       });
918bb9 181
T 182       if (rcmail.env.action == 'folders') {
183         new rcube_splitter({ id:'folderviewsplitter', p1:'#folderslist', p2:'#folder-details',
f45a97 184           orientation:'v', relative:true, start:266, min:180, size:12 }).init();
fe8374 185
efaf2e 186         new rcube_scroller('#folderslist-content', '#folderslist-header', '#folderslist-footer');
A 187
fe8374 188         rcmail.addEventListener('setquota', update_quota);
918bb9 189       }
7c2a93 190       else if (rcmail.env.action == 'identities') {
918bb9 191         new rcube_splitter({ id:'identviewsplitter', p1:'#identitieslist', p2:'#identity-details',
f45a97 192           orientation:'v', relative:true, start:266, min:180, size:12 }).init();
918bb9 193       }
eac1b7 194       else if (rcmail.env.action == 'preferences' || !rcmail.env.action) {
389fa1 195         new rcube_splitter({ id:'prefviewsplitter', p1:'#sectionslist', p2:'#preferences-box',
AM 196           orientation:'v', relative:true, start:266, min:180, size:12 }).init();
197       }
7be8a9 198       else if (rcmail.env.action == 'edit-prefs') {
TB 199         $('<a href="#toggle">&#9660;</a>')
200             .addClass('advanced-toggle')
201             .appendTo('#preferences-details fieldset.advanced legend');
202
203           $('#preferences-details fieldset.advanced legend').click(function(e){
204             var collapsed = $(this).hasClass('collapsed'),
205               toggle = $('.advanced-toggle', this).html(collapsed ? '&#9650;' : '&#9660;');
206             $(this)
207               .toggleClass('collapsed')
208               .closest('fieldset').children('.propform').toggle()
209           }).addClass('collapsed')
210       }
c7dcb3 211     }
5ff7ba 212     /***  addressbook task  ***/
bab043 213     else if (rcmail.env.task == 'addressbook') {
68e13c 214       rcmail.addEventListener('afterupload-photo', show_uploadform);
de98a8 215       rcmail.addEventListener('beforepushgroup', push_contactgroup);
TB 216       rcmail.addEventListener('beforepopgroup', pop_contactgroup);
68e13c 217
T 218       if (rcmail.env.action == '') {
219         new rcube_splitter({ id:'addressviewsplitterd', p1:'#addressview-left', p2:'#addressview-right',
220           orientation:'v', relative:true, start:226, min:150, size:12, render:resize_leftcol }).init();
221         new rcube_splitter({ id:'addressviewsplitter', p1:'#addresslist', p2:'#contacts-box',
1ba07f 222           orientation:'v', relative:true, start:286, min:270, size:12 }).init();
efaf2e 223
A 224         new rcube_scroller('#directorylist-content', '#directorylist-header', '#directorylist-footer');
68e13c 225       }
a45f9b 226
AM 227       var dragmenu = $('#dragcontactmenu');
228       if (dragmenu.length) {
229         rcmail.gui_object('dragmenu', 'dragcontactmenu');
230         popups.dragmenu = dragmenu;
231       }
822a1e 232     }
bab043 233
T 234     // turn a group of fieldsets into tabs
235     $('.tabbed').each(function(idx, elem){ init_tabs(elem); })
c7dcb3 236
7a32e9 237     // decorate select elements
85f11f 238     $('select.decorated').each(function(){
A 239       if (bw.opera) {
240         $(this).removeClass('decorated');
241         return;
242       }
7a32e9 243
3d122f 244       var select = $(this),
12e69c 245         parent = select.parent(),
c8dc07 246         height = Math.max(select.height(), 26) - 2,
3d122f 247         width = select.width() - 22,
AM 248         title = $('option', this).first().text();
249
85f11f 250       if ($('option:selected', this).val() != '')
A 251         title = $('option:selected', this).text();
7a32e9 252
77fad1 253       var overlay = $('<a class="menuselector"><span class="handle">' + title + '</span></a>')
85f11f 254         .css('position', 'absolute')
A 255         .offset(select.position())
3d122f 256         .insertAfter(select);
85f11f 257
77fad1 258       overlay.children().width(width).height(height).css('line-height', (height - 1) + 'px');
3d122f 259
77fad1 260       if (parent.css('position') != 'absolute')
TB 261         parent.css('position', 'relative');
3d122f 262
8ba01c 263       // re-set original select width to fix click action and options width in some browsers
12e69c 264       select.width(overlay.width())
AM 265         .change(function() {
266           var val = $('option:selected', this).text();
267           $(this).next().children().text(val);
268         });
85f11f 269     });
7a32e9 270
3a0f82 271     // set min-width to show all toolbar buttons
AM 272     var screen = $('body > div.minwidth');
273     if (screen.length) {
274       screen.css('min-width', $('.toolbar').width() + $('#quicksearchbar').width() + $('#searchfilter').width() + 30);
275     }
276
7a32e9 277     $(document.body)
T 278       .bind('mouseup', body_mouseup)
279       .bind('keyup', function(e){
280         if (e.keyCode == 27) {
281           for (var id in popups) {
282             if (popups[id].is(':visible'))
283               show_popup(id, false);
284           }
c7dcb3 285         }
7a32e9 286       });
7961f8 287
14a3f2 288     $('iframe').load(function(e){
T 289       // this = iframe
c95845 290       try {
AM 291         var doc = this.contentDocument ? this.contentDocument : this.contentWindow ? this.contentWindow.document : null;
292         $(doc).mouseup(body_mouseup);
293       }
294       catch (e) {
295         // catch possible "Permission denied" error in IE
296       };
14a3f2 297     })
T 298     .contents().mouseup(body_mouseup);
299
8ce602 300     // don't use $(window).resize() due to some unwanted side-effects
TB 301     window.onresize = resize;
98d096 302     resize();
28e18c 303   }
T 304
305   /**
14a3f2 306    * Handler for mouse-up events on the document body.
T 307    * This will close all open popup menus
308    */
309   function body_mouseup(e)
310   {
311     var config, obj, target = e.target;
e10fab 312     if (target.className == 'inner')
TB 313         target = e.target.parentNode;
14a3f2 314     for (var id in popups) {
T 315       obj = popups[id];
316       config = popupconfig[id];
317       if (obj.is(':visible')
318         && target.id != id+'link'
319         && !config.toggle
320         && (!config.editable || !target_overlaps(target, obj.get(0)))
321         && (!config.sticky || !rcube_mouse_is_over(e, obj.get(0)))
322       ) {
323         var myid = id+'';
324         window.setTimeout(function(){ show_popupmenu(myid, false) }, 10);
325       }
326     }
327   }
328
329   /**
28e18c 330    * Update UI on window resize
T 331    */
d227ed 332   function resize(e)
28e18c 333   {
d227ed 334     // resize in intervals to prevent lags and double onresize calls in Chrome (#1489005)
AM 335     var interval = e ? 10 : 0;
98d096 336
d227ed 337     if (rcmail.resize_timeout)
AM 338       window.clearTimeout(rcmail.resize_timeout);
bbbacd 339
d227ed 340     rcmail.resize_timeout = window.setTimeout(function() {
AM 341       if (rcmail.env.task == 'mail') {
342         if (rcmail.env.action == 'show' || rcmail.env.action == 'preview')
343           layout_messageview();
344         else if (rcmail.env.action == 'compose')
345           layout_composeview();
98d096 346       }
d227ed 347
AM 348       // make iframe footer buttons float if scrolling is active
349       $('body.iframe .footerleft').each(function(){
350         var footer = $(this),
351           body = $(document.body),
352           floating = footer.hasClass('floating'),
353           overflow = body.outerHeight(true) > $(window).height();
354
355         if (overflow != floating) {
356           var action = overflow ? 'addClass' : 'removeClass';
357           footer[action]('floating');
358           body[action]('floatingbuttons');
359         }
360       });
361     }, interval);
c7dcb3 362   }
T 363
364   /**
0e530b 365    * Triggered when a new user message is displayed
T 366    */
367   function message_displayed(p)
368   {
369     // show a popup dialog on errors
30eb9e 370     if (p.type == 'error' && rcmail.env.task != 'login') {
464a0f 371       if (me.message_timer) {
TB 372         window.clearTimeout(me.message_timer);
373       }
0e530b 374       if (!me.messagedialog) {
464a0f 375         me.messagedialog = $('<div>').addClass('popupdialog').hide();
0e530b 376       }
T 377
464a0f 378       var msg = p.message,
TB 379         pos = $(p.object).offset();
8c16ea 380       pos.top -= (rcmail.env.task == 'login' ? 20 : 160);
464a0f 381
TB 382       if (me.messagedialog.is(':visible'))
383         msg = me.messagedialog.html() + '<p>' + p.message + '</p>';
384
385       me.messagedialog.html(msg)
0e530b 386         .dialog({
T 387           resizable: false,
388           closeOnEscape: true,
389           dialogClass: 'popupmessage ' + p.type,
71e9ef 390           title: env.errortitle,
0e530b 391           close: function() {
T 392             me.messagedialog.dialog('destroy').hide();
393           },
8c16ea 394           position: ['center', pos.top],
0e530b 395           hide: { effect:'drop', direction:'down' },
T 396           width: 420,
397           minHeight: 90
398         }).show();
e493c8 399
464a0f 400       me.message_timer = window.setTimeout(function(){ me.messagedialog.dialog('close'); }, Math.max(2000, p.timeout / 2));
0e530b 401     }
T 402   }
403
404
405   /**
c7dcb3 406    * Adjust UI objects of the mail view screen
T 407    */
28e18c 408   function layout_messageview()
c7dcb3 409   {
dd5258 410     $('#messagecontent').css('top', ($('#messageheader').outerHeight() + 1) + 'px');
c7dcb3 411     $('#message-objects div a').addClass('button');
76248c 412
c7dcb3 413     if (!$('#attachment-list li').length) {
b540ed 414       $('div.rightcol').hide();
T 415       $('div.leftcol').css('margin-right', '0');
c7dcb3 416     }
T 417   }
918bb9 418
T 419
420   function render_mailboxlist(splitter)
421   {
0e530b 422     // TODO: implement smart shortening of long folder names
918bb9 423   }
T 424
425
426   function resize_leftcol(splitter)
427   {
c8dc07 428     // STUB
74d4c7 429   }
T 430
431
432   function layout_composeview()
433   {
434     var body = $('#composebody'),
071c78 435       form = $('#compose-content'),
74d4c7 436       bottom = $('#composeview-bottom'),
edfe79 437       w, h, bh, ovflw, btns = 0,
TB 438       minheight = 300,
74d4c7 439
edfe79 440     bh = (form.height() - bottom.position().top);
TB 441     ovflw = minheight - bh;
442     btns = ovflw > -100 ? 0 : 40;
443     bottom.css('height', Math.max(minheight, bh) + 'px');
444     form.css('overflow', ovflw > 0 ? 'auto' : 'hidden');
74d4c7 445
4be86f 446     w = body.parent().width() - 5;
A 447     h = body.parent().height() - 16;
74d4c7 448     body.width(w).height(h);
T 449
c792b5 450     $('#composebody_tbl').width((w+8)+'px').height('').css('margin-top', '1px');
R 451     $('#composebody_ifr').width((w+8)+'px').height((h-40)+'px');
452     $('#googie_edit_layer').height(h+'px');
edfe79 453 //    $('#composebodycontainer')[(btns ? 'addClass' : 'removeClass')]('buttons');
TB 454 //    $('#composeformbuttons')[(btns ? 'show' : 'hide')]();
fe8374 455
071c78 456     var abooks = $('#directorylist');
T 457     $('#compose-contacts .scroller').css('top', abooks.position().top + abooks.outerHeight());
918bb9 458   }
T 459
c7dcb3 460
847d31 461   function update_quota(p)
T 462   {
3d122f 463     var step = 24, step_count = 20,
AM 464       y = p.total ? Math.ceil(p.percent / 100 * step_count) * step : 0;
465
466     // never show full-circle if quota is close to 100% but below.
467     if (p.total && y == step * step_count && p.percent < 100)
468       y -= step;
469
847d31 470     $('#quotadisplay').css('background-position', '0 -'+y+'px');
T 471   }
472
473
235504 474   function enable_command(p)
AM 475   {
b972b4 476     if (p.command == 'reply-list' && rcmail.env.reply_all_mode == 1) {
235504 477       var label = rcmail.gettext(p.status ? 'replylist' : 'replyall');
AM 478       if (rcmail.env.action == 'preview')
479         $('a.button.replyall').attr('title', label);
480       else
481         $('a.button.reply-all').text(label).attr('title', label);
482     }
483   }
484
485
c7dcb3 486   /**
443b92 487    * Register a popup menu
AM 488    */
489   function add_popup(popup, config)
490   {
491     var obj = popups[popup] = $('#'+popup);
492     obj.appendTo(document.body);  // move it to top for proper absolute positioning
493
494     if (obj.length)
495       popupconfig[popup] = $.extend(popupconfig[popup] || {}, config || {});
496   }
497
498   /**
c7dcb3 499    * Trigger for popup menus
T 500    */
501   function show_popup(popup, show, config)
502   {
503     // auto-register menu object
504     if (config || !popupconfig[popup])
443b92 505       add_popup(popup, config);
c7dcb3 506
T 507     var visible = show_popupmenu(popup, show),
508       config = popupconfig[popup];
509     if (typeof config.callback == 'function')
510       config.callback(visible);
511   }
512
513   /**
514    * Show/hide a specific popup menu
515    */
516   function show_popupmenu(popup, show)
517   {
518     var obj = popups[popup],
519       config = popupconfig[popup],
bc2c43 520       ref = $(config.link ? config.link : '#'+popup+'link'),
c7dcb3 521       above = config.above;
T 522
523     if (!obj) {
524       obj = popups[popup] = $('#'+popup);
525       obj.appendTo(document.body);  // move them to top for proper absolute positioning
526     }
527
528     if (!obj || !obj.length)
529       return false;
530
531     if (typeof show == 'undefined')
532       show = obj.is(':visible') ? false : true;
533     else if (config.toggle && show && obj.is(':visible'))
534       show = false;
535
bc2c43 536     if (show && ref.length) {
c7dcb3 537       var parent = ref.parent(),
T 538         win = $(window),
539         pos;
540
541       if (parent.hasClass('dropbutton'))
542         ref = parent;
543
544       pos = ref.offset();
545       ref.offsetHeight = ref.outerHeight();
546       if (!above && pos.top + ref.offsetHeight + obj.height() > win.height())
547         above = true;
548       if (pos.left + obj.width() > win.width())
549         pos.left = win.width() - obj.width() - 12;
550
551       obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) });
552     }
553
554     obj[show?'show':'hide']();
555
556     // hide drop-down elements on buggy browsers
557     if (bw.ie6 && config.overlap) {
558       $('select').css('visibility', show?'hidden':'inherit');
559       $('select', obj).css('visibility', 'inherit');
560     }
4be86f 561
c7dcb3 562     return show;
T 563   }
564
565   /**
566    *
567    */
568   function target_overlaps(target, elem)
569   {
570     while (target.parentNode) {
571       if (target.parentNode == elem)
572         return true;
573       target = target.parentNode;
574     }
575     return false;
576   }
577
578
918bb9 579   /**
T 580    * Show/hide the preview pane
581    */
c7dcb3 582   function toggle_preview_pane(e)
T 583   {
b540ed 584     var button = $(e.target),
T 585       frame = $('#mailpreviewframe'),
586       visible = !frame.is(':visible'),
ae7027 587       splitter = mailviewsplit.pos || parseInt(rcmail.get_cookie('mailviewsplitter') || 320),
b540ed 588       topstyles, bottomstyles, uid;
T 589
590     frame.toggle();
c7dcb3 591     button.removeClass().addClass(visible ? 'enabled' : 'closed');
T 592
b540ed 593     if (visible) {
77fad1 594       $('#mailview-top').removeClass('fullheight').css({ bottom:'auto' });
918bb9 595       $('#mailview-bottom').css({ height:'auto' });
T 596
b540ed 597       rcmail.env.contentframe = 'messagecontframe';
T 598       if (uid = rcmail.message_list.get_single_selection())
599         rcmail.show_message(uid, false, true);
918bb9 600
T 601       // let the splitter set the correct size and position
602       if (mailviewsplit.handle) {
603         mailviewsplit.handle.show();
604         mailviewsplit.resize();
605       }
606       else
607         mailviewsplit.init();
b540ed 608     }
T 609     else {
610       rcmail.env.contentframe = null;
611       rcmail.show_contentframe(false);
612
77fad1 613       $('#mailview-top').addClass('fullheight').css({ height:'auto', bottom:'28px' });
918bb9 614       $('#mailview-bottom').css({ top:'auto', height:'26px' });
T 615
616       if (mailviewsplit.handle)
617         mailviewsplit.handle.hide();
618     }
b540ed 619
73ad4f 620     if (rcmail.message_list) {
TB 621       if (visible && uid)
622           rcmail.message_list.scrollto(uid);
623       rcmail.message_list.resize();
624     }
b540ed 625
T 626     rcmail.command('save-pref', { name:'preview_pane', value:(visible?1:0) });
c7dcb3 627   }
T 628
629
918bb9 630   /**
f4aaf8 631    * Switch between short and full headers display in message preview
T 632    */
ef3f1d 633   function toggle_preview_headers()
f4aaf8 634   {
T 635     $('#preview-shortheaders').toggle();
9bd97c 636     var full = $('#preview-allheaders').toggle(),
c23aad 637       button = $('a#previewheaderstoggle');
9bd97c 638
f4aaf8 639     // add toggle button to full headers table
c23aad 640     if (full.is(':visible'))
TB 641       button.attr('href', '#hide').removeClass('add').addClass('remove')
642     else
643       button.attr('href', '#details').removeClass('remove').addClass('add')
f4aaf8 644   }
T 645
646
647   /**
918bb9 648    *
T 649    */
a4be51 650   function switch_view_mode(mode)
T 651   {
652     if (rcmail.env.threading != (mode == 'thread'))
653       rcmail.set_list_options(null, undefined, undefined, mode == 'thread' ? 1 : 0);
654
655     $('#maillistmode, #mailthreadmode').removeClass('selected');
656     $('#mail'+mode+'mode').addClass('selected');
657   }
658
659
c7dcb3 660   /**** popup callbacks ****/
T 661
bc2c43 662   function menu_open(p)
AM 663   {
664     if (p && p.props && p.props.menu == 'attachmentmenu')
665       show_popupmenu('attachmentmenu');
666     else
667       show_listoptions();
668   }
669
670   function menu_save(prop)
671   {
672     save_listoptions();
673   }
674
c7dcb3 675   function searchmenu(show)
T 676   {
677     if (show && rcmail.env.search_mods) {
678       var n, all,
679         obj = popups['searchmenu'],
680         list = $('input:checkbox[name="s_mods[]"]', obj),
681         mbox = rcmail.env.mailbox,
682         mods = rcmail.env.search_mods;
683
684       if (rcmail.env.task == 'mail') {
685         mods = mods[mbox] ? mods[mbox] : mods['*'];
686         all = 'text';
687       }
688       else {
689         all = '*';
690       }
691
692       if (mods[all])
693         list.map(function() {
694           this.checked = true;
695           this.disabled = this.value != all;
696         });
697       else {
698         list.prop('disabled', false).prop('checked', false);
699         for (n in mods)
700           $('#s_mod_' + n).prop('checked', true);
701       }
702     }
703   }
704
bc2c43 705   function attachmentmenu(elem)
AM 706   {
707     var id = elem.parentNode.id.replace(/^attach/, '');
708
709     $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) {
710       return rcmail.command('open-attachment', id, this);
711     });
712
713     $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() {
714       rcmail.command('download-attachment', id, this);
715     });
716
717     popupconfig.attachmentmenu.link = elem;
718     rcmail.command('menu-open', {menu: 'attachmentmenu', id: id});
719   }
c7dcb3 720
4be86f 721   function spellmenu(show)
A 722   {
723     var link, li,
724       lang = rcmail.spellcheck_lang(),
725       menu = popups.spellmenu,
726       ul = $('ul', menu);
727
728     if (!ul.length) {
729       ul = $('<ul class="toolbarmenu selectable">');
730
731       for (i in rcmail.env.spell_langs) {
732         li = $('<li>');
ee5569 733         link = $('<a href="#"></a>').text(rcmail.env.spell_langs[i])
4be86f 734           .addClass('active').data('lang', i)
A 735           .click(function() {
736             rcmail.spellcheck_lang_set($(this).data('lang'));
737           });
738
739         link.appendTo(li);
740         li.appendTo(ul);
741       }
742
743       ul.appendTo(menu);
744     }
745
746     // select current language
747     $('li', ul).each(function() {
748       var el = $('a', this);
749       if (el.data('lang') == lang)
750         el.addClass('selected');
751       else if (el.hasClass('selected'))
752         el.removeClass('selected');
753     });
754   }
755
756
918bb9 757   /**
T 758    *
759    */
74d4c7 760   function show_listoptions()
T 761   {
762     var $dialog = $('#listoptions');
763
764     // close the dialog
765     if ($dialog.is(':visible')) {
766       $dialog.dialog('close');
767       return;
768     }
769
770     // set form values
771     $('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').prop('checked', true);
772     $('input[name="sort_ord"][value="DESC"]').prop('checked', rcmail.env.sort_order == 'DESC');
773     $('input[name="sort_ord"][value="ASC"]').prop('checked', rcmail.env.sort_order != 'DESC');
774
e0efd8 775     // set checkboxes
AM 776     $('input[name="list_col[]"]').each(function() {
777       $(this).prop('checked', $.inArray(this.value, rcmail.env.coltypes) != -1);
778     });
74d4c7 779
T 780     $dialog.dialog({
781       modal: true,
782       resizable: false,
783       closeOnEscape: true,
784       title: null,
785       close: function() {
786         $dialog.dialog('destroy').hide();
787       },
36adaf 788       minWidth: 500,
AM 789       width: $dialog.width()+25
74d4c7 790     }).show();
T 791   }
792
793
794   /**
795    *
796    */
c7dcb3 797   function save_listoptions()
T 798   {
74d4c7 799     $('#listoptions').dialog('close');
c7dcb3 800
T 801     var sort = $('input[name="sort_col"]:checked').val(),
802       ord = $('input[name="sort_ord"]:checked').val(),
803       cols = $('input[name="list_col[]"]:checked')
804         .map(function(){ return this.value; }).get();
805
ec5323 806     rcmail.set_list_options(cols, sort, ord, rcmail.env.threading);
c7dcb3 807   }
T 808
809
918bb9 810   /**
T 811    *
812    */
c7dcb3 813   function set_searchmod(elem)
T 814   {
815     var all, m, task = rcmail.env.task,
816       mods = rcmail.env.search_mods,
817       mbox = rcmail.env.mailbox;
818
819     if (!mods)
820       mods = {};
821
822     if (task == 'mail') {
823       if (!mods[mbox])
824         mods[mbox] = rcube_clone_object(mods['*']);
825       m = mods[mbox];
826       all = 'text';
827     }
828     else { //addressbook
829       m = mods;
830       all = '*';
831     }
832
833     if (!elem.checked)
834       delete(m[elem.value]);
835     else
836       m[elem.value] = 1;
837
838     // mark all fields
839     if (elem.value != all)
840       return;
841
842     $('input:checkbox[name="s_mods[]"]').map(function() {
843       if (this == elem)
844         return;
845
846       this.checked = true;
847       if (elem.checked) {
848         this.disabled = true;
849         delete m[this.value];
850       }
851       else {
852         this.disabled = false;
853         m[this.value] = 1;
854       }
855     });
856   }
74d4c7 857
de98a8 858   function push_contactgroup(p)
TB 859   {
860     // lets the contacts list swipe to the left, nice!
861     var table = $('#contacts-table'),
862       scroller = table.parent().css('overflow', 'hidden');
863
864     table.clone()
865       .css({ position:'absolute', top:'0', left:'0', width:table.width()+'px', 'z-index':10 })
866       .appendTo(scroller)
867       .animate({ left: -(table.width()+5) + 'px' }, 300, 'swing', function(){
868         $(this).remove();
869         scroller.css('overflow', 'auto')
870       });
871   }
872
873   function pop_contactgroup(p)
874   {
875     // lets the contacts list swipe to the left, nice!
876     var table = $('#contacts-table'),
877       scroller = table.parent().css('overflow', 'hidden'),
878       clone = table.clone().appendTo(scroller);
879
880       table.css({ position:'absolute', top:'0', left:-(table.width()+5) + 'px', width:table.width()+'px', height:table.height()+'px', 'z-index':10 })
881         .animate({ left:'0' }, 300, 'linear', function(){
882         clone.remove();
883         $(this).css({ position:'relative', left:'0', width:'100%', height:'auto', 'z-index':1 });
884         scroller.css('overflow', 'auto')
885       });
886   }
74d4c7 887
T 888   function show_uploadform()
889   {
890     var $dialog = $('#upload-dialog');
891
892     // close the dialog
893     if ($dialog.is(':visible')) {
894       $dialog.dialog('close');
895       return;
896     }
de98a8 897
f5521a 898     // add icons to clone file input field
354bf1 899     if (rcmail.env.action == 'compose' && !$dialog.data('extended')) {
f5521a 900       $('<a>')
T 901         .addClass('iconlink add')
902         .attr('href', '#add')
903         .html('Add')
904         .appendTo($('input[type="file"]', $dialog).parent())
905         .click(add_uploadfile);
906       $dialog.data('extended', true);
907     }
74d4c7 908
T 909     $dialog.dialog({
910       modal: true,
911       resizable: false,
912       closeOnEscape: true,
913       title: $dialog.attr('title'),
914       close: function() {
915         try { $('#upload-dialog form').get(0).reset(); }
916         catch(e){ }  // ignore errors
917
918         $dialog.dialog('destroy').hide();
f5521a 919         $('div.addline', $dialog).remove();
74d4c7 920       },
T 921       width: 480
922     }).show();
923
924     if (!document.all)
f5521a 925       $('input[type=file]', $dialog).first().click();
74d4c7 926   }
T 927
f5521a 928   function add_uploadfile(e)
T 929   {
930     var div = $(this).parent();
931     var clone = div.clone().addClass('addline').insertAfter(div);
932     clone.children('.iconlink').click(add_uploadfile);
933     clone.children('input').val('');
934
935     if (!document.all)
936       $('input[type=file]', clone).click();
937   }
938
939
74d4c7 940   /**
T 941    *
942    */
7961f8 943   function show_header_row(which, updated)
74d4c7 944   {
7961f8 945     var row = $('#compose-' + which);
T 946     if (row.is(':visible'))
947       return;  // nothing to be done here
948
949     if (compose_headers[which] && !updated)
74d4c7 950       $('#_' + which).val(compose_headers[which]);
7961f8 951
T 952     row.show();
74d4c7 953     $('#' + which + '-link').hide();
68e13c 954     layout_composeview();
74d4c7 955     return false;
T 956   }
957
958   /**
959    *
960    */
961   function hide_header_row(which)
962   {
963     // copy and clear field value
964     var field = $('#_' + which);
965     compose_headers[which] = field.val();
966     field.val('');
967
968     $('#compose-' + which).hide();
969     $('#' + which + '-link').show();
68e13c 970     layout_composeview();
T 971     return false;
74d4c7 972   }
bab043 973
T 974
975   /**
976    * Fieldsets-to-tabs converter
977    */
978   function init_tabs(elem, current)
979   {
a4e71c 980     var content = $(elem),
T 981       id = content.get(0).id,
bab043 982       fs = content.children('fieldset');
T 983
984     if (!fs.length)
985       return;
986
987     if (!id) {
988       id = 'rcmtabcontainer';
a4e71c 989       content.attr('id', id);
bab043 990     }
T 991
992     // first hide not selected tabs
993     current = current || 0;
994     fs.each(function(idx) { if (idx != current) $(this).hide(); });
995
996     // create tabs container
997     var tabs = $('<div>').addClass('tabsbar').prependTo(content);
998
999     // convert fildsets into tabs
1000     fs.each(function(idx) {
1001       var tab, a, elm = $(this), legend = elm.children('legend');
1002
1003       // create a tab
1004       a   = $('<a>').text(legend.text()).attr('href', '#');
1005       tab = $('<span>').attr({'id': 'tab'+idx, 'class': 'tablink'})
1006         .click(function() { show_tab(id, idx); return false })
1007
1008       // remove legend
1009       legend.remove();
1010       // style fieldset
1011       elm.addClass('tab');
1012       // style selected tab
1013       if (idx == current)
1014         tab.addClass('selected');
1015
1016       // add the tab to container
1017       tab.append(a).appendTo(tabs);
1018     });
1019   }
1020
1021   function show_tab(id, index)
1022   {
1023     var fs = $('#'+id).children('fieldset');
1024
1025     fs.each(function(idx) {
1026       // Show/hide fieldset (tab content)
1027       $(this)[index==idx ? 'show' : 'hide']();
1028       // Select/unselect tab
1029       $('#tab'+idx).toggleClass('selected', idx==index);
1030     });
bbbacd 1031
AM 1032     resize();
bab043 1033   }
68e13c 1034
T 1035   /**
1036    * Show about page as jquery UI dialog
1037    */
1038   function show_about(elem)
1039   {
1040     var frame = $('<iframe>').attr('id', 'aboutframe')
1041       .attr('src', rcmail.url('settings/about'))
19b34b 1042       .attr('frameborder', '0')
68e13c 1043       .appendTo(document.body);
T 1044
1045     var h = Math.floor($(window).height() * 0.75);
1046     var buttons = {};
1047     var supportln = $('#supportlink');
1048     if (supportln.length && (env.supporturl = supportln.attr('href')))
1049       buttons[supportln.html()] = function(e){ env.supporturl.indexOf('mailto:') < 0 ? window.open(env.supporturl) : location.href = env.supporturl };
1050
1051     frame.dialog({
1052       modal: true,
1053       resizable: false,
1054       closeOnEscape: true,
1055       title: elem ? elem.title || elem.innerHTML : null,
1056       close: function() {
1057         frame.dialog('destroy').remove();
1058       },
1059       buttons: buttons,
1060       width: 640,
1061       height: h
1062     }).width(640);
1063   }
c7dcb3 1064 }
T 1065
918bb9 1066
efaf2e 1067 /**
A 1068  * Roundcube Scroller class
1069  */
1070 function rcube_scroller(list, top, bottom)
1071 {
1072   var ref = this;
1073
1074   this.list = $(list);
1075   this.top = $(top);
1076   this.bottom = $(bottom);
1077   this.step_size = 6;
1078   this.step_time = 20;
1079   this.delay = 500;
1080
1081   this.top
f5aecf 1082     .mouseenter(function() { if (rcmail.drag_active) ref.ts = window.setTimeout(function() { ref.scroll('down'); }, ref.delay); })
efaf2e 1083     .mouseout(function() { if (ref.ts) window.clearTimeout(ref.ts); });
A 1084
1085   this.bottom
f5aecf 1086     .mouseenter(function() { if (rcmail.drag_active) ref.ts = window.setTimeout(function() { ref.scroll('up'); }, ref.delay); })
efaf2e 1087     .mouseout(function() { if (ref.ts) window.clearTimeout(ref.ts); });
A 1088
1089   this.scroll = function(dir)
1090   {
1091     var ref = this, size = this.step_size;
1092
1093     if (!rcmail.drag_active)
1094       return;
1095
1096     if (dir == 'down')
1097       size *= -1;
1098
1099     this.list.get(0).scrollTop += size;
1100     this.ts = window.setTimeout(function() { ref.scroll(dir); }, this.step_time);
1101   };
1102 };
1103
918bb9 1104
T 1105 /**
a4e71c 1106  * Roundcube UI splitter class
918bb9 1107  *
T 1108  * @constructor
1109  */
1110 function rcube_splitter(p)
1111 {
1112   this.p = p;
1113   this.id = p.id;
1114   this.horizontal = (p.orientation == 'horizontal' || p.orientation == 'h');
1115   this.halfsize = (p.size !== undefined ? p.size : 10) / 2;
1116   this.pos = p.start || 0;
1117   this.min = p.min || 20;
1118   this.offset = p.offset || 0;
1119   this.relative = p.relative ? true : false;
1120   this.drag_active = false;
1121   this.render = p.render;
1122   this.callback = p.callback;
1123
1124   var me = this;
3a86e2 1125   rcube_splitter._instances[this.id] = me;
918bb9 1126
T 1127   this.init = function()
1128   {
1129     this.p1 = $(this.p.p1);
1130     this.p2 = $(this.p.p2);
1131
a4e71c 1132     // check if referenced elements exist, otherwise abort
T 1133     if (!this.p1.length || !this.p2.length)
1134       return;
1135
918bb9 1136     // create and position the handle for this splitter
T 1137     this.p1pos = this.relative ? this.p1.position() : this.p1.offset();
1138     this.p2pos = this.relative ? this.p2.position() : this.p2.offset();
1139     this.handle = $('<div>')
1140       .attr('id', this.id)
1141       .attr('unselectable', 'on')
1142       .addClass('splitter ' + (this.horizontal ? 'splitter-h' : 'splitter-v'))
1143       .appendTo(this.p1.parent())
1144       .bind('mousedown', onDragStart);
1145
1146     if (this.horizontal) {
1147       var top = this.p1pos.top + this.p1.outerHeight();
1148       this.handle.css({ left:'0px', top:top+'px' });
1149     }
1150     else {
1151       var left = this.p1pos.left + this.p1.outerWidth();
1152       this.handle.css({ left:left+'px', top:'0px' });
1153     }
1154
1155     // listen to window resize on IE
1156     if (bw.ie)
a4e71c 1157       $(window).resize(onResize);
918bb9 1158
T 1159     // read saved position from cookie
ae7027 1160     var cookie = rcmail.get_cookie(this.id);
918bb9 1161     if (cookie && !isNaN(cookie)) {
T 1162       this.pos = parseFloat(cookie);
1163       this.resize();
1164     }
1165     else if (this.pos) {
1166       this.resize();
1167       this.set_cookie();
1168     }
1169   };
1170
1171   /**
1172    * Set size and position of all DOM objects
1173    * according to the saved splitter position
1174    */
1175   this.resize = function()
1176   {
1177     if (this.horizontal) {
1178       this.p1.css('height', Math.floor(this.pos - this.p1pos.top - this.halfsize) + 'px');
1179       this.p2.css('top', Math.ceil(this.pos + this.halfsize + 2) + 'px');
1180       this.handle.css('top', Math.round(this.pos - this.halfsize + this.offset)+'px');
1181       if (bw.ie) {
1182         var new_height = parseInt(this.p2.parent().outerHeight(), 10) - parseInt(this.p2.css('top'), 10) - (bw.ie8 ? 2 : 0);
822a1e 1183         this.p2.css('height', (new_height > 0 ? new_height : 0) + 'px');
918bb9 1184       }
T 1185     }
1186     else {
1187       this.p1.css('width', Math.floor(this.pos - this.p1pos.left - this.halfsize) + 'px');
1188       this.p2.css('left', Math.ceil(this.pos + this.halfsize) + 'px');
1189       this.handle.css('left', Math.round(this.pos - this.halfsize + this.offset + 3)+'px');
1190       if (bw.ie) {
1191         var new_width = parseInt(this.p2.parent().outerWidth(), 10) - parseInt(this.p2.css('left'), 10) ;
1192         this.p2.css('width', (new_width > 0 ? new_width : 0) + 'px');
1193       }
1194     }
1195
1196     this.p2.resize();
1197     this.p1.resize();
1198
5fea6b 1199     // also resize iframe covers
T 1200     if (this.drag_active) {
1201       $('iframe').each(function(i, elem) {
1202         var pos = $(this).offset();
1203         $('#iframe-splitter-fix-'+i).css({ top: pos.top+'px', left: pos.left+'px', width:elem.offsetWidth+'px', height: elem.offsetHeight+'px' });
1204       });
1205     }
1206
918bb9 1207     if (typeof this.render == 'function')
T 1208       this.render(this);
1209   };
1210
1211   /**
1212    * Handler for mousedown events
1213    */
1214   function onDragStart(e)
1215   {
1216     // disable text selection while dragging the splitter
1217     if (bw.konq || bw.chrome || bw.safari)
1218       document.body.style.webkitUserSelect = 'none';
1219
1220     me.p1pos = me.relative ? me.p1.position() : me.p1.offset();
1221     me.p2pos = me.relative ? me.p2.position() : me.p2.offset();
1222     me.drag_active = true;
1223
1224     // start listening to mousemove events
1225     $(document).bind('mousemove.'+this.id, onDrag).bind('mouseup.'+this.id, onDragStop);
1226
1227     // enable dragging above iframes
5fea6b 1228     $('iframe').each(function(i, elem) {
T 1229       $('<div>')
1230         .attr('id', 'iframe-splitter-fix-'+i)
1231         .addClass('iframe-splitter-fix')
918bb9 1232         .css({ background: '#fff',
5fea6b 1233           width: elem.offsetWidth+'px', height: elem.offsetHeight+'px',
918bb9 1234           position: 'absolute', opacity: '0.001', zIndex: 1000
T 1235         })
1236         .css($(this).offset())
1237         .appendTo('body');
1238       });
1239   };
1240
1241   /**
1242    * Handler for mousemove events
1243    */
1244   function onDrag(e)
1245   {
1246     if (!me.drag_active)
1247       return false;
1248
1249     var pos = rcube_event.get_mouse_pos(e);
1250
1251     if (me.relative) {
1252       var parent = me.p1.parent().offset();
1253       pos.x -= parent.left;
1254       pos.y -= parent.top;
1255     }
1256
1257     if (me.horizontal) {
1258       if (((pos.y - me.halfsize) > me.p1pos.top) && ((pos.y + me.halfsize) < (me.p2pos.top + me.p2.outerHeight()))) {
1259         me.pos = Math.max(me.min, pos.y - me.offset);
1260         me.resize();
1261       }
1262     }
1263     else {
1264       if (((pos.x - me.halfsize) > me.p1pos.left) && ((pos.x + me.halfsize) < (me.p2pos.left + me.p2.outerWidth()))) {
1265         me.pos = Math.max(me.min, pos.x - me.offset);
1266         me.resize();
1267       }
1268     }
1269
1270     me.p1pos = me.relative ? me.p1.position() : me.p1.offset();
1271     me.p2pos = me.relative ? me.p2.position() : me.p2.offset();
1272     return false;
1273   };
1274
1275   /**
1276    * Handler for mouseup events
1277    */
1278   function onDragStop(e)
1279   {
1280     // resume the ability to highlight text
1281     if (bw.konq || bw.chrome || bw.safari)
1282       document.body.style.webkitUserSelect = 'auto';
1283
1284     // cancel the listening for drag events
1285     $(document).unbind('.'+me.id);
1286     me.drag_active = false;
1287
1288     // remove temp divs
5fea6b 1289     $('div.iframe-splitter-fix').remove();
918bb9 1290
T 1291     me.set_cookie();
1292
1293     if (typeof me.callback == 'function')
1294       me.callback(me);
1295
1296     return bw.safari ? true : rcube_event.cancel(e);
1297   };
1298
1299   /**
1300    * Handler for window resize events
1301    */
1302   function onResize(e)
1303   {
1304     if (me.horizontal) {
1305       var new_height = parseInt(me.p2.parent().outerHeight(), 10) - parseInt(me.p2[0].style.top, 10) - (bw.ie8 ? 2 : 0);
1306       me.p2.css('height', (new_height > 0 ? new_height : 0) +'px');
1307     }
1308     else {
1309       var new_width = parseInt(me.p2.parent().outerWidth(), 10) - parseInt(me.p2[0].style.left, 10);
1310       me.p2.css('width', (new_width > 0 ? new_width : 0) + 'px');
1311     }
1312   };
1313
1314   /**
1315    * Saves splitter position in cookie
1316    */
1317   this.set_cookie = function()
1318   {
1319     var exp = new Date();
1320     exp.setYear(exp.getFullYear() + 1);
ae7027 1321     rcmail.set_cookie(this.id, this.pos, exp);
918bb9 1322   };
T 1323
1324 } // end class rcube_splitter
1325
1326
3a86e2 1327 // static getter for splitter instances
T 1328 rcube_splitter._instances = {};
1329
1330 rcube_splitter.get_instance = function(id)
1331 {
1332   return rcube_splitter._instances[id];
1333 };