aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-12-04 14:25:47 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2014-12-04 14:25:47 +0100
commit00f29ea153c5d7938160c3d5627c2dc202f6b4d4 (patch)
treee135e5926963f1ed1bf792ab88f66590a58128ea
parent2082700948655f6dd1a528163668c2b75a6b3c9f (diff)
Add errorID on deferred creation.
Change-Id: Ibd4a5a4d4ecbbda51c1af5a45ecf0eaf91fa6129
-rw-r--r--app/dashboard/static/js/linaro-base-1.0.3.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/dashboard/static/js/linaro-base-1.0.3.js b/app/dashboard/static/js/linaro-base-1.0.3.js
index 9b470e8..3a7c064 100644
--- a/app/dashboard/static/js/linaro-base-1.0.3.js
+++ b/app/dashboard/static/js/linaro-base-1.0.3.js
@@ -54,7 +54,7 @@ var JSBase = (function() {
'<button type="button" class="close" ' +
'data-dismiss="alert" aria-hidden="true">&times;</button>';
- if (reason !== null || reason !== undefined) {
+ if (reason !== null || typeof reason !== 'undefined') {
text = text + reason + '<br/>';
}
@@ -120,8 +120,9 @@ var JSBase = (function() {
// `errorFunction`: Optional function to be call on error.
// `errorReason`: Error message to be displayed.
// `headers`: Optional headers to set for the ajax call.
+ // `errorId`: ID to use for the error message div element.
function createDeferredCall(url, method, data, successFunction,
- errorFunction, errorReason, headers) {
+ errorFunction, errorReason, headers, errorId) {
var ajaxSettings, ajaxCall;
@@ -133,6 +134,12 @@ var JSBase = (function() {
errorReason = defaultErrorReason;
}
+ if (errorId === null || errorId === undefined) {
+ errorId = '#error';
+ } else {
+ errorId = checkIfID(errorId);
+ }
+
ajaxSettings = {
'type': method,
'traditional': true,
@@ -145,17 +152,17 @@ var JSBase = (function() {
'timeout': defaultTimeout,
'statusCode': {
403: function() {
- setErrorAlert('error-403', 403, errorReason);
+ setErrorAlert(errorId + '-403', 403, errorReason);
},
404: function() {
- setErrorAlert('error-404', 404, errorReason);
+ setErrorAlert(errorId + '-404', 404, errorReason);
},
408: function() {
errorReason = errorReason + 'nbsp;(timeout)';
- setErrorAlert('error-408', 408, errorReason);
+ setErrorAlert(errorId + '-408', 408, errorReason);
},
500: function() {
- setErrorAlert('error-500', 500, errorReason);
+ setErrorAlert(errorId + '-500', 500, errorReason);
}
}
};
@@ -168,7 +175,7 @@ var JSBase = (function() {
ajaxSettings.error = errorFunction;
}
- if (headers !== null || headers !== undefined) {
+ if (headers !== null || typeof headers !== undefined) {
ajaxSettings.headers = headers;
}