Dialog & select2 improvements
authorColeman Watts <coleman@civicrm.org>
Tue, 1 Apr 2014 16:21:33 +0000 (12:21 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 1 Apr 2014 16:21:33 +0000 (12:21 -0400)
css/civicrm.css
js/Common.js
templates/CRM/Activity/Form/Task/FileOnCase.tpl
templates/CRM/Admin/Page/Tag.tpl
templates/CRM/Case/Form/Activity/LinkCases.tpl
templates/CRM/Case/Form/ActivityToCase.tpl
templates/CRM/Case/Form/CaseView.js
templates/CRM/Event/Form/Search/Common.tpl
templates/CRM/Mailing/Form/InsertTokens.tpl

index 963990d80fa09ba23db75427d9772b2f60b197e1..1901c8c72d325aa1fcfc84f319018e2ee56b3ac2 100644 (file)
@@ -3948,7 +3948,16 @@ div.m ul#civicrm-menu,
 .crm-container.ui-dialog {
   box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
 }
-
+.crm-container.ui-dialog.ui-draggable:before {
+  display:block;
+  content: " ";
+  width: 16px;
+  height: 16px;
+  background: url("../i/icons/jquery-ui-3E3E3E.png") no-repeat -80px -224px;
+  position: absolute;
+  bottom: 0;
+  right: 0;
+}
 .crm-container .ui-dialog-titlebar.ui-widget-header {
   background: url("../i/crm-button-bg.gif") repeat-x scroll left center #70716B;
   color: #F5F6F1;
index 6fc8544268315e2ecb4d9a59f963355f6ff34b1e..403cef2e21e54457ca3fdd08c2c2dd2aab81fa0e 100644 (file)
@@ -246,7 +246,7 @@ CRM.validate = CRM.validate || {
     return $(this).each(function () {
       var
         $el = $(this),
-        defaults = {allowClear: !$el.hasClass('required')};
+        settings = {allowClear: !$el.hasClass('required')};
       // quickform doesn't support optgroups so here's a hack :(
       $('option[value^=crm_optgroup]', this).each(function () {
         $(this).nextUntil('option[value^=crm_optgroup]').wrapAll('<optgroup label="' + $(this).text() + '" />');
@@ -254,12 +254,16 @@ CRM.validate = CRM.validate || {
       });
       // Defaults for single-selects
       if ($el.is('select:not([multiple])')) {
-        defaults.minimumResultsForSearch = 10;
+        settings.minimumResultsForSearch = 10;
         if ($('option:first', this).val() === '') {
-          defaults.placeholderOption = 'first';
+          settings.placeholderOption = 'first';
         }
       }
-      $el.select2($.extend(defaults, $el.data('select-params') || {}, options || {}));
+      $.extend(settings, $el.data('select-params') || {}, options || {});
+      if (settings.ajax) {
+        $el.addClass('crm-ajax-select');
+      }
+      $el.select2(settings);
     });
   };
 
@@ -279,7 +283,7 @@ CRM.validate = CRM.validate || {
       $el.data('select-params', $.extend({}, $el.data('select-params') || {}, options.select));
       $el.data('api-params', $.extend({}, $el.data('api-params') || {}, options.api));
       $el.data('create-links', options.create || $el.data('create-links'));
-      $el.addClass('crm-ajax-select crm-' + entity + '-ref');
+      $el.addClass('crm-form-entityref crm-' + entity + '-ref');
       var settings = {
         // Use select2 ajax helper instead of CRM.api because it provides more value
         ajax: {
@@ -427,7 +431,7 @@ CRM.validate = CRM.validate || {
       }
       $el.parent().find('.ui-dialog-titlebar-close').attr('title', ts('Close'));
       // Add resize button
-      if ($el.parent().hasClass('crm-container')) {
+      if ($el.parent().hasClass('crm-container') && $el.dialog('option', 'resizable')) {
         $el.parent().find('.ui-dialog-titlebar').append($('<button class="crm-dialog-titlebar-resize ui-dialog-titlebar-close" title="'+ts('Resize')+'" style="right:2em;"/>').button({icons: {primary: 'ui-icon-newwin'}, text: false}));
         $('.crm-dialog-titlebar-resize', $el.parent()).click(function(e) {
           if ($el.data('origSize')) {
@@ -660,6 +664,7 @@ CRM.validate = CRM.validate || {
       message: ts('Are you sure you want to continue?'),
       width: 'auto',
       modal: true,
+      resizable: false,
       dialogClass: 'crm-container crm-confirm',
       close: function () {
         $(this).dialog('destroy').remove();
@@ -803,6 +808,7 @@ CRM.validate = CRM.validate || {
       .on('click', 'a.crm-image-popup', function(e) {
         CRM.confirm({
           title: ts('Preview'),
+          resizable: true,
           message: '<div class="crm-custom-image-popup"><img src=' + $(this).attr('href') + '></div>',
           options: null
         });
index 1c81d51d3801165e9d2f032e36f4b85afd317a9a..14a415d4da13ed83f857402b20af1f9090faff2f 100644 (file)
@@ -47,7 +47,7 @@
 <script type="text/javascript">
 CRM.$(function($) {
   var $form = $("#{/literal}{$form.formName}{literal}");
-  $('input[name=unclosed_case_id]', $form).select2({
+  $('input[name=unclosed_case_id]', $form).crmSelect2({
     placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
     minimumInputLength: 1,
     ajax: {
index f700e3253f11a1caea1b9604e9e7b5611a8d2b0b..f2ea634f9c43ced8f0672e2dfb57feba1c466291 100644 (file)
@@ -117,7 +117,7 @@ CRM.$(function($) {
       open: function() {
         var dialog = this;
         $('input[name=select_merge_tag]', dialog)
-          .select2({
+          .crmSelect2({
             placeholder: {/literal}'{ts escape="js"}- select tag -{/ts}'{literal},
             minimumInputLength: 1,
             ajax: {
index 7f15ada6913311713f912924390cf215f641c801..b98ebfd2d7dd7548ee4d5138a2e81ce11ce3734a 100644 (file)
@@ -34,7 +34,7 @@
 <script type="text/javascript">
   CRM.$(function($) {
     var $form = $("#{/literal}{$form.formName}{literal}");
-    $('input[name=link_to_case_id]', $form).select2({
+    $('input[name=link_to_case_id]', $form).crmSelect2({
       placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
       minimumInputLength: 1,
       ajax: {
index 8a2d232286eb379fcd83c1554635f85f150240aa..1b7abd8d6527b6e54737e79468c2e55807bcb59a 100644 (file)
@@ -50,7 +50,7 @@
     var selectedCaseId = '';
     var contactId = '';
     CRM.$(function($) {
-      $('input[name=unclosed_case_id]', '#fileOnCaseDialog').select2({
+      $('input[name=unclosed_case_id]', '#fileOnCaseDialog').crmSelect2({
         placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
         minimumInputLength: 1,
         ajax: {
           title: dialogTitle,
           modal: true,
           width: 600,
-          height: 270,
+          height: 'auto',
           close: function( event, ui ) {
             cj('input[name=unclosed_case_id]', '#fileOnCaseDialog').select2('destroy');
             cj(this).hide().dialog("destroy");
           },
 
           buttons: {
-            "{/literal}{ts escape='js'}Ok{/ts}{literal}": function() {
+            "{/literal}{ts escape='js'}Save{/ts}{literal}": function() {
               var subject         = cj("#case_activity_subject").val( );
               var targetContactId = cj("#target_contact_id").val( );
 
                 return false;
               }
 
-              cj(this).dialog("destroy");
+              cj(this).dialog("close");
 
               var postUrl = {/literal}"{crmURL p='civicrm/ajax/activity/convert' h=0 }"{literal};
               cj.post( postUrl, { activityID: activityID, caseID: selectedCaseId, contactID: contactId, newSubject: subject, targetContactIds: targetContactId, mode: action, key: {/literal}"{crmKey name='civicrm/ajax/activity/convert'}"{literal} },
             },
             "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() {
               cj(this).dialog("close");
-              cj(this).dialog("destroy");
             }
           }
 
index a6a11ad5a61e554353a1502abcb4acf1d672d292..681198c0483187017f024ae932007257e9b61d5d 100644 (file)
         dialog = CRM.confirm({
           title: $(this).attr('title') || $(this).text(),
           message: detached[target],
+          resizable: true,
           open: miniForms[target].pre
         })
           .on('dialogclose', function() {
index ca93d528f50aa73b3442581fad566282fdbfb56d..2658f14e35d2548001125159f31901d94e477988 100644 (file)
@@ -91,7 +91,7 @@ campaignTrClass='' campaignTdClass='crm-event-form-block-participant_campaign_id
 <script type="text/javascript">
 CRM.$(function($) {
   // FIXME: This could be much simpler as an entityRef field but the priceFieldValue api doesn't currently support the filters we need
-  $('#participant_fee_id').select2({
+  $('#participant_fee_id').crmSelect2({
     placeholder: {/literal}'{ts escape="js"}- any -{/ts}'{literal},
     minimumInputLength: 1,
     allowClear: true,
index 2e860121789842f534957751f4b860927f141b4d..7ad51d80322451b28571cafbff82bf10addc9d3e 100644 (file)
@@ -356,7 +356,7 @@ CRM.$(function($) {
   $('input.crm-token-selector', form)
     .addClass('crm-action-menu')
     .change(insertToken)
-    .select2({
+    .crmSelect2({
       data: form.data('tokens'),
       placeholder: '{/literal}{ts escape='js'}Insert Token{/ts}{literal}'
     });