ES5 no-unused-vars

This commit is contained in:
Amine Ben hammou
2017-09-25 21:39:30 +00:00
parent cb1730c4e2
commit c90e0e9f64
33 changed files with 112 additions and 162 deletions

View File

@ -47,7 +47,6 @@
"padded-blocks": 0, "padded-blocks": 0,
"strict": 0, "strict": 0,
"space-infix-ops": 0, "space-infix-ops": 0,
"no-unused-vars": 0,
"object-shorthand": 0, "object-shorthand": 0,
"new-parens": 0, "new-parens": 0,
"eol-last": 0, "eol-last": 0,

View File

@ -56,12 +56,12 @@ Object.extend(document, (function () {
return wrapper; return wrapper;
} }
return { return {
delegate: function (selector, eventName, handler, context) { delegate: function(selector, eventName) {
var wrapper = createWrapper.apply(null, arguments); var wrapper = createWrapper.apply(null, arguments);
if (wrapper) document.observe(eventName, wrapper); if (wrapper) document.observe(eventName, wrapper);
return document; return document;
}, },
stopDelegating: function (selector, eventName, handler) { stopDelegating: function(selector, eventName) {
var length = arguments.length; var length = arguments.length;
var wrapper; var wrapper;
switch(length) { switch(length) {
@ -168,22 +168,22 @@ Object.extend(window.Droppables, {
if (drop !== this.last_active) window.Droppables.activate(drop, element); if (drop !== this.last_active) window.Droppables.activate(drop, element);
} }
}, },
displayArea: function (draggable) { displayArea: function() {
if (!this.drops.length) return; if(!this.drops.length) return;
// hide controls when displaying drop areas. // hide controls when displaying drop areas.
WysijaForm.hideBlockControls(); WysijaForm.hideBlockControls();
this.drops.each(function (drop, iterator) { this.drops.each(function(drop) {
if (drop.element.hasClassName('block_placeholder')) { if(drop.element.hasClassName('block_placeholder')) {
drop.element.addClassName('active'); drop.element.addClassName('active');
} }
}); });
}, },
hideArea: function () { hideArea: function() {
if (!this.drops.length) return; if(!this.drops.length) return;
this.drops.each(function (drop, iterator) { this.drops.each(function(drop) {
if (drop.element.hasClassName('block_placeholder')) { if(drop.element.hasClassName('block_placeholder')) {
drop.element.removeClassName('active'); drop.element.removeClassName('active');
} else if (drop.element.hasClassName('image_placeholder')) { } else if (drop.element.hasClassName('image_placeholder')) {
drop.element.removeClassName('active'); drop.element.removeClassName('active');
@ -494,7 +494,6 @@ WysijaForm = {
setSettingsPosition: function () { setSettingsPosition: function () {
// get viewport offsets and dimensions // get viewport offsets and dimensions
var viewportHeight = document.viewport.getHeight(); var viewportHeight = document.viewport.getHeight();
var blockPadding = 5;
window.$(WysijaForm.options.container).select('.wysija_settings').each(function (element) { window.$(WysijaForm.options.container).select('.wysija_settings').each(function (element) {
// get parent dimensions and position // get parent dimensions and position
@ -503,16 +502,8 @@ WysijaForm = {
var is_visible = (parentPos.top <= (WysijaForm.scroll.top + viewportHeight)); var is_visible = (parentPos.top <= (WysijaForm.scroll.top + viewportHeight));
var buttonMargin = 5; var buttonMargin = 5;
var relativeTop = buttonMargin; var relativeTop = buttonMargin;
var absoluteTop;
var parentTop;
var parentBottom;
if (is_visible) {
// desired position is set to center of viewport
absoluteTop = parseInt(WysijaForm.scroll.top + ((viewportHeight / 2) - (element.getHeight() / 2)), 10);
parentTop = parseInt(parentPos.top - blockPadding, 10);
parentBottom = parseInt(parentPos.top + parentDim.height - blockPadding, 10);
if(is_visible) {
// always center // always center
relativeTop = parseInt((parentDim.height / 2) - (element.getHeight() / 2), 10); relativeTop = parseInt((parentDim.height / 2) - (element.getHeight() / 2), 10);
} }
@ -830,7 +821,6 @@ WysijaForm.Block = window.Class.create({
}, },
setupControls: function() { setupControls: function() {
var block; var block;
var field;
// enable controls // enable controls
this.controls = this.getControls(); this.controls = this.getControls();
@ -883,7 +873,6 @@ WysijaForm.Block = window.Class.create({
// TODO: refactor // TODO: refactor
block = window.$(event.target).up('.mailpoet_form_block') || null; block = window.$(event.target).up('.mailpoet_form_block') || null;
if(block !== null) { if(block !== null) {
field = WysijaForm.getFieldData(block);
this.editSettings(); this.editSettings();
} }
}.bind(this)); }.bind(this));
@ -934,7 +923,6 @@ WysijaForm.Block.create = function (createBlock, target) {
var template; var template;
var output; var output;
var settings_segments; var settings_segments;
var element;
if(window.$('form_template_' + block.type) === null) { if(window.$('form_template_' + block.type) === null) {
return false; return false;
} }
@ -966,14 +954,13 @@ WysijaForm.Block.create = function (createBlock, target) {
} }
// if the drop target was the bottom placeholder // if the drop target was the bottom placeholder
element = null;
if(target.identify() === 'block_placeholder') { if(target.identify() === 'block_placeholder') {
// insert block at the bottom // insert block at the bottom
element = body.insert(output); body.insert(output);
// block = body.childElements().last(); //block = body.childElements().last();
} else { } else {
// insert block before the drop target // insert block before the drop target
element = target.insert({ target.insert({
before: output before: output
}); });
// block = target.previous('.mailpoet_form_block'); // block = target.previous('.mailpoet_form_block');

View File

@ -10,7 +10,7 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
return output; return output;
}); });
Handlebars.registerHelper('number_format', function (value, block) { Handlebars.registerHelper('number_format', function(value) {
return Number(value).toLocaleString(); return Number(value).toLocaleString();
}); });
Handlebars.registerHelper('date_format', function(timestamp, block) { Handlebars.registerHelper('date_format', function(timestamp, block) {
@ -39,7 +39,6 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
}); });
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
var values;
switch (operator) { switch (operator) {
case '==': case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this); return (v1 == v2) ? options.fn(this) : options.inverse(this);
@ -62,25 +61,24 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
case '||': case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this); return (v1 || v2) ? options.fn(this) : options.inverse(this);
case 'in': case 'in':
values = v2.split(',');
return (v2.indexOf(v1) !== -1) ? options.fn(this) : options.inverse(this); return (v2.indexOf(v1) !== -1) ? options.fn(this) : options.inverse(this);
default: default:
return options.inverse(this); return options.inverse(this);
} }
}); });
Handlebars.registerHelper('nl2br', function (value, block) { Handlebars.registerHelper('nl2br', function(value) {
return value.gsub('\n', '<br />'); return value.gsub('\n', '<br />');
}); });
Handlebars.registerHelper('json_encode', function (value, block) { Handlebars.registerHelper('json_encode', function(value) {
return JSON.stringify(value); return JSON.stringify(value);
}); });
Handlebars.registerHelper('json_decode', function (value, block) { Handlebars.registerHelper('json_decode', function(value) {
return JSON.parse(value); return JSON.parse(value);
}); });
Handlebars.registerHelper('url', function (value, block) { Handlebars.registerHelper('url', function(value) {
var url = window.location.protocol + '//' + window.location.host + window.location.pathname; var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
return url + value; return url + value;
@ -93,12 +91,12 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
return value; return value;
} }
}); });
Handlebars.registerHelper('lookup', function (obj, field, options) { Handlebars.registerHelper('lookup', function(obj, field) {
return obj && obj[field]; return obj && obj[field];
}); });
Handlebars.registerHelper('rsa_key', function(value, block) { Handlebars.registerHelper('rsa_key', function(value) {
var lines; var lines;
// extract all lines into an array // extract all lines into an array
if(value === undefined) return ''; if(value === undefined) return '';
@ -113,8 +111,8 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
return lines.join(''); return lines.join('');
}); });
Handlebars.registerHelper('trim', function (value, block) { Handlebars.registerHelper('trim', function(value) {
if (value === null || value === undefined) return ''; if(value === null || value === undefined) return '';
return value.trim(); return value.trim();
}); });

View File

@ -179,8 +179,8 @@ define('modal', ['mailpoet', 'jquery'],
return this; return this;
}, },
initOverlay: function (toggle) { initOverlay: function() {
if (jQuery('#mailpoet_modal_overlay').length === 0) { if(jQuery('#mailpoet_modal_overlay').length === 0) {
// insert overlay into the DOM // insert overlay into the DOM
jQuery('body').append(this.templates.overlay); jQuery('body').append(this.templates.overlay);
// insert loading indicator into overlay // insert loading indicator into overlay
@ -438,7 +438,7 @@ define('modal', ['mailpoet', 'jquery'],
.removeClass('mailpoet_modal_highlight'); .removeClass('mailpoet_modal_highlight');
return this; return this;
}, },
hideModal: function (callback) { hideModal: function() {
// set modal as closed // set modal as closed
this.opened = false; this.opened = false;
@ -453,7 +453,7 @@ define('modal', ['mailpoet', 'jquery'],
return this; return this;
}, },
showOverlay: function (force) { showOverlay: function() {
jQuery('#mailpoet_modal_overlay').show(); jQuery('#mailpoet_modal_overlay').show();
return this; return this;
}, },

View File

@ -1,12 +1,8 @@
define([ define([
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',
'backbone.radio', 'backbone.radio'
'jquery', ], function(Backbone, Marionette, BackboneRadio) {
'underscore',
'handlebars',
'handlebars_helpers'
], function (Backbone, Marionette, BackboneRadio, jQuery, _, Handlebars) {
var Radio = BackboneRadio; var Radio = BackboneRadio;
var AppView = Marionette.View.extend({ var AppView = Marionette.View.extend({

View File

@ -8,7 +8,7 @@ define([
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'mailpoet', 'mailpoet',
'spectrum' 'spectrum'
], function (Marionette, BehaviorsLookup, MailPoet, Spectrum) { ], function(Marionette, BehaviorsLookup, MailPoet) {
var BL = BehaviorsLookup; var BL = BehaviorsLookup;
BL.ColorPickerBehavior = Marionette.Behavior.extend({ BL.ColorPickerBehavior = Marionette.Behavior.extend({

View File

@ -25,7 +25,7 @@ define([
this.addDropZone(); this.addDropZone();
} }
}, },
addDropZone: function(_event) { addDropZone: function() {
var that = this; var that = this;
var view = this.view; var view = this.view;
var domElement = that.$el.get(0); var domElement = that.$el.get(0);
@ -47,11 +47,11 @@ define([
interact(domElement).dropzone({ interact(domElement).dropzone({
accept: acceptableElementSelector, accept: acceptableElementSelector,
overlap: 'pointer', // Mouse pointer denotes location of a droppable overlap: 'pointer', // Mouse pointer denotes location of a droppable
ondragenter: function (event) { ondragenter: function() {
// 1. Visually mark block as active for dropping // 1. Visually mark block as active for dropping
view.$el.addClass('mailpoet_drop_active'); view.$el.addClass('mailpoet_drop_active');
}, },
ondragleave: function (event) { ondragleave: function() {
// 1. Remove visual markings of active dropping container // 1. Remove visual markings of active dropping container
// 2. Remove visual markings of drop position visualization // 2. Remove visual markings of drop position visualization
that.cleanup(); that.cleanup();
@ -193,7 +193,6 @@ define([
var droppableModel = event.draggable.getDropModel(); var droppableModel = event.draggable.getDropModel();
var viewCollection = that.getCollection(); var viewCollection = that.getCollection();
var droppedView; var droppedView;
var droppedModel;
var index; var index;
var tempCollection; var tempCollection;
var tempCollection2; var tempCollection2;

View File

@ -28,8 +28,8 @@ define([
throw "Missing 'drop' function for DraggableBehavior"; throw "Missing 'drop' function for DraggableBehavior";
}, },
onDrop: function (model, view) {}, onDrop: function() {},
testAttachToInstance: function (model, view) { return true; } testAttachToInstance: function() { return true; }
}, },
onRender: function() { onRender: function() {
var that = this; var that = this;
@ -51,10 +51,8 @@ define([
var event = startEvent; var event = startEvent;
var centerXOffset; var centerXOffset;
var centerYOffset; var centerYOffset;
var parentOffset;
var tempClone; var tempClone;
var clone; var clone;
var $original;
var $clone; var $clone;
if (that.options.cloneOriginal === true) { if (that.options.cloneOriginal === true) {
@ -62,7 +60,7 @@ define([
tempClone = (_.isFunction(that.options.onDragSubstituteBy)) ? that.options.onDragSubstituteBy(that) : undefined; tempClone = (_.isFunction(that.options.onDragSubstituteBy)) ? that.options.onDragSubstituteBy(that) : undefined;
// Or use a clone // Or use a clone
clone = tempClone || event.target.cloneNode(true); clone = tempClone || event.target.cloneNode(true);
$original = jQuery(event.target); jQuery(event.target);
$clone = jQuery(clone); $clone = jQuery(clone);
$clone.addClass('mailpoet_droppable_active'); $clone.addClass('mailpoet_droppable_active');

View File

@ -47,8 +47,7 @@ define([
right: false, right: false,
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
} }
}) }).on('resizestart', function() {
.on('resizestart', function (event) {
that.isBeingResized = true; that.isBeingResized = true;
that.$el.addClass('mailpoet_resize_active'); that.$el.addClass('mailpoet_resize_active');
}).on('resizemove', function(event) { }).on('resizemove', function(event) {
@ -59,11 +58,7 @@ define([
that.view.model.set(that.options.modelField, newLength + 'px'); that.view.model.set(that.options.modelField, newLength + 'px');
}) })
.on('resizemove', function (event) { .on('resizeend', function() {
var onResize = that.options.onResize.bind(that);
return onResize(event);
})
.on('resizeend', function (event) {
that.isBeingResized = null; that.isBeingResized = null;
that.$el.removeClass('mailpoet_resize_active'); that.$el.removeClass('mailpoet_resize_active');
}); });

View File

@ -42,7 +42,7 @@ define([
relative_urls: false, relative_urls: false,
remove_script_host: false, remove_script_host: false,
convert_urls: true, convert_urls: true,
urlconverter_callback: function (url, node, on_save, name) { urlconverter_callback: function(url) {
if (url.match(/\[.+\]/g)) { if (url.match(/\[.+\]/g)) {
// Do not convert URLs with shortcodes // Do not convert URLs with shortcodes
return url; return url;
@ -56,8 +56,8 @@ define([
plugins: this.options.plugins, plugins: this.options.plugins,
setup: function (editor) { setup: function(editor) {
editor.on('change', function (e) { editor.on('change', function() {
that.view.triggerMethod('text:editor:change', editor.getContent()); that.view.triggerMethod('text:editor:change', editor.getContent());
}); });
@ -71,12 +71,12 @@ define([
} }
}); });
editor.on('focus', function (e) { editor.on('focus', function() {
that.view.triggerMethod('text:editor:focus'); that.view.triggerMethod('text:editor:focus');
that._isActivationClick = true; that._isActivationClick = true;
}); });
editor.on('blur', function (e) { editor.on('blur', function() {
that.view.triggerMethod('text:editor:blur'); that.view.triggerMethod('text:editor:blur');
}); });
} }

View File

@ -266,7 +266,7 @@ define([
} }
}).trigger('change'); }).trigger('change');
}, },
toggleDisplayOptions: function(event) { toggleDisplayOptions: function() {
var el = this.$('.mailpoet_automated_latest_content_display_options'); var el = this.$('.mailpoet_automated_latest_content_display_options');
var showControl = this.$('.mailpoet_automated_latest_content_show_display_options'); var showControl = this.$('.mailpoet_automated_latest_content_show_display_options');
if (el.hasClass('mailpoet_closed')) { if (el.hasClass('mailpoet_closed')) {
@ -277,7 +277,7 @@ define([
showControl.removeClass('mailpoet_hidden'); showControl.removeClass('mailpoet_hidden');
} }
}, },
showButtonSettings: function (event) { showButtonSettings: function() {
var buttonModule = ButtonBlock; var buttonModule = ButtonBlock;
(new buttonModule.ButtonBlockSettingsView({ (new buttonModule.ButtonBlockSettingsView({
model: this.model.get('readMoreButton'), model: this.model.get('readMoreButton'),
@ -288,7 +288,7 @@ define([
} }
})).render(); })).render();
}, },
showDividerSettings: function (event) { showDividerSettings: function() {
var dividerModule = DividerBlock; var dividerModule = DividerBlock;
(new dividerModule.DividerBlockSettingsView({ (new dividerModule.DividerBlockSettingsView({
model: this.model.get('divider'), model: this.model.get('divider'),
@ -380,7 +380,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('automatedLatestContent', { App.registerBlockType('automatedLatestContent', {
blockModel: Module.AutomatedLatestContentBlockModel, blockModel: Module.AutomatedLatestContentBlockModel,
blockView: Module.AutomatedLatestContentBlockView blockView: Module.AutomatedLatestContentBlockView
@ -393,7 +393,7 @@ define([
}); });
}); });
App.on('start', function (App, options) { App.on('start', function(App) {
var Application = App; var Application = App;
Application._ALCSupervisor = new Module.ALCSupervisor(); Application._ALCSupervisor = new Module.ALCSupervisor();
Application._ALCSupervisor.refresh(); Application._ALCSupervisor.refresh();

View File

@ -10,9 +10,8 @@ define([
'backbone.supermodel', 'backbone.supermodel',
'underscore', 'underscore',
'jquery', 'jquery',
'mailpoet', 'mailpoet'
'modal' ], function(App, Marionette, SuperModel, _, jQuery, MailPoet) {
], function (App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
'use strict'; 'use strict';
@ -21,9 +20,8 @@ define([
Module.BlockModel = SuperModel.extend({ Module.BlockModel = SuperModel.extend({
stale: [], // Attributes to be removed upon saving stale: [], // Attributes to be removed upon saving
initialize: function () { initialize: function() {
var that = this; this.on('change', function() {
this.on('change', function () {
App.getChannel().trigger('autoSave'); App.getChannel().trigger('autoSave');
}); });
}, },
@ -99,13 +97,13 @@ define([
this.on('dom:refresh', this.showBlock, this); this.on('dom:refresh', this.showBlock, this);
this._isFirstRender = true; this._isFirstRender = true;
}, },
showTools: function (_event) { showTools: function() {
if (!this.showingToolsDisabled) { if (!this.showingToolsDisabled) {
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools'); this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
this.toolsView.triggerMethod('showTools'); this.toolsView.triggerMethod('showTools');
} }
}, },
hideTools: function (e) { hideTools: function() {
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools'); this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
this.toolsView.triggerMethod('hideTools'); this.toolsView.triggerMethod('hideTools');
}, },
@ -264,7 +262,7 @@ define([
model: this.model.toJSON() model: this.model.toJSON()
}; };
}, },
close: function (event) { close: function() {
this.destroy(); this.destroy();
}, },
changeField: function (field, event) { changeField: function (field, event) {

View File

@ -132,7 +132,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('button', { App.registerBlockType('button', {
blockModel: Module.ButtonBlockModel, blockModel: Module.ButtonBlockModel,
blockView: Module.ButtonBlockView blockView: Module.ButtonBlockView

View File

@ -23,9 +23,8 @@ define([
initialize: function () { initialize: function () {
this.on('add change remove', function () { App.getChannel().trigger('autoSave'); }); this.on('add change remove', function () { App.getChannel().trigger('autoSave'); });
}, },
parse: function (response) { parse: function(response) {
var self = this; return _.map(response, function(block) {
return _.map(response, function (block) {
var Type = App.getBlockTypeModel(block.type); var Type = App.getBlockTypeModel(block.type);
// TODO: If type has no registered model, use a backup one // TODO: If type has no registered model, use a backup one
return new Type(block, { parse: true }); return new Type(block, { parse: true });
@ -65,8 +64,8 @@ define([
} }
return response; return response;
}, },
getChildren: function () { getChildren: function() {
var models = this.get('blocks').map(function (model, index, list) { var models = this.get('blocks').map(function(model) {
return [model, model.getChildren()]; return [model, model.getChildren()];
}); });
@ -337,7 +336,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('container', { App.registerBlockType('container', {
blockModel: Module.ContainerBlockModel, blockModel: Module.ContainerBlockModel,
blockView: Module.ContainerBlockView blockView: Module.ContainerBlockView

View File

@ -5,9 +5,8 @@ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/base', 'newsletter_editor/blocks/base',
'underscore', 'underscore',
'jquery', 'jquery'
'mailpoet' ], function(App, BaseBlock, _, jQuery) {
], function (App, BaseBlock, _, jQuery, MailPoet) {
'use strict'; 'use strict';
@ -119,7 +118,7 @@ define([
repaintDividerStyleOptions: function () { repaintDividerStyleOptions: function () {
this.$('.mailpoet_field_divider_style > div').css('border-top-color', this.model.get('styles.block.borderColor')); this.$('.mailpoet_field_divider_style > div').css('border-top-color', this.model.get('styles.block.borderColor'));
}, },
applyToAll: function (event) { applyToAll: function() {
App.getChannel().trigger('replaceAllDividers', this.model.toJSON()); App.getChannel().trigger('replaceAllDividers', this.model.toJSON());
}, },
updateValueAndCall: function (fieldToUpdate, callable, event) { updateValueAndCall: function (fieldToUpdate, callable, event) {
@ -139,7 +138,7 @@ define([
} }
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('divider', { App.registerBlockType('divider', {
blockModel: Module.DividerBlockModel, blockModel: Module.DividerBlockModel,
blockView: Module.DividerBlockView blockView: Module.DividerBlockView

View File

@ -110,7 +110,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('footer', { App.registerBlockType('footer', {
blockModel: Module.FooterBlockModel, blockModel: Module.FooterBlockModel,
blockView: Module.FooterBlockView blockView: Module.FooterBlockView

View File

@ -110,7 +110,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('header', { App.registerBlockType('header', {
blockModel: Module.HeaderBlockModel, blockModel: Module.HeaderBlockModel,
blockView: Module.HeaderBlockView blockView: Module.HeaderBlockView

View File

@ -351,9 +351,6 @@ define([
// retina screen devices // retina screen devices
var targetImageWidth = 1320; var targetImageWidth = 1320;
// For main image use the size, that's closest to being 660px in width
var sizeKeys = _.keys(sizes);
// Pick the width that is closest to target width // Pick the width that is closest to target width
var increasingByWidthDifference = _.sortBy( var increasingByWidthDifference = _.sortBy(
_.keys(sizes), _.keys(sizes),
@ -416,7 +413,7 @@ define([
}); });
Module.ImageWidgetView = ImageWidgetView; Module.ImageWidgetView = ImageWidgetView;
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('image', { App.registerBlockType('image', {
blockModel: Module.ImageBlockModel, blockModel: Module.ImageBlockModel,
blockView: Module.ImageBlockView blockView: Module.ImageBlockView

View File

@ -94,7 +94,6 @@ define([
}; };
}, },
initialize: function() { initialize: function() {
var that = this;
var POST_REFRESH_DELAY_MS = 500; var POST_REFRESH_DELAY_MS = 500;
var refreshAvailablePosts = _.debounce(this.fetchAvailablePosts.bind(this), POST_REFRESH_DELAY_MS); var refreshAvailablePosts = _.debounce(this.fetchAvailablePosts.bind(this), POST_REFRESH_DELAY_MS);
var refreshTransformedPosts = _.debounce(this._refreshTransformedPosts.bind(this), POST_REFRESH_DELAY_MS); var refreshTransformedPosts = _.debounce(this._refreshTransformedPosts.bind(this), POST_REFRESH_DELAY_MS);
@ -163,7 +162,6 @@ define([
}); });
}, },
_insertSelectedPosts: function() { _insertSelectedPosts: function() {
var that = this;
var data = this.toJSON(); var data = this.toJSON();
var index = this.collection.indexOf(this); var index = this.collection.indexOf(this);
var collection = this.collection; var collection = this.collection;
@ -245,7 +243,7 @@ define([
}, },
onRender: function() { onRender: function() {
var that = this; var that = this;
var blockView = this.model.request('blockView'); this.model.request('blockView');
this.showChildView('selectionRegion', this.selectionView); this.showChildView('selectionRegion', this.selectionView);
this.showChildView('displayOptionsRegion', this.displayOptionsView); this.showChildView('displayOptionsRegion', this.displayOptionsView);
@ -497,7 +495,7 @@ define([
model: this.model.toJSON() model: this.model.toJSON()
}; };
}, },
showButtonSettings: function (event) { showButtonSettings: function() {
var buttonModule = ButtonBlock; var buttonModule = ButtonBlock;
(new buttonModule.ButtonBlockSettingsView({ (new buttonModule.ButtonBlockSettingsView({
model: this.model.get('readMoreButton'), model: this.model.get('readMoreButton'),
@ -508,7 +506,7 @@ define([
} }
})).render(); })).render();
}, },
showDividerSettings: function (event) { showDividerSettings: function() {
var dividerModule = DividerBlock; var dividerModule = DividerBlock;
(new dividerModule.DividerBlockSettingsView({ (new dividerModule.DividerBlockSettingsView({
model: this.model.get('divider'), model: this.model.get('divider'),
@ -584,7 +582,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('posts', { App.registerBlockType('posts', {
blockModel: Module.PostsBlockModel, blockModel: Module.PostsBlockModel,
blockView: Module.PostsBlockView blockView: Module.PostsBlockView

View File

@ -34,7 +34,7 @@ define([
text: defaultValues.get('title') text: defaultValues.get('title')
}; };
}, },
initialize: function (options) { initialize: function() {
var that = this; var that = this;
// Make model swap to default values for that type when iconType changes // Make model swap to default values for that type when iconType changes
this.on('change:iconType', function() { this.on('change:iconType', function() {
@ -298,7 +298,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('social', { App.registerBlockType('social', {
blockModel: Module.SocialBlockModel, blockModel: Module.SocialBlockModel,
blockView: Module.SocialBlockView blockView: Module.SocialBlockView

View File

@ -87,7 +87,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('spacer', { App.registerBlockType('spacer', {
blockModel: Module.SpacerBlockModel, blockModel: Module.SpacerBlockModel,
blockView: Module.SpacerBlockView blockView: Module.SpacerBlockView

View File

@ -94,7 +94,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
App.registerBlockType('text', { App.registerBlockType('text', {
blockModel: Module.TextBlockModel, blockModel: Module.TextBlockModel,
blockView: Module.TextBlockView blockView: Module.TextBlockView

View File

@ -98,7 +98,7 @@ define([
}); });
}; };
App.on('start', function (App, options) { App.on('start', function() {
// Prefetch post types // Prefetch post types
Module.getPostTypes(); Module.getPostTypes();
}); });

View File

@ -13,8 +13,8 @@ define([
// handled by other components. // handled by other components.
Module.NewsletterModel = SuperModel.extend({ Module.NewsletterModel = SuperModel.extend({
whitelisted: ['id', 'subject', 'preheader'], whitelisted: ['id', 'subject', 'preheader'],
initialize: function (options) { initialize: function() {
this.on('change', function () { this.on('change', function() {
App.getChannel().trigger('autoSave'); App.getChannel().trigger('autoSave');
}); });
}, },

View File

@ -29,7 +29,7 @@ define([
} }
}); });
App.on('start', function (App, options) { App.on('start', function(App) {
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() })); App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.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',

View File

@ -76,7 +76,6 @@ define([
// Temporary workaround for html2canvas-alpha2. // Temporary workaround for html2canvas-alpha2.
// Removes 1px left transparent border from resulting canvas. // Removes 1px left transparent border from resulting canvas.
var oldContext = oldCanvas.getContext('2d');
var newCanvas = document.createElement('canvas'); var newCanvas = document.createElement('canvas');
var newContext = newCanvas.getContext('2d'); var newContext = newCanvas.getContext('2d');
var leftBorderWidth = 1; var leftBorderWidth = 1;
@ -95,7 +94,6 @@ define([
}; };
Module.saveTemplate = function(options) { Module.saveTemplate = function(options) {
var that = this;
var promise = jQuery.Deferred(); var promise = jQuery.Deferred();
promise.then(function (thumbnail) { promise.then(function (thumbnail) {
@ -121,8 +119,7 @@ define([
return promise; return promise;
}; };
Module.exportTemplate = function (options) { Module.exportTemplate = function(options) {
var that = this;
return Module.getThumbnail( return Module.getThumbnail(
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0) jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
).then(function (thumbnail) { ).then(function (thumbnail) {
@ -155,7 +152,7 @@ define([
'click .mailpoet_save_export': 'toggleExportTemplate', 'click .mailpoet_save_export': 'toggleExportTemplate',
'click .mailpoet_export_template': 'exportTemplate' 'click .mailpoet_export_template': 'exportTemplate'
}, },
initialize: function (options) { initialize: function() {
App.getChannel().on('beforeEditorSave', this.beforeSave, this); App.getChannel().on('beforeEditorSave', this.beforeSave, this);
App.getChannel().on('afterEditorSave', this.afterSave, this); App.getChannel().on('afterEditorSave', this.afterSave, this);
}, },
@ -170,7 +167,7 @@ define([
// TODO: Add a loading animation instead // TODO: Add a loading animation instead
this.$('.mailpoet_autosaved_at').text(MailPoet.I18n.t('saving')); this.$('.mailpoet_autosaved_at').text(MailPoet.I18n.t('saving'));
}, },
afterSave: function (json, response) { afterSave: function(json) {
this.validateNewsletter(json); this.validateNewsletter(json);
// Update 'Last saved timer' // Update 'Last saved timer'
this.$('.mailpoet_editor_last_saved').removeClass('mailpoet_hidden'); this.$('.mailpoet_editor_last_saved').removeClass('mailpoet_hidden');
@ -285,7 +282,7 @@ define([
this.hideOptionContents(); this.hideOptionContents();
if (!this.$('.mailpoet_save_next').hasClass('button-disabled')) { if (!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
Module._cancelAutosave(); Module._cancelAutosave();
Module.save().done(function (response) { Module.save().done(function() {
window.location.href = App.getConfig().get('urls.send'); window.location.href = App.getConfig().get('urls.send');
}); });
} }
@ -355,7 +352,7 @@ define([
} }
}; };
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
var Application = App; var Application = App;
Application.save = Module.save; Application.save = Module.save;
Application.getChannel().on('autoSave', Module.autoSave); Application.getChannel().on('autoSave', Module.autoSave);
@ -365,7 +362,7 @@ define([
Application.getChannel().reply('save', Application.save); Application.getChannel().reply('save', Application.save);
}); });
App.on('start', function (App, options) { App.on('start', function(App) {
var saveView = new Module.SaveView(); var saveView = new Module.SaveView();
App._appView.showChildView('bottomRegion', saveView); App._appView.showChildView('bottomRegion', saveView);
}); });

View File

@ -6,9 +6,8 @@ define([
'backbone.marionette', 'backbone.marionette',
'backbone.supermodel', 'backbone.supermodel',
'underscore', 'underscore',
'jquery', 'jquery'
'sticky-kit' ], function(
], function (
App, App,
CommunicationComponent, CommunicationComponent,
MailPoet, MailPoet,
@ -16,8 +15,7 @@ define([
Marionette, Marionette,
SuperModel, SuperModel,
_, _,
jQuery, jQuery
StickyKit
) { ) {
'use strict'; 'use strict';
@ -90,7 +88,7 @@ define([
} }
} }
}, },
initialize: function (options) { initialize: function() {
jQuery(window) jQuery(window)
.on('resize', this.updateHorizontalScroll.bind(this)) .on('resize', this.updateHorizontalScroll.bind(this))
.on('scroll', this.updateHorizontalScroll.bind(this)); .on('scroll', this.updateHorizontalScroll.bind(this));
@ -266,12 +264,11 @@ define([
}).always(function () { }).always(function () {
MailPoet.Modal.loading(false); MailPoet.Modal.loading(false);
}).done(function(response) { }).done(function(response) {
var view;
this.previewView = new Module.NewsletterPreviewView({ this.previewView = new Module.NewsletterPreviewView({
previewUrl: response.meta.preview_url previewUrl: response.meta.preview_url
}); });
view = this.previewView.render(); this.previewView.render();
this.previewView.$el.css('height', '100%'); this.previewView.$el.css('height', '100%');
MailPoet.Modal.popup({ MailPoet.Modal.popup({
@ -324,7 +321,7 @@ define([
App.getChannel().request('save').always(function () { App.getChannel().request('save').always(function () {
CommunicationComponent.previewNewsletter(data).always(function () { CommunicationComponent.previewNewsletter(data).always(function () {
MailPoet.Modal.loading(false); MailPoet.Modal.loading(false);
}).done(function (response) { }).done(function() {
MailPoet.Notice.success( MailPoet.Notice.success(
MailPoet.I18n.t('newsletterPreviewSent'), MailPoet.I18n.t('newsletterPreviewSent'),
{ scroll: true } { scroll: true }
@ -363,7 +360,7 @@ define([
} }
}); });
App.on('before:start', function (App, options) { App.on('before:start', function(App) {
var Application = App; var Application = App;
Application.registerWidget = Module.registerWidget; Application.registerWidget = Module.registerWidget;
Application.getWidgets = Module.getWidgets; Application.getWidgets = Module.getWidgets;
@ -371,8 +368,7 @@ define([
Application.getLayoutWidgets = Module.getLayoutWidgets; Application.getLayoutWidgets = Module.getLayoutWidgets;
}); });
App.on('start', function(App, options) { App.on('start', function(App) {
var stylesModel = App.getGlobalStyles();
var sidebarView = new SidebarView(); var sidebarView = new SidebarView();
App._appView.showChildView('sidebarRegion', sidebarView); App._appView.showChildView('sidebarRegion', sidebarView);

View File

@ -83,7 +83,7 @@ define([
this.setGlobalStyles(globalStyles); this.setGlobalStyles(globalStyles);
}); });
App.on('start', function (App, options) { App.on('start', function(App) {
var stylesView = new Module.StylesView({ model: App.getGlobalStyles() }); var stylesView = new Module.StylesView({ model: App.getGlobalStyles() });
App._appView.showChildView('stylesRegion', stylesView); App._appView.showChildView('stylesRegion', stylesView);
}); });

View File

@ -10,7 +10,7 @@
/*jshint unused:false */ /*jshint unused:false */
/*global tinymce:true */ /*global tinymce:true */
tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) { tinymce.PluginManager.add('mailpoet_shortcodes', function(editor) {
var appendLabelAndClose = function(shortcode) { var appendLabelAndClose = function(shortcode) {
editor.insertContent(shortcode); editor.insertContent(shortcode);
editor.windowManager.close(); editor.windowManager.close();

View File

@ -1,12 +1,10 @@
define([ define([
'mailpoet', 'mailpoet',
'jquery', 'jquery'
'parsleyjs'
], ],
function ( function (
MailPoet, MailPoet,
jQuery, jQuery
Parsley
) { ) {
jQuery(function ($) { jQuery(function ($) {
function isSameDomain(url) { function isSameDomain(url) {
@ -20,7 +18,7 @@ function (
$('form.mailpoet_form').each(function () { $('form.mailpoet_form').each(function () {
var form = $(this); var form = $(this);
form.parsley().on('form:validated', function (parsley) { form.parsley().on('form:validated', function() {
// clear messages // clear messages
form.find('.mailpoet_message > p').hide(); form.find('.mailpoet_message > p').hide();

View File

@ -51,7 +51,7 @@ define(
jQuery('#mailpoet_sending_method_setup').fadeIn(); jQuery('#mailpoet_sending_method_setup').fadeIn();
} }
}, },
tabs: function (tabStr, section) { tabs: function(tabStr) {
// set default tab // set default tab
var tab = tabStr || 'mta'; var tab = tabStr || 'mta';

View File

@ -3,15 +3,13 @@ define(
'underscore', 'underscore',
'jquery', 'jquery',
'mailpoet', 'mailpoet',
'handlebars', 'handlebars'
'select2'
], ],
function ( function (
_, _,
jQuery, jQuery,
MailPoet, MailPoet,
Handlebars, Handlebars
select2
) { ) {
if (!jQuery('#mailpoet_subscribers_export').length) { if (!jQuery('#mailpoet_subscribers_export').length) {
return; return;
@ -158,7 +156,7 @@ define(
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false, segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
subscriber_fields: subscriberFieldsContainerElement.val() subscriber_fields: subscriberFieldsContainerElement.val()
}) })
}).always(function (response) { }).always(function() {
MailPoet.Modal.loading(false); MailPoet.Modal.loading(false);
}).done(function (response) { }).done(function (response) {
var resultMessage = MailPoet.I18n.t('exportMessage') var resultMessage = MailPoet.I18n.t('exportMessage')

View File

@ -7,8 +7,7 @@ define(
'handlebars', 'handlebars',
'papaparse', 'papaparse',
'asyncqueue', 'asyncqueue',
'moment', 'moment'
'select2'
], ],
function ( function (
Backbone, Backbone,
@ -18,8 +17,7 @@ define(
Handlebars, Handlebars,
Papa, Papa,
AsyncQueue, AsyncQueue,
Moment, Moment
select2
) { ) {
if (!jQuery('#mailpoet_subscribers_import').length) { if (!jQuery('#mailpoet_subscribers_import').length) {
return; return;
@ -64,7 +62,7 @@ define(
var uploadElement; var uploadElement;
var uploadProcessButtonElement; var uploadProcessButtonElement;
// set or reset temporary validation rule on all columns // set or reset temporary validation rule on all columns
window.mailpoetColumns = jQuery.map(window.mailpoetColumns, function (column, columnIndex) { window.mailpoetColumns = jQuery.map(window.mailpoetColumns, function (column) {
var col = column; var col = column;
col.validation_rule = false; col.validation_rule = false;
return col; return col;
@ -245,7 +243,7 @@ define(
api_key: mailChimpKeyInputElement.val(), api_key: mailChimpKeyInputElement.val(),
lists: mailChimpListsContainerElement.find('select').val() lists: mailChimpListsContainerElement.find('select').val()
} }
}).always(function (response) { }).always(function() {
MailPoet.Modal.loading(false); MailPoet.Modal.loading(false);
}).done(function (response) { }).done(function (response) {
window.importData.step1 = response.data; window.importData.step1 = response.data;
@ -771,7 +769,7 @@ define(
title: MailPoet.I18n.t('addNewField'), title: MailPoet.I18n.t('addNewField'),
template: jQuery('#form_template_field_form').html() template: jQuery('#form_template_field_form').html()
}); });
jQuery('#form_field_new').parsley().on('form:submit', function (parsley) { jQuery('#form_field_new').parsley().on('form:submit', function() {
// get data // get data
var data = jQuery(this.$element).serializeObject(); var data = jQuery(this.$element).serializeObject();
@ -874,7 +872,7 @@ define(
return { id: columnId, index: elementIndex, validationRule: validationRule, element: element }; return { id: columnId, index: elementIndex, validationRule: validationRule, element: element };
}); });
// iterate through the object of mailpoet columns // iterate through the object of mailpoet columns
jQuery.map(window.mailpoetColumns, function (column, columnIndex) { jQuery.map(window.mailpoetColumns, function (column) {
var firstRowData; var firstRowData;
var validationRule; var validationRule;
var testedFormat; var testedFormat;