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;
};
};
}
- // 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 (searching happens within select2-drop for single selects, but within the element for multiselects; this handles both)
+ if ($('#select2-drop.collapsible-optgroups-enabled .select2-search input.select2-input, .select2-dropdown-open.collapsible-optgroups .select2-search-field 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])')) {
$(this).addClass('crm-tooltip-down');
}
if (!$(this).children('.crm-tooltip-wrapper').length) {
+ var tooltipContents = $(this)[0].hasAttribute('data-tooltip-url') ? $(this).attr('data-tooltip-url') : this.href;
$(this).append('<div class="crm-tooltip-wrapper"><div class="crm-tooltip"></div></div>');
$(this).children().children('.crm-tooltip')
.html('<div class="crm-loading-element"></div>')
- .load(this.href);
+ .load(tooltipContents);
}
})
.on('mouseleave', 'a.crm-summary-link', function () {