CRM-13966 - Add Select2.js and basic widget support
authorColeman Watts <coleman@civicrm.org>
Thu, 30 Jan 2014 22:36:19 +0000 (14:36 -0800)
committerColeman Watts <coleman@civicrm.org>
Thu, 30 Jan 2014 22:36:19 +0000 (14:36 -0800)
CRM/Core/Resources.php
js/Common.js

index a871e774e4c18c8cd7b8297399be18c7b82557a9..9a79b94b1ccbdcd62308a0c3a366e9e4cfa08c60 100644 (file)
@@ -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",
 
index 322bd8e8dc2c03af094cda1d6bd32bfb1c0218c1..c36dc94220cc21a78cb47286db70cb42676aad54 100644 (file)
@@ -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);
+    });
   });
 
   /**