From 7ba7f3a062f9c6ed1a676aaf6cbb1e5aa6b7a0ad Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 23 Jun 2014 16:06:38 +0530 Subject: [PATCH] CRM-14830 fix - Links to add CC and BCC are hidden in Send an Email task https://issues.civicrm.org/jira/browse/CRM-14830 --- js/Common.js | 32 +++++++++++++++++++++++ templates/CRM/Contact/Form/Task/Email.tpl | 4 +-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/js/Common.js b/js/Common.js index abc5cae391..34af6d67c1 100644 --- a/js/Common.js +++ b/js/Common.js @@ -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 diff --git a/templates/CRM/Contact/Form/Task/Email.tpl b/templates/CRM/Contact/Form/Task/Email.tpl index 5f5caaaebe..50fa8f3766 100644 --- a/templates/CRM/Contact/Form/Task/Email.tpl +++ b/templates/CRM/Contact/Form/Task/Email.tpl @@ -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(); -- 2.25.1