ES5 space-before-function-parens
This commit is contained in:
@ -8,7 +8,7 @@ define([
|
||||
'underscore',
|
||||
'jquery',
|
||||
'sticky-kit'
|
||||
], function(
|
||||
], function (
|
||||
App,
|
||||
CommunicationComponent,
|
||||
MailPoet,
|
||||
@ -35,8 +35,8 @@ define([
|
||||
}),
|
||||
comparator: 'priority'
|
||||
}))();
|
||||
Module.registerWidget = function(widget) { return Module._contentWidgets.add(widget); };
|
||||
Module.getWidgets = function() { return Module._contentWidgets; };
|
||||
Module.registerWidget = function (widget) { return Module._contentWidgets.add(widget); };
|
||||
Module.getWidgets = function () { return Module._contentWidgets; };
|
||||
|
||||
// Layout widget handlers for use to create new layout blocks via drag&drop
|
||||
Module._layoutWidgets = new (Backbone.Collection.extend({
|
||||
@ -49,11 +49,11 @@ define([
|
||||
}),
|
||||
comparator: 'priority'
|
||||
}))();
|
||||
Module.registerLayoutWidget = function(widget) { return Module._layoutWidgets.add(widget); };
|
||||
Module.getLayoutWidgets = function() { return Module._layoutWidgets; };
|
||||
Module.registerLayoutWidget = function (widget) { return Module._layoutWidgets.add(widget); };
|
||||
Module.getLayoutWidgets = function () { return Module._layoutWidgets; };
|
||||
|
||||
var SidebarView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.sidebar; },
|
||||
getTemplate: function () { return window.templates.sidebar; },
|
||||
regions: {
|
||||
contentRegion: '.mailpoet_content_region',
|
||||
layoutRegion: '.mailpoet_layout_region',
|
||||
@ -61,7 +61,7 @@ define([
|
||||
previewRegion: '.mailpoet_preview_region'
|
||||
},
|
||||
events: {
|
||||
'click .mailpoet_sidebar_region h3, .mailpoet_sidebar_region .handlediv': function(event) {
|
||||
'click .mailpoet_sidebar_region h3, .mailpoet_sidebar_region .handlediv': function (event) {
|
||||
var $openRegion = this.$el.find('.mailpoet_sidebar_region:not(.closed)'),
|
||||
$targetRegion = this.$el.find(event.target).closest('.mailpoet_sidebar_region');
|
||||
|
||||
@ -70,7 +70,7 @@ define([
|
||||
{
|
||||
duration: 250,
|
||||
easing: 'easeOut',
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
$openRegion.addClass('closed');
|
||||
}.bind(this)
|
||||
}
|
||||
@ -82,7 +82,7 @@ define([
|
||||
{
|
||||
duration: 250,
|
||||
easing: 'easeIn',
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
$targetRegion.removeClass('closed');
|
||||
}
|
||||
}
|
||||
@ -90,12 +90,12 @@ define([
|
||||
}
|
||||
}
|
||||
},
|
||||
initialize: function(options) {
|
||||
initialize: function (options) {
|
||||
jQuery(window)
|
||||
.on('resize', this.updateHorizontalScroll.bind(this))
|
||||
.on('scroll', this.updateHorizontalScroll.bind(this));
|
||||
},
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
this.showChildView('contentRegion', new Module.SidebarWidgetsView(
|
||||
App.getWidgets()
|
||||
));
|
||||
@ -108,7 +108,7 @@ define([
|
||||
}));
|
||||
this.showChildView('previewRegion', new Module.SidebarPreviewView());
|
||||
},
|
||||
updateHorizontalScroll: function() {
|
||||
updateHorizontalScroll: function () {
|
||||
// Fixes the sidebar so that on narrower screens the horizontal
|
||||
// position of the sidebar would be scrollable and not fixed
|
||||
// partially out of visible screen
|
||||
@ -125,7 +125,7 @@ define([
|
||||
}
|
||||
});
|
||||
},
|
||||
onDomRefresh: function() {
|
||||
onDomRefresh: function () {
|
||||
this.$el.parent().stick_in_parent({
|
||||
offset_top: 32
|
||||
});
|
||||
@ -140,23 +140,23 @@ define([
|
||||
* Draggable widget collection view
|
||||
*/
|
||||
Module.SidebarWidgetsCollectionView = Marionette.CollectionView.extend({
|
||||
childView: function(item) { return item.get('widgetView'); }
|
||||
childView: function (item) { return item.get('widgetView'); }
|
||||
});
|
||||
|
||||
/**
|
||||
* Responsible for rendering draggable content widgets
|
||||
*/
|
||||
Module.SidebarWidgetsView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.sidebarContent; },
|
||||
getTemplate: function () { return window.templates.sidebarContent; },
|
||||
regions: {
|
||||
widgets: '.mailpoet_region_content'
|
||||
},
|
||||
|
||||
initialize: function(widgets) {
|
||||
initialize: function (widgets) {
|
||||
this.widgets = widgets;
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
this.showChildView('widgets', new Module.SidebarWidgetsCollectionView({
|
||||
collection: this.widgets
|
||||
}));
|
||||
@ -167,68 +167,68 @@ define([
|
||||
* Responsible for rendering draggable layout widgets
|
||||
*/
|
||||
Module.SidebarLayoutWidgetsView = Module.SidebarWidgetsView.extend({
|
||||
getTemplate: function() { return window.templates.sidebarLayout; }
|
||||
getTemplate: function () { return window.templates.sidebarLayout; }
|
||||
});
|
||||
|
||||
/**
|
||||
* Responsible for managing global styles
|
||||
*/
|
||||
Module.SidebarStylesView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.sidebarStyles; },
|
||||
getTemplate: function () { return window.templates.sidebarStyles; },
|
||||
behaviors: {
|
||||
ColorPickerBehavior: {}
|
||||
},
|
||||
events: function() {
|
||||
events: function () {
|
||||
return {
|
||||
'change #mailpoet_text_font_color': _.partial(this.changeColorField, 'text.fontColor'),
|
||||
'change #mailpoet_text_font_family': function(event) {
|
||||
'change #mailpoet_text_font_family': function (event) {
|
||||
this.model.set('text.fontFamily', event.target.value);
|
||||
},
|
||||
'change #mailpoet_text_font_size': function(event) {
|
||||
'change #mailpoet_text_font_size': function (event) {
|
||||
this.model.set('text.fontSize', event.target.value);
|
||||
},
|
||||
'change #mailpoet_h1_font_color': _.partial(this.changeColorField, 'h1.fontColor'),
|
||||
'change #mailpoet_h1_font_family': function(event) {
|
||||
'change #mailpoet_h1_font_family': function (event) {
|
||||
this.model.set('h1.fontFamily', event.target.value);
|
||||
},
|
||||
'change #mailpoet_h1_font_size': function(event) {
|
||||
'change #mailpoet_h1_font_size': function (event) {
|
||||
this.model.set('h1.fontSize', event.target.value);
|
||||
},
|
||||
'change #mailpoet_h2_font_color': _.partial(this.changeColorField, 'h2.fontColor'),
|
||||
'change #mailpoet_h2_font_family': function(event) {
|
||||
'change #mailpoet_h2_font_family': function (event) {
|
||||
this.model.set('h2.fontFamily', event.target.value);
|
||||
},
|
||||
'change #mailpoet_h2_font_size': function(event) {
|
||||
'change #mailpoet_h2_font_size': function (event) {
|
||||
this.model.set('h2.fontSize', event.target.value);
|
||||
},
|
||||
'change #mailpoet_h3_font_color': _.partial(this.changeColorField, 'h3.fontColor'),
|
||||
'change #mailpoet_h3_font_family': function(event) {
|
||||
'change #mailpoet_h3_font_family': function (event) {
|
||||
this.model.set('h3.fontFamily', event.target.value);
|
||||
},
|
||||
'change #mailpoet_h3_font_size': function(event) {
|
||||
'change #mailpoet_h3_font_size': function (event) {
|
||||
this.model.set('h3.fontSize', event.target.value);
|
||||
},
|
||||
'change #mailpoet_a_font_color': _.partial(this.changeColorField, 'link.fontColor'),
|
||||
'change #mailpoet_a_font_underline': function(event) {
|
||||
'change #mailpoet_a_font_underline': function (event) {
|
||||
this.model.set('link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
||||
},
|
||||
'change #mailpoet_newsletter_background_color': _.partial(this.changeColorField, 'wrapper.backgroundColor'),
|
||||
'change #mailpoet_background_color': _.partial(this.changeColorField, 'body.backgroundColor')
|
||||
};
|
||||
},
|
||||
templateContext: function() {
|
||||
templateContext: function () {
|
||||
return {
|
||||
model: this.model.toJSON(),
|
||||
availableStyles: this.availableStyles.toJSON()
|
||||
};
|
||||
},
|
||||
initialize: function(options) {
|
||||
initialize: function (options) {
|
||||
this.availableStyles = options.availableStyles;
|
||||
},
|
||||
changeField: function(field, event) {
|
||||
changeField: function (field, event) {
|
||||
this.model.set(field, jQuery(event.target).val());
|
||||
},
|
||||
changeColorField: function(field, event) {
|
||||
changeColorField: function (field, event) {
|
||||
var value = jQuery(event.target).val();
|
||||
if (value === '') {
|
||||
value = 'transparent';
|
||||
@ -238,18 +238,18 @@ define([
|
||||
});
|
||||
|
||||
Module.SidebarPreviewView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.sidebarPreview; },
|
||||
getTemplate: function () { return window.templates.sidebarPreview; },
|
||||
events: {
|
||||
'click .mailpoet_show_preview': 'showPreview',
|
||||
'click #mailpoet_send_preview': 'sendPreview'
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
onBeforeDestroy: function () {
|
||||
if (this.previewView) {
|
||||
this.previewView.destroy();
|
||||
this.previewView = null;
|
||||
}
|
||||
},
|
||||
showPreview: function() {
|
||||
showPreview: function () {
|
||||
var json = App.toJSON();
|
||||
|
||||
// Stringify to enable transmission of primitive non-string value types
|
||||
@ -264,9 +264,9 @@ define([
|
||||
endpoint: 'newsletters',
|
||||
action: 'showPreview',
|
||||
data: json
|
||||
}).always(function() {
|
||||
}).always(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
}).done(function (response) {
|
||||
this.previewView = new Module.NewsletterPreviewView({
|
||||
previewUrl: response.meta.preview_url
|
||||
});
|
||||
@ -280,7 +280,7 @@ define([
|
||||
width: '95%',
|
||||
height: '94%',
|
||||
title: MailPoet.I18n.t('newsletterPreview'),
|
||||
onCancel: function() {
|
||||
onCancel: function () {
|
||||
this.previewView.destroy();
|
||||
this.previewView = null;
|
||||
}.bind(this)
|
||||
@ -289,16 +289,16 @@ define([
|
||||
MailPoet.trackEvent('Editor > Browser Preview', {
|
||||
'MailPoet Free version': window.mailpoet_version
|
||||
});
|
||||
}.bind(this)).fail(function(response) {
|
||||
}.bind(this)).fail(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
response.errors.map(function (error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
sendPreview: function() {
|
||||
sendPreview: function () {
|
||||
// get form data
|
||||
var $emailField = this.$('#mailpoet_preview_to_email');
|
||||
var data = {
|
||||
@ -321,10 +321,10 @@ define([
|
||||
MailPoet.Modal.loading(true);
|
||||
|
||||
// save before sending
|
||||
App.getChannel().request('save').always(function() {
|
||||
CommunicationComponent.previewNewsletter(data).always(function() {
|
||||
App.getChannel().request('save').always(function () {
|
||||
CommunicationComponent.previewNewsletter(data).always(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
}).done(function (response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterPreviewSent'),
|
||||
{ scroll: true }
|
||||
@ -333,10 +333,10 @@ define([
|
||||
'MailPoet Free version': window.mailpoet_version,
|
||||
'Domain name': data.subscriber.substring(data.subscriber.indexOf('@') + 1)
|
||||
});
|
||||
}).fail(function(response) {
|
||||
}).fail(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
response.errors.map(function (error) { return error.message; }),
|
||||
{ scroll: true, static: true }
|
||||
);
|
||||
}
|
||||
@ -346,15 +346,15 @@ define([
|
||||
});
|
||||
|
||||
Module.NewsletterPreviewView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.newsletterPreview; },
|
||||
initialize: function(options) {
|
||||
getTemplate: function () { return window.templates.newsletterPreview; },
|
||||
initialize: function (options) {
|
||||
this.previewUrl = options.previewUrl;
|
||||
this.width = '100%';
|
||||
this.height = '100%';
|
||||
// this.width = App.getConfig().get('newsletterPreview.width');
|
||||
// this.height = App.getConfig().get('newsletterPreview.height')
|
||||
},
|
||||
templateContext: function() {
|
||||
templateContext: function () {
|
||||
return {
|
||||
previewUrl: this.previewUrl,
|
||||
width: this.width,
|
||||
@ -363,7 +363,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App, options) {
|
||||
App.on('before:start', function (App, options) {
|
||||
var Application = App;
|
||||
Application.registerWidget = Module.registerWidget;
|
||||
Application.getWidgets = Module.getWidgets;
|
||||
@ -371,7 +371,7 @@ define([
|
||||
Application.getLayoutWidgets = Module.getLayoutWidgets;
|
||||
});
|
||||
|
||||
App.on('start', function(App, options) {
|
||||
App.on('start', function (App, options) {
|
||||
var stylesModel = App.getGlobalStyles(),
|
||||
sidebarView = new SidebarView();
|
||||
|
||||
|
Reference in New Issue
Block a user