Update eslint

Only indentation updated in this commit
This commit is contained in:
Pavel Dohnal
2018-06-13 09:28:53 +01:00
parent 0545e48f8e
commit 683e9c9fa1
50 changed files with 2104 additions and 2151 deletions

View File

@ -1,12 +1,12 @@
define('admin', [
'jquery'
],
function admin(jQuery) {
jQuery(function adminDomReady($) {
// dom ready
$(function domReady() {
function admin(jQuery) {
jQuery(function adminDomReady($) {
// dom ready
$(function domReady() {
});
});
}
});
}
);

View File

@ -70,15 +70,15 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function ajax(mp, jQuery, _
// ajax request
deferred = jQuery.post(
this.options.url,
params,
null,
'json'
).then(function resultHandler(data) {
return data;
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
this.options.url,
params,
null,
'json'
).then(function resultHandler(data) {
return data;
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
// clear options
// clear options
this.options = {};
return deferred;

View File

@ -69,8 +69,8 @@ export const fromNewsletter = data =>
action: 'showPreview',
data: json,
}).done(response => fromUrl(response.meta.preview_url)
.then(resolve)
.catch(reject)
.then(resolve)
.catch(reject)
).fail(response => reject(response.errors));
});

View File

@ -7,7 +7,7 @@ define('date',
mp,
jQuery,
Moment
) {
) {
'use strict';
var MailPoet = mp;
@ -22,21 +22,21 @@ define('date',
init: function init(opts) {
var options = opts || {};
// set UTC offset
// set UTC offset
if (
options.offset === undefined
options.offset === undefined
&& window.mailpoet_date_offset !== undefined
) {
) {
options.offset = window.mailpoet_date_offset;
}
// set date format
// set date format
if (
options.format === undefined
options.format === undefined
&& window.mailpoet_date_format !== undefined
) {
) {
options.format = window.mailpoet_date_format;
}
// merge options
// merge options
this.options = jQuery.extend({}, this.defaults, options);
return this;

View File

@ -29,7 +29,7 @@ const FormFieldCheckbox = React.createClass({
{ this.props.field.values[value] }
</label>
</p>
)
)
);
return (

View File

@ -22,7 +22,7 @@ const FormFieldRadio = React.createClass({
{ this.props.field.values[value] }
</label>
</p>
)
)
);
return (

View File

@ -54,7 +54,7 @@ const FormFieldSelect = React.createClass({
>
{ this.props.field.values[value] }
</option>
)
)
);
return (

View File

@ -33,14 +33,14 @@ const FormFieldText = React.createClass({
type="text"
disabled={
(this.props.field.disabled !== undefined)
? this.props.field.disabled(this.props.item)
: false
? this.props.field.disabled(this.props.item)
: false
}
className={className}
size={
(this.props.field.size !== 'auto' && this.props.field.size > 0)
? this.props.field.size
: false
? this.props.field.size
: false
}
name={name}
id={id}

View File

@ -213,8 +213,8 @@ const Form = React.createClass({
className={formClasses}
onSubmit={
(this.props.onSubmit !== undefined)
? this.props.onSubmit
: this.handleSubmit
? this.props.onSubmit
: this.handleSubmit
}
>
{ errors }

View File

@ -596,7 +596,7 @@ WysijaForm = {
WysijaForm.toolbar.left
+ window.$(WysijaForm.options.container).getDimensions().width
+ 15
, 10);
, 10);
}
},
setToolbarPosition: function () {

View File

@ -101,11 +101,11 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
lines = value.trim().split('\n');
// remove header & footer
// remove header & footer
lines.shift();
lines.pop();
// return concatenated lines
// return concatenated lines
return lines.join('');
});

View File

@ -3,7 +3,7 @@ define('i18n',
'mailpoet'
], function i18n(
mp
) {
) {
'use strict';
var MailPoet = mp;

View File

@ -96,7 +96,7 @@ const ListingBulkActions = React.createClass({
value={action.name}
key={`action-${action.name}`}
>{ action.label }</option>
)) }
)) }
</select>
<input
onClick={this.handleApplyAction}

View File

@ -19,12 +19,12 @@ const ListingFilters = React.createClass({
getAvailableFilters: function getAvailableFilters() {
const filters = this.props.filters;
return Object.keys(filters).filter(filter => !(
filters[filter].length === 0
filters[filter].length === 0
|| (
filters[filter].length === 1
&& !filters[filter][0].value
)
));
));
},
componentDidUpdate: function componentDidUpdate() {
const selectedFilters = this.props.filter;
@ -36,7 +36,7 @@ const ListingFilters = React.createClass({
.trigger('change');
}
}
);
);
},
render: function render() {
const filters = this.props.filters;
@ -52,9 +52,9 @@ const ListingFilters = React.createClass({
value={option.value}
key={`filter-option-${option.value}`}
>{ option.label }</option>
)) }
)) }
</select>
));
));
let button;

View File

