CRM-16521 - Nicer UX for downloading files from a dialog
authorColeman Watts <coleman@civicrm.org>
Tue, 9 Jun 2015 02:04:15 +0000 (22:04 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 9 Jun 2015 02:04:15 +0000 (22:04 -0400)
js/crm.ajax.js

index 8edebab812d0fc2bcc7d828a37671780b64e88e5..dfcebaeba45b49615eee3fdc3aa0cd61795a8401 100644 (file)
           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 = [];
           $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() {