From f7b92fcd3bc94b0e519dad55f55b73a4cc9ac963 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 30 Jan 2014 14:36:19 -0800 Subject: [PATCH] CRM-13966 - Add Select2.js and basic widget support --- CRM/Core/Resources.php | 3 +++ js/Common.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index a871e774e4..9a79b94b1c 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -538,6 +538,9 @@ class CRM_Core_Resources { "packages/jquery/jquery-ui/js/jquery-ui-1.10.3.custom$min.js", "packages/jquery/jquery-ui/css/black-tie/jquery-ui-1.10.3.custom$min.css", + "packages/jquery/plugins/select2/select2$min.js", + "packages/jquery/plugins/select2/select2.css", + "packages/jquery/plugins/jquery.autocomplete.js", "packages/jquery/css/jquery.autocomplete.css", diff --git a/js/Common.js b/js/Common.js index 322bd8e8dc..c36dc94220 100644 --- a/js/Common.js +++ b/js/Common.js @@ -253,9 +253,13 @@ CRM.validate = CRM.validate || { functions: [] }; +// https://github.com/ivaynberg/select2/pull/2090 +$.fn.select2.defaults.width = 'resolve'; + (function ($, undefined) { "use strict"; + // Initialize widgets $(document).on('crmLoad', function(e) { $('table.row-highlight', e.target) .off('.rowHighlight') @@ -272,6 +276,10 @@ CRM.validate = CRM.validate || { target.toggleClass('crm-row-selected', $(this).is(':checked')); }) .find('input.select-row:checked').parents('tr').addClass('crm-row-selected'); + $('.crm-select2', e.target).each(function() { + var options = $(this).data('select2') || {}; + $(this).removeClass('crm-select2').select2(options); + }); }); /** -- 2.25.1