function init() {
// TODO watch select2-options
- element.select2(scope.crmUiSelect || {});
+ element.crmSelect2(scope.crmUiSelect || {});
if (ngModel) {
element.on('change', refreshModel);
$timeout(ngModel.$render);
.crm-container .crm-action-menu .select2-default span.select2-chosen {
color: #2786C2;
}
+.crm-container .select2-container[class*=" fa-"]:before {
+ display: none;
+}
+
/* Restore this property otherwise our css overrides it */
.select2-search input {
box-sizing: border-box;
// add disabled property for option values
$('option[value^=crm_disabled_opt]', this).attr('disabled', 'disabled');
- // Placeholder icon
+ // Placeholder icon - total hack hikacking the escapeMarkup function but select2 3.5 dosn't have any other callbacks for this :(
if ($el.is('[class*=fa-]')) {
- iconClass = $el.attr('class').match(/(fa-\S*)/)[1];
- $el.removeClass(iconClass);
+ settings.escapeMarkup = function (m) {
+ var out = _.escape(m),
+ placeholder = settings.placeholder || $el.data('placeholder') || $el.attr('placeholder') || $('option[value=""]', $el).text();
+ if (m.length && placeholder === m) {
+ iconClass = $el.attr('class').match(/(fa-\S*)/)[1];
+ out = '<i class="crm-i ' + iconClass + '"></i> ' + out;
+ }
+ return out;
+ };
}
// Defaults for single-selects
$el.addClass('crm-ajax-select');
}
$el.select2(settings);
- if (iconClass) {
- window.setTimeout(function() {
- $el.select2('container').find('span.select2-chosen').prepend('<i class="crm-i ' + iconClass + '"></i> ');
- }, 10);
- }
});
};