Rename editor's modules to be anonymous
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/App', [
|
||||
define([
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
'backbone.supermodel',
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* For more check: http://marionettejs.com/docs/marionette.behaviors.html#behaviorslookup
|
||||
*/
|
||||
define('newsletter_editor/behaviors/behaviorsLookup', [
|
||||
define([
|
||||
'backbone.marionette',
|
||||
], function(Marionette) {
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Adds a color picker integration with the view
|
||||
*/
|
||||
define('newsletter_editor/behaviors/ColorPickerBehavior', [
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'spectrum',
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Allows CollectionView instances that use this behavior to act as drop zones and
|
||||
* accept droppables
|
||||
*/
|
||||
define('newsletter_editor/behaviors/ContainerDropZoneBehavior', [
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'underscore',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Allows View instances to be draggable.
|
||||
* Part of the drag&drop behavior.
|
||||
*/
|
||||
define('newsletter_editor/behaviors/DraggableBehavior', [
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'interact',
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Allows resizing elements within a block
|
||||
*/
|
||||
define('newsletter_editor/behaviors/ResizableBehavior', [
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
'interact',
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Allows sorting elements within a collection
|
||||
*/
|
||||
define('newsletter_editor/behaviors/SortableBehavior', [
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
], function(Marionette, BehaviorsLookup) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
* This block depends on blocks.button and blocks.divider for block model and
|
||||
* block settings view.
|
||||
*/
|
||||
define('newsletter_editor/blocks/automatedLatestContent', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -4,7 +4,7 @@
|
||||
* a BlockModel and a BlockView.
|
||||
* BlockToolsView, BlockSettingsView and BlockWidgetView are optional.
|
||||
*/
|
||||
define('newsletter_editor/blocks/base', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Button content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/button', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -3,7 +3,7 @@
|
||||
* This is a special kind of block, as it can contain content blocks, as well
|
||||
* as other containers.
|
||||
*/
|
||||
define('newsletter_editor/blocks/container', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Divider content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/divider', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Footer content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/footer', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Header content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/header', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Image content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/image', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -10,7 +10,7 @@
|
||||
* This block depends on blocks.button and blocks.divider for block model and
|
||||
* block settings view.
|
||||
*/
|
||||
define('newsletter_editor/blocks/posts', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Social icons content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/social', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Spacer content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/spacer', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Text content block
|
||||
*/
|
||||
define('newsletter_editor/blocks/text', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/components/config', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
], function(EditorApplication, Backbone) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/components/content', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/components/heading', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/components/save', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/components/sidebar', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('newsletter_editor/components/styles', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
|
@ -1,14 +1,9 @@
|
||||
define('newsletter_editor/components/wordpress', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone',
|
||||
'backbone.marionette',
|
||||
'mailpoet',
|
||||
'ajax'
|
||||
], function(EditorApplication, Backbone, Marionette, MailPoet) {
|
||||
|
||||
EditorApplication.module("components.wordpress", function(Module, App, Backbone, Marionette, $, _) {
|
||||
"use strict";
|
||||
'mailpoet'
|
||||
], function(EditorApplication, MailPoet) {
|
||||
|
||||
var Module = {};
|
||||
var postTypesCache,
|
||||
taxonomiesCache = [],
|
||||
termsCache = [];
|
||||
@ -54,9 +49,10 @@ define('newsletter_editor/components/wordpress', [
|
||||
return termsCache[key];
|
||||
};
|
||||
|
||||
App.on('start', function(options) {
|
||||
EditorApplication.on('start', function(options) {
|
||||
// Prefetch post types
|
||||
Module.getPostTypes();
|
||||
});
|
||||
});
|
||||
|
||||
return Module;
|
||||
});
|
||||
|
@ -38,7 +38,7 @@
|
||||
"export-loader": "webpack/exports-loader.git",
|
||||
"import-loader": "webpack/imports-loader.git",
|
||||
"expose-loader": "webpack/expose-loader.git",
|
||||
"rewire": "webpack/rewire.git",
|
||||
"amd-inject-loader": "latest",
|
||||
"chai": "2.2.0",
|
||||
"chai-jq": "0.0.8",
|
||||
"grunt": "^0.4.5",
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/automatedLatestContent', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/automatedLatestContent'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/button', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/button'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/container', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/container'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/divider', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/divider'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/footer', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/footer'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/header', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/header'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/image', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/image'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/posts', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/posts'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/social', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/social'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/spacer', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/spacer'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/blocks/text', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/blocks/text'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/components/config', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/config'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/components/content', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/content'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/components/heading', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/heading'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/components/save', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/save'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/components/sidebar', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/sidebar'
|
||||
], function(EditorApplication) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('test/newsletter_editor/components/config', [
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/config'
|
||||
], function(EditorApplication) {
|
||||
|
@ -0,0 +1,28 @@
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/wordpress'
|
||||
], function(EditorApplication, Wordpress) {
|
||||
|
||||
describe('getPostTypes', function() {
|
||||
it('fetches post types from the server', function() {
|
||||
var injector = require('amd-inject-loader!newsletter_editor/components/wordpress');
|
||||
var module = injector({
|
||||
"mailpoet": {
|
||||
Ajax: {
|
||||
post: function() {
|
||||
var deferred = jQuery.Deferred();
|
||||
deferred.resolve({
|
||||
'post': 'val1',
|
||||
'page': 'val2',
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
module.getPostTypes().done(function(types) {
|
||||
expect(types).to.include.members(['val1', 'val2']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
define('testAjax', [ 'mailpoet', 'ajax'], function(MailPoet) {
|
||||
define(['mailpoet', 'ajax'], function(MailPoet) {
|
||||
describe('Ajax submodule', function() {
|
||||
it('has a version', function() {
|
||||
expect(MailPoet.Ajax.version).to.be.a('number');
|
||||
|
Reference in New Issue
Block a user