Rename editor's modules to be anonymous

This commit is contained in:
Tautvidas Sipavičius
2015-09-07 16:01:25 +03:00
parent 9c6955c8cf
commit 2aac4f2a70
46 changed files with 119 additions and 95 deletions

View File

@ -1,4 +1,4 @@
define('newsletter_editor/App', [ define([
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',
'backbone.supermodel', 'backbone.supermodel',

View File

@ -4,7 +4,7 @@
* *
* For more check: http://marionettejs.com/docs/marionette.behaviors.html#behaviorslookup * For more check: http://marionettejs.com/docs/marionette.behaviors.html#behaviorslookup
*/ */
define('newsletter_editor/behaviors/behaviorsLookup', [ define([
'backbone.marionette', 'backbone.marionette',
], function(Marionette) { ], function(Marionette) {

View File

@ -3,7 +3,7 @@
* *
* Adds a color picker integration with the view * Adds a color picker integration with the view
*/ */
define('newsletter_editor/behaviors/ColorPickerBehavior', [ define([
'backbone.marionette', 'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'spectrum', 'spectrum',

View File

@ -5,7 +5,7 @@
* Allows CollectionView instances that use this behavior to act as drop zones and * Allows CollectionView instances that use this behavior to act as drop zones and
* accept droppables * accept droppables
*/ */
define('newsletter_editor/behaviors/ContainerDropZoneBehavior', [ define([
'backbone.marionette', 'backbone.marionette',
'underscore', 'underscore',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',

View File

@ -4,7 +4,7 @@
* Allows View instances to be draggable. * Allows View instances to be draggable.
* Part of the drag&drop behavior. * Part of the drag&drop behavior.
*/ */
define('newsletter_editor/behaviors/DraggableBehavior', [ define([
'backbone.marionette', 'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'interact', 'interact',

View File

@ -3,7 +3,7 @@
* *
* Allows resizing elements within a block * Allows resizing elements within a block
*/ */
define('newsletter_editor/behaviors/ResizableBehavior', [ define([
'backbone.marionette', 'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'interact', 'interact',

View File

@ -3,7 +3,7 @@
* *
* Allows sorting elements within a collection * Allows sorting elements within a collection
*/ */
define('newsletter_editor/behaviors/SortableBehavior', [ define([
'backbone.marionette', 'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
], function(Marionette, BehaviorsLookup) { ], function(Marionette, BehaviorsLookup) {

View File

@ -6,7 +6,7 @@
* This block depends on blocks.button and blocks.divider for block model and * This block depends on blocks.button and blocks.divider for block model and
* block settings view. * block settings view.
*/ */
define('newsletter_editor/blocks/automatedLatestContent', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -4,7 +4,7 @@
* a BlockModel and a BlockView. * a BlockModel and a BlockView.
* BlockToolsView, BlockSettingsView and BlockWidgetView are optional. * BlockToolsView, BlockSettingsView and BlockWidgetView are optional.
*/ */
define('newsletter_editor/blocks/base', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Button content block * Button content block
*/ */
define('newsletter_editor/blocks/button', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -3,7 +3,7 @@
* This is a special kind of block, as it can contain content blocks, as well * This is a special kind of block, as it can contain content blocks, as well
* as other containers. * as other containers.
*/ */
define('newsletter_editor/blocks/container', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Divider content block * Divider content block
*/ */
define('newsletter_editor/blocks/divider', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Footer content block * Footer content block
*/ */
define('newsletter_editor/blocks/footer', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Header content block * Header content block
*/ */
define('newsletter_editor/blocks/header', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Image content block * Image content block
*/ */
define('newsletter_editor/blocks/image', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -10,7 +10,7 @@
* This block depends on blocks.button and blocks.divider for block model and * This block depends on blocks.button and blocks.divider for block model and
* block settings view. * block settings view.
*/ */
define('newsletter_editor/blocks/posts', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Social icons content block * Social icons content block
*/ */
define('newsletter_editor/blocks/social', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Spacer content block * Spacer content block
*/ */
define('newsletter_editor/blocks/spacer', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,7 +1,7 @@
/** /**
* Text content block * Text content block
*/ */
define('newsletter_editor/blocks/text', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,4 +1,4 @@
define('newsletter_editor/components/config', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
], function(EditorApplication, Backbone) { ], function(EditorApplication, Backbone) {

View File

@ -1,4 +1,4 @@
define('newsletter_editor/components/content', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,4 +1,4 @@
define('newsletter_editor/components/heading', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,4 +1,4 @@
define('newsletter_editor/components/save', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,4 +1,4 @@
define('newsletter_editor/components/sidebar', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,4 +1,4 @@
define('newsletter_editor/components/styles', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',

View File

@ -1,14 +1,9 @@
define('newsletter_editor/components/wordpress', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'backbone', 'mailpoet'
'backbone.marionette', ], function(EditorApplication, MailPoet) {
'mailpoet',
'ajax'
], function(EditorApplication, Backbone, Marionette, MailPoet) {
EditorApplication.module("components.wordpress", function(Module, App, Backbone, Marionette, $, _) {
"use strict";
var Module = {};
var postTypesCache, var postTypesCache,
taxonomiesCache = [], taxonomiesCache = [],
termsCache = []; termsCache = [];
@ -54,9 +49,10 @@ define('newsletter_editor/components/wordpress', [
return termsCache[key]; return termsCache[key];
}; };
App.on('start', function(options) { EditorApplication.on('start', function(options) {
// Prefetch post types // Prefetch post types
Module.getPostTypes(); Module.getPostTypes();
}); });
});
return Module;
}); });

View File

@ -38,7 +38,7 @@
"export-loader": "webpack/exports-loader.git", "export-loader": "webpack/exports-loader.git",
"import-loader": "webpack/imports-loader.git", "import-loader": "webpack/imports-loader.git",
"expose-loader": "webpack/expose-loader.git", "expose-loader": "webpack/expose-loader.git",
"rewire": "webpack/rewire.git", "amd-inject-loader": "latest",
"chai": "2.2.0", "chai": "2.2.0",
"chai-jq": "0.0.8", "chai-jq": "0.0.8",
"grunt": "^0.4.5", "grunt": "^0.4.5",

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/automatedLatestContent', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/automatedLatestContent' 'newsletter_editor/blocks/automatedLatestContent'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/button', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/button' 'newsletter_editor/blocks/button'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/container', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/container' 'newsletter_editor/blocks/container'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/divider', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/divider' 'newsletter_editor/blocks/divider'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/footer', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/footer' 'newsletter_editor/blocks/footer'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/header', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/header' 'newsletter_editor/blocks/header'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/image', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/image' 'newsletter_editor/blocks/image'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/posts', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/posts' 'newsletter_editor/blocks/posts'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/social', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/social' 'newsletter_editor/blocks/social'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/spacer', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/spacer' 'newsletter_editor/blocks/spacer'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/blocks/text', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/text' 'newsletter_editor/blocks/text'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/components/config', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/components/config' 'newsletter_editor/components/config'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/components/content', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/components/content' 'newsletter_editor/components/content'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/components/heading', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/components/heading' 'newsletter_editor/components/heading'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/components/save', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/components/save' 'newsletter_editor/components/save'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/components/sidebar', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/components/sidebar' 'newsletter_editor/components/sidebar'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -1,4 +1,4 @@
define('test/newsletter_editor/components/config', [ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/components/config' 'newsletter_editor/components/config'
], function(EditorApplication) { ], function(EditorApplication) {

View File

@ -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']);
});
});
});
});

View File

@ -1,4 +1,4 @@
define('testAjax', [ 'mailpoet', 'ajax'], function(MailPoet) { define(['mailpoet', 'ajax'], function(MailPoet) {
describe('Ajax submodule', function() { describe('Ajax submodule', function() {
it('has a version', function() { it('has a version', function() {
expect(MailPoet.Ajax.version).to.be.a('number'); expect(MailPoet.Ajax.version).to.be.a('number');