Replace deprecated event shorthands [MAILPOET-3386]
This commit is contained in:
@@ -3,12 +3,12 @@ import { camelCase } from 'lodash';
|
||||
|
||||
jQuery(($) => {
|
||||
$(() => {
|
||||
const previewForm = $('div.mailpoet_form[data-is-preview="1"]');
|
||||
if (!previewForm.length) {
|
||||
const $previewForm = $('div.mailpoet_form[data-is-preview="1"]');
|
||||
if (!$previewForm.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
previewForm.submit((e) => { e.preventDefault(); return false; });
|
||||
$previewForm.on('submit', (e) => { e.preventDefault(); return false; });
|
||||
|
||||
const toggleClass = (form, from, to): void => {
|
||||
form.removeClass(from);
|
||||
@@ -21,7 +21,7 @@ jQuery(($) => {
|
||||
return;
|
||||
}
|
||||
// Allow message processing only when send from editor's origin
|
||||
const editorUrl = new URL(previewForm.data('editor-url'));
|
||||
const editorUrl = new URL($previewForm.data('editor-url'));
|
||||
if (editorUrl.origin !== event.origin) {
|
||||
return;
|
||||
}
|
||||
@@ -39,10 +39,10 @@ jQuery(($) => {
|
||||
const unit = width.unit === 'pixel' ? 'px' : '%';
|
||||
const newWidth = `${width.value}${unit}`;
|
||||
if (formType === 'fixed_bar') {
|
||||
const formElement = previewForm.find('form.mailpoet_form');
|
||||
const formElement = $previewForm.find('form.mailpoet_form');
|
||||
formElement.css('width', newWidth);
|
||||
} else {
|
||||
previewForm.css('width', newWidth);
|
||||
$previewForm.css('width', newWidth);
|
||||
if (unit === 'px') { // Update others container width to render full pixel size
|
||||
$('#mailpoet_widget_preview #sidebar').css('width', newWidth);
|
||||
} else { // Reset container size to default render percent size
|
||||
@@ -58,9 +58,9 @@ jQuery(($) => {
|
||||
|
||||
const animation = event.data.formSettings?.formPlacement?.[placementName]?.animation;
|
||||
if (animation !== '' && allowAnimation) {
|
||||
previewForm.removeClass((index, className) => (className.match(/(^|\s)mailpoet_form_animation\S+/g) || []).join(' '));
|
||||
setTimeout(() => previewForm.addClass(`mailpoet_form_animation_${animation}`));
|
||||
toggleClass(previewForm.prev('.mailpoet_form_popup_overlay'), 'mailpoet_form_overlay_animation', 'mailpoet_form_overlay_animation');
|
||||
$previewForm.removeClass((index, className) => (className.match(/(^|\s)mailpoet_form_animation\S+/g) || []).join(' '));
|
||||
setTimeout(() => $previewForm.addClass(`mailpoet_form_animation_${animation}`));
|
||||
toggleClass($previewForm.prev('.mailpoet_form_popup_overlay'), 'mailpoet_form_overlay_animation', 'mailpoet_form_overlay_animation');
|
||||
}
|
||||
|
||||
const position = event.data.formSettings?.formPlacement?.[placementName]?.position;
|
||||
@@ -75,25 +75,25 @@ jQuery(($) => {
|
||||
}
|
||||
|
||||
if (formType === 'slide_in') {
|
||||
if (previewForm.hasClass('mailpoet_form_position_left') && position === 'right') {
|
||||
toggleClass(previewForm, 'mailpoet_form_position_left', 'mailpoet_form_position_right');
|
||||
} else if (previewForm.hasClass('mailpoet_form_position_right') && position === 'left') {
|
||||
toggleClass(previewForm, 'mailpoet_form_position_right', 'mailpoet_form_position_left');
|
||||
if ($previewForm.hasClass('mailpoet_form_position_left') && position === 'right') {
|
||||
toggleClass($previewForm, 'mailpoet_form_position_left', 'mailpoet_form_position_right');
|
||||
} else if ($previewForm.hasClass('mailpoet_form_position_right') && position === 'left') {
|
||||
toggleClass($previewForm, 'mailpoet_form_position_right', 'mailpoet_form_position_left');
|
||||
}
|
||||
}
|
||||
|
||||
if (formType === 'fixed_bar') {
|
||||
if (previewForm.hasClass('mailpoet_form_position_bottom') && position === 'top') {
|
||||
toggleClass(previewForm, 'mailpoet_form_position_bottom', 'mailpoet_form_position_top');
|
||||
} else if (previewForm.hasClass('mailpoet_form_position_top') && position === 'bottom') {
|
||||
toggleClass(previewForm, 'mailpoet_form_position_top', 'mailpoet_form_position_bottom');
|
||||
if ($previewForm.hasClass('mailpoet_form_position_bottom') && position === 'top') {
|
||||
toggleClass($previewForm, 'mailpoet_form_position_bottom', 'mailpoet_form_position_top');
|
||||
} else if ($previewForm.hasClass('mailpoet_form_position_top') && position === 'bottom') {
|
||||
toggleClass($previewForm, 'mailpoet_form_position_top', 'mailpoet_form_position_bottom');
|
||||
}
|
||||
}
|
||||
|
||||
// Detect tight container
|
||||
previewForm.removeClass('mailpoet_form_tight_container');
|
||||
if (previewForm.width() < 400) {
|
||||
previewForm.addClass('mailpoet_form_tight_container');
|
||||
$previewForm.removeClass('mailpoet_form_tight_container');
|
||||
if ($previewForm.width() < 400) {
|
||||
$previewForm.addClass('mailpoet_form_tight_container');
|
||||
}
|
||||
};
|
||||
window.addEventListener('message', updateForm, false);
|
||||
|
@@ -423,11 +423,11 @@ MailPoet.Modal = {
|
||||
},
|
||||
focus: function () {
|
||||
if (this.options.type === 'popup') {
|
||||
jQuery('#mailpoet_' + this.options.type).focus();
|
||||
jQuery('#mailpoet_' + this.options.type).trigger('focus');
|
||||
} else {
|
||||
// panel and subpanel
|
||||
jQuery('#mailpoet_' + this.options.type + ' .mailpoet_panel_wrapper')
|
||||
.filter(':visible').focus();
|
||||
.filter(':visible').trigger('focus');
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
@@ -190,22 +190,22 @@ jQuery(function () {
|
||||
jQuery('#progressbar').progressbar({ value: 0 });
|
||||
|
||||
// Import button
|
||||
jQuery('#import').click(function () {
|
||||
jQuery('#import').on('click', function () {
|
||||
MailPoet.MP2Migrator.startImport();
|
||||
});
|
||||
|
||||
// Stop import button
|
||||
jQuery('#stop-import').click(function () {
|
||||
jQuery('#stop-import').on('click', function () {
|
||||
MailPoet.MP2Migrator.stopImport();
|
||||
});
|
||||
|
||||
// Skip import link
|
||||
jQuery('#skip-import').click(function () {
|
||||
jQuery('#skip-import').on('click', function () {
|
||||
MailPoet.MP2Migrator.skipImport();
|
||||
});
|
||||
|
||||
// Go to welcome page
|
||||
jQuery('#goto-welcome').click(function () {
|
||||
jQuery('#goto-welcome').on('click', function () {
|
||||
MailPoet.MP2Migrator.gotoWelcomePage();
|
||||
});
|
||||
|
||||
|
@@ -242,7 +242,7 @@ Module.ContainerBlockView = base.BlockView.extend({
|
||||
that.$el.addClass('mailpoet_container_layer_active');
|
||||
$toggleButton.addClass('mailpoet_container_layer_active');
|
||||
$container.addClass('mailpoet_layer_highlight');
|
||||
$overlay.click(disableContainerLayer);
|
||||
$overlay.on('click', disableContainerLayer);
|
||||
$overlay.show();
|
||||
};
|
||||
if ($toggleButton.hasClass('mailpoet_container_layer_active')) {
|
||||
|
@@ -143,7 +143,7 @@ jQuery(($) => {
|
||||
Cookies.set('popup_form_dismissed', '1', { expires: 365, path: '/' });
|
||||
};
|
||||
|
||||
$(document).keyup((e) => {
|
||||
$(document).on('keyup', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
$('div.mailpoet_form').each((index, element) => {
|
||||
if ($(element).children('.mailpoet_form_close_icon').length !== 0) {
|
||||
@@ -163,7 +163,7 @@ jQuery(($) => {
|
||||
renderFontFamily(form.data('font-family'), form.parent());
|
||||
}
|
||||
});
|
||||
$('.mailpoet_form_close_icon').click((event) => {
|
||||
$('.mailpoet_form_close_icon').on('click', (event) => {
|
||||
const closeIcon = $(event.target);
|
||||
const formDiv = closeIcon.parent();
|
||||
if (formDiv.data('is-preview')) return; // Do not close popup in preview
|
||||
@@ -185,7 +185,7 @@ jQuery(($) => {
|
||||
showForm(formDiv, showOverlay);
|
||||
});
|
||||
|
||||
$(window).resize(() => {
|
||||
$(window).on('resize', () => {
|
||||
$('.mailpoet_form').each((index, element) => {
|
||||
// Detect form is placed in tight container
|
||||
const formDiv = $(element);
|
||||
|
@@ -128,7 +128,7 @@ jQuery(document).ready(() => {
|
||||
'confirmed_ip',
|
||||
]).trigger('change');
|
||||
|
||||
nextStepButton.click((event) => {
|
||||
nextStepButton.on('click', (event) => {
|
||||
if (jQuery(event.target).hasClass('mailpoet-disabled')) {
|
||||
return;
|
||||
}
|
||||
|
@@ -7,12 +7,12 @@ export default (onCreateSegment) => {
|
||||
title: MailPoet.I18n.t('addNewList'),
|
||||
template: jQuery('#new_segment_template').html(),
|
||||
});
|
||||
jQuery('#new_segment_name').keypress((e) => {
|
||||
jQuery('#new_segment_name').on('keypress', (e) => {
|
||||
if (e.which === 13) {
|
||||
jQuery('#new_segment_process').click();
|
||||
jQuery('#new_segment_process').trigger('click');
|
||||
}
|
||||
});
|
||||
jQuery('#new_segment_process').click(() => {
|
||||
jQuery('#new_segment_process').on('click', () => {
|
||||
const segmentName = jQuery('#new_segment_name').val().trim();
|
||||
const segmentDescription = jQuery('#new_segment_description').val().trim();
|
||||
|
||||
@@ -43,7 +43,7 @@ export default (onCreateSegment) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
jQuery('#new_segment_cancel').click(() => {
|
||||
jQuery('#new_segment_cancel').on('click', () => {
|
||||
MailPoet.Modal.close();
|
||||
});
|
||||
};
|
||||
|
@@ -23,7 +23,7 @@ export function createSelection(segments, onSelectionChange) {
|
||||
templateResult: templateRendered,
|
||||
templateSelection: templateRendered,
|
||||
})
|
||||
.change((event) => {
|
||||
.on('change', (event) => {
|
||||
const segmentSelectionNotice = jQuery('[data-id="notice_segmentSelection"]');
|
||||
if (!event.currentTarget.value) {
|
||||
if (!segmentSelectionNotice.length) {
|
||||
|
@@ -242,49 +242,49 @@ describe('Abandoned Cart Content', function () {
|
||||
describe('once rendered', function () {
|
||||
it('changes the model if post status changes', function () {
|
||||
var newValue = 'pending';
|
||||
view.$('.mailpoet_products_post_status').val(newValue).change();
|
||||
view.$('.mailpoet_products_post_status').val(newValue).trigger('change');
|
||||
expect(model.get('postStatus')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if display type changes', function () {
|
||||
var newValue = 'full';
|
||||
view.$('.mailpoet_products_display_type').val(newValue).change();
|
||||
view.$('.mailpoet_products_display_type').val(newValue).trigger('change');
|
||||
expect(model.get('displayType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title format changes', function () {
|
||||
var newValue = 'h3';
|
||||
view.$('.mailpoet_products_title_format').val(newValue).change();
|
||||
view.$('.mailpoet_products_title_format').val(newValue).trigger('change');
|
||||
expect(model.get('titleFormat')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title alignment changes', function () {
|
||||
var newValue = 'right';
|
||||
view.$('.mailpoet_products_title_alignment').val(newValue).change();
|
||||
view.$('.mailpoet_products_title_alignment').val(newValue).trigger('change');
|
||||
expect(model.get('titleAlignment')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title link changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_products_title_as_links').val(newValue).change();
|
||||
view.$('.mailpoet_products_title_as_links').val(newValue).trigger('change');
|
||||
expect(model.get('titleIsLink')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if image alignment changes', function () {
|
||||
var newValue = false;
|
||||
view.$('.mailpoet_products_image_full_width').val(newValue).change();
|
||||
view.$('.mailpoet_products_image_full_width').val(newValue).trigger('change');
|
||||
expect(model.get('imageFullWidth')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if image position changes', function () {
|
||||
var newValue = 'aboveTitle';
|
||||
view.$('.mailpoet_products_featured_image_position').val(newValue).change();
|
||||
view.$('.mailpoet_products_featured_image_position').val(newValue).trigger('change');
|
||||
expect(model.get('featuredImagePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if price position changes', function () {
|
||||
var newValue = 'below';
|
||||
view.$('.mailpoet_products_price_position').val(newValue).change();
|
||||
view.$('.mailpoet_products_price_position').val(newValue).trigger('change');
|
||||
expect(model.get('pricePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('Abandoned Cart Content', function () {
|
||||
model: innerModel,
|
||||
});
|
||||
innerView.render();
|
||||
innerView.$('.mailpoet_products_display_type').val('titleOnly').change();
|
||||
innerView.$('.mailpoet_products_display_type').val('titleOnly').trigger('change');
|
||||
});
|
||||
|
||||
it('hides "title position" option', function () {
|
||||
@@ -309,7 +309,7 @@ describe('Abandoned Cart Content', function () {
|
||||
|
||||
it('changes the model if show divider changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_products_show_divider').val(newValue).change();
|
||||
view.$('.mailpoet_products_show_divider').val(newValue).trigger('change');
|
||||
expect(model.get('showDivider')).to.equal(newValue);
|
||||
});
|
||||
});
|
||||
|
@@ -436,50 +436,50 @@ describe('Automated latest content layout', function () {
|
||||
|
||||
it('changes the model if post type changes', function () {
|
||||
var newValue = 'mailpoet_page';
|
||||
view.$('.mailpoet_automated_latest_content_content_type').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_content_type').val(newValue).trigger('change');
|
||||
expect(model.get('contentType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if inclusion type changes', function () {
|
||||
var newValue = 'exclude';
|
||||
view.$('.mailpoet_automated_latest_content_include_or_exclude').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_include_or_exclude').val(newValue).trigger('change');
|
||||
expect(model.get('inclusionType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if display type changes', function () {
|
||||
var newValue = 'full';
|
||||
view.$('.mailpoet_automated_latest_content_display_type').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_display_type').val(newValue).trigger('change');
|
||||
expect(model.get('displayType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title format changes', function () {
|
||||
var newValue = 'h3';
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val(newValue).trigger('change');
|
||||
expect(model.get('titleFormat')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title alignment changes', function () {
|
||||
var newValue = 'right';
|
||||
view.$('.mailpoet_automated_latest_content_title_alignment').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_title_alignment').val(newValue).trigger('change');
|
||||
expect(model.get('titleAlignment')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title link changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_automated_latest_content_title_as_links').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_title_as_links').val(newValue).trigger('change');
|
||||
expect(model.get('titleIsLink')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if image alignment changes', function () {
|
||||
var newValue = false;
|
||||
view.$('.mailpoet_automated_latest_content_image_full_width').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_image_full_width').val(newValue).trigger('change');
|
||||
expect(model.get('imageFullWidth')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if featured image position changes for excerpt display type', function () {
|
||||
var newValue = 'right';
|
||||
model.set('displayType', 'excerpt');
|
||||
view.$('.mailpoet_automated_latest_content_featured_image_position').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_featured_image_position').val(newValue).trigger('change');
|
||||
expect(model.get('featuredImagePosition')).to.equal(newValue);
|
||||
expect(model.get('_featuredImagePosition')).to.equal(newValue);
|
||||
});
|
||||
@@ -487,20 +487,20 @@ describe('Automated latest content layout', function () {
|
||||
it('changes the model if featured image position changes for full post display type', function () {
|
||||
var newValue = 'alternate';
|
||||
model.set('displayType', 'full');
|
||||
view.$('.mailpoet_automated_latest_content_featured_image_position').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_featured_image_position').val(newValue).trigger('change');
|
||||
expect(model.get('fullPostFeaturedImagePosition')).to.equal(newValue);
|
||||
expect(model.get('_featuredImagePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if featured image position changes', function () {
|
||||
var newValue = 'aboveExcerpt';
|
||||
view.$('.mailpoet_automated_latest_content_title_position').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_title_position').val(newValue).trigger('change');
|
||||
expect(model.get('titlePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if show author changes', function () {
|
||||
var newValue = 'belowText';
|
||||
view.$('.mailpoet_automated_latest_content_show_author').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_show_author').val(newValue).trigger('change');
|
||||
expect(model.get('showAuthor')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -512,7 +512,7 @@ describe('Automated latest content layout', function () {
|
||||
|
||||
it('changes the model if show categories changes', function () {
|
||||
var newValue = 'belowText';
|
||||
view.$('.mailpoet_automated_latest_content_show_categories').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_show_categories').val(newValue).trigger('change');
|
||||
expect(model.get('showCategories')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -524,7 +524,7 @@ describe('Automated latest content layout', function () {
|
||||
|
||||
it('changes the model if read more button type changes', function () {
|
||||
var newValue = 'link';
|
||||
view.$('.mailpoet_automated_latest_content_read_more_type').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_read_more_type').val(newValue).trigger('change');
|
||||
expect(model.get('readMoreType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -536,13 +536,13 @@ describe('Automated latest content layout', function () {
|
||||
|
||||
it('changes the model if sort by changes', function () {
|
||||
var newValue = 'oldest';
|
||||
view.$('.mailpoet_automated_latest_content_sort_by').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_sort_by').val(newValue).trigger('change');
|
||||
expect(model.get('sortBy')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if show divider changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_automated_latest_content_show_divider').val(newValue).change();
|
||||
view.$('.mailpoet_automated_latest_content_show_divider').val(newValue).trigger('change');
|
||||
expect(model.get('showDivider')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -551,7 +551,7 @@ describe('Automated latest content layout', function () {
|
||||
model = new (module.AutomatedLatestContentLayoutBlockModel)();
|
||||
view = new (module.AutomatedLatestContentLayoutBlockSettingsView)({ model: model });
|
||||
view.render();
|
||||
view.$('.mailpoet_automated_latest_content_display_type').val('titleOnly').change();
|
||||
view.$('.mailpoet_automated_latest_content_display_type').val('titleOnly').trigger('change');
|
||||
});
|
||||
|
||||
it('shows "title as list" option', function () {
|
||||
@@ -563,8 +563,8 @@ describe('Automated latest content layout', function () {
|
||||
model = new (module.AutomatedLatestContentLayoutBlockModel)();
|
||||
view = new (module.AutomatedLatestContentLayoutBlockSettingsView)({ model: model });
|
||||
view.render();
|
||||
view.$('.mailpoet_automated_latest_content_display_type').val('titleOnly').change();
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val('ul').change();
|
||||
view.$('.mailpoet_automated_latest_content_display_type').val('titleOnly').trigger('change');
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val('ul').trigger('change');
|
||||
});
|
||||
|
||||
describe('"title is link" option', function () {
|
||||
@@ -580,8 +580,8 @@ describe('Automated latest content layout', function () {
|
||||
|
||||
describe('when "title as list" is deselected', function () {
|
||||
before(function () {
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val('ul').change();
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val('h3').change();
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val('ul').trigger('change');
|
||||
view.$('.mailpoet_automated_latest_content_title_format').val('h3').trigger('change');
|
||||
});
|
||||
|
||||
describe('"title is link" option', function () {
|
||||
|
@@ -276,7 +276,7 @@ describe('Button', function () {
|
||||
it('opens settings if clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
innerModel.on('startEditing', mock);
|
||||
view.$('.mailpoet_editor_button').click();
|
||||
view.$('.mailpoet_editor_button').trigger('click');
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
@@ -382,7 +382,7 @@ describe('Button', function () {
|
||||
it('updates the model when font color changes', function () {
|
||||
var newValue = '#cccccc';
|
||||
|
||||
view.$('.mailpoet_field_button_font_color').val(newValue).change();
|
||||
view.$('.mailpoet_field_button_font_color').val(newValue).trigger('change');
|
||||
|
||||
expect(model.get('styles.block.fontColor')).to.equal(newValue);
|
||||
});
|
||||
@@ -390,27 +390,27 @@ describe('Button', function () {
|
||||
it('updates the model when font family changes', function () {
|
||||
var newValue = 'Tahoma';
|
||||
|
||||
view.$('.mailpoet_field_button_font_family').val(newValue).change();
|
||||
view.$('.mailpoet_field_button_font_family').val(newValue).trigger('change');
|
||||
|
||||
expect(model.get('styles.block.fontFamily')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('updates the model when font size changes', function () {
|
||||
var newValue = '20px';
|
||||
view.$('.mailpoet_field_button_font_size').val(newValue).change();
|
||||
view.$('.mailpoet_field_button_font_size').val(newValue).trigger('change');
|
||||
expect(model.get('styles.block.fontSize')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('updates the model when font weight changes', function () {
|
||||
var newValue = 'bold';
|
||||
view.$('.mailpoet_field_button_font_weight').prop('checked', true).change();
|
||||
view.$('.mailpoet_field_button_font_weight').prop('checked', true).trigger('change');
|
||||
expect(model.get('styles.block.fontWeight')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('updates the model when background color changes', function () {
|
||||
var newValue = '#cccccc';
|
||||
|
||||
view.$('.mailpoet_field_button_background_color').val(newValue).change();
|
||||
view.$('.mailpoet_field_button_background_color').val(newValue).trigger('change');
|
||||
|
||||
expect(model.get('styles.block.backgroundColor')).to.equal(newValue);
|
||||
});
|
||||
@@ -418,13 +418,13 @@ describe('Button', function () {
|
||||
it('updates the model when border color changes', function () {
|
||||
var newValue = '#cccccc';
|
||||
|
||||
view.$('.mailpoet_field_button_border_color').val(newValue).change();
|
||||
view.$('.mailpoet_field_button_border_color').val(newValue).trigger('change');
|
||||
|
||||
expect(model.get('styles.block.borderColor')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('updates the model when border width changes', function () {
|
||||
view.$('.mailpoet_field_button_border_width').val('3').change();
|
||||
view.$('.mailpoet_field_button_border_width').val('3').trigger('change');
|
||||
expect(model.get('styles.block.borderWidth')).to.equal('3px');
|
||||
});
|
||||
it('updates the range slider when border width input changes', function () {
|
||||
@@ -432,12 +432,12 @@ describe('Button', function () {
|
||||
expect(view.$('.mailpoet_field_button_border_width').val()).to.equal('5');
|
||||
});
|
||||
it('updates the input when border width range slider changes', function () {
|
||||
view.$('.mailpoet_field_button_border_width').val('4').change();
|
||||
view.$('.mailpoet_field_button_border_width').val('4').trigger('change');
|
||||
expect(view.$('.mailpoet_field_button_border_width_input').val()).to.equal('4');
|
||||
});
|
||||
|
||||
it('updates the model when border radius changes', function () {
|
||||
view.$('.mailpoet_field_button_border_radius').val('7').change();
|
||||
view.$('.mailpoet_field_button_border_radius').val('7').trigger('change');
|
||||
expect(model.get('styles.block.borderRadius')).to.equal('7px');
|
||||
});
|
||||
it('updates the range slider when border radius input changes', function () {
|
||||
@@ -445,12 +445,12 @@ describe('Button', function () {
|
||||
expect(view.$('.mailpoet_field_button_border_radius').val()).to.equal('7');
|
||||
});
|
||||
it('updates the input when border radius range slider changes', function () {
|
||||
view.$('.mailpoet_field_button_border_radius').val('7').change();
|
||||
view.$('.mailpoet_field_button_border_radius').val('7').trigger('change');
|
||||
expect(view.$('.mailpoet_field_button_border_radius_input').val()).to.equal('7');
|
||||
});
|
||||
|
||||
it('updates the model when width changes', function () {
|
||||
view.$('.mailpoet_field_button_width').val('127').change();
|
||||
view.$('.mailpoet_field_button_width').val('127').trigger('change');
|
||||
expect(model.get('styles.block.width')).to.equal('127px');
|
||||
});
|
||||
it('updates the range slider when width input changes', function () {
|
||||
@@ -458,12 +458,12 @@ describe('Button', function () {
|
||||
expect(view.$('.mailpoet_field_button_width').val()).to.equal('127');
|
||||
});
|
||||
it('updates the input when width range slider changes', function () {
|
||||
view.$('.mailpoet_field_button_width').val('127').change();
|
||||
view.$('.mailpoet_field_button_width').val('127').trigger('change');
|
||||
expect(view.$('.mailpoet_field_button_width_input').val()).to.equal('127');
|
||||
});
|
||||
|
||||
it('updates the model when line height changes', function () {
|
||||
view.$('.mailpoet_field_button_line_height').val('37').change();
|
||||
view.$('.mailpoet_field_button_line_height').val('37').trigger('change');
|
||||
expect(model.get('styles.block.lineHeight')).to.equal('37px');
|
||||
});
|
||||
it('updates the range slider when line height input changes', function () {
|
||||
@@ -471,7 +471,7 @@ describe('Button', function () {
|
||||
expect(view.$('.mailpoet_field_button_line_height').val()).to.equal('37');
|
||||
});
|
||||
it('updates the input when line height range slider changes', function () {
|
||||
view.$('.mailpoet_field_button_line_height').val('37').change();
|
||||
view.$('.mailpoet_field_button_line_height').val('37').trigger('change');
|
||||
expect(view.$('.mailpoet_field_button_line_height_input').val()).to.equal('37');
|
||||
});
|
||||
|
||||
@@ -512,7 +512,7 @@ describe('Button', function () {
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -253,12 +253,12 @@ describe('Container', function () {
|
||||
});
|
||||
|
||||
it('updates the model when background color changes', function () {
|
||||
view.$('.mailpoet_field_container_background_color').val('#123456').change();
|
||||
view.$('.mailpoet_field_container_background_color').val('#123456').trigger('change');
|
||||
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('updates the model background image display type changes', function () {
|
||||
view.$('.mailpoet_field_display_type:nth(2)').attr('checked', true).change();
|
||||
view.$('.mailpoet_field_display_type:nth(2)').attr('checked', true).trigger('change');
|
||||
expect(model.get('image.display')).to.equal('tile');
|
||||
});
|
||||
|
||||
@@ -293,7 +293,7 @@ describe('Container', function () {
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -142,7 +142,7 @@ describe('Divider', function () {
|
||||
var mock = sinon.mock().once();
|
||||
model.on('startEditing', mock);
|
||||
view.render();
|
||||
view.$('.mailpoet_divider').click();
|
||||
view.$('.mailpoet_divider').trigger('click');
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ describe('Divider', function () {
|
||||
var mock = sinon.mock().never();
|
||||
model.on('startEditing', mock);
|
||||
view.render();
|
||||
view.$('.mailpoet_resize_handle').click();
|
||||
view.$('.mailpoet_resize_handle').trigger('click');
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
@@ -189,12 +189,12 @@ describe('Divider', function () {
|
||||
});
|
||||
|
||||
it('updates the model when divider style changes', function () {
|
||||
view.$('.mailpoet_field_divider_style').last().click();
|
||||
view.$('.mailpoet_field_divider_style').last().trigger('click');
|
||||
expect(model.get('styles.block.borderStyle')).to.equal('inset');
|
||||
});
|
||||
|
||||
it('updates the model when divider width slider changes', function () {
|
||||
view.$('.mailpoet_field_divider_border_width').val('17').change();
|
||||
view.$('.mailpoet_field_divider_border_width').val('17').trigger('change');
|
||||
expect(model.get('styles.block.borderWidth')).to.equal('17px');
|
||||
});
|
||||
|
||||
@@ -204,23 +204,23 @@ describe('Divider', function () {
|
||||
});
|
||||
|
||||
it('updates the input when divider width range slider changes', function () {
|
||||
view.$('.mailpoet_field_divider_border_width').val('19').change();
|
||||
view.$('.mailpoet_field_divider_border_width').val('19').trigger('change');
|
||||
expect(view.$('.mailpoet_field_divider_border_width_input').val()).to.equal('19');
|
||||
});
|
||||
|
||||
it('updates the model when divider color changes', function () {
|
||||
view.$('.mailpoet_field_divider_border_color').val('#123457').change();
|
||||
view.$('.mailpoet_field_divider_border_color').val('#123457').trigger('change');
|
||||
expect(model.get('styles.block.borderColor')).to.equal('#123457');
|
||||
});
|
||||
|
||||
it('updates the model when divider background color changes', function () {
|
||||
view.$('.mailpoet_field_divider_background_color').val('#cccccc').change();
|
||||
view.$('.mailpoet_field_divider_background_color').val('#cccccc').trigger('change');
|
||||
expect(model.get('styles.block.backgroundColor')).to.equal('#cccccc');
|
||||
});
|
||||
|
||||
it('changes color of available divider styles when actual divider color changes', function () {
|
||||
var newColor = '#889912';
|
||||
view.$('.mailpoet_field_divider_border_color').val(newColor).change();
|
||||
view.$('.mailpoet_field_divider_border_color').val(newColor).trigger('change');
|
||||
expect(view.$('.mailpoet_field_divider_style div')).to.have.$css('border-top-color', newColor);
|
||||
});
|
||||
|
||||
@@ -238,7 +238,7 @@ describe('Divider', function () {
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -187,41 +187,41 @@ describe('Footer', function () {
|
||||
});
|
||||
|
||||
it('updates the model when text font color changes', function () {
|
||||
view.$('.mailpoet_field_footer_text_color').val('#123456').change();
|
||||
view.$('.mailpoet_field_footer_text_color').val('#123456').trigger('change');
|
||||
expect(model.get('styles.text.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('updates the model when text font family changes', function () {
|
||||
var value = 'Tahoma';
|
||||
view.$('.mailpoet_field_footer_text_font_family').val(value).change();
|
||||
view.$('.mailpoet_field_footer_text_font_family').val(value).trigger('change');
|
||||
expect(model.get('styles.text.fontFamily')).to.equal(value);
|
||||
});
|
||||
|
||||
it('updates the model when text font size changes', function () {
|
||||
var value = '20px';
|
||||
view.$('.mailpoet_field_footer_text_size').val(value).change();
|
||||
view.$('.mailpoet_field_footer_text_size').val(value).trigger('change');
|
||||
expect(model.get('styles.text.fontSize')).to.equal(value);
|
||||
});
|
||||
|
||||
it('updates the model when link font color changes', function () {
|
||||
view.$('#mailpoet_field_footer_link_color').val('#123456').change();
|
||||
view.$('#mailpoet_field_footer_link_color').val('#123456').trigger('change');
|
||||
expect(model.get('styles.link.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('updates the model when link text decoration changes', function () {
|
||||
view.$('#mailpoet_field_footer_link_underline').prop('checked', true).change();
|
||||
view.$('#mailpoet_field_footer_link_underline').prop('checked', true).trigger('change');
|
||||
expect(model.get('styles.link.textDecoration')).to.equal('underline');
|
||||
});
|
||||
|
||||
it('updates the model when text alignment changes', function () {
|
||||
view.$('.mailpoet_field_footer_alignment').last().prop('checked', true).change();
|
||||
view.$('.mailpoet_field_footer_alignment').last().prop('checked', true).trigger('change');
|
||||
expect(model.get('styles.text.textAlign')).to.equal('right');
|
||||
});
|
||||
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -187,41 +187,41 @@ describe('Header', function () {
|
||||
});
|
||||
|
||||
it('updates the model when text font color changes', function () {
|
||||
view.$('.mailpoet_field_header_text_color').val('#123456').change();
|
||||
view.$('.mailpoet_field_header_text_color').val('#123456').trigger('change');
|
||||
expect(model.get('styles.text.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('updates the model when text font family changes', function () {
|
||||
var value = 'Tahoma';
|
||||
view.$('.mailpoet_field_header_text_font_family').val(value).change();
|
||||
view.$('.mailpoet_field_header_text_font_family').val(value).trigger('change');
|
||||
expect(model.get('styles.text.fontFamily')).to.equal(value);
|
||||
});
|
||||
|
||||
it('updates the model when text font size changes', function () {
|
||||
var value = '20px';
|
||||
view.$('.mailpoet_field_header_text_size').val(value).change();
|
||||
view.$('.mailpoet_field_header_text_size').val(value).trigger('change');
|
||||
expect(model.get('styles.text.fontSize')).to.equal(value);
|
||||
});
|
||||
|
||||
it('updates the model when link font color changes', function () {
|
||||
view.$('#mailpoet_field_header_link_color').val('#123456').change();
|
||||
view.$('#mailpoet_field_header_link_color').val('#123456').trigger('change');
|
||||
expect(model.get('styles.link.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('updates the model when link text decoration changes', function () {
|
||||
view.$('#mailpoet_field_header_link_underline').prop('checked', true).change();
|
||||
view.$('#mailpoet_field_header_link_underline').prop('checked', true).trigger('change');
|
||||
expect(model.get('styles.link.textDecoration')).to.equal('underline');
|
||||
});
|
||||
|
||||
it('updates the model when text alignment changes', function () {
|
||||
view.$('.mailpoet_field_header_alignment').last().prop('checked', true).change();
|
||||
view.$('.mailpoet_field_header_alignment').last().prop('checked', true).trigger('change');
|
||||
expect(model.get('styles.text.textAlign')).to.equal('right');
|
||||
});
|
||||
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -195,7 +195,7 @@ describe('Image', function () {
|
||||
it('opens settings if clicked on the image', function () {
|
||||
var mock = sinon.mock().once();
|
||||
model.on('startEditing', mock);
|
||||
view.$('img').click();
|
||||
view.$('img').trigger('click');
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
@@ -251,19 +251,19 @@ describe('Image', function () {
|
||||
});
|
||||
|
||||
it('updates the model when padding changes', function () {
|
||||
view.$('.mailpoet_field_image_full_width').prop('checked', false).change();
|
||||
view.$('.mailpoet_field_image_full_width').prop('checked', false).trigger('change');
|
||||
expect(model.get('fullWidth')).to.equal(false);
|
||||
});
|
||||
|
||||
it('updates the model when alignment changes', function () {
|
||||
view.$('.mailpoet_field_image_alignment').first().prop('checked', true).change();
|
||||
view.$('.mailpoet_field_image_alignment').first().prop('checked', true).trigger('change');
|
||||
expect(model.get('styles.block.textAlign')).to.equal('left');
|
||||
});
|
||||
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -346,13 +346,13 @@ describe('Posts', function () {
|
||||
describe('once rendered', function () {
|
||||
it('changes the model if post type changes', function () {
|
||||
var newValue = 'mailpoet_page';
|
||||
view.$('.mailpoet_settings_posts_content_type').val(newValue).change();
|
||||
view.$('.mailpoet_settings_posts_content_type').val(newValue).trigger('change');
|
||||
expect(model.get('contentType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if post status changes', function () {
|
||||
var newValue = 'pending';
|
||||
view.$('.mailpoet_posts_post_status').val(newValue).change();
|
||||
view.$('.mailpoet_posts_post_status').val(newValue).trigger('change');
|
||||
expect(model.get('postStatus')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -364,38 +364,38 @@ describe('Posts', function () {
|
||||
|
||||
it('changes the model if display type changes', function () {
|
||||
var newValue = 'full';
|
||||
view.$('.mailpoet_posts_display_type').val(newValue).change();
|
||||
view.$('.mailpoet_posts_display_type').val(newValue).trigger('change');
|
||||
expect(model.get('displayType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title format changes', function () {
|
||||
var newValue = 'h3';
|
||||
view.$('.mailpoet_posts_title_format').val(newValue).change();
|
||||
view.$('.mailpoet_posts_title_format').val(newValue).trigger('change');
|
||||
expect(model.get('titleFormat')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title alignment changes', function () {
|
||||
var newValue = 'right';
|
||||
view.$('.mailpoet_posts_title_alignment').val(newValue).change();
|
||||
view.$('.mailpoet_posts_title_alignment').val(newValue).trigger('change');
|
||||
expect(model.get('titleAlignment')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title link changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_posts_title_as_links').val(newValue).change();
|
||||
view.$('.mailpoet_posts_title_as_links').val(newValue).trigger('change');
|
||||
expect(model.get('titleIsLink')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if image alignment changes', function () {
|
||||
var newValue = false;
|
||||
view.$('.mailpoet_posts_image_full_width').val(newValue).change();
|
||||
view.$('.mailpoet_posts_image_full_width').val(newValue).trigger('change');
|
||||
expect(model.get('imageFullWidth')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if featured image position changes for excerpt display type', function () {
|
||||
var newValue = 'right';
|
||||
model.set('displayType', 'excerpt');
|
||||
view.$('.mailpoet_posts_featured_image_position').val(newValue).change();
|
||||
view.$('.mailpoet_posts_featured_image_position').val(newValue).trigger('change');
|
||||
expect(model.get('featuredImagePosition')).to.equal(newValue);
|
||||
expect(model.get('_featuredImagePosition')).to.equal(newValue);
|
||||
});
|
||||
@@ -403,14 +403,14 @@ describe('Posts', function () {
|
||||
it('changes the model if featured image position changes for full post display type', function () {
|
||||
var newValue = 'alternate';
|
||||
model.set('displayType', 'full');
|
||||
view.$('.mailpoet_posts_featured_image_position').val(newValue).change();
|
||||
view.$('.mailpoet_posts_featured_image_position').val(newValue).trigger('change');
|
||||
expect(model.get('fullPostFeaturedImagePosition')).to.equal(newValue);
|
||||
expect(model.get('_featuredImagePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if show author changes', function () {
|
||||
var newValue = 'belowText';
|
||||
view.$('.mailpoet_posts_show_author').val(newValue).change();
|
||||
view.$('.mailpoet_posts_show_author').val(newValue).trigger('change');
|
||||
expect(model.get('showAuthor')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -422,7 +422,7 @@ describe('Posts', function () {
|
||||
|
||||
it('changes the model if show categories changes', function () {
|
||||
var newValue = 'belowText';
|
||||
view.$('.mailpoet_posts_show_categories').val(newValue).change();
|
||||
view.$('.mailpoet_posts_show_categories').val(newValue).trigger('change');
|
||||
expect(model.get('showCategories')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -434,7 +434,7 @@ describe('Posts', function () {
|
||||
|
||||
it('changes the model if read more button type changes', function () {
|
||||
var newValue = 'link';
|
||||
view.$('.mailpoet_posts_read_more_type').val(newValue).change();
|
||||
view.$('.mailpoet_posts_read_more_type').val(newValue).trigger('change');
|
||||
expect(model.get('readMoreType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -452,7 +452,7 @@ describe('Posts', function () {
|
||||
innerModel.request = sinon.stub().returns({ $el: {} });
|
||||
innerView = new (PostsBlock.PostsBlockSettingsView)({ model: innerModel });
|
||||
innerView.render();
|
||||
innerView.$('.mailpoet_posts_display_type').val('titleOnly').change();
|
||||
innerView.$('.mailpoet_posts_display_type').val('titleOnly').trigger('change');
|
||||
});
|
||||
|
||||
it('shows "title as list" option', function () {
|
||||
@@ -461,8 +461,8 @@ describe('Posts', function () {
|
||||
|
||||
describe('when "title as list" is selected', function () {
|
||||
beforeEach(function () {
|
||||
innerView.$('.mailpoet_posts_display_type').val('titleOnly').change();
|
||||
innerView.$('.mailpoet_posts_title_format').val('ul').change();
|
||||
innerView.$('.mailpoet_posts_display_type').val('titleOnly').trigger('change');
|
||||
innerView.$('.mailpoet_posts_title_format').val('ul').trigger('change');
|
||||
});
|
||||
|
||||
describe('"title is link" option', function () {
|
||||
@@ -478,8 +478,8 @@ describe('Posts', function () {
|
||||
|
||||
describe('when "title as list" is deselected', function () {
|
||||
before(function () {
|
||||
innerView.$('.mailpoet_posts_title_format').val('ul').change();
|
||||
innerView.$('.mailpoet_posts_title_format').val('h3').change();
|
||||
innerView.$('.mailpoet_posts_title_format').val('ul').trigger('change');
|
||||
innerView.$('.mailpoet_posts_title_format').val('h3').trigger('change');
|
||||
});
|
||||
|
||||
describe('"title is link" option', function () {
|
||||
@@ -492,7 +492,7 @@ describe('Posts', function () {
|
||||
|
||||
it('changes the model if show divider changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_posts_show_divider').val(newValue).change();
|
||||
view.$('.mailpoet_posts_show_divider').val(newValue).trigger('change');
|
||||
expect(model.get('showDivider')).to.equal(newValue);
|
||||
});
|
||||
});
|
||||
|
@@ -308,7 +308,7 @@ describe('Products', function () {
|
||||
describe('once rendered', function () {
|
||||
it('changes the model if post status changes', function () {
|
||||
var newValue = 'pending';
|
||||
view.$('.mailpoet_products_post_status').val(newValue).change();
|
||||
view.$('.mailpoet_products_post_status').val(newValue).trigger('change');
|
||||
expect(model.get('postStatus')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -320,49 +320,49 @@ describe('Products', function () {
|
||||
|
||||
it('changes the model if display type changes', function () {
|
||||
var newValue = 'full';
|
||||
view.$('.mailpoet_products_display_type').val(newValue).change();
|
||||
view.$('.mailpoet_products_display_type').val(newValue).trigger('change');
|
||||
expect(model.get('displayType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title format changes', function () {
|
||||
var newValue = 'h3';
|
||||
view.$('.mailpoet_products_title_format').val(newValue).change();
|
||||
view.$('.mailpoet_products_title_format').val(newValue).trigger('change');
|
||||
expect(model.get('titleFormat')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title alignment changes', function () {
|
||||
var newValue = 'right';
|
||||
view.$('.mailpoet_products_title_alignment').val(newValue).change();
|
||||
view.$('.mailpoet_products_title_alignment').val(newValue).trigger('change');
|
||||
expect(model.get('titleAlignment')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if title link changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_products_title_as_links').val(newValue).change();
|
||||
view.$('.mailpoet_products_title_as_links').val(newValue).trigger('change');
|
||||
expect(model.get('titleIsLink')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if image alignment changes', function () {
|
||||
var newValue = false;
|
||||
view.$('.mailpoet_products_image_full_width').val(newValue).change();
|
||||
view.$('.mailpoet_products_image_full_width').val(newValue).trigger('change');
|
||||
expect(model.get('imageFullWidth')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if image position changes', function () {
|
||||
var newValue = 'aboveTitle';
|
||||
view.$('.mailpoet_products_featured_image_position').val(newValue).change();
|
||||
view.$('.mailpoet_products_featured_image_position').val(newValue).trigger('change');
|
||||
expect(model.get('featuredImagePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if price position changes', function () {
|
||||
var newValue = 'below';
|
||||
view.$('.mailpoet_products_price_position').val(newValue).change();
|
||||
view.$('.mailpoet_products_price_position').val(newValue).trigger('change');
|
||||
expect(model.get('pricePosition')).to.equal(newValue);
|
||||
});
|
||||
|
||||
it('changes the model if buy now button type changes', function () {
|
||||
var newValue = 'link';
|
||||
view.$('.mailpoet_products_read_more_type').val(newValue).change();
|
||||
view.$('.mailpoet_products_read_more_type').val(newValue).trigger('change');
|
||||
expect(model.get('readMoreType')).to.equal(newValue);
|
||||
});
|
||||
|
||||
@@ -380,7 +380,7 @@ describe('Products', function () {
|
||||
innerModel.request = sinon.stub().returns({ $el: {} });
|
||||
innerView = new (ProductsBlock.ProductsBlockSettingsView)({ model: innerModel });
|
||||
innerView.render();
|
||||
innerView.$('.mailpoet_products_display_type').val('titleOnly').change();
|
||||
innerView.$('.mailpoet_products_display_type').val('titleOnly').trigger('change');
|
||||
});
|
||||
|
||||
it('hides "title position" option', function () {
|
||||
@@ -391,7 +391,7 @@ describe('Products', function () {
|
||||
|
||||
it('changes the model if show divider changes', function () {
|
||||
var newValue = true;
|
||||
view.$('.mailpoet_products_show_divider').val(newValue).change();
|
||||
view.$('.mailpoet_products_show_divider').val(newValue).trigger('change');
|
||||
expect(model.get('showDivider')).to.equal(newValue);
|
||||
});
|
||||
});
|
||||
|
@@ -290,34 +290,34 @@ describe('Social', function () {
|
||||
});
|
||||
|
||||
it('updates icons in settings if iconset changes', function () {
|
||||
view.$('.mailpoet_social_icon_set').last().click();
|
||||
view.$('.mailpoet_social_icon_set').last().trigger('click');
|
||||
expect(view.$('.mailpoet_social_icon_field_image').val()).to.equal(EditorApplication.getAvailableStyles().get('socialIconSets.light.custom'));
|
||||
});
|
||||
|
||||
it('removes the icon when "remove" is clicked', function () {
|
||||
view.$('.mailpoet_delete_block').click();
|
||||
view.$('.mailpoet_delete_block').trigger('click');
|
||||
expect(model.get('icons').length).to.equal(0);
|
||||
expect(view.$('.mailpoet_social_icon_settings').length).to.equal(0);
|
||||
});
|
||||
|
||||
it('adds another icon when "Add another social network" is pressed', function () {
|
||||
view.$('.mailpoet_add_social_icon').click();
|
||||
view.$('.mailpoet_add_social_icon').trigger('click');
|
||||
expect(model.get('icons').length).to.equal(2);
|
||||
});
|
||||
|
||||
it('updates alignment when it changes', function () {
|
||||
view.$('.mailpoet_social_block_alignment').eq(0).click();
|
||||
view.$('.mailpoet_social_block_alignment').eq(0).trigger('click');
|
||||
expect(model.get('styles.block.textAlign')).to.equal('left');
|
||||
view.$('.mailpoet_social_block_alignment').eq(1).click();
|
||||
view.$('.mailpoet_social_block_alignment').eq(1).trigger('click');
|
||||
expect(model.get('styles.block.textAlign')).to.equal('center');
|
||||
view.$('.mailpoet_social_block_alignment').eq(2).click();
|
||||
view.$('.mailpoet_social_block_alignment').eq(2).trigger('click');
|
||||
expect(model.get('styles.block.textAlign')).to.equal('right');
|
||||
});
|
||||
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -115,7 +115,7 @@ describe('Spacer', function () {
|
||||
var mock = sinon.mock().once();
|
||||
model.on('startEditing', mock);
|
||||
view.render();
|
||||
view.$('.mailpoet_spacer').click();
|
||||
view.$('.mailpoet_spacer').trigger('click');
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
@@ -123,7 +123,7 @@ describe('Spacer', function () {
|
||||
var mock = sinon.mock().never();
|
||||
model.on('startEditing', mock);
|
||||
view.render();
|
||||
view.$('.mailpoet_resize_handle').click();
|
||||
view.$('.mailpoet_resize_handle').trigger('click');
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
@@ -155,14 +155,14 @@ describe('Spacer', function () {
|
||||
});
|
||||
|
||||
it('updates the model when background color changes', function () {
|
||||
view.$('.mailpoet_field_spacer_background_color').val('#123456').change();
|
||||
view.$('.mailpoet_field_spacer_background_color').val('#123456').trigger('change');
|
||||
expect(model.get('styles.block.backgroundColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it.skip('closes the sidepanel after "Done" is clicked', function () {
|
||||
var mock = sinon.mock().once();
|
||||
global.MailPoet.Modal.cancel = mock;
|
||||
view.$('.mailpoet_done_editing').click();
|
||||
view.$('.mailpoet_done_editing').trigger('click');
|
||||
mock.verify();
|
||||
delete (global.MailPoet.Modal.cancel);
|
||||
});
|
||||
|
@@ -39,12 +39,12 @@ describe('Heading', function () {
|
||||
});
|
||||
|
||||
it('changes the model when subject field is changed', function () {
|
||||
view.$('.mailpoet_input_title').val('a new testing subject').keyup();
|
||||
view.$('.mailpoet_input_title').val('a new testing subject').trigger('keyup');
|
||||
expect(model.get('subject')).to.equal('a new testing subject');
|
||||
});
|
||||
|
||||
it('changes the model when preheader field is changed', function () {
|
||||
view.$('.mailpoet_input_preheader').val('a new testing preheader').keyup();
|
||||
view.$('.mailpoet_input_preheader').val('a new testing preheader').trigger('keyup');
|
||||
expect(model.get('preheader')).to.equal('a new testing preheader');
|
||||
});
|
||||
});
|
||||
|
@@ -189,13 +189,13 @@ describe('Save', function () {
|
||||
global.stubChannel(EditorApplication, {
|
||||
request: mock,
|
||||
});
|
||||
view.$('.mailpoet_save_button').click();
|
||||
view.$('.mailpoet_save_button').trigger('click');
|
||||
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
it('displays saving options when clicked on save options button', function () {
|
||||
view.$('.mailpoet_save_show_options').click();
|
||||
view.$('.mailpoet_save_show_options').trigger('click');
|
||||
expect(view.$('.mailpoet_save_options')).to.not.have.$class('mailpoet_hidden');
|
||||
});
|
||||
|
||||
@@ -248,7 +248,7 @@ describe('Save', function () {
|
||||
|
||||
view.$('.mailpoet_save_as_template_name').val('A sample template');
|
||||
view.$('.mailpoet_save_as_template_description').val('Sample template description');
|
||||
view.$('.mailpoet_save_as_template').click();
|
||||
view.$('.mailpoet_save_as_template').trigger('click');
|
||||
|
||||
mock.verify();
|
||||
});
|
||||
@@ -272,7 +272,7 @@ describe('Save', function () {
|
||||
view = new (module.SaveView)({ model: model });
|
||||
view.render();
|
||||
|
||||
view.$('.mailpoet_save_next').click();
|
||||
view.$('.mailpoet_save_next').trigger('click');
|
||||
expect(spy).to.have.callCount(1);
|
||||
expect(spy).to.have.been.calledWith('beforeEditorSave');
|
||||
});
|
||||
|
@@ -100,82 +100,82 @@ describe('Sidebar', function () {
|
||||
});
|
||||
|
||||
it('changes model if text font color field changes', function () {
|
||||
innerView.$('#mailpoet_text_font_color').val('#123456').change();
|
||||
innerView.$('#mailpoet_text_font_color').val('#123456').trigger('change');
|
||||
expect(model.get('text.fontColor')).to.equal('#123456');
|
||||
});
|
||||
|
||||
it('changes model if h1 font color field changes', function () {
|
||||
innerView.$('#mailpoet_h1_font_color').val('#123457').change();
|
||||
innerView.$('#mailpoet_h1_font_color').val('#123457').trigger('change');
|
||||
expect(model.get('h1.fontColor')).to.equal('#123457');
|
||||
});
|
||||
|
||||
it('changes model if h2 font color field changes', function () {
|
||||
innerView.$('#mailpoet_h2_font_color').val('#123458').change();
|
||||
innerView.$('#mailpoet_h2_font_color').val('#123458').trigger('change');
|
||||
expect(model.get('h2.fontColor')).to.equal('#123458');
|
||||
});
|
||||
|
||||
it('changes model if h3 font color field changes', function () {
|
||||
innerView.$('#mailpoet_h3_font_color').val('#123426').change();
|
||||
innerView.$('#mailpoet_h3_font_color').val('#123426').trigger('change');
|
||||
expect(model.get('h3.fontColor')).to.equal('#123426');
|
||||
});
|
||||
|
||||
it('changes model if link font color field changes', function () {
|
||||
innerView.$('#mailpoet_a_font_color').val('#323232').change();
|
||||
innerView.$('#mailpoet_a_font_color').val('#323232').trigger('change');
|
||||
expect(model.get('link.fontColor')).to.equal('#323232');
|
||||
});
|
||||
|
||||
it('changes model if newsletter background color field changes', function () {
|
||||
innerView.$('#mailpoet_newsletter_background_color').val('#636237').change();
|
||||
innerView.$('#mailpoet_newsletter_background_color').val('#636237').trigger('change');
|
||||
expect(model.get('wrapper.backgroundColor')).to.equal('#636237');
|
||||
});
|
||||
|
||||
it('changes model if background color field changes', function () {
|
||||
innerView.$('#mailpoet_background_color').val('#878587').change();
|
||||
innerView.$('#mailpoet_background_color').val('#878587').trigger('change');
|
||||
expect(model.get('body.backgroundColor')).to.equal('#878587');
|
||||
});
|
||||
|
||||
it('changes model if text font family field changes', function () {
|
||||
innerView.$('#mailpoet_text_font_family').val('Times New Roman').change();
|
||||
innerView.$('#mailpoet_text_font_family').val('Times New Roman').trigger('change');
|
||||
expect(model.get('text.fontFamily')).to.equal('Times New Roman');
|
||||
});
|
||||
|
||||
it('changes model if h1 font family field changes', function () {
|
||||
innerView.$('#mailpoet_h1_font_family').val('Comic Sans').change();
|
||||
innerView.$('#mailpoet_h1_font_family').val('Comic Sans').trigger('change');
|
||||
expect(model.get('h1.fontFamily')).to.equal('Comic Sans');
|
||||
});
|
||||
|
||||
it('changes model if h2 font family field changes', function () {
|
||||
innerView.$('#mailpoet_h2_font_family').val('Tahoma').change();
|
||||
innerView.$('#mailpoet_h2_font_family').val('Tahoma').trigger('change');
|
||||
expect(model.get('h2.fontFamily')).to.equal('Tahoma');
|
||||
});
|
||||
|
||||
it('changes model if h3 font family field changes', function () {
|
||||
innerView.$('#mailpoet_h3_font_family').val('Lucida').change();
|
||||
innerView.$('#mailpoet_h3_font_family').val('Lucida').trigger('change');
|
||||
expect(model.get('h3.fontFamily')).to.equal('Lucida');
|
||||
});
|
||||
|
||||
it('changes model if text font size field changes', function () {
|
||||
innerView.$('#mailpoet_text_font_size').val('9px').change();
|
||||
innerView.$('#mailpoet_text_font_size').val('9px').trigger('change');
|
||||
expect(model.get('text.fontSize')).to.equal('9px');
|
||||
});
|
||||
|
||||
it('changes model if h1 font size field changes', function () {
|
||||
innerView.$('#mailpoet_h1_font_size').val('12px').change();
|
||||
innerView.$('#mailpoet_h1_font_size').val('12px').trigger('change');
|
||||
expect(model.get('h1.fontSize')).to.equal('12px');
|
||||
});
|
||||
|
||||
it('changes model if h2 font size field changes', function () {
|
||||
innerView.$('#mailpoet_h2_font_size').val('14px').change();
|
||||
innerView.$('#mailpoet_h2_font_size').val('14px').trigger('change');
|
||||
expect(model.get('h2.fontSize')).to.equal('14px');
|
||||
});
|
||||
|
||||
it('changes model if h3 font size field changes', function () {
|
||||
innerView.$('#mailpoet_h3_font_size').val('16px').change();
|
||||
innerView.$('#mailpoet_h3_font_size').val('16px').trigger('change');
|
||||
expect(model.get('h3.fontSize')).to.equal('16px');
|
||||
});
|
||||
|
||||
it('changes model if link underline field changes', function () {
|
||||
innerView.$('#mailpoet_a_font_underline').prop('checked', true).change();
|
||||
innerView.$('#mailpoet_a_font_underline').prop('checked', true).trigger('change');
|
||||
expect(model.get('link.textDecoration')).to.equal('underline');
|
||||
});
|
||||
});
|
||||
|
@@ -18,7 +18,7 @@
|
||||
location.href = deactivateLink.attr('href');
|
||||
});
|
||||
|
||||
$(document).keyup(function(event) {
|
||||
$(document).on('keyup', function(event) {
|
||||
if ((event.keyCode === 27) && formOpen) {
|
||||
location.href = deactivateLink.attr('href');
|
||||
}
|
||||
|
Reference in New Issue
Block a user