Switch post display types using backbone views, instead of manually

[MAILPOET-2491]
This commit is contained in:
Jan Jakeš
2020-02-12 14:24:07 +01:00
committed by Jack Kitterhing
parent d592e9e1a6
commit 515131e55d
2 changed files with 12 additions and 46 deletions

View File

@ -307,33 +307,14 @@ Module.AutomatedLatestContentLayoutBlockSettingsView = base.BlockSettingsView.ex
changeDisplayType: function (event) {
var value = jQuery(event.target).val();
if (value === 'titleOnly') {
this.$('.mailpoet_automated_latest_content_title_as_list').removeClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_image_full_width_option').addClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_image_separator').addClass('mailpoet_hidden');
} else {
this.$('.mailpoet_automated_latest_content_title_as_list').addClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_image_full_width_option').removeClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_image_separator').removeClass('mailpoet_hidden');
// Reset titleFormat if it was set to List when switching away from displayType=titleOnly
if (this.model.get('titleFormat') === 'ul') {
this.model.set('titleFormat', 'h1');
this.$('.mailpoet_automated_latest_content_title_format').val(['h1']);
this.$('.mailpoet_automated_latest_content_title_as_link').removeClass('mailpoet_hidden');
}
}
if (value === 'excerpt') {
this.$('.mailpoet_automated_latest_content_featured_image_position_container').removeClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_title_position_separator').removeClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_title_position').removeClass('mailpoet_hidden');
} else {
this.$('.mailpoet_automated_latest_content_featured_image_position_container').addClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_title_position_separator').addClass('mailpoet_hidden');
this.$('.mailpoet_automated_latest_content_title_position').addClass('mailpoet_hidden');
// Reset titleFormat if it was set to List when switching away from displayType=titleOnly
if (value !== 'titleOnly' && this.model.get('titleFormat') === 'ul') {
this.model.set('titleFormat', 'h1');
this.$('.mailpoet_automated_latest_content_title_format').val(['h1']);
this.$('.mailpoet_automated_latest_content_title_as_link').removeClass('mailpoet_hidden');
}
this.changeField('displayType', event);
this.render();
},
changeTitleFormat: function (event) {
var value = jQuery(event.target).val();

View File

@ -533,30 +533,15 @@ PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({
},
changeDisplayType: function (event) {
var value = jQuery(event.target).val();
if (value === 'titleOnly') {
this.$('.mailpoet_posts_title_as_list').removeClass('mailpoet_hidden');
this.$('.mailpoet_posts_image_full_width_option').addClass('mailpoet_hidden');
this.$('.mailpoet_posts_image_separator').addClass('mailpoet_hidden');
} else {
this.$('.mailpoet_posts_title_as_list').addClass('mailpoet_hidden');
this.$('.mailpoet_posts_image_full_width_option').removeClass('mailpoet_hidden');
this.$('.mailpoet_posts_image_separator').removeClass('mailpoet_hidden');
// Reset titleFormat if it was set to List when switching away from displayType=titleOnly
if (this.model.get('titleFormat') === 'ul') {
this.model.set('titleFormat', 'h1');
this.$('.mailpoet_posts_title_format').val(['h1']);
this.$('.mailpoet_posts_title_as_link').removeClass('mailpoet_hidden');
}
// Reset titleFormat if it was set to List when switching away from displayType=titleOnly
if (value !== 'titleOnly' && this.model.get('titleFormat') === 'ul') {
this.model.set('titleFormat', 'h1');
this.$('.mailpoet_posts_title_format').val(['h1']);
this.$('.mailpoet_posts_title_as_link').removeClass('mailpoet_hidden');
}
if (value === 'excerpt') {
this.$('.mailpoet_posts_featured_image_position_container').removeClass('mailpoet_hidden');
} else {
this.$('.mailpoet_posts_featured_image_position_container').addClass('mailpoet_hidden');
}
this.changeField('displayType', event);
this.render();
},
changeTitleFormat: function (event) {
var value = jQuery(event.target).val();