diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb
index 2ceb50997..56bf2fb5f 100644
--- a/app/assets/javascripts/application.js.erb
+++ b/app/assets/javascripts/application.js.erb
@@ -224,6 +224,32 @@ var HelperModule = (function(){
}
}
+ helpers.flashAlertMsg = function(message, type) {
+ var alertType;
+ var glyphSign;
+ $('#notifications').html('');
+ if (type === 'success') {
+ alertType = ' alert-success ';
+ glyphSign = ' glyphicon-ok-sign ';
+ } else if (type === 'danger') {
+ alertType = ' alert-danger ';
+ glyphSign = ' glyphicon-exclamation-sign ';
+ }
+ var htmlSnippet = '
' +
+ '
' +
+ '' +
+ '' +
+ '' + message + '' +
+ '
' +
+ '
';
+ $('#notifications').html(htmlSnippet);
+ $('#content-wrapper').addClass('alert-shown');
+ helpers.hideFlashMsg();
+ }
+
$( document ).ready(function() {
helpers.treeLinkTruncation();
helpers.hideFlashMsg();
diff --git a/app/assets/javascripts/samples/sample_datatable.js.erb b/app/assets/javascripts/samples/sample_datatable.js.erb
index ae6d86fa1..f2f08f423 100644
--- a/app/assets/javascripts/samples/sample_datatable.js.erb
+++ b/app/assets/javascripts/samples/sample_datatable.js.erb
@@ -503,7 +503,9 @@ function onClickEdit() {
},
error: function (e, data, status, xhr) {
if (e.status == 403) {
- sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
+ HelperModule.flashAlertMsg(
+ I18n.t('samples.js.permission_error'), 'danger'
+ );
changeToViewMode();
updateButtons();
}
@@ -565,7 +567,7 @@ function onClickSave() {
dataType: "json",
data: data,
success: function (data) {
- sampleAlertMsg(data.flash, "success");
+ HelperModule.flashAlertMsg(data.flash, 'success');
onClickCancel();
},
error: function (e, eData, status, xhr) {
@@ -573,12 +575,16 @@ function onClickSave() {
clearAllErrors();
if (e.status == 404) {
- sampleAlertMsg(I18n.t("samples.js.not_found_error"), "danger");
+ HelperModule.flashAlertMsg(
+ I18n.t('samples.js.not_found_error'), 'danger'
+ );
changeToViewMode();
updateButtons();
}
else if (e.status == 403) {
- sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
+ HelperModule.flashAlertMsg(
+ I18n.t('samples.js.permission_error'), 'danger'
+ );
changeToViewMode();
updateButtons();
}
@@ -794,7 +800,9 @@ function onClickAddSample() {
},
error: function (e, eData, status, xhr) {
if (e.status == 403)
- sampleAlertMsg(I18n.t("samples.js.permission_error"), "danger");
+ HelperModule.flashAlertMsg(
+ I18n.t('samples.js.permission_error'), 'danger'
+ );
changeToViewMode();
updateButtons();
}
diff --git a/app/assets/javascripts/samples/samples.js b/app/assets/javascripts/samples/samples.js
index 1e5a3c7bc..5021f95eb 100644
--- a/app/assets/javascripts/samples/samples.js
+++ b/app/assets/javascripts/samples/samples.js
@@ -53,32 +53,6 @@ function updateSamplesTypesandGroups() {
});
}
-function sampleAlertMsg(message, type) {
- var alertType;
- var glyphSign;
- $('#notifications').html('');
- if (type === 'success') {
- alertType = ' alert-success ';
- glyphSign = ' glyphicon-ok-sign ';
- } else if (type === 'danger') {
- alertType = ' alert-danger ';
- glyphSign = ' glyphicon-exclamation-sign ';
- }
- var htmlSnippet = '' +
- '
' +
- '' +
- '' +
- '' + message + '' +
- '
' +
- '
';
- $('#notifications').html(htmlSnippet);
- $('#content-wrapper').addClass('alert-shown');
- HelperModule.hideFlashMsg();
-}
-
/**
* Initializes tutorial
*/