rebasing on master
This commit is contained in:
@ -52,7 +52,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function (mp, jQuery, _) {
|
||||
data: this.options.data || {}
|
||||
};
|
||||
},
|
||||
request: function(method, options) {
|
||||
request: function (method, options) {
|
||||
var params;
|
||||
var deferred;
|
||||
// set options
|
||||
|
@ -71,7 +71,7 @@ define('date',
|
||||
format: 'H:i:s'
|
||||
});
|
||||
},
|
||||
convertFormat: function(format) {
|
||||
convertFormat: function (format) {
|
||||
var replacements;
|
||||
var convertedFormat;
|
||||
var escapeToken;
|
||||
@ -150,7 +150,7 @@ define('date',
|
||||
convertedFormat = [];
|
||||
escapeToken = false;
|
||||
|
||||
for(index = 0, token = ''; format.charAt(index); index += 1){
|
||||
for (index = 0, token = ''; format.charAt(index); index += 1) {
|
||||
token = format.charAt(index);
|
||||
if (escapeToken === true) {
|
||||
convertedFormat.push('[' + token + ']');
|
||||
|
@ -36,7 +36,7 @@ Object.extend(document, (function () {
|
||||
function destroyWrapper(selector, eventName, handler) {
|
||||
var wrapper;
|
||||
var c = getCacheForSelector(selector);
|
||||
if(!c[eventName]) return false;
|
||||
if (!c[eventName]) return false;
|
||||
wrapper = findWrapper(selector, eventName, handler);
|
||||
c[eventName] = c[eventName].without(wrapper);
|
||||
return wrapper;
|
||||
@ -46,25 +46,25 @@ Object.extend(document, (function () {
|
||||
var wrapper;
|
||||
var element;
|
||||
var c = getWrappersForSelector(selector, eventName);
|
||||
if(c.pluck('handler').include(handler)) return false;
|
||||
wrapper = function(event) {
|
||||
if (c.pluck('handler').include(handler)) return false;
|
||||
wrapper = function (event) {
|
||||
element = event.findElement(selector);
|
||||
if(element) handler.call(context || element, event, element);
|
||||
if (element) handler.call(context || element, event, element);
|
||||
};
|
||||
wrapper.handler = handler;
|
||||
c.push(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
return {
|
||||
delegate: function(selector, eventName) {
|
||||
delegate: function (selector, eventName) {
|
||||
var wrapper = createWrapper.apply(null, arguments);
|
||||
if (wrapper) document.observe(eventName, wrapper);
|
||||
return document;
|
||||
},
|
||||
stopDelegating: function(selector, eventName) {
|
||||
stopDelegating: function (selector, eventName) {
|
||||
var length = arguments.length;
|
||||
var wrapper;
|
||||
switch(length) {
|
||||
switch (length) {
|
||||
case 2:
|
||||
getWrappersForSelector(selector, eventName).each(function (wrapper) {
|
||||
document.stopDelegating(selector, eventName, wrapper.handler);
|
||||
@ -82,14 +82,14 @@ Object.extend(document, (function () {
|
||||
break;
|
||||
default:
|
||||
wrapper = destroyWrapper.apply(null, arguments);
|
||||
if(wrapper) document.stopObserving(eventName, wrapper);
|
||||
if (wrapper) document.stopObserving(eventName, wrapper);
|
||||
}
|
||||
return document;
|
||||
}
|
||||
};
|
||||
})());
|
||||
|
||||
Observable = (function() {
|
||||
Observable = (function () {
|
||||
function getEventName(nameA, namespace) {
|
||||
var name = nameA.substring(2);
|
||||
if (namespace) name = namespace + ':' + name;
|
||||
@ -99,8 +99,8 @@ Observable = (function() {
|
||||
function getHandlers(klass) {
|
||||
var proto = klass.prototype;
|
||||
var namespace = proto.namespace;
|
||||
return Object.keys(proto).grep(/^on/).inject(window.$H(), function(handlers, name) {
|
||||
if(name === 'onDomLoaded') return handlers;
|
||||
return Object.keys(proto).grep(/^on/).inject(window.$H(), function (handlers, name) {
|
||||
if (name === 'onDomLoaded') return handlers;
|
||||
handlers.set(getEventName(name, namespace), getWrapper(proto[name], klass));
|
||||
return handlers;
|
||||
});
|
||||
@ -118,12 +118,12 @@ Observable = (function() {
|
||||
});
|
||||
}
|
||||
return {
|
||||
observe: function(selector) {
|
||||
observe: function (selector) {
|
||||
var klass = this;
|
||||
if(!this.handlers) this.handlers = {};
|
||||
if(this.handlers[selector]) return;
|
||||
if(this.prototype.onDomLoaded) {
|
||||
if(document.loaded) {
|
||||
if (!this.handlers) this.handlers = {};
|
||||
if (this.handlers[selector]) return;
|
||||
if (this.prototype.onDomLoaded) {
|
||||
if (document.loaded) {
|
||||
onDomLoad(selector, klass);
|
||||
} else {
|
||||
document.observe('dom:loaded', onDomLoad.curry(selector, klass));
|
||||
@ -153,12 +153,12 @@ Object.extend(window.Droppables, {
|
||||
if (drop.onEnter) drop.onEnter(draggable, drop.element);
|
||||
return proceed(drop);
|
||||
}),
|
||||
show: function(point, element) {
|
||||
show: function (point, element) {
|
||||
var drop;
|
||||
var affected = [];
|
||||
if(!this.drops.length) return;
|
||||
this.drops.each(function(drop) {
|
||||
if(window.Droppables.isAffected(point, element, drop)) affected.push(drop);
|
||||
if (!this.drops.length) return;
|
||||
this.drops.each(function (drop) {
|
||||
if (window.Droppables.isAffected(point, element, drop)) affected.push(drop);
|
||||
});
|
||||
if (affected.length > 0) drop = window.Droppables.findDeepestChild(affected);
|
||||
if (this.last_active && this.last_active !== drop) this.deactivate(this.last_active, element);
|
||||
@ -168,22 +168,22 @@ Object.extend(window.Droppables, {
|
||||
if (drop !== this.last_active) window.Droppables.activate(drop, element);
|
||||
}
|
||||
},
|
||||
displayArea: function() {
|
||||
if(!this.drops.length) return;
|
||||
displayArea: function () {
|
||||
if (!this.drops.length) return;
|
||||
|
||||
// hide controls when displaying drop areas.
|
||||
WysijaForm.hideBlockControls();
|
||||
|
||||
this.drops.each(function(drop) {
|
||||
if(drop.element.hasClassName('block_placeholder')) {
|
||||
this.drops.each(function (drop) {
|
||||
if (drop.element.hasClassName('block_placeholder')) {
|
||||
drop.element.addClassName('active');
|
||||
}
|
||||
});
|
||||
},
|
||||
hideArea: function() {
|
||||
if(!this.drops.length) return;
|
||||
this.drops.each(function(drop) {
|
||||
if(drop.element.hasClassName('block_placeholder')) {
|
||||
hideArea: function () {
|
||||
if (!this.drops.length) return;
|
||||
this.drops.each(function (drop) {
|
||||
if (drop.element.hasClassName('block_placeholder')) {
|
||||
drop.element.removeClassName('active');
|
||||
} else if (drop.element.hasClassName('image_placeholder')) {
|
||||
drop.element.removeClassName('active');
|
||||
@ -300,9 +300,9 @@ WysijaForm = {
|
||||
WysijaForm.Block.create(block, window.$('block_placeholder'));
|
||||
});
|
||||
},
|
||||
load: function(data) {
|
||||
load: function (data) {
|
||||
var settings_elements;
|
||||
if(data === undefined) return;
|
||||
if (data === undefined) return;
|
||||
|
||||
// load body
|
||||
if (data.body !== undefined) {
|
||||
@ -313,7 +313,7 @@ WysijaForm = {
|
||||
|
||||
// load settings
|
||||
settings_elements = window.$('mailpoet_form_settings').getElements();
|
||||
settings_elements.each(function(setting) {
|
||||
settings_elements.each(function (setting) {
|
||||
// skip lists
|
||||
if (setting.name === 'segments') {
|
||||
return true;
|
||||
@ -333,7 +333,7 @@ WysijaForm = {
|
||||
});
|
||||
}
|
||||
},
|
||||
save: function() {
|
||||
save: function () {
|
||||
var position = 1;
|
||||
var data = {
|
||||
name: window.$F('mailpoet_form_name'),
|
||||
@ -410,7 +410,7 @@ WysijaForm = {
|
||||
}
|
||||
return data;
|
||||
},
|
||||
toggleWidgets: function() {
|
||||
toggleWidgets: function () {
|
||||
var hasSegmentSelection;
|
||||
window.$$('a[wysija_unique="1"]').invoke('removeClassName', 'disabled');
|
||||
|
||||
@ -438,7 +438,7 @@ WysijaForm = {
|
||||
isSegmentSelectionValid: function () {
|
||||
var segment_selection = window.$$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]')[0];
|
||||
var block;
|
||||
if(segment_selection !== undefined) {
|
||||
if (segment_selection !== undefined) {
|
||||
block = WysijaForm.get(segment_selection).block.getData();
|
||||
return (
|
||||
(block.params.values !== undefined)
|
||||
@ -448,14 +448,14 @@ WysijaForm = {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
setBlockPositions: function(event, target) {
|
||||
setBlockPositions: function (event, target) {
|
||||
var index = 1;
|
||||
var block_placeholder;
|
||||
var previous_placeholder;
|
||||
// release dragging lock
|
||||
WysijaForm.locks.dragging = false;
|
||||
|
||||
WysijaForm.getBlocks().each(function(container) {
|
||||
WysijaForm.getBlocks().each(function (container) {
|
||||
container.setPosition(index++);
|
||||
// remove z-index value to avoid issues when resizing images
|
||||
if (container['block'] !== undefined) {
|
||||
@ -503,7 +503,7 @@ WysijaForm = {
|
||||
var buttonMargin = 5;
|
||||
var relativeTop = buttonMargin;
|
||||
|
||||
if(is_visible) {
|
||||
if (is_visible) {
|
||||
// always center
|
||||
relativeTop = parseInt((parentDim.height / 2) - (element.getHeight() / 2), 10);
|
||||
}
|
||||
@ -526,7 +526,7 @@ WysijaForm = {
|
||||
if (WysijaForm.toolbar.x === null) WysijaForm.toolbar.x = parseInt(WysijaForm.toolbar.left + window.$(WysijaForm.options.container).getDimensions().width + 15);
|
||||
|
||||
},
|
||||
setToolbarPosition: function() {
|
||||
setToolbarPosition: function () {
|
||||
var position;
|
||||
WysijaForm.initToolbarPosition();
|
||||
|
||||
@ -596,7 +596,7 @@ WysijaForm = {
|
||||
var type = typ;
|
||||
var id;
|
||||
var instance;
|
||||
if(type === undefined) type = 'block';
|
||||
if (type === undefined) type = 'block';
|
||||
// identify element
|
||||
id = element.identify();
|
||||
instance = WysijaForm.instances[id] || new WysijaForm[type.capitalize().camelize()](id);
|
||||
@ -690,7 +690,7 @@ WysijaForm.DraggableItem = window.Class.create({
|
||||
this.insert();
|
||||
},
|
||||
STYLES: new window.Template('position: absolute; top: #{top}px; left: #{left}px;'),
|
||||
cloneElement: function() {
|
||||
cloneElement: function () {
|
||||
var clone = this.element.clone();
|
||||
var offset = this.element.cumulativeOffset();
|
||||
var list = this.getList();
|
||||
@ -777,17 +777,17 @@ WysijaForm.Block = window.Class.create({
|
||||
}
|
||||
}
|
||||
},
|
||||
makeBlockDroppable: function() {
|
||||
makeBlockDroppable: function () {
|
||||
var block_placeholder;
|
||||
if(this.isBlockDroppableEnabled() === false) {
|
||||
if (this.isBlockDroppableEnabled() === false) {
|
||||
block_placeholder = this.getBlockDroppable();
|
||||
window.Droppables.add(block_placeholder.identify(), WysijaForm.blockDropOptions);
|
||||
block_placeholder.addClassName('enabled');
|
||||
}
|
||||
},
|
||||
removeBlockDroppable: function() {
|
||||
removeBlockDroppable: function () {
|
||||
var block_placeholder;
|
||||
if(this.isBlockDroppableEnabled()) {
|
||||
if (this.isBlockDroppableEnabled()) {
|
||||
block_placeholder = this.getBlockDroppable();
|
||||
window.Droppables.remove(block_placeholder.identify());
|
||||
block_placeholder.removeClassName('enabled');
|
||||
@ -819,7 +819,7 @@ WysijaForm.Block = window.Class.create({
|
||||
getControls: function () {
|
||||
return this.element.down('.wysija_controls');
|
||||
},
|
||||
setupControls: function() {
|
||||
setupControls: function () {
|
||||
var block;
|
||||
// enable controls
|
||||
this.controls = this.getControls();
|
||||
@ -872,7 +872,7 @@ WysijaForm.Block = window.Class.create({
|
||||
this.settingsButton.observe('click', function (event) {
|
||||
// TODO: refactor
|
||||
block = window.$(event.target).up('.mailpoet_form_block') || null;
|
||||
if(block !== null) {
|
||||
if (block !== null) {
|
||||
this.editSettings();
|
||||
}
|
||||
}.bind(this));
|
||||
@ -923,7 +923,7 @@ WysijaForm.Block.create = function (createBlock, target) {
|
||||
var template;
|
||||
var output;
|
||||
var settings_segments;
|
||||
if(window.$('form_template_' + block.type) === null) {
|
||||
if (window.$('form_template_' + block.type) === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -932,11 +932,11 @@ WysijaForm.Block.create = function (createBlock, target) {
|
||||
template = window.Handlebars.compile(window.$('form_template_' + block.type).innerHTML);
|
||||
output = '';
|
||||
|
||||
if(block.type === 'segment') {
|
||||
if(block.params.values === undefined) {
|
||||
if (block.type === 'segment') {
|
||||
if (block.params.values === undefined) {
|
||||
settings_segments = window.jQuery('#mailpoet_form_segments').val();
|
||||
if(settings_segments !== null && settings_segments.length > 0){
|
||||
block.params.values = window.mailpoet_segments.filter(function(segment) {
|
||||
if (settings_segments !== null && settings_segments.length > 0) {
|
||||
block.params.values = window.mailpoet_segments.filter(function (segment) {
|
||||
return (settings_segments.indexOf(segment.id) !== -1);
|
||||
});
|
||||
}
|
||||
@ -954,10 +954,10 @@ WysijaForm.Block.create = function (createBlock, target) {
|
||||
}
|
||||
|
||||
// if the drop target was the bottom placeholder
|
||||
if(target.identify() === 'block_placeholder') {
|
||||
if (target.identify() === 'block_placeholder') {
|
||||
// insert block at the bottom
|
||||
body.insert(output);
|
||||
//block = body.childElements().last();
|
||||
// block = body.childElements().last();
|
||||
} else {
|
||||
// insert block before the drop target
|
||||
target.insert({
|
||||
@ -1000,7 +1000,7 @@ WysijaForm.Widget = window.Class.create(WysijaForm.Block, {
|
||||
info('widget -> setup');
|
||||
this.setupControls();
|
||||
},
|
||||
save: function() {
|
||||
save: function () {
|
||||
var data = this.getData();
|
||||
info('widget -> save');
|
||||
|
||||
@ -1010,7 +1010,7 @@ WysijaForm.Widget = window.Class.create(WysijaForm.Block, {
|
||||
|
||||
return data;
|
||||
},
|
||||
setData: function(data) {
|
||||
setData: function (data) {
|
||||
var current_data = this.getData();
|
||||
var params = window.$H(current_data.params).merge(data.params).toObject();
|
||||
|
||||
@ -1036,7 +1036,7 @@ WysijaForm.Widget = window.Class.create(WysijaForm.Block, {
|
||||
remove: function () {
|
||||
this.removeBlock();
|
||||
},
|
||||
redraw: function(data) {
|
||||
redraw: function (data) {
|
||||
var options;
|
||||
var block_template;
|
||||
var template;
|
||||
@ -1084,7 +1084,7 @@ function info(value) {
|
||||
var length = methods.length;
|
||||
var console = {};
|
||||
window.console = {};
|
||||
while(length--) {
|
||||
while (length--) {
|
||||
console[methods[length]] = noop;
|
||||
}
|
||||
}());
|
||||
|
@ -1,29 +1,29 @@
|
||||
define('handlebars_helpers', ['handlebars'], function (Handlebars) {
|
||||
// Handlebars helpers
|
||||
Handlebars.registerHelper('concat', function() {
|
||||
Handlebars.registerHelper('concat', function () {
|
||||
var size = (arguments.length - 1);
|
||||
var output = '';
|
||||
var i;
|
||||
for(i = 0; i < size; i++) {
|
||||
for (i = 0; i < size; i++) {
|
||||
output += arguments[i];
|
||||
}
|
||||
return output;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('number_format', function(value) {
|
||||
Handlebars.registerHelper('number_format', function (value) {
|
||||
return Number(value).toLocaleString();
|
||||
});
|
||||
Handlebars.registerHelper('date_format', function(timestamp, block) {
|
||||
Handlebars.registerHelper('date_format', function (timestamp, block) {
|
||||
var f;
|
||||
if(window.moment) {
|
||||
if(timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
|
||||
if (window.moment) {
|
||||
if (timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set date format
|
||||
f = block.hash.format || 'MMM Do, YYYY';
|
||||
// check if we passed a timestamp
|
||||
if(parseInt(timestamp, 10) == timestamp) {
|
||||
if (parseInt(timestamp, 10) == timestamp) {
|
||||
return window.moment.unix(timestamp).format(f);
|
||||
} else {
|
||||
return window.moment.utc(timestamp).format(f);
|
||||
@ -67,18 +67,18 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
|
||||
}
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('nl2br', function(value) {
|
||||
Handlebars.registerHelper('nl2br', function (value) {
|
||||
return value.gsub('\n', '<br />');
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('json_encode', function(value) {
|
||||
Handlebars.registerHelper('json_encode', function (value) {
|
||||
return JSON.stringify(value);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('json_decode', function(value) {
|
||||
Handlebars.registerHelper('json_decode', function (value) {
|
||||
return JSON.parse(value);
|
||||
});
|
||||
Handlebars.registerHelper('url', function(value) {
|
||||
Handlebars.registerHelper('url', function (value) {
|
||||
var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
||||
|
||||
return url + value;
|
||||
@ -91,15 +91,15 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
|
||||
return value;
|
||||
}
|
||||
});
|
||||
Handlebars.registerHelper('lookup', function(obj, field) {
|
||||
Handlebars.registerHelper('lookup', function (obj, field) {
|
||||
return obj && obj[field];
|
||||
});
|
||||
|
||||
|
||||
Handlebars.registerHelper('rsa_key', function(value) {
|
||||
Handlebars.registerHelper('rsa_key', function (value) {
|
||||
var lines;
|
||||
// extract all lines into an array
|
||||
if(value === undefined) return '';
|
||||
if (value === undefined) return '';
|
||||
|
||||
lines = value.trim().split('\n');
|
||||
|
||||
@ -111,8 +111,8 @@ define('handlebars_helpers', ['handlebars'], function (Handlebars) {
|
||||
return lines.join('');
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('trim', function(value) {
|
||||
if(value === null || value === undefined) return '';
|
||||
Handlebars.registerHelper('trim', function (value) {
|
||||
if (value === null || value === undefined) return '';
|
||||
return value.trim();
|
||||
});
|
||||
|
||||
|
@ -23,12 +23,12 @@ define(
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
$.fn.serializeObject = function(coerce) {
|
||||
$.fn.serializeObject = function (coerce) {
|
||||
var obj = {};
|
||||
var coerce_types = { true: !0, false: !1, null: null };
|
||||
|
||||
// Iterate over all name=value pairs.
|
||||
$.each( this.serializeArray(), function(j, v){
|
||||
$.each(this.serializeArray(), function (j, v) {
|
||||
var key = v.name;
|
||||
var val = v.value;
|
||||
var cur = obj;
|
||||
@ -36,7 +36,7 @@ define(
|
||||
|
||||
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
||||
// into its component parts.
|
||||
var keys = key.split( '][' );
|
||||
var keys = key.split('][');
|
||||
var keys_last = keys.length - 1;
|
||||
|
||||
// If the first keys part contains [ and the last ends with ], then []
|
||||
|
@ -115,9 +115,9 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
return window.Handlebars.compile(template);
|
||||
}
|
||||
},
|
||||
init: function(options) {
|
||||
init: function (options) {
|
||||
var modal;
|
||||
if(this.initialized === true) {
|
||||
if (this.initialized === true) {
|
||||
this.close();
|
||||
}
|
||||
// merge options
|
||||
@ -134,7 +134,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
|
||||
if (this.options.type !== null) {
|
||||
// insert modal depending on its type
|
||||
if(this.options.type === 'popup') {
|
||||
if (this.options.type === 'popup') {
|
||||
modal = this.compileTemplate(
|
||||
this.templates[this.options.type]
|
||||
);
|
||||
@ -179,8 +179,8 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
|
||||
return this;
|
||||
},
|
||||
initOverlay: function() {
|
||||
if(jQuery('#mailpoet_modal_overlay').length === 0) {
|
||||
initOverlay: function () {
|
||||
if (jQuery('#mailpoet_modal_overlay').length === 0) {
|
||||
// insert overlay into the DOM
|
||||
jQuery('body').append(this.templates.overlay);
|
||||
// insert loading indicator into overlay
|
||||
@ -343,12 +343,12 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
|
||||
return this;
|
||||
},
|
||||
setPosition: function() {
|
||||
setPosition: function () {
|
||||
var screenWidth;
|
||||
var screenHeight;
|
||||
var modalWidth;
|
||||
var modalHeight;
|
||||
switch(this.options.type) {
|
||||
switch (this.options.type) {
|
||||
case 'popup':
|
||||
screenWidth = jQuery(window).width();
|
||||
screenHeight = jQuery(window).height();
|
||||
@ -438,7 +438,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
.removeClass('mailpoet_modal_highlight');
|
||||
return this;
|
||||
},
|
||||
hideModal: function() {
|
||||
hideModal: function () {
|
||||
// set modal as closed
|
||||
this.opened = false;
|
||||
|
||||
@ -453,7 +453,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
|
||||
return this;
|
||||
},
|
||||
showOverlay: function() {
|
||||
showOverlay: function () {
|
||||
jQuery('#mailpoet_modal_overlay').show();
|
||||
return this;
|
||||
},
|
||||
|
@ -2,7 +2,7 @@ define([
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
'backbone.radio'
|
||||
], function(Backbone, Marionette, BackboneRadio) {
|
||||
], function (Backbone, Marionette, BackboneRadio) {
|
||||
var Radio = BackboneRadio;
|
||||
|
||||
var AppView = Marionette.View.extend({
|
||||
|
@ -8,11 +8,11 @@ define([
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'mailpoet',
|
||||
'spectrum'
|
||||
], function(Marionette, BehaviorsLookup, MailPoet) {
|
||||
], function (Marionette, BehaviorsLookup, MailPoet) {
|
||||
var BL = BehaviorsLookup;
|
||||
|
||||
BL.ColorPickerBehavior = Marionette.Behavior.extend({
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
var that = this;
|
||||
var preferredFormat = 'hex6';
|
||||
this.view.$('.mailpoet_color').each(function () {
|
||||
|
@ -25,7 +25,7 @@ define([
|
||||
this.addDropZone();
|
||||
}
|
||||
},
|
||||
addDropZone: function() {
|
||||
addDropZone: function () {
|
||||
var that = this;
|
||||
var view = this.view;
|
||||
var domElement = that.$el.get(0);
|
||||
@ -47,11 +47,11 @@ define([
|
||||
interact(domElement).dropzone({
|
||||
accept: acceptableElementSelector,
|
||||
overlap: 'pointer', // Mouse pointer denotes location of a droppable
|
||||
ondragenter: function() {
|
||||
ondragenter: function () {
|
||||
// 1. Visually mark block as active for dropping
|
||||
view.$el.addClass('mailpoet_drop_active');
|
||||
},
|
||||
ondragleave: function() {
|
||||
ondragleave: function () {
|
||||
// 1. Remove visual markings of active dropping container
|
||||
// 2. Remove visual markings of drop position visualization
|
||||
that.cleanup();
|
||||
@ -281,7 +281,7 @@ define([
|
||||
// 2. Remove visual markings of drop position visualization
|
||||
this.view.$('.mailpoet_drop_marker').remove();
|
||||
},
|
||||
getDropPosition: function(eventX, eventY, is_unsafe) {
|
||||
getDropPosition: function (eventX, eventY, is_unsafe) {
|
||||
var SPECIAL_AREA_INSERTION_WIDTH = 0.00; // Disable special insertion. Default: 0.3
|
||||
|
||||
var element = this.view.$el;
|
||||
@ -409,10 +409,10 @@ define([
|
||||
_computeSpecialIndex: function (eventX, eventY) {
|
||||
return this._computeCellIndex(eventX, eventY);
|
||||
},
|
||||
_computeCellIndex: function(eventX, eventY) {
|
||||
_computeCellIndex: function (eventX, eventY) {
|
||||
var orientation = this.view.model.get('orientation');
|
||||
var eventOffset = (orientation === 'vertical') ? eventY : eventX;
|
||||
var resultView = this.getChildren().find(function(view) {
|
||||
var resultView = this.getChildren().find(function (view) {
|
||||
var element = view.$el;
|
||||
var closeOffset;
|
||||
var farOffset;
|
||||
@ -433,14 +433,14 @@ define([
|
||||
|
||||
return index;
|
||||
},
|
||||
_canAcceptNormalInsertion: function() {
|
||||
_canAcceptNormalInsertion: function () {
|
||||
var orientation = this.view.model.get('orientation');
|
||||
var depth = this.view.renderOptions.depth;
|
||||
var childCount = this.getChildren().length;
|
||||
// Note that depth is zero indexed. Root container has depth=0
|
||||
return orientation === 'vertical' || (orientation === 'horizontal' && depth === 1 && childCount < this.options.columnLimit);
|
||||
},
|
||||
_canAcceptSpecialInsertion: function() {
|
||||
_canAcceptSpecialInsertion: function () {
|
||||
var orientation = this.view.model.get('orientation');
|
||||
var depth = this.view.renderOptions.depth;
|
||||
var childCount = this.getChildren().length;
|
||||
|
@ -28,10 +28,10 @@ define([
|
||||
throw "Missing 'drop' function for DraggableBehavior";
|
||||
},
|
||||
|
||||
onDrop: function() {},
|
||||
testAttachToInstance: function() { return true; }
|
||||
onDrop: function () {},
|
||||
testAttachToInstance: function () { return true; }
|
||||
},
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
var that = this;
|
||||
var interactable;
|
||||
|
||||
|
@ -19,8 +19,8 @@ define([
|
||||
maxLength: Infinity,
|
||||
modelField: 'styles.block.height',
|
||||
onResize: function (event) {
|
||||
var currentLength = parseFloat(this.view.model.get(this.options.modelField)),
|
||||
newLength = currentLength + this.options.transformationFunction(event.dy);
|
||||
var currentLength = parseFloat(this.view.model.get(this.options.modelField));
|
||||
var newLength = currentLength + event.y;
|
||||
newLength = Math.min(this.options.maxLength, Math.max(this.options.minLength, newLength));
|
||||
this.view.model.set(this.options.modelField, newLength + 'px');
|
||||
}
|
||||
@ -36,7 +36,7 @@ define([
|
||||
this.hideResizeHandle();
|
||||
}
|
||||
},
|
||||
attachResize: function() {
|
||||
attachResize: function () {
|
||||
var domElement = (this.options.elementSelector === null) ? this.view.$el.get(0) : this.view.$(this.options.elementSelector).get(0);
|
||||
var that = this;
|
||||
interact(domElement).resizable({
|
||||
@ -47,10 +47,10 @@ define([
|
||||
right: false,
|
||||
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
|
||||
}
|
||||
}).on('resizestart', function() {
|
||||
}).on('resizestart', function () {
|
||||
that.isBeingResized = true;
|
||||
that.$el.addClass('mailpoet_resize_active');
|
||||
}).on('resizemove', function(event) {
|
||||
}).on('resizemove', function (event) {
|
||||
var currentLength = parseFloat(that.view.model.get(that.options.modelField));
|
||||
var newLength = currentLength + that.options.transformationFunction(event.dy);
|
||||
|
||||
@ -58,7 +58,7 @@ define([
|
||||
|
||||
that.view.model.set(that.options.modelField, newLength + 'px');
|
||||
})
|
||||
.on('resizeend', function() {
|
||||
.on('resizeend', function () {
|
||||
that.isBeingResized = null;
|
||||
that.$el.removeClass('mailpoet_resize_active');
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ define([
|
||||
end: function (event, ui) {
|
||||
ui.item.removeData('previousIndex');
|
||||
},
|
||||
update: function(event, ui) {
|
||||
update: function (event, ui) {
|
||||
var previousIndex = ui.item.data('previousIndex');
|
||||
var newIndex = ui.item.index();
|
||||
var model = collection.at(previousIndex);
|
||||
|
@ -42,7 +42,7 @@ define([
|
||||
relative_urls: false,
|
||||
remove_script_host: false,
|
||||
convert_urls: true,
|
||||
urlconverter_callback: function(url) {
|
||||
urlconverter_callback: function (url) {
|
||||
if (url.match(/\[.+\]/g)) {
|
||||
// Do not convert URLs with shortcodes
|
||||
return url;
|
||||
@ -56,8 +56,8 @@ define([
|
||||
|
||||
plugins: this.options.plugins,
|
||||
|
||||
setup: function(editor) {
|
||||
editor.on('change', function() {
|
||||
setup: function (editor) {
|
||||
editor.on('change', function () {
|
||||
that.view.triggerMethod('text:editor:change', editor.getContent());
|
||||
});
|
||||
|
||||
@ -71,12 +71,12 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('focus', function() {
|
||||
editor.on('focus', function () {
|
||||
that.view.triggerMethod('text:editor:focus');
|
||||
that._isActivationClick = true;
|
||||
});
|
||||
|
||||
editor.on('blur', function() {
|
||||
editor.on('blur', function () {
|
||||
that.view.triggerMethod('text:editor:blur');
|
||||
});
|
||||
}
|
||||
|
@ -42,14 +42,14 @@ define([
|
||||
_.debounce(this.refresh, DELAY_REFRESH_FOR_MS)
|
||||
);
|
||||
},
|
||||
refresh: function() {
|
||||
refresh: function () {
|
||||
var blocks;
|
||||
var models = App.findModels(function(model) {
|
||||
var models = App.findModels(function (model) {
|
||||
return model.get('type') === 'automatedLatestContent';
|
||||
}) || [];
|
||||
|
||||
if (models.length === 0) return;
|
||||
blocks = _.map(models, function(model) {
|
||||
blocks = _.map(models, function (model) {
|
||||
return model.toJSON();
|
||||
});
|
||||
|
||||
@ -60,7 +60,7 @@ define([
|
||||
refreshBlocks: function (models, renderedBlocks) {
|
||||
_.each(
|
||||
_.zip(models, renderedBlocks),
|
||||
function(args) {
|
||||
function (args) {
|
||||
var model = args[0];
|
||||
var contents = args[1];
|
||||
model.trigger('refreshPosts', contents);
|
||||
@ -149,8 +149,8 @@ define([
|
||||
events: _.extend(base.BlockView.prototype.events, {
|
||||
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
|
||||
}),
|
||||
onDragSubstituteBy: function() { return Module.AutomatedLatestContentWidgetView; },
|
||||
onRender: function() {
|
||||
onDragSubstituteBy: function () { return Module.AutomatedLatestContentWidgetView; },
|
||||
onRender: function () {
|
||||
var ContainerView = App.getBlockTypeView('container');
|
||||
var renderOptions = {
|
||||
disableTextEditor: true,
|
||||
@ -266,7 +266,7 @@ define([
|
||||
}
|
||||
}).trigger('change');
|
||||
},
|
||||
toggleDisplayOptions: function() {
|
||||
toggleDisplayOptions: function () {
|
||||
var el = this.$('.mailpoet_automated_latest_content_display_options');
|
||||
var showControl = this.$('.mailpoet_automated_latest_content_show_display_options');
|
||||
if (el.hasClass('mailpoet_closed')) {
|
||||
@ -277,7 +277,7 @@ define([
|
||||
showControl.removeClass('mailpoet_hidden');
|
||||
}
|
||||
},
|
||||
showButtonSettings: function() {
|
||||
showButtonSettings: function () {
|
||||
var buttonModule = ButtonBlock;
|
||||
(new buttonModule.ButtonBlockSettingsView({
|
||||
model: this.model.get('readMoreButton'),
|
||||
@ -288,7 +288,7 @@ define([
|
||||
}
|
||||
})).render();
|
||||
},
|
||||
showDividerSettings: function() {
|
||||
showDividerSettings: function () {
|
||||
var dividerModule = DividerBlock;
|
||||
(new dividerModule.DividerBlockSettingsView({
|
||||
model: this.model.get('divider'),
|
||||
@ -350,7 +350,7 @@ define([
|
||||
}
|
||||
this.changeField('titleFormat', event);
|
||||
},
|
||||
_updateContentTypes: function(postTypes) {
|
||||
_updateContentTypes: function (postTypes) {
|
||||
var select = this.$('.mailpoet_automated_latest_content_content_type');
|
||||
var selectedValue = this.model.get('contentType');
|
||||
|
||||
@ -380,7 +380,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('automatedLatestContent', {
|
||||
blockModel: Module.AutomatedLatestContentBlockModel,
|
||||
blockView: Module.AutomatedLatestContentBlockView
|
||||
@ -393,7 +393,7 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
App.on('start', function(App) {
|
||||
App.on('start', function (App) {
|
||||
var Application = App;
|
||||
Application._ALCSupervisor = new Module.ALCSupervisor();
|
||||
Application._ALCSupervisor.refresh();
|
||||
|
@ -12,7 +12,7 @@ define([
|
||||
'jquery',
|
||||
'mailpoet',
|
||||
'modal'
|
||||
], function(App, Marionette, SuperModel, _, jQuery, MailPoet) {
|
||||
], function (App, Marionette, SuperModel, _, jQuery, MailPoet) {
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -21,8 +21,8 @@ define([
|
||||
|
||||
Module.BlockModel = SuperModel.extend({
|
||||
stale: [], // Attributes to be removed upon saving
|
||||
initialize: function() {
|
||||
this.on('change', function() {
|
||||
initialize: function () {
|
||||
this.on('change', function () {
|
||||
App.getChannel().trigger('autoSave');
|
||||
});
|
||||
},
|
||||
@ -66,7 +66,7 @@ define([
|
||||
// and destroy self
|
||||
options.dragBehavior.view.model.destroy();
|
||||
},
|
||||
onDragSubstituteBy: function(behavior) {
|
||||
onDragSubstituteBy: function (behavior) {
|
||||
var WidgetView;
|
||||
var node;
|
||||
// When block is being dragged, display the widget icon instead.
|
||||
@ -98,13 +98,13 @@ define([
|
||||
this.on('dom:refresh', this.showBlock, this);
|
||||
this._isFirstRender = true;
|
||||
},
|
||||
showTools: function() {
|
||||
showTools: function () {
|
||||
if (!this.showingToolsDisabled) {
|
||||
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function() {
|
||||
hideTools: function () {
|
||||
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
},
|
||||
@ -239,7 +239,7 @@ define([
|
||||
behaviors: {
|
||||
ColorPickerBehavior: {}
|
||||
},
|
||||
initialize: function(params) {
|
||||
initialize: function (params) {
|
||||
var panelParams;
|
||||
this.model.trigger('startEditing');
|
||||
panelParams = {
|
||||
@ -263,7 +263,7 @@ define([
|
||||
model: this.model.toJSON()
|
||||
};
|
||||
},
|
||||
close: function() {
|
||||
close: function () {
|
||||
this.destroy();
|
||||
},
|
||||
changeField: function (field, event) {
|
||||
|
@ -132,7 +132,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('button', {
|
||||
blockModel: Module.ButtonBlockModel,
|
||||
blockView: Module.ButtonBlockView
|
||||
|
@ -23,8 +23,8 @@ define([
|
||||
initialize: function () {
|
||||
this.on('add change remove', function () { App.getChannel().trigger('autoSave'); });
|
||||
},
|
||||
parse: function(response) {
|
||||
return _.map(response, function(block) {
|
||||
parse: function (response) {
|
||||
return _.map(response, function (block) {
|
||||
var Type = App.getBlockTypeModel(block.type);
|
||||
// TODO: If type has no registered model, use a backup one
|
||||
return new Type(block, { parse: true });
|
||||
@ -64,8 +64,8 @@ define([
|
||||
}
|
||||
return response;
|
||||
},
|
||||
getChildren: function() {
|
||||
var models = this.get('blocks').map(function(model) {
|
||||
getChildren: function () {
|
||||
var models = this.get('blocks').map(function (model) {
|
||||
return [model, model.getChildren()];
|
||||
});
|
||||
|
||||
@ -119,7 +119,7 @@ define([
|
||||
// and destroy self
|
||||
options.dragBehavior.view.model.destroy();
|
||||
},
|
||||
onDragSubstituteBy: function(behavior) {
|
||||
onDragSubstituteBy: function (behavior) {
|
||||
var WidgetView;
|
||||
var node;
|
||||
// When block is being dragged, display the widget icon instead.
|
||||
@ -189,19 +189,19 @@ define([
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
}
|
||||
},
|
||||
toggleEditingLayer: function(event) {
|
||||
toggleEditingLayer: function (event) {
|
||||
var that = this;
|
||||
var $toggleButton = this.$('> .mailpoet_tools .mailpoet_newsletter_layer_selector');
|
||||
var $overlay = jQuery('.mailpoet_layer_overlay');
|
||||
var $container = this.$('> .mailpoet_container');
|
||||
var enableContainerLayer = function() {
|
||||
var enableContainerLayer = function () {
|
||||
that.$el.addClass('mailpoet_container_layer_active');
|
||||
$toggleButton.addClass('mailpoet_container_layer_active');
|
||||
$container.addClass('mailpoet_layer_highlight');
|
||||
$overlay.click(disableContainerLayer);
|
||||
$overlay.show();
|
||||
};
|
||||
var disableContainerLayer = function() {
|
||||
var disableContainerLayer = function () {
|
||||
that.$el.removeClass('mailpoet_container_layer_active');
|
||||
$toggleButton.removeClass('mailpoet_container_layer_active');
|
||||
$container.removeClass('mailpoet_layer_highlight');
|
||||
@ -336,7 +336,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('container', {
|
||||
blockModel: Module.ContainerBlockModel,
|
||||
blockView: Module.ContainerBlockView
|
||||
|
@ -6,7 +6,7 @@ define([
|
||||
'newsletter_editor/blocks/base',
|
||||
'underscore',
|
||||
'jquery'
|
||||
], function(App, BaseBlock, _, jQuery) {
|
||||
], function (App, BaseBlock, _, jQuery) {
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -46,8 +46,8 @@ define([
|
||||
ignoreFrom: '.mailpoet_resize_handle'
|
||||
}
|
||||
}, base.BlockView.prototype.behaviors),
|
||||
onDragSubstituteBy: function() { return Module.DividerWidgetView; },
|
||||
initialize: function() {
|
||||
onDragSubstituteBy: function () { return Module.DividerWidgetView; },
|
||||
initialize: function () {
|
||||
var that = this;
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
|
||||
@ -118,7 +118,7 @@ define([
|
||||
repaintDividerStyleOptions: function () {
|
||||
this.$('.mailpoet_field_divider_style > div').css('border-top-color', this.model.get('styles.block.borderColor'));
|
||||
},
|
||||
applyToAll: function() {
|
||||
applyToAll: function () {
|
||||
App.getChannel().trigger('replaceAllDividers', this.model.toJSON());
|
||||
},
|
||||
updateValueAndCall: function (fieldToUpdate, callable, event) {
|
||||
@ -138,7 +138,7 @@ define([
|
||||
}
|
||||
}
|
||||
});
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('divider', {
|
||||
blockModel: Module.DividerBlockModel,
|
||||
blockView: Module.DividerBlockView
|
||||
|
@ -110,7 +110,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('footer', {
|
||||
blockModel: Module.FooterBlockModel,
|
||||
blockView: Module.FooterBlockView
|
||||
|
@ -110,7 +110,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('header', {
|
||||
blockModel: Module.HeaderBlockModel,
|
||||
blockView: Module.HeaderBlockView
|
||||
|
@ -48,8 +48,8 @@ define([
|
||||
elementSelector: '.mailpoet_image',
|
||||
resizeHandleSelector: '.mailpoet_image_resize_handle',
|
||||
onResize: function (event) {
|
||||
var corner = this.$('.mailpoet_image').offset(),
|
||||
width = event.pageX - corner.left;
|
||||
var corner = this.$('.mailpoet_image').offset();
|
||||
var width = event.pageX - corner.left;
|
||||
this.view.model.set('width', width + 'px');
|
||||
}
|
||||
},
|
||||
@ -126,7 +126,7 @@ define([
|
||||
this.showMediaManager();
|
||||
}
|
||||
},
|
||||
showMediaManager: function() {
|
||||
showMediaManager: function () {
|
||||
var that = this;
|
||||
var MediaManager;
|
||||
var theFrame;
|
||||
@ -198,7 +198,7 @@ define([
|
||||
}
|
||||
},
|
||||
|
||||
bindHandlers: function() {
|
||||
bindHandlers: function () {
|
||||
var handlers;
|
||||
// from Select
|
||||
this.on('router:create:browse', this.createRouter, this);
|
||||
@ -247,7 +247,7 @@ define([
|
||||
view.url.focus();
|
||||
},
|
||||
|
||||
editSelectionContent: function() {
|
||||
editSelectionContent: function () {
|
||||
var state = this.state();
|
||||
var selection = state.get('selection');
|
||||
var view;
|
||||
@ -305,7 +305,7 @@ define([
|
||||
text: 'Select Image',
|
||||
requires: { selection: true },
|
||||
|
||||
click: function() {
|
||||
click: function () {
|
||||
var state = controller.state();
|
||||
var selection = state.get('selection');
|
||||
|
||||
@ -344,7 +344,7 @@ define([
|
||||
this._mediaManager.on('insert', function () {
|
||||
// Append media manager image selections to Images tab
|
||||
var selection = theFrame.state().get('selection');
|
||||
selection.each(function(attachment) {
|
||||
selection.each(function (attachment) {
|
||||
var sizes = attachment.get('sizes');
|
||||
// Following advice from Becs, the target width should
|
||||
// be a double of one column width to render well on
|
||||
@ -354,13 +354,13 @@ define([
|
||||
// Pick the width that is closest to target width
|
||||
var increasingByWidthDifference = _.sortBy(
|
||||
_.keys(sizes),
|
||||
function(size) { return Math.abs(targetImageWidth - sizes[size].width); }
|
||||
function (size) { return Math.abs(targetImageWidth - sizes[size].width); }
|
||||
);
|
||||
var bestWidth = sizes[_.first(increasingByWidthDifference)].width;
|
||||
var imagesOfBestWidth = _.filter(_.values(sizes), function(size) { return size.width === bestWidth; });
|
||||
var imagesOfBestWidth = _.filter(_.values(sizes), function (size) { return size.width === bestWidth; });
|
||||
|
||||
// Maximize the height if there are multiple images with same width
|
||||
var mainSize = _.max(imagesOfBestWidth, function(size) { return size.height; });
|
||||
var mainSize = _.max(imagesOfBestWidth, function (size) { return size.height; });
|
||||
|
||||
that.model.set({
|
||||
height: mainSize.height + 'px',
|
||||
@ -413,7 +413,7 @@ define([
|
||||
});
|
||||
Module.ImageWidgetView = ImageWidgetView;
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('image', {
|
||||
blockModel: Module.ImageBlockModel,
|
||||
blockView: Module.ImageBlockView
|
||||
|
@ -93,7 +93,7 @@ define([
|
||||
_transformedPosts: App.getBlockTypeModel('container')
|
||||
};
|
||||
},
|
||||
initialize: function() {
|
||||
initialize: function () {
|
||||
var POST_REFRESH_DELAY_MS = 500;
|
||||
var refreshAvailablePosts = _.debounce(this.fetchAvailablePosts.bind(this), POST_REFRESH_DELAY_MS);
|
||||
var refreshTransformedPosts = _.debounce(this._refreshTransformedPosts.bind(this), POST_REFRESH_DELAY_MS);
|
||||
@ -123,7 +123,7 @@ define([
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchAvailablePosts'));
|
||||
});
|
||||
},
|
||||
_loadMorePosts: function() {
|
||||
_loadMorePosts: function () {
|
||||
var that = this;
|
||||
var postCount = this.get('_availablePosts').length;
|
||||
var nextOffset = this.get('offset') + Number(this.get('amount'));
|
||||
@ -144,7 +144,7 @@ define([
|
||||
that.trigger('morePostsLoaded');
|
||||
});
|
||||
},
|
||||
_refreshTransformedPosts: function() {
|
||||
_refreshTransformedPosts: function () {
|
||||
var that = this;
|
||||
var data = this.toJSON();
|
||||
|
||||
@ -161,7 +161,7 @@ define([
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
|
||||
});
|
||||
},
|
||||
_insertSelectedPosts: function() {
|
||||
_insertSelectedPosts: function () {
|
||||
var data = this.toJSON();
|
||||
var index = this.collection.indexOf(this);
|
||||
var collection = this.collection;
|
||||
@ -192,7 +192,7 @@ define([
|
||||
this.toolsView = new Module.PostsBlockToolsView({ model: this.model });
|
||||
this.model.reply('blockView', this.notifyAboutSelf, this);
|
||||
},
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
var ContainerView;
|
||||
var renderOptions;
|
||||
if (!this.getRegion('toolsRegion').hasView()) {
|
||||
@ -241,7 +241,7 @@ define([
|
||||
this.selectionView = new PostSelectionSettingsView({ model: this.model });
|
||||
this.displayOptionsView = new PostsDisplayOptionsSettingsView({ model: this.model });
|
||||
},
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
var that = this;
|
||||
this.model.request('blockView');
|
||||
|
||||
@ -313,7 +313,7 @@ define([
|
||||
});
|
||||
|
||||
PostSelectionSettingsView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.postSelectionPostsBlockSettings; },
|
||||
getTemplate: function () { return window.templates.postSelectionPostsBlockSettings; },
|
||||
regions: {
|
||||
posts: '.mailpoet_post_selection_container'
|
||||
},
|
||||
@ -338,7 +338,7 @@ define([
|
||||
this.$('.mailpoet_post_selection_loading').css('visibility', 'hidden');
|
||||
}
|
||||
},
|
||||
onRender: function() {
|
||||
onRender: function () {
|
||||
var postsView;
|
||||
// Dynamically update available post types
|
||||
CommunicationComponent.getPostTypes().done(_.bind(this._updateContentTypes, this));
|
||||
@ -419,7 +419,7 @@ define([
|
||||
changeField: function (field, event) {
|
||||
this.model.set(field, jQuery(event.target).val());
|
||||
},
|
||||
_updateContentTypes: function(postTypes) {
|
||||
_updateContentTypes: function (postTypes) {
|
||||
var select = this.$('.mailpoet_settings_posts_content_type');
|
||||
var selectedValue = this.model.get('contentType');
|
||||
|
||||
@ -435,12 +435,12 @@ define([
|
||||
});
|
||||
|
||||
EmptyPostSelectionSettingsView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.emptyPostPostsBlockSettings; }
|
||||
getTemplate: function () { return window.templates.emptyPostPostsBlockSettings; }
|
||||
});
|
||||
|
||||
SinglePostSelectionSettingsView = Marionette.View.extend({
|
||||
getTemplate: function() { return window.templates.singlePostPostsBlockSettings; },
|
||||
events: function() {
|
||||
getTemplate: function () { return window.templates.singlePostPostsBlockSettings; },
|
||||
events: function () {
|
||||
return {
|
||||
'change .mailpoet_select_post_checkbox': 'postSelectionChange'
|
||||
};
|
||||
@ -454,7 +454,7 @@ define([
|
||||
initialize: function (options) {
|
||||
this.blockModel = options.blockModel;
|
||||
},
|
||||
postSelectionChange: function(event) {
|
||||
postSelectionChange: function (event) {
|
||||
var checkBox = jQuery(event.target);
|
||||
var selectedPostsCollection = this.blockModel.get('_selectedPosts');
|
||||
if (checkBox.prop('checked')) {
|
||||
@ -466,8 +466,8 @@ define([
|
||||
});
|
||||
|
||||
PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({
|
||||
getTemplate: function() { return window.templates.displayOptionsPostsBlockSettings; },
|
||||
events: function() {
|
||||
getTemplate: function () { return window.templates.displayOptionsPostsBlockSettings; },
|
||||
events: function () {
|
||||
return {
|
||||
'click .mailpoet_posts_select_button': 'showButtonSettings',
|
||||
'click .mailpoet_posts_select_divider': 'showDividerSettings',
|
||||
@ -495,7 +495,7 @@ define([
|
||||
model: this.model.toJSON()
|
||||
};
|
||||
},
|
||||
showButtonSettings: function() {
|
||||
showButtonSettings: function () {
|
||||
var buttonModule = ButtonBlock;
|
||||
(new buttonModule.ButtonBlockSettingsView({
|
||||
model: this.model.get('readMoreButton'),
|
||||
@ -506,7 +506,7 @@ define([
|
||||
}
|
||||
})).render();
|
||||
},
|
||||
showDividerSettings: function() {
|
||||
showDividerSettings: function () {
|
||||
var dividerModule = DividerBlock;
|
||||
(new dividerModule.DividerBlockSettingsView({
|
||||
model: this.model.get('divider'),
|
||||
@ -582,7 +582,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('posts', {
|
||||
blockModel: Module.PostsBlockModel,
|
||||
blockView: Module.PostsBlockView
|
||||
|
@ -34,10 +34,10 @@ define([
|
||||
text: defaultValues.get('title')
|
||||
};
|
||||
},
|
||||
initialize: function() {
|
||||
initialize: function () {
|
||||
var that = this;
|
||||
// Make model swap to default values for that type when iconType changes
|
||||
this.on('change:iconType', function() {
|
||||
this.on('change:iconType', function () {
|
||||
var defaultValues = App.getConfig().get('socialIcons').get(that.get('iconType'));
|
||||
var iconSet = that.collection.iconBlockModel.getIconSet();
|
||||
this.set({
|
||||
@ -175,10 +175,10 @@ define([
|
||||
this.$('.mailpoet_social_icon_image').attr('alt', this.model.get('text'));
|
||||
}
|
||||
},
|
||||
templateContext: function() {
|
||||
templateContext: function () {
|
||||
var icons = App.getConfig().get('socialIcons');
|
||||
// Construct icon type list of format [{iconType: 'type', title: 'Title'}, ...]
|
||||
var availableIconTypes = _.map(_.keys(icons.attributes), function(key) { return { iconType: key, title: icons.get(key).get('title') }; });
|
||||
var availableIconTypes = _.map(_.keys(icons.attributes), function (key) { return { iconType: key, title: icons.get(key).get('title') }; });
|
||||
var allIconSets = App.getAvailableStyles().get('socialIconSets');
|
||||
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
||||
iconTypes: availableIconTypes,
|
||||
@ -298,7 +298,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('social', {
|
||||
blockModel: Module.SocialBlockModel,
|
||||
blockView: Module.SocialBlockView
|
||||
|
@ -87,7 +87,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('spacer', {
|
||||
blockModel: Module.SpacerBlockModel,
|
||||
blockView: Module.SpacerBlockView
|
||||
|
@ -94,7 +94,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
App.registerBlockType('text', {
|
||||
blockModel: Module.TextBlockModel,
|
||||
blockView: Module.TextBlockView
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Courtesy of https://gist.github.com/jmeas/7992474cdb1c5672d88b
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
(function (root, factory) {
|
||||
var Marionette = require('backbone.marionette');
|
||||
var Radio = require('backbone.radio');
|
||||
var _ = require('underscore');
|
||||
|
@ -98,7 +98,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
App.on('start', function() {
|
||||
App.on('start', function () {
|
||||
// Prefetch post types
|
||||
Module.getPostTypes();
|
||||
});
|
||||
|
@ -13,8 +13,8 @@ define([
|
||||
// handled by other components.
|
||||
Module.NewsletterModel = SuperModel.extend({
|
||||
whitelisted: ['id', 'subject', 'preheader'],
|
||||
initialize: function() {
|
||||
this.on('change', function() {
|
||||
initialize: function () {
|
||||
this.on('change', function () {
|
||||
App.getChannel().trigger('autoSave');
|
||||
});
|
||||
},
|
||||
|
@ -29,7 +29,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('start', function(App) {
|
||||
App.on('start', function (App) {
|
||||
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
|
||||
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
|
||||
tooltipId: 'tooltip-designer-subject-line-ti',
|
||||
|
@ -93,7 +93,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
Module.saveTemplate = function(options) {
|
||||
Module.saveTemplate = function (options) {
|
||||
var promise = jQuery.Deferred();
|
||||
|
||||
promise.then(function (thumbnail) {
|
||||
@ -119,7 +119,7 @@ define([
|
||||
return promise;
|
||||
};
|
||||
|
||||
Module.exportTemplate = function(options) {
|
||||
Module.exportTemplate = function (options) {
|
||||
return Module.getThumbnail(
|
||||
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
||||
).then(function (thumbnail) {
|
||||
@ -152,7 +152,7 @@ define([
|
||||
'click .mailpoet_save_export': 'toggleExportTemplate',
|
||||
'click .mailpoet_export_template': 'exportTemplate'
|
||||
},
|
||||
initialize: function() {
|
||||
initialize: function () {
|
||||
App.getChannel().on('beforeEditorSave', this.beforeSave, this);
|
||||
App.getChannel().on('afterEditorSave', this.afterSave, this);
|
||||
},
|
||||
@ -167,7 +167,7 @@ define([
|
||||
// TODO: Add a loading animation instead
|
||||
this.$('.mailpoet_autosaved_at').text(MailPoet.I18n.t('saving'));
|
||||
},
|
||||
afterSave: function(json) {
|
||||
afterSave: function (json) {
|
||||
this.validateNewsletter(json);
|
||||
// Update 'Last saved timer'
|
||||
this.$('.mailpoet_editor_last_saved').removeClass('mailpoet_hidden');
|
||||
@ -188,7 +188,7 @@ define([
|
||||
hideSaveAsTemplate: function () {
|
||||
this.$('.mailpoet_save_as_template_container').addClass('mailpoet_hidden');
|
||||
},
|
||||
saveAsTemplate: function() {
|
||||
saveAsTemplate: function () {
|
||||
var templateName = this.$('.mailpoet_save_as_template_name').val();
|
||||
var templateDescription = this.$('.mailpoet_save_as_template_description').val();
|
||||
var that = this;
|
||||
@ -244,7 +244,7 @@ define([
|
||||
hideExportTemplate: function () {
|
||||
this.$('.mailpoet_export_template_container').addClass('mailpoet_hidden');
|
||||
},
|
||||
exportTemplate: function() {
|
||||
exportTemplate: function () {
|
||||
var templateName = this.$('.mailpoet_export_template_name').val();
|
||||
var templateDescription = this.$('.mailpoet_export_template_description').val();
|
||||
var that = this;
|
||||
@ -282,12 +282,12 @@ define([
|
||||
this.hideOptionContents();
|
||||
if (!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
|
||||
Module._cancelAutosave();
|
||||
Module.save().done(function() {
|
||||
Module.save().done(function () {
|
||||
window.location.href = App.getConfig().get('urls.send');
|
||||
});
|
||||
}
|
||||
},
|
||||
validateNewsletter: function(jsonObject) {
|
||||
validateNewsletter: function (jsonObject) {
|
||||
var contents;
|
||||
if (!App._contentContainer.isValid()) {
|
||||
this.showValidationError(App._contentContainer.validationError);
|
||||
@ -337,7 +337,7 @@ define([
|
||||
saveTimeout = undefined;
|
||||
};
|
||||
|
||||
Module.beforeExitWithUnsavedChanges = function(e) {
|
||||
Module.beforeExitWithUnsavedChanges = function (e) {
|
||||
var message;
|
||||
var event;
|
||||
if (saveTimeout) {
|
||||
@ -352,7 +352,7 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
var Application = App;
|
||||
Application.save = Module.save;
|
||||
Application.getChannel().on('autoSave', Module.autoSave);
|
||||
@ -362,7 +362,7 @@ define([
|
||||
Application.getChannel().reply('save', Application.save);
|
||||
});
|
||||
|
||||
App.on('start', function(App) {
|
||||
App.on('start', function (App) {
|
||||
var saveView = new Module.SaveView();
|
||||
App._appView.showChildView('bottomRegion', saveView);
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
'backbone.supermodel',
|
||||
'underscore',
|
||||
'jquery'
|
||||
], function(
|
||||
], function (
|
||||
App,
|
||||
CommunicationComponent,
|
||||
MailPoet,
|
||||
@ -51,7 +51,7 @@ define([
|
||||
Module.getLayoutWidgets = function () { return Module._layoutWidgets; };
|
||||
|
||||
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',
|
||||
@ -59,7 +59,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)');
|
||||
var $targetRegion = this.$el.find(event.target).closest('.mailpoet_sidebar_region');
|
||||
|
||||
@ -88,7 +88,7 @@ define([
|
||||
}
|
||||
}
|
||||
},
|
||||
initialize: function() {
|
||||
initialize: function () {
|
||||
jQuery(window)
|
||||
.on('resize', this.updateHorizontalScroll.bind(this))
|
||||
.on('scroll', this.updateHorizontalScroll.bind(this));
|
||||
@ -263,7 +263,7 @@ define([
|
||||
data: json
|
||||
}).always(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
}).done(function (response) {
|
||||
this.previewView = new Module.NewsletterPreviewView({
|
||||
previewUrl: response.meta.preview_url
|
||||
});
|
||||
@ -321,7 +321,7 @@ define([
|
||||
App.getChannel().request('save').always(function () {
|
||||
CommunicationComponent.previewNewsletter(data).always(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function() {
|
||||
}).done(function () {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterPreviewSent'),
|
||||
{ scroll: true }
|
||||
@ -360,7 +360,7 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(App) {
|
||||
App.on('before:start', function (App) {
|
||||
var Application = App;
|
||||
Application.registerWidget = Module.registerWidget;
|
||||
Application.getWidgets = Module.getWidgets;
|
||||
@ -368,7 +368,7 @@ define([
|
||||
Application.getLayoutWidgets = Module.getLayoutWidgets;
|
||||
});
|
||||
|
||||
App.on('start', function(App) {
|
||||
App.on('start', function (App) {
|
||||
var sidebarView = new SidebarView();
|
||||
|
||||
App._appView.showChildView('sidebarRegion', sidebarView);
|
||||
|
@ -83,7 +83,7 @@ define([
|
||||
this.setGlobalStyles(globalStyles);
|
||||
});
|
||||
|
||||
App.on('start', function(App) {
|
||||
App.on('start', function (App) {
|
||||
var stylesView = new Module.StylesView({ model: App.getGlobalStyles() });
|
||||
App._appView.showChildView('stylesRegion', stylesView);
|
||||
});
|
||||
|
@ -8,22 +8,22 @@
|
||||
* its placeholder into editor text.
|
||||
*/
|
||||
|
||||
/*jshint unused:false */
|
||||
/*global tinymce:true */
|
||||
tinymce.PluginManager.add('mailpoet_shortcodes', function(editor) {
|
||||
var appendLabelAndClose = function(shortcode) {
|
||||
/* jshint unused:false */
|
||||
/* global tinymce:true */
|
||||
tinymce.PluginManager.add('mailpoet_shortcodes', function (editor) {
|
||||
var appendLabelAndClose = function (shortcode) {
|
||||
editor.insertContent(shortcode);
|
||||
editor.windowManager.close();
|
||||
};
|
||||
var generateOnClickFunc = function(shortcode) {
|
||||
return function() {
|
||||
var generateOnClickFunc = function (shortcode) {
|
||||
return function () {
|
||||
appendLabelAndClose(shortcode);
|
||||
};
|
||||
};
|
||||
|
||||
editor.addButton('mailpoet_shortcodes', {
|
||||
icon: 'mailpoet_shortcodes',
|
||||
onclick: function() {
|
||||
onclick: function () {
|
||||
var shortcodes = [];
|
||||
var configShortcodes = editor.settings.mailpoet_shortcodes;
|
||||
var segment;
|
||||
|
@ -46,7 +46,7 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
|
||||
return this;
|
||||
},
|
||||
createNotice: function() {
|
||||
createNotice: function () {
|
||||
var onClose;
|
||||
var positionAfter;
|
||||
// clone element
|
||||
@ -177,7 +177,7 @@ define('notice', ['mailpoet', 'jquery'], function (mp, jQuery) {
|
||||
this.options.onOpen(this.element);
|
||||
}
|
||||
},
|
||||
hide: function(all) {
|
||||
hide: function (all) {
|
||||
var id;
|
||||
if (all !== undefined && all === true) {
|
||||
// all notices
|
||||
|
@ -18,7 +18,7 @@ function (
|
||||
$('form.mailpoet_form').each(function () {
|
||||
var form = $(this);
|
||||
|
||||
form.parsley().on('form:validated', function() {
|
||||
form.parsley().on('form:validated', function () {
|
||||
// clear messages
|
||||
form.find('.mailpoet_message > p').hide();
|
||||
|
||||
|
@ -51,7 +51,7 @@ define(
|
||||
jQuery('#mailpoet_sending_method_setup').fadeIn();
|
||||
}
|
||||
},
|
||||
tabs: function(tabStr) {
|
||||
tabs: function (tabStr) {
|
||||
// set default tab
|
||||
var tab = tabStr || 'mta';
|
||||
|
||||
|
@ -156,7 +156,7 @@ define(
|
||||
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
|
||||
subscriber_fields: subscriberFieldsContainerElement.val()
|
||||
})
|
||||
}).always(function() {
|
||||
}).always(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function (response) {
|
||||
var resultMessage = MailPoet.I18n.t('exportMessage')
|
||||
|
@ -243,7 +243,7 @@ define(
|
||||
api_key: mailChimpKeyInputElement.val(),
|
||||
lists: mailChimpListsContainerElement.find('select').val()
|
||||
}
|
||||
}).always(function() {
|
||||
}).always(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function (response) {
|
||||
window.importData.step1 = response.data;
|
||||
@ -340,7 +340,7 @@ define(
|
||||
email = test[1].trim();
|
||||
}
|
||||
// test for valid characters using WP's rule (https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/formatting.php#L2902)
|
||||
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email) ) {
|
||||
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email)) {
|
||||
return false;
|
||||
}
|
||||
return email;
|
||||
@ -618,7 +618,7 @@ define(
|
||||
name: segmentName,
|
||||
description: segmentDescription
|
||||
}
|
||||
}).done(function(response) {
|
||||
}).done(function (response) {
|
||||
var selected_values;
|
||||
window.mailpoetSegments.push({
|
||||
id: response.data.id,
|
||||
@ -769,7 +769,7 @@ define(
|
||||
title: MailPoet.I18n.t('addNewField'),
|
||||
template: jQuery('#form_template_field_form').html()
|
||||
});
|
||||
jQuery('#form_field_new').parsley().on('form:submit', function() {
|
||||
jQuery('#form_field_new').parsley().on('form:submit', function () {
|
||||
// get data
|
||||
var data = jQuery(this.$element).serializeObject();
|
||||
|
||||
@ -927,7 +927,7 @@ define(
|
||||
for (format in allowedDateFormats) {
|
||||
testedFormat = allowedDateFormats[format];
|
||||
if (Moment(firstRowData, testedFormat, true).isValid()) {
|
||||
validationRule = (typeof(testedFormat) === 'function') ?
|
||||
validationRule = (typeof (testedFormat) === 'function') ?
|
||||
'datetime' :
|
||||
testedFormat;
|
||||
// set validation on the column element
|
||||
|
Reference in New Issue
Block a user