ES5 space-before-function-parens

This commit is contained in:
Amine Ben hammou
2017-09-21 08:35:12 +00:00
parent bf1d76a3a7
commit 680446b77e
52 changed files with 871 additions and 872 deletions

View File

@@ -10,7 +10,7 @@ define([
'jquery',
'newsletter_editor/App',
'newsletter_editor/blocks/base'
], function(Backbone, Marionette, _, jQuery, App, BaseBlock) {
], function (Backbone, Marionette, _, jQuery, App, BaseBlock) {
'use strict';
@@ -20,12 +20,12 @@ define([
BlockCollection = Backbone.Collection.extend({
model: base.BlockModel,
initialize: function() {
this.on('add change remove', function() { App.getChannel().trigger('autoSave'); });
initialize: function () {
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);
// TODO: If type has no registered model, use a backup one
return new Type(block, {parse: true});
@@ -37,7 +37,7 @@ define([
relations: {
blocks: BlockCollection
},
defaults: function() {
defaults: function () {
return this._getDefaults({
type: 'container',
orientation: 'vertical',
@@ -49,14 +49,14 @@ define([
blocks: new BlockCollection()
}, App.getConfig().get('blockDefaults.container'));
},
validate: function() {
validate: function () {
// Recursively propagate validation checks to blocks in the tree
var invalidBlock = this.get('blocks').find(function(block) { return !block.isValid(); });
var invalidBlock = this.get('blocks').find(function (block) { return !block.isValid(); });
if (invalidBlock) {
return invalidBlock.validationError;
}
},
parse: function(response) {
parse: function (response) {
// If container has any blocks - add them to a collection
if (response.type === 'container' && _.has(response, 'blocks')) {
response.blocks = new BlockCollection(response.blocks, {
@@ -65,8 +65,8 @@ define([
}
return response;
},
getChildren: function() {
var models = this.get('blocks').map(function(model, index, list) {
getChildren: function () {
var models = this.get('blocks').map(function (model, index, list) {
return [model, model.getChildren()];
});
@@ -76,10 +76,10 @@ define([
Module.ContainerBlocksView = Marionette.CollectionView.extend({
className: 'mailpoet_container',
childView: function(model) {
childView: function (model) {
return App.getBlockTypeView(model.get('type'));
},
childViewOptions: function() {
childViewOptions: function () {
var newRenderOptions = _.clone(this.renderOptions);
if (newRenderOptions.depth !== undefined) {
newRenderOptions.depth += 1;
@@ -88,9 +88,9 @@ define([
renderOptions: newRenderOptions
};
},
emptyView: function() { return Module.ContainerBlockEmptyView; },
emptyViewOptions: function() { return { renderOptions: this.renderOptions }; },
initialize: function(options) {
emptyView: function () { return Module.ContainerBlockEmptyView; },
emptyViewOptions: function () { return { renderOptions: this.renderOptions }; },
initialize: function (options) {
this.renderOptions = options.renderOptions;
}
});
@@ -103,7 +103,7 @@ define([
}
}),
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
getTemplate: function() { return window.templates.containerBlock; },
getTemplate: function () { return window.templates.containerBlock; },
events: _.extend({}, base.BlockView.prototype.events, {
'click .mailpoet_newsletter_layer_selector': 'toggleEditingLayer'
}),
@@ -115,12 +115,12 @@ define([
DraggableBehavior: {
cloneOriginal: true,
hideOriginal: true,
onDrop: function(options) {
onDrop: function (options) {
// After a clone of model has been dropped, cleanup
// and destroy self
options.dragBehavior.view.model.destroy();
},
onDragSubstituteBy: function(behavior) {
onDragSubstituteBy: function (behavior) {
var WidgetView, node;
// When block is being dragged, display the widget icon instead.
// This will create an instance of block's widget view and
@@ -133,7 +133,7 @@ define([
return node;
}
},
testAttachToInstance: function(model, view) {
testAttachToInstance: function (model, view) {
// Attach Draggable only to layout containers and disable it
// for root and column containers.
return view.renderOptions.depth === 1;
@@ -141,7 +141,7 @@ define([
},
HighlightContainerBehavior: {}
}),
onDragSubstituteBy: function() {
onDragSubstituteBy: function () {
// For two and three column layouts display their respective widgets,
// otherwise always default to one column layout widget
if (this.renderOptions.depth === 1) {
@@ -151,12 +151,12 @@ define([
return Module.OneColumnContainerWidgetView;
},
initialize: function(options) {
initialize: function (options) {
base.BlockView.prototype.initialize.apply(this, arguments);
this.renderOptions = _.defaults(options.renderOptions || {}, {});
},
onRender: function() {
onRender: function () {
this.toolsView = new Module.ContainerBlockToolsView({
model: this.model,
tools: {
@@ -177,31 +177,31 @@ define([
// Sets child container orientation HTML class here, as child CollectionView won't have access to model and will overwrite existing region element instead
this.$('> .mailpoet_container').attr('class', 'mailpoet_container mailpoet_container_' + this.model.get('orientation'));
},
showTools: function() {
showTools: function () {
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
this.$(this.ui.tools).addClass('mailpoet_display_tools');
this.toolsView.triggerMethod('showTools');
}
},
hideTools: function() {
hideTools: function () {
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
this.toolsView.triggerMethod('hideTools');
}
},
toggleEditingLayer: function(event) {
toggleEditingLayer: function (event) {
var that = this,
$toggleButton = this.$('> .mailpoet_tools .mailpoet_newsletter_layer_selector'),
$overlay = jQuery('.mailpoet_layer_overlay'),
$container = this.$('> .mailpoet_container'),
enableContainerLayer = function() {
enableContainerLayer = function () {
that.$el.addClass('mailpoet_container_layer_active');
$toggleButton.addClass('mailpoet_container_layer_active');
$container.addClass('mailpoet_layer_highlight');
$overlay.click(disableContainerLayer);
$overlay.show();
},
disableContainerLayer = function() {
disableContainerLayer = function () {
that.$el.removeClass('mailpoet_container_layer_active');
$toggleButton.removeClass('mailpoet_container_layer_active');
$container.removeClass('mailpoet_layer_highlight');
@@ -218,11 +218,11 @@ define([
});
Module.ContainerBlockEmptyView = Marionette.View.extend({
getTemplate: function() { return window.templates.containerEmpty; },
initialize: function(options) {
getTemplate: function () { return window.templates.containerEmpty; },
initialize: function (options) {
this.renderOptions = _.defaults(options.renderOptions || {}, {});
},
templateContext: function() {
templateContext: function () {
return {
isRoot: this.renderOptions.depth === 0,
emptyContainerMessage: this.renderOptions.emptyContainerMessage || ''
@@ -231,12 +231,12 @@ define([
});
Module.ContainerBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.ContainerBlockSettingsView; }
getSettingsView: function () { return Module.ContainerBlockSettingsView; }
});
Module.ContainerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return window.templates.containerBlockSettings; },
events: function() {
getTemplate: function () { return window.templates.containerBlockSettings; },
events: function () {
return {
'change .mailpoet_field_container_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_done_editing': 'close'
@@ -245,21 +245,21 @@ define([
regions: {
columnsSettingsRegion: '.mailpoet_container_columns_settings'
},
initialize: function() {
initialize: function () {
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
this._columnsSettingsView = new (Module.ContainerBlockColumnsSettingsView)({
collection: this.model.get('blocks')
});
},
onRender: function() {
onRender: function () {
this.showChildView('columnsSettingsRegion', this._columnsSettingsView);
}
});
Module.ContainerBlockColumnsSettingsView = Marionette.CollectionView.extend({
childView: function() { return Module.ContainerBlockColumnSettingsView; },
childViewOptions: function(model, index) {
childView: function () { return Module.ContainerBlockColumnSettingsView; },
childViewOptions: function (model, index) {
return {
columnIndex: index
};
@@ -267,11 +267,11 @@ define([
});
Module.ContainerBlockColumnSettingsView = Marionette.View.extend({
getTemplate: function() { return window.templates.containerBlockColumnSettings; },
initialize: function(options) {
getTemplate: function () { return window.templates.containerBlockColumnSettings; },
initialize: function (options) {
this.columnNumber = (options.columnIndex || 0) + 1;
},
templateContext: function() {
templateContext: function () {
return {
model: this.model.toJSON(),
columnNumber: this.columnNumber
@@ -281,11 +281,11 @@ define([
Module.OneColumnContainerWidgetView = base.WidgetView.extend({
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
getTemplate: function() { return window.templates.oneColumnLayoutInsertion; },
getTemplate: function () { return window.templates.oneColumnLayoutInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
drop: function() {
drop: function () {
return new Module.ContainerBlockModel({
orientation: 'horizontal',
blocks: [
@@ -299,11 +299,11 @@ define([
Module.TwoColumnContainerWidgetView = base.WidgetView.extend({
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
getTemplate: function() { return window.templates.twoColumnLayoutInsertion; },
getTemplate: function () { return window.templates.twoColumnLayoutInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
drop: function() {
drop: function () {
return new Module.ContainerBlockModel({
orientation: 'horizontal',
blocks: [
@@ -318,11 +318,11 @@ define([
Module.ThreeColumnContainerWidgetView = base.WidgetView.extend({
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
getTemplate: function() { return window.templates.threeColumnLayoutInsertion; },
getTemplate: function () { return window.templates.threeColumnLayoutInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
drop: function() {
drop: function () {
return new Module.ContainerBlockModel({
orientation: 'horizontal',
blocks: [
@@ -336,7 +336,7 @@ define([
}
});
App.on('before:start', function(App, options) {
App.on('before:start', function (App, options) {
App.registerBlockType('container', {
blockModel: Module.ContainerBlockModel,
blockView: Module.ContainerBlockView