Mercurial > hg > rc2
comparison skins/classic/functions.js @ 8:bf99236cc5cd default tip
try to recover from upgrade fail
author | Charlie Root |
---|---|
date | Sat, 29 Dec 2018 07:07:34 -0500 |
parents | 4681f974d28b |
children |
comparison
equal
deleted
inserted
replaced
7:65fd7d441cf1 | 8:bf99236cc5cd |
---|---|
191 if (!show) { | 191 if (!show) { |
192 try { $('#attachment-form form')[0].reset(); } | 192 try { $('#attachment-form form')[0].reset(); } |
193 catch(e){} // ignore errors | 193 catch(e){} // ignore errors |
194 } | 194 } |
195 | 195 |
196 if (rcmail.mailvelope_editor) | |
197 return; | |
198 | |
196 this.show_popupmenu('uploadmenu', show); | 199 this.show_popupmenu('uploadmenu', show); |
197 | 200 |
198 if (!document.all && this.popups.uploadmenu.obj.is(':visible')) | 201 if (!document.all && this.popups.uploadmenu.obj.is(':visible')) |
199 $('#attachment-form input[type=file]').click(); | 202 $('#attachment-form input[type=file]').click(); |
200 }, | 203 }, |
311 | 314 |
312 // set checkboxes | 315 // set checkboxes |
313 $('input[name="list_col[]"]').each(function() { | 316 $('input[name="list_col[]"]').each(function() { |
314 $(this).prop('checked', $.inArray(this.value, rcmail.env.listcols) != -1); | 317 $(this).prop('checked', $.inArray(this.value, rcmail.env.listcols) != -1); |
315 }); | 318 }); |
319 | |
320 $.each(['widescreen', 'desktop', 'list'], function() { | |
321 $('input[name="layout"][value="' + this + '"]').prop('checked', rcmail.env.layout == this); | |
322 }); | |
323 $('#listoptions-columns', $dialog)[rcmail.env.layout == 'widescreen' ? 'hide' : 'show'](); | |
316 | 324 |
317 buttons[rcmail.gettext('save')] = function(e) { | 325 buttons[rcmail.gettext('save')] = function(e) { |
318 $dialog.dialog('close', e); | 326 $dialog.dialog('close', e); |
319 self.save_listmenu(); | 327 self.save_listmenu(); |
320 }; | 328 }; |
349 save_listmenu: function() | 357 save_listmenu: function() |
350 { | 358 { |
351 var sort = $('input[name="sort_col"]:checked').val(), | 359 var sort = $('input[name="sort_col"]:checked').val(), |
352 ord = $('input[name="sort_ord"]:checked').val(), | 360 ord = $('input[name="sort_ord"]:checked').val(), |
353 thread = $('input[name="view"]:checked').val(), | 361 thread = $('input[name="view"]:checked').val(), |
362 layout = $('input[name="layout"]:checked').val(), | |
354 cols = $('input[name="list_col[]"]:checked') | 363 cols = $('input[name="list_col[]"]:checked') |
355 .map(function(){ return this.value; }).get(); | 364 .map(function(){ return this.value; }).get(); |
356 | 365 |
357 rcmail.set_list_options(cols, sort, ord, thread == 'thread' ? 1 : 0); | 366 rcmail.set_list_options(cols, sort, ord, thread == 'thread' ? 1 : 0, layout); |
358 }, | 367 }, |
359 | 368 |
360 spellmenu: function(show) | 369 spellmenu: function(show) |
361 { | 370 { |
362 var link, li, | 371 var link, li, |
396 | 405 |
397 show_attachmentmenu: function(elem, event) | 406 show_attachmentmenu: function(elem, event) |
398 { | 407 { |
399 var id = elem.parentNode.id.replace(/^attach/, ''); | 408 var id = elem.parentNode.id.replace(/^attach/, ''); |
400 | 409 |
401 $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) { | 410 $.each(['open', 'download', 'rename'], function() { |
402 return rcmail.command('open-attachment', id, this); | 411 var action = this; |
403 }); | 412 $('#attachmenu' + action).off('click').attr('onclick', '').click(function(e) { |
404 | 413 return rcmail.command(action + '-attachment', id, this); |
405 $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() { | 414 }); |
406 rcmail.command('download-attachment', id, this); | |
407 }); | 415 }); |
408 | 416 |
409 this.popups.attachmentmenu.link = elem; | 417 this.popups.attachmentmenu.link = elem; |
410 rcmail.command('menu-open', {menu: 'attachmentmenu', id: id}, elem, event); | 418 rcmail.command('menu-open', {menu: 'attachmentmenu', id: id}, elem, event); |
411 }, | 419 }, |
452 this.show_popup(k, false); | 460 this.show_popup(k, false); |
453 } | 461 } |
454 } | 462 } |
455 }, | 463 }, |
456 | 464 |
457 switch_preview_pane: function(elem) | 465 // Mail view layout initialization and change handler |
458 { | 466 set_layout: function(p) |
459 var uid, prev_frm = $('#mailpreviewframe'); | 467 { |
460 | 468 var layout = p ? p.new_layout : rcmail.env.layout, |
461 if (elem.checked) { | 469 top = $('#mailcontframe'), |
462 rcmail.env.contentframe = 'messagecontframe'; | 470 bottom = $('#mailpreviewframe'); |
463 if (mailviewsplit.layer) { | 471 |
464 mailviewsplit.resize(); | 472 if (p) |
465 mailviewsplit.layer.elm.style.display = ''; | 473 $('#mailrightcontainer').removeClass().addClass(layout); |
474 | |
475 if (!this.mailviewsplitv) { | |
476 this.mailviewsplitv = new rcube_splitter({id:'mailviewsplitterv', p1: 'mailleftcontainer', p2: 'mailrightcontainer', | |
477 orientation: 'v', relative: true, start: 165, callback: rcube_render_mailboxlist }); | |
478 this.mailviewsplitv.init(); | |
479 } | |
480 | |
481 $('#mailviewsplitter')[layout == 'desktop' ? 'show' : 'hide'](); | |
482 $('#mailviewsplitter2')[layout == 'widescreen' ? 'show' : 'hide'](); | |
483 $('#mailpreviewframe')[layout != 'list' ? 'show' : 'hide'](); | |
484 rcmail.env.contentframe = layout == 'list' ? null : 'messagecontframe'; | |
485 | |
486 if (layout == 'widescreen') { | |
487 $('#countcontrols').detach().appendTo($('#messagelistheader')); | |
488 top.css({height: 'auto', width: 400}); | |
489 bottom.css({top: 0, left: 410, height: 'auto'}).show(); | |
490 if (!this.mailviewsplit2) { | |
491 this.mailviewsplit2 = new rcube_splitter({id:'mailviewsplitter2', p1: 'mailcontframe', p2: 'mailpreviewframe', | |
492 orientation: 'v', relative: true, start: 405}); | |
493 this.mailviewsplit2.init(); | |
466 } | 494 } |
467 else | 495 else |
468 mailviewsplit.init(); | 496 this.mailviewsplit2.resize(); |
469 | 497 } |
470 if (bw.opera) { | 498 else if (layout == 'desktop') { |
471 $('#messagelistcontainer').css({height: ''}); | 499 top.css({height: 200, width: '100%'}); |
472 } | 500 bottom.css({left: 0, top: 210, height: 'auto'}).show(); |
473 prev_frm.show(); | 501 if (!this.mailviewsplit) { |
474 | 502 this.mailviewsplit = new rcube_splitter({id:'mailviewsplitter', p1: 'mailcontframe', p2: 'mailpreviewframe', |
475 if (uid = rcmail.message_list.get_single_selection()) | 503 orientation: 'h', relative: true, start: 205}); |
476 rcmail.show_message(uid, false, true); | 504 this.mailviewsplit.init(); |
477 } | 505 } |
478 else { | 506 else |
479 prev_frm.hide(); | 507 this.mailviewsplit.resize(); |
480 if (bw.ie7) { | 508 } |
481 var fr = document.getElementById('mailcontframe'); | 509 else { // layout == 'list' |
482 fr.style.bottom = 0; | 510 top.css({height: 'auto', width: '100%'}); |
483 fr.style.height = parseInt(fr.parentNode.offsetHeight)+'px'; | 511 bottom.hide(); |
484 } | 512 } |
485 else { | 513 |
486 $('#mailcontframe').css({height: 'auto', bottom: 0}); | 514 if (p && p.old_layout == 'widescreen') { |
487 if (bw.opera) | 515 $('#countcontrols').detach().appendTo($('#messagelistfooter')); |
488 $('#messagelistcontainer').css({height: 'auto'}); | 516 } |
489 } | 517 }, |
490 if (mailviewsplit.layer) | 518 |
491 mailviewsplit.layer.elm.style.display = 'none'; | |
492 | |
493 rcmail.env.contentframe = null; | |
494 rcmail.show_contentframe(false); | |
495 } | |
496 | |
497 rcmail.command('save-pref', {name: 'preview_pane', value: (elem.checked?1:0)}); | |
498 }, | |
499 | 519 |
500 /* Message composing */ | 520 /* Message composing */ |
501 init_compose_form: function() | 521 init_compose_form: function() |
502 { | 522 { |
503 var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto'], | 523 var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto'], |
634 enable_command: function(p) | 654 enable_command: function(p) |
635 { | 655 { |
636 if (p.command == 'reply-list' && rcmail.env.reply_all_mode == 1) { | 656 if (p.command == 'reply-list' && rcmail.env.reply_all_mode == 1) { |
637 var label = rcmail.gettext(p.status ? 'replylist' : 'replyall'); | 657 var label = rcmail.gettext(p.status ? 'replylist' : 'replyall'); |
638 $('a.button.replyAll').attr('title', label); | 658 $('a.button.replyAll').attr('title', label); |
659 } | |
660 else if (p.command == 'compose-encrypted') { | |
661 // show the toolbar button for Mailvelope | |
662 $('#messagetoolbar > a.encrypt').show(); | |
639 } | 663 } |
640 }, | 664 }, |
641 | 665 |
642 folder_search_init: function(container) | 666 folder_search_init: function(container) |
643 { | 667 { |
818 this.list.get(0).scrollTop += size; | 842 this.list.get(0).scrollTop += size; |
819 this.ts = window.setTimeout(function() { ref.scroll(dir); }, this.step_time); | 843 this.ts = window.setTimeout(function() { ref.scroll(dir); }, this.step_time); |
820 }; | 844 }; |
821 }; | 845 }; |
822 | 846 |
823 | |
824 // Events handling in iframes (eg. preview pane) | |
825 function iframe_events() | |
826 { | |
827 // this==iframe | |
828 try { | |
829 var doc = this.contentDocument ? this.contentDocument : this.contentWindow ? this.contentWindow.document : null; | |
830 $(doc).mouseup(function(e) { rcmail_ui.body_mouseup(e); }); | |
831 } | |
832 catch (e) { | |
833 // catch possible "Permission denied" error in IE | |
834 }; | |
835 }; | |
836 | |
837 // Abbreviate mailbox names to fit width of the container | 847 // Abbreviate mailbox names to fit width of the container |
838 function rcube_render_mailboxlist() | 848 function rcube_render_mailboxlist() |
839 { | 849 { |
840 var list = $('#mailboxlist > li > a, #mailboxlist ul:visible > li > a'); | 850 var list = $('#mailboxlist > li > a, #mailboxlist ul:visible > li > a'); |
841 | 851 |
842 // it's too slow with really big number of folders, especially on IE | 852 // it's too slow with really big number of folders |
843 if (list.length > (bw.ie && bw.vendver < 9 ? 40 : 100)) | 853 if (list.length > 100) |
844 return; | 854 return; |
845 | 855 |
846 list.each(function() { | 856 list.each(function() { |
847 var elem = $(this), | 857 var elem = $(this), |
848 text = elem.data('text'); | 858 text = elem.data('text'); |
989 $(obj).html('').append(bar1).append(bar2).append(main); | 999 $(obj).html('').append(bar1).append(bar2).append(main); |
990 // update #quotaimg title | 1000 // update #quotaimg title |
991 $('#quotaimg').attr('title', data.title); | 1001 $('#quotaimg').attr('title', data.title); |
992 }; | 1002 }; |
993 | 1003 |
1004 function attachment_menu_append(item) | |
1005 { | |
1006 $(item).append( | |
1007 $('<a class="drop"></a>').on('click keypress', function(e) { | |
1008 if (e.type != 'keypress' || e.which == 13) { | |
1009 rcmail_ui.show_attachmentmenu(this, e); | |
1010 return false; | |
1011 } | |
1012 }) | |
1013 ); | |
1014 }; | |
1015 | |
994 // Optional parameters used by TinyMCE | 1016 // Optional parameters used by TinyMCE |
995 var rcmail_editor_settings = {}; | 1017 var rcmail_editor_settings = {}; |
996 | 1018 |
997 var rcmail_ui; | 1019 var rcmail_ui; |
998 | 1020 |
1006 rcmail.addEventListener('init', function() { | 1028 rcmail.addEventListener('init', function() { |
1007 if (rcmail.env.quota_content) | 1029 if (rcmail.env.quota_content) |
1008 update_quota(rcmail.env.quota_content); | 1030 update_quota(rcmail.env.quota_content); |
1009 rcmail.addEventListener('setquota', update_quota); | 1031 rcmail.addEventListener('setquota', update_quota); |
1010 | 1032 |
1011 $('iframe').load(iframe_events) | 1033 rcube_webmail.set_iframe_events({mouseup: function(e) { return rcmail_ui.body_mouseup(e); }}); |
1012 .contents().mouseup(function(e) { rcmail_ui.body_mouseup(e); }); | |
1013 | 1034 |
1014 if (rcmail.env.task == 'mail') { | 1035 if (rcmail.env.task == 'mail') { |
1015 rcmail.addEventListener('enable-command', 'enable_command', rcmail_ui) | 1036 rcmail.addEventListener('enable-command', 'enable_command', rcmail_ui) |
1016 .addEventListener('menu-open', 'menu_open', rcmail_ui) | 1037 .addEventListener('menu-open', 'menu_open', rcmail_ui) |
1017 .addEventListener('aftersend-attachment', 'uploadmenu', rcmail_ui) | 1038 .addEventListener('aftersend-attachment', 'uploadmenu', rcmail_ui) |
1025 .addEventListener('responseaftercheck-recent', rcube_render_mailboxlist) | 1046 .addEventListener('responseaftercheck-recent', rcube_render_mailboxlist) |
1026 .addEventListener('responseafterrefresh', rcube_render_mailboxlist) | 1047 .addEventListener('responseafterrefresh', rcube_render_mailboxlist) |
1027 .addEventListener('afterimport-messages', function(){ rcmail_ui.show_popup('uploadform', false); }); | 1048 .addEventListener('afterimport-messages', function(){ rcmail_ui.show_popup('uploadform', false); }); |
1028 } | 1049 } |
1029 | 1050 |
1051 rcmail.init_pagejumper('#pagejumper'); | |
1052 | |
1030 // fix message list header on window resize (#1490213) | 1053 // fix message list header on window resize (#1490213) |
1031 if (bw.ie && rcmail.message_list) | 1054 if (bw.ie && rcmail.message_list) |
1032 $(window).resize(function() { | 1055 $(window).resize(function() { |
1033 setTimeout(function() { rcmail.message_list.resize(); }, 10); | 1056 setTimeout(function() { rcmail.message_list.resize(); }, 10); |
1034 }); | 1057 }); |
1035 | 1058 |
1036 if (rcmail.env.action == 'compose') | 1059 if (rcmail.env.action == 'list' || !rcmail.env.action) { |
1060 rcmail.addEventListener('layout-change', 'set_layout', rcmail_ui); | |
1061 rcmail_ui.set_layout(); | |
1062 } | |
1063 else if (rcmail.env.action == 'compose') { | |
1037 rcmail_ui.init_compose_form(); | 1064 rcmail_ui.init_compose_form(); |
1038 else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') | 1065 rcmail.addEventListener('compose-encrypted', function(e) { |
1066 $("a.button.encrypt")[(e.active ? 'addClass' : 'removeClass')]('selected'); | |
1067 $("select[name='editorSelector']").prop('disabled', e.active); | |
1068 $('a.button.attach, a.button.responses, a.button.attach, #uploadmenulink')[(e.active ? 'addClass' : 'removeClass')]('buttonPas disabled'); | |
1069 $('#responseslist a.insertresponse')[(e.active ? 'removeClass' : 'addClass')]('active'); | |
1070 }); | |
1071 rcmail.addEventListener('fileappended', function(e) { | |
1072 if (e.attachment.complete) | |
1073 attachment_menu_append(e.item); | |
1074 }); | |
1075 | |
1076 // add menu link for each attachment | |
1077 $('#attachmentslist > li').each(function() { | |
1078 attachment_menu_append(this); | |
1079 }); | |
1080 } | |
1081 else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') { | |
1039 // add menu link for each attachment | 1082 // add menu link for each attachment |
1040 $('#attachment-list > li[id^="attach"]').each(function() { | 1083 $('#attachment-list > li[id^="attach"]').each(function() { |
1041 $(this).append($('<a class="drop"></a>').bind('click keypress', function(e) { | 1084 attachment_menu_append(this); |
1042 if (e.type != 'keypress' || e.which == 13) { | |
1043 rcmail_ui.show_attachmentmenu(this, e); | |
1044 return false; | |
1045 } | |
1046 })); | |
1047 }); | 1085 }); |
1086 | |
1087 $(window).resize(function() { | |
1088 if (!$('#attachment-list > li[id^="attach"]').length) | |
1089 $('#attachment-list').hide(); | |
1090 | |
1091 var mvlpe = $('#messagebody.mailvelope'); | |
1092 if (mvlpe.length) { | |
1093 var content = $('#messageframe'), | |
1094 h = (content.length ? content.height() + content.offset().top - 25 : $(this).height()) - mvlpe.offset().top - 20; | |
1095 mvlpe.height(h); | |
1096 } | |
1097 }); | |
1098 } | |
1048 } | 1099 } |
1049 else if (rcmail.env.task == 'addressbook') { | 1100 else if (rcmail.env.task == 'addressbook') { |
1050 rcmail.addEventListener('afterupload-photo', function(){ rcmail_ui.show_popup('uploadform', false); }) | 1101 rcmail.addEventListener('afterupload-photo', function(){ rcmail_ui.show_popup('uploadform', false); }) |
1051 .gui_object('dragmenu', 'dragmenu'); | 1102 .gui_object('dragmenu', 'dragmenu'); |
1052 } | 1103 } |