| | |
| | | var me = this; |
| | | var mailviewsplit; |
| | | var compose_headers = {}; |
| | | var prefs; |
| | | |
| | | // export public methods |
| | | this.set = setenv; |
| | |
| | | this.show_popup = show_popup; |
| | | this.add_popup = add_popup; |
| | | this.set_searchmod = set_searchmod; |
| | | this.set_searchscope = set_searchscope; |
| | | this.show_uploadform = show_uploadform; |
| | | this.show_header_row = show_header_row; |
| | | this.hide_header_row = hide_header_row; |
| | |
| | | */ |
| | | function get_pref(key) |
| | | { |
| | | return rcmail.get_cookie(key); |
| | | if (!prefs) { |
| | | prefs = window.localStorage ? rcmail.local_storage_get_item('prefs.larry', {}) : {}; |
| | | } |
| | | |
| | | // fall-back to cookies |
| | | if (prefs[key] == null) { |
| | | var cookie = rcmail.get_cookie(key); |
| | | if (cookie != null) { |
| | | prefs[key] = cookie; |
| | | |
| | | // copy value to local storage and remove cookie |
| | | if (window.localStorage) { |
| | | rcmail.local_storage_set_item('prefs.larry', prefs); |
| | | rcmail.set_cookie(key, cookie, new Date()); // expire cookie |
| | | } |
| | | } |
| | | } |
| | | |
| | | return prefs[key]; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | function save_pref(key, val) |
| | | { |
| | | var exp = new Date(); |
| | | exp.setYear(exp.getFullYear() + 1); |
| | | rcmail.set_cookie(key, val, exp); |
| | | prefs[key] = val; |
| | | |
| | | // write prefs to local storage |
| | | if (window.localStorage) { |
| | | rcmail.local_storage_set_item('prefs.larry', prefs); |
| | | } |
| | | else { |
| | | // store value in cookie |
| | | var exp = new Date(); |
| | | exp.setYear(exp.getFullYear() + 1); |
| | | rcmail.set_cookie(key, val, exp); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /*** mail task ***/ |
| | | if (rcmail.env.task == 'mail') { |
| | | rcmail.addEventListener('menu-open', menu_open); |
| | | rcmail.addEventListener('menu-save', menu_save); |
| | | rcmail.addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') }); |
| | | rcmail.addEventListener('menu-open', menu_open) |
| | | .addEventListener('menu-save', menu_save) |
| | | .addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') }); |
| | | |
| | | var dragmenu = $('#dragmessagemenu'); |
| | | if (dragmenu.length) { |
| | |
| | | } |
| | | |
| | | if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') { |
| | | rcmail.addEventListener('enable-command', enable_command); |
| | | rcmail.addEventListener('aftershow-headers', function() { layout_messageview(); }); |
| | | rcmail.addEventListener('afterhide-headers', function() { layout_messageview(); }); |
| | | rcmail.addEventListener('enable-command', enable_command) |
| | | .addEventListener('aftershow-headers', function() { layout_messageview(); }) |
| | | .addEventListener('afterhide-headers', function() { layout_messageview(); }); |
| | | $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(); return false }); |
| | | |
| | | // add menu link for each attachment |
| | |
| | | } |
| | | } |
| | | else if (rcmail.env.action == 'compose') { |
| | | rcmail.addEventListener('aftertoggle-editor', function(e){ |
| | | window.setTimeout(function(){ layout_composeview() }, 200); |
| | | if (e && e.mode) |
| | | $("select[name='editorSelector']").val(e.mode); |
| | | }); |
| | | rcmail.addEventListener('aftersend-attachment', show_uploadform); |
| | | rcmail.addEventListener('add-recipient', function(p){ show_header_row(p.field, true); }); |
| | | rcmail.addEventListener('aftersend-attachment', show_uploadform) |
| | | .addEventListener('add-recipient', function(p){ show_header_row(p.field, true); }) |
| | | .addEventListener('aftertoggle-editor', function(e){ |
| | | window.setTimeout(function(){ layout_composeview() }, 200); |
| | | if (e && e.mode) |
| | | $("select[name='editorSelector']").val(e.mode); |
| | | }); |
| | | |
| | | // Show input elements with non-empty value |
| | | var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto']; |
| | |
| | | if (previewframe) |
| | | mailviewsplit.init(); |
| | | |
| | | new rcube_scroller('#folderlist-content', '#folderlist-header', '#folderlist-footer'); |
| | | |
| | | rcmail.addEventListener('setquota', update_quota); |
| | | rcmail.addEventListener('enable-command', enable_command); |
| | | rcmail.addEventListener('afterimport-messages', show_uploadform); |
| | | rcmail.addEventListener('setquota', update_quota) |
| | | .addEventListener('enable-command', enable_command) |
| | | .addEventListener('afterimport-messages', show_uploadform); |
| | | } |
| | | else if (rcmail.env.action == 'get') { |
| | | new rcube_splitter({ id:'mailpartsplitterv', p1:'#messagepartheader', p2:'#messagepartcontainer', |
| | |
| | | } |
| | | /*** addressbook task ***/ |
| | | else if (rcmail.env.task == 'addressbook') { |
| | | rcmail.addEventListener('afterupload-photo', show_uploadform); |
| | | rcmail.addEventListener('beforepushgroup', push_contactgroup); |
| | | rcmail.addEventListener('beforepopgroup', pop_contactgroup); |
| | | rcmail.addEventListener('afterupload-photo', show_uploadform) |
| | | .addEventListener('beforepushgroup', push_contactgroup) |
| | | .addEventListener('beforepopgroup', pop_contactgroup); |
| | | |
| | | if (rcmail.env.action == '') { |
| | | new rcube_splitter({ id:'addressviewsplitterd', p1:'#addressview-left', p2:'#addressview-right', |
| | | orientation:'v', relative:true, start:226, min:150, size:12, render:resize_leftcol }).init(); |
| | | new rcube_splitter({ id:'addressviewsplitter', p1:'#addresslist', p2:'#contacts-box', |
| | | orientation:'v', relative:true, start:286, min:270, size:12 }).init(); |
| | | |
| | | new rcube_scroller('#directorylist-content', '#directorylist-header', '#directorylist-footer'); |
| | | } |
| | | |
| | | var dragmenu = $('#dragcontactmenu'); |
| | |
| | | function body_mouseup(e) |
| | | { |
| | | var config, obj, target = e.target; |
| | | |
| | | if (target.className == 'inner') |
| | | target = e.target.parentNode; |
| | | |
| | | for (var id in popups) { |
| | | obj = popups[id]; |
| | | config = popupconfig[id]; |
| | |
| | | && !config.toggle |
| | | && (!config.editable || !target_overlaps(target, obj.get(0))) |
| | | && (!config.sticky || !rcube_mouse_is_over(e, obj.get(0))) |
| | | && !$(target).is('.folder-selector-link') |
| | | ) { |
| | | var myid = id+''; |
| | | window.setTimeout(function(){ show_popupmenu(myid, false) }, 10); |
| | | window.setTimeout(function() { show_popupmenu(myid, false); }, 10); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // show a popup dialog on errors |
| | | if (p.type == 'error' && rcmail.env.task != 'login') { |
| | | // hide original message object, we don't want both |
| | | rcmail.hide_message(p.object); |
| | | |
| | | if (me.message_timer) { |
| | | window.clearTimeout(me.message_timer); |
| | | } |
| | |
| | | } |
| | | |
| | | var msg = p.message, |
| | | pos = $(p.object).offset(); |
| | | pos.top -= (rcmail.env.task == 'login' ? 20 : 160); |
| | | dialog_close = function() { |
| | | // check if dialog is still displayed, to prevent from js error |
| | | me.messagedialog.is(':visible') && me.messagedialog.dialog('destroy').hide(); |
| | | }; |
| | | |
| | | if (me.messagedialog.is(':visible')) |
| | | msg = me.messagedialog.html() + '<p>' + p.message + '</p>'; |
| | |
| | | closeOnEscape: true, |
| | | dialogClass: 'popupmessage ' + p.type, |
| | | title: env.errortitle, |
| | | close: function() { |
| | | me.messagedialog.dialog('destroy').hide(); |
| | | }, |
| | | position: ['center', pos.top], |
| | | hide: { effect:'drop', direction:'right' }, |
| | | close: dialog_close, |
| | | position: ['center', 'center'], |
| | | hide: {effect: 'fadeOut'}, |
| | | width: 420, |
| | | minHeight: 90 |
| | | }).show(); |
| | | |
| | | me.message_timer = window.setTimeout(function(){ me.messagedialog.dialog('close'); }, Math.max(3000, p.timeout / 2)); |
| | | me.message_timer = window.setTimeout(dialog_close, p.timeout); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | function switch_view_mode(mode) |
| | | { |
| | | if (rcmail.env.threading != (mode == 'thread')) |
| | | rcmail.set_list_options(null, undefined, undefined, mode == 'thread' ? 1 : 0); |
| | | |
| | | $('#maillistmode, #mailthreadmode').removeClass('selected'); |
| | | $('#mail'+mode+'mode').addClass('selected'); |
| | | if (!$('#mail'+mode+'mode').hasClass('disabled')) { |
| | | $('#maillistmode, #mailthreadmode').removeClass('selected'); |
| | | $('#mail'+mode+'mode').addClass('selected'); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | obj = popups['searchmenu'], |
| | | list = $('input:checkbox[name="s_mods[]"]', obj), |
| | | mbox = rcmail.env.mailbox, |
| | | mods = rcmail.env.search_mods; |
| | | mods = rcmail.env.search_mods, |
| | | scope = rcmail.env.search_scope || 'base'; |
| | | |
| | | if (rcmail.env.task == 'mail') { |
| | | if (scope == 'all') |
| | | mbox = '*'; |
| | | mods = mods[mbox] ? mods[mbox] : mods['*']; |
| | | all = 'text'; |
| | | $('#s_scope_'+scope).prop('checked', true); |
| | | } |
| | | else { |
| | | all = '*'; |
| | |
| | | { |
| | | var all, m, task = rcmail.env.task, |
| | | mods = rcmail.env.search_mods, |
| | | mbox = rcmail.env.mailbox; |
| | | mbox = rcmail.env.mailbox, |
| | | scope = $('input[name="s_scope"]:checked').val(); |
| | | |
| | | if (scope == 'all') |
| | | mbox = '*'; |
| | | |
| | | if (!mods) |
| | | mods = {}; |
| | |
| | | }); |
| | | } |
| | | |
| | | function set_searchscope(elem) |
| | | { |
| | | rcmail.env.search_scope = elem.value; |
| | | } |
| | | |
| | | function push_contactgroup(p) |
| | | { |
| | | // lets the contacts list swipe to the left, nice! |