| | |
| | | var me = this; |
| | | var mailviewsplit; |
| | | var compose_headers = {}; |
| | | var prefs; |
| | | |
| | | // export public methods |
| | | this.set = setenv; |
| | |
| | | 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'); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get preference stored in browser |
| | | */ |
| | | function get_pref(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]; |
| | | } |
| | | |
| | | /** |
| | | * Saves preference value to browser storage |
| | | */ |
| | | function save_pref(key, val) |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Initialize UI |
| | | * Called on document.ready |
| | | */ |
| | |
| | | |
| | | $('#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(); |
| | | }); |
| | | |
| | |
| | | $('#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(); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | function message_displayed(p) |
| | | { |
| | | var siblings = $(p.object).siblings('div'); |
| | | if (siblings.length) |
| | | $(p.object).insertBefore(siblings.first()); |
| | | |
| | | // 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:'down' }, |
| | | 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(2000, p.timeout / 2)); |
| | | me.message_timer = window.setTimeout(dialog_close, p.timeout); |
| | | } |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | |
| | | if (visible) { |
| | | $('#mailview-top').removeClass('fullheight').css({ bottom:'auto' }); |
| | | $('#mailview-bottom').css({ height:'auto' }); |
| | | $('#mailview-bottom').css({ height:'auto' }).show(); |
| | | |
| | | rcmail.env.contentframe = 'messagecontframe'; |
| | | if (uid = rcmail.message_list.get_single_selection()) |
| | |
| | | rcmail.env.contentframe = null; |
| | | rcmail.show_contentframe(false); |
| | | |
| | | $('#mailview-top').addClass('fullheight').css({ height:'auto', bottom:'28px' }); |
| | | $('#mailview-bottom').css({ top:'auto', height:'26px' }); |
| | | $('#mailview-top').addClass('fullheight').css({ height:'auto', bottom:'0px' }); |
| | | $('#mailview-bottom').css({ top:'auto', height:'0px' }).hide(); |
| | | |
| | | if (mailviewsplit.handle) |
| | | mailviewsplit.handle.hide(); |
| | |
| | | $(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(); |
| | |
| | | if (!me.drag_active) |
| | | return false; |
| | | |
| | | // with timing events dragging action is more responsive |
| | | window.clearTimeout(me.ts); |
| | | me.ts = window.setTimeout(function() { onDragAction(e); }, 1); |
| | | |
| | | return false; |
| | | }; |
| | | |
| | | /** |
| | | * Dragging action (see onDrag()) |
| | | */ |
| | | function onDragAction(e) |
| | | { |
| | | var pos = rcube_event.get_mouse_pos(e); |
| | | |
| | | if (me.relative) { |
| | |
| | | |
| | | me.p1pos = me.relative ? me.p1.position() : me.p1.offset(); |
| | | me.p2pos = me.relative ? me.p2.position() : me.p2.offset(); |
| | | return false; |
| | | }; |
| | | |
| | | /** |
| | |
| | | }; |
| | | |
| | | /** |
| | | * 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 |