Add option to scroll to notices

This commit is contained in:
Tautvidas Sipavičius
2016-01-14 13:39:48 +02:00
parent 7954346a3f
commit 46c1b682fa
2 changed files with 24 additions and 5 deletions

View File

@@ -47,10 +47,15 @@ define([
} else if(response.error !== undefined) {
if(response.error.length === 0) {
// TODO: Handle translations
MailPoet.Notice.error("<?php _e('An unknown error occurred, please check your settings.'); ?>");
MailPoet.Notice.error(
"An unknown error occurred, please check your settings.",
{
scroll: true,
}
);
} else {
$(response.error).each(function(i, error) {
MailPoet.Notice.error(error);
MailPoet.Notice.error(error, { scroll: true });
});
}
}
@@ -168,6 +173,7 @@ define([
App.getConfig().get('translations.templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
}
);
} else if (templateDescription === '') {
@@ -175,6 +181,7 @@ define([
App.getConfig().get('translations.templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
}
);
} else {
@@ -188,6 +195,7 @@ define([
App.getConfig().get('translations.templateSaved'),
{
positionAfter: that.$el,
scroll: true,
}
);
}).fail(function() {
@@ -196,6 +204,7 @@ define([
App.getConfig().get('translations.templateSaveFailed'),
{
positionAfter: that.$el,
scroll: true,
}
);
});
@@ -220,6 +229,7 @@ define([
App.getConfig().get('translations.templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
}
);
} else if (templateDescription === '') {
@@ -227,6 +237,7 @@ define([
App.getConfig().get('translations.templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
}
);
} else {

View File

@@ -251,12 +251,20 @@ define([
CommunicationComponent.previewNewsletter(data).done(function(response) {
if(response.result !== undefined && response.result === true) {
MailPoet.Notice.success(App.getConfig().get('translations.newsletterPreviewSent'));
MailPoet.Notice.success(App.getConfig().get('translations.newsletterPreviewSent'), { scroll: true });
} else {
if (_.isArray(response.errors)) {
MailPoet.Notice.error(response.errors.join("\n"));
response.errors.map(function(error) {
MailPoet.Notice.error(error, { scroll: true });
});
} else {
MailPoet.Notice.error(App.getConfig().get('translations.newsletterPreviewFailedToSend'));
MailPoet.Notice.error(
App.getConfig().get('translations.newsletterPreviewFailedToSend'),
{
scroll: true,
static: true,
}
);
}
}
MailPoet.Modal.loading(false);