diff options
author | thomascube <thomas@roundcube.net> | 2011-12-16 19:23:04 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2011-12-16 19:23:04 +0000 |
commit | 74d4c7f9ada668d0bf53361a407b00be7d10488c (patch) | |
tree | 7c86fa86be25a8115aa1751a05280f38c0a0b038 /skins/larry/ui.js | |
parent | f94e442469deca30b39f3fa08aade83cbd0ede70 (diff) |
Setup dialogs (using jquery UI) and compose form for Larry
Diffstat (limited to 'skins/larry/ui.js')
-rw-r--r-- | skins/larry/ui.js | 169 |
1 files changed, 164 insertions, 5 deletions
diff --git a/skins/larry/ui.js b/skins/larry/ui.js index a995610ab..ef4b65a5a 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -1,5 +1,14 @@ /** * Roundcube functions for default skin interface + * + * Copyright (c) 2011, The Roundcube Dev Team + * + * The contents are subject to the Creative Commons Attribution-ShareAlike + * 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. + * + * $Id$ */ @@ -21,11 +30,15 @@ function rcube_mail_ui() var me = this; var mailviewsplit; + var compose_headers = {}; // export public methods this.init = init; this.show_popup = show_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; /** * @@ -33,11 +46,16 @@ function rcube_mail_ui() function init() { if (rcmail.env.task == 'mail') { - rcmail.gui_object('message_dragmenu', 'dragmessagemenu'); - rcmail.addEventListener('menu-open', function(){ show_popup('listoptions'); }); + rcmail.addEventListener('menu-open', show_listoptions); rcmail.addEventListener('menu-save', save_listoptions); -// rcmail.addEventListener('aftersend-attachment', 'uploadmenu', rcmail_ui); -// rcmail.addEventListener('aftertoggle-editor', 'resize_compose_body_ev', rcmail_ui); + rcmail.addEventListener('aftersend-attachment', show_uploadform); + rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 100); }); + + var dragmenu = $('#dragmessagemenu'); + if (dragmenu.length) { + rcmail.gui_object('message_dragmenu', 'dragmessagemenu'); + popups.dragmessagemenu = dragmenu; + } var previewframe = $('#mailpreviewframe').is(':visible'); $('#mailpreviewtoggle').addClass(previewframe ? 'enabled' : 'closed').click(function(e){ toggle_preview_pane(e); return false }); @@ -47,6 +65,19 @@ function rcube_mail_ui() if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') { layout_messageview(); } + else if (rcmail.env.action == 'compose') { + layout_composeview(); + + $('#composeoptionstoggle').click(function(){ + $(this).toggleClass('enabled'); + $('#composeoptions').toggle(); + layout_composeview(); + return false; + }); + + new rcube_splitter({ id:'composesplitterv', p1:'#composeview-left', p2:'#composeview-right', + orientation:'v', relative:true, start:248, min:150, size:12 }).init(); + } else if (rcmail.env.action == 'list' || !rcmail.env.action) { mailviewsplit = new rcube_splitter({ id:'mailviewsplitter', p1:'#mailview-top', p2:'#mailview-bottom', orientation:'h', relative:true, start:310, min:150, size:0, offset:-22 }); @@ -113,6 +144,9 @@ function rcube_mail_ui() if (rcmail.env.task == 'mail' && (rcmail.env.action == 'show' || rcmail.env.action == 'preview')) { layout_messageview(); } + if (rcmail.env.task == 'mail' && rcmail.env.action == 'compose') { + layout_composeview(); + } } /** @@ -142,6 +176,28 @@ function rcube_mail_ui() } + function layout_composeview() + { + var body = $('#composebody'), + bottom = $('#composeview-bottom'), + w, h; + + bottom.css('height', (bottom.parent().height() - bottom.position().top) + 'px'); + + w = body.parent().width() - 8; + h = body.parent().height() - 36; + body.width(w).height(h); + + if (window.tinyMCE && tinyMCE.get('composebody')) { + $('#composebody_tbl').width((w+6)+'px').height(''); + $('#composebody_ifr').width((w+6)+'px').height((h-54)+'px'); + } + else { + $('#googie_edit_layer').height(h+'px'); + } + } + + /** * Trigger for popup menus */ @@ -320,9 +376,55 @@ function rcube_mail_ui() /** * */ + function show_listoptions() + { + var $dialog = $('#listoptions'); + + // close the dialog + if ($dialog.is(':visible')) { + $dialog.dialog('close'); + return; + } + + // set form values + $('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').prop('checked', true); + $('input[name="sort_ord"][value="DESC"]').prop('checked', rcmail.env.sort_order == 'DESC'); + $('input[name="sort_ord"][value="ASC"]').prop('checked', rcmail.env.sort_order != 'DESC'); + $('input[name="view"][value="thread"]').prop('checked', rcmail.env.threading ? true : false); + $('input[name="view"][value="list"]').prop('checked', rcmail.env.threading ? false : true); + + // list columns + var found, cols = $('input[name="list_col[]"]'); + for (var i=0; i < cols.length; i++) { + if (cols[i].value != 'from') { + found = $.inArray(cols[i].value, rcmail.env.coltypes) != -1; + } + else { + found = ($.inArray('from', rcmail.env.coltypes) != -1 + || $.inArray('to', rcmail.env.coltypes) != -1); + } + $(cols[i]).prop('checked', found); + } + + $dialog.dialog({ + modal: true, + resizable: false, + closeOnEscape: true, + title: null, + close: function() { + $dialog.dialog('destroy').hide(); + }, + width: 650 + }).show(); + } + + + /** + * + */ function save_listoptions() { - show_popupmenu('listoptions', false); + $('#listoptions').dialog('close'); var sort = $('input[name="sort_col"]:checked').val(), ord = $('input[name="sort_ord"]:checked').val(), @@ -381,6 +483,63 @@ function rcube_mail_ui() } }); } + + + function show_uploadform() + { + var $dialog = $('#upload-dialog'); + + // close the dialog + if ($dialog.is(':visible')) { + $dialog.dialog('close'); + return; + } + + $dialog.dialog({ + modal: true, + resizable: false, + closeOnEscape: true, + title: $dialog.attr('title'), + close: function() { + try { $('#upload-dialog form').get(0).reset(); } + catch(e){ } // ignore errors + + $dialog.dialog('destroy').hide(); + }, + width: 480 + }).show(); + + if (!document.all) + $('input[type=file]', $dialog).click(); + } + + /** + * + */ + function show_header_row(which) + { + if (compose_headers[which]) + $('#_' + which).val(compose_headers[which]); + $('#compose-' + which).show(); + $('#' + which + '-link').hide(); + this.resize_compose_body(); + return false; + } + + /** + * + */ + function hide_header_row(which) + { + // copy and clear field value + var field = $('#_' + which); + compose_headers[which] = field.val(); + field.val(''); + + $('#compose-' + which).hide(); + $('#' + which + '-link').show(); + this.resize_compose_body(); + } } |