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
});
```
This commit is contained in:
Luke Towers 2017-02-03 15:54:59 -06:00 committed by GitHub
parent ebed3cde5e
commit 2be18764d4
1 changed files with 9 additions and 1 deletions

View File

@ -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)