Fix eslint rules in ES5 files
This commit is contained in:
@ -8,5 +8,4 @@ function admin(jQuery) {
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -368,7 +368,7 @@ WysijaForm = {
|
||||
// skip lists
|
||||
if (setting.name === 'segments') {
|
||||
return true;
|
||||
} else if (setting.name === 'on_success') {
|
||||
} if (setting.name === 'on_success') {
|
||||
// if the input value is equal to the one stored in the settings
|
||||
if (setting.value === data.settings[setting.name]) {
|
||||
// check selected value
|
||||
@ -502,8 +502,7 @@ WysijaForm = {
|
||||
block = WysijaForm.get(segmentSelection).block.getData();
|
||||
return (
|
||||
(block.params.values !== undefined)
|
||||
&&
|
||||
(block.params.values.length > 0)
|
||||
&& (block.params.values.length > 0)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
@ -577,8 +576,9 @@ WysijaForm = {
|
||||
},
|
||||
initToolbarPosition: function () {
|
||||
if (WysijaForm.toolbar.top === null) {
|
||||
WysijaForm.toolbar.top =
|
||||
parseInt(window.$(WysijaForm.options.container).positionedOffset().top, 10);
|
||||
WysijaForm.toolbar.top = parseInt(
|
||||
window.$(WysijaForm.options.container).positionedOffset().top, 10
|
||||
);
|
||||
}
|
||||
if (WysijaForm.toolbar.y === null) {
|
||||
WysijaForm.toolbar.y = parseInt(WysijaForm.toolbar.top, 10);
|
||||
@ -587,16 +587,17 @@ WysijaForm = {
|
||||
if (window.isRtl) {
|
||||
if (WysijaForm.toolbar.left === null) WysijaForm.toolbar.left = 0;
|
||||
} else if (WysijaForm.toolbar.left === null) {
|
||||
WysijaForm.toolbar.left =
|
||||
parseInt(window.$(WysijaForm.options.container).positionedOffset().left, 10);
|
||||
WysijaForm.toolbar.left = parseInt(
|
||||
window.$(WysijaForm.options.container).positionedOffset().left, 10
|
||||
);
|
||||
}
|
||||
if (WysijaForm.toolbar.x === null) {
|
||||
WysijaForm.toolbar.x =
|
||||
parseInt(
|
||||
WysijaForm.toolbar.left
|
||||
WysijaForm.toolbar.x = parseInt(
|
||||
WysijaForm.toolbar.left
|
||||
+ window.$(WysijaForm.options.container).getDimensions().width
|
||||
+ 15
|
||||
, 10);
|
||||
+ 15,
|
||||
10
|
||||
);
|
||||
}
|
||||
},
|
||||
setToolbarPosition: function () {
|
||||
@ -726,7 +727,7 @@ WysijaForm = {
|
||||
if (protocol === null) {
|
||||
// this is not a url so encode the whole thing
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
|
||||
} else if (protocol.length === 1) {
|
||||
} if (protocol.length === 1) {
|
||||
// this is a url, so do not encode the protocol
|
||||
return encodeURI(str).replace(/[!'()*]/g, escape);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
|
||||
Handlebars.registerHelper('date_format', function (timestamp, block) {
|
||||
var f;
|
||||
if (window.moment) {
|
||||
if (timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
|
||||
if (timestamp === undefined || Number.isNaN(timestamp) || timestamp <= 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ define(
|
||||
|
||||
// Coerce values.
|
||||
if (coerce) {
|
||||
if (val && !isNaN(val)) { // number
|
||||
if (val && !Number.isNaN(val)) { // number
|
||||
val = +val;
|
||||
} else if (val === 'undefined') { // undefined
|
||||
val = undefined;
|
||||
@ -79,7 +79,7 @@ define(
|
||||
for (; i <= keysLast; i += 1) {
|
||||
key = keys[i] === '' ? cur.length : keys[i];
|
||||
cur[key] = i < keysLast
|
||||
? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : [])
|
||||
? cur[key] || (keys[i + 1] && Number.isNaN(keys[i + 1]) ? {} : [])
|
||||
: val;
|
||||
cur = cur[key];
|
||||
}
|
||||
|
@ -297,8 +297,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
this.loadTemplate();
|
||||
// show modal window
|
||||
this.showModal();
|
||||
}.bind(this)
|
||||
);
|
||||
}.bind(this));
|
||||
} else if (this.options.method === 'post') {
|
||||
// make ajax request
|
||||
jQuery.post(this.options.url, JSON.stringify(this.options.params),
|
||||
@ -309,8 +308,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
// show modal window
|
||||
this.showModal();
|
||||
}.bind(this),
|
||||
'json'
|
||||
);
|
||||
'json');
|
||||
}
|
||||
|
||||
return this;
|
||||
@ -646,6 +644,4 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
@ -29,4 +29,3 @@ define([
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -146,7 +146,8 @@ define([
|
||||
_.omit(base.BlockView.prototype.modelEvents, 'change'),
|
||||
{
|
||||
postsChanged: 'render'
|
||||
}),
|
||||
}
|
||||
),
|
||||
events: _.extend(base.BlockView.prototype.events, {
|
||||
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
|
||||
}),
|
||||
|
@ -141,7 +141,8 @@ define([
|
||||
_.omit(base.BlockView.prototype.modelEvents, 'change'),
|
||||
{
|
||||
postsChanged: 'render'
|
||||
}),
|
||||
}
|
||||
),
|
||||
events: _.extend(base.BlockView.prototype.events, {
|
||||
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
|
||||
}),
|
||||
|
@ -191,8 +191,7 @@ define([
|
||||
classIrregular = 'mailpoet_irregular_width_contents_container column_layout_' + columnLayout;
|
||||
}
|
||||
this.$('> .mailpoet_container').attr('class',
|
||||
'mailpoet_container mailpoet_container_' + this.model.get('orientation') + ' ' + classIrregular
|
||||
);
|
||||
'mailpoet_container mailpoet_container_' + this.model.get('orientation') + ' ' + classIrregular);
|
||||
},
|
||||
showTools: function () {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
|
@ -274,16 +274,16 @@ define([
|
||||
if (jsonObject && jsonObject.body && jsonObject.body.content) {
|
||||
body = JSON.stringify(jsonObject.body.content);
|
||||
}
|
||||
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
|
||||
body.indexOf('[link:subscription_unsubscribe_url]') < 0 &&
|
||||
body.indexOf('[link:subscription_unsubscribe]') < 0) {
|
||||
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent')
|
||||
&& body.indexOf('[link:subscription_unsubscribe_url]') < 0
|
||||
&& body.indexOf('[link:subscription_unsubscribe]') < 0) {
|
||||
this.showValidationError(MailPoet.I18n.t('unsubscribeLinkMissing'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((App.getNewsletter().get('type') === 'notification') &&
|
||||
body.indexOf('"type":"automatedLatestContent"') < 0 &&
|
||||
body.indexOf('"type":"automatedLatestContentLayout"') < 0
|
||||
if ((App.getNewsletter().get('type') === 'notification')
|
||||
&& body.indexOf('"type":"automatedLatestContent"') < 0
|
||||
&& body.indexOf('"type":"automatedLatestContentLayout"') < 0
|
||||
) {
|
||||
this.showValidationError(MailPoet.I18n.t('automatedLatestContentMissing'));
|
||||
return;
|
||||
|
@ -124,8 +124,7 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) { // eslint-disab
|
||||
|
||||
if (
|
||||
this.options.id !== null
|
||||
&&
|
||||
jQuery('[data-id="' + this.options.id + '"]').length > 0
|
||||
&& jQuery('[data-id="' + this.options.id + '"]').length > 0
|
||||
) {
|
||||
this.updateNotice();
|
||||
} else {
|
||||
|
@ -7,7 +7,7 @@ define(
|
||||
) {
|
||||
var element;
|
||||
function eventHandler() {
|
||||
if (confirm(MailPoet.I18n.t('reinstallConfirmation'))) { // eslint-disable-line no-alert
|
||||
if (confirm(MailPoet.I18n.t('reinstallConfirmation'))) { // eslint-disable-line
|
||||
MailPoet.trackEvent(
|
||||
'User has reinstalled MailPoet via Settings',
|
||||
{ 'MailPoet Free version': window.mailpoet_version }
|
||||
@ -40,4 +40,5 @@ define(
|
||||
if (element) {
|
||||
element.addEventListener('click', eventHandler, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -23,8 +23,7 @@ define(
|
||||
if (!window.exportData.segments) {
|
||||
return;
|
||||
}
|
||||
subscribersExportTemplate =
|
||||
Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
|
||||
subscribersExportTemplate = Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
|
||||
|
||||
// render template
|
||||
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribersExportTemplate(window.exportData));
|
||||
@ -89,8 +88,7 @@ define(
|
||||
})
|
||||
.on('change', function onChange() {
|
||||
if ((window.exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
|
||||
||
|
||||
(!window.exportData.segments && subscriberFieldsContainerElement.select2('data').length)
|
||||
|| (!window.exportData.segments && subscriberFieldsContainerElement.select2('data').length)
|
||||
) {
|
||||
toggleNextStepButton('on');
|
||||
} else {
|
||||
@ -153,4 +151,5 @@ define(
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -43,7 +43,7 @@ define(
|
||||
MailPoet.Notice.hide();
|
||||
MailPoet.Modal.loading(false);
|
||||
jQuery('#mailpoet_subscribers_import > div[id^="step"]').hide();
|
||||
jQuery(location.hash).show();
|
||||
jQuery(window.location.hash).show();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -75,28 +75,24 @@ define(
|
||||
}
|
||||
|
||||
// render process button for each method
|
||||
methodProcessContainerTemplate =
|
||||
Handlebars.compile(jQuery('#method_process_template').html());
|
||||
methodProcessContainerTemplate = Handlebars.compile(jQuery('#method_process_template').html());
|
||||
jQuery('.mailpoet_method_process').html(methodProcessContainerTemplate());
|
||||
|
||||
// define reusable variables
|
||||
currentStepE = jQuery(location.hash);
|
||||
currentStepE = jQuery(window.location.hash);
|
||||
methodSelectionElement = jQuery('#select_method');
|
||||
pasteInputElement = jQuery('#paste_input');
|
||||
pasteInputPlaceholderElement =
|
||||
pasteInputElement.data('placeholder').replace(/\\n/g, '\n');
|
||||
pasteProcessButtonElement =
|
||||
jQuery('#method_paste > div.mailpoet_method_process')
|
||||
.find('a.mailpoet_process');
|
||||
pasteInputPlaceholderElement = pasteInputElement.data('placeholder').replace(/\\n/g, '\n');
|
||||
pasteProcessButtonElement = jQuery('#method_paste > div.mailpoet_method_process')
|
||||
.find('a.mailpoet_process');
|
||||
mailChimpKeyInputElement = jQuery('#mailchimp_key');
|
||||
mailChimpKeyVerifyButtonElement = jQuery('#mailchimp_key_verify');
|
||||
mailChimpListsContainerElement = jQuery('#mailchimp_lists');
|
||||
mailChimpProcessButtonElement = jQuery('#method_mailchimp > div.mailpoet_method_process')
|
||||
.find('a.mailpoet_process');
|
||||
uploadElement = jQuery('#file_local');
|
||||
uploadProcessButtonElement =
|
||||
jQuery('#method_file > div.mailpoet_method_process')
|
||||
.find('a.mailpoet_process');
|
||||
uploadProcessButtonElement = jQuery('#method_file > div.mailpoet_method_process')
|
||||
.find('a.mailpoet_process');
|
||||
|
||||
// define method change behavior
|
||||
methodSelectionElement.change(function () {
|
||||
@ -243,18 +239,18 @@ define(
|
||||
// if the header options is set, there should be at least
|
||||
// 2 data rows, otherwise at least 1 data row
|
||||
if (
|
||||
processedSubscribers &&
|
||||
(
|
||||
processedSubscribers
|
||||
&& (
|
||||
(isHeaderFound && processedSubscribers.length >= 2)
|
||||
||
|
||||
(!isHeaderFound && processedSubscribers.length >= 1)
|
||||
|| (!isHeaderFound && processedSubscribers.length >= 1)
|
||||
)
|
||||
) {
|
||||
// since we assume that the header line is always present, we need
|
||||
// to detect the header by checking if it contains a valid e-mail address
|
||||
window.importData.step1 = {
|
||||
header: (!window.mailpoet_email_regex.test(
|
||||
processedSubscribers[0][emailColumnPosition])
|
||||
processedSubscribers[0][emailColumnPosition]
|
||||
)
|
||||
) ? processedSubscribers.shift() : null,
|
||||
subscribers: processedSubscribers,
|
||||
subscribersCount: processedSubscribers.length,
|
||||
@ -545,10 +541,9 @@ define(
|
||||
.click(function () {
|
||||
var details = jQuery('.mailpoet_subscribers_data_parse_results_details');
|
||||
jQuery(details).toggle();
|
||||
this.text =
|
||||
(jQuery(details).is(':visible'))
|
||||
? MailPoet.I18n.t('hideDetails')
|
||||
: MailPoet.I18n.t('showDetails');
|
||||
this.text = (jQuery(details).is(':visible'))
|
||||
? MailPoet.I18n.t('hideDetails')
|
||||
: MailPoet.I18n.t('showDetails');
|
||||
});
|
||||
|
||||
// show available segments
|
||||
@ -702,22 +697,22 @@ define(
|
||||
// make sure the column id has not been previously selected
|
||||
// (e.g., subscriber_first_name shouldn't be autodetected twice),
|
||||
// except for "ignore"
|
||||
columnId =
|
||||
(columnId !== 'ignore'
|
||||
columnId = (columnId !== 'ignore'
|
||||
&& displayedColumnsIds.indexOf(columnId) === -1)
|
||||
? columnId
|
||||
: 'ignore';
|
||||
? columnId
|
||||
: 'ignore';
|
||||
displayedColumns[i] = { column_id: columnId };
|
||||
displayedColumnsIds.push(columnId);
|
||||
});
|
||||
return options.fn(displayedColumns);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// sanitize unsafe data
|
||||
Handlebars.registerHelper('sanitize_data', function (data) {
|
||||
return (data instanceof Handlebars.SafeString) ?
|
||||
data :
|
||||
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
||||
return (data instanceof Handlebars.SafeString)
|
||||
? data
|
||||
: new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
||||
});
|
||||
|
||||
// start array index from 1
|
||||
@ -728,7 +723,7 @@ define(
|
||||
if (index === maxRowsToShow && subscribers.subscribersCount > (maxRowsToShow + 1)) {
|
||||
fillerPosition = index;
|
||||
return filler;
|
||||
} else if (index === (subscribers.subscribers.length - 1)) {
|
||||
} if (index === (subscribers.subscribers.length - 1)) {
|
||||
// if we're on the last line, show the total count of subscribers data
|
||||
return subscribers.subscribersCount.toLocaleString();
|
||||
}
|
||||
@ -750,7 +745,8 @@ define(
|
||||
var preventNextStep = false;
|
||||
var displayedColumns;
|
||||
jQuery(
|
||||
'[data-id="notice_invalidEmail"], [data-id="notice_invalidDate"]')
|
||||
'[data-id="notice_invalidEmail"], [data-id="notice_invalidDate"]'
|
||||
)
|
||||
.remove();
|
||||
displayedColumns = jQuery.map(
|
||||
jQuery('.mailpoet_subscribers_column_data_match'), function (element, elementIndex) {
|
||||
@ -763,7 +759,8 @@ define(
|
||||
validationRule: validationRule,
|
||||
element: element
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
// iterate through the object of mailpoet columns
|
||||
jQuery.map(window.mailpoetColumns, function (column) {
|
||||
var firstRowData;
|
||||
@ -780,7 +777,8 @@ define(
|
||||
// email, hide the next button
|
||||
if (column.id === 'email') {
|
||||
if (!window.mailpoet_email_regex.test(
|
||||
subscribersClone.subscribers[0][matchedColumn.index])
|
||||
subscribersClone.subscribers[0][matchedColumn.index]
|
||||
)
|
||||
) {
|
||||
preventNextStep = true;
|
||||
if (!jQuery('[data-id="notice_invalidEmail"]').length) {
|
||||
@ -812,8 +810,7 @@ define(
|
||||
validationRule = false;
|
||||
// check if date exists
|
||||
if (firstRowData.trim() === '') {
|
||||
subscribersClone.subscribers[0][matchedColumn.index] =
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
subscribersClone.subscribers[0][matchedColumn.index] = '<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('emptyFirstRowDate')
|
||||
+ '</span> ';
|
||||
@ -822,9 +819,9 @@ define(
|
||||
Object.keys(allowedDateFormats).forEach(function allowedDateFormatsLoop(format) {
|
||||
testedFormat = allowedDateFormats[format];
|
||||
if (Moment(firstRowData, testedFormat, true).isValid()) {
|
||||
validationRule = (typeof (testedFormat) === 'function') ?
|
||||
'datetime' :
|
||||
testedFormat;
|
||||
validationRule = (typeof (testedFormat) === 'function')
|
||||
? 'datetime'
|
||||
: testedFormat;
|
||||
// set validation on the column element
|
||||
jQuery(matchedColumn.element).data('validation-rule', validationRule);
|
||||
return;
|
||||
@ -976,7 +973,7 @@ define(
|
||||
// prompt user
|
||||
if (elementId === selectedOptionId
|
||||
&& elementId !== 'ignore') {
|
||||
if (confirm(MailPoet.I18n.t('selectedValueAlreadyMatched') + ' ' + MailPoet.I18n.t('confirmCorrespondingColumn'))) { // eslint-disable-line no-alert
|
||||
if (confirm(MailPoet.I18n.t('selectedValueAlreadyMatched') + ' ' + MailPoet.I18n.t('confirmCorrespondingColumn'))) { // eslint-disable-line
|
||||
jQuery(element).data('column-id', 'ignore');
|
||||
} else {
|
||||
selectEvent.preventDefault();
|
||||
@ -1052,11 +1049,11 @@ define(
|
||||
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes')
|
||||
})
|
||||
}).done(function (response) {
|
||||
var added = response.data.added_to_segment_with_welcome_notification;
|
||||
clickImportResults.created += response.data.created;
|
||||
clickImportResults.updated += response.data.updated;
|
||||
clickImportResults.segments = response.data.segments;
|
||||
clickImportResults.added_to_segment_with_welcome_notification =
|
||||
response.data.added_to_segment_with_welcome_notification;
|
||||
clickImportResults.added_to_segment_with_welcome_notification = added;
|
||||
addQueue.run();
|
||||
}).fail(function (response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
@ -1080,8 +1077,7 @@ define(
|
||||
&& !clickImportResults.updated
|
||||
&& !clickImportResults.created
|
||||
) {
|
||||
MailPoet.Notice.error(_.flatten(clickImportResults.errors)
|
||||
);
|
||||
MailPoet.Notice.error(_.flatten(clickImportResults.errors));
|
||||
} else {
|
||||
window.mailpoetSegments = clickImportResults.segments;
|
||||
clickImportResults.segments = _.map(segmentSelectElement.select2('data'),
|
||||
@ -1121,8 +1117,7 @@ define(
|
||||
});
|
||||
|
||||
// display statistics
|
||||
subscribersDataImportResultsTemplate =
|
||||
Handlebars.compile(jQuery('#subscribers_data_import_results_template').html());
|
||||
subscribersDataImportResultsTemplate = Handlebars.compile(jQuery('#subscribers_data_import_results_template').html());
|
||||
exportMenuElement = jQuery('span.mailpoet_export');
|
||||
importResults = {
|
||||
created: (window.importData.step2.created)
|
||||
@ -1167,4 +1162,5 @@ define(
|
||||
Backbone.history.start();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -584,4 +584,3 @@ define([
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user