(function ($) {
$.extend($.fn.select2.defaults, {
formatNoMatches: function () {
return "No matches found";
},
formatInputTooShort: function (input, min) {
var n = min - input.length;
return "Please enter " + n + " more character" + (n == 1 ? "" : "s");
},
formatInputTooLong: function (input, max) {
var n = input.length - max;
return "Please enter " + n + " less character" + (n == 1? "" : "s");
},
formatSelectionTooBig: function (limit) {
return "You can only select " + limit + " item" + (limit == 1 ? "" : "s");
},
formatLoadMore: function (pageNumber) {
return "Loading more results...";
},
formatSearching: function () {
return "Searching...";
}
});
var processor = function ($context) {
$('select[data-select2-config]', $context).each(function (i, e) {
var $e = $(e);
var $data = $.extend(
{
autoSubmit: false,
escapeMarkup: function (m) {
return '' + m;
}
},
$e.data('select2-config')
);
if ($.type($data['selectionFormat']) != 'undefined') {
$data.formatSelection = function (object, container) {
var template = $data['selectionFormat'];
var templateVars = $.extend({}, $(object.element).data('template-vars'));
for (var a in templateVars) {
template = template.replace(new RegExp(a, 'g'), templateVars[a]);
}
return template;
};
}
$e.select2($data);
$e.off('change.select2');
if ($data.autoSubmit != false) {
$e.on('change.select2', function (e) {
$(this).closest('form').trigger('submit');
});
}
$e.on('change.select2.display', function (e) {
var $$ = $(this);
if ($(':selected', $$).length > 0) {
$$.prevUntil('.select2-selected-teaser').last().prev().slideDown('show');
} else {
$$.prevUntil('.select2-selected-teaser').last().prev().slideUp('show');
}
});
$e.trigger('change.select2.display');
});
};
processor($(document));
$(document).on('mutation', function (e, context) {
processor($(context));
});
})(jQuery);
(function ($) {
$(function () {
var processor = function ($context) {
$('select.researchmicrotrendreference', $context).each(function (i, e) {
var $e = $(this);
var $button = $('Add\u0020to\u0020research');
$button.on('click', function (e) {
e.preventDefault();
$e.select2('open');
});
var $container = $($e.select2('container'));
$container.after($button);
});
};
processor($(document));
$(document).on('mutation', function (e, context) {
processor($(context));
});
});
})(jQuery);
(function ($) {
$(function () {});
})(jQuery);