fix eslint errors
This commit is contained in:
@@ -102,7 +102,7 @@ define([
|
|||||||
data: {
|
data: {
|
||||||
id: App.toJSON().id
|
id: App.toJSON().id
|
||||||
}
|
}
|
||||||
}).then(function(response) {
|
}).then(function (response) {
|
||||||
var type = response.data.type;
|
var type = response.data.type;
|
||||||
if (type == 'welcome') {
|
if (type == 'welcome') {
|
||||||
categories.push('welcome_emails');
|
categories.push('welcome_emails');
|
||||||
@@ -110,7 +110,7 @@ define([
|
|||||||
if (type == 'notification') {
|
if (type == 'notification') {
|
||||||
categories.push('post_notifications');
|
categories.push('post_notifications');
|
||||||
}
|
}
|
||||||
}).then(function() {
|
}).then(function () {
|
||||||
return Module.getThumbnail(
|
return Module.getThumbnail(
|
||||||
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
||||||
).then(function (thumbnail) {
|
).then(function (thumbnail) {
|
||||||
|
@@ -11,7 +11,7 @@ define(
|
|||||||
'newsletters/breadcrumb.jsx',
|
'newsletters/breadcrumb.jsx',
|
||||||
'help-tooltip.jsx',
|
'help-tooltip.jsx',
|
||||||
'jquery',
|
'jquery',
|
||||||
'html2canvas'
|
'html2canvas',
|
||||||
],
|
],
|
||||||
(
|
(
|
||||||
React,
|
React,
|
||||||
@@ -90,11 +90,11 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveTemplate: function(data, done) {
|
saveTemplate: function (data, done) {
|
||||||
var iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
iframe.src = data.preview_url;
|
iframe.src = data.preview_url;
|
||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
html2canvas(iframe.contentDocument.documentElement).then(function(thumbnail){
|
html2canvas(iframe.contentDocument.documentElement).then((thumbnail) => {
|
||||||
document.body.removeChild(iframe);
|
document.body.removeChild(iframe);
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
api_version: window.mailpoet_api_version,
|
api_version: window.mailpoet_api_version,
|
||||||
@@ -105,11 +105,11 @@ define(
|
|||||||
description: data.preheader,
|
description: data.preheader,
|
||||||
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
||||||
body: JSON.stringify(data.body),
|
body: JSON.stringify(data.body),
|
||||||
categories: '["recent"]'
|
categories: '["recent"]',
|
||||||
}
|
},
|
||||||
}).then(done).fail(this.showError);
|
}).then(done).fail(this.showError);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
// just to hide the iframe
|
// just to hide the iframe
|
||||||
iframe.style.cssText ='position: absolute; opacity:0; z-index: -9999';
|
iframe.style.cssText ='position: absolute; opacity:0; z-index: -9999';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
|
@@ -86,7 +86,7 @@ const NewsletterTemplates = React.createClass({
|
|||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
templates: {},
|
templates: {},
|
||||||
selectedCategory: ''
|
selectedCategory: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
@@ -117,7 +117,7 @@ const NewsletterTemplates = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const templates = response.data.reduce((result, item) => {
|
const templates = response.data.reduce((result, item) => {
|
||||||
JSON.parse(item.categories).forEach(category => {
|
JSON.parse(item.categories).forEach((category) => {
|
||||||
result[category].push(item);
|
result[category].push(item);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@@ -127,7 +127,7 @@ const NewsletterTemplates = React.createClass({
|
|||||||
inspiration: [],
|
inspiration: [],
|
||||||
blank: [],
|
blank: [],
|
||||||
recent: [],
|
recent: [],
|
||||||
saved: []
|
saved: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectInitialCategory(templates);
|
this.selectInitialCategory(templates);
|
||||||
@@ -142,32 +142,32 @@ const NewsletterTemplates = React.createClass({
|
|||||||
MailPoet.Modal.loading(false);
|
MailPoet.Modal.loading(false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectInitialCategory: function(templates) {
|
selectInitialCategory: function (templates) {
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
api_version: window.mailpoet_api_version,
|
api_version: window.mailpoet_api_version,
|
||||||
endpoint: 'newsletters',
|
endpoint: 'newsletters',
|
||||||
action: 'get',
|
action: 'get',
|
||||||
data: {
|
data: {
|
||||||
id: this.props.params.id
|
id: this.props.params.id,
|
||||||
},
|
},
|
||||||
}).always(() => {
|
}).always(() => {
|
||||||
MailPoet.Modal.loading(false);
|
MailPoet.Modal.loading(false);
|
||||||
}).done((response) => {
|
}).done((response) => {
|
||||||
const type = response.data.type
|
const type = response.data.type;
|
||||||
let category = 'inspiration'
|
let category = 'inspiration';
|
||||||
if (type == 'welcome') {
|
if (type === 'welcome') {
|
||||||
category = 'welcome_emails';
|
category = 'welcome_emails';
|
||||||
} else if (type == 'notification') {
|
} else if (type === 'notification') {
|
||||||
category = 'post_notifications';
|
category = 'post_notifications';
|
||||||
} else if (templates['recent'] && templates['recent'].length > 0) {
|
} else if (templates.recent && templates.recent.length > 0) {
|
||||||
category = 'recent';
|
category = 'recent';
|
||||||
} else if (templates['saved'] && templates['saved'].length > 0) {
|
} else if (templates.saved && templates.saved.length > 0) {
|
||||||
category = 'saved';
|
category = 'saved';
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
templates: templates,
|
templates: templates,
|
||||||
selectedCategory: category,
|
selectedCategory: category,
|
||||||
loading: false
|
loading: false,
|
||||||
});
|
});
|
||||||
}).fail((response) => {
|
}).fail((response) => {
|
||||||
if (response.errors.length > 0) {
|
if (response.errors.length > 0) {
|
||||||
@@ -178,8 +178,8 @@ const NewsletterTemplates = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectCategory: function(category) {
|
selectCategory: function (category) {
|
||||||
this.setState({selectedCategory: category});
|
this.setState({ selectedCategory: category });
|
||||||
},
|
},
|
||||||
handleSelectTemplate: function (template) {
|
handleSelectTemplate: function (template) {
|
||||||
let body = template.body;
|
let body = template.body;
|
||||||
@@ -325,37 +325,37 @@ const NewsletterTemplates = React.createClass({
|
|||||||
<ul className="filter-links">
|
<ul className="filter-links">
|
||||||
<li><a
|
<li><a
|
||||||
href="javascript:"
|
href="javascript:"
|
||||||
className={this.state.selectedCategory == 'recent' ? 'current' : ''}
|
className={this.state.selectedCategory === 'recent' ? 'current' : ''}
|
||||||
onClick={() => this.selectCategory('recent')}
|
onClick={() => this.selectCategory('recent')}
|
||||||
> Recently sent
|
> Recently sent
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a
|
<li><a
|
||||||
href="javascript:"
|
href="javascript:"
|
||||||
className={this.state.selectedCategory == 'saved' ? 'current' : ''}
|
className={this.state.selectedCategory === 'saved' ? 'current' : ''}
|
||||||
onClick={() => this.selectCategory('saved')}
|
onClick={() => this.selectCategory('saved')}
|
||||||
> Your saved templates
|
> Your saved templates
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a
|
<li><a
|
||||||
href="javascript:"
|
href="javascript:"
|
||||||
className={this.state.selectedCategory == 'blank' ? 'current' : ''}
|
className={this.state.selectedCategory === 'blank' ? 'current' : ''}
|
||||||
onClick={() => this.selectCategory('blank')}
|
onClick={() => this.selectCategory('blank')}
|
||||||
> Blank
|
> Blank
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a
|
<li><a
|
||||||
href="javascript:"
|
href="javascript:"
|
||||||
className={this.state.selectedCategory == 'inspiration' ? 'current' : ''}
|
className={this.state.selectedCategory === 'inspiration' ? 'current' : ''}
|
||||||
onClick={() => this.selectCategory('inspiration')}
|
onClick={() => this.selectCategory('inspiration')}
|
||||||
> Inspiration
|
> Inspiration
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a
|
<li><a
|
||||||
href="javascript:"
|
href="javascript:"
|
||||||
className={this.state.selectedCategory == 'welcome_emails' ? 'current' : ''}
|
className={this.state.selectedCategory === 'welcome_emails' ? 'current' : ''}
|
||||||
onClick={() => this.selectCategory('welcome_emails')}
|
onClick={() => this.selectCategory('welcome_emails')}
|
||||||
> Welcome Emails
|
> Welcome Emails
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a
|
<li><a
|
||||||
href="javascript:"
|
href="javascript:"
|
||||||
className={this.state.selectedCategory == 'post_notifications' ? 'current' : ''}
|
className={this.state.selectedCategory === 'post_notifications' ? 'current' : ''}
|
||||||
onClick={() => this.selectCategory('post_notifications')}
|
onClick={() => this.selectCategory('post_notifications')}
|
||||||
> Post Notifications
|
> Post Notifications
|
||||||
</a></li>
|
</a></li>
|
||||||
|
Reference in New Issue
Block a user