|
|
@ -266,12 +266,18 @@ $.api = $.fn.api = function(parameters) { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
should: { |
|
|
|
removeError: function() { |
|
|
|
return ( settings.hideError === true || (settings.hideError === 'auto' && !module.is.form()) ); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
is: { |
|
|
|
disabled: function() { |
|
|
|
return ($module.filter(selector.disabled).length > 0); |
|
|
|
}, |
|
|
|
form: function() { |
|
|
|
return $module.is('form'); |
|
|
|
return $module.is('form') || $context.is('form'); |
|
|
|
}, |
|
|
|
mocked: function() { |
|
|
|
return (settings.mockResponse || settings.mockResponseAsync); |
|
|
@ -562,7 +568,9 @@ $.api = $.fn.api = function(parameters) { |
|
|
|
if(settings.errorDuration && status !== 'aborted') { |
|
|
|
module.debug('Adding error state'); |
|
|
|
module.set.error(); |
|
|
|
setTimeout(module.remove.error, settings.errorDuration); |
|
|
|
if( module.should.removeError() ) { |
|
|
|
setTimeout(module.remove.error, settings.errorDuration); |
|
|
|
} |
|
|
|
} |
|
|
|
module.debug('API Request failed', errorMessage, xhr); |
|
|
|
settings.onFailure.call(context, response, $module, xhr); |
|
|
@ -789,7 +797,7 @@ $.api = $.fn.api = function(parameters) { |
|
|
|
url = settings.api[action]; |
|
|
|
} |
|
|
|
else if( module.is.form() ) { |
|
|
|
url = $module.attr('action') || false; |
|
|
|
url = $module.attr('action') || $context.attr('action') || false; |
|
|
|
module.debug('No url or action specified, defaulting to form action', url); |
|
|
|
} |
|
|
|
return url; |
|
|
@ -1016,9 +1024,13 @@ $.api.settings = { |
|
|
|
// duration for loading state
|
|
|
|
loadingDuration : 0, |
|
|
|
|
|
|
|
// whether to hide errors after a period of time
|
|
|
|
hideError : 'auto', |
|
|
|
|
|
|
|
// duration for error state
|
|
|
|
errorDuration : 2000, |
|
|
|
|
|
|
|
// whether parameters should be encoded with encodeURIComponent
|
|
|
|
encodeParameters : true, |
|
|
|
|
|
|
|
// API action to use
|
|
|
|