merged master
This commit is contained in:
@@ -61,7 +61,7 @@ define([
|
||||
};
|
||||
},
|
||||
initialize: function() {
|
||||
base.BlockModel.prototype.initialize.apply(this);
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
this.fetchPosts();
|
||||
this.on('change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:titlePosition change:titleAlignment change:titleIsLink change:imagePadded change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider', this._scheduleFetchPosts, this);
|
||||
this.listenTo(this.get('readMoreButton'), 'change', this._scheduleFetchPosts);
|
||||
@@ -69,13 +69,12 @@ define([
|
||||
},
|
||||
fetchPosts: function() {
|
||||
var that = this;
|
||||
// TODO: Migrate to new AJAX queries
|
||||
//mailpoet_post_wpi('automated_latest_content.php', this.toJSON(), function(response) {
|
||||
//console.log('ALC fetched', arguments);
|
||||
//that.get('_container').get('blocks').reset(response, {parse: true});
|
||||
//}, function() {
|
||||
//console.log('ALC fetchPosts error', arguments);
|
||||
//});
|
||||
WordpressComponent.getTransformedPosts(this.toJSON()).done(function(content) {
|
||||
console.log('ALC fetched', arguments);
|
||||
that.get('_container').get('blocks').reset(content, {parse: true});
|
||||
}).fail(function(error) {
|
||||
console.log('ALC fetchPosts error', arguments);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Batch more changes during a specific time, instead of fetching
|
||||
@@ -101,6 +100,9 @@ define([
|
||||
toolsRegion: '.mailpoet_tools',
|
||||
postsRegion: '.mailpoet_automated_latest_content_block_posts',
|
||||
},
|
||||
events: _.extend(base.BlockView.prototype.events, {
|
||||
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings',
|
||||
}),
|
||||
onDragSubstituteBy: function() { return Module.AutomatedLatestContentWidgetView; },
|
||||
onRender: function() {
|
||||
var ContainerView = App.getBlockTypeView('container'),
|
||||
@@ -236,6 +238,7 @@ define([
|
||||
});
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
base.BlockSettingsView.prototype.onBeforeDestroy.apply(this, arguments);
|
||||
// Force close select2 if it hasn't closed yet
|
||||
this.$('.mailpoet_automated_latest_content_categories_and_tags').select2('close');
|
||||
},
|
||||
@@ -336,7 +339,10 @@ define([
|
||||
cloneOriginal: true,
|
||||
drop: function() {
|
||||
return new Module.AutomatedLatestContentBlockModel({}, { parse: true });
|
||||
}
|
||||
},
|
||||
onDrop: function(options) {
|
||||
options.droppedView.triggerMethod('showSettings');
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@@ -87,6 +87,9 @@ define([
|
||||
AugmentedView.apply(this, arguments);
|
||||
this.$el.addClass('mailpoet_editor_view_' + this.cid);
|
||||
},
|
||||
initialize: function() {
|
||||
this.on('showSettings', this.showSettings);
|
||||
},
|
||||
showTools: function(_event) {
|
||||
if (!this.showingToolsDisabled) {
|
||||
this.$('> .mailpoet_tools').show();
|
||||
@@ -104,6 +107,9 @@ define([
|
||||
this.showingToolsDisabled = true;
|
||||
this.hideTools();
|
||||
},
|
||||
showSettings: function(options) {
|
||||
this.toolsView.triggerMethod('showSettings', options);
|
||||
},
|
||||
/**
|
||||
* Defines drop behavior of BlockView instance
|
||||
*/
|
||||
@@ -141,6 +147,7 @@ define([
|
||||
|
||||
// Automatically cancel deletion
|
||||
this.on('hideTools', this.hideDeletionConfirmation, this);
|
||||
this.on('showSettings', this.changeSettings);
|
||||
},
|
||||
templateHelpers: function() {
|
||||
return {
|
||||
@@ -149,9 +156,9 @@ define([
|
||||
tools: this.tools,
|
||||
};
|
||||
},
|
||||
changeSettings: function() {
|
||||
changeSettings: function(options) {
|
||||
var ViewType = this.getSettingsView();
|
||||
(new ViewType({ model: this.model })).render();
|
||||
(new ViewType(_.extend({ model: this.model }, options || {}))).render();
|
||||
},
|
||||
showDeletionConfirmation: function() {
|
||||
this.$('.mailpoet_delete_block').addClass('mailpoet_delete_block_activated');
|
||||
@@ -182,7 +189,6 @@ define([
|
||||
});
|
||||
},
|
||||
close: function(event) {
|
||||
MailPoet.Modal.cancel();
|
||||
this.destroy();
|
||||
},
|
||||
changeField: function(field, event) {
|
||||
@@ -204,6 +210,9 @@ define([
|
||||
}
|
||||
this.model.set(field, value);
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
MailPoet.Modal.close();
|
||||
},
|
||||
});
|
||||
|
||||
Module.WidgetView = Marionette.ItemView.extend({
|
||||
|
@@ -35,9 +35,6 @@ define([
|
||||
Module.ImageBlockView = base.BlockView.extend({
|
||||
className: "mailpoet_block mailpoet_image_block mailpoet_droppable_block",
|
||||
getTemplate: function() { return templates.imageBlock; },
|
||||
initialize: function() {
|
||||
this.on('showSettings', this.showSettings);
|
||||
},
|
||||
onDragSubstituteBy: function() { return Module.ImageWidgetView; },
|
||||
templateHelpers: function() {
|
||||
return {
|
||||
@@ -56,29 +53,10 @@ define([
|
||||
this.$el.addClass('mailpoet_full_image');
|
||||
}
|
||||
},
|
||||
showSettings: function(options) {
|
||||
this.toolsView.triggerMethod('showSettings', options);
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
this.off('showSettings');
|
||||
},
|
||||
});
|
||||
|
||||
Module.ImageBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function() { return Module.ImageBlockSettingsView; },
|
||||
initialize: function() {
|
||||
base.BlockToolsView.prototype.initialize.apply(this, arguments);
|
||||
this.on('showSettings', this.changeSettings);
|
||||
},
|
||||
changeSettings: function(options) {
|
||||
(new Module.ImageBlockSettingsView({
|
||||
model: this.model,
|
||||
showImageManager: (options.showImageManager === true),
|
||||
})).render();
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
this.off('showSettings');
|
||||
},
|
||||
});
|
||||
|
||||
Module.ImageBlockSettingsView = base.BlockSettingsView.extend({
|
||||
@@ -349,6 +327,7 @@ define([
|
||||
this._mediaManager.open();
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
base.BlockSettingsView.prototype.onBeforeDestroy.apply(this, arguments);
|
||||
if (typeof this._mediaManager === 'object') {
|
||||
this._mediaManager.remove();
|
||||
}
|
||||
|
@@ -132,8 +132,8 @@ define([
|
||||
modelEvents: {},
|
||||
onDragSubstituteBy: function() { return Module.PostsWidgetView; },
|
||||
initialize: function() {
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
this.toolsView = new Module.PostsBlockToolsView({ model: this.model });
|
||||
this.on('showSettings', this.showSettings);
|
||||
this.model.reply('blockView', this.notifyAboutSelf, this);
|
||||
},
|
||||
onRender: function() {
|
||||
@@ -142,9 +142,6 @@ define([
|
||||
}
|
||||
this.trigger('showSettings');
|
||||
},
|
||||
showSettings: function(options) {
|
||||
this.toolsView.triggerMethod('showSettings', options);
|
||||
},
|
||||
notifyAboutSelf: function() {
|
||||
return this;
|
||||
},
|
||||
@@ -155,19 +152,6 @@ define([
|
||||
|
||||
Module.PostsBlockToolsView = base.BlockToolsView.extend({
|
||||
getSettingsView: function() { return Module.PostsBlockSettingsView; },
|
||||
initialize: function() {
|
||||
base.BlockToolsView.prototype.initialize.apply(this, arguments);
|
||||
this.on('showSettings', this.changeSettings);
|
||||
this.settingsView = new Module.PostsBlockSettingsView({ model: this.model });
|
||||
},
|
||||
changeSettings: function() {
|
||||
this.settingsView.render();
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
this.settingsView.destroy();
|
||||
this.off('showSettings');
|
||||
MailPoet.Modal.close();
|
||||
},
|
||||
});
|
||||
|
||||
Module.PostsBlockSettingsView = base.BlockSettingsView.extend({
|
||||
@@ -320,6 +304,7 @@ define([
|
||||
});
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
base.BlockSettingsView.prototype.onBeforeDestroy.apply(this, arguments);
|
||||
// Force close select2 if it hasn't closed yet
|
||||
this.$('.mailpoet_posts_categories_and_tags').select2('close');
|
||||
},
|
||||
|
@@ -22,10 +22,10 @@ define(
|
||||
|
||||
var messages = {
|
||||
updated: function() {
|
||||
MailPoet.Notice.success('Segment succesfully updated!');
|
||||
MailPoet.Notice.success('Segment successfully updated!');
|
||||
},
|
||||
created: function() {
|
||||
MailPoet.Notice.success('Segment succesfully added!');
|
||||
MailPoet.Notice.success('Segment successfully added!');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -51,4 +51,4 @@ define(
|
||||
|
||||
return SegmentForm;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@@ -42,10 +42,10 @@ define(
|
||||
|
||||
var messages = {
|
||||
updated: function() {
|
||||
MailPoet.Notice.success('Subscriber succesfully updated!');
|
||||
MailPoet.Notice.success('Subscriber successfully updated!');
|
||||
},
|
||||
created: function() {
|
||||
MailPoet.Notice.success('Subscriber succesfully added!');
|
||||
MailPoet.Notice.success('Subscriber successfully added!');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -71,4 +71,4 @@ define(
|
||||
|
||||
return SubscriberForm;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
Reference in New Issue
Block a user