Small code improvements

pull/7051/head
Aleksander Machniak 5 years ago
parent c5c5a9325c
commit 6aab238773

@ -119,7 +119,7 @@ function rcube_elastic_ui()
// Intercept jQuery-UI dialogs... // Intercept jQuery-UI dialogs...
$.ui && $.widget('ui.dialog', $.ui.dialog, { $.ui && $.widget('ui.dialog', $.ui.dialog, {
open: function() { open: function() {
// .. to unify min width for iframe'd dialogs // ... to unify min width for iframe'd dialogs
if ($(this.element).is('.iframe')) { if ($(this.element).is('.iframe')) {
this.options.width = Math.max(576, this.options.width); this.options.width = Math.max(576, this.options.width);
} }
@ -152,20 +152,20 @@ function rcube_elastic_ui()
} }
} }
else if (!is_framed) { else if (!is_framed) {
title = $('.boxtitle', layout.content).first().detach().text(); title = layout.content.find('.boxtitle').first().detach().text();
if (!title) { if (!title) {
title = $('h1.voice').first().text(); title = $('h1.voice').first().text();
} }
if (title) { if (title) {
$('.header > .header-title', layout.content).text(title); layout.content.find('.header > .header-title').text(title);
} }
} }
// Add content frame toolbar in the footer, for content buttons and navigation // Add content frame toolbar in the footer, for content buttons and navigation
if (!is_framed && layout.content.length && !$(layout.content).is('.no-navbar') if (!is_framed && layout.content.length && !layout.content.is('.no-navbar')
&& !$(layout.content).children('.frame-content').length && !layout.content.children('.frame-content').length
) { ) {
env.frame_nav = $('<div class="footer menu toolbar content-frame-navigation hide-nav-buttons">') env.frame_nav = $('<div class="footer menu toolbar content-frame-navigation hide-nav-buttons">')
.append($('<a class="button prev">') .append($('<a class="button prev">')
@ -1181,7 +1181,7 @@ function rcube_elastic_ui()
title = $('h1.voice').text() || $('title').text() || ''; title = $('h1.voice').text() || $('title').text() || '';
} }
$('.header > .header-title', layout.content).text(title); layout.content.find('.header > .header-title').text(title);
}; };
// display or reset the content frame // display or reset the content frame
@ -2096,37 +2096,33 @@ function rcube_elastic_ui()
}; };
// convert content toolbar to a popup list // convert content toolbar to a popup list
if (layout.content) { layout.content.find('.header > .menu').each(function() {
$('.header > .menu', layout.content).each(function() { var toolbar = $(this);
var toolbar = $(this);
toolbar.children().each(function() { button_func(this, items); }); toolbar.children().each(function() { button_func(this, items); });
toolbar.remove(); toolbar.remove();
}); });
}
// convert list toolbar to a popup list // convert list toolbar to a popup list
if (layout.list) { layout.list.find('.header > .menu').each(function() {
$('.header > .menu', layout.list).each(function() { var toolbar = $(this);
var toolbar = $(this);
list_mark = toolbar.next(); list_mark = toolbar.next();
toolbar.children().each(function() { toolbar.children().each(function() {
if (meta.mode != 'large') { if (meta.mode != 'large') {
// TODO: Would be better to set this automatically on submenu display // TODO: Would be better to set this automatically on submenu display
// i.e. in show/shown event (see popup_init()), if possible // i.e. in show/shown event (see popup_init()), if possible
$(this).data('popup-pos', 'right'); $(this).data('popup-pos', 'right');
} }
// add items to the content menu too
button_func(this, items, true);
button_func(this, list_items);
});
toolbar.remove(); // add items to the content menu too
button_func(this, items, true);
button_func(this, list_items);
}); });
}
toolbar.remove();
});
// special elements to clone and add to the toolbar (mobile only) // special elements to clone and add to the toolbar (mobile only)
$('ul[data-menu="toolbar-small"] > li > a').each(function() { $('ul[data-menu="toolbar-small"] > li > a').each(function() {
@ -2169,13 +2165,11 @@ function rcube_elastic_ui()
.append($('<ul>').attr(menu_attrs).data('popup-parent', container).append(items)) .append($('<ul>').attr(menu_attrs).data('popup-parent', container).append(items))
.append(menu_button); .append(menu_button);
if (layout.list.length) { // bind toolbar menu with the menu button in the list header
// bind toolbar menu with the menu button in the list header layout.list.find('a.toolbar-menu-button').click(function(e) {
$('a.toolbar-menu-button', layout.list).click(function(e) { e.stopPropagation();
e.stopPropagation(); menu_button.click();
menu_button.click(); });
});
}
} }
}; };
@ -2356,7 +2350,7 @@ function rcube_elastic_ui()
// the DOM (https://github.com/twbs/bootstrap/issues/20219) // the DOM (https://github.com/twbs/bootstrap/issues/20219)
// making our menus to not update buttons state. // making our menus to not update buttons state.
// Work around this by attaching it back to the DOM tree. // Work around this by attaching it back to the DOM tree.
popup.appendTo(popup.data('popup-parent') || document.body); .appendTo(popup.data('popup-parent') || document.body);
} }
// close orphaned popovers, for some reason there are sometimes such dummy elements left // close orphaned popovers, for some reason there are sometimes such dummy elements left

Loading…
Cancel
Save