/** * Roundcube webmail functions for the Elastic skin * * Copyright (c) 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 */ log = function() { return Function.prototype.bind.call(console.log, console);}(); warn = function() { return Function.prototype.bind.call(console.warn, console);}(); error = function() { return Function.prototype.bind.call(console.error, console);}(); "use strict"; function rcube_elastic_ui() { var prefs, ref = this, mode = 'normal', // one of: large, normal, small, phone color_mode = 'light', // 'light' or 'dark' touch = false, ios = false, popups_close_lock, 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 }, checkboxes: 0, 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.task-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.menu_destroy = menu_destroy; this.popup_init = popup_init; this.about_dialog = about_dialog; this.headers_dialog = headers_dialog; this.import_dialog = import_dialog; this.props_dialog = props_dialog; //this.headers_show = headers_show; this.spellmenu = spellmenu; this.searchmenu = searchmenu; this.headersmenu = headersmenu; this.header_reset = header_reset; // this.compose_status = compose_status; this.attachmentmenu = attachmentmenu; this.mailtomenu = mailtomenu; this.recipient_selector = recipient_selector; 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.searchbar_init = searchbar_init; this.pretty_checkbox = pretty_checkbox; this.pretty_select = pretty_select; this.datepicker_init = datepicker_init; //this.bootstrap_style = bootstrap_style; //this.toggle_list_selection = toggle_list_selection; this.get_screen_mode = get_screen_mode; this.screen_resize_headers = screen_resize_headers; this.is_mobile = is_mobile; this.is_touch = is_touch; // Detect screen size/mode screen_mode(); // Initialize layout layout_init(); // Convert some elements to Bootstrap style // bootstrap_style(); bootstrap_style_elastic2022() // 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 = []; // Intercept jQuery-UI dialogs... $.ui && $.widget('ui.dialog', $.ui.dialog, { open: function() { // ... to unify min width for iframe'd dialogs if ($(this.element).is('.iframe')) { this.options.width = Math.max(576, this.options.width); } this._super(); // ... to re-style them on dialog open dialog_open(this); return this; }, close: function() { this._super(); // ... to close custom select dropdowns on dialog close $('.select-menu:visible').remove(); return this; } }); // menu/sidebar/list button //buttons.menu.on('click', function() { app_menu(true); return false; }); //buttons.back_sidebar.on('click', function() { show_sidebar(); return false; }); buttons.menu.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; }); // Initialize search forms $('.searchbar').each(function() { searchbar_init(this); }); // 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:not(.constant)').text(title); } } else if (!is_framed) { title = layout.content.find('.boxtitle').first().detach().text(); if (!title) { title = $('h1.voice').first().text(); } if (title) { layout.content.find('.header > .header-title').text(title); } } // Add content frame toolbar in the footer, for content buttons and navigation /* if (!is_framed && layout.content.length && !layout.content.is('.no-navbar') && !layout.content.children('.frame-content').length ) { env.frame_nav = $('