From ba05d50e28b8353a7c137827782f9156ee1ad28f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 8 Jun 2015 22:04:15 -0400 Subject: [PATCH] CRM-16521 - Nicer UX for downloading files from a dialog --- js/crm.ajax.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 8edebab812..dfcebaeba4 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -474,8 +474,8 @@ e.preventDefault(); }); } - // Show form buttons as part of the dialog if ($el.data('uiDialog')) { + // Show form buttons as part of the dialog var buttonContainers = '.crm-submit-buttons, .action-link', buttons = [], added = []; @@ -501,6 +501,15 @@ $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() { -- 2.25.1