| | |
| | | // @license http://creativecommons.org/publicdomain/zero/1.0/legalcode CC0 |
| | | |
| | | /** |
| | | * Roundcube functions for default skin interface |
| | | * |
| | |
| | | * License. It is allowed to copy, distribute, transmit and to adapt the work |
| | | * by keeping credits to the original autors in the README file. |
| | | * See http://creativecommons.org/licenses/by-sa/3.0/ for details. |
| | | * |
| | | * @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0 |
| | | */ |
| | | |
| | | function rcube_mail_ui() |
| | |
| | | searchmenu: { editable:1, callback:searchmenu }, |
| | | attachmentmenu: { }, |
| | | listoptions: { editable:1 }, |
| | | dragmenu: { sticky:1 }, |
| | | groupmenu: { above:1 }, |
| | | mailboxmenu: { above:1 }, |
| | | spellmenu: { callback: spellmenu }, |
| | | // toggle: #1486823, #1486930 |
| | | 'attachment-form': { editable:1, above:1, toggle:!bw.ie&&!bw.linux }, |
| | | 'upload-form': { editable:1, toggle:!bw.ie&&!bw.linux } |
| | | 'folder-selector': { iconized:1 } |
| | | }; |
| | | |
| | | var me = this; |
| | | var mailviewsplit; |
| | | var compose_headers = {}; |
| | | var prefs; |
| | | var focused_popup; |
| | | var popup_keyboard_active = false; |
| | | |
| | | // export public methods |
| | | this.set = setenv; |
| | |
| | | this.update_quota = update_quota; |
| | | this.get_pref = get_pref; |
| | | this.save_pref = save_pref; |
| | | this.folder_search_init = folder_search_init; |
| | | |
| | | |
| | | // set minimal mode on small screens (don't wait for document.ready) |
| | |
| | | function get_pref(key) |
| | | { |
| | | if (!prefs) { |
| | | prefs = window.localStorage ? rcmail.local_storage_get_item('prefs.larry', {}) : {}; |
| | | prefs = rcmail.local_storage_get_item('prefs.larry', {}); |
| | | } |
| | | |
| | | // fall-back to cookies |
| | |
| | | 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); |
| | | // copy value to local storage and remove cookie (if localStorage is supported) |
| | | if (rcmail.local_storage_set_item('prefs.larry', prefs)) { |
| | | rcmail.set_cookie(key, cookie, new Date()); // expire cookie |
| | | } |
| | | } |
| | |
| | | { |
| | | prefs[key] = val; |
| | | |
| | | // write prefs to local storage |
| | | if (window.localStorage) { |
| | | rcmail.local_storage_set_item('prefs.larry', prefs); |
| | | } |
| | | else { |
| | | // write prefs to local storage (if supported) |
| | | if (!rcmail.local_storage_set_item('prefs.larry', prefs)) { |
| | | // store value in cookie |
| | | var exp = new Date(); |
| | | exp.setYear(exp.getFullYear() + 1); |
| | |
| | | rcmail.addEventListener('menu-open', menu_toggle) |
| | | .addEventListener('menu-close', menu_toggle) |
| | | .addEventListener('menu-save', save_listoptions) |
| | | .addEventListener('enable-command', enable_command) |
| | | .addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list', true) }) |
| | | .addEventListener('responseaftersearch', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list', true) }); |
| | | |
| | |
| | | } |
| | | |
| | | if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') { |
| | | rcmail.addEventListener('enable-command', enable_command) |
| | | .addEventListener('aftershow-headers', function() { layout_messageview(); }) |
| | | rcmail.addEventListener('aftershow-headers', function() { layout_messageview(); }) |
| | | .addEventListener('afterhide-headers', function() { layout_messageview(); }); |
| | | $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(); return false }); |
| | | |
| | | $('#previewheaderstoggle').click(function(e) { |
| | | toggle_preview_headers(); |
| | | if (this.blur && !rcube_event.is_keyboard(e)) |
| | | this.blur(); |
| | | return false; |
| | | }); |
| | | |
| | | // add menu link for each attachment |
| | | $('#attachment-list > li').each(function() { |
| | | $(this).append($('<a class="drop" tabindex="0" aria-haspopup="true">Show options</a>') |
| | | .bind('click keypress', function(e) { |
| | | .on('click keypress', function(e) { |
| | | if (e.type != 'keypress' || rcube_event.get_keycode(e) == 13) { |
| | | attachmentmenu(this, e); |
| | | return false; |
| | |
| | | if (get_pref('previewheaders') == '1') { |
| | | toggle_preview_headers(); |
| | | } |
| | | |
| | | if (rcmail.env.action == 'show') { |
| | | $('#messagecontent').focus() |
| | | } |
| | | } |
| | | else if (rcmail.env.action == 'compose') { |
| | | rcmail.addEventListener('aftersend-attachment', show_uploadform) |
| | | .addEventListener('add-recipient', function(p){ show_header_row(p.field, true); }) |
| | | .addEventListener('aftertoggle-editor', function(e){ |
| | | .addEventListener('aftertoggle-editor', function(e) { |
| | | window.setTimeout(function(){ layout_composeview() }, 200); |
| | | if (e && e.mode) |
| | | $("select[name='editorSelector']").val(e.mode); |
| | | }) |
| | | .addEventListener('compose-encrypted', function(e) { |
| | | $("select[name='editorSelector']").prop('disabled', e.active); |
| | | $('a.button.attach, a.button.responses')[(e.active?'addClass':'removeClass')]('disabled'); |
| | | $('#responseslist a.insertresponse')[(e.active?'removeClass':'addClass')]('active'); |
| | | }); |
| | | |
| | | // Show input elements with non-empty value |
| | |
| | | } |
| | | } |
| | | |
| | | $('#composeoptionstoggle').click(function(){ |
| | | $('#composeoptionstoggle').toggleClass('remove'); |
| | | $('#composeoptions').toggle(); |
| | | $('#composeoptionstoggle').click(function(e){ |
| | | var expanded = $('#composeoptions').toggle().is(':visible'); |
| | | $('#composeoptionstoggle').toggleClass('remove').attr('aria-expanded', expanded ? 'true' : 'false'); |
| | | layout_composeview(); |
| | | save_pref('composeoptions', $('#composeoptions').is(':visible') ? '1' : '0'); |
| | | save_pref('composeoptions', expanded ? '1' : '0'); |
| | | if (!rcube_event.is_keyboard(e)) |
| | | this.blur(); |
| | | return false; |
| | | }).css('cursor', 'pointer'); |
| | | |
| | |
| | | $('#composeoptionstoggle').click(); |
| | | |
| | | new rcube_splitter({ id:'composesplitterv', p1:'#composeview-left', p2:'#composeview-right', |
| | | orientation:'v', relative:true, start:248, min:170, size:12, render:layout_composeview }).init(); |
| | | orientation:'v', relative:true, start:206, min:170, size:12, render:layout_composeview }).init(); |
| | | } |
| | | else if (rcmail.env.action == 'list' || !rcmail.env.action) { |
| | | var previewframe = $('#mailpreviewframe').is(':visible'); |
| | | $('#mailpreviewtoggle').addClass(previewframe ? 'enabled' : 'closed').click(function(e){ toggle_preview_pane(e); return false }); |
| | | $('#maillistmode').addClass(rcmail.env.threading ? '' : 'selected').click(function(e){ switch_view_mode('list'); return false }); |
| | | $('#mailthreadmode').addClass(rcmail.env.threading ? 'selected' : '').click(function(e){ switch_view_mode('thread'); return false }); |
| | | |
| | | $('#mailpreviewtoggle').addClass(previewframe ? 'enabled' : 'closed').attr('aria-expanded', previewframe ? 'true' : 'false') |
| | | .click(function(e) { toggle_preview_pane(e); return false; }); |
| | | $('#maillistmode').addClass(rcmail.env.threading ? '' : 'selected').click(function(e) { switch_view_mode('list'); return false; }); |
| | | $('#mailthreadmode').addClass(rcmail.env.threading ? 'selected' : '').click(function(e) { switch_view_mode('thread'); return false; }); |
| | | |
| | | mailviewsplit = new rcube_splitter({ id:'mailviewsplitter', p1:'#mailview-top', p2:'#mailview-bottom', |
| | | orientation:'h', relative:true, start:310, min:150, size:12, offset:4 }); |
| | | orientation:'h', relative:true, start:276, min:150, size:12, offset:4 }); |
| | | if (previewframe) |
| | | mailviewsplit.init(); |
| | | |
| | | rcmail.init_pagejumper('#pagejumper'); |
| | | |
| | | rcmail.addEventListener('setquota', update_quota) |
| | | .addEventListener('enable-command', enable_command) |
| | | .addEventListener('afterimport-messages', show_uploadform); |
| | | } |
| | | else if (rcmail.env.action == 'get') { |
| | |
| | | |
| | | if ($('#mailview-left').length) { |
| | | new rcube_splitter({ id:'mailviewsplitterv', p1:'#mailview-left', p2:'#mailview-right', |
| | | orientation:'v', relative:true, start:226, min:150, size:12, callback:render_mailboxlist, render:resize_leftcol }).init(); |
| | | orientation:'v', relative:true, start:206, min:150, size:12, callback:render_mailboxlist, render:resize_leftcol }).init(); |
| | | } |
| | | } |
| | | /*** settings task ***/ |
| | |
| | | new rcube_splitter({ id:'folderviewsplitter', p1:'#folderslist', p2:'#folder-details', |
| | | orientation:'v', relative:true, start:266, min:180, size:12 }).init(); |
| | | |
| | | new rcube_scroller('#folderslist-content', '#folderslist-header', '#folderslist-footer'); |
| | | |
| | | rcmail.addEventListener('setquota', update_quota); |
| | | |
| | | folder_search_init($('#folderslist')); |
| | | } |
| | | else if (rcmail.env.action == 'identities') { |
| | | new rcube_splitter({ id:'identviewsplitter', p1:'#identitieslist', p2:'#identity-details', |
| | |
| | | orientation:'v', relative:true, start:266, min:180, size:12 }).init(); |
| | | } |
| | | else if (rcmail.env.action == 'edit-prefs') { |
| | | $('<a href="#toggle">▼</a>') |
| | | .addClass('advanced-toggle') |
| | | .appendTo('#preferences-details fieldset.advanced legend'); |
| | | var legend = $('#preferences-details fieldset.advanced legend'), |
| | | toggle = $('<a href="#toggle"></a>') |
| | | .text(env.toggleoptions) |
| | | .attr('title', env.toggleoptions) |
| | | .addClass('advanced-toggle'); |
| | | |
| | | $('#preferences-details fieldset.advanced legend').click(function(e){ |
| | | var collapsed = $(this).hasClass('collapsed'), |
| | | toggle = $('.advanced-toggle', this).html(collapsed ? '▲' : '▼'); |
| | | $(this) |
| | | .toggleClass('collapsed') |
| | | .closest('fieldset').children('.propform').toggle() |
| | | }).addClass('collapsed') |
| | | legend.click(function(e) { |
| | | toggle.html($(this).hasClass('collapsed') ? '▲' : '▼'); |
| | | |
| | | $(this).toggleClass('collapsed') |
| | | .closest('fieldset').children('.propform').toggle() |
| | | }).append(toggle).addClass('collapsed') |
| | | |
| | | // this magically fixes incorrect position of toggle link created above in Firefox 3.6 |
| | | if (bw.mz) |
| | | legend.parents('form').css('display', 'inline'); |
| | | } |
| | | } |
| | | /*** addressbook task ***/ |
| | | else if (rcmail.env.task == 'addressbook') { |
| | | rcmail.addEventListener('afterupload-photo', show_uploadform) |
| | | .addEventListener('beforepushgroup', push_contactgroup) |
| | | .addEventListener('beforepopgroup', pop_contactgroup); |
| | | .addEventListener('beforepopgroup', pop_contactgroup) |
| | | .addEventListener('menu-open', menu_toggle) |
| | | .addEventListener('menu-close', menu_toggle); |
| | | |
| | | 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(); |
| | | orientation:'v', relative:true, start:206, 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(); |
| | | orientation:'v', relative:true, start:266, min:260, size:12 }).init(); |
| | | } |
| | | |
| | | var dragmenu = $('#dragcontactmenu'); |
| | |
| | | if ($('option:selected', this).val() != '') |
| | | title = $('option:selected', this).text(); |
| | | |
| | | var overlay = $('<a class="menuselector"><span class="handle">' + title + '</span></a>') |
| | | var overlay = $('<a class="menuselector" tabindex="-1"><span class="handle">' + title + '</span></a>') |
| | | .css('position', 'absolute') |
| | | .offset(select.position()) |
| | | .insertAfter(select); |
| | |
| | | |
| | | // re-set original select width to fix click action and options width in some browsers |
| | | select.width(overlay.width()) |
| | | .change(function() { |
| | | .on(bw.mz ? 'change keyup' : 'change', function() { |
| | | var val = $('option:selected', this).text(); |
| | | $(this).next().children().text(val); |
| | | }); |
| | |
| | | screen.css('min-width', $('.toolbar').width() + $('#quicksearchbar').width() + $('#searchfilter').width() + 30); |
| | | } |
| | | |
| | | $(document.body) |
| | | .bind('mouseup', body_mouseup) |
| | | .bind('keydown', popup_keypress); |
| | | |
| | | $('iframe').load(function(e){ |
| | | // this = iframe |
| | | try { |
| | | var doc = this.contentDocument ? this.contentDocument : this.contentWindow ? this.contentWindow.document : null; |
| | | $(doc).mouseup(body_mouseup); |
| | | } |
| | | catch (e) { |
| | | // catch possible "Permission denied" error in IE |
| | | }; |
| | | }) |
| | | .contents().mouseup(body_mouseup); |
| | | |
| | | // don't use $(window).resize() due to some unwanted side-effects |
| | | window.onresize = resize; |
| | | resize(); |
| | | } |
| | | |
| | | /** |
| | | * Handler for mouse-up events on the document body. |
| | | * This will close all open popup menus |
| | | */ |
| | | 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]; |
| | | if (obj.is(':visible') |
| | | && target.id != id+'link' |
| | | && target != obj.get(0) // check if scroll bar was clicked (#1489832) |
| | | && !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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | if (me.message_timer) { |
| | | window.clearTimeout(me.message_timer); |
| | | } |
| | | |
| | | if (!me.messagedialog) { |
| | | me.messagedialog = $('<div>').addClass('popupdialog').hide(); |
| | | } |
| | |
| | | me.messagedialog.is(':visible') && me.messagedialog.dialog('destroy').hide(); |
| | | }; |
| | | |
| | | if (me.messagedialog.is(':visible')) |
| | | if (me.messagedialog.is(':visible') && me.messagedialog.text() != msg) |
| | | msg = me.messagedialog.html() + '<p>' + p.message + '</p>'; |
| | | |
| | | me.messagedialog.html(msg) |
| | |
| | | |
| | | me.messagedialog.closest('div[role=dialog]').attr('role', 'alertdialog'); |
| | | |
| | | me.message_timer = window.setTimeout(dialog_close, p.timeout); |
| | | if (p.timeout > 0) |
| | | me.message_timer = window.setTimeout(dialog_close, p.timeout); |
| | | } |
| | | } |
| | | |
| | |
| | | if (!$('#attachment-list li').length) { |
| | | $('div.rightcol').hide().attr('aria-hidden', 'true'); |
| | | $('div.leftcol').css('margin-right', '0'); |
| | | } |
| | | |
| | | var mvlpe = $('#messagebody.mailvelope, #messagebody > .mailvelope'); |
| | | if (mvlpe.length) { |
| | | var h = $('#messagecontent').length ? |
| | | $('#messagecontent').height() - 16 : |
| | | $(window).height() - mvlpe.offset().top - 10; |
| | | mvlpe.height(h); |
| | | } |
| | | } |
| | | |
| | |
| | | w, h, bh, ovflw, btns = 0, |
| | | minheight = 300, |
| | | |
| | | bh = (form.height() - bottom.position().top); |
| | | bh = form.height() - bottom.position().top; |
| | | ovflw = minheight - bh; |
| | | btns = ovflw > -100 ? 0 : 40; |
| | | bottom.css('height', Math.max(minheight, bh) + 'px'); |
| | | bottom.height(Math.max(minheight, bh)); |
| | | form.css('overflow', ovflw > 0 ? 'auto' : 'hidden'); |
| | | |
| | | w = body.parent().width() - 5; |
| | | h = body.parent().height() - 16; |
| | | h = body.parent().height() - 8; |
| | | body.width(w).height(h); |
| | | |
| | | $('#composebody_tbl').width((w+8)+'px').height('').css('margin-top', '1px'); |
| | | $('#composebody_ifr').width((w+8)+'px').height((h-40)+'px'); |
| | | $('#googie_edit_layer').height(h+'px'); |
| | | $('#composebodycontainer > div').width(w+8); |
| | | $('#composebody_ifr').height(h + 4 - $('div.mce-toolbar').height()); |
| | | $('#googie_edit_layer').width(w).height(h); |
| | | // $('#composebodycontainer')[(btns ? 'addClass' : 'removeClass')]('buttons'); |
| | | // $('#composeformbuttons')[(btns ? 'show' : 'hide')](); |
| | | |
| | | var abooks = $('#directorylist'); |
| | | $('#compose-contacts .scroller').css('top', abooks.position().top + abooks.outerHeight()); |
| | | if (abooks.length) |
| | | $('#compose-contacts .scroller').css('top', abooks.position().top + abooks.outerHeight()); |
| | | } |
| | | |
| | | |
| | | function update_quota(p) |
| | | { |
| | | var step = 24, step_count = 20, |
| | | var element = $('#quotadisplay'), menu = $('#quotamenu'), |
| | | step = 24, step_count = 20, |
| | | y = p.total ? Math.ceil(p.percent / 100 * step_count) * step : 0; |
| | | |
| | | // never show full-circle if quota is close to 100% but below. |
| | | if (p.total && y == step * step_count && p.percent < 100) |
| | | y -= step; |
| | | |
| | | $('#quotadisplay').css('background-position', '0 -'+y+'px'); |
| | | element.css('background-position', '0 -' + y + 'px'); |
| | | element.attr('class', 'countdisplay p' + (Math.round(p.percent / 10) * 10)); |
| | | |
| | | if (p.table) { |
| | | if (!menu.length) |
| | | menu = $('<div id="quotamenu" class="popupmenu">').appendTo($('body')); |
| | | |
| | | menu.html(p.table); |
| | | element.css('cursor', 'pointer').off('click').on('click', function(e) { |
| | | return rcmail.command('menu-open', 'quotamenu', e.target, e); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | function folder_search_init(container) |
| | | { |
| | | // animation to unfold list search box |
| | | $('.boxtitle a.search', container).click(function(e) { |
| | | var title = $('.boxtitle', container), |
| | | box = $('.listsearchbox', container), |
| | | dir = box.is(':visible') ? -1 : 1, |
| | | height = 34 + ($('select', box).length ? 22 : 0); |
| | | |
| | | box.slideToggle({ |
| | | duration: 160, |
| | | progress: function(animation, progress) { |
| | | if (dir < 0) progress = 1 - progress; |
| | | $('.scroller', container).css('top', (title.outerHeight() + height * progress) + 'px'); |
| | | }, |
| | | complete: function() { |
| | | box.toggleClass('expanded'); |
| | | if (box.is(':visible')) { |
| | | box.find('input[type=text]').focus(); |
| | | height = 34 + ($('select', box).length ? $('select', box).outerHeight() + 4 : 0); |
| | | $('.scroller', container).css('top', (title.outerHeight() + height) + 'px'); |
| | | } |
| | | else { |
| | | $('a.reset', box).click(); |
| | | } |
| | | // TODO: save state in localStorage |
| | | } |
| | | }); |
| | | |
| | | return false; |
| | | }); |
| | | } |
| | | |
| | | function enable_command(p) |
| | | { |
| | |
| | | $('a.button.replyall').attr('title', label); |
| | | else |
| | | $('a.button.reply-all').text(label).attr('title', label); |
| | | } |
| | | else if (p.command == 'compose-encrypted') { |
| | | // show the toolbar button for Mailvelope |
| | | $('a.button.encrypt').show(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | function toggle_popup(popup, e, config) |
| | | { |
| | | show_popup(popup, undefined, config, rcube_event.is_keyboard(e)); |
| | | // auto-register menu object |
| | | if (config || !popupconfig[popup]) |
| | | add_popup(popup, config); |
| | | |
| | | return rcmail.command('menu-open', popup, e.target, e); |
| | | } |
| | | |
| | | /** |
| | | * (Deprecated) trigger for popup menus |
| | | */ |
| | | function show_popup(popup, show, config, keyboard) |
| | | function show_popup(popup, show, config) |
| | | { |
| | | // auto-register menu object |
| | | if (config || !popupconfig[popup]) |
| | | add_popup(popup, config); |
| | | |
| | | var visible = show_popupmenu(popup, show, keyboard), |
| | | config = popupconfig[popup]; |
| | | if (typeof config.callback == 'function') |
| | | config.callback(visible); |
| | | } |
| | | |
| | | /** |
| | | * Show/hide a specific popup menu |
| | | */ |
| | | function show_popupmenu(popup, show, keyboard) |
| | | { |
| | | var obj = popups[popup], |
| | | config = popupconfig[popup], |
| | | ref = $(config.link ? config.link : '#'+popup+'link'), |
| | | above = config.above; |
| | | |
| | | if (!obj) { |
| | | obj = popups[popup] = $('#'+popup); |
| | | obj.appendTo(document.body); // move them to top for proper absolute positioning |
| | | } |
| | | |
| | | if (!obj || !obj.length) |
| | | return false; |
| | | |
| | | if (typeof show == 'undefined') |
| | | show = obj.is(':visible') ? false : true; |
| | | else if (config.toggle && show && obj.is(':visible')) |
| | | show = false; |
| | | |
| | | if (show && ref.length) { |
| | | var parent = ref.parent(), |
| | | win = $(window), |
| | | pos; |
| | | |
| | | if (parent.hasClass('dropbutton')) |
| | | ref = parent; |
| | | |
| | | config = popupconfig[popup] || {}; |
| | | var ref = $(config.link ? config.link : '#'+popup+'link'), |
| | | pos = ref.offset(); |
| | | ref.offsetHeight = ref.outerHeight(); |
| | | if (!above && pos.top + ref.offsetHeight + obj.height() > win.height()) |
| | | above = true; |
| | | if (pos.left + obj.width() > win.width()) |
| | | pos.left = win.width() - obj.width() - 12; |
| | | if (ref.has('.inner')) |
| | | ref = ref.children('.inner'); |
| | | |
| | | obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) }); |
| | | } |
| | | else if (!show && keyboard && ref.length) { |
| | | ref.focus(); |
| | | } |
| | | |
| | | obj[show?'show':'hide']().attr('aria-hidden', show?'false':'true'); |
| | | |
| | | popup_keyboard_active = show && keyboard; |
| | | if (popup_keyboard_active) { |
| | | focused_popup = popup; |
| | | obj.find('a,input:not(:disabled)').not('[aria-disabled=true]').first().focus(); |
| | | } |
| | | else { |
| | | focused_popup = null; |
| | | } |
| | | |
| | | return show; |
| | | } |
| | | |
| | | /** |
| | | * Handler for keyboard events on active popups |
| | | */ |
| | | function popup_keypress(e) |
| | | { |
| | | var target = e.target || {}, |
| | | keyCode = rcube_event.get_keycode(e); |
| | | |
| | | if (e.keyCode != 27 && (!popup_keyboard_active || target.nodeName == 'TEXTAREA' || target.nodeName == 'SELECT')) |
| | | return true; |
| | | |
| | | switch (keyCode) { |
| | | case 38: |
| | | case 40: |
| | | case 63232: // "up", in safari keypress |
| | | case 63233: // "down", in safari keypress |
| | | popup_focus_item(mod = keyCode == 38 || keyCode == 63232 ? -1 : 1); |
| | | break; |
| | | |
| | | case 9: // tab |
| | | if (focused_popup) { |
| | | var mod = rcube_event.get_modifier(e); |
| | | if (!popup_focus_item(mod == SHIFT_KEY ? -1 : 1)) { |
| | | show_popup(focused_popup, false, undefined, true); |
| | | } |
| | | } |
| | | return rcube_event.cancel(e); |
| | | |
| | | case 27: // esc |
| | | for (var id in popups) { |
| | | if (popups[id].is(':visible')) |
| | | show_popup(id, false, undefined, true); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Helper method to move focus to the next/prev popup menu item |
| | | */ |
| | | function popup_focus_item(dir) |
| | | { |
| | | var obj, mod = dir < 0 ? 'prevAll' : 'nextAll', limit = dir < 0 ? 'last' : 'first'; |
| | | if (focused_popup && (obj = popups[focused_popup])) { |
| | | return obj.find(':focus').closest('li')[mod](':has(:not([aria-disabled=true]))').find('a,input')[limit]().focus().length; |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | function target_overlaps(target, elem) |
| | | { |
| | | while (target.parentNode) { |
| | | if (target.parentNode == elem) |
| | | return true; |
| | | target = target.parentNode; |
| | | } |
| | | return false; |
| | | // fire command with simulated mouse click event |
| | | return rcmail.command('menu-open', |
| | | { menu:popup, show:show }, |
| | | ref.get(0), |
| | | $.Event('click', { target:ref.get(0), pageX:pos.left, pageY:pos.top, clientX:pos.left, clientY:pos.top })); |
| | | } |
| | | |
| | | |
| | |
| | | topstyles, bottomstyles, uid; |
| | | |
| | | frame.toggle(); |
| | | button.removeClass().addClass(visible ? 'enabled' : 'closed'); |
| | | button.toggleClass('enabled closed').attr('aria-expanded', visible ? 'true' : 'false'); |
| | | |
| | | if (visible) { |
| | | $('#mailview-top').removeClass('fullheight').css({ bottom:'auto' }); |
| | |
| | | |
| | | // add toggle button to full headers table |
| | | if (full.is(':visible')) |
| | | button.attr('href', '#hide').removeClass('add').addClass('remove') |
| | | button.attr('href', '#hide').removeClass('add').addClass('remove').attr('aria-expanded', 'true'); |
| | | else |
| | | button.attr('href', '#details').removeClass('remove').addClass('add') |
| | | button.attr('href', '#details').removeClass('remove').addClass('add').attr('aria-expanded', 'false'); |
| | | |
| | | save_pref('previewheaders', full.is(':visible') ? '1' : '0'); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /**** popup callbacks ****/ |
| | | /**** popup menu callbacks ****/ |
| | | |
| | | /** |
| | | * Handler for menu-open and menu-close events |
| | | */ |
| | | function menu_toggle(p) |
| | | { |
| | | if (p && p.props && p.props.menu == 'attachmentmenu') |
| | | show_popupmenu('attachmentmenu', undefined, rcube_event.is_keyboard(p.originalEvent)); |
| | | else |
| | | if (p && p.name == 'messagelistmenu') { |
| | | show_listoptions(p); |
| | | } |
| | | else if (p) { |
| | | // adjust menu position according to config |
| | | var config = popupconfig[p.name] || {}, |
| | | ref = $(config.link || '#'+p.name+'link'), |
| | | visible = p.obj && p.obj.is(':visible'), |
| | | above = config.above; |
| | | |
| | | // fix position according to config |
| | | if (p.obj && visible && ref.length) { |
| | | var parent = ref.parent(), |
| | | win = $(window), pos; |
| | | |
| | | if (parent.hasClass('dropbutton')) |
| | | ref = parent; |
| | | |
| | | if (config.above || ref.hasClass('dropbutton')) { |
| | | pos = ref.offset(); |
| | | p.obj.css({ left:pos.left+'px', top:(pos.top + (config.above ? -p.obj.height() : ref.outerHeight()))+'px' }); |
| | | } |
| | | } |
| | | |
| | | // add the right classes |
| | | if (p.obj && config.iconized) { |
| | | p.obj.children('ul').addClass('iconized'); |
| | | } |
| | | |
| | | // apply some data-attributes from menu config |
| | | if (p.obj && config.editable) |
| | | p.obj.attr('data-editable', 'true'); |
| | | |
| | | // trigger callback function |
| | | if (typeof config.callback == 'function') { |
| | | config.callback(visible, p); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function searchmenu(show) |
| | |
| | | { |
| | | var id = elem.parentNode.id.replace(/^attach/, ''); |
| | | |
| | | $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) { |
| | | $('#attachmenuopen').off('click').attr('onclick', '').click(function(e) { |
| | | return rcmail.command('open-attachment', id, this); |
| | | }); |
| | | |
| | | $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() { |
| | | $('#attachmenudownload').off('click').attr('onclick', '').click(function() { |
| | | rcmail.command('download-attachment', id, this); |
| | | }); |
| | | |
| | |
| | | rcmail.command('menu-open', {menu: 'attachmentmenu', id: id}, elem, event); |
| | | } |
| | | |
| | | function spellmenu(show) |
| | | function spellmenu(show, p) |
| | | { |
| | | var k, link, li, |
| | | lang = rcmail.spellcheck_lang(), |
| | | menu = popups.spellmenu, |
| | | ul = $('ul', menu); |
| | | ul = $('ul', p.obj); |
| | | |
| | | if (!ul.length) { |
| | | ul = $('<ul class="toolbarmenu selectable" role="menu">'); |
| | |
| | | li = $('<li role="menuitem">'); |
| | | link = $('<a href="#'+k+'" tabindex="0"></a>').text(rcmail.env.spell_langs[k]) |
| | | .addClass('active').data('lang', k) |
| | | .bind('click keypress', function(e) { |
| | | .on('click keypress', function(e) { |
| | | if (e.type != 'keypress' || rcube_event.get_keycode(e) == 13) { |
| | | rcmail.spellcheck_lang_set($(this).data('lang')); |
| | | show_popupmenu('spellmenu', false, rcube_event.is_keyboard(e)) |
| | | rcmail.hide_menu('spellmenu', e); |
| | | return false; |
| | | } |
| | | }); |
| | |
| | | li.appendTo(ul); |
| | | } |
| | | |
| | | ul.appendTo(menu); |
| | | ul.appendTo(p.obj); |
| | | } |
| | | |
| | | // select current language |
| | |
| | | }); |
| | | } |
| | | |
| | | function show_uploadform() |
| | | function show_uploadform(e) |
| | | { |
| | | var $dialog = $('#upload-dialog'); |
| | | |
| | |
| | | $dialog.dialog('close'); |
| | | return; |
| | | } |
| | | |
| | | // do nothing if mailvelope editor is active |
| | | if (rcmail.mailvelope_editor) |
| | | return; |
| | | |
| | | // add icons to clone file input field |
| | | if (rcmail.env.action == 'compose' && !$dialog.data('extended')) { |
| | |
| | | resizable: false, |
| | | closeOnEscape: true, |
| | | title: $dialog.attr('title'), |
| | | open: function(e) { |
| | | if (!document.all) |
| | | $('input[type=file]', $dialog).first().click(); |
| | | }, |
| | | close: function() { |
| | | try { $('#upload-dialog form').get(0).reset(); } |
| | | catch(e){ } // ignore errors |
| | |
| | | }, |
| | | width: 480 |
| | | }).show(); |
| | | |
| | | if (!document.all) |
| | | $('input[type=file]', $dialog).first().click(); |
| | | } |
| | | |
| | | function add_uploadfile(e) |
| | |
| | | |
| | | row.show(); |
| | | $('#' + which + '-link').hide(); |
| | | |
| | | layout_composeview(); |
| | | $('input,textarea', row).focus(); |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | content.attr('id', id); |
| | | } |
| | | |
| | | // first hide not selected tabs |
| | | current = current || 0; |
| | | fs.each(function(idx) { if (idx != current) $(this).hide(); }); |
| | | |
| | | // create tabs container |
| | | var tabs = $('<div>').addClass('tabsbar').prependTo(content); |
| | | var tabs = $('<ul>').addClass('tabsbar').prependTo(content); |
| | | |
| | | // convert fildsets into tabs |
| | | fs.each(function(idx) { |
| | | var tab, a, elm = $(this), legend = elm.children('legend'); |
| | | var tab, a, elm = $(this), |
| | | legend = elm.children('legend'), |
| | | tid = id + '-t' + idx; |
| | | |
| | | // create a tab |
| | | a = $('<a>').text(legend.text()).attr('href', '#'); |
| | | tab = $('<span>').attr({'id': 'tab'+idx, 'class': 'tablink'}) |
| | | .click(function() { show_tab(id, idx); return false }) |
| | | a = $('<a>').text(legend.text()).attr('href', '#' + tid); |
| | | tab = $('<li>').addClass('tablink'); |
| | | |
| | | // remove legend |
| | | legend.remove(); |
| | | // style fieldset |
| | | elm.addClass('tab'); |
| | | // style selected tab |
| | | if (idx == current) |
| | | tab.addClass('selected'); |
| | | |
| | | // link fieldset with tab item |
| | | elm.attr('id', tid); |
| | | |
| | | // add the tab to container |
| | | tab.append(a).appendTo(tabs); |
| | | }); |
| | | } |
| | | |
| | | function show_tab(id, index) |
| | | { |
| | | var fs = $('#'+id).children('fieldset'); |
| | | |
| | | fs.each(function(idx) { |
| | | // Show/hide fieldset (tab content) |
| | | $(this)[index==idx ? 'show' : 'hide'](); |
| | | // Select/unselect tab |
| | | $('#tab'+idx).toggleClass('selected', idx==index); |
| | | // use jquery UI tabs widget to do the interaction and styling |
| | | content.tabs({ |
| | | active: current || 0, |
| | | heightStyle: 'content', |
| | | activate: function(e, ui) {resize(); } |
| | | }); |
| | | |
| | | resize(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | function show_about(elem) |
| | | { |
| | | var frame = $('<iframe>').attr('id', 'aboutframe') |
| | | .attr('src', rcmail.url('settings/about')) |
| | | .attr('frameborder', '0') |
| | | .appendTo(document.body); |
| | | var frame = $('<iframe>').attr({id: 'aboutframe', src: rcmail.url('settings/about'), frameborder: '0'}); |
| | | h = Math.floor($(window).height() * 0.75), |
| | | buttons = {}, |
| | | supportln = $('#supportlink'); |
| | | |
| | | var h = Math.floor($(window).height() * 0.75); |
| | | var buttons = {}; |
| | | var supportln = $('#supportlink'); |
| | | if (supportln.length && (env.supporturl = supportln.attr('href'))) |
| | | buttons[supportln.html()] = function(e){ env.supporturl.indexOf('mailto:') < 0 ? window.open(env.supporturl) : location.href = env.supporturl }; |
| | | |
| | |
| | | |
| | | /** |
| | | * Roundcube Scroller class |
| | | * |
| | | * @deprecated Use treelist widget |
| | | */ |
| | | function rcube_scroller(list, top, bottom) |
| | | { |
| | |
| | | this.handle = $('<div>') |
| | | .attr('id', this.id) |
| | | .attr('unselectable', 'on') |
| | | .attr('role', 'presentation') |
| | | .addClass('splitter ' + (this.horizontal ? 'splitter-h' : 'splitter-v')) |
| | | .appendTo(this.parent) |
| | | .bind('mousedown', onDragStart); |
| | | .mousedown(onDragStart); |
| | | |
| | | if (this.horizontal) { |
| | | var top = this.p1pos.top + this.p1.outerHeight(); |
| | |
| | | this.resize = function() |
| | | { |
| | | if (this.horizontal) { |
| | | this.p1.css('height', Math.floor(this.pos - this.p1pos.top - this.halfsize) + 'px'); |
| | | this.p2.css('top', Math.ceil(this.pos + this.halfsize + 2) + 'px'); |
| | | this.p1.css('height', Math.floor(this.pos - this.p1pos.top - Math.floor(this.halfsize)) + 'px'); |
| | | this.p2.css('top', Math.ceil(this.pos + Math.ceil(this.halfsize) + 2) + 'px'); |
| | | this.handle.css('top', Math.round(this.pos - this.halfsize + this.offset)+'px'); |
| | | if (bw.ie) { |
| | | var new_height = parseInt(this.parent.outerHeight(), 10) - parseInt(this.p2.css('top'), 10) - (bw.ie8 ? 2 : 0); |
| | |
| | | } |
| | | } |
| | | else { |
| | | this.p1.css('width', Math.floor(this.pos - this.p1pos.left - this.halfsize) + 'px'); |
| | | this.p2.css('left', Math.ceil(this.pos + this.halfsize) + 'px'); |
| | | this.p1.css('width', Math.floor(this.pos - this.p1pos.left - Math.floor(this.halfsize)) + 'px'); |
| | | this.p2.css('left', Math.ceil(this.pos + Math.ceil(this.halfsize)) + 'px'); |
| | | this.handle.css('left', Math.round(this.pos - this.halfsize + this.offset + 3)+'px'); |
| | | if (bw.ie) { |
| | | var new_width = parseInt(this.parent.outerWidth(), 10) - parseInt(this.p2.css('left'), 10) ; |
| | |
| | | me.drag_active = true; |
| | | |
| | | // start listening to mousemove events |
| | | $(document).bind('mousemove.'+this.id, onDrag).bind('mouseup.'+this.id, onDragStop); |
| | | $(document).on('mousemove.' + this.id, onDrag).on('mouseup.' + this.id, onDragStop); |
| | | |
| | | // enable dragging above iframes |
| | | $('iframe').each(function(i, elem) { |
| | |
| | | |
| | | if (me.horizontal) { |
| | | if (((pos.y - me.halfsize) > me.p1pos.top) && ((pos.y + me.halfsize) < (me.p2pos.top + me.p2.outerHeight()))) { |
| | | me.pos = Math.max(me.min, pos.y - me.offset); |
| | | me.pos = Math.max(me.min, pos.y - Math.max(0, me.offset)); |
| | | if (me.pos > me.min) |
| | | me.pos = Math.min(me.pos, me.parent.height() - me.min); |
| | | |
| | |
| | | } |
| | | else { |
| | | if (((pos.x - me.halfsize) > me.p1pos.left) && ((pos.x + me.halfsize) < (me.p2pos.left + me.p2.outerWidth()))) { |
| | | me.pos = Math.max(me.min, pos.x - me.offset); |
| | | me.pos = Math.max(me.min, pos.x - Math.max(0, me.offset)); |
| | | if (me.pos > me.min) |
| | | me.pos = Math.min(me.pos, me.parent.width() - me.min); |
| | | |
| | |
| | | document.body.style.webkitUserSelect = 'auto'; |
| | | |
| | | // cancel the listening for drag events |
| | | $(document).unbind('.'+me.id); |
| | | $(document).off('.' + me.id); |
| | | me.drag_active = false; |
| | | |
| | | // remove temp divs |
| | |
| | | return rcube_splitter._instances[id]; |
| | | }; |
| | | |
| | | // @license-end |
| | | // @license-end |