Fix space-before-function-paren eslint rule

[MAILPOET-985]
This commit is contained in:
Pavel Dohnal
2017-07-05 09:31:46 +01:00
parent 6dc1bf4e95
commit f39cbe6b55
37 changed files with 374 additions and 375 deletions

View File

@ -42,7 +42,6 @@
"comma-dangle": 0,
"prefer-arrow-callback": 0,
"func-names": 0,
"space-before-function-paren": 0,
"object-shorthand": 0,
"no-bitwise": 0,
"arrow-body-style": 0,

View File

@ -1,15 +1,15 @@
define([
'react'
],
function(
function (
React
) {
const FormFieldCheckbox = React.createClass({
onValueChange: function(e) {
onValueChange: function (e) {
e.target.value = this.refs.checkbox.checked ? '1' : '0';
return this.props.onValueChange(e);
},
render: function() {
render: function () {
if (this.props.field.values === undefined) {
return false;
}

View File

@ -1,7 +1,7 @@
define([
'react',
'moment',
], function(
], function (
React,
Moment
) {

View File

@ -8,7 +8,7 @@ define([
'form/fields/selection.jsx',
'form/fields/date.jsx',
],
function(
function (
React,
FormFieldText,
FormFieldTextarea,
@ -19,7 +19,7 @@ function(
FormFieldDate
) {
var FormField = React.createClass({
renderField: function(data, inline = false) {
renderField: function (data, inline = false) {
var description = false;
if(data.field.description) {
description = (
@ -83,11 +83,11 @@ function(
);
}
},
render: function() {
render: function () {
var field = false;
if(this.props.field['fields'] !== undefined) {
field = this.props.field.fields.map(function(subfield, index) {
field = this.props.field.fields.map(function (subfield, index) {
return this.renderField({
index: index,
field: subfield,

View File

@ -1,11 +1,11 @@
define([
'react'
],
function(
function (
React
) {
const FormFieldRadio = React.createClass({
render: function() {
render: function () {
if (this.props.field.values === undefined) {
return false;
}

View File

@ -4,33 +4,33 @@ define([
'jquery',
'select2'
],
function(
function (
React,
ReactDOM,
jQuery
) {
var Selection = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
items: [],
select2: false
};
},
componentWillMount: function() {
componentWillMount: function () {
this.loadCachedItems();
},
allowMultipleValues: function() {
allowMultipleValues: function () {
return (this.props.field.multiple === true);
},
isSelect2Initialized: function() {
isSelect2Initialized: function () {
return (this.state.select2 === true);
},
componentDidMount: function() {
componentDidMount: function () {
if(this.allowMultipleValues()) {
this.setupSelect2();
}
},
componentDidUpdate: function(prevProps, prevState) {
componentDidUpdate: function (prevProps, prevState) {
if(
(this.props.item !== undefined && prevProps.item !== undefined)
&& (this.props.item.id !== prevProps.item.id)
@ -40,24 +40,24 @@ function(
.trigger('change');
}
},
componentWillUnmount: function() {
componentWillUnmount: function () {
if(this.allowMultipleValues()) {
this.destroySelect2();
}
},
destroySelect2: function() {
destroySelect2: function () {
if(this.isSelect2Initialized()) {
jQuery('#'+this.refs.select.id).select2('destroy');
}
},
setupSelect2: function() {
setupSelect2: function () {
if(this.isSelect2Initialized()) {
return;
}
var select2 = jQuery('#'+this.refs.select.id).select2({
width: (this.props.width || ''),
templateResult: function(item) {
templateResult: function (item) {
if(item.element && item.element.selected) {
return null;
} else {
@ -71,10 +71,10 @@ function(
});
var hasRemoved = false;
select2.on('select2:unselecting', function(e) {
select2.on('select2:unselecting', function (e) {
hasRemoved = true;
});
select2.on('select2:opening', function(e) {
select2.on('select2:opening', function (e) {
if(hasRemoved === true) {
hasRemoved = false;
e.preventDefault();
@ -85,13 +85,13 @@ function(
this.setState({ select2: true });
},
getSelectedValues: function() {
getSelectedValues: function () {
if(this.props.field['selected'] !== undefined) {
return this.props.field['selected'](this.props.item);
} else if(this.props.item !== undefined && this.props.field.name !== undefined) {
if (this.allowMultipleValues()) {
if (Array.isArray(this.props.item[this.props.field.name])) {
return this.props.item[this.props.field.name].map(function(item) {
return this.props.item[this.props.field.name].map(function (item) {
return item.id;
});
}
@ -101,7 +101,7 @@ function(
}
return null;
},
loadCachedItems: function() {
loadCachedItems: function () {
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
var items = window['mailpoet_'+this.props.field.endpoint];
@ -115,7 +115,7 @@ function(
});
}
},
handleChange: function(e) {
handleChange: function (e) {
if(this.props.onValueChange !== undefined) {
if(this.props.field.multiple) {
value = jQuery('#'+this.refs.select.id).val();
@ -131,19 +131,19 @@ function(
});
}
},
getLabel: function(item) {
getLabel: function (item) {
if(this.props.field['getLabel'] !== undefined) {
return this.props.field.getLabel(item, this.props.item);
}
return item.name;
},
getSearchLabel: function(item) {
getSearchLabel: function (item) {
if(this.props.field['getSearchLabel'] !== undefined) {
return this.props.field.getSearchLabel(item, this.props.item);
}
return null;
},
getValue: function(item) {
getValue: function (item) {
if(this.props.field['getValue'] !== undefined) {
return this.props.field.getValue(item, this.props.item);
}
@ -152,14 +152,14 @@ function(
// When it's impossible to represent the desired value in DOM,
// this function may be used to transform the placeholder value into
// desired value.
transformChangedValue: function(value) {
transformChangedValue: function (value) {
if(typeof this.props.field['transformChangedValue'] === 'function') {
return this.props.field.transformChangedValue.call(this, value);
} else {
return value;
}
},
render: function() {
render: function () {
const options = this.state.items.map((item, index) => {
let label = this.getLabel(item);
let searchLabel = this.getSearchLabel(item);

View File

@ -1,11 +1,11 @@
define([
'react'
],
function(
function (
React
) {
var FormFieldTextarea = React.createClass({
render: function() {
render: function () {
return (
<textarea
type="text"

View File

@ -6,7 +6,7 @@ define(
'react-router',
'form/fields/field.jsx'
],
function(
function (
React,
MailPoet,
classNames,
@ -18,25 +18,25 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired
},
getDefaultProps: function() {
getDefaultProps: function () {
return {
params: {},
};
},
getInitialState: function() {
getInitialState: function () {
return {
loading: false,
errors: [],
item: {}
};
},
getValues: function() {
getValues: function () {
return this.props.item ? this.props.item : this.state.item;
},
getErrors: function() {
getErrors: function () {
return this.props.errors ? this.props.errors : this.state.errors;
},
componentDidMount: function() {
componentDidMount: function () {
if(this.isMounted()) {
if(this.props.params.id !== undefined) {
this.loadItem(this.props.params.id);
@ -47,7 +47,7 @@ define(
}
}
},
componentWillReceiveProps: function(props) {
componentWillReceiveProps: function (props) {
if(props.params.id === undefined) {
this.setState({
loading: false,
@ -60,7 +60,7 @@ define(
this.loadItem(props.params.id);
}
},
loadItem: function(id) {
loadItem: function (id) {
this.setState({ loading: true });
MailPoet.Ajax.post({
@ -79,12 +79,12 @@ define(
this.setState({
loading: false,
item: {}
}, function() {
}, function () {
this.context.router.push('/new');
});
});
},
handleSubmit: function(e) {
handleSubmit: function (e) {
e.preventDefault();
// handle validation
@ -98,9 +98,9 @@ define(
// only get values from displayed fields
var item = {};
this.props.fields.map(function(field) {
this.props.fields.map(function (field) {
if(field['fields'] !== undefined) {
field.fields.map(function(subfield) {
field.fields.map(function (subfield) {
item[subfield.name] = this.state.item[subfield.name];
}.bind(this));
} else {
@ -137,7 +137,7 @@ define(
}
});
},
handleValueChange: function(e) {
handleValueChange: function (e) {
if (this.props.onChange) {
return this.props.onChange(e);
} else {
@ -152,9 +152,9 @@ define(
return true;
}
},
render: function() {
render: function () {
if(this.getErrors() !== undefined) {
var errors = this.getErrors().map(function(error, index) {
var errors = this.getErrors().map(function (error, index) {
return (
<p key={ 'error-'+index } className="mailpoet_error">
{ error.message }
@ -179,7 +179,7 @@ define(
afterFormContent = this.props.afterFormContent(this.getValues());
}
var fields = this.props.fields.map(function(field, i) {
var fields = this.props.fields.map(function (field, i) {
return (
<FormField
field={ field }

View File

@ -86,7 +86,7 @@ const item_actions = [
{
name: 'edit',
label: MailPoet.I18n.t('edit'),
link: function(item) {
link: function (item) {
return (
<a href={ `admin.php?page=mailpoet-form-editor&id=${item.id}` }>{MailPoet.I18n.t('edit')}</a>
);
@ -95,7 +95,7 @@ const item_actions = [
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function(item, refresh) {
onClick: function (item, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',
@ -111,7 +111,7 @@ const item_actions = [
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
@ -134,7 +134,7 @@ const FormList = React.createClass({
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
@ -147,9 +147,9 @@ const FormList = React.createClass({
'has-row-actions'
);
let segments = mailpoet_segments.filter(function(segment) {
let segments = mailpoet_segments.filter(function (segment) {
return (jQuery.inArray(segment.id, form.segments) !== -1);
}).map(function(segment) {
}).map(function (segment) {
return segment.name;
}).join(', ');

View File

@ -2,22 +2,22 @@ define([
'react',
'mailpoet'
],
function(
function (
React,
MailPoet
) {
var ListingBulkActions = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
action: false,
extra: false
};
},
handleChangeAction: function(e) {
handleChangeAction: function (e) {
this.setState({
action: e.target.value,
extra: false
}, function() {
}, function () {
var action = this.getSelectedAction();
// action on select callback
@ -28,7 +28,7 @@ function(
}
}.bind(this));
},
handleApplyAction: function(e) {
handleApplyAction: function (e) {
e.preventDefault();
var action = this.getSelectedAction();
@ -47,7 +47,7 @@ function(
data.action = this.state.action;
var onSuccess = function() {};
var onSuccess = function () {};
if(action['onSuccess'] !== undefined) {
onSuccess = action.onSuccess;
}
@ -64,10 +64,10 @@ function(
extra: false
});
},
getSelectedAction: function() {
getSelectedAction: function () {
var selected_action = this.refs.action.value;
if(selected_action.length > 0) {
var action = this.props.bulk_actions.filter(function(action) {
var action = this.props.bulk_actions.filter(function (action) {
return (action.name === selected_action);
});
@ -77,7 +77,7 @@ function(
}
return null;
},
render: function() {
render: function () {
if(this.props.bulk_actions.length === 0) {
return null;
}
@ -97,7 +97,7 @@ function(
onChange={this.handleChangeAction}
>
<option value="">{MailPoet.I18n.t('bulkActions')}</option>
{ this.props.bulk_actions.map(function(action, index) {
{ this.props.bulk_actions.map(function (action, index) {
return (
<option
value={ action.name }

View File

@ -3,25 +3,25 @@ define([
'jquery',
'mailpoet'
],
function(
function (
React,
jQuery,
MailPoet
) {
var ListingFilters = React.createClass({
handleFilterAction: function() {
handleFilterAction: function () {
let filters = {};
this.getAvailableFilters().map((filter, i) => {
filters[this.refs['filter-'+i].name] = this.refs['filter-'+i].value;
});
return this.props.onSelectFilter(filters);
},
handleEmptyTrash: function() {
handleEmptyTrash: function () {
return this.props.onEmptyTrash();
},
getAvailableFilters: function() {
getAvailableFilters: function () {
let filters = this.props.filters;
return Object.keys(filters).filter(function(filter) {
return Object.keys(filters).filter(function (filter) {
return !(
filters[filter].length === 0
|| (
@ -31,10 +31,10 @@ function(
);
});
},
componentDidUpdate: function() {
componentDidUpdate: function () {
const selected_filters = this.props.filter;
const available_filters = this.getAvailableFilters().map(
function(filter, i) {
function (filter, i) {
if (selected_filters[filter] !== undefined && selected_filters[filter]) {
jQuery(this.refs['filter-'+i])
.val(selected_filters[filter])
@ -43,17 +43,17 @@ function(
}.bind(this)
);
},
render: function() {
render: function () {
const filters = this.props.filters;
const available_filters = this.getAvailableFilters()
.map(function(filter, i) {
.map(function (filter, i) {
return (
<select
ref={ `filter-${i}` }
key={ `filter-${i}` }
name={ filter }
>
{ filters[filter].map(function(option, j) {
{ filters[filter].map(function (option, j) {
return (
<option
value={ option.value }

View File

@ -1,11 +1,11 @@
define(['react', 'classnames'], function(React, classNames) {
define(['react', 'classnames'], function (React, classNames) {
var ListingGroups = React.createClass({
handleSelect: function(group) {
handleSelect: function (group) {
return this.props.onSelectGroup(group);
},
render: function() {
var groups = this.props.groups.map(function(group, index) {
render: function () {
var groups = this.props.groups.map(function (group, index) {
if(group.name === 'trash' && group.count === 0) {
return false;
}

View File

@ -3,13 +3,13 @@ import React from 'react';
import classNames from 'classnames';
const ListingHeader = React.createClass({
handleSelectItems: function() {
handleSelectItems: function () {
return this.props.onSelectItems(
this.refs.toggle.checked
);
},
render: function() {
const columns = this.props.columns.map(function(column, index) {
render: function () {
const columns = this.props.columns.map(function (column, index) {
column.is_primary = (index === 0);
column.sorted = (this.props.sort_by === column.name)
? this.props.sort_order
@ -52,12 +52,12 @@ const ListingHeader = React.createClass({
});
const ListingColumn = React.createClass({
handleSort: function() {
handleSort: function () {
const sort_by = this.props.column.name;
const sort_order = (this.props.column.sorted === 'asc') ? 'desc' : 'asc';
this.props.onSort(sort_by, sort_order);
},
render: function() {
render: function () {
const classes = classNames(
'manage-column',
{ 'column-primary': this.props.column.is_primary },

View File

@ -12,12 +12,12 @@ import ListingGroups from 'listing/groups.jsx';
import ListingFilters from 'listing/filters.jsx';
const ListingItem = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
expanded: false
};
},
handleSelectItem: function(e) {
handleSelectItem: function (e) {
this.props.onSelectItem(
parseInt(e.target.value, 10),
e.target.checked
@ -25,19 +25,19 @@ const ListingItem = React.createClass({
return !e.target.checked;
},
handleRestoreItem: function(id) {
handleRestoreItem: function (id) {
this.props.onRestoreItem(id);
},
handleTrashItem: function(id) {
handleTrashItem: function (id) {
this.props.onTrashItem(id);
},
handleDeleteItem: function(id) {
handleDeleteItem: function (id) {
this.props.onDeleteItem(id);
},
handleToggleItem: function(id) {
handleToggleItem: function (id) {
this.setState({ expanded: !this.state.expanded });
},
render: function() {
render: function () {
var checkbox = false;
if (this.props.is_selectable === true) {
@ -63,7 +63,7 @@ const ListingItem = React.createClass({
if (custom_actions.length > 0) {
let is_first = true;
item_actions = custom_actions.map(function(action, index) {
item_actions = custom_actions.map(function (action, index) {
if (action.display !== undefined) {
if (action.display(this.props.item) === false) {
return;
@ -196,7 +196,7 @@ const ListingItem = React.createClass({
const ListingItems = React.createClass({
render: function() {
render: function () {
if (this.props.items.length === 0) {
let message;
if (this.props.loading === true) {
@ -259,7 +259,7 @@ const ListingItems = React.createClass({
</td>
</tr>
{this.props.items.map(function(item, index) {
{this.props.items.map(function (item, index) {
item.id = parseInt(item.id, 10);
item.selected = (this.props.selected_ids.indexOf(item.id) !== -1);
@ -290,7 +290,7 @@ const Listing = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState: function() {
getInitialState: function () {
return {
loading: false,
search: '',
@ -309,12 +309,12 @@ const Listing = React.createClass({
meta: {}
};
},
getParam: function(param) {
getParam: function (param) {
const regex = /(.*)\[(.*)\]/;
const matches = regex.exec(param);
return [matches[1], matches[2]];
},
initWithParams: function(params) {
initWithParams: function (params) {
let state = this.getInitialState();
// check for url params
if (params.splat) {
@ -323,7 +323,7 @@ const Listing = React.createClass({
switch(key) {
case 'filter':
let filters = {};
value.split('&').map(function(pair) {
value.split('&').map(function (pair) {
let [k, v] = pair.split('=');
filters[k] = v;
}
@ -352,11 +352,11 @@ const Listing = React.createClass({
state.sort_order = this.props.sort_order;
}
this.setState(state, function() {
this.setState(state, function () {
this.getItems();
}.bind(this));
},
getParams: function() {
getParams: function () {
// get all route parameters (without the "splat")
let params = _.omit(this.props.params, 'splat');
// TODO:
@ -367,7 +367,7 @@ const Listing = React.createClass({
}
return params;
},
setParams: function() {
setParams: function () {
if (this.props.location) {
let params = Object.keys(this.state)
.filter(key => {
@ -405,7 +405,7 @@ const Listing = React.createClass({
}
}
},
getUrlWithParams: function(params) {
getUrlWithParams: function (params) {
let base_url = (this.props.base_url !== undefined)
? this.props.base_url
: null;
@ -417,7 +417,7 @@ const Listing = React.createClass({
return `/${ params }`;
}
},
setBaseUrlParams: function(base_url) {
setBaseUrlParams: function (base_url) {
if (base_url.indexOf(':') !== -1) {
const params = this.getParams();
Object.keys(params).map((key) => {
@ -429,23 +429,23 @@ const Listing = React.createClass({
return base_url;
},
componentDidMount: function() {
componentDidMount: function () {
if (this.isMounted()) {
const params = this.props.params || {};
this.initWithParams(params);
if (this.props.auto_refresh) {
jQuery(document).on('heartbeat-tick.mailpoet', function(e, data) {
jQuery(document).on('heartbeat-tick.mailpoet', function (e, data) {
this.getItems();
}.bind(this));
}
}
},
componentWillReceiveProps: function(nextProps) {
componentWillReceiveProps: function (nextProps) {
const params = nextProps.params || {};
this.initWithParams(params);
},
getItems: function() {
getItems: function () {
if (this.isMounted()) {
this.setState({ loading: true });
@ -489,14 +489,14 @@ const Listing = React.createClass({
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
}
},
handleRestoreItem: function(id) {
handleRestoreItem: function (id) {
this.setState({
loading: true,
page: 1
@ -519,12 +519,12 @@ const Listing = React.createClass({
this.getItems();
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
});
},
handleTrashItem: function(id) {
handleTrashItem: function (id) {
this.setState({
loading: true,
page: 1
@ -547,12 +547,12 @@ const Listing = React.createClass({
this.getItems();
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
});
},
handleDeleteItem: function(id) {
handleDeleteItem: function (id) {
this.setState({
loading: true,
page: 1
@ -575,12 +575,12 @@ const Listing = React.createClass({
this.getItems();
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
});
},
handleEmptyTrash: function() {
handleEmptyTrash: function () {
return this.handleBulkAction('all', {
action: 'delete',
group: 'trash'
@ -592,12 +592,12 @@ const Listing = React.createClass({
this.handleGroup('all');
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
});
},
handleBulkAction: function(selected_ids, params) {
handleBulkAction: function (selected_ids, params) {
if (
this.state.selection === false
&& this.state.selected_ids.length === 0
@ -630,25 +630,25 @@ const Listing = React.createClass({
this.getItems();
});
},
handleSearch: function(search) {
handleSearch: function (search) {
this.setState({
search: search,
page: 1,
selection: false,
selected_ids: []
}, function() {
}, function () {
this.setParams();
}.bind(this));
},
handleSort: function(sort_by, sort_order = 'asc') {
handleSort: function (sort_by, sort_order = 'asc') {
this.setState({
sort_by: sort_by,
sort_order: (sort_order === 'asc') ? 'asc' : 'desc',
}, function() {
}, function () {
this.setParams();
}.bind(this));
},
handleSelectItem: function(id, is_checked) {
handleSelectItem: function (id, is_checked) {
var selected_ids = this.state.selected_ids,
selection = false;
@ -669,11 +669,11 @@ const Listing = React.createClass({
selected_ids: selected_ids
});
},
handleSelectItems: function(is_checked) {
handleSelectItems: function (is_checked) {
if (is_checked === false) {
this.clearSelection();
} else {
var selected_ids = this.state.items.map(function(item) {
var selected_ids = this.state.items.map(function (item) {
return ~~item.id;
});
@ -683,7 +683,7 @@ const Listing = React.createClass({
});
}
},
handleSelectAll: function() {
handleSelectAll: function () {
if (this.state.selection === 'all') {
this.clearSelection();
} else {
@ -693,21 +693,21 @@ const Listing = React.createClass({
});
}
},
clearSelection: function() {
clearSelection: function () {
this.setState({
selection: false,
selected_ids: []
});
},
handleFilter: function(filters) {
handleFilter: function (filters) {
this.setState({
filter: filters,
page: 1
}, function() {
}, function () {
this.setParams();
}.bind(this));
},
handleGroup: function(group) {
handleGroup: function (group) {
// reset search
jQuery('#search_input').val('');
@ -716,34 +716,34 @@ const Listing = React.createClass({
filter: {},
search: '',
page: 1
}, function() {
}, function () {
this.setParams();
}.bind(this));
},
handleSetPage: function(page) {
handleSetPage: function (page) {
this.setState({
page: page,
selection: false,
selected_ids: []
}, function() {
}, function () {
this.setParams();
}.bind(this));
},
handleRenderItem: function(item, actions) {
handleRenderItem: function (item, actions) {
const render = this.props.onRenderItem(item, actions, this.state.meta);
return render.props.children;
},
handleRefreshItems: function() {
handleRefreshItems: function () {
this.getItems();
},
render: function() {
render: function () {
const items = this.state.items;
const sort_by = this.state.sort_by;
const sort_order = this.state.sort_order;
// columns
let columns = this.props.columns || [];
columns = columns.filter(function(column) {
columns = columns.filter(function (column) {
return (column.display === undefined || !!(column.display) === true);
});

View File

@ -2,61 +2,61 @@ define([
'react',
'classnames',
'mailpoet'
], function(
], function (
React,
classNames,
MailPoet
) {
var ListingPages = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
page: null
};
},
setPage: function(page) {
setPage: function (page) {
this.setState({
page: null
}, function () {
this.props.onSetPage(this.constrainPage(page));
}.bind(this));
},
setFirstPage: function() {
setFirstPage: function () {
this.setPage(1);
},
setLastPage: function() {
setLastPage: function () {
this.setPage(this.getLastPage());
},
setPreviousPage: function() {
setPreviousPage: function () {
this.setPage(this.constrainPage(
parseInt(this.props.page, 10) - 1)
);
},
setNextPage: function() {
setNextPage: function () {
this.setPage(this.constrainPage(
parseInt(this.props.page, 10) + 1)
);
},
constrainPage: function(page) {
constrainPage: function (page) {
return Math.min(Math.max(1, Math.abs(~~page)), this.getLastPage());
},
handleSetManualPage: function(e) {
handleSetManualPage: function (e) {
if(e.which === 13) {
this.setPage(this.state.page);
}
},
handleChangeManualPage: function(e) {
handleChangeManualPage: function (e) {
this.setState({
page: e.target.value
});
},
handleBlurManualPage: function(e) {
handleBlurManualPage: function (e) {
this.setPage(e.target.value);
},
getLastPage: function() {
getLastPage: function () {
return Math.ceil(this.props.count / this.props.limit);
},
render: function() {
render: function () {
if(this.props.count === 0) {
return false;
} else {

View File

@ -1,22 +1,22 @@
define([
'mailpoet',
'react'
], function(
], function (
MailPoet,
React
) {
var ListingSearch = React.createClass({
handleSearch: function(e) {
handleSearch: function (e) {
e.preventDefault();
this.props.onSearch(
this.refs.search.value
);
},
componentWillReceiveProps: function(nextProps) {
componentWillReceiveProps: function (nextProps) {
this.refs.search.value = nextProps.search;
},
render: function() {
render: function () {
if(this.props.search === false) {
return false;
} else {

View File

@ -5,7 +5,7 @@ define(
'classnames',
'mailpoet'
],
function(
function (
React,
Router,
classNames,
@ -14,7 +14,7 @@ define(
var Link = Router.Link;
var Breadcrumb = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
step: null,
steps: [
@ -38,8 +38,8 @@ define(
]
};
},
render: function() {
var steps = this.state.steps.map(function(step, index) {
render: function () {
var steps = this.state.steps.map(function (step, index) {
var stepClasses = classNames(
{ 'mailpoet_current': (this.props.step === step.name) }
);

View File

@ -10,7 +10,7 @@ import Hooks from 'wp-js-hooks';
import StatsBadge from 'newsletters/badges/stats.jsx';
const _QueueMixin = {
pauseSending: function(newsletter) {
pauseSending: function (newsletter) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
@ -18,19 +18,19 @@ const _QueueMixin = {
data: {
newsletter_id: newsletter.id
}
}).done(function() {
}).done(function () {
jQuery('#resume_'+newsletter.id).show();
jQuery('#pause_'+newsletter.id).hide();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
resumeSending: function(newsletter) {
resumeSending: function (newsletter) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
@ -38,19 +38,19 @@ const _QueueMixin = {
data: {
newsletter_id: newsletter.id
}
}).done(function() {
}).done(function () {
jQuery('#pause_'+newsletter.id).show();
jQuery('#resume_'+newsletter.id).hide();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
renderQueueStatus: function(newsletter, mailer_log) {
renderQueueStatus: function (newsletter, mailer_log) {
if (!newsletter.queue) {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
@ -144,7 +144,7 @@ const _QueueMixin = {
};
const _StatisticsMixin = {
renderStatistics: function(newsletter, is_sent, current_time) {
renderStatistics: function (newsletter, is_sent, current_time) {
if (is_sent === undefined) {
// condition for standard and post notification listings
is_sent = newsletter.statistics
@ -304,7 +304,7 @@ const _StatisticsMixin = {
};
const _MailerMixin = {
checkMailerStatus: function(state) {
checkMailerStatus: function (state) {
if (state.meta.mta_log.error && state.meta.mta_log.status === 'paused') {
MailPoet.Notice.error(
'',
@ -356,14 +356,14 @@ const _MailerMixin = {
api_version: window.mailpoet_api_version,
endpoint: 'mailer',
action: 'resumeSending'
}).done(function() {
}).done(function () {
MailPoet.Notice.hide('mailpoet_mailer_error');
MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice'));
window.mailpoet_listing.forceUpdate();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}

View File

@ -106,7 +106,7 @@ const bulk_actions = [
const newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ newsletter.preview_url } target="_blank">
{MailPoet.I18n.t('preview')}
@ -116,7 +116,7 @@ const newsletter_actions = [
},
{
name: 'edit',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
{MailPoet.I18n.t('edit')}
@ -127,7 +127,7 @@ const newsletter_actions = [
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function(newsletter, refresh) {
onClick: function (newsletter, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -145,7 +145,7 @@ const newsletter_actions = [
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
@ -159,7 +159,7 @@ const newsletter_actions = [
const NewsletterListNotification = React.createClass({
mixins: [ MailerMixin ],
updateStatus: function(e) {
updateStatus: function (e) {
// make the event persist so that we can still override the selected value
// in the ajax callback
e.persist();
@ -185,7 +185,7 @@ const NewsletterListNotification = React.createClass({
e.target.value = response.status;
});
},
renderStatus: function(newsletter) {
renderStatus: function (newsletter) {
return (
<select
data-id={ newsletter.id }
@ -197,12 +197,12 @@ const NewsletterListNotification = React.createClass({
</select>
);
},
renderSettings: function(newsletter) {
renderSettings: function (newsletter) {
let sendingFrequency;
let sendingToSegments;
// get list of segments' name
const segments = newsletter.segments.map(function(segment) {
const segments = newsletter.segments.map(function (segment) {
return segment.name;
});
@ -264,7 +264,7 @@ const NewsletterListNotification = React.createClass({
</span>
);
},
renderHistoryLink: function(newsletter) {
renderHistoryLink: function (newsletter) {
const childrenCount = ~~(newsletter.children_count);
if (childrenCount === 0) {
return (
@ -278,7 +278,7 @@ const NewsletterListNotification = React.createClass({
);
}
},
renderItem: function(newsletter, actions) {
renderItem: function (newsletter, actions) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -311,7 +311,7 @@ const NewsletterListNotification = React.createClass({
</div>
);
},
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -44,7 +44,7 @@ const columns = [
let newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ newsletter.preview_url } target="_blank">
{MailPoet.I18n.t('preview')}
@ -58,19 +58,19 @@ newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_notificat
const NewsletterListNotificationHistory = React.createClass({
mixins: [ QueueMixin, StatisticsMixin, MailerMixin ],
renderSentDate: function(newsletter) {
renderSentDate: function (newsletter) {
return (newsletter.queue.status === 'completed')
? ( <abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr> )
: MailPoet.I18n.t('notSentYet');
},
renderItem: function(newsletter, actions, meta) {
renderItem: function (newsletter, actions, meta) {
const rowClasses = classNames(
'manage-column',
'column-primary',
'has-row-actions'
);
const segments = newsletter.segments.map(function(segment) {
const segments = newsletter.segments.map(function (segment) {
return segment.name;
}).join(', ');
@ -104,7 +104,7 @@ const NewsletterListNotificationHistory = React.createClass({
</div>
);
},
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -101,7 +101,7 @@ const bulk_actions = [
let newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ newsletter.preview_url } target="_blank">
{MailPoet.I18n.t('preview')}
@ -111,7 +111,7 @@ let newsletter_actions = [
},
{
name: 'edit',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
{MailPoet.I18n.t('edit')}
@ -122,7 +122,7 @@ let newsletter_actions = [
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function(newsletter, refresh) {
onClick: function (newsletter, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -140,7 +140,7 @@ let newsletter_actions = [
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
@ -156,14 +156,14 @@ newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_standard_
const NewsletterListStandard = React.createClass({
mixins: [ QueueMixin, StatisticsMixin, MailerMixin ],
renderItem: function(newsletter, actions, meta) {
renderItem: function (newsletter, actions, meta) {
const rowClasses = classNames(
'manage-column',
'column-primary',
'has-row-actions'
);
const segments = newsletter.segments.map(function(segment) {
const segments = newsletter.segments.map(function (segment) {
return segment.name;
}).join(', ');
@ -195,7 +195,7 @@ const NewsletterListStandard = React.createClass({
</div>
);
},
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -104,7 +104,7 @@ const bulk_actions = [
let newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ newsletter.preview_url } target="_blank">
{MailPoet.I18n.t('preview')}
@ -114,7 +114,7 @@ let newsletter_actions = [
},
{
name: 'edit',
link: function(newsletter) {
link: function (newsletter) {
return (
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
{MailPoet.I18n.t('edit')}
@ -131,7 +131,7 @@ newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_welcome_n
const NewsletterListWelcome = React.createClass({
mixins: [ StatisticsMixin, MailerMixin ],
updateStatus: function(e) {
updateStatus: function (e) {
// make the event persist so that we can still override the selected value
// in the ajax callback
e.persist();
@ -157,7 +157,7 @@ const NewsletterListWelcome = React.createClass({
e.target.value = response.status;
});
},
renderStatus: function(newsletter) {
renderStatus: function (newsletter) {
let total_sent;
total_sent = (
MailPoet.I18n.t('sentToXSubscribers')
@ -180,7 +180,7 @@ const NewsletterListWelcome = React.createClass({
</div>
);
},
renderSettings: function(newsletter) {
renderSettings: function (newsletter) {
let sendingEvent;
let sendingDelay;
@ -199,7 +199,7 @@ const NewsletterListWelcome = React.createClass({
case 'segment':
// get segment
const segment = _.find(mailpoet_segments, function(segment) {
const segment = _.find(mailpoet_segments, function (segment) {
return (~~(segment.id) === ~~(newsletter.options.segment));
});
@ -251,7 +251,7 @@ const NewsletterListWelcome = React.createClass({
</span>
);
},
renderItem: function(newsletter, actions) {
renderItem: function (newsletter, actions) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -289,7 +289,7 @@ const NewsletterListWelcome = React.createClass({
</div>
);
},
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -25,9 +25,9 @@ const TIME_STEP_SECONDS = 3600;
const numberOfTimeSteps = SECONDS_IN_DAY / TIME_STEP_SECONDS;
const _timeOfDayValues = _.object(_.map(
_.times(numberOfTimeSteps,function(step) {
_.times(numberOfTimeSteps,function (step) {
return step * TIME_STEP_SECONDS;
}), function(seconds) {
}), function (seconds) {
let date = new Date(null);
date.setSeconds(seconds);
const timeLabel = MailPoet.Date.format(date, { format: timeFormat, offset: 0 });
@ -48,9 +48,9 @@ const _weekDayValues = {
const NUMBER_OF_DAYS_IN_MONTH = 28;
const _monthDayValues = _.object(
_.map(
_.times(NUMBER_OF_DAYS_IN_MONTH, function(day) {
_.times(NUMBER_OF_DAYS_IN_MONTH, function (day) {
return day;
}), function(day) {
}), function (day) {
const labels = {
0: MailPoet.I18n.t('first'),
1: MailPoet.I18n.t('second'),

View File

@ -10,7 +10,7 @@ define(
'newsletters/send/welcome.jsx',
'newsletters/breadcrumb.jsx'
],
function(
function (
React,
Router,
_,
@ -26,41 +26,41 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState: function() {
getInitialState: function () {
return {
fields: [],
item: {},
loading: false,
};
},
getFieldsByNewsletter: function(newsletter) {
getFieldsByNewsletter: function (newsletter) {
var type = this.getSubtype(newsletter);
return type.getFields(newsletter);
},
getSendButtonOptions: function() {
getSendButtonOptions: function () {
var type = this.getSubtype(this.state.item);
return type.getSendButtonOptions(this.state.item);
},
getSubtype: function(newsletter) {
getSubtype: function (newsletter) {
switch(newsletter.type) {
case 'notification': return NotificationNewsletterFields;
case 'welcome': return WelcomeNewsletterFields;
default: return StandardNewsletterFields;
}
},
isValid: function() {
isValid: function () {
return jQuery('#mailpoet_newsletter').parsley().isValid();
},
componentDidMount: function() {
componentDidMount: function () {
if(this.isMounted()) {
this.loadItem(this.props.params.id);
}
jQuery('#mailpoet_newsletter').parsley();
},
componentWillReceiveProps: function(props) {
componentWillReceiveProps: function (props) {
this.loadItem(props.params.id);
},
loadItem: function(id) {
loadItem: function (id) {
this.setState({ loading: true });
MailPoet.Ajax.post({
@ -85,7 +85,7 @@ define(
});
});
},
handleSend: function(e) {
handleSend: function (e) {
e.preventDefault();
if(!this.isValid()) {
@ -149,7 +149,7 @@ define(
}
return false;
},
handleSave: function(e) {
handleSave: function (e) {
e.preventDefault();
this._save(e).done((response) => {
@ -160,7 +160,7 @@ define(
this.context.router.push(`/${ this.state.item.type || '' }`);
}).fail(this._showError);
},
handleRedirectToDesign: function(e) {
handleRedirectToDesign: function (e) {
e.preventDefault();
var redirectTo = e.target.href;
@ -172,7 +172,7 @@ define(
window.location = redirectTo;
}).fail(this._showError);
},
_save: function(e) {
_save: function (e) {
var data = this.state.item;
this.setState({ loading: true });
@ -198,12 +198,12 @@ define(
_showError: (response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
},
handleFormChange: function(e) {
handleFormChange: function (e) {
var item = this.state.item,
field = e.target.name;
@ -214,7 +214,7 @@ define(
});
return true;
},
render: function() {
render: function () {
return (
<div>
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>

View File

@ -5,7 +5,7 @@ define(
'newsletters/types/notification/scheduling.jsx',
'underscore'
],
function(
function (
MailPoet,
Hooks,
Scheduling,
@ -41,16 +41,16 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
filter: function(segment) {
filter: function (segment) {
return !!(!segment.deleted_at);
},
getLabel: function(segment) {
getLabel: function (segment) {
return segment.name + ' (' + parseInt(segment.subscribers, 10).toLocaleString() + ')';
},
transformChangedValue: function(segment_ids) {
transformChangedValue: function (segment_ids) {
var all_segments = this.state.items;
return _.map(segment_ids, function(id) {
return _.find(all_segments, function(segment) {
return _.map(segment_ids, function (id) {
return _.find(all_segments, function (segment) {
return segment.id === id;
});
});
@ -107,10 +107,10 @@ define(
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function(newsletter) {
getFields: function (newsletter) {
return fields;
},
getSendButtonOptions: function(newsletter) {
getSendButtonOptions: function (newsletter) {
return {
value: MailPoet.I18n.t('activate')
};

View File

@ -9,7 +9,7 @@ define(
'form/fields/select.jsx',
'form/fields/text.jsx',
],
function(
function (
React,
jQuery,
_,
@ -90,7 +90,7 @@ define(
};
var DateText = React.createClass({
onChange: function(event) {
onChange: function (event) {
// Swap display format to storage format
var displayDate = event.target.value,
storageDate = this.getStorageDate(displayDate);
@ -98,19 +98,19 @@ define(
event.target.value = storageDate;
this.props.onChange(event);
},
componentDidMount: function() {
componentDidMount: function () {
var $element = jQuery(this.refs.dateInput),
that = this;
if ($element.datepicker) {
// Override jQuery UI datepicker Date parsing and formatting
jQuery.datepicker.parseDate = function(format, value) {
jQuery.datepicker.parseDate = function (format, value) {
// Transform string format to Date object
return MailPoet.Date.toDate(value, {
parseFormat: dateDisplayFormat,
format: format
});
};
jQuery.datepicker.formatDate = function(format, value) {
jQuery.datepicker.formatDate = function (format, value) {
// Transform Date object to string format
var newValue = MailPoet.Date.format(value, {
format: format
@ -121,7 +121,7 @@ define(
$element.datepicker(_.extend({
dateFormat: this.props.displayFormat,
isRTL: false,
onSelect: function(value) {
onSelect: function (value) {
that.onChange({
target: {
name: that.getFieldName(),
@ -134,27 +134,27 @@ define(
this.datepickerInitialized = true;
}
},
componentWillUnmount: function() {
componentWillUnmount: function () {
if (this.datepickerInitialized) {
jQuery(this.refs.dateInput).datepicker('destroy');
}
},
getFieldName: function() {
getFieldName: function () {
return this.props.name || 'date';
},
getDisplayDate: function(date) {
getDisplayDate: function (date) {
return MailPoet.Date.format(date, {
parseFormat: this.props.storageFormat,
format: this.props.displayFormat
});
},
getStorageDate: function(date) {
getStorageDate: function (date) {
return MailPoet.Date.format(date, {
parseFormat: this.props.displayFormat,
format: this.props.storageFormat
});
},
render: function() {
render: function () {
return (
<input
type="text"
@ -170,7 +170,7 @@ define(
});
var TimeSelect = React.createClass({
render: function() {
render: function () {
const options = Object.keys(timeOfDayItems).map(
(value, index) => {
return (
@ -198,13 +198,13 @@ define(
var DateTime = React.createClass({
_DATE_TIME_SEPARATOR: " ",
getInitialState: function() {
getInitialState: function () {
return this._buildStateFromProps(this.props);
},
componentWillReceiveProps: function(nextProps) {
componentWillReceiveProps: function (nextProps) {
this.setState(this._buildStateFromProps(nextProps));
},
_buildStateFromProps: function(props) {
_buildStateFromProps: function (props) {
let value = props.value || defaultDateTime;
const [date, time] = value.split(this._DATE_TIME_SEPARATOR);
return {
@ -212,15 +212,15 @@ define(
time: time,
};
},
handleChange: function(event) {
handleChange: function (event) {
var newState = {};
newState[event.target.name] = event.target.value;
this.setState(newState, function() {
this.setState(newState, function () {
this.propagateChange();
});
},
propagateChange: function() {
propagateChange: function () {
if (this.props.onChange) {
return this.props.onChange({
target: {
@ -230,10 +230,10 @@ define(
});
}
},
getDateTime: function() {
getDateTime: function () {
return [this.state.date, this.state.time].join(this._DATE_TIME_SEPARATOR);
},
render: function() {
render: function () {
return (
<span>
<DateText
@ -254,7 +254,7 @@ define(
});
var StandardScheduling = React.createClass({
_getCurrentValue: function() {
_getCurrentValue: function () {
return _.defaults(
this.props.item[this.props.field.name] || {},
{
@ -263,7 +263,7 @@ define(
}
);
},
handleValueChange: function(event) {
handleValueChange: function (event) {
var oldValue = this._getCurrentValue(),
newValue = {};
newValue[event.target.name] = event.target.value;
@ -275,21 +275,21 @@ define(
}
});
},
handleCheckboxChange: function(event) {
handleCheckboxChange: function (event) {
event.target.value = this.refs.isScheduled.checked ? '1' : '0';
return this.handleValueChange(event);
},
isScheduled: function() {
isScheduled: function () {
return this._getCurrentValue().isScheduled === '1';
},
getDateValidation: function() {
getDateValidation: function () {
return {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('noScheduledDateError'),
'data-parsley-errors-container': '#mailpoet_scheduling',
};
},
render: function() {
render: function () {
var schedulingOptions;
if (this.isScheduled()) {
@ -345,16 +345,16 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
filter: function(segment) {
filter: function (segment) {
return !!(!segment.deleted_at);
},
getLabel: function(segment) {
getLabel: function (segment) {
return segment.name + ' (' + parseInt(segment.subscribers, 10).toLocaleString() + ')';
},
transformChangedValue: function(segment_ids) {
transformChangedValue: function (segment_ids) {
var all_segments = this.state.items;
return _.map(segment_ids, function(id) {
return _.find(all_segments, function(segment) {
return _.map(segment_ids, function (id) {
return _.find(all_segments, function (segment) {
return segment.id === id;
});
});
@ -417,10 +417,10 @@ define(
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function(newsletter) {
getFields: function (newsletter) {
return fields;
},
getSendButtonOptions: function(newsletter) {
getSendButtonOptions: function (newsletter) {
newsletter = newsletter || {};
let isScheduled = (

View File

@ -4,7 +4,7 @@ define(
'wp-js-hooks',
'newsletters/types/welcome/scheduling.jsx'
],
function(
function (
MailPoet,
Hooks,
Scheduling
@ -76,10 +76,10 @@ define(
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function(newsletter) {
getFields: function (newsletter) {
return fields;
},
getSendButtonOptions: function(newsletter) {
getSendButtonOptions: function (newsletter) {
return {
value: MailPoet.I18n.t('activate')
};

View File

@ -7,7 +7,7 @@ define(
'classnames',
'newsletters/breadcrumb.jsx'
],
function(
function (
React,
_,
MailPoet,
@ -17,7 +17,7 @@ define(
) {
var ImportTemplate = React.createClass({
saveTemplate: function(template) {
saveTemplate: function (template) {
// Stringify to enable transmission of primitive non-string value types
if (!_.isUndefined(template.body)) {
@ -31,20 +31,20 @@ define(
endpoint: 'newsletterTemplates',
action: 'save',
data: template
}).always(function() {
}).always(function () {
MailPoet.Modal.loading(false);
}).done((response) => {
this.props.onImport(response.data);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
handleSubmit: function(e) {
handleSubmit: function (e) {
e.preventDefault();
if (_.size(this.refs.templateFile.files) <= 0) return false;
@ -63,7 +63,7 @@ define(
reader.readAsText(file);
},
render: function() {
render: function () {
return (
<div>
<h2>{MailPoet.I18n.t('importTemplateTitle')}</h2>
@ -83,16 +83,16 @@ define(
});
var NewsletterTemplates = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
loading: false,
templates: []
};
},
componentDidMount: function() {
componentDidMount: function () {
this.getTemplates();
},
getTemplates: function() {
getTemplates: function () {
this.setState({ loading: true });
MailPoet.Modal.loading(true);
@ -123,7 +123,7 @@ define(
}
});
},
handleSelectTemplate: function(template) {
handleSelectTemplate: function (template) {
var body = template.body;
// Stringify to enable transmission of primitive non-string value types
@ -145,13 +145,13 @@ define(
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
handleDeleteTemplate: function(template) {
handleDeleteTemplate: function (template) {
this.setState({ loading: true });
if(
window.confirm(
@ -174,18 +174,18 @@ define(
this.setState({ loading: false });
}
},
handleShowTemplate: function(template) {
handleShowTemplate: function (template) {
MailPoet.Modal.popup({
title: template.name,
template: '<div class="mailpoet_boxes_preview" style="background-color: {{ body.globalStyles.body.backgroundColor }}"><img src="{{ thumbnail }}" /></div>',
data: template
});
},
handleTemplateImport: function() {
handleTemplateImport: function () {
this.getTemplates();
},
render: function() {
var templates = this.state.templates.map(function(template, index) {
render: function () {
var templates = this.state.templates.map(function (template, index) {
var deleteLink = (
<div className="mailpoet_delete">
<a

View File

@ -6,7 +6,7 @@ define(
'react-router',
'newsletters/breadcrumb.jsx'
],
function(
function (
React,
MailPoet,
Hooks,
@ -17,12 +17,12 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired
},
setupNewsletter: function(type) {
setupNewsletter: function (type) {
if(type !== undefined) {
this.context.router.push(`/new/${type}`);
}
},
createNewsletter: function(type) {
createNewsletter: function (type) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -36,19 +36,19 @@ define(
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
render: function() {
render: function () {
var types = [
{
'id': 'standard',
'title': MailPoet.I18n.t('regularNewsletterTypeTitle'),
'description': MailPoet.I18n.t('regularNewsletterTypeDescription'),
'action': function() {
'action': function () {
return (
<a className="button button-primary" onClick={ this.createNewsletter.bind(null, 'standard') }>
{MailPoet.I18n.t('create')}
@ -60,7 +60,7 @@ define(
'id': 'welcome',
'title': MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
'description': MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
'action': function() {
'action': function () {
return (
<div>
<a href="?page=mailpoet-premium" target="_blank">
@ -74,7 +74,7 @@ define(
'id': 'notification',
'title': MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
'description': MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
'action': function() {
'action': function () {
return (
<a className="button button-primary" onClick={ this.setupNewsletter.bind(null, 'notification') }>
{MailPoet.I18n.t('setUp')}
@ -93,7 +93,7 @@ define(
<Breadcrumb step="type" />
<ul className="mailpoet_boxes clearfix">
{types.map(function(type, index) {
{types.map(function (type, index) {
return (
<li key={index} data-type={type.id}>
<div>

View File

@ -7,7 +7,7 @@ define(
'newsletters/types/notification/scheduling.jsx',
'newsletters/breadcrumb.jsx'
],
function(
function (
_,
React,
Router,
@ -26,7 +26,7 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState: function() {
getInitialState: function () {
return {
options: {
intervalType: 'daily',
@ -37,12 +37,12 @@ define(
}
};
},
handleValueChange: function(event) {
handleValueChange: function (event) {
var state = this.state;
state[event.target.name] = event.target.value;
this.setState(state);
},
handleNext: function() {
handleNext: function () {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -56,16 +56,16 @@ define(
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
showTemplateSelection: function(newsletterId) {
showTemplateSelection: function (newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
},
render: function() {
render: function () {
return (
<div>
<h1>{MailPoet.I18n.t('postNotificationNewsletterTypeTitle')}</h1>

View File

@ -35,10 +35,10 @@ const nthWeekDayField = {
};
const NotificationScheduling = React.createClass({
_getCurrentValue: function() {
_getCurrentValue: function () {
return (this.props.item[this.props.field.name] || {});
},
handleValueChange: function(name, value) {
handleValueChange: function (name, value) {
const oldValue = this._getCurrentValue();
let newValue = {};
@ -51,37 +51,37 @@ const NotificationScheduling = React.createClass({
}
});
},
handleIntervalChange: function(event) {
handleIntervalChange: function (event) {
return this.handleValueChange(
'intervalType',
event.target.value
);
},
handleTimeOfDayChange: function(event) {
handleTimeOfDayChange: function (event) {
return this.handleValueChange(
'timeOfDay',
event.target.value
);
},
handleWeekDayChange: function(event) {
handleWeekDayChange: function (event) {
return this.handleValueChange(
'weekDay',
event.target.value
);
},
handleMonthDayChange: function(event) {
handleMonthDayChange: function (event) {
return this.handleValueChange(
'monthDay',
event.target.value
);
},
handleNthWeekDayChange: function(event) {
handleNthWeekDayChange: function (event) {
return this.handleValueChange(
'nthWeekDay',
event.target.value
);
},
render: function() {
render: function () {
const value = this._getCurrentValue();
let timeOfDaySelection;
let weekDaySelection;

View File

@ -5,7 +5,7 @@ define(
'mailpoet',
'newsletters/breadcrumb.jsx'
],
function(
function (
React,
Router,
MailPoet,
@ -16,10 +16,10 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired
},
showTemplateSelection: function(newsletterId) {
showTemplateSelection: function (newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
},
componentDidMount: function() {
componentDidMount: function () {
// No options for this type, create a newsletter upon mounting
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
@ -33,13 +33,13 @@ define(
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
render: function() {
render: function () {
return (
<div>
<h1>{MailPoet.I18n.t('regularNewsletterTypeTitle')}</h1>

View File

@ -26,7 +26,7 @@ const events = {
const availableSegmentValues = _.object(_.map(
availableSegments,
function(segment) {
function (segment) {
let name = segment.name + ' (' + parseInt(segment.subscribers, 10).toLocaleString() + ')';
return [segment.id, name];
}
@ -56,10 +56,10 @@ const WelcomeScheduling = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
},
_getCurrentValue: function() {
_getCurrentValue: function () {
return (this.props.item[this.props.field.name] || {});
},
handleValueChange: function(name, value) {
handleValueChange: function (name, value) {
const oldValue = this._getCurrentValue();
let newValue = {};
@ -72,37 +72,37 @@ const WelcomeScheduling = React.createClass({
}
});
},
handleEventChange: function(event) {
handleEventChange: function (event) {
return this.handleValueChange(
'event',
event.target.value
);
},
handleSegmentChange: function(event) {
handleSegmentChange: function (event) {
return this.handleValueChange(
'segment',
event.target.value
);
},
handleRoleChange: function(event) {
handleRoleChange: function (event) {
return this.handleValueChange(
'role',
event.target.value
);
},
handleAfterTimeNumberChange: function(event) {
handleAfterTimeNumberChange: function (event) {
return this.handleValueChange(
'afterTimeNumber',
event.target.value
);
},
handleAfterTimeTypeChange: function(event) {
handleAfterTimeTypeChange: function (event) {
return this.handleValueChange(
'afterTimeType',
event.target.value
);
},
handleNext: function() {
handleNext: function () {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -116,16 +116,16 @@ const WelcomeScheduling = React.createClass({
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
}
});
},
showTemplateSelection: function(newsletterId) {
showTemplateSelection: function (newsletterId) {
this.context.router.push(`/template/${ newsletterId }`);
},
render: function() {
render: function () {
const value = this._getCurrentValue();
let roleSegmentSelection;
let timeNumber;

View File

@ -5,7 +5,7 @@ define(
'mailpoet',
'form/form.jsx'
],
function(
function (
React,
Router,
MailPoet,
@ -27,10 +27,10 @@ define(
];
const messages = {
onUpdate: function() {
onUpdate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('segmentUpdated'));
},
onCreate: function() {
onCreate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('segmentAdded'));
}
};
@ -38,7 +38,7 @@ define(
var Link = Router.Link;
const SegmentForm = React.createClass({
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -98,12 +98,12 @@ const bulk_actions = [
const item_actions = [
{
name: 'edit',
link: function(item) {
link: function (item) {
return (
<Link to={ `/edit/${item.id}` }>{MailPoet.I18n.t('edit')}</Link>
);
},
display: function(segment) {
display: function (segment) {
return (segment.type !== 'wp_users');
}
},
@ -125,18 +125,18 @@ const item_actions = [
refresh();
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
response.errors.map(function (error) { return error.message; }),
{ scroll: true }
);
});
},
display: function(segment) {
display: function (segment) {
return (segment.type !== 'wp_users');
}
},
{
name: 'read_more',
link: function(item) {
link: function (item) {
return (
<a
href="http://docs.mailpoet.com/article/133-the-wordpress-users-list"
@ -144,20 +144,20 @@ const item_actions = [
>{MailPoet.I18n.t('readMore')}</a>
);
},
display: function(segment) {
display: function (segment) {
return (segment.type === 'wp_users');
}
},
{
name: 'synchronize_segment',
label: MailPoet.I18n.t('forceSync'),
onClick: function(item, refresh) {
onClick: function (item, refresh) {
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'segments',
action: 'synchronize'
}).done(function(response) {
}).done(function (response) {
MailPoet.Modal.loading(false);
if(response === true) {
MailPoet.Notice.success(
@ -167,13 +167,13 @@ const item_actions = [
}
});
},
display: function(segment) {
display: function (segment) {
return (segment.type === 'wp_users');
}
},
{
name: 'view_subscribers',
link: function(item) {
link: function (item) {
return (
<a href={ item.subscribers_url }>{MailPoet.I18n.t('viewSubscribers')}</a>
);
@ -181,14 +181,14 @@ const item_actions = [
},
{
name: 'trash',
display: function(segment) {
display: function (segment) {
return (segment.type !== 'wp_users');
}
}
];
const SegmentList = React.createClass({
renderItem: function(segment, actions) {
renderItem: function (segment, actions) {
var rowClasses = classNames(
'manage-column',
'column-primary',
@ -245,7 +245,7 @@ const SegmentList = React.createClass({
</div>
);
},
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -6,7 +6,7 @@ define(
'form/form.jsx',
'react-string-replace'
],
function(
function (
React,
Router,
MailPoet,
@ -18,7 +18,7 @@ define(
name: 'email',
label: MailPoet.I18n.t('email'),
type: 'text',
disabled: function(subscriber) {
disabled: function (subscriber) {
return ~~(subscriber.wp_user_id > 0);
}
},
@ -26,7 +26,7 @@ define(
name: 'first_name',
label: MailPoet.I18n.t('firstname'),
type: 'text',
disabled: function(subscriber) {
disabled: function (subscriber) {
return ~~(subscriber.wp_user_id > 0);
}
},
@ -34,7 +34,7 @@ define(
name: 'last_name',
label: MailPoet.I18n.t('lastname'),
type: 'text',
disabled: function(subscriber) {
disabled: function (subscriber) {
return ~~(subscriber.wp_user_id > 0);
}
},
@ -48,7 +48,7 @@ define(
'unsubscribed': MailPoet.I18n.t('unsubscribed'),
'bounced': MailPoet.I18n.t('bounced')
},
filter: function(subscriber, value) {
filter: function (subscriber, value) {
if (~~(subscriber.wp_user_id) > 0 && value === 'unconfirmed') {
return false;
}
@ -63,28 +63,28 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
selected: function(subscriber) {
selected: function (subscriber) {
if (Array.isArray(subscriber.subscriptions) === false) {
return null;
}
return subscriber.subscriptions.map(function(subscription) {
return subscriber.subscriptions.map(function (subscription) {
if (subscription.status === 'subscribed') {
return subscription.segment_id;
}
});
},
filter: function(segment) {
filter: function (segment) {
return !!(!segment.deleted_at && segment.type === 'default');
},
getLabel: function(segment) {
getLabel: function (segment) {
return segment.name + ' ('+ segment.subscribers +')';
},
getSearchLabel: function(segment, subscriber) {
getSearchLabel: function (segment, subscriber) {
let label = '';
if (subscriber.subscriptions !== undefined) {
subscriber.subscriptions.map(function(subscription) {
subscriber.subscriptions.map(function (subscription) {
if (segment.id === subscription.segment_id) {
label = segment.name;
@ -139,15 +139,15 @@ define(
});
var messages = {
onUpdate: function() {
onUpdate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('subscriberUpdated'));
},
onCreate: function() {
onCreate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('subscriberAdded'));
}
};
var beforeFormContent = function(subscriber) {
var beforeFormContent = function (subscriber) {
if (~~(subscriber.wp_user_id) > 0) {
return (
<p className="description">
@ -167,7 +167,7 @@ define(
}
};
var afterFormContent = function(subscriber) {
var afterFormContent = function (subscriber) {
return (
<p className="description">
<strong>
@ -180,7 +180,7 @@ define(
var Link = Router.Link;
var SubscriberForm = React.createClass({
render: function() {
render: function () {
return (
<div>
<h1 className="title">

View File

@ -104,12 +104,12 @@ const bulk_actions = [
{
name: 'moveToList',
label: MailPoet.I18n.t('moveToList'),
onSelect: function() {
onSelect: function () {
let field = {
id: 'move_to_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function(segment) {
filter: function (segment) {
return !!(
!segment.deleted_at && segment.type === 'default'
);
@ -120,12 +120,12 @@ const bulk_actions = [
<Selection field={ field }/>
);
},
getData: function() {
getData: function () {
return {
segment_id: ~~(jQuery('#move_to_segment').val())
};
},
onSuccess: function(response) {
onSuccess: function (response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersMovedToList')
.replace('%$1d', (~~(response.meta.count)).toLocaleString())
@ -136,12 +136,12 @@ const bulk_actions = [
{
name: 'addToList',
label: MailPoet.I18n.t('addToList'),
onSelect: function() {
onSelect: function () {
let field = {
id: 'add_to_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function(segment) {
filter: function (segment) {
return !!(
!segment.deleted_at && segment.type === 'default'
);
@ -152,12 +152,12 @@ const bulk_actions = [
<Selection field={ field }/>
);
},
getData: function() {
getData: function () {
return {
segment_id: ~~(jQuery('#add_to_segment').val())
};
},
onSuccess: function(response) {
onSuccess: function (response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersAddedToList')
.replace('%$1d', (~~response.meta.count).toLocaleString())
@ -168,12 +168,12 @@ const bulk_actions = [
{
name: 'removeFromList',
label: MailPoet.I18n.t('removeFromList'),
onSelect: function() {
onSelect: function () {
let field = {
id: 'remove_from_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function(segment) {
filter: function (segment) {
return !!(
segment.type === 'default'
);
@ -184,12 +184,12 @@ const bulk_actions = [
<Selection field={ field }/>
);
},
getData: function() {
getData: function () {
return {
segment_id: ~~(jQuery('#remove_from_segment').val())
};
},
onSuccess: function(response) {
onSuccess: function (response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
.replace('%$1d', (~~response.meta.count).toLocaleString())
@ -200,7 +200,7 @@ const bulk_actions = [
{
name: 'removeFromAllLists',
label: MailPoet.I18n.t('removeFromAllLists'),
onSuccess: function(response) {
onSuccess: function (response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
.replace('%$1d', (~~response.meta.count).toLocaleString())
@ -210,7 +210,7 @@ const bulk_actions = [
{
name: 'sendConfirmationEmail',
label: MailPoet.I18n.t('resendConfirmationEmail'),
onSuccess: function(response) {
onSuccess: function (response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleConfirmationEmailsSent')
.replace('%$1d', (~~response.meta.count).toLocaleString())
@ -228,7 +228,7 @@ const item_actions = [
{
name: 'edit',
label: MailPoet.I18n.t('edit'),
link: function(subscriber) {
link: function (subscriber) {
return (
<Link to={ `/edit/${subscriber.id}` }>{MailPoet.I18n.t('edit')}</Link>
);
@ -236,23 +236,23 @@ const item_actions = [
},
{
name: 'trash',
display: function(subscriber) {
display: function (subscriber) {
return !!(~~subscriber.wp_user_id === 0);
}
}
];
const SubscriberList = React.createClass({
getSegmentFromId: function(segment_id) {
getSegmentFromId: function (segment_id) {
let result = false;
mailpoet_segments.map(function(segment) {
mailpoet_segments.map(function (segment) {
if (segment.id === segment_id) {
result = segment;
}
});
return result;
},
renderItem: function(subscriber, actions) {
renderItem: function (subscriber, actions) {
let row_classes = classNames(
'manage-column',
'column-primary',
@ -344,7 +344,7 @@ const SubscriberList = React.createClass({
</div>
);
},
render: function() {
render: function () {
return (
<div>
<h1 className="title">