CRM-14830 fix - Links to add CC and BCC are hidden in Send an Email task
authormonishdeb <monish.deb@webaccessglobal.com>
Mon, 23 Jun 2014 10:36:38 +0000 (16:06 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 23 Jun 2014 10:36:38 +0000 (16:06 +0530)
https://issues.civicrm.org/jira/browse/CRM-14830

js/Common.js
templates/CRM/Contact/Form/Task/Email.tpl

index abc5cae3919372b766bb09156a5cef8341ce8d66..34af6d67c12c9ba8a8aee7765d046d6f606ba828 100644 (file)
@@ -255,6 +255,38 @@ CRM.validate = CRM.validate || {
     return isDirty;
   };
 
+   /**
+   * Wrapper for toggle function which is deprecated in from jQuery 1.8;
+   * @param fn1,fn2 handlers
+   */
+
+  $.fn.toggleClick = function( fn1, fn2 ) {
+    // Don't mess with animation or css toggles
+    if ( !$.isFunction( fn1 ) || !$.isFunction( fn2 ) ) {
+      return;
+    }
+    // migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
+    // Save reference to arguments for access in closure
+    var args = arguments,
+    guid = fn1.guid || $.guid++,
+    i = 0,
+    toggler = function( event ) {
+      // Figure out which function to execute
+      var lastToggle = ( $._data( this, "lastToggle" + fn1.guid ) || 0 ) % i;
+      $._data( this, "lastToggle" + fn1.guid, lastToggle + 1 );
+      // Make sure that clicks stop
+      event.preventDefault();
+      // and execute the function
+      return args[ lastToggle ].apply( this, arguments ) || false;
+    };
+    // link all the functions, so any of them can unbind this click handler
+    toggler.guid = guid;
+    while ( i < args.length ) {
+      args[ i++ ].guid = guid;
+    }
+    return this.click( toggler );
+  };
+
   /**
    * Wrapper for select2 initialization function; supplies defaults
    * @param options object
index 5f5caaaebebff74b7784475d4353cc97bee72d35..50fa8f376665543f0efae30bda52b79d0b316ce4 100644 (file)
@@ -94,12 +94,12 @@ var toContact = ccContact = bccContact = '';
 
 {literal}
 CRM.$(function($){
-  cj('#addcc').toggle( function() { cj(this).text('Remove CC');
+  cj('#addcc').toggleClick( function() { cj(this).text('Remove CC');
                                   cj('tr#cc').show().find('ul').find('input').focus();
                    },function() { cj(this).text('Add CC');cj('#cc_id').val('');
                                   cj('tr#cc ul li:not(:last)').remove();cj('#cc').hide();
 });
-  cj('#addbcc').toggle( function() { cj(this).text('Remove BCC');
+  cj('#addbcc').toggleClick( function() { cj(this).text('Remove BCC');
                                    cj('tr#bcc').show().find('ul').find('input').focus();
                     },function() { cj(this).text('Add BCC');cj('#bcc_id').val('');
                                    cj('tr#bcc ul li:not(:last)').remove();cj('#bcc').hide();