Skip to content

Commit

Permalink
added variable fixes for javascript buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
tnikcevs committed Mar 6, 2018
1 parent 679a0fa commit 254af45
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
28 changes: 11 additions & 17 deletions view/adminhtml/web/js/testconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ define([
'mage/translate'
], function ($) {
return function (config) {
successBtnMsg = $('#fastly-test-success-button-msg');
errorBtnMsg = $('#fastly-test-error-button-msg');
warningBtnMsg = $('#fastly-test-warning-button-msg');
var testSuccessBtnMsg = $('#fastly-test-success-button-msg');
var testErrorBtnMsg = $('#fastly-test-error-button-msg');

$('#fastly_test_connection_button').on('click', function () {
resetAllMessages();

testSuccessBtnMsg.text();
testSuccessBtnMsg.hide();
testErrorBtnMsg.text();
testErrorBtnMsg.hide();

$.ajax({
type: "POST",
url: config.testServiceUrl,
Expand All @@ -22,25 +26,15 @@ define([
cache: false,
success: function (response) {
if (response.status == false) {
return errorBtnMsg.text($.mage.__('Please check your Service ID and API token and try again.')).show();
return testErrorBtnMsg.text($.mage.__('Please check your Service ID and API token and try again.')).show();
} else {
return successBtnMsg.text($.mage.__('Connection to service name ' + response.service_name + ' has been succesfully established. Please, save configuration and clear cache.')).show();
return testSuccessBtnMsg.text($.mage.__('Connection to service name ' + response.service_name + ' has been succesfully established. Please, save configuration and clear cache.')).show();
}
},
error: function (msg) {
return errorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
return testErrorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
}
});
});
};

function resetAllMessages()
{
successBtnMsg.text();
successBtnMsg.hide();
errorBtnMsg.text();
errorBtnMsg.hide();
warningBtnMsg.text();
warningBtnMsg.hide();
}
});
28 changes: 11 additions & 17 deletions view/adminhtml/web/js/updateblocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ define([
'mage/translate'
], function ($) {
return function (config) {
successBtnMsg = $('#fastly-update-blocking-success-button-msg');
errorBtnMsg = $('#fastly-update-blocking-error-button-msg');
warningBtnMsg = $('#fastly-update-blocking-warning-button-msg');
var blockingSuccessBtnMsg = $('#fastly-update-blocking-success-button-msg');
var blockingErrorBtnMsg = $('#fastly-update-blocking-error-button-msg');

$('#fastly_update_blocking_button').on('click', function () {
resetAllMessages();

blockingSuccessBtnMsg.text();
blockingSuccessBtnMsg.hide();
blockingErrorBtnMsg.text();
blockingErrorBtnMsg.hide();

$.ajax({
type: "POST",
url: config.updateBlockingUrl,
Expand All @@ -24,25 +28,15 @@ define([
cache: false,
success: function (response) {
if (response.status == false) {
return errorBtnMsg.text($.mage.__('Please make sure that blocking is enabled.')).show();
return blockingErrorBtnMsg.text($.mage.__('Please make sure that blocking is enabled.')).show();
} else {
return successBtnMsg.text($.mage.__('Blocking snippet has been updated successfully.')).show();
return blockingSuccessBtnMsg.text($.mage.__('Blocking snippet has been updated successfully.')).show();
}
},
error: function (msg) {
return errorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
return blockingErrorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
}
});
});
};

function resetAllMessages()
{
successBtnMsg.text();
successBtnMsg.hide();
errorBtnMsg.text();
errorBtnMsg.hide();
warningBtnMsg.text();
warningBtnMsg.hide();
}
});

0 comments on commit 254af45

Please sign in to comment.