@ -19,8 +19,8 @@ class ListingGroups extends React.Component {
}
const classes = classNames(
{ current: (group.name === this.props.group) }
);
{ current: (group.name === this.props.group) }
);
return (
<li key={group.name}>

View File

@ -66,70 +66,70 @@ const ListingItem = React.createClass({
if (customActions.length > 0) {
let isFirst = true;
itemActions = customActions
.filter(action => action.display === undefined || action.display(this.props.item))
.map((action, index) => {
let customAction = null;
.filter(action => action.display === undefined || action.display(this.props.item))
.map((action, index) => {
let customAction = null;
if (action.name === 'trash') {
customAction = (
<span key={`action-${action.name}`} className="trash">
{(!isFirst) ? ' | ' : ''}
<a
href="javascript:;"
onClick={() => this.handleTrashItem(this.props.item.id)}
if (action.name === 'trash') {
customAction = (
<span key={`action-${action.name}`} className="trash">
{(!isFirst) ? ' | ' : ''}
<a
href="javascript:;"
onClick={() => this.handleTrashItem(this.props.item.id)}
>
{MailPoet.I18n.t('moveToTrash')}
</a>
</span>
);
} else if (action.refresh) {
customAction = (
<span
onClick={this.props.onRefreshItems}
key={`action-${action.name}`}
className={action.name}
role="button"
tabIndex={index}
>
{MailPoet.I18n.t('moveToTrash')}
</a>
</span>
);
} else if (action.refresh) {
customAction = (
<span
onClick={this.props.onRefreshItems}
key={`action-${action.name}`}
className={action.name}
role="button"
tabIndex={index}
>
{(!isFirst) ? ' | ' : ''}
{ action.link(this.props.item) }
</span>
);
} else if (action.link) {
customAction = (
<span
key={`action-${action.name}`}
className={action.name}
>
{(!isFirst) ? ' | ' : ''}
{ action.link(this.props.item) }
</span>
);
} else {
customAction = (
<span
key={`action-${action.name}`}
className={action.name}
>
{(!isFirst) ? ' | ' : ''}
<a
href="javascript:;"
onClick={
(action.onClick !== undefined)
? () => action.onClick(this.props.item, this.props.onRefreshItems)
: false
}
>{ action.label }</a>
</span>
);
}
{(!isFirst) ? ' | ' : ''}
{ action.link(this.props.item) }
</span>
);
} else if (action.link) {
customAction = (
<span
key={`action-${action.name}`}
className={action.name}
>
{(!isFirst) ? ' | ' : ''}
{ action.link(this.props.item) }
</span>
);
} else {
customAction = (
<span
key={`action-${action.name}`}
className={action.name}
>
{(!isFirst) ? ' | ' : ''}
<a
href="javascript:;"
onClick={
(action.onClick !== undefined)
? () => action.onClick(this.props.item, this.props.onRefreshItems)
: false
}
>{ action.label }</a>
</span>
);
}
if (customAction !== null && isFirst === true) {
isFirst = false;
}
if (customAction !== null && isFirst === true) {
isFirst = false;
}
return customAction;
});
return customAction;
});
} else {
itemActions = (
<span className="edit">
@ -228,39 +228,39 @@ const ListingItems = React.createClass({
);
}
const selectAllClasses = classNames(
'mailpoet_select_all',
'mailpoet_select_all',
{ mailpoet_hidden: (
this.props.selection === false
this.props.selection === false
|| (this.props.count <= this.props.limit)
),
),
}
);
);
return (
<tbody>
<tr className={selectAllClasses}>
<td colSpan={
this.props.columns.length
this.props.columns.length
+ (this.props.is_selectable ? 1 : 0)
}
}
>
{
(this.props.selection !== 'all')
(this.props.selection !== 'all')
? MailPoet.I18n.t('selectAllLabel')
: MailPoet.I18n.t('selectedAllLabel').replace(
'%d',
this.props.count
)
}
}
&nbsp;
<a
onClick={this.props.onSelectAll}
href="javascript:;"
>{
(this.props.selection !== 'all')
(this.props.selection !== 'all')
? MailPoet.I18n.t('selectAllLink')
: MailPoet.I18n.t('clearSelection')
}</a>
}</a>
</td>
</tr>
@ -326,7 +326,7 @@ const Listing = React.createClass({
},
initWithParams: function initWithParams(params) {
const state = this.getInitialState();
// check for url params
// check for url params
if (params.splat) {
params.splat.split('/').forEach((param) => {
const [key, value] = this.getParam(param);
@ -380,15 +380,15 @@ const Listing = React.createClass({
if (this.props.location) {
const params = Object.keys(this.state)
.filter(key => (
[
'group',
'filter',
'search',
'page',
'sort_by',
'sort_order',
].indexOf(key) !== -1
))
[
'group',
'filter',
'search',
'page',
'sort_by',
'sort_order',
].indexOf(key) !== -1
))
.map((key) => {
let value = this.state[key];
if (value === Object(value)) {

View File

@ -181,9 +181,9 @@ define('modal', ['mailpoet', 'jquery'],
},
initOverlay: function () {
if (jQuery('#mailpoet_modal_overlay').length === 0) {
// insert overlay into the DOM
// insert overlay into the DOM
jQuery('body').append(this.templates.overlay);
// insert loading indicator into overlay
// insert loading indicator into overlay
jQuery('#mailpoet_modal_overlay').append(this.templates.loading);
}
return this;
@ -191,10 +191,10 @@ define('modal', ['mailpoet', 'jquery'],
toggleOverlay: function (toggle) {
if (toggle === true) {
jQuery('#mailpoet_modal_overlay')
.removeClass('mailpoet_overlay_hidden');
.removeClass('mailpoet_overlay_hidden');
} else {
jQuery('#mailpoet_modal_overlay')
.addClass('mailpoet_overlay_hidden');
.addClass('mailpoet_overlay_hidden');
}
return this;
@ -250,60 +250,60 @@ define('modal', ['mailpoet', 'jquery'],
},
loadTemplate: function () {
if (this.subpanels.length > 0) {
// hide panel
// hide panel
jQuery('.mailpoet_' + this.options.type + '_wrapper').hide();
// add sub panel wrapper
// add sub panel wrapper
jQuery('#mailpoet_' + this.options.type)
.append(this.templates.subpanel);
.append(this.templates.subpanel);
// add sub panel content
// add sub panel content
jQuery('.mailpoet_' + this.options.type + '_body').last()
.html(this.subpanels[(this.subpanels.length - 1)].element);
.html(this.subpanels[(this.subpanels.length - 1)].element);
// focus on sub panel
// focus on sub panel
if (this.options.focus) {
this.focus();
}
} else if (this.options.element) {
jQuery('.mailpoet_' + this.options.type + '_body').empty();
jQuery('.mailpoet_' + this.options.type + '_body')
.append(this.options.element);
.append(this.options.element);
} else {
jQuery('.mailpoet_' + this.options.type + '_body')
.html(
this.options.body_template(
this.options.data
)
);
.html(
this.options.body_template(
this.options.data
)
);
}
return this;
},
loadUrl: function () {
if (this.options.method === 'get') {
// make ajax request
// make ajax request
jQuery.getJSON(this.options.url,
function (data) {
this.options.data = jQuery.extend({}, this.options.data, data);
// load template using fetched data
this.loadTemplate();
// show modal window
this.showModal();
}.bind(this)
);
function (data) {
this.options.data = jQuery.extend({}, this.options.data, data);
// load template using fetched data
this.loadTemplate();
// show modal window
this.showModal();
}.bind(this)
);
} else if (this.options.method === 'post') {
// make ajax request
// make ajax request
jQuery.post(this.options.url, JSON.stringify(this.options.params),
function (data) {
this.options.data = jQuery.extend({}, this.options.data, data);
// load template using fetched data
this.loadTemplate();
// show modal window
this.showModal();
}.bind(this),
'json'
);
function (data) {
this.options.data = jQuery.extend({}, this.options.data, data);
// load template using fetched data
this.loadTemplate();
// show modal window
this.showModal();
}.bind(this),
'json'
);
}
return this;
@ -311,18 +311,18 @@ define('modal', ['mailpoet', 'jquery'],
setDimensions: function () {
switch (this.options.type) {
case 'popup':
// set popup dimensions
// set popup dimensions
jQuery('#mailpoet_popup').css({
width: this.options.width,
height: this.options.height
});
// set popup wrapper height
// set popup wrapper height
jQuery('#mailpoet_popup_wrapper').css({
height: this.options.height
});
break;
case 'panel':
// set dimensions
// set dimensions
if (this.options.position === 'right') {
jQuery('#mailpoet_panel').css({
width: this.options.width,
@ -365,7 +365,7 @@ define('modal', ['mailpoet', 'jquery'],
break;
case 'panel':
setTimeout(function () {
// set position of popup depending on screen dimensions.
// set position of popup depending on screen dimensions.
if (this.options.position === 'right') {
jQuery('#mailpoet_panel').css({
marginRight: 0
@ -383,22 +383,22 @@ define('modal', ['mailpoet', 'jquery'],
return this;
},
showModal: function () {
// set modal dimensions
// set modal dimensions
this.setDimensions();
// remember the previously focused element
// remember the previously focused element
this.prevFocus = jQuery(':focus');
// show popup
// show popup
jQuery('#mailpoet_' + this.options.type).show();
// display overlay
// display overlay
this.showOverlay();
// set modal position
// set modal position
this.setPosition();
// add class on highlighted elements
// add class on highlighted elements
if (this.options.highlight !== null) {
if (this.options.highlight.length > 0) {
this.highlightOn(this.options.highlight);
@ -409,10 +409,10 @@ define('modal', ['mailpoet', 'jquery'],
this.focus();
}
// set popup as opened
// set popup as opened
this.opened = true;
// trigger init event if specified
// trigger init event if specified
if (this.options.onInit !== null) {
this.options.onInit(this);
}
@ -423,9 +423,9 @@ define('modal', ['mailpoet', 'jquery'],
if (this.options.type === 'popup') {
jQuery('#mailpoet_' + this.options.type).focus();
} else {
// panel and subpanel
// panel and subpanel
jQuery('#mailpoet_' + this.options.type + ' .mailpoet_panel_wrapper')
.filter(':visible').focus();
.filter(':visible').focus();
}
return this;
},
@ -435,17 +435,17 @@ define('modal', ['mailpoet', 'jquery'],
},
highlightOff: function () {
jQuery('.mailpoet_modal_highlight')
.removeClass('mailpoet_modal_highlight');
.removeClass('mailpoet_modal_highlight');
return this;
},
hideModal: function () {
// set modal as closed
// set modal as closed
this.opened = false;
// hide modal
// hide modal
jQuery('#mailpoet_' + this.options.type).hide();
// remove class on highlighted elements
// remove class on highlighted elements
this.highlightOff();
return this;
@ -459,46 +459,46 @@ define('modal', ['mailpoet', 'jquery'],
return this;
},
popup: function (opts) {
// get options
// get options
var options = opts || {};
// set modal type
// set modal type
options.type = 'popup';
// set overlay state
// set overlay state
options.overlay = options.overlay || true;
// initialize modal
// initialize modal
this.init(options);
// open modal
// open modal
this.open();
return this;
},
panel: function (opts) {
// get options
// get options
var options = opts || {};
// reset subpanels
// reset subpanels
this.subpanels = [];
// set modal type
// set modal type
options.type = 'panel';
// set overlay state
// set overlay state
options.overlay = options.overlay || false;
// set highlighted element
// set highlighted element
options.highlight = options.highlight || null;
// set modal dimensions
// set modal dimensions
options.width = options.width || '40%';
options.height = options.height || 'auto';
// initialize modal
// initialize modal
this.init(options);
// open modal
// open modal
this.open();
return this;
},
subpanel: function (options) {
if (this.opened === false) {
// if no panel is already opened, let's create one instead
// if no panel is already opened, let's create one instead
this.panel(options);
} else {
// if a panel is already opened, add a sub panel to it
// if a panel is already opened, add a sub panel to it
this.subpanels.push(options);
this.loadTemplate();
}
@ -506,7 +506,7 @@ define('modal', ['mailpoet', 'jquery'],
return this;
},
loading: function (toggle) {
// make sure the overlay is initialized and that it's visible
// make sure the overlay is initialized and that it's visible
this.initOverlay(true);
if (toggle === true) {
@ -520,32 +520,32 @@ define('modal', ['mailpoet', 'jquery'],
showLoading: function () {
jQuery('#mailpoet_loading').show();
// add loading class to overlay
// add loading class to overlay
jQuery('#mailpoet_modal_overlay')
.addClass('mailpoet_overlay_loading');
.addClass('mailpoet_overlay_loading');
return this;
},
hideLoading: function () {
jQuery('#mailpoet_loading').hide();
// remove loading class from overlay
// remove loading class from overlay
jQuery('#mailpoet_modal_overlay')
.removeClass('mailpoet_overlay_loading');
.removeClass('mailpoet_overlay_loading');
return this;
},
open: function () {
// load template if specified
// load template if specified
if (this.options.template !== null) {
// check if a url was specified to get extra data
// check if a url was specified to get extra data
if (this.options.url !== null) {
this.loadUrl();
} else {
// load template
// load template
this.loadTemplate();
// show modal window
// show modal window
this.showModal();
}
} else {
@ -585,7 +585,7 @@ define('modal', ['mailpoet', 'jquery'],
destroy: function () {
this.hideOverlay();
// remove extra modal
// remove extra modal
if (jQuery('#mailpoet_' + this.options.type).length > 0) {
jQuery('#mailpoet_' + this.options.type).remove();
}
@ -598,16 +598,16 @@ define('modal', ['mailpoet', 'jquery'],
if (this.isLocked() === true) { return this; }
if (this.subpanels.length > 0) {
// close subpanel
// close subpanel
jQuery('.mailpoet_' + this.options.type + '_wrapper').last().remove();
// show previous panel
// show previous panel
jQuery('.mailpoet_' + this.options.type + '_wrapper').last().show();
// remove last subpanels
// remove last subpanels
this.subpanels.pop();
// focus on previous panel
// focus on previous panel
if (this.options.focus) {
this.focus();
}
@ -615,21 +615,21 @@ define('modal', ['mailpoet', 'jquery'],
return this;
}
// remove event handlers
// remove event handlers
this.removeEvents();
// hide modal window
// hide modal window
this.hideModal();
// destroy modal element
// destroy modal element
this.destroy();
// restore the previously focused element
// restore the previously focused element
if (this.prevFocus !== undefined) {
this.prevFocus.focus();
}
// reset options
// reset options
this.options = {
onSuccess: null,
onCancel: null

View File

@ -426,7 +426,7 @@ define([
position: 'before'
};
}
// Second half of the element
// Second half of the element
return {
index: index,
position: 'after'

View File

@ -119,16 +119,16 @@ define([
}
}
})
.preventDefault('auto')
.styleCursor(false)
.actionChecker(function actionChecker(pointer, event, action) {
.preventDefault('auto')
.styleCursor(false)
.actionChecker(function actionChecker(pointer, event, action) {
// Disable dragging with right click
if (event.button !== 0) {
return null;
}
if (event.button !== 0) {
return null;
}
return action;
});
return action;
});
if (this.options.drop !== undefined) {
interactable.getDropModel = this.options.drop;

View File

@ -54,17 +54,17 @@ define([
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
}
})
.on('resizestart', function () { // eslint-disable-line func-names
that.isBeingResized = true;
that.$el.addClass('mailpoet_resize_active');
}).on('resizemove', function (event) { // eslint-disable-line func-names
var onResize = that.options.onResize.bind(that);
return onResize(event);
})
.on('resizeend', function () { // eslint-disable-line func-names
that.isBeingResized = null;
that.$el.removeClass('mailpoet_resize_active');
});
.on('resizestart', function () { // eslint-disable-line func-names
that.isBeingResized = true;
that.$el.addClass('mailpoet_resize_active');
}).on('resizemove', function (event) { // eslint-disable-line func-names
var onResize = that.options.onResize.bind(that);
return onResize(event);
})
.on('resizeend', function () { // eslint-disable-line func-names
that.isBeingResized = null;
that.$el.removeClass('mailpoet_resize_active');
});
},
showResizeHandle: function () { // eslint-disable-line func-names
if (typeof this.options.resizeHandleSelector === 'string') {

View File

@ -65,11 +65,11 @@ define([
editor.focus();
if (that._isActivationClick) {
editor.selection.setRng(
window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(
e.clientX,
e.clientY,
editor.getDoc()
)
window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(
e.clientX,
e.clientY,
editor.getDoc()
)
);
that._isActivationClick = false;
}

View File

@ -27,7 +27,7 @@ define([
SuperModel,
_,
jQuery
) {
) {
'use strict';
var Module = {};

View File

@ -22,7 +22,7 @@ define([
SuperModel,
_,
jQuery
) {
) {
'use strict';
var Module = {};

View File

@ -36,7 +36,7 @@ define([
BaseBlock,
ButtonBlock,
DividerBlock
) {
) {
'use strict';
var Module = {};

View File

@ -257,7 +257,7 @@ define([
if ((App.getNewsletter().get('type') === 'notification') &&
contents.indexOf('"type":"automatedLatestContent"') < 0 &&
contents.indexOf('"type":"automatedLatestContentLayout"') < 0
) {
) {
this.showValidationError(MailPoet.I18n.t('automatedLatestContentMissing'));
return;
}

View File

@ -17,7 +17,7 @@ define([
SuperModel,
_,
jQuery
) {
) {
'use strict';
var Module = {};

View File

@ -32,52 +32,52 @@ const initializeEditor = (config) => {
id: getUrlParam('id'),
},
})
.always(() => MailPoet.Modal.loading(false))
.done((response) => {
const newsletter = response.data;
.always(() => MailPoet.Modal.loading(false))
.done((response) => {
const newsletter = response.data;
Promise.resolve(Hooks.applyFilters('mailpoet_newsletters_editor_extend_config', config, newsletter)).then((extendedConfig) => {
window.EditorApplication.start({
newsletter,
config: extendedConfig,
});
}).catch(() => {
window.EditorApplication.start({
newsletter,
config,
Promise.resolve(Hooks.applyFilters('mailpoet_newsletters_editor_extend_config', config, newsletter)).then((extendedConfig) => {
window.EditorApplication.start({
newsletter,
config: extendedConfig,
});
}).catch(() => {
window.EditorApplication.start({
newsletter,
config,
});
});
renderBreadcrumb(newsletter.type);
if (newsletter.status === 'sending' && newsletter.queue && newsletter.queue.status === null) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sending_queue',
action: 'pause',
data: {
newsletter_id: newsletter.id,
},
})
.done(() => MailPoet.Notice.success(MailPoet.I18n.t('newsletterIsPaused')))
.fail((pauseFailResponse) => {
if (pauseFailResponse.errors.length > 0) {
MailPoet.Notice.error(
pauseFailResponse.errors.map(error => error.message),
{ scroll: true, static: true }
);
}
});
}
})
.fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(error => error.message),
{ scroll: true, static: true }
);
}
});
renderBreadcrumb(newsletter.type);
if (newsletter.status === 'sending' && newsletter.queue && newsletter.queue.status === null) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sending_queue',
action: 'pause',
data: {
newsletter_id: newsletter.id,
},
})
.done(() => MailPoet.Notice.success(MailPoet.I18n.t('newsletterIsPaused')))
.fail((pauseFailResponse) => {
if (pauseFailResponse.errors.length > 0) {
MailPoet.Notice.error(
pauseFailResponse.errors.map(error => error.message),
{ scroll: true, static: true }
);
}
});
}
})
.fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(error => error.message),
{ scroll: true, static: true }
);
}
});
};
Hooks.addAction('mailpoet_newsletters_editor_initialize', initializeEditor);

View File

@ -9,8 +9,8 @@ const ListingHeading = () => (
className="page-title-action"
to="/new"
onClick={() => MailPoet.trackEvent(
'Emails > Add New',
{ 'MailPoet Free version': window.mailpoet_version }
'Emails > Add New',
{ 'MailPoet Free version': window.mailpoet_version }
)}
data-automation-id="new_email"
>

View File

@ -69,14 +69,14 @@ const QueueMixin = {
);
}
const progressClasses = classNames(
'mailpoet_progress',
{ mailpoet_progress_complete: newsletter.queue.status === 'completed' }
);
'mailpoet_progress',
{ mailpoet_progress_complete: newsletter.queue.status === 'completed' }
);
// calculate percentage done
let percentage = Math.round(
(newsletter.queue.count_processed * 100) / (newsletter.queue.count_total)
);
(newsletter.queue.count_processed * 100) / (newsletter.queue.count_total)
);
let label;
@ -84,12 +84,12 @@ const QueueMixin = {
label = (
<span>
{
MailPoet.I18n.t('newsletterQueueCompleted')
MailPoet.I18n.t('newsletterQueueCompleted')
.replace('%$1d', parseInt(newsletter.queue.count_processed, 10).toLocaleString())
.replace('%$2d', parseInt(newsletter.queue.count_total, 10).toLocaleString())
}
}
</span>
);
);
} else {
const resumeSendingClick = _.partial(this.resumeSending, newsletter);
const pauseSendingClick = _.partial(this.pauseSending, newsletter);
@ -101,7 +101,7 @@ const QueueMixin = {
id={`resume_${newsletter.id}`}
className="button"
style={{ display: (newsletter.queue.status === 'paused')
? 'inline-block' : 'none' }}
? 'inline-block' : 'none' }}
href="javascript:;"
onClick={resumeSendingClick}
>{MailPoet.I18n.t('resume')}</a>
@ -109,12 +109,12 @@ const QueueMixin = {
id={`pause_${newsletter.id}`}
className="button mailpoet_pause"
style={{ display: (newsletter.queue.status === null)
? 'inline-block' : 'none' }}
? 'inline-block' : 'none' }}
href="javascript:;"
onClick={pauseSendingClick}
>{MailPoet.I18n.t('pause')}</a>
</span>
);
);
}
let progressBarWidth = 0;
@ -258,7 +258,7 @@ const StatisticsMixin = {
{ tooEarlyForStats && (
<div className="mailpoet_badge mailpoet_badge_green">
{MailPoet.I18n.t('checkBackInHours')
.replace('%$1d', showStatsTimeout - sentHoursAgo)}
.replace('%$1d', showStatsTimeout - sentHoursAgo)}
</div>
) }
</div>
@ -406,7 +406,7 @@ const MailerMixin = {
}
if (state.meta.mta_log.error.error_code) {
mailerErrorNotice += ` ${MailPoet.I18n.t('mailerErrorCode')
.replace('%$1s', state.meta.mta_log.error.error_code)}`;
.replace('%$1s', state.meta.mta_log.error.error_code)}`;
}
return (
<div>

View File

@ -216,34 +216,34 @@ const NewsletterListNotification = React.createClass({
switch (newsletter.options.intervalType) {
case 'daily':
sendingFrequency = MailPoet.I18n.t('sendDaily').replace(
'%$1s', timeOfDayValues[newsletter.options.timeOfDay]
);
'%$1s', timeOfDayValues[newsletter.options.timeOfDay]
);
break;
case 'weekly':
sendingFrequency = MailPoet.I18n.t('sendWeekly').replace(
'%$1s', weekDayValues[newsletter.options.weekDay]
).replace(
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
);
'%$1s', weekDayValues[newsletter.options.weekDay]
).replace(
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
);
break;
case 'monthly':
sendingFrequency = MailPoet.I18n.t('sendMonthly').replace(
'%$1s', monthDayValues[newsletter.options.monthDay]
).replace(
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
);
'%$1s', monthDayValues[newsletter.options.monthDay]
).replace(
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
);
break;
case 'nthWeekDay':
sendingFrequency = MailPoet.I18n.t('sendNthWeekDay').replace(
'%$1s', nthWeekDayValues[newsletter.options.nthWeekDay]
).replace(
'%$2s', weekDayValues[newsletter.options.weekDay]
).replace(
'%$3s', timeOfDayValues[newsletter.options.timeOfDay]
);
'%$1s', nthWeekDayValues[newsletter.options.nthWeekDay]
).replace(
'%$2s', weekDayValues[newsletter.options.weekDay]
).replace(
'%$3s', timeOfDayValues[newsletter.options.timeOfDay]
);
break;
case 'immediately':

View File

@ -210,8 +210,8 @@ const NewsletterListWelcome = React.createClass({
);
}
sendingEvent = MailPoet.I18n.t('welcomeEventSegment').replace(
'%$1s', segment.name
);
'%$1s', segment.name
);
break;
}

View File

@ -109,20 +109,20 @@ const NewsletterSend = React.createClass({
return this.saveNewsletter(e).done(() => {
this.setState({ loading: true });
})
.done((response) => {
switch (response.data.type) {
case 'notification':
case 'welcome':
return this.activateNewsletter(response);
default:
return this.sendNewsletter(response);
}
})
.fail((err) => {
this.showError(err);
this.setState({ loading: false });
MailPoet.Modal.loading(false);
});
.done((response) => {
switch (response.data.type) {
case 'notification':
case 'welcome':
return this.activateNewsletter(response);
default:
return this.sendNewsletter(response);
}
})
.fail((err) => {
this.showError(err);
this.setState({ loading: false });
MailPoet.Modal.loading(false);
});
},
sendNewsletter: function sendNewsletter(newsletter) {
return MailPoet.Ajax.post(
@ -242,12 +242,12 @@ const NewsletterSend = React.createClass({
}
});
})
.fail((err) => {
this.showError(err);
})
.always(() => {
this.setState({ loading: false });
});
.fail((err) => {
this.showError(err);
})
.always(() => {
this.setState({ loading: false });
});
}
return false;
},
@ -289,8 +289,8 @@ const NewsletterSend = React.createClass({
'status', 'updated_at', 'type',
];
const newsletterData = _.omit(
data,
IGNORED_NEWSLETTER_PROPERTIES
data,
IGNORED_NEWSLETTER_PROPERTIES
);
return MailPoet.Ajax.post({
@ -363,7 +363,7 @@ const NewsletterSend = React.createClass({
onClick={this.handleResume}
value={MailPoet.I18n.t('resume')}
/>
:
:
<input
className="button button-primary"
type="button"

View File

@ -165,7 +165,7 @@ const TimeSelect = React.createClass({
>
{ timeOfDayItems[value] }
</option>
)
)
);
return (

View File

@ -155,7 +155,7 @@ const NewsletterTypes = React.createClass({
</div>
</div>
</li>
), this)}
), this)}
</ul>
</div>
);

View File

@ -53,7 +53,7 @@ class AutomaticEmailEvent extends React.PureComponent {
<span className={`mailpoet_badge mailpoet_badge_${event.badge.style}`}>
{event.badge.text}
</span>
) : ''
) : ''
}
</div>
<p>{event.description}</p>

View File

@ -25,7 +25,7 @@ class AutomaticEmailEventsList extends React.Component {
key={index}
eventsConfigurator={this.eventsConfigurator}
/>
)
)
);
return (

View File

@ -111,9 +111,9 @@ const WelcomeScheduling = React.createClass({
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(error => error.message),
{ scroll: true }
);
response.errors.map(error => error.message),
{ scroll: true }
);
}
});
},

View File

@ -3,7 +3,7 @@ define('num',
'mailpoet'
], function ( // eslint-disable-line func-names
mp
) {
) {
'use strict';
var MailPoet = mp;
@ -12,10 +12,10 @@ define('num',
var precision = precisionOpts || 0;
var factor = Math.pow(10, precision);
return (Math.round(num * factor) / factor)
.toLocaleString(
undefined,
{ minimumFractionDigits: precision, maximumFractionDigits: precision }
);
.toLocaleString(
undefined,
{ minimumFractionDigits: precision, maximumFractionDigits: precision }
);
}
};
});

View File

@ -64,43 +64,43 @@ function ( // eslint-disable-line func-names
data: formData.data
}).fail(function (response) { // eslint-disable-line func-names
form.find('.mailpoet_validate_error').html(
response.errors.map(function (error) { // eslint-disable-line func-names
return error.message;
}).join('<br />')
).show();
response.errors.map(function (error) { // eslint-disable-line func-names
return error.message;
}).join('<br />')
).show();
}).done(function (response) { // eslint-disable-line func-names
if (window.grecaptcha && formData.recaptcha) {
window.grecaptcha.reset(formData.recaptcha);
}
return response;
}).done(function (response) { // eslint-disable-line func-names
// successfully subscribed
// successfully subscribed
if (
response.meta !== undefined
response.meta !== undefined
&& response.meta.redirect_url !== undefined
) {
// go to page
) {
// go to page
window.location.href = response.meta.redirect_url;
} else {
// display success message
// display success message
form.find('.mailpoet_validate_success').show();
}
// reset form
// reset form
form.trigger('reset');
// reset validation
// reset validation
parsley.reset();
// reset captcha
if (window.grecaptcha && formData.recaptcha) {
window.grecaptcha.reset(formData.recaptcha);
}
// resize iframe
// resize iframe
if (
window.frameElement !== null
window.frameElement !== null
&& MailPoet !== undefined
&& MailPoet.Iframe
) {
) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});

View File

@ -118,14 +118,14 @@ const itemActions = [
},
}).done((response) => {
MailPoet.Notice.success(
MailPoet.I18n.t('listDuplicated').replace('%$1s', response.data.name)
);
MailPoet.I18n.t('listDuplicated').replace('%$1s', response.data.name)
);
refresh();
}).fail((response) => {
MailPoet.Notice.error(
response.errors.map(error => error.message),
{ scroll: true }
);
response.errors.map(error => error.message),
{ scroll: true }
);
}),
display: function display(segment) {
return (segment.type !== 'wp_users');

View File

@ -39,8 +39,8 @@ define(
// toggle SPF (hidden if the sending method is MailPoet)
jQuery('#mailpoet_mta_spf')[
(group === 'mailpoet')
? 'hide'
: 'show'
? 'hide'
: 'show'
]();
// hide sending methods

View File

@ -149,15 +149,15 @@ function beforeFormContent(subscriber) {
return (
<p className="description">
{ ReactStringReplace(
MailPoet.I18n.t('WPUserEditNotice'),
/\[link\](.*?)\[\/link\]/g,
(match, i) => (
<a
key={i}
href={`user-edit.php?user_id=${subscriber.wp_user_id}`}
>{ match }</a>
)
MailPoet.I18n.t('WPUserEditNotice'),
/\[link\](.*?)\[\/link\]/g,
(match, i) => (
<a
key={i}
href={`user-edit.php?user_id=${subscriber.wp_user_id}`}
>{ match }</a>
)
)
}
</p>
);

View File

@ -5,149 +5,149 @@ define(
'mailpoet',
'handlebars'
],
function exportSubscribers(
_,
jQuery,
MailPoet,
Handlebars
) {
if (!jQuery('#mailpoet_subscribers_export').length) {
return;
}
jQuery(document).ready(function documentReady() {
var segmentsContainerElement;
var subscriberFieldsContainerElement;
var nextStepButton;
var renderSegmentsAndFields;
var subscribersExportTemplate;
if (!window.exportData.segments) {
return;
}
subscribersExportTemplate =
function exportSubscribers(
_,
jQuery,
MailPoet,
Handlebars
) {
if (!jQuery('#mailpoet_subscribers_export').length) {
return;
}
jQuery(document).ready(function documentReady() {
var segmentsContainerElement;
var subscriberFieldsContainerElement;
var nextStepButton;
var renderSegmentsAndFields;
var subscribersExportTemplate;
if (!window.exportData.segments) {
return;
}
subscribersExportTemplate =
Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
// render template
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribersExportTemplate(window.exportData));
// render template
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribersExportTemplate(window.exportData));
function toggleNextStepButton(condition) {
var disabled = 'button-disabled';
if (condition === 'on') {
nextStepButton.removeClass(disabled);
} else {
nextStepButton.addClass(disabled);
}
}
function toggleNextStepButton(condition) {
var disabled = 'button-disabled';
if (condition === 'on') {
nextStepButton.removeClass(disabled);
} else {
nextStepButton.addClass(disabled);
}
}
// define reusable variables
segmentsContainerElement = jQuery('#export_lists');
subscriberFieldsContainerElement = jQuery('#export_columns');
nextStepButton = jQuery('a.mailpoet_export_process');
renderSegmentsAndFields = function renderSegmentsFields(container, data) {
if (container.data('select2')) {
container
.html('')
.select2('destroy');
}
container
.select2({
data: data,
width: '20em',
templateResult: function templateResult(item) {
return (item.subscriberCount > 0)
? item.name + ' (' + parseInt(item.subscriberCount, 10).toLocaleString() + ')'
: item.name;
},
templateSelection: function templateSelection(item) {
return (item.subscriberCount > 0)
? item.name + ' (' + parseInt(item.subscriberCount, 10).toLocaleString() + ')'
: item.name;
}
})
.on('select2:selecting', function onSelect2Selecting(selectEvent) {
var selectElement = this;
var selectedOptionId = selectEvent.params.args.data.id;
var fieldsToExclude = [
'select',
'deselect'
];
var allOptions;
if (_.contains(fieldsToExclude, selectedOptionId)) {
selectEvent.preventDefault();
if (selectedOptionId === 'deselect') {
jQuery(selectElement).val('').trigger('change');
} else {
allOptions = [];
_.each(container.find('option'), function eachOption(field) {
if (!_.contains(fieldsToExclude, field.value)) {
allOptions.push(field.value);
}
});
jQuery(selectElement).val(allOptions).trigger('change');
}
jQuery(selectElement).select2('close');
}
})
.on('change', function onCHange() {
if ((window.exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
// define reusable variables
segmentsContainerElement = jQuery('#export_lists');
subscriberFieldsContainerElement = jQuery('#export_columns');
nextStepButton = jQuery('a.mailpoet_export_process');
renderSegmentsAndFields = function renderSegmentsFields(container, data) {
if (container.data('select2')) {
container
.html('')
.select2('destroy');
}
container
.select2({
data: data,
width: '20em',
templateResult: function templateResult(item) {
return (item.subscriberCount > 0)
? item.name + ' (' + parseInt(item.subscriberCount, 10).toLocaleString() + ')'
: item.name;
},
templateSelection: function templateSelection(item) {
return (item.subscriberCount > 0)
? item.name + ' (' + parseInt(item.subscriberCount, 10).toLocaleString() + ')'
: item.name;
}
})
.on('select2:selecting', function onSelect2Selecting(selectEvent) {
var selectElement = this;
var selectedOptionId = selectEvent.params.args.data.id;
var fieldsToExclude = [
'select',
'deselect'
];
var allOptions;
if (_.contains(fieldsToExclude, selectedOptionId)) {
selectEvent.preventDefault();
if (selectedOptionId === 'deselect') {
jQuery(selectElement).val('').trigger('change');
} else {
allOptions = [];
_.each(container.find('option'), function eachOption(field) {
if (!_.contains(fieldsToExclude, field.value)) {
allOptions.push(field.value);
}
});
jQuery(selectElement).val(allOptions).trigger('change');
}
jQuery(selectElement).select2('close');
}
})
.on('change', function onCHange() {
if ((window.exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
||
(!window.exportData.segments && subscriberFieldsContainerElement.select2('data').length)
) {
toggleNextStepButton('on');
} else {
toggleNextStepButton('off');
}
});
};
) {
toggleNextStepButton('on');
} else {
toggleNextStepButton('off');
}
});
};
renderSegmentsAndFields(subscriberFieldsContainerElement, window.subscriberFieldsSelect2);
renderSegmentsAndFields(segmentsContainerElement, window.segments);
renderSegmentsAndFields(subscriberFieldsContainerElement, window.subscriberFieldsSelect2);
renderSegmentsAndFields(segmentsContainerElement, window.segments);
subscriberFieldsContainerElement.val([
'email',
'first_name',
'last_name',
'list_status',
'global_status'
]).trigger('change');
subscriberFieldsContainerElement.val([
'email',
'first_name',
'last_name',
'list_status',
'global_status'
]).trigger('change');
nextStepButton.click(function nextClick() {
var exportFormat;
if (jQuery(this).hasClass('button-disabled')) {
return;
}
MailPoet.Modal.loading(true);
exportFormat = jQuery(':radio[name="option_format"]:checked').val();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processExport',
data: JSON.stringify({
export_format_option: exportFormat,
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
subscriber_fields: subscriberFieldsContainerElement.val()
})
}).always(function always() {
MailPoet.Modal.loading(false);
}).done(function done(response) {
var resultMessage = MailPoet.I18n.t('exportMessage')
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported, 133).toLocaleString() + '</strong>')
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
.replace('[/link]', '</a>');
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
window.location.href = response.data.exportFileURL;
MailPoet.trackEvent('Subscribers export completed', {
'Total exported': response.data.totalExported,
'File Format': exportFormat,
'MailPoet Free version': window.mailpoet_version
});
}).fail(function fail(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
nextStepButton.click(function nextClick() {
var exportFormat;
if (jQuery(this).hasClass('button-disabled')) {
return;
}
MailPoet.Modal.loading(true);
exportFormat = jQuery(':radio[name="option_format"]:checked').val();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processExport',
data: JSON.stringify({
export_format_option: exportFormat,
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
subscriber_fields: subscriberFieldsContainerElement.val()
})
}).always(function always() {
MailPoet.Modal.loading(false);
}).done(function done(response) {
var resultMessage = MailPoet.I18n.t('exportMessage')
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported, 133).toLocaleString() + '</strong>')
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
.replace('[/link]', '</a>');
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
window.location.href = response.data.exportFileURL;
MailPoet.trackEvent('Subscribers export completed', {
'Total exported': response.data.totalExported,
'File Format': exportFormat,
'MailPoet Free version': window.mailpoet_version
});
}).fail(function fail(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function mapError(error) { return error.message; }),
{ scroll: true }
);
}
});
});
});
});
}
});
});
});
});

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,8 @@ const bulkActions = [
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersMovedToList')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
);
},
},
@ -160,8 +160,8 @@ const bulkActions = [
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersAddedToList')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
);
},
},
@ -192,8 +192,8 @@ const bulkActions = [
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$2s', response.meta.segment)
);
},
},
@ -203,7 +203,7 @@ const bulkActions = [
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
);
},
},
@ -213,7 +213,7 @@ const bulkActions = [
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleConfirmationEmailsSent')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
);
},
},

1021
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@
"chai-jq": "0.0.8",
"clean-webpack-plugin": "^0.1.19",
"cross-env": "^5.1.5",
"eslint": "^3.19.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^15.0.1",
"eslint-import-resolver-webpack": "^0.8.4",
"eslint-plugin-import": "^2.11.0",
@ -59,7 +59,7 @@
"imports-loader": "~0.7.1",
"jsdom": "^11.10.0",
"json-loader": "^0.5.7",
"mocha": "2.2.1",
"mocha": "^5.2.0",
"nib": "~1.1.2",
"sinon": "1.14.1",
"sinon-chai": "2.7.0",

View File

@ -15,7 +15,7 @@ define([
ContainerBlock,
AutomatedLatestContentInjector,
Communication
) {
) {
var EditorApplication = App;
var CommunicationComponent = Communication;

View File

@ -109,8 +109,8 @@ define([
expect(model.get('blocks').at(0).get('blocks')).to.have.length(2);
expect(
model.get('blocks').at(0)
.get('blocks').at(1)
.get('someField')
.get('blocks').at(1)
.get('someField')
).to.equal('some text 2');
});
});

View File

@ -215,8 +215,8 @@ define([
var deferred = jQuery.Deferred();
deferred.resolve({
data: [
{ post_title: 'title 1' },
{ post_title: 'post title 2' }
{ post_title: 'title 1' },
{ post_title: 'post title 2' }
]
});
return deferred;
@ -286,8 +286,8 @@ define([
var deferred = jQuery.Deferred();
deferred.resolve({
data: [
{ type: 'text', text: 'something' },
{ type: 'text', text: 'something else' }
{ type: 'text', text: 'something' },
{ type: 'text', text: 'something else' }
]
});
return deferred;