Fix no-shadow eslint rule in ES5 files
[MAILPOET-1144]
This commit is contained in:
@@ -37,7 +37,6 @@
|
|||||||
"global-require": 0,
|
"global-require": 0,
|
||||||
"no-throw-literal": 0,
|
"no-throw-literal": 0,
|
||||||
"no-extra-bind": 0,
|
"no-extra-bind": 0,
|
||||||
"no-shadow": 0,
|
|
||||||
"no-underscore-dangle": 0,
|
"no-underscore-dangle": 0,
|
||||||
"brace-style": 0,
|
"brace-style": 0,
|
||||||
"no-else-return": 0,
|
"no-else-return": 0,
|
||||||
|
@@ -66,18 +66,18 @@ Object.extend(document, (function () {
|
|||||||
var wrapper;
|
var wrapper;
|
||||||
switch (length) {
|
switch (length) {
|
||||||
case 2:
|
case 2:
|
||||||
getWrappersForSelector(selector, eventName).each(function (wrapper) {
|
getWrappersForSelector(selector, eventName).each(function (selectorWrapper) {
|
||||||
document.stopDelegating(selector, eventName, wrapper.handler);
|
document.stopDelegating(selector, eventName, selectorWrapper.handler);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Object.keys(getCacheForSelector(selector)).each(function (eventName) {
|
Object.keys(getCacheForSelector(selector)).each(function (event) {
|
||||||
document.stopDelegating(selector, eventName);
|
document.stopDelegating(selector, event);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
Object.keys(cache).each(function (selector) {
|
Object.keys(cache).each(function (cacheSelector) {
|
||||||
document.stopDelegating(selector);
|
document.stopDelegating(cacheSelector);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -157,8 +157,8 @@ Object.extend(window.Droppables, {
|
|||||||
var drop;
|
var drop;
|
||||||
var affected = [];
|
var affected = [];
|
||||||
if (!this.drops.length) return;
|
if (!this.drops.length) return;
|
||||||
this.drops.each(function (drop) {
|
this.drops.each(function (dropsDrop) {
|
||||||
if (window.Droppables.isAffected(point, element, drop)) affected.push(drop);
|
if (window.Droppables.isAffected(point, element, dropsDrop)) affected.push(dropsDrop);
|
||||||
});
|
});
|
||||||
if (affected.length > 0) drop = window.Droppables.findDeepestChild(affected);
|
if (affected.length > 0) drop = window.Droppables.findDeepestChild(affected);
|
||||||
if (this.last_active && this.last_active !== drop) this.deactivate(this.last_active, element);
|
if (this.last_active && this.last_active !== drop) this.deactivate(this.last_active, element);
|
||||||
|
@@ -380,21 +380,21 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('automatedLatestContent', {
|
BeforeStartApp.registerBlockType('automatedLatestContent', {
|
||||||
blockModel: Module.AutomatedLatestContentBlockModel,
|
blockModel: Module.AutomatedLatestContentBlockModel,
|
||||||
blockView: Module.AutomatedLatestContentBlockView
|
blockView: Module.AutomatedLatestContentBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'automatedLatestContent',
|
name: 'automatedLatestContent',
|
||||||
widgetView: Module.AutomatedLatestContentWidgetView,
|
widgetView: Module.AutomatedLatestContentWidgetView,
|
||||||
priority: 97
|
priority: 97
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function (App) {
|
App.on('start', function (StartApp) {
|
||||||
var Application = App;
|
var Application = StartApp;
|
||||||
Application._ALCSupervisor = new Module.ALCSupervisor();
|
Application._ALCSupervisor = new Module.ALCSupervisor();
|
||||||
Application._ALCSupervisor.refresh();
|
Application._ALCSupervisor.refresh();
|
||||||
});
|
});
|
||||||
|
@@ -132,13 +132,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('button', {
|
BeforeStartApp.registerBlockType('button', {
|
||||||
blockModel: Module.ButtonBlockModel,
|
blockModel: Module.ButtonBlockModel,
|
||||||
blockView: Module.ButtonBlockView
|
blockView: Module.ButtonBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'button',
|
name: 'button',
|
||||||
widgetView: Module.ButtonWidgetView,
|
widgetView: Module.ButtonWidgetView,
|
||||||
priority: 92
|
priority: 92
|
||||||
|
@@ -338,25 +338,25 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('container', {
|
BeforeStartApp.registerBlockType('container', {
|
||||||
blockModel: Module.ContainerBlockModel,
|
blockModel: Module.ContainerBlockModel,
|
||||||
blockView: Module.ContainerBlockView
|
blockView: Module.ContainerBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerLayoutWidget({
|
BeforeStartApp.registerLayoutWidget({
|
||||||
name: 'oneColumnLayout',
|
name: 'oneColumnLayout',
|
||||||
priority: 100,
|
priority: 100,
|
||||||
widgetView: Module.OneColumnContainerWidgetView
|
widgetView: Module.OneColumnContainerWidgetView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerLayoutWidget({
|
BeforeStartApp.registerLayoutWidget({
|
||||||
name: 'twoColumnLayout',
|
name: 'twoColumnLayout',
|
||||||
priority: 100,
|
priority: 100,
|
||||||
widgetView: Module.TwoColumnContainerWidgetView
|
widgetView: Module.TwoColumnContainerWidgetView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerLayoutWidget({
|
BeforeStartApp.registerLayoutWidget({
|
||||||
name: 'threeColumnLayout',
|
name: 'threeColumnLayout',
|
||||||
priority: 100,
|
priority: 100,
|
||||||
widgetView: Module.ThreeColumnContainerWidgetView
|
widgetView: Module.ThreeColumnContainerWidgetView
|
||||||
|
@@ -138,13 +138,13 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('divider', {
|
BeforeStartApp.registerBlockType('divider', {
|
||||||
blockModel: Module.DividerBlockModel,
|
blockModel: Module.DividerBlockModel,
|
||||||
blockView: Module.DividerBlockView
|
blockView: Module.DividerBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'divider',
|
name: 'divider',
|
||||||
widgetView: Module.DividerWidgetView,
|
widgetView: Module.DividerWidgetView,
|
||||||
priority: 93
|
priority: 93
|
||||||
|
@@ -110,13 +110,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('footer', {
|
BeforeStartApp.registerBlockType('footer', {
|
||||||
blockModel: Module.FooterBlockModel,
|
blockModel: Module.FooterBlockModel,
|
||||||
blockView: Module.FooterBlockView
|
blockView: Module.FooterBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'footer',
|
name: 'footer',
|
||||||
widgetView: Module.FooterWidgetView,
|
widgetView: Module.FooterWidgetView,
|
||||||
priority: 99
|
priority: 99
|
||||||
|
@@ -110,13 +110,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('header', {
|
BeforeStartApp.registerBlockType('header', {
|
||||||
blockModel: Module.HeaderBlockModel,
|
blockModel: Module.HeaderBlockModel,
|
||||||
blockView: Module.HeaderBlockView
|
blockView: Module.HeaderBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'header',
|
name: 'header',
|
||||||
widgetView: Module.HeaderWidgetView,
|
widgetView: Module.HeaderWidgetView,
|
||||||
priority: 98
|
priority: 98
|
||||||
|
@@ -413,13 +413,13 @@ define([
|
|||||||
});
|
});
|
||||||
Module.ImageWidgetView = ImageWidgetView;
|
Module.ImageWidgetView = ImageWidgetView;
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('image', {
|
BeforeStartApp.registerBlockType('image', {
|
||||||
blockModel: Module.ImageBlockModel,
|
blockModel: Module.ImageBlockModel,
|
||||||
blockView: Module.ImageBlockView
|
blockView: Module.ImageBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'image',
|
name: 'image',
|
||||||
widgetView: Module.ImageWidgetView,
|
widgetView: Module.ImageWidgetView,
|
||||||
priority: 91
|
priority: 91
|
||||||
|
@@ -583,13 +583,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('posts', {
|
BeforeStartApp.registerBlockType('posts', {
|
||||||
blockModel: Module.PostsBlockModel,
|
blockModel: Module.PostsBlockModel,
|
||||||
blockView: Module.PostsBlockView
|
blockView: Module.PostsBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'posts',
|
name: 'posts',
|
||||||
widgetView: Module.PostsWidgetView,
|
widgetView: Module.PostsWidgetView,
|
||||||
priority: 96
|
priority: 96
|
||||||
|
@@ -299,13 +299,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('social', {
|
BeforeStartApp.registerBlockType('social', {
|
||||||
blockModel: Module.SocialBlockModel,
|
blockModel: Module.SocialBlockModel,
|
||||||
blockView: Module.SocialBlockView
|
blockView: Module.SocialBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'social',
|
name: 'social',
|
||||||
widgetView: Module.SocialWidgetView,
|
widgetView: Module.SocialWidgetView,
|
||||||
priority: 95
|
priority: 95
|
||||||
|
@@ -87,13 +87,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('spacer', {
|
BeforeStartApp.registerBlockType('spacer', {
|
||||||
blockModel: Module.SpacerBlockModel,
|
blockModel: Module.SpacerBlockModel,
|
||||||
blockView: Module.SpacerBlockView
|
blockView: Module.SpacerBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'spacer',
|
name: 'spacer',
|
||||||
widgetView: Module.SpacerWidgetView,
|
widgetView: Module.SpacerWidgetView,
|
||||||
priority: 94
|
priority: 94
|
||||||
|
@@ -94,13 +94,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
App.registerBlockType('text', {
|
BeforeStartApp.registerBlockType('text', {
|
||||||
blockModel: Module.TextBlockModel,
|
blockModel: Module.TextBlockModel,
|
||||||
blockView: Module.TextBlockView
|
blockView: Module.TextBlockView
|
||||||
});
|
});
|
||||||
|
|
||||||
App.registerWidget({
|
BeforeStartApp.registerWidget({
|
||||||
name: 'text',
|
name: 'text',
|
||||||
widgetView: Module.TextWidgetView,
|
widgetView: Module.TextWidgetView,
|
||||||
priority: 90
|
priority: 90
|
||||||
|
@@ -11,8 +11,8 @@
|
|||||||
var Radio = require('backbone.radio');
|
var Radio = require('backbone.radio');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define(['backbone.marionette', 'backbone.radio', 'underscore'], function (Marionette, Radio, _) {
|
define(['backbone.marionette', 'backbone.radio', 'underscore'], function (BackboneMarionette, BackboneRadio, underscore) {
|
||||||
return factory(Marionette, Radio, _);
|
return factory(BackboneMarionette, BackboneRadio, underscore);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (typeof exports !== 'undefined') {
|
else if (typeof exports !== 'undefined') {
|
||||||
|
@@ -24,8 +24,8 @@ define([
|
|||||||
return Module._config;
|
return Module._config;
|
||||||
};
|
};
|
||||||
|
|
||||||
App.on('before:start', function (App, options) {
|
App.on('before:start', function (BeforeStartApp, options) {
|
||||||
var Application = App;
|
var Application = BeforeStartApp;
|
||||||
// Expose config methods globally
|
// Expose config methods globally
|
||||||
Application.getConfig = Module.getConfig;
|
Application.getConfig = Module.getConfig;
|
||||||
Application.setConfig = Module.setConfig;
|
Application.setConfig = Module.setConfig;
|
||||||
|
@@ -68,21 +68,21 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
App.on('before:start', function (Application, options) {
|
App.on('before:start', function (Application, options) {
|
||||||
var App = Application;
|
var BeforeStartApp = Application;
|
||||||
// Expose block methods globally
|
// Expose block methods globally
|
||||||
App.registerBlockType = Module.registerBlockType;
|
BeforeStartApp.registerBlockType = Module.registerBlockType;
|
||||||
App.getBlockTypeModel = Module.getBlockTypeModel;
|
BeforeStartApp.getBlockTypeModel = Module.getBlockTypeModel;
|
||||||
App.getBlockTypeView = Module.getBlockTypeView;
|
BeforeStartApp.getBlockTypeView = Module.getBlockTypeView;
|
||||||
App.toJSON = Module.toJSON;
|
BeforeStartApp.toJSON = Module.toJSON;
|
||||||
App.getBody = Module.getBody;
|
BeforeStartApp.getBody = Module.getBody;
|
||||||
App.getNewsletter = Module.getNewsletter;
|
BeforeStartApp.getNewsletter = Module.getNewsletter;
|
||||||
App.findModels = Module.findModels;
|
BeforeStartApp.findModels = Module.findModels;
|
||||||
|
|
||||||
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
|
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function (Application, options) {
|
App.on('start', function (Application, options) {
|
||||||
var App = Application;
|
var StartApp = Application;
|
||||||
var body = options.newsletter.body;
|
var body = options.newsletter.body;
|
||||||
var content = (_.has(body, 'content')) ? body.content : {};
|
var content = (_.has(body, 'content')) ? body.content : {};
|
||||||
|
|
||||||
@@ -93,13 +93,13 @@ define([
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
App._contentContainer = new (App.getBlockTypeModel('container'))(content, { parse: true });
|
StartApp._contentContainer = new (StartApp.getBlockTypeModel('container'))(content, { parse: true });
|
||||||
App._contentContainerView = new (App.getBlockTypeView('container'))({
|
StartApp._contentContainerView = new (StartApp.getBlockTypeView('container'))({
|
||||||
model: App._contentContainer,
|
model: StartApp._contentContainer,
|
||||||
renderOptions: { depth: 0 }
|
renderOptions: { depth: 0 }
|
||||||
});
|
});
|
||||||
|
|
||||||
App._appView.showChildView('contentRegion', App._contentContainerView);
|
StartApp._appView.showChildView('contentRegion', StartApp._contentContainerView);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@@ -29,8 +29,8 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function (App) {
|
App.on('start', function (StartApp) {
|
||||||
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
|
StartApp._appView.showChildView('headingRegion', new Module.HeadingView({ model: StartApp.getNewsletter() }));
|
||||||
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
|
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
|
||||||
tooltipId: 'tooltip-designer-subject-line-ti',
|
tooltipId: 'tooltip-designer-subject-line-ti',
|
||||||
tooltip: MailPoet.I18n.t('helpTooltipDesignerSubjectLine'),
|
tooltip: MailPoet.I18n.t('helpTooltipDesignerSubjectLine'),
|
||||||
|
@@ -353,8 +353,8 @@ define([
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
var Application = App;
|
var Application = BeforeStartApp;
|
||||||
Application.save = Module.save;
|
Application.save = Module.save;
|
||||||
Application.getChannel().on('autoSave', Module.autoSave);
|
Application.getChannel().on('autoSave', Module.autoSave);
|
||||||
|
|
||||||
@@ -363,9 +363,9 @@ define([
|
|||||||
Application.getChannel().reply('save', Application.save);
|
Application.getChannel().reply('save', Application.save);
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function (App) {
|
App.on('start', function (BeforeStartApp) {
|
||||||
var saveView = new Module.SaveView();
|
var saveView = new Module.SaveView();
|
||||||
App._appView.showChildView('bottomRegion', saveView);
|
BeforeStartApp._appView.showChildView('bottomRegion', saveView);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Module;
|
return Module;
|
||||||
|
@@ -361,18 +361,18 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('before:start', function (App) {
|
App.on('before:start', function (BeforeStartApp) {
|
||||||
var Application = App;
|
var Application = BeforeStartApp;
|
||||||
Application.registerWidget = Module.registerWidget;
|
Application.registerWidget = Module.registerWidget;
|
||||||
Application.getWidgets = Module.getWidgets;
|
Application.getWidgets = Module.getWidgets;
|
||||||
Application.registerLayoutWidget = Module.registerLayoutWidget;
|
Application.registerLayoutWidget = Module.registerLayoutWidget;
|
||||||
Application.getLayoutWidgets = Module.getLayoutWidgets;
|
Application.getLayoutWidgets = Module.getLayoutWidgets;
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function (App) {
|
App.on('start', function (StartApp) {
|
||||||
var sidebarView = new SidebarView();
|
var sidebarView = new SidebarView();
|
||||||
|
|
||||||
App._appView.showChildView('sidebarRegion', sidebarView);
|
StartApp._appView.showChildView('sidebarRegion', sidebarView);
|
||||||
|
|
||||||
MailPoet.helpTooltip.show(document.getElementById('tooltip-send-preview'), {
|
MailPoet.helpTooltip.show(document.getElementById('tooltip-send-preview'), {
|
||||||
tooltipId: 'tooltip-editor-send-preview',
|
tooltipId: 'tooltip-editor-send-preview',
|
||||||
|
@@ -69,8 +69,8 @@ define([
|
|||||||
return App.getConfig().get('availableStyles');
|
return App.getConfig().get('availableStyles');
|
||||||
};
|
};
|
||||||
|
|
||||||
App.on('before:start', function (App, options) {
|
App.on('before:start', function (BeforeStartApp, options) {
|
||||||
var Application = App;
|
var Application = BeforeStartApp;
|
||||||
var body;
|
var body;
|
||||||
var globalStyles;
|
var globalStyles;
|
||||||
// Expose style methods to global application
|
// Expose style methods to global application
|
||||||
@@ -83,9 +83,9 @@ define([
|
|||||||
this.setGlobalStyles(globalStyles);
|
this.setGlobalStyles(globalStyles);
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function (App) {
|
App.on('start', function (StartApp) {
|
||||||
var stylesView = new Module.StylesView({ model: App.getGlobalStyles() });
|
var stylesView = new Module.StylesView({ model: StartApp.getGlobalStyles() });
|
||||||
App._appView.showChildView('stylesRegion', stylesView);
|
StartApp._appView.showChildView('stylesRegion', stylesView);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Module;
|
return Module;
|
||||||
|
@@ -501,8 +501,8 @@ define(
|
|||||||
// count repeating e-mails inside duplicate array and present them in
|
// count repeating e-mails inside duplicate array and present them in
|
||||||
// 'email (xN)' format
|
// 'email (xN)' format
|
||||||
duplicates = {};
|
duplicates = {};
|
||||||
subscribers.duplicate.forEach(function (email) {
|
subscribers.duplicate.forEach(function (subscriberEmail) {
|
||||||
duplicates[email] = (duplicates[email] || 0) + 1;
|
duplicates[subscriberEmail] = (duplicates[subscriberEmail] || 0) + 1;
|
||||||
});
|
});
|
||||||
subscribers.duplicate = [];
|
subscribers.duplicate = [];
|
||||||
for (email in duplicates) {
|
for (email in duplicates) {
|
||||||
@@ -662,7 +662,7 @@ define(
|
|||||||
// autodetect column types
|
// autodetect column types
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
'show_and_match_columns',
|
'show_and_match_columns',
|
||||||
function (subscribers, options) {
|
function (helperSubscribers, options) {
|
||||||
var displayedColumns = [];
|
var displayedColumns = [];
|
||||||
var displayedColumnsIds = [];
|
var displayedColumnsIds = [];
|
||||||
var i;
|
var i;
|
||||||
@@ -671,14 +671,14 @@ define(
|
|||||||
var headerName;
|
var headerName;
|
||||||
var headerNameMatch;
|
var headerNameMatch;
|
||||||
// go through all elements of the first row in subscribers data
|
// go through all elements of the first row in subscribers data
|
||||||
for (i in subscribers.subscribers[0]) {
|
for (i in helperSubscribers.subscribers[0]) {
|
||||||
columnData = subscribers.subscribers[0][i];
|
columnData = helperSubscribers.subscribers[0][i];
|
||||||
columnId = 'ignore'; // set default column type
|
columnId = 'ignore'; // set default column type
|
||||||
// if the column is not undefined and has a valid e-mail, set type as email
|
// if the column is not undefined and has a valid e-mail, set type as email
|
||||||
if (columnData % 1 !== 0 && window.emailRegex.test(columnData)) {
|
if (columnData % 1 !== 0 && window.emailRegex.test(columnData)) {
|
||||||
columnId = 'email';
|
columnId = 'email';
|
||||||
} else if (subscribers.header) {
|
} else if (helperSubscribers.header) {
|
||||||
headerName = subscribers.header[i];
|
headerName = helperSubscribers.header[i];
|
||||||
headerNameMatch = window.mailpoetColumns.map(function (el) {
|
headerNameMatch = window.mailpoetColumns.map(function (el) {
|
||||||
return el.name;
|
return el.name;
|
||||||
}).indexOf(headerName);
|
}).indexOf(headerName);
|
||||||
@@ -1007,22 +1007,21 @@ define(
|
|||||||
var batchNumber = 0;
|
var batchNumber = 0;
|
||||||
var batchSize = 2000;
|
var batchSize = 2000;
|
||||||
var timestamp = Date.now() / 1000;
|
var timestamp = Date.now() / 1000;
|
||||||
var subscribers = [];
|
|
||||||
var importResults = {
|
var importResults = {
|
||||||
created: 0,
|
created: 0,
|
||||||
updated: 0,
|
updated: 0,
|
||||||
errors: [],
|
errors: [],
|
||||||
segments: []
|
segments: []
|
||||||
};
|
};
|
||||||
var subscribers;
|
var clickSubscribers;
|
||||||
var splitSubscribers;
|
var splitSubscribers;
|
||||||
|
|
||||||
if (jQuery(this).hasClass('button-disabled')) {
|
if (jQuery(this).hasClass('button-disabled')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MailPoet.Modal.loading(true);
|
MailPoet.Modal.loading(true);
|
||||||
splitSubscribers = function (subscribers, size) {
|
splitSubscribers = function (localSubscribers, size) {
|
||||||
return subscribers.reduce(function (res, item, index) {
|
return localSubscribers.reduce(function (res, item, index) {
|
||||||
if (index % size === 0) {
|
if (index % size === 0) {
|
||||||
res.push([]);
|
res.push([]);
|
||||||
}
|
}
|
||||||
@@ -1030,7 +1029,7 @@ define(
|
|||||||
return res;
|
return res;
|
||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
subscribers = splitSubscribers(window.importData.step1.subscribers, batchSize);
|
clickSubscribers = splitSubscribers(window.importData.step1.subscribers, batchSize);
|
||||||
|
|
||||||
_.each(jQuery('select.mailpoet_subscribers_column_data_match'),
|
_.each(jQuery('select.mailpoet_subscribers_column_data_match'),
|
||||||
function (column, columnIndex) {
|
function (column, columnIndex) {
|
||||||
@@ -1042,16 +1041,16 @@ define(
|
|||||||
columns[columnId] = { index: columnIndex, validation_rule: validationRule };
|
columns[columnId] = { index: columnIndex, validation_rule: validationRule };
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(subscribers, function () {
|
_.each(clickSubscribers, function () {
|
||||||
queue.add(function (queue) {
|
queue.add(function (addQueue) {
|
||||||
queue.pause();
|
addQueue.pause();
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
api_version: window.mailpoet_api_version,
|
api_version: window.mailpoet_api_version,
|
||||||
endpoint: 'ImportExport',
|
endpoint: 'ImportExport',
|
||||||
action: 'processImport',
|
action: 'processImport',
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
columns: columns,
|
columns: columns,
|
||||||
subscribers: subscribers[batchNumber],
|
subscribers: clickSubscribers[batchNumber],
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
segments: segmentSelectElement.val(),
|
segments: segmentSelectElement.val(),
|
||||||
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes')
|
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes')
|
||||||
@@ -1061,7 +1060,7 @@ define(
|
|||||||
importResults.updated += response.data.updated;
|
importResults.updated += response.data.updated;
|
||||||
importResults.segments = response.data.segments;
|
importResults.segments = response.data.segments;
|
||||||
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
|
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
|
||||||
queue.run();
|
addQueue.run();
|
||||||
}).fail(function (response) {
|
}).fail(function (response) {
|
||||||
MailPoet.Modal.loading(false);
|
MailPoet.Modal.loading(false);
|
||||||
if (response.errors.length > 0) {
|
if (response.errors.length > 0) {
|
||||||
|
Reference in New Issue
Block a user