From: Coleman Watts Date: Tue, 9 Jun 2015 02:04:15 +0000 (-0400) Subject: CRM-16521 - Nicer UX for downloading files from a dialog X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ba05d50e28b8353a7c137827782f9156ee1ad28f;p=civicrm-core.git CRM-16521 - Nicer UX for downloading files from a dialog --- 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() {