From ea033ee7ce833f36e2e46214881ad0fbcacf3127 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 7 Oct 2015 21:38:41 -0400 Subject: [PATCH] CRM-16725 - Remove global download behavior from popups It was problematic to have the button change run globally. Now it's just in the spot that needs it. If other spots need something similar it would be good to find a way to reuse the code. --- js/crm.ajax.js | 9 --------- .../CRM/Contact/Form/Task/PDFLetterCommon.tpl | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 3ea776c4f8..6f0f244553 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -497,15 +497,6 @@ $el.parents(buttonContainers).css({height: 0, padding: 0, margin: 0, overflow: 'hidden'}).find('.crm-button-icon').hide(); }); $el.dialog('option', 'buttons', buttons); - - // Show done button for non-ajax dialogs (e.g. file downloads) - $(this).on('submit', "form[data-no-ajax-submit=true]", function() { - $el.dialog('option', 'buttons', [{ - text: ts('Done'), - icons: {primary: 'ui-icon-close'}, - click: function() {$(this).dialog('close');} - }]); - }); } // Allow a button to prevent ajax submit $('input[data-no-ajax-submit=true]').click(function() { diff --git a/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl b/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl index 5439af0fba..65a473d0d9 100644 --- a/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl +++ b/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl @@ -127,8 +127,18 @@ CRM.$(function($) { }); // After the pdf downloads, the user has to manually close the dialog (which would be nice to fix) // But at least we can trigger the underlying list of activities to refresh - $form.closest('.ui-dialog-content.crm-ajax-container').on('dialogbeforeclose', function() { - $(this).trigger('crmFormSuccess'); + $('[name=_qf_PDF_submit]', $form).click(function() { + var $dialog = $(this).closest('.ui-dialog-content.crm-ajax-container'); + if ($dialog.length) { + $dialog.on('dialogbeforeclose', function () { + $(this).trigger('crmFormSuccess'); + }); + $dialog.dialog('option', 'buttons', [{ + text: {/literal}"{ts escape='js'}Done{/ts}"{literal}, + icons: {primary: 'ui-icon-close'}, + click: function() {$(this).dialog('close');} + }]); + } }); showSaveDetails($('input[name=saveTemplate]', $form)[0]); -- 2.25.1