From 2be18764d47f78820d7f4a02ce3c0995358a16d1 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Fri, 3 Feb 2017 15:54:59 -0600 Subject: [PATCH] Support passing objects as the loading indicator Adds support for passing objects to be used as the loading indicator. Note: Objects must support `.show()` and `.hide()` methods. Example: ```js $.request('onHandler', { loading: $.oc.stripeLoadIndicator }); ``` --- modules/system/assets/js/framework.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/system/assets/js/framework.js b/modules/system/assets/js/framework.js index 9b35005e0..0886a8442 100644 --- a/modules/system/assets/js/framework.js +++ b/modules/system/assets/js/framework.js @@ -58,8 +58,16 @@ if (window.jQuery === undefined) $form = $el.closest('form'), $triggerEl = !!$form.length ? $form : $el, context = { handler: handler, options: options }, - loading = options.loading !== undefined && options.loading.length ? $(options.loading) : null, isRedirect = options.redirect !== undefined && options.redirect.length + + var loading = null + if (options.loading !== undefined) { + if ($.type(options.loading) === 'string') { + loading = $(options.loading) + } else if ($.type(options.loading) === 'object') { + loading = options.loading + } + } var _event = jQuery.Event('oc.beforeRequest') $triggerEl.trigger(_event, context)