Fix vendor asset loading, add initial newsletter data

This commit is contained in:
Tautvidas Sipavičius
2015-08-21 13:24:06 +03:00
parent 40507d2cad
commit c1d6f9ba44
22 changed files with 1147 additions and 129 deletions

View File

@ -4,6 +4,7 @@ class RoboFile extends \Robo\Tasks {
private $css_files = array(
'assets/css/src/admin.styl',
'assets/css/src/newsletter_editor/newsletter_editor.styl',
'assets/css/src/public.styl',
'assets/css/src/rtl.styl',
'assets/css/src/newsletter_editor/newsletter_editor.styl'

View File

@ -1,3 +1,7 @@
// Vendor CSS
@require 'select2/select2.css'
@require 'spectrum-colorpicker/spectrum.css'
// Bootstrapping
@require 'mixins/border-radius'
@require 'mixins/box-shadow'

View File

@ -9,10 +9,9 @@
define('newsletter_editor/blocks/automatedLatestContent', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.automatedLatestContent", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -7,18 +7,17 @@
define('newsletter_editor/blocks/base', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
'modal',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.base", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
var AugmentedView = Marionette.LayoutView.extend({});
Module.BlockModel = SuperModel.extend({
Module.BlockModel = Backbone.SuperModel.extend({
stale: [], // Attributes to be removed upon saving
initialize: function() {
var that = this;
@ -30,14 +29,14 @@ define('newsletter_editor/blocks/base', [
var defaults = (_.isObject(configDefaults) && _.isFunction(configDefaults.toJSON)) ? configDefaults.toJSON() : configDefaults;
// Patch the resulting JSON object and fix it's constructors to be Object.
// Otherwise SuperModel interprets it not as a simpleObject
// Otherwise Backbone.SuperModel interprets it not as a simpleObject
// and misbehaves
// TODO: Investigate for a better solution
return JSON.parse(JSON.stringify(jQuery.extend(blockDefaults, defaults || {})));
},
toJSON: function() {
// Remove stale attributes from resulting JSON object
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
return _.omit(Backbone.SuperModel.prototype.toJSON.call(this), this.stale);
},
});

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/button', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.button", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -6,10 +6,9 @@
define('newsletter_editor/blocks/container', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.container", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/divider', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.divider", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/footer', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.footer", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
@ -54,37 +53,37 @@ define('newsletter_editor/blocks/footer', [
},
attachTextEditor: function() {
var that = this;
this.$('.mailpoet_content').tinymce({
inline: true,
//this.$('.mailpoet_content').tinymce({
//inline: true,
menubar: false,
toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
//menubar: false,
//toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
invalid_elements: "script",
style_formats: [
{title: 'Paragraph', block: 'p'},
],
//valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
//invalid_elements: "script",
//style_formats: [
//{title: 'Paragraph', block: 'p'},
//],
plugins: "wplink textcolor mailpoet_custom_fields",
//plugins: "wplink textcolor mailpoet_custom_fields",
setup: function(editor) {
editor.on('change', function(e) {
that.model.set('text', editor.getContent());
});
//setup: function(editor) {
//editor.on('change', function(e) {
//that.model.set('text', editor.getContent());
//});
editor.on('focus', function(e) {
that.disableShowingTools();
});
//editor.on('focus', function(e) {
//that.disableShowingTools();
//});
editor.on('blur', function(e) {
that.enableShowingTools();
});
},
//editor.on('blur', function(e) {
//that.enableShowingTools();
//});
//},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
});
//mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
//mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
//});
},
});

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/header', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.header", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
@ -54,37 +53,37 @@ define('newsletter_editor/blocks/header', [
},
attachTextEditor: function() {
var that = this;
this.$('.mailpoet_content').tinymce({
inline: true,
//this.$('.mailpoet_content').tinymce({
//inline: true,
menubar: false,
toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
//menubar: false,
//toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
invalid_elements: "script",
style_formats: [
{title: 'Paragraph', block: 'p'},
],
//valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
//invalid_elements: "script",
//style_formats: [
//{title: 'Paragraph', block: 'p'},
//],
plugins: "wplink textcolor mailpoet_custom_fields",
//plugins: "wplink textcolor mailpoet_custom_fields",
setup: function(editor) {
editor.on('change', function(e) {
that.model.set('text', editor.getContent());
});
//setup: function(editor) {
//editor.on('change', function(e) {
//that.model.set('text', editor.getContent());
//});
editor.on('focus', function(e) {
that.disableShowingTools();
});
//editor.on('focus', function(e) {
//that.disableShowingTools();
//});
editor.on('blur', function(e) {
that.enableShowingTools();
});
},
//editor.on('blur', function(e) {
//that.enableShowingTools();
//});
//},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
});
//mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
//mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
//});
},
});

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/image', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.image", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -13,10 +13,9 @@
define('newsletter_editor/blocks/posts', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.posts", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/social', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.social", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
@ -15,7 +14,7 @@ define('newsletter_editor/blocks/social', [
var base = App.module('blocks.base'),
SocialBlockSettingsIconSelectorView, SocialBlockSettingsIconView, SocialBlockSettingsStylesView;
Module.SocialIconModel = SuperModel.extend({
Module.SocialIconModel = Backbone.SuperModel.extend({
defaults: function() {
var defaultValues = App.getConfig().get('socialIcons.custom');
return {

View File

@ -4,10 +4,9 @@
define('newsletter_editor/blocks/spacer', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet) {
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("blocks.spacer", function(Module, App, Backbone, Marionette, $, _) {
"use strict";

View File

@ -4,13 +4,12 @@
define('newsletter_editor/blocks/text', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'mailpoet',
'jquery',
//'tinymce',
//'jquery.tinymce',
], function(EditorApplication, Backbone, SuperModel, Marionette, MailPoet, jQuery, TinyMCE) {
], function(EditorApplication, Backbone, Marionette, MailPoet, jQuery, TinyMCE) {
EditorApplication.module("blocks.text", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
@ -51,43 +50,43 @@ define('newsletter_editor/blocks/text', [
attachTextEditor: function() {
var that = this;
if (!this.renderOptions.disableTextEditor) {
this.$('.mailpoet_content').tinymce({
inline: true,
//this.$('.mailpoet_content').tinymce({
//inline: true,
menubar: false,
toolbar1: "styleselect bold italic forecolor | link unlink",
toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_custom_fields",
//menubar: false,
//toolbar1: "styleselect bold italic forecolor | link unlink",
//toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_custom_fields",
//forced_root_block: 'p',
valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
invalid_elements: "script",
style_formats: [
{title: 'Heading 1', block: 'h1'},
{title: 'Heading 2', block: 'h2'},
{title: 'Heading 3', block: 'h3'},
////forced_root_block: 'p',
//valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
//invalid_elements: "script",
//style_formats: [
//{title: 'Heading 1', block: 'h1'},
//{title: 'Heading 2', block: 'h2'},
//{title: 'Heading 3', block: 'h3'},
{title: 'Paragraph', block: 'p'},
],
//{title: 'Paragraph', block: 'p'},
//],
plugins: "wplink code textcolor mailpoet_custom_fields",
//plugins: "wplink code textcolor mailpoet_custom_fields",
setup: function(editor) {
editor.on('change', function(e) {
that.model.set('text', editor.getContent());
});
//setup: function(editor) {
//editor.on('change', function(e) {
//that.model.set('text', editor.getContent());
//});
editor.on('focus', function(e) {
that.disableShowingTools();
});
//editor.on('focus', function(e) {
//that.disableShowingTools();
//});
editor.on('blur', function(e) {
that.enableShowingTools();
});
},
//editor.on('blur', function(e) {
//that.enableShowingTools();
//});
//},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
});
//mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
//mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
//});
}
},
});

View File

@ -1,13 +1,12 @@
define('newsletter_editor/components/config', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
], function(EditorApplication, Backbone, SuperModel) {
], function(EditorApplication, Backbone) {
EditorApplication.module("components.config", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
Module.ConfigModel = SuperModel.extend({
Module.ConfigModel = Backbone.SuperModel.extend({
defaults: {
availableStyles: {},
socialIcons: {},

View File

@ -1,9 +1,8 @@
define('newsletter_editor/components/content', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
], function(EditorApplication, Backbone, SuperModel, Marionette) {
], function(EditorApplication, Backbone, Marionette) {
EditorApplication.module("components.content", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
@ -11,7 +10,7 @@ define('newsletter_editor/components/content', [
// Holds newsletter entry fields, such as subject or creation datetime.
// Does not hold newsletter content nor newsletter styles, those are
// handled by other components.
Module.NewsletterModel = SuperModel.extend({
Module.NewsletterModel = Backbone.SuperModel.extend({
stale: ['data', 'styles'],
initialize: function(options) {
this.on('change', function() {
@ -20,7 +19,7 @@ define('newsletter_editor/components/content', [
},
toJSON: function() {
// Remove stale attributes from resulting JSON object
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
return _.omit(Backbone.SuperModel.prototype.toJSON.call(this), this.stale);
},
});
@ -63,7 +62,7 @@ define('newsletter_editor/components/content', [
App.toJSON = Module.toJSON;
App.getNewsletter = Module.getNewsletter;
Module.newsletter = new Module.NewsletterModel(options.newsletter);
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['data', 'styles']));
});
App.on('start', function(options) {

View File

@ -1,17 +1,16 @@
define('newsletter_editor/components/sidebar', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
'sticky-kit',
], function(EditorApplication, Backbone, SuperModel, Marionette) {
], function(EditorApplication, Backbone, Marionette) {
EditorApplication.module("components.sidebar", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
// Widget handlers for use to create new content blocks via drag&drop
Module._contentWidgets = new (Backbone.Collection.extend({
model: SuperModel.extend({
model: Backbone.SuperModel.extend({
defaults: {
name: '',
priority: 100,
@ -25,7 +24,7 @@ define('newsletter_editor/components/sidebar', [
// Layout widget handlers for use to create new layout blocks via drag&drop
Module._layoutWidgets = new (Backbone.Collection.extend({
model: SuperModel.extend({
model: Backbone.SuperModel.extend({
defaults: {
name: '',
priority: 100,

View File

@ -1,14 +1,13 @@
define('newsletter_editor/components/styles', [
'newsletter_editor/App',
'backbone',
'backbone.supermodel',
'backbone.marionette',
], function(EditorApplication, Backbone, SuperModel, Marionette) {
], function(EditorApplication, Backbone, Marionette) {
EditorApplication.module("components.styles", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
Module.StylesModel = SuperModel.extend({
Module.StylesModel = Backbone.SuperModel.extend({
defaults: {
text: {
fontColor: '#000000',
@ -53,7 +52,7 @@ define('newsletter_editor/components/styles', [
},
});
Module._globalStyles = new SuperModel();
Module._globalStyles = new Backbone.SuperModel();
Module.getGlobalStyles = function() {
return Module._globalStyles;
};

View File

@ -35,6 +35,9 @@
"devDependencies": {
"babel-core": "^5.8.22",
"babel-loader": "^5.3.2",
"export-loader": "latest",
"import-loader": "latest",
"expose-loader": "latest",
"chai": "2.2.0",
"chai-jq": "0.0.8",
"grunt": "^0.4.5",

View File

@ -24,8 +24,7 @@
<!-- javascripts -->
<%= javascript(
'vendor.js',
'mailpoet.js',
'admin.js'
'mailpoet.js'
)%>
<!-- handlebars templates -->

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,8 @@ baseConfig = {
alias: {
'handlebars': 'handlebars/dist/handlebars.js',
'backbone.marionette': 'backbone.marionette/lib/backbone.marionette',
'backbone.supermodel$': 'backbone.supermodel/build/backbone.supermodel.js',
'sticky-kit': 'sticky-kit/jquery.sticky-kit',
//'tinymce': 'tinymce/tinymce.jquery',
//'jquery.tinymce': 'tinymce/jquery.tinymce.min.js',
}
},
node: {
@ -31,6 +30,22 @@ baseConfig = {
{
test: /\.jsx$/,
loader: 'babel-loader'
},
{
include: require.resolve('backbone'),
loader: 'expose-loader?Backbone',
},
{
include: require.resolve('underscore'),
loader: 'expose-loader?_',
},
{
include: require.resolve('backbone.supermodel'),
loader: 'imports-loader?Backbone=backbone!exports-loader?Backbone.SuperModel',
},
{
include: require.resolve('handlebars'),
loader: 'expose-loader?Handlebars',
}
]
}
@ -54,7 +69,7 @@ config.push(_.extend({}, baseConfig, {
'underscore',
'backbone',
'backbone.marionette',
'backbone.supermodel/build/backbone.supermodel.amd',
'backbone.supermodel',
'interact.js',
'backbone.radio',
//'moment-with-locales',