From 2e1367c7b20d4b673b227a7eb0a5df4674074d0b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 25 Jun 2018 11:03:52 +0000 Subject: [PATCH] Elastic: Fix various corner-cases in pretty select --- skins/elastic/ui.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js index eed398593..7d5bdf445 100644 --- a/skins/elastic/ui.js +++ b/skins/elastic/ui.js @@ -3042,15 +3042,27 @@ function rcube_elastic_ui() select = $(select); + var select_ident = 'select' + select.attr('id') + select.attr('name'); + var is_menu_open = function() { + // Use proper window in cases when the select element intialized + // inside an iframe is then used in a dialog inside a parent's window + // For some reason we can't access data-button property in cross-window + // case, we use data-ident attribute instead + var win = select[0].ownerDocument.defaultView; + if (win.$('.select-menu .listing').data('ident') == select_ident) { + return true; + } + }; + var close_func = function() { - var open = $('.select-menu').length; + var open = is_menu_open(); select.popover('dispose').focus(); return !open; }; var open_func = function(e) { var items = [], - dialog = select.parents('.ui-dialog')[0], + dialog = select.closest('.ui-dialog')[0], min_width = select.outerWidth(), max_height = $(document.body).height() - 75, max_width = $(document.body).width() - 20, @@ -3077,8 +3089,8 @@ function rcube_elastic_ui() }); var list = $('