X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2FCommon.js;h=f5601ed8c0df7118541b84ca7b8c33e7123131f5;hb=1a10d7ed9e639131ccd758c5130a06c26101037a;hp=1db1f25885f7f037af559efa45f3b0a83e223579;hpb=5348fd413ef5b54e1080c750dc74709b66027293;p=civicrm-core.git diff --git a/js/Common.js b/js/Common.js index 1db1f25885..f5601ed8c0 100644 --- a/js/Common.js +++ b/js/Common.js @@ -185,7 +185,7 @@ if (!CRM.vars) CRM.vars = {}; // Workaround for https://github.com/ivaynberg/select2/issues/1246 $.ui.dialog.prototype._allowInteraction = function(e) { - return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop, .cke_dialog, #civicrm-menu').length; + return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop, .cke_dialog, .ck-balloon-panel, #civicrm-menu').length; }; // Implements jQuery hook.prop @@ -368,6 +368,9 @@ if (!CRM.vars) CRM.vars = {}; settings.width = '' + parseInt(percentage+gap-((screenWidth - 700)/7*(gap)/100), 10) + '%'; } } + if (settings.dialogClass && !_.includes(settings.dialogClass, 'crm-container')) { + settings.dialogClass += ' crm-container'; + } return settings; }; @@ -474,12 +477,36 @@ if (!CRM.vars) CRM.vars = {}; }; } - // Use description as title for each option - $el.on('select2-loaded.crmSelect2', function() { - $('.crm-select2-row-description', '#select2-drop').each(function() { - $(this).closest('.select2-result-label').attr('title', $(this).text()); + $el + .on('select2-loaded.crmSelect2', function() { + // Use description as title for each option + $('.crm-select2-row-description', '#select2-drop').each(function() { + $(this).closest('.select2-result-label').attr('title', $(this).text()); + }); + // Collapsible optgroups should be expanded when searching + if ($('#select2-drop.collapsible-optgroups-enabled .select2-search input.select2-input').val()) { + $('#select2-drop.collapsible-optgroups-enabled li.select2-result-with-children') + .addClass('optgroup-expanded'); + } + }) + // Handle collapsible optgroups + .on('select2-open', function(e) { + var isCollapsible = $(e.target).hasClass('collapsible-optgroups'); + $('#select2-drop') + .off('.collapseOptionGroup') + .toggleClass('collapsible-optgroups-enabled', isCollapsible); + if (isCollapsible) { + $('#select2-drop') + .on('click.collapseOptionGroup', '.select2-result-with-children > .select2-result-label', function() { + $(this).parent().toggleClass('optgroup-expanded'); + }) + // If the first item in the list is an optgroup, expand it + .find('li.select2-result-with-children:first-child').addClass('optgroup-expanded'); + } + }) + .on('select2-close', function() { + $('#select2-drop').off('.collapseOptionGroup').removeClass('collapsible-optgroups-enabled'); }); - }); // Defaults for single-selects if ($el.is('select:not([multiple])')) { @@ -756,6 +783,7 @@ if (!CRM.vars) CRM.vars = {}; } markup += '
' + (row.color ? ' ' : '') + + (row.icon ? ' ' : '') + _.escape((row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : '')) + '
' + '
';