Fix func-names rule in es5
Please remove those comments if you work on those files [MAILPOET-1143]
This commit is contained in:
@ -41,7 +41,6 @@
|
||||
"no-throw-literal": 0,
|
||||
"no-extra-bind": 0,
|
||||
"brace-style": 0,
|
||||
"space-infix-ops": 0,
|
||||
"func-names": 0
|
||||
"space-infix-ops": 0
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
define('admin', [
|
||||
'jquery'
|
||||
],
|
||||
function (jQuery) {
|
||||
jQuery(function ($) {
|
||||
function admin(jQuery) {
|
||||
jQuery(function adminDomReady($) {
|
||||
// dom ready
|
||||
$(function () {
|
||||
$(function domReady() {
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ function requestFailed(errorMessage, xhr) {
|
||||
};
|
||||
}
|
||||
|
||||
define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
define('ajax', ['mailpoet', 'jquery', 'underscore'], function ajax(mp, jQuery, _) {
|
||||
var MailPoet = mp;
|
||||
|
||||
MailPoet.Ajax = {
|
||||
@ -25,10 +25,10 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
token: null,
|
||||
data: {}
|
||||
},
|
||||
post: function (options) {
|
||||
post: function post(options) {
|
||||
return this.request('post', options);
|
||||
},
|
||||
init: function (options) {
|
||||
init: function init(options) {
|
||||
// merge options
|
||||
this.options = jQuery.extend({}, this.defaults, options);
|
||||
|
||||
@ -42,7 +42,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
this.options.token = window.mailpoet_token;
|
||||
}
|
||||
},
|
||||
getParams: function () {
|
||||
getParams: function getParams() {
|
||||
return {
|
||||
action: 'mailpoet',
|
||||
api_version: this.options.api_version,
|
||||
@ -52,7 +52,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
data: this.options.data || {}
|
||||
};
|
||||
},
|
||||
request: function (method, options) {
|
||||
request: function request(method, options) {
|
||||
var params;
|
||||
var deferred;
|
||||
// set options
|
||||
@ -63,7 +63,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
|
||||
// remove null values from the data object
|
||||
if (_.isObject(params.data)) {
|
||||
params.data = _.pick(params.data, function (value) {
|
||||
params.data = _.pick(params.data, function IsNotNull(value) {
|
||||
return (value !== null);
|
||||
});
|
||||
}
|
||||
@ -74,7 +74,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
params,
|
||||
null,
|
||||
'json'
|
||||
).then(function (data) {
|
||||
).then(function resultHandler(data) {
|
||||
return data;
|
||||
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
||||
|
||||
|
@ -31,12 +31,12 @@ function exportMixpanel(mp) {
|
||||
if (window.mailpoet_analytics_enabled) {
|
||||
MailPoet.trackEvent = track;
|
||||
} else {
|
||||
MailPoet.trackEvent = function () {};
|
||||
MailPoet.trackEvent = function emptyFunction() {};
|
||||
}
|
||||
}
|
||||
|
||||
function trackCachedEvents() {
|
||||
eventsCache.map(function (event) {
|
||||
eventsCache.map(function trackIfEnabled(event) {
|
||||
if (window.mailpoet_analytics_enabled || event.forced) {
|
||||
window.mixpanel.track(event.name, event.data);
|
||||
}
|
||||
@ -53,7 +53,7 @@ function cacheEvent(forced, name, data) {
|
||||
|
||||
define(
|
||||
['mailpoet', 'underscore'],
|
||||
function (mp, _) {
|
||||
function analyticsEvent(mp, _) {
|
||||
var MailPoet = mp;
|
||||
|
||||
function initializeMixpanelWhenLoaded() {
|
||||
|
@ -3,7 +3,7 @@ define('date',
|
||||
'mailpoet',
|
||||
'jquery',
|
||||
'moment'
|
||||
], function (
|
||||
], function ( // eslint-disable-line func-names
|
||||
mp,
|
||||
jQuery,
|
||||
Moment
|
||||
@ -19,7 +19,7 @@ define('date',
|
||||
offset: 0,
|
||||
format: 'F, d Y H:i:s'
|
||||
},
|
||||
init: function (opts) {
|
||||
init: function init(opts) {
|
||||
var options = opts || {};
|
||||
|
||||
// set UTC offset
|
||||
@ -41,7 +41,7 @@ define('date',
|
||||
|
||||
return this;
|
||||
},
|
||||
format: function (date, opts) {
|
||||
format: function format(date, opts) {
|
||||
var options = opts || {};
|
||||
var momentDate;
|
||||
this.init(options);
|
||||
@ -50,28 +50,28 @@ define('date',
|
||||
if (options.offset === 0) momentDate = momentDate.utc();
|
||||
return momentDate.format(this.convertFormat(this.options.format));
|
||||
},
|
||||
toDate: function (date, opts) {
|
||||
toDate: function toDate(date, opts) {
|
||||
var options = opts || {};
|
||||
this.init(options);
|
||||
|
||||
return Moment(date, this.convertFormat(options.parseFormat)).toDate();
|
||||
},
|
||||
short: function (date) {
|
||||
short: function short(date) {
|
||||
return this.format(date, {
|
||||
format: 'F, j Y'
|
||||
});
|
||||
},
|
||||
full: function (date) {
|
||||
full: function full(date) {
|
||||
return this.format(date, {
|
||||
format: 'F, j Y H:i:s'
|
||||
});
|
||||
},
|
||||
time: function (date) {
|
||||
time: function time(date) {
|
||||
return this.format(date, {
|
||||
format: 'H:i:s'
|
||||
});
|
||||
},
|
||||
convertFormat: function (format) {
|
||||
convertFormat: function convertFormat(format) {
|
||||
var replacements;
|
||||
var convertedFormat;
|
||||
var escapeToken;
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/*
|
||||
* name: MailPoet Form Editor
|
||||
* author: Jonathan Labreuille
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define('handlebars_helpers', ['handlebars'], function (Handlebars) {
|
||||
// Handlebars helpers
|
||||
Handlebars.registerHelper('concat', function () {
|
||||
|
@ -1,11 +1,11 @@
|
||||
define('helpTooltip', ['mailpoet', 'react', 'react-dom', 'help-tooltip.jsx'],
|
||||
function (mp, React, ReactDOM, TooltipComponent) {
|
||||
function helpTooltip(mp, React, ReactDOM, TooltipComponent) {
|
||||
'use strict';
|
||||
|
||||
var MailPoet = mp;
|
||||
|
||||
MailPoet.helpTooltip = {
|
||||
show: function (domContainerNode, opts) {
|
||||
show: function show(domContainerNode, opts) {
|
||||
ReactDOM.render(React.createElement(
|
||||
TooltipComponent, {
|
||||
tooltip: opts.tooltip,
|
||||
|
@ -1,7 +1,7 @@
|
||||
define('i18n',
|
||||
[
|
||||
'mailpoet'
|
||||
], function (
|
||||
], function i18n(
|
||||
mp
|
||||
) {
|
||||
'use strict';
|
||||
@ -11,13 +11,13 @@ define('i18n',
|
||||
var translations = {};
|
||||
|
||||
MailPoet.I18n = {
|
||||
add: function (key, value) {
|
||||
add: function add(key, value) {
|
||||
translations[key] = value;
|
||||
},
|
||||
t: function (key) {
|
||||
t: function t(key) {
|
||||
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
|
||||
},
|
||||
all: function () {
|
||||
all: function all() {
|
||||
return translations;
|
||||
}
|
||||
};
|
||||
|
@ -1,10 +1,10 @@
|
||||
define('iframe', ['mailpoet'], function (mp) {
|
||||
define('iframe', ['mailpoet'], function iframeModule(mp) {
|
||||
'use strict';
|
||||
|
||||
var MailPoet = mp;
|
||||
MailPoet.Iframe = {
|
||||
marginY: 20,
|
||||
autoSize: function (iframe) {
|
||||
autoSize: function autoSize(iframe) {
|
||||
if (!iframe) return;
|
||||
|
||||
this.setSize(
|
||||
@ -12,7 +12,7 @@ define('iframe', ['mailpoet'], function (mp) {
|
||||
iframe.contentWindow.document.body.scrollHeight
|
||||
);
|
||||
},
|
||||
setSize: function (sizeIframe, i) {
|
||||
setSize: function setSize(sizeIframe, i) {
|
||||
var iframe = sizeIframe;
|
||||
if (!iframe) return;
|
||||
|
||||
|
@ -2,7 +2,7 @@ define(
|
||||
[
|
||||
'jquery'
|
||||
],
|
||||
function (
|
||||
function ( // eslint-disable-line func-names
|
||||
jQuery
|
||||
) {
|
||||
var $ = jQuery;
|
||||
@ -23,12 +23,12 @@ define(
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
$.fn.mailpoetSerializeObject = function (coerce) {
|
||||
$.fn.mailpoetSerializeObject = function (coerce) { // eslint-disable-line func-names
|
||||
var obj = {};
|
||||
var coerceTypes = { true: !0, false: !1, null: null };
|
||||
|
||||
// Iterate over all name=value pairs.
|
||||
$.each(this.serializeArray(), function (j, v) {
|
||||
$.each(this.serializeArray(), function (j, v) { // eslint-disable-line func-names
|
||||
var key = v.name;
|
||||
var val = v.value;
|
||||
var cur = obj;
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('mailpoet', [], function () {
|
||||
define('mailpoet', [], function mailpoet() {
|
||||
// A placeholder for MailPoet object
|
||||
var MailPoet = {};
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define('modal', ['mailpoet', 'jquery'],
|
||||
function (mp, jQuery) {
|
||||
'use strict';
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define('mp2migrator', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
'use strict';
|
||||
|
||||
|
@ -2,7 +2,7 @@ define([
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
'backbone.radio'
|
||||
], function (Backbone, Marionette, BackboneRadio) {
|
||||
], function (Backbone, Marionette, BackboneRadio) { // eslint-disable-line func-names
|
||||
var Radio = BackboneRadio;
|
||||
|
||||
var AppView = Marionette.View.extend({
|
||||
@ -19,12 +19,12 @@ define([
|
||||
var EditorApplication = Marionette.Application.extend({
|
||||
region: '#mailpoet_editor',
|
||||
|
||||
onStart: function () {
|
||||
onStart: function () { // eslint-disable-line func-names
|
||||
this._appView = new AppView();
|
||||
this.showView(this._appView);
|
||||
},
|
||||
|
||||
getChannel: function (channel) {
|
||||
getChannel: function (channel) { // eslint-disable-line func-names
|
||||
if (channel === undefined) {
|
||||
return Radio.channel('global');
|
||||
}
|
||||
|
@ -6,10 +6,10 @@
|
||||
*/
|
||||
define([
|
||||
'backbone.marionette'
|
||||
], function (BackboneMarionette) {
|
||||
], function (BackboneMarionette) { // eslint-disable-line func-names
|
||||
var Marionette = BackboneMarionette;
|
||||
var BehaviorsLookup = {};
|
||||
Marionette.Behaviors.behaviorsLookup = function () {
|
||||
Marionette.Behaviors.behaviorsLookup = function () { // eslint-disable-line func-names
|
||||
return BehaviorsLookup;
|
||||
};
|
||||
|
||||
|
@ -8,16 +8,16 @@ define([
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'mailpoet',
|
||||
'spectrum'
|
||||
], function (Marionette, BehaviorsLookup, MailPoet) {
|
||||
], function (Marionette, BehaviorsLookup, MailPoet) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.ColorPickerBehavior = Marionette.Behavior.extend({
|
||||
onRender: function () {
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
var that = this;
|
||||
var preferredFormat = 'hex6';
|
||||
this.view.$('.mailpoet_color').each(function () {
|
||||
this.view.$('.mailpoet_color').each(function () { // eslint-disable-line func-names
|
||||
var $input = that.view.$(this);
|
||||
var updateColorInput = function (color) {
|
||||
var updateColorInput = function (color) { // eslint-disable-line func-names
|
||||
if (color && color.getAlpha() > 0) {
|
||||
$input.val(color.toString(preferredFormat));
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* ContainerDropZoneBehavior
|
||||
*
|
||||
|
@ -10,7 +10,7 @@ define([
|
||||
'jquery',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'interact'
|
||||
], function (Marionette, _, jQuery, BehaviorsLookup, interact) {
|
||||
], function (Marionette, _, jQuery, BehaviorsLookup, interact) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.DraggableBehavior = Marionette.Behavior.extend({
|
||||
@ -24,14 +24,14 @@ define([
|
||||
*
|
||||
* @return Backbone.Model A model that will be passed to the receiver
|
||||
*/
|
||||
getDropModel: function () {
|
||||
getDropModel: function () { // eslint-disable-line func-names
|
||||
throw "Missing 'drop' function for DraggableBehavior";
|
||||
},
|
||||
|
||||
onDrop: function () {},
|
||||
testAttachToInstance: function () { return true; }
|
||||
onDrop: function () {}, // eslint-disable-line func-names
|
||||
testAttachToInstance: function () { return true; } // eslint-disable-line func-names
|
||||
},
|
||||
onRender: function () {
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
var that = this;
|
||||
var interactable;
|
||||
|
||||
@ -47,7 +47,7 @@ define([
|
||||
// Scroll when dragging near edges of a window
|
||||
autoScroll: true,
|
||||
|
||||
onstart: function (startEvent) {
|
||||
onstart: function (startEvent) { // eslint-disable-line func-names
|
||||
var event = startEvent;
|
||||
var centerXOffset;
|
||||
var centerYOffset;
|
||||
@ -86,7 +86,7 @@ define([
|
||||
}
|
||||
},
|
||||
// call this function on every dragmove event
|
||||
onmove: function (event) {
|
||||
onmove: function (event) { // eslint-disable-line func-names
|
||||
var target = event.target;
|
||||
// keep the dragged position in the data-x/data-y attributes
|
||||
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx;
|
||||
@ -100,7 +100,7 @@ define([
|
||||
target.setAttribute('data-x', x);
|
||||
target.setAttribute('data-y', y);
|
||||
},
|
||||
onend: function (event) {
|
||||
onend: function (event) { // eslint-disable-line func-names
|
||||
var target = event.target;
|
||||
target.style.transform = '';
|
||||
target.style.webkitTransform = target.style.transform;
|
||||
@ -119,7 +119,7 @@ define([
|
||||
})
|
||||
.preventDefault('auto')
|
||||
.styleCursor(false)
|
||||
.actionChecker(function (pointer, event, action) {
|
||||
.actionChecker(function (pointer, event, action) { // eslint-disable-line func-names
|
||||
// Disable dragging with right click
|
||||
if (event.button !== 0) {
|
||||
return null;
|
||||
@ -133,7 +133,7 @@ define([
|
||||
} else {
|
||||
interactable.getDropModel = this.view.getDropFunc();
|
||||
}
|
||||
interactable.onDrop = function (opts) {
|
||||
interactable.onDrop = function (opts) { // eslint-disable-line func-names
|
||||
var options = opts;
|
||||
if (_.isObject(options)) {
|
||||
// Inject Draggable behavior if possible
|
||||
|
@ -6,7 +6,7 @@
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup'
|
||||
], function (Marionette, BehaviorsLookup) {
|
||||
], function (Marionette, BehaviorsLookup) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.HighlightContainerBehavior = Marionette.Behavior.extend({
|
||||
@ -14,10 +14,10 @@ define([
|
||||
'mouseenter @ui.tools': 'enableHighlight',
|
||||
'mouseleave @ui.tools': 'disableHighlight'
|
||||
},
|
||||
enableHighlight: function () {
|
||||
enableHighlight: function () { // eslint-disable-line func-names
|
||||
this.$el.addClass('mailpoet_highlight');
|
||||
},
|
||||
disableHighlight: function () {
|
||||
disableHighlight: function () { // eslint-disable-line func-names
|
||||
if (!this.view._isBeingEdited) {
|
||||
this.$el.removeClass('mailpoet_highlight');
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup'
|
||||
], function (Marionette, BehaviorsLookup) {
|
||||
], function (Marionette, BehaviorsLookup) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.HighlightEditingBehavior = Marionette.Behavior.extend({
|
||||
@ -14,11 +14,11 @@ define([
|
||||
startEditing: 'enableHighlight',
|
||||
stopEditing: 'disableHighlight'
|
||||
},
|
||||
enableHighlight: function () {
|
||||
enableHighlight: function () { // eslint-disable-line func-names
|
||||
this.view._isBeingEdited = true;
|
||||
this.$el.addClass('mailpoet_highlight');
|
||||
},
|
||||
disableHighlight: function () {
|
||||
disableHighlight: function () { // eslint-disable-line func-names
|
||||
this.view._isBeingEdited = false;
|
||||
this.$el.removeClass('mailpoet_highlight');
|
||||
}
|
||||
|
@ -7,18 +7,18 @@ define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'interact'
|
||||
], function (Marionette, BehaviorsLookup, interact) {
|
||||
], function (Marionette, BehaviorsLookup, interact) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.ResizableBehavior = Marionette.Behavior.extend({
|
||||
defaults: {
|
||||
elementSelector: null,
|
||||
resizeHandleSelector: true, // true will use edges of the element itself
|
||||
transformationFunction: function (y) { return y; }, // for blocks that use the default onResize function
|
||||
transformationFunction: function transformationFunction(y) { return y; }, // for blocks that use the default onResize function
|
||||
minLength: 0,
|
||||
maxLength: Infinity,
|
||||
modelField: 'styles.block.height',
|
||||
onResize: function (event) {
|
||||
onResize: function (event) { // eslint-disable-line func-names
|
||||
var currentLength = parseFloat(this.view.model.get(this.options.modelField));
|
||||
var newLength = currentLength + this.options.transformationFunction(event.dy);
|
||||
newLength = Math.min(this.options.maxLength, Math.max(this.options.minLength, newLength));
|
||||
@ -29,14 +29,14 @@ define([
|
||||
mouseenter: 'showResizeHandle',
|
||||
mouseleave: 'hideResizeHandle'
|
||||
},
|
||||
onRender: function () {
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
this.attachResize();
|
||||
|
||||
if (this.isBeingResized !== true) {
|
||||
this.hideResizeHandle();
|
||||
}
|
||||
},
|
||||
attachResize: function () {
|
||||
attachResize: function () { // eslint-disable-line func-names
|
||||
var domElement = (this.options.elementSelector === null) ? this.view.$el.get(0) : this.view.$(this.options.elementSelector).get(0);
|
||||
var that = this;
|
||||
interact(domElement).resizable({
|
||||
@ -48,24 +48,24 @@ define([
|
||||
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
|
||||
}
|
||||
})
|
||||
.on('resizestart', function () {
|
||||
.on('resizestart', function () { // eslint-disable-line func-names
|
||||
that.isBeingResized = true;
|
||||
that.$el.addClass('mailpoet_resize_active');
|
||||
}).on('resizemove', function (event) {
|
||||
}).on('resizemove', function (event) { // eslint-disable-line func-names
|
||||
var onResize = that.options.onResize.bind(that);
|
||||
return onResize(event);
|
||||
})
|
||||
.on('resizeend', function () {
|
||||
.on('resizeend', function () { // eslint-disable-line func-names
|
||||
that.isBeingResized = null;
|
||||
that.$el.removeClass('mailpoet_resize_active');
|
||||
});
|
||||
},
|
||||
showResizeHandle: function () {
|
||||
showResizeHandle: function () { // eslint-disable-line func-names
|
||||
if (typeof this.options.resizeHandleSelector === 'string') {
|
||||
this.view.$(this.options.resizeHandleSelector).removeClass('mailpoet_hidden');
|
||||
}
|
||||
},
|
||||
hideResizeHandle: function () {
|
||||
hideResizeHandle: function () { // eslint-disable-line func-names
|
||||
if (typeof this.options.resizeHandleSelector === 'string') {
|
||||
this.view.$(this.options.resizeHandleSelector).addClass('mailpoet_hidden');
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
'backbone.marionette',
|
||||
'jquery',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup'
|
||||
], function (Marionette, jQuery, BehaviorsLookup) {
|
||||
], function (Marionette, jQuery, BehaviorsLookup) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.ShowSettingsBehavior = Marionette.Behavior.extend({
|
||||
@ -17,12 +17,12 @@ define([
|
||||
events: {
|
||||
'click .mailpoet_content': 'showSettings'
|
||||
},
|
||||
showSettings: function (event) {
|
||||
showSettings: function (event) { // eslint-disable-line func-names
|
||||
if (!this.isIgnoredElement(event.target)) {
|
||||
this.view.triggerMethod('showSettings');
|
||||
}
|
||||
},
|
||||
isIgnoredElement: function (element) {
|
||||
isIgnoredElement: function (element) { // eslint-disable-line func-names
|
||||
return this.options.ignoreFrom
|
||||
&& this.options.ignoreFrom.length > 0
|
||||
&& jQuery(element).is(this.options.ignoreFrom);
|
||||
|
@ -7,23 +7,23 @@ define([
|
||||
'backbone.marionette',
|
||||
'underscore',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup'
|
||||
], function (Marionette, _, BehaviorsLookup) {
|
||||
], function (Marionette, _, BehaviorsLookup) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.SortableBehavior = Marionette.Behavior.extend({
|
||||
onRender: function () {
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
var collection = this.view.collection;
|
||||
|
||||
if (_.isFunction(this.$el.sortable)) {
|
||||
this.$el.sortable({
|
||||
cursor: 'move',
|
||||
start: function (event, ui) {
|
||||
start: function (event, ui) { // eslint-disable-line func-names
|
||||
ui.item.data('previousIndex', ui.item.index());
|
||||
},
|
||||
end: function (event, ui) {
|
||||
end: function (event, ui) { // eslint-disable-line func-names
|
||||
ui.item.removeData('previousIndex');
|
||||
},
|
||||
update: function (event, ui) {
|
||||
update: function (event, ui) { // eslint-disable-line func-names
|
||||
var previousIndex = ui.item.data('previousIndex');
|
||||
var newIndex = ui.item.index();
|
||||
var model = collection.at(previousIndex);
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
'backbone.marionette',
|
||||
'underscore',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup'
|
||||
], function (Marionette, _, BehaviorsLookup) {
|
||||
], function (Marionette, _, BehaviorsLookup) { // eslint-disable-line func-names
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.TextEditorBehavior = Marionette.Behavior.extend({
|
||||
@ -19,9 +19,9 @@ define([
|
||||
invalidElements: 'script',
|
||||
blockFormats: 'Paragraph=p',
|
||||
plugins: 'link textcolor colorpicker mailpoet_shortcodes',
|
||||
configurationFilter: function (originalConfig) { return originalConfig; }
|
||||
configurationFilter: function (originalConfig) { return originalConfig; } // eslint-disable-line func-names
|
||||
},
|
||||
onDomRefresh: function () {
|
||||
onDomRefresh: function () { // eslint-disable-line func-names
|
||||
var that = this;
|
||||
if (this.view.disableTextEditor === true) {
|
||||
return;
|
||||
@ -42,7 +42,7 @@ define([
|
||||
relative_urls: false,
|
||||
remove_script_host: false,
|
||||
convert_urls: true,
|
||||
urlconverter_callback: function (url) {
|
||||
urlconverter_callback: function (url) { // eslint-disable-line func-names
|
||||
if (url.match(/\[.+\]/g)) {
|
||||
// Do not convert URLs with shortcodes
|
||||
return url;
|
||||
@ -56,12 +56,12 @@ define([
|
||||
|
||||
plugins: this.options.plugins,
|
||||
|
||||
setup: function (editor) {
|
||||
editor.on('change', function () {
|
||||
setup: function (editor) { // eslint-disable-line func-names
|
||||
editor.on('change', function () { // eslint-disable-line func-names
|
||||
that.view.triggerMethod('text:editor:change', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function (e) {
|
||||
editor.on('click', function (e) { // eslint-disable-line func-names
|
||||
editor.focus();
|
||||
if (that._isActivationClick) {
|
||||
editor.selection.setRng(
|
||||
@ -71,12 +71,12 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('focus', function () {
|
||||
editor.on('focus', function () { // eslint-disable-line func-names
|
||||
that.view.triggerMethod('text:editor:focus');
|
||||
that._isActivationClick = true;
|
||||
});
|
||||
|
||||
editor.on('blur', function () {
|
||||
editor.on('blur', function () { // eslint-disable-line func-names
|
||||
that.view.triggerMethod('text:editor:blur');
|
||||
});
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Automated latest content block.
|
||||
* Only query parameters can be modified by the user. Posts pulled by this
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Defines base classes for actual content blocks to extend.
|
||||
* Extending content block modules need to at least extend
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Button content block
|
||||
*/
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Container content block.
|
||||
* This is a special kind of block, as it can contain content blocks, as well
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Divider content block
|
||||
*/
|
||||
@ -6,14 +8,12 @@ define([
|
||||
'newsletter_editor/blocks/base',
|
||||
'underscore',
|
||||
'jquery'
|
||||
], function (App, BaseBlock, _, jQuery) {
|
||||
'use strict';
|
||||
|
||||
], function (App, BaseBlock, _, jQuery) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
var base = BaseBlock;
|
||||
|
||||
Module.DividerBlockModel = base.BlockModel.extend({
|
||||
defaults: function () {
|
||||
defaults: function () { // eslint-disable-line func-names
|
||||
return this._getDefaults({
|
||||
type: 'divider',
|
||||
styles: {
|
||||
@ -31,13 +31,13 @@ define([
|
||||
|
||||
Module.DividerBlockView = base.BlockView.extend({
|
||||
className: 'mailpoet_block mailpoet_divider_block mailpoet_droppable_block',
|
||||
getTemplate: function () { return window.templates.dividerBlock; },
|
||||
getTemplate: function () { return window.templates.dividerBlock; }, // eslint-disable-line func-names
|
||||
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
||||
behaviors: _.defaults({
|
||||
ResizableBehavior: {
|
||||
elementSelector: '.mailpoet_content',
|
||||
resizeHandleSelector: '.mailpoet_resize_handle',
|
||||
transformationFunction: function (y) { return y / 2; },
|
||||
transformationFunction: function (y) { return y / 2; }, // eslint-disable-line func-names
|
||||
minLength: 0, // TODO: Move this number to editor configuration
|
||||
modelField: 'styles.block.padding'
|
||||
},
|
||||
@ -45,32 +45,32 @@ define([
|
||||
ignoreFrom: '.mailpoet_resize_handle'
|
||||
}
|
||||
}, base.BlockView.prototype.behaviors),
|
||||
onDragSubstituteBy: function () { return Module.DividerWidgetView; },
|
||||
initialize: function () {
|
||||
onDragSubstituteBy: function () { return Module.DividerWidgetView; }, // eslint-disable-line func-names
|
||||
initialize: function () { // eslint-disable-line func-names
|
||||
var that = this;
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
|
||||
// Listen for attempts to change all dividers in one go
|
||||
this._replaceDividerHandler = function (data) { that.model.set(data); that.model.trigger('applyToAll'); };
|
||||
this._replaceDividerHandler = function (data) { that.model.set(data); that.model.trigger('applyToAll'); }; // eslint-disable-line func-names
|
||||
App.getChannel().on('replaceAllDividers', this._replaceDividerHandler);
|
||||
|
||||
this.listenTo(this.model, 'change:src change:styles.block.backgroundColor change:styles.block.borderStyle change:styles.block.borderWidth change:styles.block.borderColor applyToAll', this.render);
|
||||
this.listenTo(this.model, 'change:styles.block.padding', this.changePadding);
|
||||
},
|
||||
templateContext: function () {
|
||||
templateContext: function () { // eslint-disable-line func-names
|
||||
return _.extend({
|
||||
totalHeight: parseInt(this.model.get('styles.block.padding'), 10) * 2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px'
|
||||
}, base.BlockView.prototype.templateContext.apply(this));
|
||||
},
|
||||
onRender: function () {
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
this.toolsView = new Module.DividerBlockToolsView({ model: this.model });
|
||||
this.showChildView('toolsRegion', this.toolsView);
|
||||
},
|
||||
onBeforeDestroy: function () {
|
||||
onBeforeDestroy: function () { // eslint-disable-line func-names
|
||||
App.getChannel().off('replaceAllDividers', this._replaceDividerHandler);
|
||||
this.stopListening(this.model);
|
||||
},
|
||||
changePadding: function () {
|
||||
changePadding: function () { // eslint-disable-line func-names
|
||||
this.$('.mailpoet_content').css('padding-top', this.model.get('styles.block.padding'));
|
||||
this.$('.mailpoet_content').css('padding-bottom', this.model.get('styles.block.padding'));
|
||||
this.$('.mailpoet_resize_handle_text').text(parseInt(this.model.get('styles.block.padding'), 10) * 2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px');
|
||||
@ -78,12 +78,12 @@ define([
|
||||
});
|
||||
|
||||
Module.DividerBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function () { return Module.DividerBlockSettingsView; }
|
||||
getSettingsView: function () { return Module.DividerBlockSettingsView; } // eslint-disable-line func-names
|
||||
});
|
||||
|
||||
Module.DividerBlockSettingsView = base.BlockSettingsView.extend({
|
||||
getTemplate: function () { return window.templates.dividerBlockSettings; },
|
||||
events: function () {
|
||||
getTemplate: function () { return window.templates.dividerBlockSettings; }, // eslint-disable-line func-names
|
||||
events: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
'click .mailpoet_field_divider_style': 'changeStyle',
|
||||
|
||||
@ -97,47 +97,47 @@ define([
|
||||
'click .mailpoet_done_editing': 'close'
|
||||
};
|
||||
},
|
||||
modelEvents: function () {
|
||||
modelEvents: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
'change:styles.block.borderColor': 'repaintDividerStyleOptions'
|
||||
};
|
||||
},
|
||||
templateContext: function () {
|
||||
templateContext: function () { // eslint-disable-line func-names
|
||||
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
||||
availableStyles: App.getAvailableStyles().toJSON(),
|
||||
renderOptions: this.renderOptions
|
||||
});
|
||||
},
|
||||
changeStyle: function (event) {
|
||||
changeStyle: function (event) { // eslint-disable-line func-names
|
||||
var style = jQuery(event.currentTarget).data('style');
|
||||
this.model.set('styles.block.borderStyle', style);
|
||||
this.$('.mailpoet_field_divider_style').removeClass('mailpoet_active_divider_style');
|
||||
this.$('.mailpoet_field_divider_style[data-style="' + style + '"]').addClass('mailpoet_active_divider_style');
|
||||
},
|
||||
repaintDividerStyleOptions: function () {
|
||||
repaintDividerStyleOptions: function () { // eslint-disable-line func-names
|
||||
this.$('.mailpoet_field_divider_style > div').css('border-top-color', this.model.get('styles.block.borderColor'));
|
||||
},
|
||||
applyToAll: function () {
|
||||
applyToAll: function () { // eslint-disable-line func-names
|
||||
App.getChannel().trigger('replaceAllDividers', this.model.toJSON());
|
||||
},
|
||||
updateValueAndCall: function (fieldToUpdate, callable, event) {
|
||||
updateValueAndCall: function (fieldToUpdate, callable, event) { // eslint-disable-line func-names
|
||||
this.$(fieldToUpdate).val(jQuery(event.target).val());
|
||||
callable(event);
|
||||
}
|
||||
});
|
||||
|
||||
Module.DividerWidgetView = base.WidgetView.extend({
|
||||
getTemplate: function () { return window.templates.dividerInsertion; },
|
||||
getTemplate: function () { return window.templates.dividerInsertion; }, // eslint-disable-line func-names
|
||||
behaviors: {
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
drop: function () { // eslint-disable-line func-names
|
||||
return new Module.DividerBlockModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
App.on('before:start', function (BeforeStartApp) {
|
||||
App.on('before:start', function (BeforeStartApp) { // eslint-disable-line func-names
|
||||
BeforeStartApp.registerBlockType('divider', {
|
||||
blockModel: Module.DividerBlockModel,
|
||||
blockView: Module.DividerBlockView
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Footer content block
|
||||
*/
|
||||
@ -6,14 +8,12 @@ define([
|
||||
'newsletter_editor/blocks/base',
|
||||
'underscore',
|
||||
'mailpoet'
|
||||
], function (App, BaseBlock, _, MailPoet) {
|
||||
'use strict';
|
||||
|
||||
], function (App, BaseBlock, _, MailPoet) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
var base = BaseBlock;
|
||||
|
||||
Module.FooterBlockModel = base.BlockModel.extend({
|
||||
defaults: function () {
|
||||
defaults: function () { // eslint-disable-line func-names
|
||||
return this._getDefaults({
|
||||
type: 'footer',
|
||||
text: '<a href="[link:subscription_unsubscribe_url]">Unsubscribe</a> | <a href="[link:subscription_manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>',
|
||||
@ -38,13 +38,13 @@ define([
|
||||
|
||||
Module.FooterBlockView = base.BlockView.extend({
|
||||
className: 'mailpoet_block mailpoet_footer_block mailpoet_droppable_block',
|
||||
getTemplate: function () { return window.templates.footerBlock; },
|
||||
getTemplate: function () { return window.templates.footerBlock; }, // eslint-disable-line func-names
|
||||
modelEvents: _.extend({
|
||||
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
|
||||
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
|
||||
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
||||
TextEditorBehavior: {
|
||||
configurationFilter: function (originalSettings) {
|
||||
configurationFilter: function (originalSettings) { // eslint-disable-line func-names
|
||||
return _.extend({}, originalSettings, {
|
||||
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
||||
@ -52,37 +52,37 @@ define([
|
||||
}
|
||||
}
|
||||
}),
|
||||
onDragSubstituteBy: function () { return Module.FooterWidgetView; },
|
||||
onRender: function () {
|
||||
onDragSubstituteBy: function () { return Module.FooterWidgetView; }, // eslint-disable-line func-names
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
this.toolsView = new Module.FooterBlockToolsView({ model: this.model });
|
||||
this.showChildView('toolsRegion', this.toolsView);
|
||||
},
|
||||
onTextEditorChange: function (newContent) {
|
||||
onTextEditorChange: function (newContent) { // eslint-disable-line func-names
|
||||
this.model.set('text', newContent);
|
||||
},
|
||||
onTextEditorFocus: function () {
|
||||
onTextEditorFocus: function () { // eslint-disable-line func-names
|
||||
this.disableDragging();
|
||||
this.disableShowingTools();
|
||||
},
|
||||
onTextEditorBlur: function () {
|
||||
onTextEditorBlur: function () { // eslint-disable-line func-names
|
||||
this.enableDragging();
|
||||
this.enableShowingTools();
|
||||
}
|
||||
});
|
||||
|
||||
Module.FooterBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function () { return Module.FooterBlockSettingsView; }
|
||||
getSettingsView: function () { return Module.FooterBlockSettingsView; } // eslint-disable-line func-names
|
||||
});
|
||||
|
||||
Module.FooterBlockSettingsView = base.BlockSettingsView.extend({
|
||||
getTemplate: function () { return window.templates.footerBlockSettings; },
|
||||
events: function () {
|
||||
getTemplate: function () { return window.templates.footerBlockSettings; }, // eslint-disable-line func-names
|
||||
events: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
'change .mailpoet_field_footer_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
|
||||
'change .mailpoet_field_footer_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
|
||||
'change .mailpoet_field_footer_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
|
||||
'change #mailpoet_field_footer_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
|
||||
'change #mailpoet_field_footer_link_underline': function (event) {
|
||||
'change #mailpoet_field_footer_link_underline': function (event) { // eslint-disable-line func-names
|
||||
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
||||
},
|
||||
'change .mailpoet_field_footer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
||||
@ -90,7 +90,7 @@ define([
|
||||
'click .mailpoet_done_editing': 'close'
|
||||
};
|
||||
},
|
||||
templateContext: function () {
|
||||
templateContext: function () { // eslint-disable-line func-names
|
||||
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
||||
availableStyles: App.getAvailableStyles().toJSON()
|
||||
});
|
||||
@ -98,18 +98,18 @@ define([
|
||||
});
|
||||
|
||||
Module.FooterWidgetView = base.WidgetView.extend({
|
||||
getTemplate: function () { return window.templates.footerInsertion; },
|
||||
getTemplate: function () { return window.templates.footerInsertion; }, // eslint-disable-line func-names
|
||||
behaviors: {
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
drop: function () { // eslint-disable-line func-names
|
||||
return new Module.FooterBlockModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function (BeforeStartApp) {
|
||||
App.on('before:start', function (BeforeStartApp) { // eslint-disable-line func-names
|
||||
BeforeStartApp.registerBlockType('footer', {
|
||||
blockModel: Module.FooterBlockModel,
|
||||
blockView: Module.FooterBlockView
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Header content block
|
||||
*/
|
||||
@ -6,14 +8,12 @@ define([
|
||||
'newsletter_editor/blocks/base',
|
||||
'underscore',
|
||||
'mailpoet'
|
||||
], function (App, BaseBlock, _, MailPoet) {
|
||||
'use strict';
|
||||
|
||||
], function (App, BaseBlock, _, MailPoet) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
var base = BaseBlock;
|
||||
|
||||
Module.HeaderBlockModel = base.BlockModel.extend({
|
||||
defaults: function () {
|
||||
defaults: function () { // eslint-disable-line func-names
|
||||
return this._getDefaults({
|
||||
type: 'header',
|
||||
text: 'Display problems? <a href="[link:newsletter_view_in_browser_url]">View it in your browser</a>',
|
||||
@ -38,13 +38,13 @@ define([
|
||||
|
||||
Module.HeaderBlockView = base.BlockView.extend({
|
||||
className: 'mailpoet_block mailpoet_header_block mailpoet_droppable_block',
|
||||
getTemplate: function () { return window.templates.headerBlock; },
|
||||
getTemplate: function () { return window.templates.headerBlock; }, // eslint-disable-line func-names
|
||||
modelEvents: _.extend({
|
||||
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
|
||||
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
|
||||
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
||||
TextEditorBehavior: {
|
||||
configurationFilter: function (originalSettings) {
|
||||
configurationFilter: function (originalSettings) { // eslint-disable-line func-names
|
||||
return _.extend({}, originalSettings, {
|
||||
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
||||
@ -52,37 +52,37 @@ define([
|
||||
}
|
||||
}
|
||||
}),
|
||||
onDragSubstituteBy: function () { return Module.HeaderWidgetView; },
|
||||
onRender: function () {
|
||||
onDragSubstituteBy: function () { return Module.HeaderWidgetView; }, // eslint-disable-line func-names
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
this.toolsView = new Module.HeaderBlockToolsView({ model: this.model });
|
||||
this.showChildView('toolsRegion', this.toolsView);
|
||||
},
|
||||
onTextEditorChange: function (newContent) {
|
||||
onTextEditorChange: function (newContent) { // eslint-disable-line func-names
|
||||
this.model.set('text', newContent);
|
||||
},
|
||||
onTextEditorFocus: function () {
|
||||
onTextEditorFocus: function () { // eslint-disable-line func-names
|
||||
this.disableDragging();
|
||||
this.disableShowingTools();
|
||||
},
|
||||
onTextEditorBlur: function () {
|
||||
onTextEditorBlur: function () { // eslint-disable-line func-names
|
||||
this.enableDragging();
|
||||
this.enableShowingTools();
|
||||
}
|
||||
});
|
||||
|
||||
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function () { return Module.HeaderBlockSettingsView; }
|
||||
getSettingsView: function () { return Module.HeaderBlockSettingsView; } // eslint-disable-line func-names
|
||||
});
|
||||
|
||||
Module.HeaderBlockSettingsView = base.BlockSettingsView.extend({
|
||||
getTemplate: function () { return window.templates.headerBlockSettings; },
|
||||
events: function () {
|
||||
getTemplate: function () { return window.templates.headerBlockSettings; }, // eslint-disable-line func-names
|
||||
events: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
'change .mailpoet_field_header_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
|
||||
'change .mailpoet_field_header_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
|
||||
'change .mailpoet_field_header_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
|
||||
'change #mailpoet_field_header_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
|
||||
'change #mailpoet_field_header_link_underline': function (event) {
|
||||
'change #mailpoet_field_header_link_underline': function (event) { // eslint-disable-line func-names
|
||||
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
||||
},
|
||||
'change .mailpoet_field_header_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
||||
@ -90,7 +90,7 @@ define([
|
||||
'click .mailpoet_done_editing': 'close'
|
||||
};
|
||||
},
|
||||
templateContext: function () {
|
||||
templateContext: function () { // eslint-disable-line func-names
|
||||
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
||||
availableStyles: App.getAvailableStyles().toJSON()
|
||||
});
|
||||
@ -98,18 +98,18 @@ define([
|
||||
});
|
||||
|
||||
Module.HeaderWidgetView = base.WidgetView.extend({
|
||||
getTemplate: function () { return window.templates.headerInsertion; },
|
||||
getTemplate: function () { return window.templates.headerInsertion; }, // eslint-disable-line func-names
|
||||
behaviors: {
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
drop: function () { // eslint-disable-line func-names
|
||||
return new Module.HeaderBlockModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function (BeforeStartApp) {
|
||||
App.on('before:start', function (BeforeStartApp) { // eslint-disable-line func-names
|
||||
BeforeStartApp.registerBlockType('header', {
|
||||
blockModel: Module.HeaderBlockModel,
|
||||
blockView: Module.HeaderBlockView
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Image content block
|
||||
*/
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Posts block.
|
||||
*
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
/**
|
||||
* Social icons content block
|
||||
*/
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Spacer content block
|
||||
*/
|
||||
@ -5,14 +7,12 @@ define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/base',
|
||||
'underscore'
|
||||
], function (App, BaseBlock, _) {
|
||||
'use strict';
|
||||
|
||||
], function (App, BaseBlock, _) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
var base = BaseBlock;
|
||||
|
||||
Module.SpacerBlockModel = base.BlockModel.extend({
|
||||
defaults: function () {
|
||||
defaults: function () { // eslint-disable-line func-names
|
||||
return this._getDefaults({
|
||||
type: 'spacer',
|
||||
styles: {
|
||||
@ -27,7 +27,7 @@ define([
|
||||
|
||||
Module.SpacerBlockView = base.BlockView.extend({
|
||||
className: 'mailpoet_block mailpoet_spacer_block mailpoet_droppable_block',
|
||||
getTemplate: function () { return window.templates.spacerBlock; },
|
||||
getTemplate: function () { return window.templates.spacerBlock; }, // eslint-disable-line func-names
|
||||
behaviors: _.defaults({
|
||||
ResizableBehavior: {
|
||||
elementSelector: '.mailpoet_spacer',
|
||||
@ -40,33 +40,33 @@ define([
|
||||
}
|
||||
}, base.BlockView.prototype.behaviors),
|
||||
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
||||
onDragSubstituteBy: function () { return Module.SpacerWidgetView; },
|
||||
initialize: function () {
|
||||
onDragSubstituteBy: function () { return Module.SpacerWidgetView; }, // eslint-disable-line func-names
|
||||
initialize: function () { // eslint-disable-line func-names
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
|
||||
this.listenTo(this.model, 'change:styles.block.backgroundColor', this.render);
|
||||
this.listenTo(this.model, 'change:styles.block.height', this.changeHeight);
|
||||
},
|
||||
onRender: function () {
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
this.toolsView = new Module.SpacerBlockToolsView({ model: this.model });
|
||||
this.showChildView('toolsRegion', this.toolsView);
|
||||
},
|
||||
changeHeight: function () {
|
||||
changeHeight: function () { // eslint-disable-line func-names
|
||||
this.$('.mailpoet_spacer').css('height', this.model.get('styles.block.height'));
|
||||
this.$('.mailpoet_resize_handle_text').text(this.model.get('styles.block.height'));
|
||||
},
|
||||
onBeforeDestroy: function () {
|
||||
onBeforeDestroy: function () { // eslint-disable-line func-names
|
||||
this.stopListening(this.model);
|
||||
}
|
||||
});
|
||||
|
||||
Module.SpacerBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function () { return Module.SpacerBlockSettingsView; }
|
||||
getSettingsView: function () { return Module.SpacerBlockSettingsView; } // eslint-disable-line func-names
|
||||
});
|
||||
|
||||
Module.SpacerBlockSettingsView = base.BlockSettingsView.extend({
|
||||
getTemplate: function () { return window.templates.spacerBlockSettings; },
|
||||
events: function () {
|
||||
getTemplate: function () { return window.templates.spacerBlockSettings; }, // eslint-disable-line func-names
|
||||
events: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
'change .mailpoet_field_spacer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
||||
'click .mailpoet_done_editing': 'close'
|
||||
@ -75,18 +75,18 @@ define([
|
||||
});
|
||||
|
||||
Module.SpacerWidgetView = base.WidgetView.extend({
|
||||
getTemplate: function () { return window.templates.spacerInsertion; },
|
||||
getTemplate: function () { return window.templates.spacerInsertion; }, // eslint-disable-line func-names
|
||||
behaviors: {
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
drop: function () { // eslint-disable-line func-names
|
||||
return new Module.SpacerBlockModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function (BeforeStartApp) {
|
||||
App.on('before:start', function (BeforeStartApp) { // eslint-disable-line func-names
|
||||
BeforeStartApp.registerBlockType('spacer', {
|
||||
blockModel: Module.SpacerBlockModel,
|
||||
blockView: Module.SpacerBlockView
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Text content block
|
||||
*/
|
||||
@ -6,14 +8,12 @@ define([
|
||||
'newsletter_editor/blocks/base',
|
||||
'underscore',
|
||||
'mailpoet'
|
||||
], function (App, BaseBlock, _, MailPoet) {
|
||||
'use strict';
|
||||
|
||||
], function (App, BaseBlock, _, MailPoet) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
var base = BaseBlock;
|
||||
|
||||
Module.TextBlockModel = base.BlockModel.extend({
|
||||
defaults: function () {
|
||||
defaults: function () { // eslint-disable-line func-names
|
||||
return this._getDefaults({
|
||||
type: 'text',
|
||||
text: 'Edit this to insert text'
|
||||
@ -23,7 +23,7 @@ define([
|
||||
|
||||
Module.TextBlockView = base.BlockView.extend({
|
||||
className: 'mailpoet_block mailpoet_text_block mailpoet_droppable_block',
|
||||
getTemplate: function () { return window.templates.textBlock; },
|
||||
getTemplate: function () { return window.templates.textBlock; }, // eslint-disable-line func-names
|
||||
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), // Prevent rerendering on model change due to text editor redrawing
|
||||
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
||||
TextEditorBehavior: {
|
||||
@ -33,7 +33,7 @@ define([
|
||||
invalidElements: 'script',
|
||||
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
|
||||
plugins: 'link lists code textcolor colorpicker mailpoet_shortcodes paste',
|
||||
configurationFilter: function (originalSettings) {
|
||||
configurationFilter: function (originalSettings) { // eslint-disable-line func-names
|
||||
return _.extend({}, originalSettings, {
|
||||
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
||||
@ -41,7 +41,7 @@ define([
|
||||
}
|
||||
}
|
||||
}),
|
||||
initialize: function (options) {
|
||||
initialize: function (options) { // eslint-disable-line func-names
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
|
||||
this.renderOptions = _.defaults(options.renderOptions || {}, {
|
||||
@ -50,8 +50,8 @@ define([
|
||||
|
||||
this.disableTextEditor = this.renderOptions.disableTextEditor;
|
||||
},
|
||||
onDragSubstituteBy: function () { return Module.TextWidgetView; },
|
||||
onRender: function () {
|
||||
onDragSubstituteBy: function () { return Module.TextWidgetView; }, // eslint-disable-line func-names
|
||||
onRender: function () { // eslint-disable-line func-names
|
||||
this.toolsView = new Module.TextBlockToolsView({
|
||||
model: this.model,
|
||||
tools: {
|
||||
@ -60,40 +60,40 @@ define([
|
||||
});
|
||||
this.showChildView('toolsRegion', this.toolsView);
|
||||
},
|
||||
onTextEditorChange: function (newContent) {
|
||||
onTextEditorChange: function (newContent) { // eslint-disable-line func-names
|
||||
this.model.set('text', newContent);
|
||||
},
|
||||
onTextEditorFocus: function () {
|
||||
onTextEditorFocus: function () { // eslint-disable-line func-names
|
||||
this.disableDragging();
|
||||
this.disableShowingTools();
|
||||
},
|
||||
onTextEditorBlur: function () {
|
||||
onTextEditorBlur: function () { // eslint-disable-line func-names
|
||||
this.enableDragging();
|
||||
this.enableShowingTools();
|
||||
}
|
||||
});
|
||||
|
||||
Module.TextBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function () { return Module.TextBlockSettingsView; }
|
||||
getSettingsView: function () { return Module.TextBlockSettingsView; } // eslint-disable-line func-names
|
||||
});
|
||||
|
||||
Module.TextBlockSettingsView = base.BlockSettingsView.extend({
|
||||
getTemplate: function () { return window.templates.textBlockSettings; }
|
||||
getTemplate: function () { return window.templates.textBlockSettings; } // eslint-disable-line func-names
|
||||
});
|
||||
|
||||
Module.TextWidgetView = base.WidgetView.extend({
|
||||
getTemplate: function () { return window.templates.textInsertion; },
|
||||
getTemplate: function () { return window.templates.textInsertion; }, // eslint-disable-line func-names
|
||||
behaviors: {
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
drop: function () { // eslint-disable-line func-names
|
||||
return new Module.TextBlockModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function (BeforeStartApp) {
|
||||
App.on('before:start', function (BeforeStartApp) { // eslint-disable-line func-names
|
||||
BeforeStartApp.registerBlockType('text', {
|
||||
blockModel: Module.TextBlockModel,
|
||||
blockView: Module.TextBlockView
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* This shim replaces the default Backbone.Marionette communication library
|
||||
* Backbone.Wreqr with Backbone.Radio ahead of time,
|
||||
@ -6,12 +8,12 @@
|
||||
* Courtesy of https://gist.github.com/jmeas/7992474cdb1c5672d88b
|
||||
*/
|
||||
|
||||
(function (root, factory) {
|
||||
(function (root, factory) { // eslint-disable-line func-names
|
||||
var Marionette = require('backbone.marionette');
|
||||
var Radio = require('backbone.radio');
|
||||
var _ = require('underscore');
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['backbone.marionette', 'backbone.radio', 'underscore'], function (BackboneMarionette, BackboneRadio, underscore) {
|
||||
define(['backbone.marionette', 'backbone.radio', 'underscore'], function (BackboneMarionette, BackboneRadio, underscore) { // eslint-disable-line func-names
|
||||
return factory(BackboneMarionette, BackboneRadio, underscore);
|
||||
});
|
||||
}
|
||||
@ -21,11 +23,9 @@
|
||||
else {
|
||||
factory(root.Backbone.Marionette, root.Backbone.Radio, root._);
|
||||
}
|
||||
}(this, function (Marionette, Radio, _) {
|
||||
'use strict';
|
||||
|
||||
}(this, function (Marionette, Radio, _) { // eslint-disable-line func-names
|
||||
var MarionetteApplication = Marionette.Application;
|
||||
MarionetteApplication.prototype._initChannel = function () {
|
||||
MarionetteApplication.prototype._initChannel = function () { // eslint-disable-line func-names
|
||||
this.channelName = _.result(this, 'channelName') || 'global';
|
||||
this.channel = _.result(this, 'channel') || Radio.channel(this.channelName);
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'underscore',
|
||||
|
@ -1,7 +1,7 @@
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone.supermodel'
|
||||
], function (App, SuperModel) {
|
||||
], function (App, SuperModel) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
|
||||
Module.ConfigModel = SuperModel.extend({
|
||||
@ -17,13 +17,13 @@ define([
|
||||
|
||||
// Global and available styles for access in blocks and their settings
|
||||
Module._config = {};
|
||||
Module.getConfig = function () { return Module._config; };
|
||||
Module.setConfig = function (options) {
|
||||
Module.getConfig = function () { return Module._config; }; // eslint-disable-line func-names
|
||||
Module.setConfig = function (options) { // eslint-disable-line func-names
|
||||
Module._config = new Module.ConfigModel(options, { parse: true });
|
||||
return Module._config;
|
||||
};
|
||||
|
||||
App.on('before:start', function (BeforeStartApp, options) {
|
||||
App.on('before:start', function (BeforeStartApp, options) { // eslint-disable-line func-names
|
||||
var Application = BeforeStartApp;
|
||||
// Expose config methods globally
|
||||
Application.getConfig = Module.getConfig;
|
||||
|
@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone.supermodel',
|
||||
'underscore',
|
||||
'mailpoet'
|
||||
], function (App, SuperModel, _, MailPoet) {
|
||||
'use strict';
|
||||
|
||||
], function (App, SuperModel, _, MailPoet) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
|
||||
// Holds newsletter entry fields, such as subject or creation datetime.
|
||||
@ -13,12 +13,12 @@ define([
|
||||
// handled by other components.
|
||||
Module.NewsletterModel = SuperModel.extend({
|
||||
whitelisted: ['id', 'subject', 'preheader'],
|
||||
initialize: function () {
|
||||
this.on('change', function () {
|
||||
initialize: function () { // eslint-disable-line func-names
|
||||
this.on('change', function () { // eslint-disable-line func-names
|
||||
App.getChannel().trigger('autoSave');
|
||||
});
|
||||
},
|
||||
toJSON: function () {
|
||||
toJSON: function () { // eslint-disable-line func-names
|
||||
// Use only whitelisted properties to ensure properties editor
|
||||
// doesn't control don't change.
|
||||
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
|
||||
@ -27,45 +27,45 @@ define([
|
||||
|
||||
// Content block view and model handlers for different content types
|
||||
Module._blockTypes = {};
|
||||
Module.registerBlockType = function (type, data) {
|
||||
Module.registerBlockType = function (type, data) { // eslint-disable-line func-names
|
||||
Module._blockTypes[type] = data;
|
||||
};
|
||||
Module.getBlockTypeModel = function (type) {
|
||||
Module.getBlockTypeModel = function (type) { // eslint-disable-line func-names
|
||||
if (type in Module._blockTypes) {
|
||||
return Module._blockTypes[type].blockModel;
|
||||
}
|
||||
throw 'Block type not supported: ' + type;
|
||||
};
|
||||
Module.getBlockTypeView = function (type) {
|
||||
Module.getBlockTypeView = function (type) { // eslint-disable-line func-names
|
||||
if (type in Module._blockTypes) {
|
||||
return Module._blockTypes[type].blockView;
|
||||
}
|
||||
throw 'Block type not supported: ' + type;
|
||||
};
|
||||
|
||||
Module.getBody = function () {
|
||||
Module.getBody = function () { // eslint-disable-line func-names
|
||||
return {
|
||||
content: App._contentContainer.toJSON(),
|
||||
globalStyles: App.getGlobalStyles().toJSON()
|
||||
};
|
||||
};
|
||||
|
||||
Module.toJSON = function () {
|
||||
Module.toJSON = function () { // eslint-disable-line func-names
|
||||
return _.extend({
|
||||
body: Module.getBody()
|
||||
}, App.getNewsletter().toJSON());
|
||||
};
|
||||
|
||||
Module.getNewsletter = function () {
|
||||
Module.getNewsletter = function () { // eslint-disable-line func-names
|
||||
return Module.newsletter;
|
||||
};
|
||||
|
||||
Module.findModels = function (predicate) {
|
||||
Module.findModels = function (predicate) { // eslint-disable-line func-names
|
||||
var blocks = App._contentContainer.getChildren();
|
||||
return _.filter(blocks, predicate);
|
||||
};
|
||||
|
||||
App.on('before:start', function (Application, options) {
|
||||
App.on('before:start', function (Application, options) { // eslint-disable-line func-names
|
||||
var BeforeStartApp = Application;
|
||||
// Expose block methods globally
|
||||
BeforeStartApp.registerBlockType = Module.registerBlockType;
|
||||
@ -79,7 +79,7 @@ define([
|
||||
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
|
||||
});
|
||||
|
||||
App.on('start', function (Application, options) {
|
||||
App.on('start', function (Application, options) { // eslint-disable-line func-names
|
||||
var StartApp = Application;
|
||||
var body = options.newsletter.body;
|
||||
var content = (_.has(body, 'content')) ? body.content : {};
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
@ -5,30 +7,28 @@ define([
|
||||
'underscore',
|
||||
'jquery',
|
||||
'mailpoet'
|
||||
], function (App, Backbone, Marionette, _, jQuery, MailPoet) {
|
||||
'use strict';
|
||||
|
||||
], function (App, Backbone, Marionette, _, jQuery, MailPoet) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
|
||||
Module.HeadingView = Marionette.View.extend({
|
||||
getTemplate: function () { return window.templates.heading; },
|
||||
templateContext: function () {
|
||||
getTemplate: function () { return window.templates.heading; }, // eslint-disable-line func-names
|
||||
templateContext: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
model: this.model.toJSON()
|
||||
};
|
||||
},
|
||||
events: function () {
|
||||
events: function () { // eslint-disable-line func-names
|
||||
return {
|
||||
'keyup .mailpoet_input_title': _.partial(this.changeField, 'subject'),
|
||||
'keyup .mailpoet_input_preheader': _.partial(this.changeField, 'preheader')
|
||||
};
|
||||
},
|
||||
changeField: function (field, event) {
|
||||
changeField: function (field, event) { // eslint-disable-line func-names
|
||||
this.model.set(field, jQuery(event.target).val());
|
||||
}
|
||||
});
|
||||
|
||||
App.on('start', function (StartApp) {
|
||||
App.on('start', function (StartApp) { // eslint-disable-line func-names
|
||||
StartApp._appView.showChildView('headingRegion', new Module.HeadingView({ model: StartApp.getNewsletter() }));
|
||||
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
|
||||
tooltipId: 'tooltip-designer-subject-line-ti',
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/communication',
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/communication',
|
||||
|
@ -1,11 +1,12 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone.marionette',
|
||||
'backbone.supermodel',
|
||||
'underscore'
|
||||
], function (App, Marionette, SuperModel, _) {
|
||||
'use strict';
|
||||
|
||||
], function (App, Marionette, SuperModel, _) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
|
||||
Module.StylesModel = SuperModel.extend({
|
||||
@ -41,34 +42,34 @@ define([
|
||||
backgroundColor: '#cccccc'
|
||||
}
|
||||
},
|
||||
initialize: function () {
|
||||
this.on('change', function () { App.getChannel().trigger('autoSave'); });
|
||||
initialize: function () { // eslint-disable-line func-names
|
||||
this.on('change', function () { App.getChannel().trigger('autoSave'); }); // eslint-disable-line func-names
|
||||
}
|
||||
});
|
||||
|
||||
Module.StylesView = Marionette.View.extend({
|
||||
getTemplate: function () { return window.templates.styles; },
|
||||
getTemplate: function () { return window.templates.styles; }, // eslint-disable-line func-names
|
||||
modelEvents: {
|
||||
change: 'render'
|
||||
},
|
||||
serializeData: function () {
|
||||
serializeData: function () { // eslint-disable-line func-names
|
||||
return this.model.toJSON();
|
||||
}
|
||||
});
|
||||
|
||||
Module._globalStyles = new SuperModel();
|
||||
Module.getGlobalStyles = function () {
|
||||
Module.getGlobalStyles = function () { // eslint-disable-line func-names
|
||||
return Module._globalStyles;
|
||||
};
|
||||
Module.setGlobalStyles = function (options) {
|
||||
Module.setGlobalStyles = function (options) { // eslint-disable-line func-names
|
||||
Module._globalStyles = new Module.StylesModel(options);
|
||||
return Module._globalStyles;
|
||||
};
|
||||
Module.getAvailableStyles = function () {
|
||||
Module.getAvailableStyles = function () { // eslint-disable-line func-names
|
||||
return App.getConfig().get('availableStyles');
|
||||
};
|
||||
|
||||
App.on('before:start', function (BeforeStartApp, options) {
|
||||
App.on('before:start', function (BeforeStartApp, options) { // eslint-disable-line func-names
|
||||
var Application = BeforeStartApp;
|
||||
var body;
|
||||
var globalStyles;
|
||||
@ -82,7 +83,7 @@ define([
|
||||
this.setGlobalStyles(globalStyles);
|
||||
});
|
||||
|
||||
App.on('start', function (StartApp) {
|
||||
App.on('start', function (StartApp) { // eslint-disable-line func-names
|
||||
var stylesView = new Module.StylesView({ model: StartApp.getGlobalStyles() });
|
||||
StartApp._appView.showChildView('stylesRegion', stylesView);
|
||||
});
|
||||
|
@ -10,20 +10,20 @@
|
||||
|
||||
/* jshint unused:false */
|
||||
/* global tinymce:true */
|
||||
tinymce.PluginManager.add('mailpoet_shortcodes', function (editor) {
|
||||
var appendLabelAndClose = function (shortcode) {
|
||||
tinymce.PluginManager.add('mailpoet_shortcodes', function (editor) { // eslint-disable-line func-names
|
||||
var appendLabelAndClose = function (shortcode) { // eslint-disable-line func-names
|
||||
editor.insertContent(shortcode);
|
||||
editor.windowManager.close();
|
||||
};
|
||||
var generateOnClickFunc = function (shortcode) {
|
||||
return function () {
|
||||
var generateOnClickFunc = function (shortcode) { // eslint-disable-line func-names
|
||||
return function () { // eslint-disable-line func-names
|
||||
appendLabelAndClose(shortcode);
|
||||
};
|
||||
};
|
||||
|
||||
editor.addButton('mailpoet_shortcodes', {
|
||||
icon: 'mailpoet_shortcodes',
|
||||
onclick: function () {
|
||||
onclick: function () { // eslint-disable-line func-names
|
||||
var shortcodes = [];
|
||||
var configShortcodes = editor.settings.mailpoet_shortcodes;
|
||||
var segment;
|
||||
|
@ -1,6 +1,6 @@
|
||||
define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) { // eslint-disable-line func-names
|
||||
/*= =================================================================================================
|
||||
|
||||
MailPoet Notice:
|
||||
@ -40,13 +40,13 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
onClose: null
|
||||
},
|
||||
options: {},
|
||||
init: function (options) {
|
||||
init: function init(options) {
|
||||
// set options
|
||||
this.options = jQuery.extend({}, this.defaults, options);
|
||||
|
||||
return this;
|
||||
},
|
||||
createNotice: function () {
|
||||
createNotice: function createNotice() {
|
||||
var onClose;
|
||||
var positionAfter;
|
||||
// clone element
|
||||
@ -80,8 +80,8 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
}
|
||||
|
||||
// listen to remove event
|
||||
jQuery(this.element).on('close', function () {
|
||||
jQuery(this).fadeOut(200, function () {
|
||||
jQuery(this.element).on('close', function () { // eslint-disable-line func-names
|
||||
jQuery(this).fadeOut(200, function () { // eslint-disable-line func-names
|
||||
// on close callback
|
||||
if (onClose !== null) {
|
||||
onClose();
|
||||
@ -92,19 +92,19 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
}.bind(this.element));
|
||||
|
||||
// listen to message event
|
||||
jQuery(this.element).on('setMessage', function (e, message) {
|
||||
jQuery(this.element).on('setMessage', function (e, message) { // eslint-disable-line func-names
|
||||
MailPoet.Notice.setMessage(message);
|
||||
}.bind(this.element));
|
||||
|
||||
return this;
|
||||
},
|
||||
updateNotice: function () {
|
||||
updateNotice: function updateNotice() {
|
||||
// update notice's message
|
||||
jQuery('[data-id="' + this.options.id + '"').first().trigger(
|
||||
'setMessage', this.options.message
|
||||
);
|
||||
},
|
||||
setMessage: function (message) {
|
||||
setMessage: function setMessage(message) {
|
||||
var formattedMessage = this.formatMessage(message);
|
||||
|
||||
// let's sugar coat the message with a fancy <p>
|
||||
@ -112,13 +112,13 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
// set message
|
||||
return this.element.html(formattedMessage);
|
||||
},
|
||||
formatMessage: function (message) {
|
||||
formatMessage: function formatMessage(message) {
|
||||
if (Array.isArray(message)) {
|
||||
return message.join('<br />');
|
||||
}
|
||||
return message;
|
||||
},
|
||||
show: function (options) {
|
||||
show: function show(options) {
|
||||
// initialize
|
||||
this.init(options);
|
||||
|
||||
@ -133,7 +133,7 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
}
|
||||
this.showNotice();
|
||||
},
|
||||
showNotice: function () {
|
||||
showNotice: function showNotice() {
|
||||
// set message
|
||||
this.setMessage(this.options.message);
|
||||
|
||||
@ -166,7 +166,7 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
this.element.delay(this.options.timeout).trigger('close');
|
||||
} else if (this.options.hideClose === false) {
|
||||
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
|
||||
this.element.find('.mailpoet_notice_close').on('click', function () {
|
||||
this.element.find('.mailpoet_notice_close').on('click', function () { // eslint-disable-line func-names
|
||||
jQuery(this).trigger('close');
|
||||
});
|
||||
}
|
||||
@ -176,7 +176,7 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
this.options.onOpen(this.element);
|
||||
}
|
||||
},
|
||||
hide: function (all) {
|
||||
hide: function hide(all) {
|
||||
var id;
|
||||
if (all !== undefined && all === true) {
|
||||
// all notices
|
||||
@ -194,19 +194,19 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
.trigger('close');
|
||||
}
|
||||
},
|
||||
error: function (message, options) {
|
||||
error: function error(message, options) {
|
||||
this.show(jQuery.extend({}, {
|
||||
type: 'error',
|
||||
message: message
|
||||
}, options));
|
||||
},
|
||||
success: function (message, options) {
|
||||
success: function success(message, options) {
|
||||
this.show(jQuery.extend({}, {
|
||||
type: 'success',
|
||||
message: message
|
||||
}, options));
|
||||
},
|
||||
system: function (message, options) {
|
||||
system: function system(message, options) {
|
||||
this.show(jQuery.extend({}, {
|
||||
type: 'system',
|
||||
static: true,
|
||||
|
@ -1,14 +1,14 @@
|
||||
define('num',
|
||||
[
|
||||
'mailpoet'
|
||||
], function (
|
||||
], function ( // eslint-disable-line func-names
|
||||
mp
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var MailPoet = mp;
|
||||
MailPoet.Num = {
|
||||
toLocaleFixed: function (num, precisionOpts) {
|
||||
toLocaleFixed: function (num, precisionOpts) { // eslint-disable-line func-names
|
||||
var precision = precisionOpts || 0;
|
||||
var factor = Math.pow(10, precision);
|
||||
return (Math.round(num * factor) / factor)
|
||||
|
@ -3,23 +3,23 @@ define([
|
||||
'jquery',
|
||||
'parsleyjs'
|
||||
],
|
||||
function (
|
||||
function ( // eslint-disable-line func-names
|
||||
MailPoet,
|
||||
jQuery
|
||||
) {
|
||||
jQuery(function ($) {
|
||||
jQuery(function ($) { // eslint-disable-line func-names
|
||||
function isSameDomain(url) {
|
||||
var link = document.createElement('a');
|
||||
link.href = url;
|
||||
return (window.location.hostname === link.hostname);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$(function () { // eslint-disable-line func-names
|
||||
// setup form validation
|
||||
$('form.mailpoet_form').each(function () {
|
||||
$('form.mailpoet_form').each(function () { // eslint-disable-line func-names
|
||||
var form = $(this);
|
||||
|
||||
form.parsley().on('form:validated', function () {
|
||||
form.parsley().on('form:validated', function () { // eslint-disable-line func-names
|
||||
// clear messages
|
||||
form.find('.mailpoet_message > p').hide();
|
||||
|
||||
@ -29,7 +29,7 @@ function (
|
||||
}
|
||||
});
|
||||
|
||||
form.parsley().on('form:submit', function (parsley) {
|
||||
form.parsley().on('form:submit', function (parsley) { // eslint-disable-line func-names
|
||||
var formData = form.mailpoetSerializeObject() || {};
|
||||
// check if we're on the same domain
|
||||
if (isSameDomain(window.MailPoetForm.ajax_url) === false) {
|
||||
@ -44,13 +44,13 @@ function (
|
||||
endpoint: 'subscribers',
|
||||
action: 'subscribe',
|
||||
data: formData.data
|
||||
}).fail(function (response) {
|
||||
}).fail(function (response) { // eslint-disable-line func-names
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.map(function (error) {
|
||||
response.errors.map(function (error) { // eslint-disable-line func-names
|
||||
return error.message;
|
||||
}).join('<br />')
|
||||
).show();
|
||||
}).done(function (response) {
|
||||
}).done(function (response) { // eslint-disable-line func-names
|
||||
// successfully subscribed
|
||||
if (
|
||||
response.meta !== undefined
|
||||
|
@ -2,7 +2,7 @@ define(
|
||||
[
|
||||
'mailpoet'
|
||||
],
|
||||
function (
|
||||
function ( // eslint-disable-line func-names
|
||||
MailPoet
|
||||
) {
|
||||
var element;
|
||||
@ -18,14 +18,14 @@ define(
|
||||
api_version: window.mailpoet_api_version,
|
||||
endpoint: 'setup',
|
||||
action: 'reset'
|
||||
}).always(function () {
|
||||
}).always(function () { // eslint-disable-line func-names
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function () {
|
||||
}).done(function () { // eslint-disable-line func-names
|
||||
window.location = 'admin.php?page=mailpoet-newsletters';
|
||||
}).fail(function (response) {
|
||||
}).fail(function (response) { // eslint-disable-line func-names
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function (error) {
|
||||
response.errors.map(function (error) { // eslint-disable-line func-names
|
||||
return error.message;
|
||||
}),
|
||||
{ scroll: true }
|
||||
|
@ -4,7 +4,7 @@ define(
|
||||
'jquery',
|
||||
'mailpoet'
|
||||
],
|
||||
function (
|
||||
function ( // eslint-disable-line func-names
|
||||
Backbone,
|
||||
jQuery,
|
||||
mp
|
||||
@ -20,7 +20,7 @@ define(
|
||||
'mta(/:group)': 'sendingMethodGroup',
|
||||
'(:tab)': 'tabs'
|
||||
},
|
||||
sendingMethodGroup: function (group) {
|
||||
sendingMethodGroup: function (group) { // eslint-disable-line func-names
|
||||
// display mta tab
|
||||
this.tabs('mta');
|
||||
|
||||
@ -51,7 +51,7 @@ define(
|
||||
jQuery('#mailpoet_sending_method_setup').fadeIn();
|
||||
}
|
||||
},
|
||||
tabs: function (tabStr) {
|
||||
tabs: function (tabStr) { // eslint-disable-line func-names
|
||||
// set default tab
|
||||
var tab = tabStr || 'mta';
|
||||
|
||||
@ -82,7 +82,7 @@ define(
|
||||
}
|
||||
}))();
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
jQuery(document).ready(function () { // eslint-disable-line func-names
|
||||
if (!Backbone.History.started) Backbone.history.start();
|
||||
});
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ define(
|
||||
'mailpoet',
|
||||
'handlebars'
|
||||
],
|
||||
function (
|
||||
function (// eslint-disable-line func-names
|
||||
_,
|
||||
jQuery,
|
||||
MailPoet,
|
||||
@ -14,7 +14,7 @@ define(
|
||||
if (!jQuery('#mailpoet_subscribers_export').length) {
|
||||
return;
|
||||
}
|
||||
jQuery(document).ready(function () {
|
||||
jQuery(document).ready(function () { // eslint-disable-line func-names
|
||||
var segmentsContainerElement;
|
||||
var subscriberFieldsContainerElement;
|
||||
var exportConfirmedOptionElement;
|
||||
@ -47,7 +47,7 @@ define(
|
||||
exportConfirmedOptionElement = jQuery(':radio[name="option_confirmed"]');
|
||||
groupBySegmentOptionElement = jQuery(':checkbox[name="option_group_by_list"]');
|
||||
nextStepButton = jQuery('a.mailpoet_export_process');
|
||||
renderSegmentsAndFields = function (container, data) {
|
||||
renderSegmentsAndFields = function (container, data) { // eslint-disable-line func-names
|
||||
if (container.data('select2')) {
|
||||
container
|
||||
.html('')
|
||||
@ -57,18 +57,18 @@ define(
|
||||
.select2({
|
||||
data: data,
|
||||
width: '20em',
|
||||
templateResult: function (item) {
|
||||
templateResult: function (item) { // eslint-disable-line func-names
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + parseInt(item.subscriberCount).toLocaleString() + ')'
|
||||
: item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
templateSelection: function (item) { // eslint-disable-line func-names
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + parseInt(item.subscriberCount).toLocaleString() + ')'
|
||||
: item.name;
|
||||
}
|
||||
})
|
||||
.on('select2:selecting', function (selectEvent) {
|
||||
.on('select2:selecting', function (selectEvent) { // eslint-disable-line func-names
|
||||
var selectElement = this;
|
||||
var selectedOptionId = selectEvent.params.args.data.id;
|
||||
var fieldsToExclude = [
|
||||
@ -82,7 +82,7 @@ define(
|
||||
jQuery(selectElement).val('').trigger('change');
|
||||
} else {
|
||||
allOptions = [];
|
||||
_.each(container.find('option'), function (field) {
|
||||
_.each(container.find('option'), function (field) { // eslint-disable-line func-names
|
||||
if (!_.contains(fieldsToExclude, field.value)) {
|
||||
allOptions.push(field.value);
|
||||
}
|
||||
@ -92,7 +92,7 @@ define(
|
||||
jQuery(selectElement).select2('close');
|
||||
}
|
||||
})
|
||||
.on('change', function () {
|
||||
.on('change', function () { // eslint-disable-line func-names
|
||||
if ((window.exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
|
||||
||
|
||||
(!window.exportData.segments && subscriberFieldsContainerElement.select2('data').length)
|
||||
@ -125,7 +125,7 @@ define(
|
||||
'status'
|
||||
]).trigger('change');
|
||||
|
||||
exportConfirmedOptionElement.change(function () {
|
||||
exportConfirmedOptionElement.change(function () { // eslint-disable-line func-names
|
||||
var selectedSegments = segmentsContainerElement.val();
|
||||
if (this.value == 1) {
|
||||
window.exportData.exportConfirmedOption = true;
|
||||
@ -138,7 +138,7 @@ define(
|
||||
segmentsContainerElement.val(selectedSegments).trigger('change');
|
||||
});
|
||||
|
||||
nextStepButton.click(function () {
|
||||
nextStepButton.click(function () { // eslint-disable-line func-names
|
||||
var exportFormat;
|
||||
if (jQuery(this).hasClass('button-disabled')) {
|
||||
return;
|
||||
@ -156,9 +156,9 @@ define(
|
||||
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
|
||||
subscriber_fields: subscriberFieldsContainerElement.val()
|
||||
})
|
||||
}).always(function () {
|
||||
}).always(function () { // eslint-disable-line func-names
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function (response) {
|
||||
}).done(function (response) { // eslint-disable-line func-names
|
||||
var resultMessage = MailPoet.I18n.t('exportMessage')
|
||||
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
||||
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
||||
@ -171,10 +171,10 @@ define(
|
||||
'File Format': exportFormat,
|
||||
'MailPoet Free version': window.mailpoet_version
|
||||
});
|
||||
}).fail(function (response) {
|
||||
}).fail(function (response) { // eslint-disable-line func-names
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function (error) { return error.message; }),
|
||||
response.errors.map(function (error) { return error.message; }), // eslint-disable-line func-names
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable func-names */
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
|
Reference in New Issue
Block a user