/** * Roundcube webmail functions for the Elastic skin * * Copyright (c) 2017, 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. * * @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0 */ "use strict"; function rcube_elastic_ui() { var ref = this, mode = 'normal', // one of: large, normal, small, phone touch = false, is_framed = rcmail.is_framed(), env = { config: { standard_windows: rcmail.env.standard_windows, message_extwin: rcmail.env.message_extwin, compose_extwin: rcmail.env.compose_extwin, help_open_extwin: rcmail.env.help_open_extwin }, small_screen_config: { standard_windows: true, message_extwin: false, compose_extwin: false, help_open_extwin: false } }, menus = {}, content_buttons = [], frame_buttons = [], layout = { menu: $('#layout > .menu'), sidebar: $('#layout > .sidebar'), list: $('#layout > .list'), content: $('#layout > .content'), }, buttons = { menu: $('a.menu-button'), back_sidebar: $('a.back-sidebar-button'), back_list: $('a.back-list-button'), back_content: $('a.back-content-button'), }; // Public methods this.register_content_buttons = register_content_buttons; this.menu_hide = menu_hide; this.menu_toggle = menu_toggle; this.about_dialog = about_dialog; this.headers_dialog = headers_dialog; this.spellmenu = spellmenu; this.searchmenu = searchmenu; this.headersmenu = headersmenu; this.attachmentmenu = attachmentmenu; this.mailtomenu = mailtomenu; this.show_list = show_list; this.show_sidebar = show_sidebar; this.smart_field_init = smart_field_init; this.smart_field_reset = smart_field_reset; this.form_errors = form_errors; this.switch_nav_list = switch_nav_list; this.popup_init = popup_init; // Initialize layout layout_init(); // Convert some elements to Bootstrap style bootstrap_style(); // Initialize responsive toolbars (have to be before popups init) toolbar_init(); // Initialize content frame and list handlers content_frame_init(); // Initialize menu dropdowns dropdowns_init(); // Setup various UI elements setup(); // Update layout after initialization resize(); /** * Setup procedure */ function setup() { var title, form, content_buttons = []; // Initialize search forms (in list headers) $('.header > .searchbar').each(function() { searchbar_init(this); }); $('.header > .searchfilterbar').each(function() { searchfilterbar_init(this); }); // Intercept jQuery-UI dialogs to re-style them if ($.ui) { $.widget('ui.dialog', $.ui.dialog, { open: function() { this._super(); dialog_open(this); return this; } }); } // menu/sidebar/list button buttons.menu.on('click', function() { show_menu(); return false; }); buttons.back_sidebar.on('click', function() { show_sidebar(); return false; }); buttons.back_list.on('click', function() { show_list(); return false; }); buttons.back_content.on('click', function() { show_content(true); return false; }); $('body').on('click', function() { if (mode == 'phone') layout.menu.addClass('hidden'); }); // Set content frame title in parent window (exclude ext-windows and dialog frames) if (is_framed && !rcmail.env.extwin && !parent.$('.ui-dialog:visible').length) { if (title = $('h1.voice:first').text()) { parent.$('#layout > .content > .header > .header-title').text(title); } } else if (!is_framed) { title = $('.boxtitle:first', layout.content).detach().text(); if (!title) { title = $('h1.voice:first').text(); } if (title) { $('.header > .header-title', layout.content).text(title); } } // Add content frame toolbar in the footer, for content buttons and navigation if (!is_framed && layout.content.length) { env.frame_nav = $('