diff options
author | Hugues Hiegel <root@paranoid> | 2014-08-05 16:46:22 +0200 |
---|---|---|
committer | Hugues Hiegel <root@paranoid> | 2014-08-05 16:46:22 +0200 |
commit | 59478e06c25303a790a0840ab2ac30662c4ef781 (patch) | |
tree | 8d5e964a8f94adaef41efebb0597629f11495c42 /skins/larry/ui.js | |
parent | 7c494b677f9e470ee0d32e62cfa8dc709f39e748 (diff) |
c'est la merde..working
Diffstat (limited to 'skins/larry/ui.js')
-rw-r--r-- | skins/larry/ui.js | 217 |
1 files changed, 49 insertions, 168 deletions
diff --git a/skins/larry/ui.js b/skins/larry/ui.js index ae14d81b2..19f8a516a 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -17,9 +17,8 @@ function rcube_mail_ui() var popupconfig = { forwardmenu: { editable:1 }, searchmenu: { editable:1, callback:searchmenu }, - attachmentmenu: { }, listoptions: { editable:1 }, - dragmenu: { sticky:1 }, + dragmessagemenu: { sticky:1 }, groupmenu: { above:1 }, mailboxmenu: { above:1 }, spellmenu: { callback: spellmenu }, @@ -38,12 +37,10 @@ function rcube_mail_ui() this.init_tabs = init_tabs; this.show_about = show_about; this.show_popup = show_popup; - this.add_popup = add_popup; this.set_searchmod = set_searchmod; this.show_uploadform = show_uploadform; this.show_header_row = show_header_row; this.hide_header_row = hide_header_row; - this.update_quota = update_quota; // set minimal mode on small screens (don't wait for document.ready) @@ -88,26 +85,20 @@ function rcube_mail_ui() /*** mail task ***/ if (rcmail.env.task == 'mail') { - rcmail.addEventListener('menu-open', menu_open); - rcmail.addEventListener('menu-save', menu_save); + rcmail.addEventListener('menu-open', show_listoptions); + rcmail.addEventListener('menu-save', save_listoptions); rcmail.addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') }); var dragmenu = $('#dragmessagemenu'); if (dragmenu.length) { - rcmail.gui_object('dragmenu', 'dragmessagemenu'); - popups.dragmenu = dragmenu; + rcmail.gui_object('message_dragmenu', 'dragmessagemenu'); + popups.dragmessagemenu = dragmenu; } 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(); }); - $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(); return false }); - - // add menu link for each attachment - $('#attachment-list > li').each(function() { - $(this).append($('<a class="drop">').click(function() { attachmentmenu(this); })); - }); + $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(this); return false }); } else if (rcmail.env.action == 'compose') { rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 200); }); @@ -116,14 +107,10 @@ function rcube_mail_ui() layout_composeview(); // Show input elements with non-empty value - var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto']; - for (f=0; f < fields.length; f++) { - v = fields[f]; field = $('#_'+v); - if (field.length) { - field.on('change', {v: v}, function(e) { if (this.value) show_header_row(e.data.v, true); }); - if (field.val() != '') - show_header_row(v, true); - } + var field, fields = ['cc', 'bcc', 'replyto', 'followupto']; + for (var f=0; f < fields.length; f++) { + if ((field = $('#_'+fields[f])) && field.length && field.val() != '') + show_header_row(fields[f], true); } $('#composeoptionstoggle').click(function(){ @@ -155,12 +142,6 @@ function rcube_mail_ui() 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); - } - else if (rcmail.env.action == 'get') { - new rcube_splitter({ id:'mailpartsplitterv', p1:'#messagepartheader', p2:'#messagepartcontainer', - orientation:'v', relative:true, start:226, min:150, size:12}).init(); } if ($('#mailview-left').length) { @@ -199,8 +180,6 @@ function rcube_mail_ui() /*** addressbook task ***/ else if (rcmail.env.task == 'addressbook') { rcmail.addEventListener('afterupload-photo', show_uploadform); - rcmail.addEventListener('beforepushgroup', push_contactgroup); - rcmail.addEventListener('beforepopgroup', pop_contactgroup); if (rcmail.env.action == '') { new rcube_splitter({ id:'addressviewsplitterd', p1:'#addressview-left', p2:'#addressview-right', @@ -210,12 +189,12 @@ function rcube_mail_ui() new rcube_scroller('#directorylist-content', '#directorylist-header', '#directorylist-footer'); } + } - var dragmenu = $('#dragcontactmenu'); - if (dragmenu.length) { - rcmail.gui_object('dragmenu', 'dragcontactmenu'); - popups.dragmenu = dragmenu; - } + // set min-width to show all toolbar buttons + var screen = $('.minwidth'); + if (screen.length) { + screen.css('min-width', $('.toolbar').width() + $('#quicksearchbar').parent().width() + 20); } // turn a group of fieldsets into tabs @@ -229,7 +208,6 @@ function rcube_mail_ui() } var select = $(this), - parent = select.parent(), height = Math.max(select.height(), 26) - 2, width = select.width() - 22, title = $('option', this).first().text(); @@ -244,23 +222,19 @@ function rcube_mail_ui() overlay.children().width(width).height(height).css('line-height', (height - 1) + 'px'); + select.change(function() { + var val = $('option:selected', this).text(); + $(this).next().children().html(val); + }); + + var parent = select.parent(); if (parent.css('position') != 'absolute') parent.css('position', 'relative'); // re-set original select width to fix click action and options width in some browsers - select.width(overlay.width()) - .change(function() { - var val = $('option:selected', this).text(); - $(this).next().children().text(val); - }); + select.width(overlay.width()); }); - // set min-width to show all toolbar buttons - var screen = $('body > div.minwidth'); - if (screen.length) { - screen.css('min-width', $('.toolbar').width() + $('#quicksearchbar').width() + $('#searchfilter').width() + 30); - } - $(document.body) .bind('mouseup', body_mouseup) .bind('keyup', function(e){ @@ -316,36 +290,28 @@ function rcube_mail_ui() /** * Update UI on window resize */ - function resize(e) + function resize() { - // resize in intervals to prevent lags and double onresize calls in Chrome (#1489005) - var interval = e ? 10 : 0; - - if (rcmail.resize_timeout) - window.clearTimeout(rcmail.resize_timeout); + if (rcmail.env.task == 'mail') { + if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') + layout_messageview(); + else if (rcmail.env.action == 'compose') + layout_composeview(); + } - rcmail.resize_timeout = window.setTimeout(function() { - if (rcmail.env.task == 'mail') { - if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') - layout_messageview(); - else if (rcmail.env.action == 'compose') - layout_composeview(); + // make iframe footer buttons float if scrolling is active + $('body.iframe .footerleft').each(function(){ + var footer = $(this), + body = $(document.body), + floating = footer.hasClass('floating'), + overflow = body.outerHeight(true) > $(window).height(); + + if (overflow != floating) { + var action = overflow ? 'addClass' : 'removeClass'; + footer[action]('floating'); + body[action]('floatingbuttons'); } - - // make iframe footer buttons float if scrolling is active - $('body.iframe .footerleft').each(function(){ - var footer = $(this), - body = $(document.body), - floating = footer.hasClass('floating'), - overflow = body.outerHeight(true) > $(window).height(); - - if (overflow != floating) { - var action = overflow ? 'addClass' : 'removeClass'; - footer[action]('floating'); - body[action]('floatingbuttons'); - } - }); - }, interval); + }); } /** @@ -458,30 +424,6 @@ function rcube_mail_ui() } - function enable_command(p) - { - if (p.command == 'reply-list') { - var label = rcmail.gettext(p.status ? 'replylist' : 'replyall'); - if (rcmail.env.action == 'preview') - $('a.button.replyall').attr('title', label); - else - $('a.button.reply-all').text(label).attr('title', label); - } - } - - - /** - * Register a popup menu - */ - function add_popup(popup, config) - { - var obj = popups[popup] = $('#'+popup); - obj.appendTo(document.body); // move it to top for proper absolute positioning - - if (obj.length) - popupconfig[popup] = $.extend(popupconfig[popup] || {}, config || {}); - } - /** * Trigger for popup menus */ @@ -489,7 +431,7 @@ function rcube_mail_ui() { // auto-register menu object if (config || !popupconfig[popup]) - add_popup(popup, config); + popupconfig[popup] = $.extend(popupconfig[popup] || {}, config); var visible = show_popupmenu(popup, show), config = popupconfig[popup]; @@ -504,7 +446,7 @@ function rcube_mail_ui() { var obj = popups[popup], config = popupconfig[popup], - ref = $(config.link ? config.link : '#'+popup+'link'), + ref = $('#'+popup+'link'), above = config.above; if (!obj) { @@ -520,7 +462,7 @@ function rcube_mail_ui() else if (config.toggle && show && obj.is(':visible')) show = false; - if (show && ref.length) { + if (show && ref) { var parent = ref.parent(), win = $(window), pos; @@ -604,11 +546,8 @@ function rcube_mail_ui() mailviewsplit.handle.hide(); } - if (rcmail.message_list) { - if (visible && uid) - rcmail.message_list.scrollto(uid); - rcmail.message_list.resize(); - } + if (visible && uid && rcmail.message_list) + rcmail.message_list.scrollto(uid); rcmail.command('save-pref', { name:'preview_pane', value:(visible?1:0) }); } @@ -617,7 +556,7 @@ function rcube_mail_ui() /** * Switch between short and full headers display in message preview */ - function toggle_preview_headers() + function toggle_preview_headers(button) { $('#preview-shortheaders').toggle(); var full = $('#preview-allheaders').toggle(), @@ -646,19 +585,6 @@ function rcube_mail_ui() /**** popup callbacks ****/ - function menu_open(p) - { - if (p && p.props && p.props.menu == 'attachmentmenu') - show_popupmenu('attachmentmenu'); - else - show_listoptions(); - } - - function menu_save(prop) - { - save_listoptions(); - } - function searchmenu(show) { if (show && rcmail.env.search_mods) { @@ -689,21 +615,6 @@ function rcube_mail_ui() } } - function attachmentmenu(elem) - { - var id = elem.parentNode.id.replace(/^attach/, ''); - - $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) { - return rcmail.command('open-attachment', id, this); - }); - - $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() { - rcmail.command('download-attachment', id, this); - }); - - popupconfig.attachmentmenu.link = elem; - rcmail.command('menu-open', {menu: 'attachmentmenu', id: id}); - } function spellmenu(show) { @@ -772,8 +683,7 @@ function rcube_mail_ui() close: function() { $dialog.dialog('destroy').hide(); }, - minWidth: 500, - width: $dialog.width()+25 + width: 650 }).show(); } @@ -842,35 +752,6 @@ function rcube_mail_ui() }); } - function push_contactgroup(p) - { - // lets the contacts list swipe to the left, nice! - var table = $('#contacts-table'), - scroller = table.parent().css('overflow', 'hidden'); - - table.clone() - .css({ position:'absolute', top:'0', left:'0', width:table.width()+'px', 'z-index':10 }) - .appendTo(scroller) - .animate({ left: -(table.width()+5) + 'px' }, 300, 'swing', function(){ - $(this).remove(); - scroller.css('overflow', 'auto') - }); - } - - function pop_contactgroup(p) - { - // lets the contacts list swipe to the left, nice! - var table = $('#contacts-table'), - scroller = table.parent().css('overflow', 'hidden'), - clone = table.clone().appendTo(scroller); - - table.css({ position:'absolute', top:'0', left:-(table.width()+5) + 'px', width:table.width()+'px', height:table.height()+'px', 'z-index':10 }) - .animate({ left:'0' }, 300, 'linear', function(){ - clone.remove(); - $(this).css({ position:'relative', left:'0', width:'100%', height:'auto', 'z-index':1 }); - scroller.css('overflow', 'auto') - }); - } function show_uploadform() { @@ -881,7 +762,7 @@ function rcube_mail_ui() $dialog.dialog('close'); return; } - + // add icons to clone file input field if (rcmail.env.action == 'compose' && !$dialog.data('extended')) { $('<a>') |