Version Description
- 2017-09-26 =
- Added: images can be resized in newsletter editor;
- Fixed: scheduled newsletters that are unscheduled will not be mistakenly sent. Thx Georges in Provence;
- Fixed: plugin does not time out on sites with a large number of lists and subscribers. Thanks Roy;
- Fixed: long email addresses no longer trigger MySQL errors during subscription. Thank you Sameer Bhatt and Bits of Freedom!
Download this release
Release Info
Developer | wysija |
Plugin | MailPoet Newsletters (New) |
Version | 3.0.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.0 to 3.0.1
- assets/css/manifest.json +1 -1
- assets/css/{newsletter_editor.55f2b9dc.css → newsletter_editor.47c884ae.css} +45 -1
- assets/js/{admin.ef421cc2.js → admin.e3b1aa46.js} +51 -51
- assets/js/{admin_vendor.c1a3e332.js → admin_vendor.53a6d3ec.js} +106 -133
- assets/js/{form_editor.00c531b6.js → form_editor.c4bc7e0b.js} +216 -216
- assets/js/lib/mailpoet_shortcodes/plugin.js +7 -7
- assets/js/{mailpoet.25f879a2.js → mailpoet.eab93337.js} +287 -310
- assets/js/manifest.json +8 -8
- assets/js/{mp2migrator.923dd5b2.js → mp2migrator.e755af46.js} +22 -22
- assets/js/{newsletter_editor.cc3c87be.js → newsletter_editor.2627c560.js} +838 -800
- assets/js/{public.5b18b937.js → public.6e3f442a.js} +47 -47
- assets/js/{vendor.2e3b215c.js → vendor.b4463523.js} +22 -22
- lang/index.php +3 -0
- lang/mailpoet-da_DK.mo +0 -0
- lang/mailpoet-de_DE.mo +0 -0
- lang/mailpoet-en_GB.mo +0 -0
- lang/mailpoet-es_ES.mo +0 -0
- lang/mailpoet-fa_IR.mo +0 -0
- lang/mailpoet-fr_CA.mo +0 -0
- lang/mailpoet-fr_FR.mo +0 -0
- lang/mailpoet-it_IT.mo +0 -0
- lang/mailpoet-ja.mo +0 -0
- lang/mailpoet-nl_NL.mo +0 -0
- lang/mailpoet-pl_PL.mo +0 -0
- lang/mailpoet-pt_BR.mo +0 -0
- lang/mailpoet-pt_PT.mo +0 -0
- lang/mailpoet-ru_RU.mo +0 -0
- lang/mailpoet-sv_SE.mo +0 -0
- lang/mailpoet-tr_TR.mo +0 -0
- lang/mailpoet.pot +21 -20
- lib/API/JSON/ErrorResponse.php +9 -12
- lib/API/JSON/v1/Newsletters.php +54 -53
- lib/Config/Migrator.php +2 -1
- lib/Config/PopulatorData/Templates/AppWelcome.php +1 -1
- lib/Config/PopulatorData/Templates/BurgerJoint.php +1 -1
- lib/Config/PopulatorData/Templates/ChocolateStore.php +1 -1
- lib/Config/PopulatorData/Templates/CoffeeShop.php +1 -1
- lib/Config/PopulatorData/Templates/Discount.php +1 -1
- lib/Config/PopulatorData/Templates/Faith.php +2 -2
- lib/Config/PopulatorData/Templates/FestivalEvent.php +1 -1
- lib/Config/PopulatorData/Templates/FoodBox.php +1 -1
- lib/Config/PopulatorData/Templates/KickOff.php +1 -1
- lib/Config/PopulatorData/Templates/NewsDay.php +1 -1
- lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php +1 -1
- lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php +1 -1
- lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php +1 -1
- lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php +1 -1
- lib/Config/PopulatorData/Templates/PieceOfCake.php +1 -1
- lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php +1 -1
- lib/Config/PopulatorData/Templates/ScienceWeekly.php +1 -1
- lib/Config/PopulatorData/Templates/Shoes.php +1 -1
- lib/Config/PopulatorData/Templates/SimpleText.php +1 -1
- lib/Config/PopulatorData/Templates/TakeAHike.php +2 -2
- lib/Config/PopulatorData/Templates/TravelNomads.php +2 -2
- lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php +1 -1
- lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php +1 -1
- lib/Config/PopulatorData/Templates/WorldCup.php +1 -1
- lib/Config/PopulatorData/Templates/YogaStudio.php +1 -1
- lib/Config/Shortcodes.php +8 -7
- lib/Form/Block/Base.php +5 -1
- lib/Models/ModelValidator.php +6 -1
- mailpoet.php +2 -2
- readme.txt +7 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +5 -5
- views/newsletter/templates/blocks/image/block.hbs +12 -1
- views/newsletter/templates/blocks/image/settings.hbs +25 -0
- views/newsletter/templates/svg/block-icons/spacer.svg +4 -4
- views/newsletter/templates/svg/block-tools/resize.svg +4 -0
assets/css/manifest.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"admin.css": "admin.8b85810c.css",
|
3 |
"importExport.css": "importExport.b3745466.css",
|
4 |
-
"newsletter_editor.css": "newsletter_editor.
|
5 |
"public.css": "public.cae357df.css",
|
6 |
"rtl.css": "rtl.d41d8cd9.css"
|
7 |
}
|
1 |
{
|
2 |
"admin.css": "admin.8b85810c.css",
|
3 |
"importExport.css": "importExport.b3745466.css",
|
4 |
+
"newsletter_editor.css": "newsletter_editor.47c884ae.css",
|
5 |
"public.css": "public.cae357df.css",
|
6 |
"rtl.css": "rtl.d41d8cd9.css"
|
7 |
}
|
assets/css/{newsletter_editor.55f2b9dc.css → newsletter_editor.47c884ae.css}
RENAMED
@@ -1929,6 +1929,45 @@ input.mailpoet_option_offset_left_small {
|
|
1929 |
.mailpoet_block.mailpoet_resize_active > .mailpoet_block_highlight .mailpoet_resize_handle {
|
1930 |
display: inline-block;
|
1931 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1932 |
.mailpoet_block {
|
1933 |
box-sizing: border-box;
|
1934 |
position: relative;
|
@@ -2218,14 +2257,19 @@ input.mailpoet_option_offset_left_small {
|
|
2218 |
.mailpoet_image_block img {
|
2219 |
vertical-align: bottom;
|
2220 |
max-width: 100%;
|
2221 |
-
width: auto;
|
2222 |
height: auto;
|
2223 |
}
|
2224 |
.mailpoet_image_block.mailpoet_full_image {
|
2225 |
padding-left: 0;
|
2226 |
padding-right: 0;
|
|
|
2227 |
margin-bottom: 0;
|
2228 |
}
|
|
|
|
|
|
|
|
|
|
|
2229 |
.mailpoet_image_block .mailpoet_content a:hover {
|
2230 |
cursor: all-scroll;
|
2231 |
}
|
1929 |
.mailpoet_block.mailpoet_resize_active > .mailpoet_block_highlight .mailpoet_resize_handle {
|
1930 |
display: inline-block;
|
1931 |
}
|
1932 |
+
.mailpoet_image_resize_handle_container {
|
1933 |
+
position: absolute;
|
1934 |
+
bottom: 0;
|
1935 |
+
right: 0;
|
1936 |
+
width: 20px;
|
1937 |
+
height: 20px;
|
1938 |
+
}
|
1939 |
+
.mailpoet_image_resize_handle {
|
1940 |
+
position: relative;
|
1941 |
+
background: #0074a2;
|
1942 |
+
-webkit-border-radius: 3px;
|
1943 |
+
-moz-border-radius: 3px;
|
1944 |
+
border-radius: 3px;
|
1945 |
+
display: inline-block;
|
1946 |
+
width: 20px;
|
1947 |
+
height: 20px;
|
1948 |
+
cursor: nwse-resize;
|
1949 |
+
z-index: 2;
|
1950 |
+
}
|
1951 |
+
.mailpoet_image_resize_handle .mailpoet_image_resize_handle_text,
|
1952 |
+
.mailpoet_image_resize_handle .mailpoet_image_resize_handle_icon {
|
1953 |
+
pointer-events: none;
|
1954 |
+
}
|
1955 |
+
.mailpoet_image_resize_handle_icon {
|
1956 |
+
position: absolute;
|
1957 |
+
top: 0;
|
1958 |
+
right: 0;
|
1959 |
+
}
|
1960 |
+
.mailpoet_image_resize_handle_icon > svg {
|
1961 |
+
width: 100%;
|
1962 |
+
height: 100%;
|
1963 |
+
fill: #fff;
|
1964 |
+
}
|
1965 |
+
.mailpoet_block.mailpoet_image_resize_active > .mailpoet_block_highlight {
|
1966 |
+
border: 1px dashed #0074a2;
|
1967 |
+
}
|
1968 |
+
.mailpoet_block.mailpoet_image_resize_active > .mailpoet_block_highlight .mailpoet_image_resize_handle {
|
1969 |
+
display: inline-block;
|
1970 |
+
}
|
1971 |
.mailpoet_block {
|
1972 |
box-sizing: border-box;
|
1973 |
position: relative;
|
2257 |
.mailpoet_image_block img {
|
2258 |
vertical-align: bottom;
|
2259 |
max-width: 100%;
|
|
|
2260 |
height: auto;
|
2261 |
}
|
2262 |
.mailpoet_image_block.mailpoet_full_image {
|
2263 |
padding-left: 0;
|
2264 |
padding-right: 0;
|
2265 |
+
margin: auto;
|
2266 |
margin-bottom: 0;
|
2267 |
}
|
2268 |
+
.mailpoet_image_block .mailpoet_content {
|
2269 |
+
margin: auto;
|
2270 |
+
max-width: 100%;
|
2271 |
+
min-width: 36px;
|
2272 |
+
}
|
2273 |
.mailpoet_image_block .mailpoet_content a:hover {
|
2274 |
cursor: all-scroll;
|
2275 |
}
|
assets/js/{admin.ef421cc2.js → admin.e3b1aa46.js}
RENAMED
@@ -38778,13 +38778,13 @@ webpackJsonp([0],[
|
|
38778 |
__webpack_require__(535),
|
38779 |
__webpack_require__(273),
|
38780 |
__webpack_require__(274)
|
38781 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
38782 |
Backbone,
|
38783 |
jQuery,
|
38784 |
mp
|
38785 |
) {
|
38786 |
var MailPoet = mp;
|
38787 |
-
if(jQuery('#mailpoet_settings').length === 0) {
|
38788 |
return;
|
38789 |
}
|
38790 |
|
@@ -38794,7 +38794,7 @@ webpackJsonp([0],[
|
|
38794 |
'mta(/:group)': 'sendingMethodGroup',
|
38795 |
'(:tab)': 'tabs'
|
38796 |
},
|
38797 |
-
sendingMethodGroup: function(group) {
|
38798 |
// display mta tab
|
38799 |
this.tabs('mta');
|
38800 |
|
@@ -38806,7 +38806,7 @@ webpackJsonp([0],[
|
|
38806 |
// hide "save settings" button
|
38807 |
jQuery('.mailpoet_settings_submit').hide();
|
38808 |
|
38809 |
-
if(group === null) {
|
38810 |
// show sending methods
|
38811 |
jQuery('.mailpoet_sending_methods, .mailpoet_sending_methods_help').fadeIn();
|
38812 |
} else {
|
@@ -38821,11 +38821,11 @@ webpackJsonp([0],[
|
|
38821 |
jQuery('.mailpoet_sending_methods, .mailpoet_sending_methods_help').hide();
|
38822 |
|
38823 |
// display selected sending method's settings
|
38824 |
-
jQuery('.mailpoet_sending_method[data-group="'+ group +'"]').show();
|
38825 |
jQuery('#mailpoet_sending_method_setup').fadeIn();
|
38826 |
}
|
38827 |
},
|
38828 |
-
tabs: function(tabStr, section) {
|
38829 |
// set default tab
|
38830 |
var tab = tabStr || 'mta';
|
38831 |
|
@@ -38836,11 +38836,11 @@ webpackJsonp([0],[
|
|
38836 |
jQuery('.mailpoet_panel, .mailpoet_section').hide();
|
38837 |
|
38838 |
// set active tab
|
38839 |
-
jQuery('a.nav-tab[href="#'+tab+'"]').addClass('nav-tab-active').blur();
|
38840 |
|
38841 |
// show selected panel
|
38842 |
-
if(jQuery('.mailpoet_panel[data-tab="'+ tab +'"]').length > 0) {
|
38843 |
-
jQuery('.mailpoet_panel[data-tab="'+ tab +'"]').show();
|
38844 |
}
|
38845 |
|
38846 |
// show "save settings" button
|
@@ -38856,7 +38856,7 @@ webpackJsonp([0],[
|
|
38856 |
}
|
38857 |
}));
|
38858 |
|
38859 |
-
jQuery(document).ready(function() {
|
38860 |
if (!Backbone.History.started) Backbone.history.start();
|
38861 |
});
|
38862 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -41107,7 +41107,7 @@ webpackJsonp([0],[
|
|
41107 |
|
41108 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
41109 |
__webpack_require__(274)
|
41110 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
41111 |
MailPoet
|
41112 |
) {
|
41113 |
|
@@ -41115,7 +41115,7 @@ webpackJsonp([0],[
|
|
41115 |
if (confirm(MailPoet.I18n.t('reinstallConfirmation'))) {
|
41116 |
MailPoet.trackEvent(
|
41117 |
'User has reinstalled MailPoet via Settings',
|
41118 |
-
{'MailPoet Free version': window.mailpoet_version}
|
41119 |
);
|
41120 |
|
41121 |
MailPoet.Modal.loading(true);
|
@@ -41133,7 +41133,7 @@ webpackJsonp([0],[
|
|
41133 |
response.errors.map(function (error) {
|
41134 |
return error.message;
|
41135 |
}),
|
41136 |
-
{scroll: true}
|
41137 |
);
|
41138 |
}
|
41139 |
});
|
@@ -41186,7 +41186,7 @@ webpackJsonp([0],[
|
|
41186 |
step3: 'step3'
|
41187 |
},
|
41188 |
home: function () {
|
41189 |
-
this.navigate('step1', {trigger: true});
|
41190 |
}
|
41191 |
}));
|
41192 |
|
@@ -41348,9 +41348,9 @@ webpackJsonp([0],[
|
|
41348 |
data: {
|
41349 |
api_key: mailChimpKeyInputElement.val()
|
41350 |
}
|
41351 |
-
}).always(function() {
|
41352 |
MailPoet.Modal.loading(false);
|
41353 |
-
}).done(function(response) {
|
41354 |
jQuery('.mailpoet_mailchimp-key-status')
|
41355 |
.html('')
|
41356 |
.removeClass()
|
@@ -41362,10 +41362,10 @@ webpackJsonp([0],[
|
|
41362 |
} else {
|
41363 |
displayMailChimpLists(response.data);
|
41364 |
}
|
41365 |
-
}).fail(function(response) {
|
41366 |
if (response.errors.length > 0) {
|
41367 |
MailPoet.Notice.error(
|
41368 |
-
response.errors.map(function(error) { return error.message; }),
|
41369 |
{ scroll: true }
|
41370 |
);
|
41371 |
}
|
@@ -41385,19 +41385,19 @@ webpackJsonp([0],[
|
|
41385 |
api_key: mailChimpKeyInputElement.val(),
|
41386 |
lists: mailChimpListsContainerElement.find('select').val()
|
41387 |
}
|
41388 |
-
}).always(function(response) {
|
41389 |
MailPoet.Modal.loading(false);
|
41390 |
-
}).done(function(response) {
|
41391 |
window.importData.step1 = response.data;
|
41392 |
MailPoet.trackEvent('Subscribers import started', {
|
41393 |
source: 'MailChimp',
|
41394 |
'MailPoet Free version': window.mailpoet_version
|
41395 |
});
|
41396 |
-
router.navigate('step2', {trigger: true});
|
41397 |
-
}).fail(function(response) {
|
41398 |
if (response.errors.length > 0) {
|
41399 |
MailPoet.Notice.error(
|
41400 |
-
response.errors.map(function(error) { return error.message; }),
|
41401 |
{ scroll: true }
|
41402 |
);
|
41403 |
}
|
@@ -41482,7 +41482,7 @@ webpackJsonp([0],[
|
|
41482 |
email = test[1].trim();
|
41483 |
}
|
41484 |
// test for valid characters using WP's rule (https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/formatting.php#L2902)
|
41485 |
-
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email)
|
41486 |
return false;
|
41487 |
}
|
41488 |
return email;
|
@@ -41574,7 +41574,7 @@ webpackJsonp([0],[
|
|
41574 |
source: isFile ? 'file upload' : 'pasted data',
|
41575 |
'MailPoet Free version': window.mailpoet_version
|
41576 |
});
|
41577 |
-
router.navigate('step2', {trigger: true});
|
41578 |
}
|
41579 |
else {
|
41580 |
MailPoet.Modal.loading(false);
|
@@ -41590,7 +41590,7 @@ webpackJsonp([0],[
|
|
41590 |
|
41591 |
router.on('route:step2', function () {
|
41592 |
if (typeof (window.importData.step1) === 'undefined') {
|
41593 |
-
router.navigate('step1', {trigger: true});
|
41594 |
return;
|
41595 |
}
|
41596 |
// define reusable variables
|
@@ -41727,12 +41727,12 @@ webpackJsonp([0],[
|
|
41727 |
});
|
41728 |
}
|
41729 |
|
41730 |
-
jQuery('.mailpoet_create_segment').click(function() {
|
41731 |
MailPoet.Modal.popup({
|
41732 |
title: MailPoet.I18n.t('addNewList'),
|
41733 |
template: jQuery('#new_segment_template').html()
|
41734 |
});
|
41735 |
-
jQuery('#new_segment_name').keypress(function(e) {
|
41736 |
if (e.which == 13) {
|
41737 |
jQuery('#new_segment_process').click();
|
41738 |
}
|
@@ -41749,7 +41749,7 @@ webpackJsonp([0],[
|
|
41749 |
name: segmentName,
|
41750 |
description: segmentDescription
|
41751 |
}
|
41752 |
-
}).done(function(response) {
|
41753 |
window.mailpoetSegments.push({
|
41754 |
id: response.data.id,
|
41755 |
name: response.data.name,
|
@@ -41768,11 +41768,11 @@ webpackJsonp([0],[
|
|
41768 |
jQuery('.mailpoet_segments:hidden').show();
|
41769 |
jQuery('.mailpoet_no_segments:visible').hide();
|
41770 |
MailPoet.Modal.close();
|
41771 |
-
}).fail(function(response) {
|
41772 |
if (response.errors.length > 0) {
|
41773 |
MailPoet.Notice.hide();
|
41774 |
MailPoet.Notice.error(
|
41775 |
-
response.errors.map(function(error) { return error.message; }),
|
41776 |
{ positionAfter: '#new_segment_name' }
|
41777 |
);
|
41778 |
}
|
@@ -41829,14 +41829,14 @@ webpackJsonp([0],[
|
|
41829 |
&& displayedColumnsIds.indexOf(columnId) === -1)
|
41830 |
? columnId
|
41831 |
: 'ignore';
|
41832 |
-
displayedColumns[i] = {column_id: columnId};
|
41833 |
displayedColumnsIds.push(columnId);
|
41834 |
}
|
41835 |
return options.fn(displayedColumns);
|
41836 |
});
|
41837 |
|
41838 |
// sanitize unsafe data
|
41839 |
-
Handlebars.registerHelper('sanitize_data', function(data) {
|
41840 |
return (data instanceof Handlebars.SafeString) ?
|
41841 |
data :
|
41842 |
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
@@ -41894,7 +41894,7 @@ webpackJsonp([0],[
|
|
41894 |
title: MailPoet.I18n.t('addNewField'),
|
41895 |
template: jQuery('#form_template_field_form').html()
|
41896 |
});
|
41897 |
-
jQuery('#form_field_new').parsley().on('form:submit', function(parsley) {
|
41898 |
// get data
|
41899 |
var data = jQuery(this.$element).serializeObject();
|
41900 |
|
@@ -41904,7 +41904,7 @@ webpackJsonp([0],[
|
|
41904 |
endpoint: 'customFields',
|
41905 |
action: 'save',
|
41906 |
data: data
|
41907 |
-
}).done(function(response) {
|
41908 |
var new_column_data = {
|
41909 |
id: response.data.id,
|
41910 |
name: response.data.name,
|
@@ -41942,10 +41942,10 @@ webpackJsonp([0],[
|
|
41942 |
filterSubscribers();
|
41943 |
// close popup
|
41944 |
MailPoet.Modal.close();
|
41945 |
-
}).fail(function(response) {
|
41946 |
if (response.errors.length > 0) {
|
41947 |
MailPoet.Notice.error(
|
41948 |
-
response.errors.map(function(error) { return error.message; }),
|
41949 |
{ positionAfter: '#field_name' }
|
41950 |
);
|
41951 |
}
|
@@ -41999,7 +41999,7 @@ webpackJsonp([0],[
|
|
41999 |
jQuery.map(window.mailpoetColumns, function (column, columnIndex) {
|
42000 |
// check if the column id matches the selected id of one of the
|
42001 |
// subscriber's data columns
|
42002 |
-
var matchedColumn = _.find(displayedColumns, function(data) { return data.id === column.id; });
|
42003 |
// EMAIL filter: if the first value in the column doesn't have a valid
|
42004 |
// email, hide the next button
|
42005 |
if (column.id === 'email') {
|
@@ -42046,7 +42046,7 @@ webpackJsonp([0],[
|
|
42046 |
for (var format in allowedDateFormats) {
|
42047 |
var testedFormat = allowedDateFormats[format];
|
42048 |
if (Moment(firstRowData, testedFormat, true).isValid()) {
|
42049 |
-
var validationRule = (typeof(testedFormat) === 'function') ?
|
42050 |
'datetime' :
|
42051 |
testedFormat;
|
42052 |
// set validation on the column element
|
@@ -42160,7 +42160,7 @@ webpackJsonp([0],[
|
|
42160 |
});
|
42161 |
|
42162 |
_.each(subscribers, function () {
|
42163 |
-
queue.add(function(queue) {
|
42164 |
queue.pause();
|
42165 |
MailPoet.Ajax.post({
|
42166 |
api_version: window.mailpoet_api_version,
|
@@ -42173,17 +42173,17 @@ webpackJsonp([0],[
|
|
42173 |
segments: segmentSelectElement.val(),
|
42174 |
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes')
|
42175 |
})
|
42176 |
-
}).done(function(response) {
|
42177 |
importResults.created += response.data.created;
|
42178 |
importResults.updated += response.data.updated;
|
42179 |
importResults.segments = response.data.segments;
|
42180 |
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
|
42181 |
queue.run();
|
42182 |
-
}).fail(function(response) {
|
42183 |
MailPoet.Modal.loading(false);
|
42184 |
if (response.errors.length > 0) {
|
42185 |
MailPoet.Notice.error(
|
42186 |
-
response.errors.map(function(error) { return error.message; }),
|
42187 |
{ scroll: true }
|
42188 |
);
|
42189 |
}
|
@@ -42208,7 +42208,7 @@ webpackJsonp([0],[
|
|
42208 |
});
|
42209 |
window.importData.step2 = importResults;
|
42210 |
enableSegmentSelection(window.mailpoetSegments);
|
42211 |
-
router.navigate('step3', {trigger: true});
|
42212 |
}
|
42213 |
});
|
42214 |
});
|
@@ -42219,7 +42219,7 @@ webpackJsonp([0],[
|
|
42219 |
|
42220 |
router.on('route:step3', function () {
|
42221 |
if (typeof (window.importData.step2) === 'undefined') {
|
42222 |
-
router.navigate('step2', {trigger: true});
|
42223 |
return;
|
42224 |
}
|
42225 |
|
@@ -42262,7 +42262,7 @@ webpackJsonp([0],[
|
|
42262 |
|
42263 |
jQuery('a.mailpoet_import_again').off().click(function () {
|
42264 |
jQuery('#subscribers_data_import_results').hide();
|
42265 |
-
router.navigate('step1', {trigger: true});
|
42266 |
});
|
42267 |
|
42268 |
jQuery('a.mailpoet_view_subscribers').off().click(function () {
|
@@ -42410,7 +42410,7 @@ webpackJsonp([0],[
|
|
42410 |
var subscribers_export_template =
|
42411 |
Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
|
42412 |
|
42413 |
-
//render template
|
42414 |
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribers_export_template(window.exportData));
|
42415 |
|
42416 |
// define reusable variables
|
@@ -42536,9 +42536,9 @@ webpackJsonp([0],[
|
|
42536 |
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
|
42537 |
subscriber_fields: subscriberFieldsContainerElement.val()
|
42538 |
})
|
42539 |
-
}).always(function(response) {
|
42540 |
MailPoet.Modal.loading(false);
|
42541 |
-
}).done(function(response) {
|
42542 |
var resultMessage = MailPoet.I18n.t('exportMessage')
|
42543 |
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
42544 |
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
@@ -42551,10 +42551,10 @@ webpackJsonp([0],[
|
|
42551 |
'File Format': exportFormat,
|
42552 |
'MailPoet Free version': window.mailpoet_version
|
42553 |
});
|
42554 |
-
}).fail(function(response) {
|
42555 |
if (response.errors.length > 0) {
|
42556 |
MailPoet.Notice.error(
|
42557 |
-
response.errors.map(function(error) { return error.message; }),
|
42558 |
{ scroll: true }
|
42559 |
);
|
42560 |
}
|
38778 |
__webpack_require__(535),
|
38779 |
__webpack_require__(273),
|
38780 |
__webpack_require__(274)
|
38781 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
38782 |
Backbone,
|
38783 |
jQuery,
|
38784 |
mp
|
38785 |
) {
|
38786 |
var MailPoet = mp;
|
38787 |
+
if (jQuery('#mailpoet_settings').length === 0) {
|
38788 |
return;
|
38789 |
}
|
38790 |
|
38794 |
'mta(/:group)': 'sendingMethodGroup',
|
38795 |
'(:tab)': 'tabs'
|
38796 |
},
|
38797 |
+
sendingMethodGroup: function (group) {
|
38798 |
// display mta tab
|
38799 |
this.tabs('mta');
|
38800 |
|
38806 |
// hide "save settings" button
|
38807 |
jQuery('.mailpoet_settings_submit').hide();
|
38808 |
|
38809 |
+
if (group === null) {
|
38810 |
// show sending methods
|
38811 |
jQuery('.mailpoet_sending_methods, .mailpoet_sending_methods_help').fadeIn();
|
38812 |
} else {
|
38821 |
jQuery('.mailpoet_sending_methods, .mailpoet_sending_methods_help').hide();
|
38822 |
|
38823 |
// display selected sending method's settings
|
38824 |
+
jQuery('.mailpoet_sending_method[data-group="' + group + '"]').show();
|
38825 |
jQuery('#mailpoet_sending_method_setup').fadeIn();
|
38826 |
}
|
38827 |
},
|
38828 |
+
tabs: function (tabStr, section) {
|
38829 |
// set default tab
|
38830 |
var tab = tabStr || 'mta';
|
38831 |
|
38836 |
jQuery('.mailpoet_panel, .mailpoet_section').hide();
|
38837 |
|
38838 |
// set active tab
|
38839 |
+
jQuery('a.nav-tab[href="#' + tab + '"]').addClass('nav-tab-active').blur();
|
38840 |
|
38841 |
// show selected panel
|
38842 |
+
if (jQuery('.mailpoet_panel[data-tab="' + tab + '"]').length > 0) {
|
38843 |
+
jQuery('.mailpoet_panel[data-tab="' + tab + '"]').show();
|
38844 |
}
|
38845 |
|
38846 |
// show "save settings" button
|
38856 |
}
|
38857 |
}));
|
38858 |
|
38859 |
+
jQuery(document).ready(function () {
|
38860 |
if (!Backbone.History.started) Backbone.history.start();
|
38861 |
});
|
38862 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
41107 |
|
41108 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
41109 |
__webpack_require__(274)
|
41110 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
41111 |
MailPoet
|
41112 |
) {
|
41113 |
|
41115 |
if (confirm(MailPoet.I18n.t('reinstallConfirmation'))) {
|
41116 |
MailPoet.trackEvent(
|
41117 |
'User has reinstalled MailPoet via Settings',
|
41118 |
+
{ 'MailPoet Free version': window.mailpoet_version }
|
41119 |
);
|
41120 |
|
41121 |
MailPoet.Modal.loading(true);
|
41133 |
response.errors.map(function (error) {
|
41134 |
return error.message;
|
41135 |
}),
|
41136 |
+
{ scroll: true }
|
41137 |
);
|
41138 |
}
|
41139 |
});
|
41186 |
step3: 'step3'
|
41187 |
},
|
41188 |
home: function () {
|
41189 |
+
this.navigate('step1', { trigger: true });
|
41190 |
}
|
41191 |
}));
|
41192 |
|
41348 |
data: {
|
41349 |
api_key: mailChimpKeyInputElement.val()
|
41350 |
}
|
41351 |
+
}).always(function () {
|
41352 |
MailPoet.Modal.loading(false);
|
41353 |
+
}).done(function (response) {
|
41354 |
jQuery('.mailpoet_mailchimp-key-status')
|
41355 |
.html('')
|
41356 |
.removeClass()
|
41362 |
} else {
|
41363 |
displayMailChimpLists(response.data);
|
41364 |
}
|
41365 |
+
}).fail(function (response) {
|
41366 |
if (response.errors.length > 0) {
|
41367 |
MailPoet.Notice.error(
|
41368 |
+
response.errors.map(function (error) { return error.message; }),
|
41369 |
{ scroll: true }
|
41370 |
);
|
41371 |
}
|
41385 |
api_key: mailChimpKeyInputElement.val(),
|
41386 |
lists: mailChimpListsContainerElement.find('select').val()
|
41387 |
}
|
41388 |
+
}).always(function (response) {
|
41389 |
MailPoet.Modal.loading(false);
|
41390 |
+
}).done(function (response) {
|
41391 |
window.importData.step1 = response.data;
|
41392 |
MailPoet.trackEvent('Subscribers import started', {
|
41393 |
source: 'MailChimp',
|
41394 |
'MailPoet Free version': window.mailpoet_version
|
41395 |
});
|
41396 |
+
router.navigate('step2', { trigger: true });
|
41397 |
+
}).fail(function (response) {
|
41398 |
if (response.errors.length > 0) {
|
41399 |
MailPoet.Notice.error(
|
41400 |
+
response.errors.map(function (error) { return error.message; }),
|
41401 |
{ scroll: true }
|
41402 |
);
|
41403 |
}
|
41482 |
email = test[1].trim();
|
41483 |
}
|
41484 |
// test for valid characters using WP's rule (https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/formatting.php#L2902)
|
41485 |
+
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email)) {
|
41486 |
return false;
|
41487 |
}
|
41488 |
return email;
|
41574 |
source: isFile ? 'file upload' : 'pasted data',
|
41575 |
'MailPoet Free version': window.mailpoet_version
|
41576 |
});
|
41577 |
+
router.navigate('step2', { trigger: true });
|
41578 |
}
|
41579 |
else {
|
41580 |
MailPoet.Modal.loading(false);
|
41590 |
|
41591 |
router.on('route:step2', function () {
|
41592 |
if (typeof (window.importData.step1) === 'undefined') {
|
41593 |
+
router.navigate('step1', { trigger: true });
|
41594 |
return;
|
41595 |
}
|
41596 |
// define reusable variables
|
41727 |
});
|
41728 |
}
|
41729 |
|
41730 |
+
jQuery('.mailpoet_create_segment').click(function () {
|
41731 |
MailPoet.Modal.popup({
|
41732 |
title: MailPoet.I18n.t('addNewList'),
|
41733 |
template: jQuery('#new_segment_template').html()
|
41734 |
});
|
41735 |
+
jQuery('#new_segment_name').keypress(function (e) {
|
41736 |
if (e.which == 13) {
|
41737 |
jQuery('#new_segment_process').click();
|
41738 |
}
|
41749 |
name: segmentName,
|
41750 |
description: segmentDescription
|
41751 |
}
|
41752 |
+
}).done(function (response) {
|
41753 |
window.mailpoetSegments.push({
|
41754 |
id: response.data.id,
|
41755 |
name: response.data.name,
|
41768 |
jQuery('.mailpoet_segments:hidden').show();
|
41769 |
jQuery('.mailpoet_no_segments:visible').hide();
|
41770 |
MailPoet.Modal.close();
|
41771 |
+
}).fail(function (response) {
|
41772 |
if (response.errors.length > 0) {
|
41773 |
MailPoet.Notice.hide();
|
41774 |
MailPoet.Notice.error(
|
41775 |
+
response.errors.map(function (error) { return error.message; }),
|
41776 |
{ positionAfter: '#new_segment_name' }
|
41777 |
);
|
41778 |
}
|
41829 |
&& displayedColumnsIds.indexOf(columnId) === -1)
|
41830 |
? columnId
|
41831 |
: 'ignore';
|
41832 |
+
displayedColumns[i] = { column_id: columnId };
|
41833 |
displayedColumnsIds.push(columnId);
|
41834 |
}
|
41835 |
return options.fn(displayedColumns);
|
41836 |
});
|
41837 |
|
41838 |
// sanitize unsafe data
|
41839 |
+
Handlebars.registerHelper('sanitize_data', function (data) {
|
41840 |
return (data instanceof Handlebars.SafeString) ?
|
41841 |
data :
|
41842 |
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
41894 |
title: MailPoet.I18n.t('addNewField'),
|
41895 |
template: jQuery('#form_template_field_form').html()
|
41896 |
});
|
41897 |
+
jQuery('#form_field_new').parsley().on('form:submit', function (parsley) {
|
41898 |
// get data
|
41899 |
var data = jQuery(this.$element).serializeObject();
|
41900 |
|
41904 |
endpoint: 'customFields',
|
41905 |
action: 'save',
|
41906 |
data: data
|
41907 |
+
}).done(function (response) {
|
41908 |
var new_column_data = {
|
41909 |
id: response.data.id,
|
41910 |
name: response.data.name,
|
41942 |
filterSubscribers();
|
41943 |
// close popup
|
41944 |
MailPoet.Modal.close();
|
41945 |
+
}).fail(function (response) {
|
41946 |
if (response.errors.length > 0) {
|
41947 |
MailPoet.Notice.error(
|
41948 |
+
response.errors.map(function (error) { return error.message; }),
|
41949 |
{ positionAfter: '#field_name' }
|
41950 |
);
|
41951 |
}
|
41999 |
jQuery.map(window.mailpoetColumns, function (column, columnIndex) {
|
42000 |
// check if the column id matches the selected id of one of the
|
42001 |
// subscriber's data columns
|
42002 |
+
var matchedColumn = _.find(displayedColumns, function (data) { return data.id === column.id; });
|
42003 |
// EMAIL filter: if the first value in the column doesn't have a valid
|
42004 |
// email, hide the next button
|
42005 |
if (column.id === 'email') {
|
42046 |
for (var format in allowedDateFormats) {
|
42047 |
var testedFormat = allowedDateFormats[format];
|
42048 |
if (Moment(firstRowData, testedFormat, true).isValid()) {
|
42049 |
+
var validationRule = (typeof (testedFormat) === 'function') ?
|
42050 |
'datetime' :
|
42051 |
testedFormat;
|
42052 |
// set validation on the column element
|
42160 |
});
|
42161 |
|
42162 |
_.each(subscribers, function () {
|
42163 |
+
queue.add(function (queue) {
|
42164 |
queue.pause();
|
42165 |
MailPoet.Ajax.post({
|
42166 |
api_version: window.mailpoet_api_version,
|
42173 |
segments: segmentSelectElement.val(),
|
42174 |
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes')
|
42175 |
})
|
42176 |
+
}).done(function (response) {
|
42177 |
importResults.created += response.data.created;
|
42178 |
importResults.updated += response.data.updated;
|
42179 |
importResults.segments = response.data.segments;
|
42180 |
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
|
42181 |
queue.run();
|
42182 |
+
}).fail(function (response) {
|
42183 |
MailPoet.Modal.loading(false);
|
42184 |
if (response.errors.length > 0) {
|
42185 |
MailPoet.Notice.error(
|
42186 |
+
response.errors.map(function (error) { return error.message; }),
|
42187 |
{ scroll: true }
|
42188 |
);
|
42189 |
}
|
42208 |
});
|
42209 |
window.importData.step2 = importResults;
|
42210 |
enableSegmentSelection(window.mailpoetSegments);
|
42211 |
+
router.navigate('step3', { trigger: true });
|
42212 |
}
|
42213 |
});
|
42214 |
});
|
42219 |
|
42220 |
router.on('route:step3', function () {
|
42221 |
if (typeof (window.importData.step2) === 'undefined') {
|
42222 |
+
router.navigate('step2', { trigger: true });
|
42223 |
return;
|
42224 |
}
|
42225 |
|
42262 |
|
42263 |
jQuery('a.mailpoet_import_again').off().click(function () {
|
42264 |
jQuery('#subscribers_data_import_results').hide();
|
42265 |
+
router.navigate('step1', { trigger: true });
|
42266 |
});
|
42267 |
|
42268 |
jQuery('a.mailpoet_view_subscribers').off().click(function () {
|
42410 |
var subscribers_export_template =
|
42411 |
Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
|
42412 |
|
42413 |
+
// render template
|
42414 |
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribers_export_template(window.exportData));
|
42415 |
|
42416 |
// define reusable variables
|
42536 |
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
|
42537 |
subscriber_fields: subscriberFieldsContainerElement.val()
|
42538 |
})
|
42539 |
+
}).always(function (response) {
|
42540 |
MailPoet.Modal.loading(false);
|
42541 |
+
}).done(function (response) {
|
42542 |
var resultMessage = MailPoet.I18n.t('exportMessage')
|
42543 |
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
42544 |
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
42551 |
'File Format': exportFormat,
|
42552 |
'MailPoet Free version': window.mailpoet_version
|
42553 |
});
|
42554 |
+
}).fail(function (response) {
|
42555 |
if (response.errors.length > 0) {
|
42556 |
MailPoet.Notice.error(
|
42557 |
+
response.errors.map(function (error) { return error.message; }),
|
42558 |
{ scroll: true }
|
42559 |
);
|
42560 |
}
|
assets/js/{admin_vendor.c1a3e332.js → admin_vendor.53a6d3ec.js}
RENAMED
@@ -771,11 +771,9 @@ webpackJsonp([1],[
|
|
771 |
|
772 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
773 |
* Copyright (c) 2013-present, Facebook, Inc.
|
774 |
-
* All rights reserved.
|
775 |
*
|
776 |
-
* This source code is licensed under the
|
777 |
-
* LICENSE file in the root directory of this source tree.
|
778 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
779 |
*
|
780 |
*/
|
781 |
|
@@ -1212,12 +1210,10 @@ webpackJsonp([1],[
|
|
1212 |
/***/ function(module, exports, __webpack_require__) {
|
1213 |
|
1214 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1215 |
-
* Copyright 2014-
|
1216 |
-
* All rights reserved.
|
1217 |
*
|
1218 |
-
* This source code is licensed under the
|
1219 |
-
* LICENSE file in the root directory of this source tree.
|
1220 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
1221 |
*
|
1222 |
*/
|
1223 |
|
@@ -1285,11 +1281,9 @@ webpackJsonp([1],[
|
|
1285 |
|
1286 |
/**
|
1287 |
* Copyright (c) 2013-present, Facebook, Inc.
|
1288 |
-
* All rights reserved.
|
1289 |
*
|
1290 |
-
* This source code is licensed under the
|
1291 |
-
* LICENSE file in the root directory of this source tree.
|
1292 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
1293 |
*
|
1294 |
*
|
1295 |
*/
|
@@ -1894,11 +1888,9 @@ webpackJsonp([1],[
|
|
1894 |
|
1895 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1896 |
* Copyright (c) 2013-present, Facebook, Inc.
|
1897 |
-
* All rights reserved.
|
1898 |
*
|
1899 |
-
* This source code is licensed under the
|
1900 |
-
* LICENSE file in the root directory of this source tree.
|
1901 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
1902 |
*
|
1903 |
*/
|
1904 |
|
@@ -6338,11 +6330,9 @@ webpackJsonp([1],[
|
|
6338 |
|
6339 |
/**
|
6340 |
* Copyright (c) 2013-present, Facebook, Inc.
|
6341 |
-
* All rights reserved.
|
6342 |
*
|
6343 |
-
* This source code is licensed under the
|
6344 |
-
* LICENSE file in the root directory of this source tree.
|
6345 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
6346 |
*
|
6347 |
*/
|
6348 |
|
@@ -8558,11 +8548,9 @@ webpackJsonp([1],[
|
|
8558 |
|
8559 |
/**
|
8560 |
* Copyright (c) 2013-present, Facebook, Inc.
|
8561 |
-
* All rights reserved.
|
8562 |
*
|
8563 |
-
* This source code is licensed under the
|
8564 |
-
* LICENSE file in the root directory of this source tree.
|
8565 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8566 |
*
|
8567 |
* @typechecks
|
8568 |
*/
|
@@ -8594,11 +8582,9 @@ webpackJsonp([1],[
|
|
8594 |
|
8595 |
/**
|
8596 |
* Copyright (c) 2013-present, Facebook, Inc.
|
8597 |
-
* All rights reserved.
|
8598 |
*
|
8599 |
-
* This source code is licensed under the
|
8600 |
-
* LICENSE file in the root directory of this source tree.
|
8601 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8602 |
*
|
8603 |
* @typechecks
|
8604 |
*/
|
@@ -10362,11 +10348,9 @@ webpackJsonp([1],[
|
|
10362 |
|
10363 |
/**
|
10364 |
* Copyright (c) 2013-present, Facebook, Inc.
|
10365 |
-
* All rights reserved.
|
10366 |
*
|
10367 |
-
* This source code is licensed under the
|
10368 |
-
* LICENSE file in the root directory of this source tree.
|
10369 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
10370 |
*
|
10371 |
* @typechecks
|
10372 |
*/
|
@@ -10451,11 +10435,9 @@ webpackJsonp([1],[
|
|
10451 |
|
10452 |
/**
|
10453 |
* Copyright (c) 2013-present, Facebook, Inc.
|
10454 |
-
* All rights reserved.
|
10455 |
*
|
10456 |
-
* This source code is licensed under the
|
10457 |
-
* LICENSE file in the root directory of this source tree.
|
10458 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
10459 |
*
|
10460 |
* @typechecks
|
10461 |
*/
|
@@ -10583,11 +10565,9 @@ webpackJsonp([1],[
|
|
10583 |
|
10584 |
/**
|
10585 |
* Copyright (c) 2013-present, Facebook, Inc.
|
10586 |
-
* All rights reserved.
|
10587 |
*
|
10588 |
-
* This source code is licensed under the
|
10589 |
-
* LICENSE file in the root directory of this source tree.
|
10590 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
10591 |
*
|
10592 |
*/
|
10593 |
|
@@ -11753,11 +11733,9 @@ webpackJsonp([1],[
|
|
11753 |
|
11754 |
/**
|
11755 |
* Copyright (c) 2013-present, Facebook, Inc.
|
11756 |
-
* All rights reserved.
|
11757 |
*
|
11758 |
-
* This source code is licensed under the
|
11759 |
-
* LICENSE file in the root directory of this source tree.
|
11760 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
11761 |
*
|
11762 |
*/
|
11763 |
|
@@ -12150,11 +12128,9 @@ webpackJsonp([1],[
|
|
12150 |
|
12151 |
/**
|
12152 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12153 |
-
* All rights reserved.
|
12154 |
*
|
12155 |
-
* This source code is licensed under the
|
12156 |
-
* LICENSE file in the root directory of this source tree.
|
12157 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12158 |
*
|
12159 |
* @typechecks
|
12160 |
*/
|
@@ -12196,11 +12172,9 @@ webpackJsonp([1],[
|
|
12196 |
|
12197 |
/**
|
12198 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12199 |
-
* All rights reserved.
|
12200 |
*
|
12201 |
-
* This source code is licensed under the
|
12202 |
-
* LICENSE file in the root directory of this source tree.
|
12203 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12204 |
*
|
12205 |
* @typechecks
|
12206 |
*/
|
@@ -12314,11 +12288,9 @@ webpackJsonp([1],[
|
|
12314 |
|
12315 |
/**
|
12316 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12317 |
-
* All rights reserved.
|
12318 |
*
|
12319 |
-
* This source code is licensed under the
|
12320 |
-
* LICENSE file in the root directory of this source tree.
|
12321 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12322 |
*
|
12323 |
* @typechecks
|
12324 |
*/
|
@@ -12359,11 +12331,9 @@ webpackJsonp([1],[
|
|
12359 |
|
12360 |
/**
|
12361 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12362 |
-
* All rights reserved.
|
12363 |
*
|
12364 |
-
* This source code is licensed under the
|
12365 |
-
* LICENSE file in the root directory of this source tree.
|
12366 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12367 |
*
|
12368 |
* @typechecks
|
12369 |
*/
|
@@ -12394,11 +12364,9 @@ webpackJsonp([1],[
|
|
12394 |
|
12395 |
/**
|
12396 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12397 |
-
* All rights reserved.
|
12398 |
*
|
12399 |
-
* This source code is licensed under the
|
12400 |
-
* LICENSE file in the root directory of this source tree.
|
12401 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12402 |
*
|
12403 |
*
|
12404 |
* @typechecks static-only
|
@@ -16040,11 +16008,9 @@ webpackJsonp([1],[
|
|
16040 |
|
16041 |
/**
|
16042 |
* Copyright (c) 2013-present, Facebook, Inc.
|
16043 |
-
* All rights reserved.
|
16044 |
*
|
16045 |
-
* This source code is licensed under the
|
16046 |
-
* LICENSE file in the root directory of this source tree.
|
16047 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
16048 |
*
|
16049 |
* @typechecks
|
16050 |
*
|
@@ -18148,11 +18114,9 @@ webpackJsonp([1],[
|
|
18148 |
|
18149 |
/**
|
18150 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18151 |
-
* All rights reserved.
|
18152 |
*
|
18153 |
-
* This source code is licensed under the
|
18154 |
-
* LICENSE file in the root directory of this source tree.
|
18155 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18156 |
*
|
18157 |
* @typechecks
|
18158 |
*/
|
@@ -18228,11 +18192,9 @@ webpackJsonp([1],[
|
|
18228 |
|
18229 |
/**
|
18230 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18231 |
-
* All rights reserved.
|
18232 |
*
|
18233 |
-
* This source code is licensed under the
|
18234 |
-
* LICENSE file in the root directory of this source tree.
|
18235 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18236 |
*
|
18237 |
* @typechecks
|
18238 |
*/
|
@@ -18916,11 +18878,9 @@ webpackJsonp([1],[
|
|
18916 |
|
18917 |
/**
|
18918 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18919 |
-
* All rights reserved.
|
18920 |
*
|
18921 |
-
* This source code is licensed under the
|
18922 |
-
* LICENSE file in the root directory of this source tree.
|
18923 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18924 |
*
|
18925 |
*
|
18926 |
*/
|
@@ -18960,11 +18920,9 @@ webpackJsonp([1],[
|
|
18960 |
|
18961 |
/**
|
18962 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18963 |
-
* All rights reserved.
|
18964 |
*
|
18965 |
-
* This source code is licensed under the
|
18966 |
-
* LICENSE file in the root directory of this source tree.
|
18967 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18968 |
*
|
18969 |
* @typechecks
|
18970 |
*/
|
@@ -18989,11 +18947,9 @@ webpackJsonp([1],[
|
|
18989 |
|
18990 |
/**
|
18991 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18992 |
-
* All rights reserved.
|
18993 |
*
|
18994 |
-
* This source code is licensed under the
|
18995 |
-
* LICENSE file in the root directory of this source tree.
|
18996 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18997 |
*
|
18998 |
* @typechecks
|
18999 |
*/
|
@@ -19018,11 +18974,9 @@ webpackJsonp([1],[
|
|
19018 |
|
19019 |
/**
|
19020 |
* Copyright (c) 2013-present, Facebook, Inc.
|
19021 |
-
* All rights reserved.
|
19022 |
*
|
19023 |
-
* This source code is licensed under the
|
19024 |
-
* LICENSE file in the root directory of this source tree.
|
19025 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
19026 |
*
|
19027 |
* @typechecks
|
19028 |
*/
|
@@ -21726,12 +21680,10 @@ webpackJsonp([1],[
|
|
21726 |
/***/ function(module, exports, __webpack_require__) {
|
21727 |
|
21728 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21729 |
-
* Copyright 2013-present, Facebook, Inc.
|
21730 |
-
* All rights reserved.
|
21731 |
*
|
21732 |
-
* This source code is licensed under the
|
21733 |
-
* LICENSE file in the root directory of this source tree.
|
21734 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
21735 |
*/
|
21736 |
|
21737 |
if (process.env.NODE_ENV !== 'production') {
|
@@ -21763,12 +21715,10 @@ webpackJsonp([1],[
|
|
21763 |
/***/ function(module, exports, __webpack_require__) {
|
21764 |
|
21765 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21766 |
-
* Copyright 2013-present, Facebook, Inc.
|
21767 |
-
* All rights reserved.
|
21768 |
*
|
21769 |
-
* This source code is licensed under the
|
21770 |
-
* LICENSE file in the root directory of this source tree.
|
21771 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
21772 |
*/
|
21773 |
|
21774 |
'use strict';
|
@@ -21776,6 +21726,7 @@ webpackJsonp([1],[
|
|
21776 |
var emptyFunction = __webpack_require__(14);
|
21777 |
var invariant = __webpack_require__(10);
|
21778 |
var warning = __webpack_require__(13);
|
|
|
21779 |
|
21780 |
var ReactPropTypesSecret = __webpack_require__(186);
|
21781 |
var checkPropTypes = __webpack_require__(187);
|
@@ -21874,7 +21825,8 @@ webpackJsonp([1],[
|
|
21874 |
objectOf: createObjectOfTypeChecker,
|
21875 |
oneOf: createEnumTypeChecker,
|
21876 |
oneOfType: createUnionTypeChecker,
|
21877 |
-
shape: createShapeTypeChecker
|
|
|
21878 |
};
|
21879 |
|
21880 |
/**
|
@@ -22089,7 +22041,7 @@ webpackJsonp([1],[
|
|
22089 |
if (typeof checker !== 'function') {
|
22090 |
warning(
|
22091 |
false,
|
22092 |
-
'Invalid argument
|
22093 |
'received %s at index %s.',
|
22094 |
getPostfixForTypeWarning(checker),
|
22095 |
i
|
@@ -22143,6 +22095,36 @@ webpackJsonp([1],[
|
|
22143 |
return createChainableTypeChecker(validate);
|
22144 |
}
|
22145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22146 |
function isNode(propValue) {
|
22147 |
switch (typeof propValue) {
|
22148 |
case 'number':
|
@@ -22282,12 +22264,10 @@ webpackJsonp([1],[
|
|
22282 |
/***/ function(module, exports) {
|
22283 |
|
22284 |
/**
|
22285 |
-
* Copyright 2013-present, Facebook, Inc.
|
22286 |
-
* All rights reserved.
|
22287 |
*
|
22288 |
-
* This source code is licensed under the
|
22289 |
-
* LICENSE file in the root directory of this source tree.
|
22290 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22291 |
*/
|
22292 |
|
22293 |
'use strict';
|
@@ -22302,12 +22282,10 @@ webpackJsonp([1],[
|
|
22302 |
/***/ function(module, exports, __webpack_require__) {
|
22303 |
|
22304 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
22305 |
-
* Copyright 2013-present, Facebook, Inc.
|
22306 |
-
* All rights reserved.
|
22307 |
*
|
22308 |
-
* This source code is licensed under the
|
22309 |
-
* LICENSE file in the root directory of this source tree.
|
22310 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22311 |
*/
|
22312 |
|
22313 |
'use strict';
|
@@ -22341,7 +22319,7 @@ webpackJsonp([1],[
|
|
22341 |
try {
|
22342 |
// This is intentionally an invariant that gets caught. It's the same
|
22343 |
// behavior as without this statement except with a better message.
|
22344 |
-
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + '
|
22345 |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
22346 |
} catch (ex) {
|
22347 |
error = ex;
|
@@ -22370,12 +22348,10 @@ webpackJsonp([1],[
|
|
22370 |
/***/ function(module, exports, __webpack_require__) {
|
22371 |
|
22372 |
/**
|
22373 |
-
* Copyright 2013-present, Facebook, Inc.
|
22374 |
-
* All rights reserved.
|
22375 |
*
|
22376 |
-
* This source code is licensed under the
|
22377 |
-
* LICENSE file in the root directory of this source tree.
|
22378 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22379 |
*/
|
22380 |
|
22381 |
'use strict';
|
@@ -22420,7 +22396,8 @@ webpackJsonp([1],[
|
|
22420 |
objectOf: getShim,
|
22421 |
oneOf: getShim,
|
22422 |
oneOfType: getShim,
|
22423 |
-
shape: getShim
|
|
|
22424 |
};
|
22425 |
|
22426 |
ReactPropTypes.checkPropTypes = emptyFunction;
|
@@ -22926,12 +22903,10 @@ webpackJsonp([1],[
|
|
22926 |
/***/ function(module, exports, __webpack_require__) {
|
22927 |
|
22928 |
/**
|
22929 |
-
* Copyright 2013-present, Facebook, Inc.
|
22930 |
-
* All rights reserved.
|
22931 |
*
|
22932 |
-
* This source code is licensed under the
|
22933 |
-
* LICENSE file in the root directory of this source tree.
|
22934 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22935 |
*
|
22936 |
*/
|
22937 |
|
@@ -22962,12 +22937,10 @@ webpackJsonp([1],[
|
|
22962 |
/***/ function(module, exports, __webpack_require__) {
|
22963 |
|
22964 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
22965 |
-
* Copyright 2013-present, Facebook, Inc.
|
22966 |
-
* All rights reserved.
|
22967 |
*
|
22968 |
-
* This source code is licensed under the
|
22969 |
-
* LICENSE file in the root directory of this source tree.
|
22970 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22971 |
*
|
22972 |
*/
|
22973 |
|
@@ -28151,7 +28124,7 @@ webpackJsonp([1],[
|
|
28151 |
/* 274 */
|
28152 |
/***/ function(module, exports, __webpack_require__) {
|
28153 |
|
28154 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
|
28155 |
// A placeholder for MailPoet object
|
28156 |
var MailPoet = {};
|
28157 |
|
771 |
|
772 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
773 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
774 |
*
|
775 |
+
* This source code is licensed under the MIT license found in the
|
776 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
777 |
*
|
778 |
*/
|
779 |
|
1210 |
/***/ function(module, exports, __webpack_require__) {
|
1211 |
|
1212 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1213 |
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
1214 |
*
|
1215 |
+
* This source code is licensed under the MIT license found in the
|
1216 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
1217 |
*
|
1218 |
*/
|
1219 |
|
1281 |
|
1282 |
/**
|
1283 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
1284 |
*
|
1285 |
+
* This source code is licensed under the MIT license found in the
|
1286 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
1287 |
*
|
1288 |
*
|
1289 |
*/
|
1888 |
|
1889 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1890 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
1891 |
*
|
1892 |
+
* This source code is licensed under the MIT license found in the
|
1893 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
1894 |
*
|
1895 |
*/
|
1896 |
|
6330 |
|
6331 |
/**
|
6332 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
6333 |
*
|
6334 |
+
* This source code is licensed under the MIT license found in the
|
6335 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
6336 |
*
|
6337 |
*/
|
6338 |
|
8548 |
|
8549 |
/**
|
8550 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
8551 |
*
|
8552 |
+
* This source code is licensed under the MIT license found in the
|
8553 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
8554 |
*
|
8555 |
* @typechecks
|
8556 |
*/
|
8582 |
|
8583 |
/**
|
8584 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
8585 |
*
|
8586 |
+
* This source code is licensed under the MIT license found in the
|
8587 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
8588 |
*
|
8589 |
* @typechecks
|
8590 |
*/
|
10348 |
|
10349 |
/**
|
10350 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
10351 |
*
|
10352 |
+
* This source code is licensed under the MIT license found in the
|
10353 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
10354 |
*
|
10355 |
* @typechecks
|
10356 |
*/
|
10435 |
|
10436 |
/**
|
10437 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
10438 |
*
|
10439 |
+
* This source code is licensed under the MIT license found in the
|
10440 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
10441 |
*
|
10442 |
* @typechecks
|
10443 |
*/
|
10565 |
|
10566 |
/**
|
10567 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
10568 |
*
|
10569 |
+
* This source code is licensed under the MIT license found in the
|
10570 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
10571 |
*
|
10572 |
*/
|
10573 |
|
11733 |
|
11734 |
/**
|
11735 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
11736 |
*
|
11737 |
+
* This source code is licensed under the MIT license found in the
|
11738 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
11739 |
*
|
11740 |
*/
|
11741 |
|
12128 |
|
12129 |
/**
|
12130 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12131 |
*
|
12132 |
+
* This source code is licensed under the MIT license found in the
|
12133 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12134 |
*
|
12135 |
* @typechecks
|
12136 |
*/
|
12172 |
|
12173 |
/**
|
12174 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12175 |
*
|
12176 |
+
* This source code is licensed under the MIT license found in the
|
12177 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12178 |
*
|
12179 |
* @typechecks
|
12180 |
*/
|
12288 |
|
12289 |
/**
|
12290 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12291 |
*
|
12292 |
+
* This source code is licensed under the MIT license found in the
|
12293 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12294 |
*
|
12295 |
* @typechecks
|
12296 |
*/
|
12331 |
|
12332 |
/**
|
12333 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12334 |
*
|
12335 |
+
* This source code is licensed under the MIT license found in the
|
12336 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12337 |
*
|
12338 |
* @typechecks
|
12339 |
*/
|
12364 |
|
12365 |
/**
|
12366 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12367 |
*
|
12368 |
+
* This source code is licensed under the MIT license found in the
|
12369 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12370 |
*
|
12371 |
*
|
12372 |
* @typechecks static-only
|
16008 |
|
16009 |
/**
|
16010 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
16011 |
*
|
16012 |
+
* This source code is licensed under the MIT license found in the
|
16013 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
16014 |
*
|
16015 |
* @typechecks
|
16016 |
*
|
18114 |
|
18115 |
/**
|
18116 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18117 |
*
|
18118 |
+
* This source code is licensed under the MIT license found in the
|
18119 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18120 |
*
|
18121 |
* @typechecks
|
18122 |
*/
|
18192 |
|
18193 |
/**
|
18194 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18195 |
*
|
18196 |
+
* This source code is licensed under the MIT license found in the
|
18197 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18198 |
*
|
18199 |
* @typechecks
|
18200 |
*/
|
18878 |
|
18879 |
/**
|
18880 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18881 |
*
|
18882 |
+
* This source code is licensed under the MIT license found in the
|
18883 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18884 |
*
|
18885 |
*
|
18886 |
*/
|
18920 |
|
18921 |
/**
|
18922 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18923 |
*
|
18924 |
+
* This source code is licensed under the MIT license found in the
|
18925 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18926 |
*
|
18927 |
* @typechecks
|
18928 |
*/
|
18947 |
|
18948 |
/**
|
18949 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18950 |
*
|
18951 |
+
* This source code is licensed under the MIT license found in the
|
18952 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18953 |
*
|
18954 |
* @typechecks
|
18955 |
*/
|
18974 |
|
18975 |
/**
|
18976 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18977 |
*
|
18978 |
+
* This source code is licensed under the MIT license found in the
|
18979 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18980 |
*
|
18981 |
* @typechecks
|
18982 |
*/
|
21680 |
/***/ function(module, exports, __webpack_require__) {
|
21681 |
|
21682 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21683 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
21684 |
*
|
21685 |
+
* This source code is licensed under the MIT license found in the
|
21686 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
21687 |
*/
|
21688 |
|
21689 |
if (process.env.NODE_ENV !== 'production') {
|
21715 |
/***/ function(module, exports, __webpack_require__) {
|
21716 |
|
21717 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21718 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
21719 |
*
|
21720 |
+
* This source code is licensed under the MIT license found in the
|
21721 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
21722 |
*/
|
21723 |
|
21724 |
'use strict';
|
21726 |
var emptyFunction = __webpack_require__(14);
|
21727 |
var invariant = __webpack_require__(10);
|
21728 |
var warning = __webpack_require__(13);
|
21729 |
+
var assign = __webpack_require__(6);
|
21730 |
|
21731 |
var ReactPropTypesSecret = __webpack_require__(186);
|
21732 |
var checkPropTypes = __webpack_require__(187);
|
21825 |
objectOf: createObjectOfTypeChecker,
|
21826 |
oneOf: createEnumTypeChecker,
|
21827 |
oneOfType: createUnionTypeChecker,
|
21828 |
+
shape: createShapeTypeChecker,
|
21829 |
+
exact: createStrictShapeTypeChecker,
|
21830 |
};
|
21831 |
|
21832 |
/**
|
22041 |
if (typeof checker !== 'function') {
|
22042 |
warning(
|
22043 |
false,
|
22044 |
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
22045 |
'received %s at index %s.',
|
22046 |
getPostfixForTypeWarning(checker),
|
22047 |
i
|
22095 |
return createChainableTypeChecker(validate);
|
22096 |
}
|
22097 |
|
22098 |
+
function createStrictShapeTypeChecker(shapeTypes) {
|
22099 |
+
function validate(props, propName, componentName, location, propFullName) {
|
22100 |
+
var propValue = props[propName];
|
22101 |
+
var propType = getPropType(propValue);
|
22102 |
+
if (propType !== 'object') {
|
22103 |
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
22104 |
+
}
|
22105 |
+
// We need to check all keys in case some are required but missing from
|
22106 |
+
// props.
|
22107 |
+
var allKeys = assign({}, props[propName], shapeTypes);
|
22108 |
+
for (var key in allKeys) {
|
22109 |
+
var checker = shapeTypes[key];
|
22110 |
+
if (!checker) {
|
22111 |
+
return new PropTypeError(
|
22112 |
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
22113 |
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
22114 |
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
22115 |
+
);
|
22116 |
+
}
|
22117 |
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
22118 |
+
if (error) {
|
22119 |
+
return error;
|
22120 |
+
}
|
22121 |
+
}
|
22122 |
+
return null;
|
22123 |
+
}
|
22124 |
+
|
22125 |
+
return createChainableTypeChecker(validate);
|
22126 |
+
}
|
22127 |
+
|
22128 |
function isNode(propValue) {
|
22129 |
switch (typeof propValue) {
|
22130 |
case 'number':
|
22264 |
/***/ function(module, exports) {
|
22265 |
|
22266 |
/**
|
22267 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22268 |
*
|
22269 |
+
* This source code is licensed under the MIT license found in the
|
22270 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22271 |
*/
|
22272 |
|
22273 |
'use strict';
|
22282 |
/***/ function(module, exports, __webpack_require__) {
|
22283 |
|
22284 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
22285 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22286 |
*
|
22287 |
+
* This source code is licensed under the MIT license found in the
|
22288 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22289 |
*/
|
22290 |
|
22291 |
'use strict';
|
22319 |
try {
|
22320 |
// This is intentionally an invariant that gets caught. It's the same
|
22321 |
// behavior as without this statement except with a better message.
|
22322 |
+
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
22323 |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
22324 |
} catch (ex) {
|
22325 |
error = ex;
|
22348 |
/***/ function(module, exports, __webpack_require__) {
|
22349 |
|
22350 |
/**
|
22351 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22352 |
*
|
22353 |
+
* This source code is licensed under the MIT license found in the
|
22354 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22355 |
*/
|
22356 |
|
22357 |
'use strict';
|
22396 |
objectOf: getShim,
|
22397 |
oneOf: getShim,
|
22398 |
oneOfType: getShim,
|
22399 |
+
shape: getShim,
|
22400 |
+
exact: getShim
|
22401 |
};
|
22402 |
|
22403 |
ReactPropTypes.checkPropTypes = emptyFunction;
|
22903 |
/***/ function(module, exports, __webpack_require__) {
|
22904 |
|
22905 |
/**
|
22906 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22907 |
*
|
22908 |
+
* This source code is licensed under the MIT license found in the
|
22909 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22910 |
*
|
22911 |
*/
|
22912 |
|
22937 |
/***/ function(module, exports, __webpack_require__) {
|
22938 |
|
22939 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
22940 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22941 |
*
|
22942 |
+
* This source code is licensed under the MIT license found in the
|
22943 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22944 |
*
|
22945 |
*/
|
22946 |
|
28124 |
/* 274 */
|
28125 |
/***/ function(module, exports, __webpack_require__) {
|
28126 |
|
28127 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
|
28128 |
// A placeholder for MailPoet object
|
28129 |
var MailPoet = {};
|
28130 |
|
assets/js/{form_editor.00c531b6.js → form_editor.c4bc7e0b.js}
RENAMED
@@ -31,7 +31,7 @@ webpackJsonp([2],{
|
|
31 |
'use strict';
|
32 |
|
33 |
Event.cacheDelegated = {};
|
34 |
-
Object.extend(document, (function() {
|
35 |
var cache = Event.cacheDelegated;
|
36 |
|
37 |
function getCacheForSelector(selector) {
|
@@ -47,14 +47,14 @@ webpackJsonp([2],{
|
|
47 |
|
48 |
function findWrapper(selector, eventName, handler) {
|
49 |
var c = getWrappersForSelector(selector, eventName);
|
50 |
-
return c.find(function(wrapper) {
|
51 |
return wrapper.handler === handler;
|
52 |
});
|
53 |
}
|
54 |
|
55 |
function destroyWrapper(selector, eventName, handler) {
|
56 |
var c = getCacheForSelector(selector);
|
57 |
-
if(!c[eventName]) return false;
|
58 |
var wrapper = findWrapper(selector, eventName, handler);
|
59 |
c[eventName] = c[eventName].without(wrapper);
|
60 |
return wrapper;
|
@@ -62,95 +62,95 @@ webpackJsonp([2],{
|
|
62 |
|
63 |
function createWrapper(selector, eventName, handler, context) {
|
64 |
var wrapper, c = getWrappersForSelector(selector, eventName);
|
65 |
-
if(c.pluck('handler').include(handler)) return false;
|
66 |
-
wrapper = function(event) {
|
67 |
var element = event.findElement(selector);
|
68 |
-
if(element) handler.call(context || element, event, element);
|
69 |
};
|
70 |
wrapper.handler = handler;
|
71 |
c.push(wrapper);
|
72 |
return wrapper;
|
73 |
}
|
74 |
return {
|
75 |
-
delegate: function(selector, eventName, handler, context) {
|
76 |
var wrapper = createWrapper.apply(null, arguments);
|
77 |
-
if(wrapper) document.observe(eventName, wrapper);
|
78 |
return document;
|
79 |
},
|
80 |
-
stopDelegating: function(selector, eventName, handler) {
|
81 |
var length = arguments.length;
|
82 |
-
switch(length) {
|
83 |
case 2:
|
84 |
-
getWrappersForSelector(selector, eventName).each(function(wrapper) {
|
85 |
document.stopDelegating(selector, eventName, wrapper.handler);
|
86 |
});
|
87 |
break;
|
88 |
case 1:
|
89 |
-
Object.keys(getCacheForSelector(selector)).each(function(eventName) {
|
90 |
document.stopDelegating(selector, eventName);
|
91 |
});
|
92 |
break;
|
93 |
case 0:
|
94 |
-
Object.keys(cache).each(function(selector) {
|
95 |
document.stopDelegating(selector);
|
96 |
});
|
97 |
break;
|
98 |
default:
|
99 |
var wrapper = destroyWrapper.apply(null, arguments);
|
100 |
-
if(wrapper) document.stopObserving(eventName, wrapper);
|
101 |
}
|
102 |
return document;
|
103 |
}
|
104 |
};
|
105 |
})());
|
106 |
|
107 |
-
var Observable = (function() {
|
108 |
function getEventName(nameA, namespace) {
|
109 |
var name = nameA.substring(2);
|
110 |
-
if(namespace) name = namespace + ':' + name;
|
111 |
return name.underscore().split('_').join(':');
|
112 |
}
|
113 |
|
114 |
function getHandlers(klass) {
|
115 |
var proto = klass.prototype,
|
116 |
namespace = proto.namespace;
|
117 |
-
return Object.keys(proto).grep(/^on/).inject(window.$H(), function(handlers, name) {
|
118 |
-
if(name === 'onDomLoaded') return handlers;
|
119 |
handlers.set(getEventName(name, namespace), getWrapper(proto[name], klass));
|
120 |
return handlers;
|
121 |
});
|
122 |
}
|
123 |
|
124 |
function getWrapper(handler, klass) {
|
125 |
-
return function(event) {
|
126 |
return handler.call(new klass(this), event, event.memo);
|
127 |
};
|
128 |
}
|
129 |
|
130 |
function onDomLoad(selector, klass) {
|
131 |
-
window.$$(selector).each(function(element) {
|
132 |
new klass(element).onDomLoaded();
|
133 |
});
|
134 |
}
|
135 |
return {
|
136 |
-
observe: function(selector) {
|
137 |
-
if(!this.handlers) this.handlers = {};
|
138 |
-
if(this.handlers[selector]) return;
|
139 |
var klass = this;
|
140 |
-
if(this.prototype.onDomLoaded) {
|
141 |
-
if(document.loaded) {
|
142 |
onDomLoad(selector, klass);
|
143 |
} else {
|
144 |
document.observe('dom:loaded', onDomLoad.curry(selector, klass));
|
145 |
}
|
146 |
}
|
147 |
-
this.handlers[selector] = getHandlers(klass).each(function(handler) {
|
148 |
document.delegate(selector, handler.key, handler.value);
|
149 |
});
|
150 |
},
|
151 |
-
stopObserving: function(selector) {
|
152 |
-
if(!this.handlers || !this.handlers[selector]) return;
|
153 |
-
this.handlers[selector].each(function(handler) {
|
154 |
document.stopDelegating(selector, handler.key, handler.value);
|
155 |
});
|
156 |
delete this.handlers[selector];
|
@@ -160,55 +160,55 @@ webpackJsonp([2],{
|
|
160 |
|
161 |
// override droppables
|
162 |
Object.extend(window.Droppables, {
|
163 |
-
deactivate: window.Droppables.deactivate.wrap(function(proceed, drop, draggable) {
|
164 |
-
if(drop.onLeave) drop.onLeave(draggable, drop.element);
|
165 |
return proceed(drop);
|
166 |
}),
|
167 |
-
activate: window.Droppables.activate.wrap(function(proceed, drop, draggable) {
|
168 |
-
if(drop.onEnter) drop.onEnter(draggable, drop.element);
|
169 |
return proceed(drop);
|
170 |
}),
|
171 |
-
show: function(point, element) {
|
172 |
-
if(!this.drops.length) return;
|
173 |
var drop, affected = [];
|
174 |
-
this.drops.each(function(drop) {
|
175 |
-
if(window.Droppables.isAffected(point, element, drop)) affected.push(drop);
|
176 |
});
|
177 |
-
if(affected.length > 0) drop = window.Droppables.findDeepestChild(affected);
|
178 |
-
if(this.last_active && this.last_active !== drop) this.deactivate(this.last_active, element);
|
179 |
-
if(drop) {
|
180 |
window.Position.within(drop.element, point[0], point[1]);
|
181 |
-
if(drop.onHover) drop.onHover(element, drop.element, window.Position.overlap(drop.overlap, drop.element));
|
182 |
-
if(drop !== this.last_active) window.Droppables.activate(drop, element);
|
183 |
}
|
184 |
},
|
185 |
-
displayArea: function(draggable) {
|
186 |
-
if(!this.drops.length) return;
|
187 |
|
188 |
// hide controls when displaying drop areas.
|
189 |
WysijaForm.hideBlockControls();
|
190 |
|
191 |
-
this.drops.each(function(drop, iterator) {
|
192 |
-
if(drop.element.hasClassName('block_placeholder')) {
|
193 |
drop.element.addClassName('active');
|
194 |
}
|
195 |
});
|
196 |
},
|
197 |
-
hideArea: function() {
|
198 |
-
if(!this.drops.length) return;
|
199 |
-
this.drops.each(function(drop, iterator) {
|
200 |
-
if(drop.element.hasClassName('block_placeholder')) {
|
201 |
drop.element.removeClassName('active');
|
202 |
-
} else if(drop.element.hasClassName('image_placeholder')) {
|
203 |
drop.element.removeClassName('active');
|
204 |
drop.element.up().removeClassName('active');
|
205 |
-
} else if(drop.element.hasClassName('text_placeholder')) {
|
206 |
drop.element.removeClassName('active');
|
207 |
}
|
208 |
});
|
209 |
},
|
210 |
-
reset: function(draggable) {
|
211 |
-
if(this.last_active) this.deactivate(this.last_active, draggable);
|
212 |
}
|
213 |
});
|
214 |
|
@@ -221,18 +221,18 @@ webpackJsonp([2],{
|
|
221 |
var WysijaHistory = {
|
222 |
container: 'mailpoet_form_history',
|
223 |
size: 30,
|
224 |
-
enqueue: function(element) {
|
225 |
// create deep clone (includes child elements) of passed element
|
226 |
var clone = element.clone(true);
|
227 |
|
228 |
// check if the field is unique
|
229 |
-
if(parseInt(clone.readAttribute('wysija_unique'), 10) === 1) {
|
230 |
// check if the field is already in the queue
|
231 |
window.$(WysijaHistory.container).select('[wysija_name="' + clone.readAttribute('wysija_name') + '"]').invoke('remove');
|
232 |
}
|
233 |
|
234 |
// check history size
|
235 |
-
if(window.$(WysijaHistory.container).select('> div').length >= WysijaHistory.size) {
|
236 |
// remove oldest element (last in the list)
|
237 |
window.$(WysijaHistory.container).select('> div').last().remove();
|
238 |
}
|
@@ -242,21 +242,21 @@ webpackJsonp([2],{
|
|
242 |
top: clone
|
243 |
});
|
244 |
},
|
245 |
-
dequeue: function() {
|
246 |
// pop last block off the history
|
247 |
var block = window.$(WysijaHistory.container).select('div').first();
|
248 |
|
249 |
-
if(block !== undefined) {
|
250 |
// insert block back into the editor
|
251 |
window.$(WysijaForm.options.body).insert({
|
252 |
top: block
|
253 |
});
|
254 |
}
|
255 |
},
|
256 |
-
clear: function() {
|
257 |
window.$(WysijaHistory.container).innerHTML = '';
|
258 |
},
|
259 |
-
remove: function(field) {
|
260 |
window.$(WysijaHistory.container).select('[wysija_name="' + field + '"]').invoke('remove');
|
261 |
}
|
262 |
};
|
@@ -291,16 +291,16 @@ webpackJsonp([2],{
|
|
291 |
selectingColor: false,
|
292 |
showingTools: false
|
293 |
},
|
294 |
-
encodeHtmlValue: function(str) {
|
295 |
return str.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<').replace(/"/g, '"');
|
296 |
// ": fix for FileMerge because the previous line fucks up its syntax coloring
|
297 |
},
|
298 |
-
decodeHtmlValue: function(str) {
|
299 |
return str.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<').replace(/"/g, '"');
|
300 |
// ": fix for FileMerge because the previous line fucks up its syntax coloring
|
301 |
},
|
302 |
-
loading: function(is_loading) {
|
303 |
-
if(is_loading) {
|
304 |
window.$(WysijaForm.options.editor).addClassName('loading');
|
305 |
window.$(WysijaForm.options.toolbar).addClassName('loading');
|
306 |
} else {
|
@@ -308,36 +308,36 @@ webpackJsonp([2],{
|
|
308 |
window.$(WysijaForm.options.toolbar).removeClassName('loading');
|
309 |
}
|
310 |
},
|
311 |
-
loadStatic: function(blocks) {
|
312 |
-
window.$A(blocks).each(function(block) {
|
313 |
// create block
|
314 |
WysijaForm.Block.create(block, window.$('block_placeholder'));
|
315 |
});
|
316 |
},
|
317 |
-
load: function(data) {
|
318 |
-
if(data === undefined) return;
|
319 |
|
320 |
// load body
|
321 |
-
if(data.body !== undefined) {
|
322 |
-
window.$A(data.body).each(function(block) {
|
323 |
// create block
|
324 |
WysijaForm.Block.create(block, window.$('block_placeholder'));
|
325 |
});
|
326 |
|
327 |
// load settings
|
328 |
var settings_elements = window.$('mailpoet_form_settings').getElements();
|
329 |
-
settings_elements.each(function(setting) {
|
330 |
// skip lists
|
331 |
-
if(setting.name === 'segments') {
|
332 |
return true;
|
333 |
-
} else if(setting.name === 'on_success') {
|
334 |
// if the input value is equal to the one stored in the settings
|
335 |
-
if(setting.value === data.settings[setting.name]) {
|
336 |
// check selected value
|
337 |
window.$(setting).checked = true;
|
338 |
}
|
339 |
-
} else if(data.settings[setting.name] !== undefined) {
|
340 |
-
if(typeof data.settings[setting.name] === 'string') {
|
341 |
setting.setValue(WysijaForm.decodeHtmlValue(data.settings[setting.name]));
|
342 |
} else {
|
343 |
setting.setValue(data.settings[setting.name]);
|
@@ -346,7 +346,7 @@ webpackJsonp([2],{
|
|
346 |
});
|
347 |
}
|
348 |
},
|
349 |
-
save: function() {
|
350 |
var position = 1,
|
351 |
data = {
|
352 |
name: window.$F('mailpoet_form_name'),
|
@@ -355,10 +355,10 @@ webpackJsonp([2],{
|
|
355 |
styles: (window.MailPoet.CodeEditor !== undefined) ? window.MailPoet.CodeEditor.getValue() : null
|
356 |
};
|
357 |
// body
|
358 |
-
WysijaForm.getBlocks().each(function(b) {
|
359 |
-
var block_data = (typeof(b.block['save']) === 'function') ? b.block.save() : null;
|
360 |
|
361 |
-
if(block_data !== null) {
|
362 |
// set block position
|
363 |
block_data['position'] = position;
|
364 |
|
@@ -372,7 +372,7 @@ webpackJsonp([2],{
|
|
372 |
|
373 |
return data;
|
374 |
},
|
375 |
-
init: function() {
|
376 |
// set document scroll
|
377 |
info('init -> set scroll offsets');
|
378 |
WysijaForm.setScrollOffsets();
|
@@ -405,7 +405,7 @@ webpackJsonp([2],{
|
|
405 |
info('init -> toggle widgets');
|
406 |
WysijaForm.toggleWidgets();
|
407 |
},
|
408 |
-
getFieldData: function(element) {
|
409 |
// get basic field data
|
410 |
var data = {
|
411 |
type: element.readAttribute('wysija_type'),
|
@@ -418,25 +418,25 @@ webpackJsonp([2],{
|
|
418 |
};
|
419 |
|
420 |
// get params (may be empty)
|
421 |
-
if(element.readAttribute('wysija_params') !== null && element.readAttribute('wysija_params').length > 0) {
|
422 |
data.params = JSON.parse(element.readAttribute('wysija_params'));
|
423 |
}
|
424 |
return data;
|
425 |
},
|
426 |
-
toggleWidgets: function() {
|
427 |
window.$$('a[wysija_unique="1"]').invoke('removeClassName', 'disabled');
|
428 |
|
429 |
// loop through each unique field already inserted in the editor and disable its toolbar equivalent
|
430 |
-
window.$$('#' + WysijaForm.options.editor + ' [wysija_unique="1"]').map(function(element) {
|
431 |
var field = window.$$('#' + WysijaForm.options.toolbar + ' [wysija_id="' + element.readAttribute('wysija_id') + '"]');
|
432 |
-
if(field.length > 0) {
|
433 |
field.first().addClassName('disabled');
|
434 |
}
|
435 |
});
|
436 |
|
437 |
var hasSegmentSelection = WysijaForm.hasSegmentSelection();
|
438 |
|
439 |
-
if(hasSegmentSelection) {
|
440 |
window.$('mailpoet_form_segments').writeAttribute('required', false).disable();
|
441 |
window.$('mailpoet_settings_segment_selection').hide();
|
442 |
} else {
|
@@ -444,12 +444,12 @@ webpackJsonp([2],{
|
|
444 |
window.$('mailpoet_settings_segment_selection').show();
|
445 |
}
|
446 |
},
|
447 |
-
hasSegmentSelection: function() {
|
448 |
return (window.$$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]').length > 0);
|
449 |
},
|
450 |
-
isSegmentSelectionValid: function() {
|
451 |
var segment_selection = window.$$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]')[0];
|
452 |
-
if(segment_selection !== undefined) {
|
453 |
var block = WysijaForm.get(segment_selection).block.getData();
|
454 |
return (
|
455 |
(block.params.values !== undefined)
|
@@ -459,34 +459,34 @@ webpackJsonp([2],{
|
|
459 |
}
|
460 |
return false;
|
461 |
},
|
462 |
-
setBlockPositions: function(event, target) {
|
463 |
// release dragging lock
|
464 |
WysijaForm.locks.dragging = false;
|
465 |
|
466 |
var index = 1;
|
467 |
-
WysijaForm.getBlocks().each(function(container) {
|
468 |
container.setPosition(index++);
|
469 |
// remove z-index value to avoid issues when resizing images
|
470 |
-
if(container['block'] !== undefined) {
|
471 |
container.block.element.setStyle({
|
472 |
zIndex: ''
|
473 |
});
|
474 |
}
|
475 |
});
|
476 |
|
477 |
-
if(target !== undefined) {
|
478 |
// get placeholders (previous placeholder matches the placeholder linked to the next block)
|
479 |
var block_placeholder = window.$(target.element.readAttribute('wysija_placeholder')),
|
480 |
previous_placeholder = target.element.previous('.block_placeholder');
|
481 |
|
482 |
-
if(block_placeholder !== null) {
|
483 |
// put block placeholder before the current block
|
484 |
target.element.insert({
|
485 |
before: block_placeholder
|
486 |
});
|
487 |
|
488 |
// if the next block is a wysija_block, insert previous placeholder
|
489 |
-
if(target.element.next() !== undefined && target.element.next().hasClassName('mailpoet_form_block') && previous_placeholder !== undefined) {
|
490 |
target.element.insert({
|
491 |
after: previous_placeholder
|
492 |
});
|
@@ -494,18 +494,18 @@ webpackJsonp([2],{
|
|
494 |
}
|
495 |
}
|
496 |
},
|
497 |
-
setScrollOffsets: function() {
|
498 |
WysijaForm.scroll = document.viewport.getScrollOffsets();
|
499 |
},
|
500 |
-
hideSettings: function() {
|
501 |
window.$(WysijaForm.options.container).select('.wysija_settings').invoke('hide');
|
502 |
},
|
503 |
-
setSettingsPosition: function() {
|
504 |
// get viewport offsets and dimensions
|
505 |
var viewportHeight = document.viewport.getHeight(),
|
506 |
blockPadding = 5;
|
507 |
|
508 |
-
window.$(WysijaForm.options.container).select('.wysija_settings').each(function(element) {
|
509 |
// get parent dimensions and position
|
510 |
var parentDim = element.up('.mailpoet_form_block').getDimensions(),
|
511 |
parentPos = element.up('.mailpoet_form_block').cumulativeOffset(),
|
@@ -513,7 +513,7 @@ webpackJsonp([2],{
|
|
513 |
buttonMargin = 5,
|
514 |
relativeTop = buttonMargin;
|
515 |
|
516 |
-
if(is_visible) {
|
517 |
// desired position is set to center of viewport
|
518 |
var absoluteTop = parseInt(WysijaForm.scroll.top + ((viewportHeight / 2) - (element.getHeight() / 2)), 10),
|
519 |
parentTop = parseInt(parentPos.top - blockPadding, 10),
|
@@ -529,19 +529,19 @@ webpackJsonp([2],{
|
|
529 |
});
|
530 |
});
|
531 |
},
|
532 |
-
initToolbarPosition: function() {
|
533 |
-
if(WysijaForm.toolbar.top === null) WysijaForm.toolbar.top = parseInt(window.$(WysijaForm.options.container).positionedOffset().top);
|
534 |
-
if(WysijaForm.toolbar.y === null) WysijaForm.toolbar.y = parseInt(WysijaForm.toolbar.top);
|
535 |
|
536 |
-
if(window.isRtl) {
|
537 |
-
if(WysijaForm.toolbar.left === null) WysijaForm.toolbar.left = 0;
|
538 |
} else {
|
539 |
-
if(WysijaForm.toolbar.left === null) WysijaForm.toolbar.left = parseInt(window.$(WysijaForm.options.container).positionedOffset().left);
|
540 |
}
|
541 |
-
if(WysijaForm.toolbar.x === null) WysijaForm.toolbar.x = parseInt(WysijaForm.toolbar.left + window.$(WysijaForm.options.container).getDimensions().width + 15);
|
542 |
|
543 |
},
|
544 |
-
setToolbarPosition: function() {
|
545 |
WysijaForm.initToolbarPosition();
|
546 |
|
547 |
var position = {
|
@@ -549,7 +549,7 @@ webpackJsonp([2],{
|
|
549 |
visibility: 'visible'
|
550 |
};
|
551 |
|
552 |
-
if(window.isRtl) {
|
553 |
position.right = WysijaForm.toolbar.x + 'px';
|
554 |
} else {
|
555 |
position.left = WysijaForm.toolbar.x + 'px';
|
@@ -557,14 +557,14 @@ webpackJsonp([2],{
|
|
557 |
|
558 |
window.$(WysijaForm.options.toolbar).setStyle(position);
|
559 |
},
|
560 |
-
updateToolbarPosition: function() {
|
561 |
// init toolbar position (updates scroll and toolbar y)
|
562 |
WysijaForm.initToolbarPosition();
|
563 |
|
564 |
// cancel previous effect
|
565 |
-
if(WysijaForm.toolbar.effect !== null) WysijaForm.toolbar.effect.cancel();
|
566 |
|
567 |
-
if(WysijaForm.scroll.top >= (WysijaForm.toolbar.top - 20)) {
|
568 |
WysijaForm.toolbar.y = parseInt(20 + WysijaForm.scroll.top);
|
569 |
// start effect
|
570 |
WysijaForm.toolbar.effect = new window.Effect.Move(WysijaForm.options.toolbar, {
|
@@ -582,33 +582,33 @@ webpackJsonp([2],{
|
|
582 |
},
|
583 |
blockDropOptions: {
|
584 |
accept: window.$w('mailpoet_form_field'), // acceptable items (classes array)
|
585 |
-
onEnter: function(draggable, droppable) {
|
586 |
window.$(droppable).addClassName('hover');
|
587 |
},
|
588 |
-
onLeave: function(draggable, droppable) {
|
589 |
window.$(droppable).removeClassName('hover');
|
590 |
},
|
591 |
-
onDrop: function(draggable, droppable) {
|
592 |
// custom data for images
|
593 |
droppable.fire('wjfe:item:drop', WysijaForm.getFieldData(draggable));
|
594 |
window.$(droppable).removeClassName('hover');
|
595 |
}
|
596 |
},
|
597 |
-
hideControls: function() {
|
598 |
try {
|
599 |
return WysijaForm.getBlocks().invoke('hideControls');
|
600 |
-
} catch(e) {
|
601 |
return;
|
602 |
}
|
603 |
},
|
604 |
-
hideTools: function() {
|
605 |
window.$$('.wysija_tools').invoke('hide');
|
606 |
WysijaForm.locks.showingTools = false;
|
607 |
},
|
608 |
instances: {},
|
609 |
-
get: function(element, typ) {
|
610 |
var type = typ;
|
611 |
-
if(type === undefined) type = 'block';
|
612 |
// identify element
|
613 |
var id = element.identify();
|
614 |
var instance = WysijaForm.instances[id] || new WysijaForm[type.capitalize().camelize()](id);
|
@@ -616,10 +616,10 @@ webpackJsonp([2],{
|
|
616 |
WysijaForm.instances[id] = instance;
|
617 |
return instance;
|
618 |
},
|
619 |
-
makeDroppable: function() {
|
620 |
window.Droppables.add('block_placeholder', WysijaForm.blockDropOptions);
|
621 |
},
|
622 |
-
makeSortable: function() {
|
623 |
var body = window.$(WysijaForm.options.body);
|
624 |
window.Sortable.create(body, {
|
625 |
tag: 'div',
|
@@ -636,44 +636,44 @@ webpackJsonp([2],{
|
|
636 |
onEnd: WysijaForm.setBlockPositions
|
637 |
});
|
638 |
},
|
639 |
-
hideBlockControls: function() {
|
640 |
window.$$('.wysija_controls').invoke('hide');
|
641 |
this.getBlockElements().invoke('removeClassName', 'hover');
|
642 |
},
|
643 |
-
getBlocks: function() {
|
644 |
-
return WysijaForm.getBlockElements().map(function(element) {
|
645 |
return WysijaForm.get(element);
|
646 |
});
|
647 |
},
|
648 |
-
getBlockElements: function() {
|
649 |
return window.$(WysijaForm.options.container).select('.mailpoet_form_block');
|
650 |
},
|
651 |
-
startBlockPositions: function(event, target) {
|
652 |
-
if(target.element.hasClassName('mailpoet_form_block')) {
|
653 |
// store block placeholder id for the block that is being repositionned
|
654 |
-
if(target.element.previous('.block_placeholder') !== undefined) {
|
655 |
target.element.writeAttribute('wysija_placeholder', target.element.previous('.block_placeholder').identify());
|
656 |
}
|
657 |
}
|
658 |
WysijaForm.locks.dragging = true;
|
659 |
},
|
660 |
-
encodeURIComponent: function(str) {
|
661 |
// check if it's a url and if so, prevent encoding of protocol
|
662 |
var regexp = new RegExp(/^http[s]?:\/\//),
|
663 |
protocol = regexp.exec(str);
|
664 |
|
665 |
-
if(protocol === null) {
|
666 |
// this is not a url so encode the whole thing
|
667 |
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
|
668 |
-
} else if(protocol.length === 1) {
|
669 |
// this is a url, so do not encode the protocol
|
670 |
return encodeURI(str).replace(/[!'()*]/g, escape);
|
671 |
}
|
672 |
},
|
673 |
-
updateBlock: function(field) {
|
674 |
var hasUpdated = false;
|
675 |
-
WysijaForm.getBlocks().each(function(b) {
|
676 |
-
if(b.block.getData().id === field.id) {
|
677 |
hasUpdated = true;
|
678 |
b.block.redraw(field);
|
679 |
}
|
@@ -681,10 +681,10 @@ webpackJsonp([2],{
|
|
681 |
|
682 |
return hasUpdated;
|
683 |
},
|
684 |
-
removeBlock: function(field, callback) {
|
685 |
var hasRemoved = false;
|
686 |
-
WysijaForm.getBlocks().each(function(b) {
|
687 |
-
if(b.block.getData().id === field.id) {
|
688 |
hasRemoved = true;
|
689 |
b.block.removeBlock(callback);
|
690 |
}
|
@@ -695,14 +695,14 @@ webpackJsonp([2],{
|
|
695 |
};
|
696 |
|
697 |
WysijaForm.DraggableItem = window.Class.create({
|
698 |
-
initialize: function(element) {
|
699 |
this.elementType = window.$(element).readAttribute('wysija_type');
|
700 |
this.element = window.$(element).down() || window.$(element);
|
701 |
this.clone = this.cloneElement();
|
702 |
this.insert();
|
703 |
},
|
704 |
STYLES: new window.Template('position: absolute; top: #{top}px; left: #{left}px;'),
|
705 |
-
cloneElement: function() {
|
706 |
var clone = this.element.clone(),
|
707 |
offset = this.element.cumulativeOffset(),
|
708 |
list = this.getList(),
|
@@ -717,27 +717,27 @@ webpackJsonp([2],{
|
|
717 |
clone.innerHTML = this.element.innerHTML;
|
718 |
return clone;
|
719 |
},
|
720 |
-
getOffset: function() {
|
721 |
return this.element.offsetTop - this.getList().scrollTop;
|
722 |
},
|
723 |
-
getList: function() {
|
724 |
return this.element.up('ul');
|
725 |
},
|
726 |
-
insert: function() {
|
727 |
window.$$('body')[0].insert(this.clone);
|
728 |
},
|
729 |
-
onMousedown: function(event) {
|
730 |
var draggable = new window.Draggable(this.clone, {
|
731 |
scroll: window,
|
732 |
-
onStart: function() {
|
733 |
window.Droppables.displayArea(draggable);
|
734 |
},
|
735 |
-
onEnd: function(drag) {
|
736 |
drag.destroy();
|
737 |
drag.element.remove();
|
738 |
window.Droppables.hideArea();
|
739 |
},
|
740 |
-
starteffect: function(element) {
|
741 |
new window.Effect.Opacity(element, {
|
742 |
duration: 0.2,
|
743 |
from: element.getOpacity(),
|
@@ -756,7 +756,7 @@ webpackJsonp([2],{
|
|
756 |
|
757 |
WysijaForm.Block = window.Class.create({
|
758 |
/* Invoked on load */
|
759 |
-
initialize: function(element) {
|
760 |
info('block -> init');
|
761 |
|
762 |
this.element = window.$(element);
|
@@ -766,78 +766,78 @@ webpackJsonp([2],{
|
|
766 |
this.block.makeBlockDroppable();
|
767 |
|
768 |
// setup events
|
769 |
-
if(this.block['setup'] !== undefined) {
|
770 |
this.block.setup();
|
771 |
}
|
772 |
return this;
|
773 |
},
|
774 |
-
setPosition: function(position) {
|
775 |
this.element.writeAttribute('wysija_position', position);
|
776 |
},
|
777 |
-
hideControls: function() {
|
778 |
-
if(this['getControls']) {
|
779 |
this.element.removeClassName('hover');
|
780 |
this.getControls().hide();
|
781 |
}
|
782 |
},
|
783 |
-
showControls: function() {
|
784 |
-
if(this['getControls']) {
|
785 |
this.element.addClassName('hover');
|
786 |
try {
|
787 |
this.getControls().show();
|
788 |
-
} catch(e) {
|
789 |
}
|
790 |
}
|
791 |
},
|
792 |
-
makeBlockDroppable: function() {
|
793 |
-
if(this.isBlockDroppableEnabled() === false) {
|
794 |
var block_placeholder = this.getBlockDroppable();
|
795 |
window.Droppables.add(block_placeholder.identify(), WysijaForm.blockDropOptions);
|
796 |
block_placeholder.addClassName('enabled');
|
797 |
}
|
798 |
},
|
799 |
-
removeBlockDroppable: function() {
|
800 |
-
if(this.isBlockDroppableEnabled()) {
|
801 |
var block_placeholder = this.getBlockDroppable();
|
802 |
window.Droppables.remove(block_placeholder.identify());
|
803 |
block_placeholder.removeClassName('enabled');
|
804 |
}
|
805 |
},
|
806 |
-
isBlockDroppableEnabled: function() {
|
807 |
// if the block_placeholder does not exist, create it
|
808 |
var block_placeholder = this.getBlockDroppable();
|
809 |
-
if(block_placeholder === null) {
|
810 |
return this.createBlockDroppable().hasClassName('enabled');
|
811 |
} else {
|
812 |
return block_placeholder.hasClassName('enabled');
|
813 |
}
|
814 |
},
|
815 |
-
createBlockDroppable: function() {
|
816 |
info('block -> createBlockDroppable');
|
817 |
this.element.insert({
|
818 |
before: '<div class=\"block_placeholder\">' + window.$('block_placeholder').innerHTML + '</div>'
|
819 |
});
|
820 |
return this.element.previous('.block_placeholder');
|
821 |
},
|
822 |
-
getBlockDroppable: function() {
|
823 |
-
if(this.element.previous() === undefined || this.element.previous().hasClassName('block_placeholder') === false) {
|
824 |
return null;
|
825 |
} else {
|
826 |
return this.element.previous();
|
827 |
}
|
828 |
},
|
829 |
-
getControls: function() {
|
830 |
return this.element.down('.wysija_controls');
|
831 |
},
|
832 |
-
setupControls: function() {
|
833 |
// enable controls
|
834 |
this.controls = this.getControls();
|
835 |
|
836 |
-
if(this.controls) {
|
837 |
// setup events for block controls
|
838 |
-
this.element.observe('mouseover', function() {
|
839 |
// special cases where controls shouldn't be displayed
|
840 |
-
if(WysijaForm.locks.dragging === true || WysijaForm.locks.selectingColor === true || WysijaForm.locks.showingTools === true) return;
|
841 |
|
842 |
// set block flag
|
843 |
this.element.addClassName('hover');
|
@@ -846,20 +846,20 @@ webpackJsonp([2],{
|
|
846 |
this.showControls();
|
847 |
|
848 |
// show settings if present
|
849 |
-
if(this.element.down('.wysija_settings') !== undefined) {
|
850 |
this.element.down('.wysija_settings').show();
|
851 |
}
|
852 |
}.bind(this));
|
853 |
|
854 |
-
this.element.observe('mouseout', function() {
|
855 |
// special cases where controls shouldn't hide
|
856 |
-
if(WysijaForm.locks.dragging === true || WysijaForm.locks.selectingColor === true) return;
|
857 |
|
858 |
// hide controls
|
859 |
this.hideControls();
|
860 |
|
861 |
// hide settings if present
|
862 |
-
if(this.element.down('.wysija_settings') !== undefined) {
|
863 |
this.element.down('.wysija_settings').hide();
|
864 |
}
|
865 |
}.bind(this));
|
@@ -867,8 +867,8 @@ webpackJsonp([2],{
|
|
867 |
|
868 |
// setup click event for remove button
|
869 |
this.removeButton = this.controls.down('.remove') || null;
|
870 |
-
if(this.removeButton !== null) {
|
871 |
-
this.removeButton.observe('click', function() {
|
872 |
this.removeBlock();
|
873 |
this.removeButton.stopObserving('click');
|
874 |
}.bind(this));
|
@@ -877,11 +877,11 @@ webpackJsonp([2],{
|
|
877 |
// setup click event for settings button
|
878 |
this.settingsButton = this.element.down('.settings') || null;
|
879 |
|
880 |
-
if(this.settingsButton !== null) {
|
881 |
-
this.settingsButton.observe('click', function(event) {
|
882 |
// TODO: refactor
|
883 |
var block = window.$(event.target).up('.mailpoet_form_block') || null;
|
884 |
-
if(block !== null) {
|
885 |
var field = WysijaForm.getFieldData(block);
|
886 |
this.editSettings();
|
887 |
}
|
@@ -890,7 +890,7 @@ webpackJsonp([2],{
|
|
890 |
}
|
891 |
return this;
|
892 |
},
|
893 |
-
removeBlock: function(callback) {
|
894 |
info('block -> removeBlock');
|
895 |
|
896 |
// save block in history
|
@@ -898,9 +898,9 @@ webpackJsonp([2],{
|
|
898 |
|
899 |
window.Effect.Fade(this.element.identify(), {
|
900 |
duration: 0.2,
|
901 |
-
afterFinish: function(effect) {
|
902 |
// remove placeholder
|
903 |
-
if(effect.element.previous('.block_placeholder') !== undefined) {
|
904 |
effect.element.previous('.block_placeholder').remove();
|
905 |
}
|
906 |
|
@@ -914,7 +914,7 @@ webpackJsonp([2],{
|
|
914 |
WysijaForm.toggleWidgets();
|
915 |
|
916 |
// optional callback execution after completely removing block
|
917 |
-
if(callback !== undefined && typeof(callback) === 'function') {
|
918 |
callback();
|
919 |
}
|
920 |
|
@@ -926,9 +926,9 @@ webpackJsonp([2],{
|
|
926 |
});
|
927 |
|
928 |
/* Invoked on item dropped */
|
929 |
-
WysijaForm.Block.create = function(createBlock, target) {
|
930 |
var block = createBlock;
|
931 |
-
if(window.$('form_template_' + block.type) === null) {
|
932 |
return false;
|
933 |
}
|
934 |
|
@@ -937,11 +937,11 @@ webpackJsonp([2],{
|
|
937 |
template = window.Handlebars.compile(window.$('form_template_' + block.type).innerHTML),
|
938 |
output = '';
|
939 |
|
940 |
-
if(block.type === 'segment') {
|
941 |
-
if(block.params.values === undefined) {
|
942 |
var settings_segments = window.jQuery('#mailpoet_form_segments').val();
|
943 |
-
if(settings_segments !== null && settings_segments.length > 0){
|
944 |
-
block.params.values = window.mailpoet_segments.filter(function(segment) {
|
945 |
return (settings_segments.indexOf(segment.id) !== -1);
|
946 |
});
|
947 |
}
|
@@ -954,22 +954,22 @@ webpackJsonp([2],{
|
|
954 |
|
955 |
// check if the new block is unique and if there's already an instance
|
956 |
// of it in the history. If so, remove its former instance from the history
|
957 |
-
if(block.unique === 1) {
|
958 |
WysijaHistory.remove(block.field);
|
959 |
}
|
960 |
|
961 |
// if the drop target was the bottom placeholder
|
962 |
var element = null;
|
963 |
-
if(target.identify() === 'block_placeholder') {
|
964 |
// insert block at the bottom
|
965 |
element = body.insert(output);
|
966 |
-
//block = body.childElements().last();
|
967 |
} else {
|
968 |
// insert block before the drop target
|
969 |
element = target.insert({
|
970 |
before: output
|
971 |
});
|
972 |
-
//block = target.previous('.mailpoet_form_block');
|
973 |
}
|
974 |
// refresh sortable items
|
975 |
WysijaForm.makeSortable();
|
@@ -981,7 +981,7 @@ webpackJsonp([2],{
|
|
981 |
WysijaForm.setSettingsPosition();
|
982 |
};
|
983 |
|
984 |
-
document.observe('wjfe:item:drop', function(event) {
|
985 |
info('create block');
|
986 |
WysijaForm.Block.create(event.memo, event.target);
|
987 |
|
@@ -990,59 +990,59 @@ webpackJsonp([2],{
|
|
990 |
WysijaForm.hideBlockControls();
|
991 |
|
992 |
// toggle widgets
|
993 |
-
setTimeout(function() {
|
994 |
WysijaForm.toggleWidgets();
|
995 |
}, 1);
|
996 |
});
|
997 |
|
998 |
/* Form Widget */
|
999 |
WysijaForm.Widget = window.Class.create(WysijaForm.Block, {
|
1000 |
-
initialize: function(element) {
|
1001 |
info('widget -> init');
|
1002 |
this.element = window.$(element);
|
1003 |
return this;
|
1004 |
},
|
1005 |
-
setup: function() {
|
1006 |
info('widget -> setup');
|
1007 |
this.setupControls();
|
1008 |
},
|
1009 |
-
save: function() {
|
1010 |
info('widget -> save');
|
1011 |
var data = this.getData();
|
1012 |
|
1013 |
-
if(data.element !== undefined) {
|
1014 |
delete data.element;
|
1015 |
}
|
1016 |
|
1017 |
return data;
|
1018 |
},
|
1019 |
-
setData: function(data) {
|
1020 |
var current_data = this.getData(),
|
1021 |
params = window.$H(current_data.params).merge(data.params).toObject();
|
1022 |
|
1023 |
// update type if it changed
|
1024 |
-
if(data.type !== undefined && data.type !== current_data.type) {
|
1025 |
this.element.writeAttribute('wysija_type', data.type);
|
1026 |
}
|
1027 |
|
1028 |
// update params
|
1029 |
this.element.writeAttribute('wysija_params', JSON.stringify(params));
|
1030 |
},
|
1031 |
-
getData: function() {
|
1032 |
var data = WysijaForm.getFieldData(this.element);
|
1033 |
// decode params
|
1034 |
-
if(data.params.length > 0) {
|
1035 |
data.params = JSON.parse(data.params);
|
1036 |
}
|
1037 |
return data;
|
1038 |
},
|
1039 |
-
getControls: function() {
|
1040 |
return this.element.down('.wysija_controls');
|
1041 |
},
|
1042 |
-
remove: function() {
|
1043 |
this.removeBlock();
|
1044 |
},
|
1045 |
-
redraw: function(data) {
|
1046 |
// set parameters
|
1047 |
this.setData(data);
|
1048 |
var options = this.getData();
|
@@ -1056,18 +1056,18 @@ webpackJsonp([2],{
|
|
1056 |
|
1057 |
WysijaForm.init();
|
1058 |
},
|
1059 |
-
editSettings: function() {
|
1060 |
window.MailPoet.Modal.popup({
|
1061 |
title: window.MailPoet.I18n.t('editFieldSettings'),
|
1062 |
template: window.jQuery('#form_template_field_settings').html(),
|
1063 |
data: this.getData(),
|
1064 |
-
onSuccess: function() {
|
1065 |
var data = window.jQuery('#form_field_settings').serializeObject();
|
1066 |
this.redraw(data);
|
1067 |
}.bind(this)
|
1068 |
});
|
1069 |
},
|
1070 |
-
getSettings: function() {
|
1071 |
return this.element.down('.wysija_settings');
|
1072 |
}
|
1073 |
});
|
@@ -1077,23 +1077,23 @@ webpackJsonp([2],{
|
|
1077 |
|
1078 |
/* LOGGING */
|
1079 |
function info(value) {
|
1080 |
-
if(WysijaForm.options.debug === false) return;
|
1081 |
|
1082 |
-
if(!(window.console && console.log)) {
|
1083 |
-
(function() {
|
1084 |
-
var noop = function() {};
|
1085 |
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
|
1086 |
var length = methods.length;
|
1087 |
window.console = {};
|
1088 |
var console = {};
|
1089 |
-
while(length--) {
|
1090 |
console[methods[length]] = noop;
|
1091 |
}
|
1092 |
}());
|
1093 |
}
|
1094 |
try {
|
1095 |
console.log('[DEBUG] ' + value);
|
1096 |
-
} catch(e) {}
|
1097 |
}
|
1098 |
|
1099 |
module.exports = WysijaForm;
|
31 |
'use strict';
|
32 |
|
33 |
Event.cacheDelegated = {};
|
34 |
+
Object.extend(document, (function () {
|
35 |
var cache = Event.cacheDelegated;
|
36 |
|
37 |
function getCacheForSelector(selector) {
|
47 |
|
48 |
function findWrapper(selector, eventName, handler) {
|
49 |
var c = getWrappersForSelector(selector, eventName);
|
50 |
+
return c.find(function (wrapper) {
|
51 |
return wrapper.handler === handler;
|
52 |
});
|
53 |
}
|
54 |
|
55 |
function destroyWrapper(selector, eventName, handler) {
|
56 |
var c = getCacheForSelector(selector);
|
57 |
+
if (!c[eventName]) return false;
|
58 |
var wrapper = findWrapper(selector, eventName, handler);
|
59 |
c[eventName] = c[eventName].without(wrapper);
|
60 |
return wrapper;
|
62 |
|
63 |
function createWrapper(selector, eventName, handler, context) {
|
64 |
var wrapper, c = getWrappersForSelector(selector, eventName);
|
65 |
+
if (c.pluck('handler').include(handler)) return false;
|
66 |
+
wrapper = function (event) {
|
67 |
var element = event.findElement(selector);
|
68 |
+
if (element) handler.call(context || element, event, element);
|
69 |
};
|
70 |
wrapper.handler = handler;
|
71 |
c.push(wrapper);
|
72 |
return wrapper;
|
73 |
}
|
74 |
return {
|
75 |
+
delegate: function (selector, eventName, handler, context) {
|
76 |
var wrapper = createWrapper.apply(null, arguments);
|
77 |
+
if (wrapper) document.observe(eventName, wrapper);
|
78 |
return document;
|
79 |
},
|
80 |
+
stopDelegating: function (selector, eventName, handler) {
|
81 |
var length = arguments.length;
|
82 |
+
switch (length) {
|
83 |
case 2:
|
84 |
+
getWrappersForSelector(selector, eventName).each(function (wrapper) {
|
85 |
document.stopDelegating(selector, eventName, wrapper.handler);
|
86 |
});
|
87 |
break;
|
88 |
case 1:
|
89 |
+
Object.keys(getCacheForSelector(selector)).each(function (eventName) {
|
90 |
document.stopDelegating(selector, eventName);
|
91 |
});
|
92 |
break;
|
93 |
case 0:
|
94 |
+
Object.keys(cache).each(function (selector) {
|
95 |
document.stopDelegating(selector);
|
96 |
});
|
97 |
break;
|
98 |
default:
|
99 |
var wrapper = destroyWrapper.apply(null, arguments);
|
100 |
+
if (wrapper) document.stopObserving(eventName, wrapper);
|
101 |
}
|
102 |
return document;
|
103 |
}
|
104 |
};
|
105 |
})());
|
106 |
|
107 |
+
var Observable = (function () {
|
108 |
function getEventName(nameA, namespace) {
|
109 |
var name = nameA.substring(2);
|
110 |
+
if (namespace) name = namespace + ':' + name;
|
111 |
return name.underscore().split('_').join(':');
|
112 |
}
|
113 |
|
114 |
function getHandlers(klass) {
|
115 |
var proto = klass.prototype,
|
116 |
namespace = proto.namespace;
|
117 |
+
return Object.keys(proto).grep(/^on/).inject(window.$H(), function (handlers, name) {
|
118 |
+
if (name === 'onDomLoaded') return handlers;
|
119 |
handlers.set(getEventName(name, namespace), getWrapper(proto[name], klass));
|
120 |
return handlers;
|
121 |
});
|
122 |
}
|
123 |
|
124 |
function getWrapper(handler, klass) {
|
125 |
+
return function (event) {
|
126 |
return handler.call(new klass(this), event, event.memo);
|
127 |
};
|
128 |
}
|
129 |
|
130 |
function onDomLoad(selector, klass) {
|
131 |
+
window.$$(selector).each(function (element) {
|
132 |
new klass(element).onDomLoaded();
|
133 |
});
|
134 |
}
|
135 |
return {
|
136 |
+
observe: function (selector) {
|
137 |
+
if (!this.handlers) this.handlers = {};
|
138 |
+
if (this.handlers[selector]) return;
|
139 |
var klass = this;
|
140 |
+
if (this.prototype.onDomLoaded) {
|
141 |
+
if (document.loaded) {
|
142 |
onDomLoad(selector, klass);
|
143 |
} else {
|
144 |
document.observe('dom:loaded', onDomLoad.curry(selector, klass));
|
145 |
}
|
146 |
}
|
147 |
+
this.handlers[selector] = getHandlers(klass).each(function (handler) {
|
148 |
document.delegate(selector, handler.key, handler.value);
|
149 |
});
|
150 |
},
|
151 |
+
stopObserving: function (selector) {
|
152 |
+
if (!this.handlers || !this.handlers[selector]) return;
|
153 |
+
this.handlers[selector].each(function (handler) {
|
154 |
document.stopDelegating(selector, handler.key, handler.value);
|
155 |
});
|
156 |
delete this.handlers[selector];
|
160 |
|
161 |
// override droppables
|
162 |
Object.extend(window.Droppables, {
|
163 |
+
deactivate: window.Droppables.deactivate.wrap(function (proceed, drop, draggable) {
|
164 |
+
if (drop.onLeave) drop.onLeave(draggable, drop.element);
|
165 |
return proceed(drop);
|
166 |
}),
|
167 |
+
activate: window.Droppables.activate.wrap(function (proceed, drop, draggable) {
|
168 |
+
if (drop.onEnter) drop.onEnter(draggable, drop.element);
|
169 |
return proceed(drop);
|
170 |
}),
|
171 |
+
show: function (point, element) {
|
172 |
+
if (!this.drops.length) return;
|
173 |
var drop, affected = [];
|
174 |
+
this.drops.each(function (drop) {
|
175 |
+
if (window.Droppables.isAffected(point, element, drop)) affected.push(drop);
|
176 |
});
|
177 |
+
if (affected.length > 0) drop = window.Droppables.findDeepestChild(affected);
|
178 |
+
if (this.last_active && this.last_active !== drop) this.deactivate(this.last_active, element);
|
179 |
+
if (drop) {
|
180 |
window.Position.within(drop.element, point[0], point[1]);
|
181 |
+
if (drop.onHover) drop.onHover(element, drop.element, window.Position.overlap(drop.overlap, drop.element));
|
182 |
+
if (drop !== this.last_active) window.Droppables.activate(drop, element);
|
183 |
}
|
184 |
},
|
185 |
+
displayArea: function (draggable) {
|
186 |
+
if (!this.drops.length) return;
|
187 |
|
188 |
// hide controls when displaying drop areas.
|
189 |
WysijaForm.hideBlockControls();
|
190 |
|
191 |
+
this.drops.each(function (drop, iterator) {
|
192 |
+
if (drop.element.hasClassName('block_placeholder')) {
|
193 |
drop.element.addClassName('active');
|
194 |
}
|
195 |
});
|
196 |
},
|
197 |
+
hideArea: function () {
|
198 |
+
if (!this.drops.length) return;
|
199 |
+
this.drops.each(function (drop, iterator) {
|
200 |
+
if (drop.element.hasClassName('block_placeholder')) {
|
201 |
drop.element.removeClassName('active');
|
202 |
+
} else if (drop.element.hasClassName('image_placeholder')) {
|
203 |
drop.element.removeClassName('active');
|
204 |
drop.element.up().removeClassName('active');
|
205 |
+
} else if (drop.element.hasClassName('text_placeholder')) {
|
206 |
drop.element.removeClassName('active');
|
207 |
}
|
208 |
});
|
209 |
},
|
210 |
+
reset: function (draggable) {
|
211 |
+
if (this.last_active) this.deactivate(this.last_active, draggable);
|
212 |
}
|
213 |
});
|
214 |
|
221 |
var WysijaHistory = {
|
222 |
container: 'mailpoet_form_history',
|
223 |
size: 30,
|
224 |
+
enqueue: function (element) {
|
225 |
// create deep clone (includes child elements) of passed element
|
226 |
var clone = element.clone(true);
|
227 |
|
228 |
// check if the field is unique
|
229 |
+
if (parseInt(clone.readAttribute('wysija_unique'), 10) === 1) {
|
230 |
// check if the field is already in the queue
|
231 |
window.$(WysijaHistory.container).select('[wysija_name="' + clone.readAttribute('wysija_name') + '"]').invoke('remove');
|
232 |
}
|
233 |
|
234 |
// check history size
|
235 |
+
if (window.$(WysijaHistory.container).select('> div').length >= WysijaHistory.size) {
|
236 |
// remove oldest element (last in the list)
|
237 |
window.$(WysijaHistory.container).select('> div').last().remove();
|
238 |
}
|
242 |
top: clone
|
243 |
});
|
244 |
},
|
245 |
+
dequeue: function () {
|
246 |
// pop last block off the history
|
247 |
var block = window.$(WysijaHistory.container).select('div').first();
|
248 |
|
249 |
+
if (block !== undefined) {
|
250 |
// insert block back into the editor
|
251 |
window.$(WysijaForm.options.body).insert({
|
252 |
top: block
|
253 |
});
|
254 |
}
|
255 |
},
|
256 |
+
clear: function () {
|
257 |
window.$(WysijaHistory.container).innerHTML = '';
|
258 |
},
|
259 |
+
remove: function (field) {
|
260 |
window.$(WysijaHistory.container).select('[wysija_name="' + field + '"]').invoke('remove');
|
261 |
}
|
262 |
};
|
291 |
selectingColor: false,
|
292 |
showingTools: false
|
293 |
},
|
294 |
+
encodeHtmlValue: function (str) {
|
295 |
return str.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<').replace(/"/g, '"');
|
296 |
// ": fix for FileMerge because the previous line fucks up its syntax coloring
|
297 |
},
|
298 |
+
decodeHtmlValue: function (str) {
|
299 |
return str.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<').replace(/"/g, '"');
|
300 |
// ": fix for FileMerge because the previous line fucks up its syntax coloring
|
301 |
},
|
302 |
+
loading: function (is_loading) {
|
303 |
+
if (is_loading) {
|
304 |
window.$(WysijaForm.options.editor).addClassName('loading');
|
305 |
window.$(WysijaForm.options.toolbar).addClassName('loading');
|
306 |
} else {
|
308 |
window.$(WysijaForm.options.toolbar).removeClassName('loading');
|
309 |
}
|
310 |
},
|
311 |
+
loadStatic: function (blocks) {
|
312 |
+
window.$A(blocks).each(function (block) {
|
313 |
// create block
|
314 |
WysijaForm.Block.create(block, window.$('block_placeholder'));
|
315 |
});
|
316 |
},
|
317 |
+
load: function (data) {
|
318 |
+
if (data === undefined) return;
|
319 |
|
320 |
// load body
|
321 |
+
if (data.body !== undefined) {
|
322 |
+
window.$A(data.body).each(function (block) {
|
323 |
// create block
|
324 |
WysijaForm.Block.create(block, window.$('block_placeholder'));
|
325 |
});
|
326 |
|
327 |
// load settings
|
328 |
var settings_elements = window.$('mailpoet_form_settings').getElements();
|
329 |
+
settings_elements.each(function (setting) {
|
330 |
// skip lists
|
331 |
+
if (setting.name === 'segments') {
|
332 |
return true;
|
333 |
+
} else if (setting.name === 'on_success') {
|
334 |
// if the input value is equal to the one stored in the settings
|
335 |
+
if (setting.value === data.settings[setting.name]) {
|
336 |
// check selected value
|
337 |
window.$(setting).checked = true;
|
338 |
}
|
339 |
+
} else if (data.settings[setting.name] !== undefined) {
|
340 |
+
if (typeof data.settings[setting.name] === 'string') {
|
341 |
setting.setValue(WysijaForm.decodeHtmlValue(data.settings[setting.name]));
|
342 |
} else {
|
343 |
setting.setValue(data.settings[setting.name]);
|
346 |
});
|
347 |
}
|
348 |
},
|
349 |
+
save: function () {
|
350 |
var position = 1,
|
351 |
data = {
|
352 |
name: window.$F('mailpoet_form_name'),
|
355 |
styles: (window.MailPoet.CodeEditor !== undefined) ? window.MailPoet.CodeEditor.getValue() : null
|
356 |
};
|
357 |
// body
|
358 |
+
WysijaForm.getBlocks().each(function (b) {
|
359 |
+
var block_data = (typeof (b.block['save']) === 'function') ? b.block.save() : null;
|
360 |
|
361 |
+
if (block_data !== null) {
|
362 |
// set block position
|
363 |
block_data['position'] = position;
|
364 |
|
372 |
|
373 |
return data;
|
374 |
},
|
375 |
+
init: function () {
|
376 |
// set document scroll
|
377 |
info('init -> set scroll offsets');
|
378 |
WysijaForm.setScrollOffsets();
|
405 |
info('init -> toggle widgets');
|
406 |
WysijaForm.toggleWidgets();
|
407 |
},
|
408 |
+
getFieldData: function (element) {
|
409 |
// get basic field data
|
410 |
var data = {
|
411 |
type: element.readAttribute('wysija_type'),
|
418 |
};
|
419 |
|
420 |
// get params (may be empty)
|
421 |
+
if (element.readAttribute('wysija_params') !== null && element.readAttribute('wysija_params').length > 0) {
|
422 |
data.params = JSON.parse(element.readAttribute('wysija_params'));
|
423 |
}
|
424 |
return data;
|
425 |
},
|
426 |
+
toggleWidgets: function () {
|
427 |
window.$$('a[wysija_unique="1"]').invoke('removeClassName', 'disabled');
|
428 |
|
429 |
// loop through each unique field already inserted in the editor and disable its toolbar equivalent
|
430 |
+
window.$$('#' + WysijaForm.options.editor + ' [wysija_unique="1"]').map(function (element) {
|
431 |
var field = window.$$('#' + WysijaForm.options.toolbar + ' [wysija_id="' + element.readAttribute('wysija_id') + '"]');
|
432 |
+
if (field.length > 0) {
|
433 |
field.first().addClassName('disabled');
|
434 |
}
|
435 |
});
|
436 |
|
437 |
var hasSegmentSelection = WysijaForm.hasSegmentSelection();
|
438 |
|
439 |
+
if (hasSegmentSelection) {
|
440 |
window.$('mailpoet_form_segments').writeAttribute('required', false).disable();
|
441 |
window.$('mailpoet_settings_segment_selection').hide();
|
442 |
} else {
|
444 |
window.$('mailpoet_settings_segment_selection').show();
|
445 |
}
|
446 |
},
|
447 |
+
hasSegmentSelection: function () {
|
448 |
return (window.$$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]').length > 0);
|
449 |
},
|
450 |
+
isSegmentSelectionValid: function () {
|
451 |
var segment_selection = window.$$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]')[0];
|
452 |
+
if (segment_selection !== undefined) {
|
453 |
var block = WysijaForm.get(segment_selection).block.getData();
|
454 |
return (
|
455 |
(block.params.values !== undefined)
|
459 |
}
|
460 |
return false;
|
461 |
},
|
462 |
+
setBlockPositions: function (event, target) {
|
463 |
// release dragging lock
|
464 |
WysijaForm.locks.dragging = false;
|
465 |
|
466 |
var index = 1;
|
467 |
+
WysijaForm.getBlocks().each(function (container) {
|
468 |
container.setPosition(index++);
|
469 |
// remove z-index value to avoid issues when resizing images
|
470 |
+
if (container['block'] !== undefined) {
|
471 |
container.block.element.setStyle({
|
472 |
zIndex: ''
|
473 |
});
|
474 |
}
|
475 |
});
|
476 |
|
477 |
+
if (target !== undefined) {
|
478 |
// get placeholders (previous placeholder matches the placeholder linked to the next block)
|
479 |
var block_placeholder = window.$(target.element.readAttribute('wysija_placeholder')),
|
480 |
previous_placeholder = target.element.previous('.block_placeholder');
|
481 |
|
482 |
+
if (block_placeholder !== null) {
|
483 |
// put block placeholder before the current block
|
484 |
target.element.insert({
|
485 |
before: block_placeholder
|
486 |
});
|
487 |
|
488 |
// if the next block is a wysija_block, insert previous placeholder
|
489 |
+
if (target.element.next() !== undefined && target.element.next().hasClassName('mailpoet_form_block') && previous_placeholder !== undefined) {
|
490 |
target.element.insert({
|
491 |
after: previous_placeholder
|
492 |
});
|
494 |
}
|
495 |
}
|
496 |
},
|
497 |
+
setScrollOffsets: function () {
|
498 |
WysijaForm.scroll = document.viewport.getScrollOffsets();
|
499 |
},
|
500 |
+
hideSettings: function () {
|
501 |
window.$(WysijaForm.options.container).select('.wysija_settings').invoke('hide');
|
502 |
},
|
503 |
+
setSettingsPosition: function () {
|
504 |
// get viewport offsets and dimensions
|
505 |
var viewportHeight = document.viewport.getHeight(),
|
506 |
blockPadding = 5;
|
507 |
|
508 |
+
window.$(WysijaForm.options.container).select('.wysija_settings').each(function (element) {
|
509 |
// get parent dimensions and position
|
510 |
var parentDim = element.up('.mailpoet_form_block').getDimensions(),
|
511 |
parentPos = element.up('.mailpoet_form_block').cumulativeOffset(),
|
513 |
buttonMargin = 5,
|
514 |
relativeTop = buttonMargin;
|
515 |
|
516 |
+
if (is_visible) {
|
517 |
// desired position is set to center of viewport
|
518 |
var absoluteTop = parseInt(WysijaForm.scroll.top + ((viewportHeight / 2) - (element.getHeight() / 2)), 10),
|
519 |
parentTop = parseInt(parentPos.top - blockPadding, 10),
|
529 |
});
|
530 |
});
|
531 |
},
|
532 |
+
initToolbarPosition: function () {
|
533 |
+
if (WysijaForm.toolbar.top === null) WysijaForm.toolbar.top = parseInt(window.$(WysijaForm.options.container).positionedOffset().top);
|
534 |
+
if (WysijaForm.toolbar.y === null) WysijaForm.toolbar.y = parseInt(WysijaForm.toolbar.top);
|
535 |
|
536 |
+
if (window.isRtl) {
|
537 |
+
if (WysijaForm.toolbar.left === null) WysijaForm.toolbar.left = 0;
|
538 |
} else {
|
539 |
+
if (WysijaForm.toolbar.left === null) WysijaForm.toolbar.left = parseInt(window.$(WysijaForm.options.container).positionedOffset().left);
|
540 |
}
|
541 |
+
if (WysijaForm.toolbar.x === null) WysijaForm.toolbar.x = parseInt(WysijaForm.toolbar.left + window.$(WysijaForm.options.container).getDimensions().width + 15);
|
542 |
|
543 |
},
|
544 |
+
setToolbarPosition: function () {
|
545 |
WysijaForm.initToolbarPosition();
|
546 |
|
547 |
var position = {
|
549 |
visibility: 'visible'
|
550 |
};
|
551 |
|
552 |
+
if (window.isRtl) {
|
553 |
position.right = WysijaForm.toolbar.x + 'px';
|
554 |
} else {
|
555 |
position.left = WysijaForm.toolbar.x + 'px';
|
557 |
|
558 |
window.$(WysijaForm.options.toolbar).setStyle(position);
|
559 |
},
|
560 |
+
updateToolbarPosition: function () {
|
561 |
// init toolbar position (updates scroll and toolbar y)
|
562 |
WysijaForm.initToolbarPosition();
|
563 |
|
564 |
// cancel previous effect
|
565 |
+
if (WysijaForm.toolbar.effect !== null) WysijaForm.toolbar.effect.cancel();
|
566 |
|
567 |
+
if (WysijaForm.scroll.top >= (WysijaForm.toolbar.top - 20)) {
|
568 |
WysijaForm.toolbar.y = parseInt(20 + WysijaForm.scroll.top);
|
569 |
// start effect
|
570 |
WysijaForm.toolbar.effect = new window.Effect.Move(WysijaForm.options.toolbar, {
|
582 |
},
|
583 |
blockDropOptions: {
|
584 |
accept: window.$w('mailpoet_form_field'), // acceptable items (classes array)
|
585 |
+
onEnter: function (draggable, droppable) {
|
586 |
window.$(droppable).addClassName('hover');
|
587 |
},
|
588 |
+
onLeave: function (draggable, droppable) {
|
589 |
window.$(droppable).removeClassName('hover');
|
590 |
},
|
591 |
+
onDrop: function (draggable, droppable) {
|
592 |
// custom data for images
|
593 |
droppable.fire('wjfe:item:drop', WysijaForm.getFieldData(draggable));
|
594 |
window.$(droppable).removeClassName('hover');
|
595 |
}
|
596 |
},
|
597 |
+
hideControls: function () {
|
598 |
try {
|
599 |
return WysijaForm.getBlocks().invoke('hideControls');
|
600 |
+
} catch (e) {
|
601 |
return;
|
602 |
}
|
603 |
},
|
604 |
+
hideTools: function () {
|
605 |
window.$$('.wysija_tools').invoke('hide');
|
606 |
WysijaForm.locks.showingTools = false;
|
607 |
},
|
608 |
instances: {},
|
609 |
+
get: function (element, typ) {
|
610 |
var type = typ;
|
611 |
+
if (type === undefined) type = 'block';
|
612 |
// identify element
|
613 |
var id = element.identify();
|
614 |
var instance = WysijaForm.instances[id] || new WysijaForm[type.capitalize().camelize()](id);
|
616 |
WysijaForm.instances[id] = instance;
|
617 |
return instance;
|
618 |
},
|
619 |
+
makeDroppable: function () {
|
620 |
window.Droppables.add('block_placeholder', WysijaForm.blockDropOptions);
|
621 |
},
|
622 |
+
makeSortable: function () {
|
623 |
var body = window.$(WysijaForm.options.body);
|
624 |
window.Sortable.create(body, {
|
625 |
tag: 'div',
|
636 |
onEnd: WysijaForm.setBlockPositions
|
637 |
});
|
638 |
},
|
639 |
+
hideBlockControls: function () {
|
640 |
window.$$('.wysija_controls').invoke('hide');
|
641 |
this.getBlockElements().invoke('removeClassName', 'hover');
|
642 |
},
|
643 |
+
getBlocks: function () {
|
644 |
+
return WysijaForm.getBlockElements().map(function (element) {
|
645 |
return WysijaForm.get(element);
|
646 |
});
|
647 |
},
|
648 |
+
getBlockElements: function () {
|
649 |
return window.$(WysijaForm.options.container).select('.mailpoet_form_block');
|
650 |
},
|
651 |
+
startBlockPositions: function (event, target) {
|
652 |
+
if (target.element.hasClassName('mailpoet_form_block')) {
|
653 |
// store block placeholder id for the block that is being repositionned
|
654 |
+
if (target.element.previous('.block_placeholder') !== undefined) {
|
655 |
target.element.writeAttribute('wysija_placeholder', target.element.previous('.block_placeholder').identify());
|
656 |
}
|
657 |
}
|
658 |
WysijaForm.locks.dragging = true;
|
659 |
},
|
660 |
+
encodeURIComponent: function (str) {
|
661 |
// check if it's a url and if so, prevent encoding of protocol
|
662 |
var regexp = new RegExp(/^http[s]?:\/\//),
|
663 |
protocol = regexp.exec(str);
|
664 |
|
665 |
+
if (protocol === null) {
|
666 |
// this is not a url so encode the whole thing
|
667 |
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
|
668 |
+
} else if (protocol.length === 1) {
|
669 |
// this is a url, so do not encode the protocol
|
670 |
return encodeURI(str).replace(/[!'()*]/g, escape);
|
671 |
}
|
672 |
},
|
673 |
+
updateBlock: function (field) {
|
674 |
var hasUpdated = false;
|
675 |
+
WysijaForm.getBlocks().each(function (b) {
|
676 |
+
if (b.block.getData().id === field.id) {
|
677 |
hasUpdated = true;
|
678 |
b.block.redraw(field);
|
679 |
}
|
681 |
|
682 |
return hasUpdated;
|
683 |
},
|
684 |
+
removeBlock: function (field, callback) {
|
685 |
var hasRemoved = false;
|
686 |
+
WysijaForm.getBlocks().each(function (b) {
|
687 |
+
if (b.block.getData().id === field.id) {
|
688 |
hasRemoved = true;
|
689 |
b.block.removeBlock(callback);
|
690 |
}
|
695 |
};
|
696 |
|
697 |
WysijaForm.DraggableItem = window.Class.create({
|
698 |
+
initialize: function (element) {
|
699 |
this.elementType = window.$(element).readAttribute('wysija_type');
|
700 |
this.element = window.$(element).down() || window.$(element);
|
701 |
this.clone = this.cloneElement();
|
702 |
this.insert();
|
703 |
},
|
704 |
STYLES: new window.Template('position: absolute; top: #{top}px; left: #{left}px;'),
|
705 |
+
cloneElement: function () {
|
706 |
var clone = this.element.clone(),
|
707 |
offset = this.element.cumulativeOffset(),
|
708 |
list = this.getList(),
|
717 |
clone.innerHTML = this.element.innerHTML;
|
718 |
return clone;
|
719 |
},
|
720 |
+
getOffset: function () {
|
721 |
return this.element.offsetTop - this.getList().scrollTop;
|
722 |
},
|
723 |
+
getList: function () {
|
724 |
return this.element.up('ul');
|
725 |
},
|
726 |
+
insert: function () {
|
727 |
window.$$('body')[0].insert(this.clone);
|
728 |
},
|
729 |
+
onMousedown: function (event) {
|
730 |
var draggable = new window.Draggable(this.clone, {
|
731 |
scroll: window,
|
732 |
+
onStart: function () {
|
733 |
window.Droppables.displayArea(draggable);
|
734 |
},
|
735 |
+
onEnd: function (drag) {
|
736 |
drag.destroy();
|
737 |
drag.element.remove();
|
738 |
window.Droppables.hideArea();
|
739 |
},
|
740 |
+
starteffect: function (element) {
|
741 |
new window.Effect.Opacity(element, {
|
742 |
duration: 0.2,
|
743 |
from: element.getOpacity(),
|
756 |
|
757 |
WysijaForm.Block = window.Class.create({
|
758 |
/* Invoked on load */
|
759 |
+
initialize: function (element) {
|
760 |
info('block -> init');
|
761 |
|
762 |
this.element = window.$(element);
|
766 |
this.block.makeBlockDroppable();
|
767 |
|
768 |
// setup events
|
769 |
+
if (this.block['setup'] !== undefined) {
|
770 |
this.block.setup();
|
771 |
}
|
772 |
return this;
|
773 |
},
|
774 |
+
setPosition: function (position) {
|
775 |
this.element.writeAttribute('wysija_position', position);
|
776 |
},
|
777 |
+
hideControls: function () {
|
778 |
+
if (this['getControls']) {
|
779 |
this.element.removeClassName('hover');
|
780 |
this.getControls().hide();
|
781 |
}
|
782 |
},
|
783 |
+
showControls: function () {
|
784 |
+
if (this['getControls']) {
|
785 |
this.element.addClassName('hover');
|
786 |
try {
|
787 |
this.getControls().show();
|
788 |
+
} catch (e) {
|
789 |
}
|
790 |
}
|
791 |
},
|
792 |
+
makeBlockDroppable: function () {
|
793 |
+
if (this.isBlockDroppableEnabled() === false) {
|
794 |
var block_placeholder = this.getBlockDroppable();
|
795 |
window.Droppables.add(block_placeholder.identify(), WysijaForm.blockDropOptions);
|
796 |
block_placeholder.addClassName('enabled');
|
797 |
}
|
798 |
},
|
799 |
+
removeBlockDroppable: function () {
|
800 |
+
if (this.isBlockDroppableEnabled()) {
|
801 |
var block_placeholder = this.getBlockDroppable();
|
802 |
window.Droppables.remove(block_placeholder.identify());
|
803 |
block_placeholder.removeClassName('enabled');
|
804 |
}
|
805 |
},
|
806 |
+
isBlockDroppableEnabled: function () {
|
807 |
// if the block_placeholder does not exist, create it
|
808 |
var block_placeholder = this.getBlockDroppable();
|
809 |
+
if (block_placeholder === null) {
|
810 |
return this.createBlockDroppable().hasClassName('enabled');
|
811 |
} else {
|
812 |
return block_placeholder.hasClassName('enabled');
|
813 |
}
|
814 |
},
|
815 |
+
createBlockDroppable: function () {
|
816 |
info('block -> createBlockDroppable');
|
817 |
this.element.insert({
|
818 |
before: '<div class=\"block_placeholder\">' + window.$('block_placeholder').innerHTML + '</div>'
|
819 |
});
|
820 |
return this.element.previous('.block_placeholder');
|
821 |
},
|
822 |
+
getBlockDroppable: function () {
|
823 |
+
if (this.element.previous() === undefined || this.element.previous().hasClassName('block_placeholder') === false) {
|
824 |
return null;
|
825 |
} else {
|
826 |
return this.element.previous();
|
827 |
}
|
828 |
},
|
829 |
+
getControls: function () {
|
830 |
return this.element.down('.wysija_controls');
|
831 |
},
|
832 |
+
setupControls: function () {
|
833 |
// enable controls
|
834 |
this.controls = this.getControls();
|
835 |
|
836 |
+
if (this.controls) {
|
837 |
// setup events for block controls
|
838 |
+
this.element.observe('mouseover', function () {
|
839 |
// special cases where controls shouldn't be displayed
|
840 |
+
if (WysijaForm.locks.dragging === true || WysijaForm.locks.selectingColor === true || WysijaForm.locks.showingTools === true) return;
|
841 |
|
842 |
// set block flag
|
843 |
this.element.addClassName('hover');
|
846 |
this.showControls();
|
847 |
|
848 |
// show settings if present
|
849 |
+
if (this.element.down('.wysija_settings') !== undefined) {
|
850 |
this.element.down('.wysija_settings').show();
|
851 |
}
|
852 |
}.bind(this));
|
853 |
|
854 |
+
this.element.observe('mouseout', function () {
|
855 |
// special cases where controls shouldn't hide
|
856 |
+
if (WysijaForm.locks.dragging === true || WysijaForm.locks.selectingColor === true) return;
|
857 |
|
858 |
// hide controls
|
859 |
this.hideControls();
|
860 |
|
861 |
// hide settings if present
|
862 |
+
if (this.element.down('.wysija_settings') !== undefined) {
|
863 |
this.element.down('.wysija_settings').hide();
|
864 |
}
|
865 |
}.bind(this));
|
867 |
|
868 |
// setup click event for remove button
|
869 |
this.removeButton = this.controls.down('.remove') || null;
|
870 |
+
if (this.removeButton !== null) {
|
871 |
+
this.removeButton.observe('click', function () {
|
872 |
this.removeBlock();
|
873 |
this.removeButton.stopObserving('click');
|
874 |
}.bind(this));
|
877 |
// setup click event for settings button
|
878 |
this.settingsButton = this.element.down('.settings') || null;
|
879 |
|
880 |
+
if (this.settingsButton !== null) {
|
881 |
+
this.settingsButton.observe('click', function (event) {
|
882 |
// TODO: refactor
|
883 |
var block = window.$(event.target).up('.mailpoet_form_block') || null;
|
884 |
+
if (block !== null) {
|
885 |
var field = WysijaForm.getFieldData(block);
|
886 |
this.editSettings();
|
887 |
}
|
890 |
}
|
891 |
return this;
|
892 |
},
|
893 |
+
removeBlock: function (callback) {
|
894 |
info('block -> removeBlock');
|
895 |
|
896 |
// save block in history
|
898 |
|
899 |
window.Effect.Fade(this.element.identify(), {
|
900 |
duration: 0.2,
|
901 |
+
afterFinish: function (effect) {
|
902 |
// remove placeholder
|
903 |
+
if (effect.element.previous('.block_placeholder') !== undefined) {
|
904 |
effect.element.previous('.block_placeholder').remove();
|
905 |
}
|
906 |
|
914 |
WysijaForm.toggleWidgets();
|
915 |
|
916 |
// optional callback execution after completely removing block
|
917 |
+
if (callback !== undefined && typeof (callback) === 'function') {
|
918 |
callback();
|
919 |
}
|
920 |
|
926 |
});
|
927 |
|
928 |
/* Invoked on item dropped */
|
929 |
+
WysijaForm.Block.create = function (createBlock, target) {
|
930 |
var block = createBlock;
|
931 |
+
if (window.$('form_template_' + block.type) === null) {
|
932 |
return false;
|
933 |
}
|
934 |
|
937 |
template = window.Handlebars.compile(window.$('form_template_' + block.type).innerHTML),
|
938 |
output = '';
|
939 |
|
940 |
+
if (block.type === 'segment') {
|
941 |
+
if (block.params.values === undefined) {
|
942 |
var settings_segments = window.jQuery('#mailpoet_form_segments').val();
|
943 |
+
if (settings_segments !== null && settings_segments.length > 0) {
|
944 |
+
block.params.values = window.mailpoet_segments.filter(function (segment) {
|
945 |
return (settings_segments.indexOf(segment.id) !== -1);
|
946 |
});
|
947 |
}
|
954 |
|
955 |
// check if the new block is unique and if there's already an instance
|
956 |
// of it in the history. If so, remove its former instance from the history
|
957 |
+
if (block.unique === 1) {
|
958 |
WysijaHistory.remove(block.field);
|
959 |
}
|
960 |
|
961 |
// if the drop target was the bottom placeholder
|
962 |
var element = null;
|
963 |
+
if (target.identify() === 'block_placeholder') {
|
964 |
// insert block at the bottom
|
965 |
element = body.insert(output);
|
966 |
+
// block = body.childElements().last();
|
967 |
} else {
|
968 |
// insert block before the drop target
|
969 |
element = target.insert({
|
970 |
before: output
|
971 |
});
|
972 |
+
// block = target.previous('.mailpoet_form_block');
|
973 |
}
|
974 |
// refresh sortable items
|
975 |
WysijaForm.makeSortable();
|
981 |
WysijaForm.setSettingsPosition();
|
982 |
};
|
983 |
|
984 |
+
document.observe('wjfe:item:drop', function (event) {
|
985 |
info('create block');
|
986 |
WysijaForm.Block.create(event.memo, event.target);
|
987 |
|
990 |
WysijaForm.hideBlockControls();
|
991 |
|
992 |
// toggle widgets
|
993 |
+
setTimeout(function () {
|
994 |
WysijaForm.toggleWidgets();
|
995 |
}, 1);
|
996 |
});
|
997 |
|
998 |
/* Form Widget */
|
999 |
WysijaForm.Widget = window.Class.create(WysijaForm.Block, {
|
1000 |
+
initialize: function (element) {
|
1001 |
info('widget -> init');
|
1002 |
this.element = window.$(element);
|
1003 |
return this;
|
1004 |
},
|
1005 |
+
setup: function () {
|
1006 |
info('widget -> setup');
|
1007 |
this.setupControls();
|
1008 |
},
|
1009 |
+
save: function () {
|
1010 |
info('widget -> save');
|
1011 |
var data = this.getData();
|
1012 |
|
1013 |
+
if (data.element !== undefined) {
|
1014 |
delete data.element;
|
1015 |
}
|
1016 |
|
1017 |
return data;
|
1018 |
},
|
1019 |
+
setData: function (data) {
|
1020 |
var current_data = this.getData(),
|
1021 |
params = window.$H(current_data.params).merge(data.params).toObject();
|
1022 |
|
1023 |
// update type if it changed
|
1024 |
+
if (data.type !== undefined && data.type !== current_data.type) {
|
1025 |
this.element.writeAttribute('wysija_type', data.type);
|
1026 |
}
|
1027 |
|
1028 |
// update params
|
1029 |
this.element.writeAttribute('wysija_params', JSON.stringify(params));
|
1030 |
},
|
1031 |
+
getData: function () {
|
1032 |
var data = WysijaForm.getFieldData(this.element);
|
1033 |
// decode params
|
1034 |
+
if (data.params.length > 0) {
|
1035 |
data.params = JSON.parse(data.params);
|
1036 |
}
|
1037 |
return data;
|
1038 |
},
|
1039 |
+
getControls: function () {
|
1040 |
return this.element.down('.wysija_controls');
|
1041 |
},
|
1042 |
+
remove: function () {
|
1043 |
this.removeBlock();
|
1044 |
},
|
1045 |
+
redraw: function (data) {
|
1046 |
// set parameters
|
1047 |
this.setData(data);
|
1048 |
var options = this.getData();
|
1056 |
|
1057 |
WysijaForm.init();
|
1058 |
},
|
1059 |
+
editSettings: function () {
|
1060 |
window.MailPoet.Modal.popup({
|
1061 |
title: window.MailPoet.I18n.t('editFieldSettings'),
|
1062 |
template: window.jQuery('#form_template_field_settings').html(),
|
1063 |
data: this.getData(),
|
1064 |
+
onSuccess: function () {
|
1065 |
var data = window.jQuery('#form_field_settings').serializeObject();
|
1066 |
this.redraw(data);
|
1067 |
}.bind(this)
|
1068 |
});
|
1069 |
},
|
1070 |
+
getSettings: function () {
|
1071 |
return this.element.down('.wysija_settings');
|
1072 |
}
|
1073 |
});
|
1077 |
|
1078 |
/* LOGGING */
|
1079 |
function info(value) {
|
1080 |
+
if (WysijaForm.options.debug === false) return;
|
1081 |
|
1082 |
+
if (!(window.console && console.log)) {
|
1083 |
+
(function () {
|
1084 |
+
var noop = function () {};
|
1085 |
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
|
1086 |
var length = methods.length;
|
1087 |
window.console = {};
|
1088 |
var console = {};
|
1089 |
+
while (length--) {
|
1090 |
console[methods[length]] = noop;
|
1091 |
}
|
1092 |
}());
|
1093 |
}
|
1094 |
try {
|
1095 |
console.log('[DEBUG] ' + value);
|
1096 |
+
} catch (e) {}
|
1097 |
}
|
1098 |
|
1099 |
module.exports = WysijaForm;
|
assets/js/lib/mailpoet_shortcodes/plugin.js
CHANGED
@@ -8,22 +8,22 @@
|
|
8 |
* its placeholder into editor text.
|
9 |
*/
|
10 |
|
11 |
-
/*jshint unused:false */
|
12 |
-
/*global tinymce:true */
|
13 |
-
tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
|
14 |
-
var appendLabelAndClose = function(shortcode) {
|
15 |
editor.insertContent(shortcode);
|
16 |
editor.windowManager.close();
|
17 |
},
|
18 |
-
generateOnClickFunc = function(shortcode) {
|
19 |
-
return function() {
|
20 |
appendLabelAndClose(shortcode);
|
21 |
};
|
22 |
};
|
23 |
|
24 |
editor.addButton('mailpoet_shortcodes', {
|
25 |
icon: 'mailpoet_shortcodes',
|
26 |
-
onclick: function() {
|
27 |
var shortcodes = [],
|
28 |
configShortcodes = editor.settings.mailpoet_shortcodes;
|
29 |
|
8 |
* its placeholder into editor text.
|
9 |
*/
|
10 |
|
11 |
+
/* jshint unused:false */
|
12 |
+
/* global tinymce:true */
|
13 |
+
tinymce.PluginManager.add('mailpoet_shortcodes', function (editor, url) {
|
14 |
+
var appendLabelAndClose = function (shortcode) {
|
15 |
editor.insertContent(shortcode);
|
16 |
editor.windowManager.close();
|
17 |
},
|
18 |
+
generateOnClickFunc = function (shortcode) {
|
19 |
+
return function () {
|
20 |
appendLabelAndClose(shortcode);
|
21 |
};
|
22 |
};
|
23 |
|
24 |
editor.addButton('mailpoet_shortcodes', {
|
25 |
icon: 'mailpoet_shortcodes',
|
26 |
+
onclick: function () {
|
27 |
var shortcodes = [],
|
28 |
configShortcodes = editor.settings.mailpoet_shortcodes;
|
29 |
|
assets/js/{mailpoet.25f879a2.js → mailpoet.eab93337.js}
RENAMED
@@ -775,11 +775,9 @@ webpackJsonp([3],[
|
|
775 |
|
776 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
777 |
* Copyright (c) 2013-present, Facebook, Inc.
|
778 |
-
* All rights reserved.
|
779 |
*
|
780 |
-
* This source code is licensed under the
|
781 |
-
* LICENSE file in the root directory of this source tree.
|
782 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
783 |
*
|
784 |
*/
|
785 |
|
@@ -1216,12 +1214,10 @@ webpackJsonp([3],[
|
|
1216 |
/***/ function(module, exports, __webpack_require__) {
|
1217 |
|
1218 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1219 |
-
* Copyright 2014-
|
1220 |
-
* All rights reserved.
|
1221 |
*
|
1222 |
-
* This source code is licensed under the
|
1223 |
-
* LICENSE file in the root directory of this source tree.
|
1224 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
1225 |
*
|
1226 |
*/
|
1227 |
|
@@ -1289,11 +1285,9 @@ webpackJsonp([3],[
|
|
1289 |
|
1290 |
/**
|
1291 |
* Copyright (c) 2013-present, Facebook, Inc.
|
1292 |
-
* All rights reserved.
|
1293 |
*
|
1294 |
-
* This source code is licensed under the
|
1295 |
-
* LICENSE file in the root directory of this source tree.
|
1296 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
1297 |
*
|
1298 |
*
|
1299 |
*/
|
@@ -1898,11 +1892,9 @@ webpackJsonp([3],[
|
|
1898 |
|
1899 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1900 |
* Copyright (c) 2013-present, Facebook, Inc.
|
1901 |
-
* All rights reserved.
|
1902 |
*
|
1903 |
-
* This source code is licensed under the
|
1904 |
-
* LICENSE file in the root directory of this source tree.
|
1905 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
1906 |
*
|
1907 |
*/
|
1908 |
|
@@ -6342,11 +6334,9 @@ webpackJsonp([3],[
|
|
6342 |
|
6343 |
/**
|
6344 |
* Copyright (c) 2013-present, Facebook, Inc.
|
6345 |
-
* All rights reserved.
|
6346 |
*
|
6347 |
-
* This source code is licensed under the
|
6348 |
-
* LICENSE file in the root directory of this source tree.
|
6349 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
6350 |
*
|
6351 |
*/
|
6352 |
|
@@ -8562,11 +8552,9 @@ webpackJsonp([3],[
|
|
8562 |
|
8563 |
/**
|
8564 |
* Copyright (c) 2013-present, Facebook, Inc.
|
8565 |
-
* All rights reserved.
|
8566 |
*
|
8567 |
-
* This source code is licensed under the
|
8568 |
-
* LICENSE file in the root directory of this source tree.
|
8569 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8570 |
*
|
8571 |
* @typechecks
|
8572 |
*/
|
@@ -8598,11 +8586,9 @@ webpackJsonp([3],[
|
|
8598 |
|
8599 |
/**
|
8600 |
* Copyright (c) 2013-present, Facebook, Inc.
|
8601 |
-
* All rights reserved.
|
8602 |
*
|
8603 |
-
* This source code is licensed under the
|
8604 |
-
* LICENSE file in the root directory of this source tree.
|
8605 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8606 |
*
|
8607 |
* @typechecks
|
8608 |
*/
|
@@ -10366,11 +10352,9 @@ webpackJsonp([3],[
|
|
10366 |
|
10367 |
/**
|
10368 |
* Copyright (c) 2013-present, Facebook, Inc.
|
10369 |
-
* All rights reserved.
|
10370 |
*
|
10371 |
-
* This source code is licensed under the
|
10372 |
-
* LICENSE file in the root directory of this source tree.
|
10373 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
10374 |
*
|
10375 |
* @typechecks
|
10376 |
*/
|
@@ -10455,11 +10439,9 @@ webpackJsonp([3],[
|
|
10455 |
|
10456 |
/**
|
10457 |
* Copyright (c) 2013-present, Facebook, Inc.
|
10458 |
-
* All rights reserved.
|
10459 |
*
|
10460 |
-
* This source code is licensed under the
|
10461 |
-
* LICENSE file in the root directory of this source tree.
|
10462 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
10463 |
*
|
10464 |
* @typechecks
|
10465 |
*/
|
@@ -10587,11 +10569,9 @@ webpackJsonp([3],[
|
|
10587 |
|
10588 |
/**
|
10589 |
* Copyright (c) 2013-present, Facebook, Inc.
|
10590 |
-
* All rights reserved.
|
10591 |
*
|
10592 |
-
* This source code is licensed under the
|
10593 |
-
* LICENSE file in the root directory of this source tree.
|
10594 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
10595 |
*
|
10596 |
*/
|
10597 |
|
@@ -11757,11 +11737,9 @@ webpackJsonp([3],[
|
|
11757 |
|
11758 |
/**
|
11759 |
* Copyright (c) 2013-present, Facebook, Inc.
|
11760 |
-
* All rights reserved.
|
11761 |
*
|
11762 |
-
* This source code is licensed under the
|
11763 |
-
* LICENSE file in the root directory of this source tree.
|
11764 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
11765 |
*
|
11766 |
*/
|
11767 |
|
@@ -12154,11 +12132,9 @@ webpackJsonp([3],[
|
|
12154 |
|
12155 |
/**
|
12156 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12157 |
-
* All rights reserved.
|
12158 |
*
|
12159 |
-
* This source code is licensed under the
|
12160 |
-
* LICENSE file in the root directory of this source tree.
|
12161 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12162 |
*
|
12163 |
* @typechecks
|
12164 |
*/
|
@@ -12200,11 +12176,9 @@ webpackJsonp([3],[
|
|
12200 |
|
12201 |
/**
|
12202 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12203 |
-
* All rights reserved.
|
12204 |
*
|
12205 |
-
* This source code is licensed under the
|
12206 |
-
* LICENSE file in the root directory of this source tree.
|
12207 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12208 |
*
|
12209 |
* @typechecks
|
12210 |
*/
|
@@ -12318,11 +12292,9 @@ webpackJsonp([3],[
|
|
12318 |
|
12319 |
/**
|
12320 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12321 |
-
* All rights reserved.
|
12322 |
*
|
12323 |
-
* This source code is licensed under the
|
12324 |
-
* LICENSE file in the root directory of this source tree.
|
12325 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12326 |
*
|
12327 |
* @typechecks
|
12328 |
*/
|
@@ -12363,11 +12335,9 @@ webpackJsonp([3],[
|
|
12363 |
|
12364 |
/**
|
12365 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12366 |
-
* All rights reserved.
|
12367 |
*
|
12368 |
-
* This source code is licensed under the
|
12369 |
-
* LICENSE file in the root directory of this source tree.
|
12370 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12371 |
*
|
12372 |
* @typechecks
|
12373 |
*/
|
@@ -12398,11 +12368,9 @@ webpackJsonp([3],[
|
|
12398 |
|
12399 |
/**
|
12400 |
* Copyright (c) 2013-present, Facebook, Inc.
|
12401 |
-
* All rights reserved.
|
12402 |
*
|
12403 |
-
* This source code is licensed under the
|
12404 |
-
* LICENSE file in the root directory of this source tree.
|
12405 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
12406 |
*
|
12407 |
*
|
12408 |
* @typechecks static-only
|
@@ -16044,11 +16012,9 @@ webpackJsonp([3],[
|
|
16044 |
|
16045 |
/**
|
16046 |
* Copyright (c) 2013-present, Facebook, Inc.
|
16047 |
-
* All rights reserved.
|
16048 |
*
|
16049 |
-
* This source code is licensed under the
|
16050 |
-
* LICENSE file in the root directory of this source tree.
|
16051 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
16052 |
*
|
16053 |
* @typechecks
|
16054 |
*
|
@@ -18152,11 +18118,9 @@ webpackJsonp([3],[
|
|
18152 |
|
18153 |
/**
|
18154 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18155 |
-
* All rights reserved.
|
18156 |
*
|
18157 |
-
* This source code is licensed under the
|
18158 |
-
* LICENSE file in the root directory of this source tree.
|
18159 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18160 |
*
|
18161 |
* @typechecks
|
18162 |
*/
|
@@ -18232,11 +18196,9 @@ webpackJsonp([3],[
|
|
18232 |
|
18233 |
/**
|
18234 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18235 |
-
* All rights reserved.
|
18236 |
*
|
18237 |
-
* This source code is licensed under the
|
18238 |
-
* LICENSE file in the root directory of this source tree.
|
18239 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18240 |
*
|
18241 |
* @typechecks
|
18242 |
*/
|
@@ -18920,11 +18882,9 @@ webpackJsonp([3],[
|
|
18920 |
|
18921 |
/**
|
18922 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18923 |
-
* All rights reserved.
|
18924 |
*
|
18925 |
-
* This source code is licensed under the
|
18926 |
-
* LICENSE file in the root directory of this source tree.
|
18927 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18928 |
*
|
18929 |
*
|
18930 |
*/
|
@@ -18964,11 +18924,9 @@ webpackJsonp([3],[
|
|
18964 |
|
18965 |
/**
|
18966 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18967 |
-
* All rights reserved.
|
18968 |
*
|
18969 |
-
* This source code is licensed under the
|
18970 |
-
* LICENSE file in the root directory of this source tree.
|
18971 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
18972 |
*
|
18973 |
* @typechecks
|
18974 |
*/
|
@@ -18993,11 +18951,9 @@ webpackJsonp([3],[
|
|
18993 |
|
18994 |
/**
|
18995 |
* Copyright (c) 2013-present, Facebook, Inc.
|
18996 |
-
* All rights reserved.
|
18997 |
*
|
18998 |
-
* This source code is licensed under the
|
18999 |
-
* LICENSE file in the root directory of this source tree.
|
19000 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
19001 |
*
|
19002 |
* @typechecks
|
19003 |
*/
|
@@ -19022,11 +18978,9 @@ webpackJsonp([3],[
|
|
19022 |
|
19023 |
/**
|
19024 |
* Copyright (c) 2013-present, Facebook, Inc.
|
19025 |
-
* All rights reserved.
|
19026 |
*
|
19027 |
-
* This source code is licensed under the
|
19028 |
-
* LICENSE file in the root directory of this source tree.
|
19029 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
19030 |
*
|
19031 |
* @typechecks
|
19032 |
*/
|
@@ -21469,12 +21423,10 @@ webpackJsonp([3],[
|
|
21469 |
/***/ function(module, exports, __webpack_require__) {
|
21470 |
|
21471 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21472 |
-
* Copyright 2013-present, Facebook, Inc.
|
21473 |
-
* All rights reserved.
|
21474 |
*
|
21475 |
-
* This source code is licensed under the
|
21476 |
-
* LICENSE file in the root directory of this source tree.
|
21477 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
21478 |
*/
|
21479 |
|
21480 |
if (process.env.NODE_ENV !== 'production') {
|
@@ -21506,12 +21458,10 @@ webpackJsonp([3],[
|
|
21506 |
/***/ function(module, exports, __webpack_require__) {
|
21507 |
|
21508 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21509 |
-
* Copyright 2013-present, Facebook, Inc.
|
21510 |
-
* All rights reserved.
|
21511 |
*
|
21512 |
-
* This source code is licensed under the
|
21513 |
-
* LICENSE file in the root directory of this source tree.
|
21514 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
21515 |
*/
|
21516 |
|
21517 |
'use strict';
|
@@ -21519,6 +21469,7 @@ webpackJsonp([3],[
|
|
21519 |
var emptyFunction = __webpack_require__(14);
|
21520 |
var invariant = __webpack_require__(10);
|
21521 |
var warning = __webpack_require__(13);
|
|
|
21522 |
|
21523 |
var ReactPropTypesSecret = __webpack_require__(186);
|
21524 |
var checkPropTypes = __webpack_require__(187);
|
@@ -21617,7 +21568,8 @@ webpackJsonp([3],[
|
|
21617 |
objectOf: createObjectOfTypeChecker,
|
21618 |
oneOf: createEnumTypeChecker,
|
21619 |
oneOfType: createUnionTypeChecker,
|
21620 |
-
shape: createShapeTypeChecker
|
|
|
21621 |
};
|
21622 |
|
21623 |
/**
|
@@ -21832,7 +21784,7 @@ webpackJsonp([3],[
|
|
21832 |
if (typeof checker !== 'function') {
|
21833 |
warning(
|
21834 |
false,
|
21835 |
-
'Invalid argument
|
21836 |
'received %s at index %s.',
|
21837 |
getPostfixForTypeWarning(checker),
|
21838 |
i
|
@@ -21886,6 +21838,36 @@ webpackJsonp([3],[
|
|
21886 |
return createChainableTypeChecker(validate);
|
21887 |
}
|
21888 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21889 |
function isNode(propValue) {
|
21890 |
switch (typeof propValue) {
|
21891 |
case 'number':
|
@@ -22025,12 +22007,10 @@ webpackJsonp([3],[
|
|
22025 |
/***/ function(module, exports) {
|
22026 |
|
22027 |
/**
|
22028 |
-
* Copyright 2013-present, Facebook, Inc.
|
22029 |
-
* All rights reserved.
|
22030 |
*
|
22031 |
-
* This source code is licensed under the
|
22032 |
-
* LICENSE file in the root directory of this source tree.
|
22033 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22034 |
*/
|
22035 |
|
22036 |
'use strict';
|
@@ -22045,12 +22025,10 @@ webpackJsonp([3],[
|
|
22045 |
/***/ function(module, exports, __webpack_require__) {
|
22046 |
|
22047 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
22048 |
-
* Copyright 2013-present, Facebook, Inc.
|
22049 |
-
* All rights reserved.
|
22050 |
*
|
22051 |
-
* This source code is licensed under the
|
22052 |
-
* LICENSE file in the root directory of this source tree.
|
22053 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22054 |
*/
|
22055 |
|
22056 |
'use strict';
|
@@ -22084,7 +22062,7 @@ webpackJsonp([3],[
|
|
22084 |
try {
|
22085 |
// This is intentionally an invariant that gets caught. It's the same
|
22086 |
// behavior as without this statement except with a better message.
|
22087 |
-
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + '
|
22088 |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
22089 |
} catch (ex) {
|
22090 |
error = ex;
|
@@ -22113,12 +22091,10 @@ webpackJsonp([3],[
|
|
22113 |
/***/ function(module, exports, __webpack_require__) {
|
22114 |
|
22115 |
/**
|
22116 |
-
* Copyright 2013-present, Facebook, Inc.
|
22117 |
-
* All rights reserved.
|
22118 |
*
|
22119 |
-
* This source code is licensed under the
|
22120 |
-
* LICENSE file in the root directory of this source tree.
|
22121 |
-
* of patent rights can be found in the PATENTS file in the same directory.
|
22122 |
*/
|
22123 |
|
22124 |
'use strict';
|
@@ -22163,7 +22139,8 @@ webpackJsonp([3],[
|
|
22163 |
objectOf: getShim,
|
22164 |
oneOf: getShim,
|
22165 |
oneOfType: getShim,
|
22166 |
-
shape: getShim
|
|
|
22167 |
};
|
22168 |
|
22169 |
ReactPropTypes.checkPropTypes = emptyFunction;
|
@@ -22267,7 +22244,7 @@ webpackJsonp([3],[
|
|
22267 |
/* 274 */
|
22268 |
/***/ function(module, exports, __webpack_require__) {
|
22269 |
|
22270 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
|
22271 |
// A placeholder for MailPoet object
|
22272 |
var MailPoet = {};
|
22273 |
|
@@ -49898,7 +49875,7 @@ webpackJsonp([3],[
|
|
49898 |
};
|
49899 |
}
|
49900 |
|
49901 |
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery, _) {
|
49902 |
var MailPoet = mp;
|
49903 |
|
49904 |
MailPoet.Ajax = {
|
@@ -49912,24 +49889,24 @@ webpackJsonp([3],[
|
|
49912 |
token: null,
|
49913 |
data: {}
|
49914 |
},
|
49915 |
-
post: function(options) {
|
49916 |
return this.request('post', options);
|
49917 |
},
|
49918 |
-
init: function(options) {
|
49919 |
// merge options
|
49920 |
this.options = jQuery.extend({}, this.defaults, options);
|
49921 |
|
49922 |
// set default url
|
49923 |
-
if(this.options.url === null) {
|
49924 |
this.options.url = window.ajaxurl;
|
49925 |
}
|
49926 |
|
49927 |
// set default token
|
49928 |
-
if(this.options.token === null) {
|
49929 |
this.options.token = window.mailpoet_token;
|
49930 |
}
|
49931 |
},
|
49932 |
-
getParams: function() {
|
49933 |
return {
|
49934 |
action: 'mailpoet',
|
49935 |
api_version: this.options.api_version,
|
@@ -49939,7 +49916,7 @@ webpackJsonp([3],[
|
|
49939 |
data: this.options.data || {}
|
49940 |
};
|
49941 |
},
|
49942 |
-
request: function(method, options) {
|
49943 |
// set options
|
49944 |
this.init(options);
|
49945 |
|
@@ -49948,7 +49925,7 @@ webpackJsonp([3],[
|
|
49948 |
|
49949 |
// remove null values from the data object
|
49950 |
if (_.isObject(params.data)) {
|
49951 |
-
params.data = _.pick(params.data, function(value) {
|
49952 |
return (value !== null);
|
49953 |
});
|
49954 |
}
|
@@ -49959,7 +49936,7 @@ webpackJsonp([3],[
|
|
49959 |
params,
|
49960 |
null,
|
49961 |
'json'
|
49962 |
-
).then(function(data) {
|
49963 |
return data;
|
49964 |
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
49965 |
|
@@ -49980,7 +49957,7 @@ webpackJsonp([3],[
|
|
49980 |
__webpack_require__(274),
|
49981 |
__webpack_require__(273),
|
49982 |
__webpack_require__(297)
|
49983 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
49984 |
mp,
|
49985 |
jQuery,
|
49986 |
Moment
|
@@ -50018,7 +49995,7 @@ webpackJsonp([3],[
|
|
50018 |
|
50019 |
return this;
|
50020 |
},
|
50021 |
-
format: function(date, opts) {
|
50022 |
var options = opts || {};
|
50023 |
this.init(options);
|
50024 |
|
@@ -50026,28 +50003,28 @@ webpackJsonp([3],[
|
|
50026 |
if (options.offset === 0) momentDate = momentDate.utc();
|
50027 |
return momentDate.format(this.convertFormat(this.options.format));
|
50028 |
},
|
50029 |
-
toDate: function(date, opts) {
|
50030 |
var options = opts || {};
|
50031 |
this.init(options);
|
50032 |
|
50033 |
return Moment(date, this.convertFormat(options.parseFormat)).toDate();
|
50034 |
},
|
50035 |
-
short: function(date) {
|
50036 |
return this.format(date, {
|
50037 |
format: 'F, j Y'
|
50038 |
});
|
50039 |
},
|
50040 |
-
full: function(date) {
|
50041 |
return this.format(date, {
|
50042 |
format: 'F, j Y H:i:s'
|
50043 |
});
|
50044 |
},
|
50045 |
-
time: function(date) {
|
50046 |
return this.format(date, {
|
50047 |
format: 'H:i:s'
|
50048 |
});
|
50049 |
},
|
50050 |
-
convertFormat: function(format) {
|
50051 |
var format_mappings = {
|
50052 |
date: {
|
50053 |
d: 'DD',
|
@@ -50122,10 +50099,10 @@ webpackJsonp([3],[
|
|
50122 |
var convertedFormat = [];
|
50123 |
var escapeToken = false;
|
50124 |
|
50125 |
-
for(var index = 0, token = ''; format.charAt(index); index += 1){
|
50126 |
token = format.charAt(index);
|
50127 |
if (escapeToken === true) {
|
50128 |
-
convertedFormat.push('['+token+']');
|
50129 |
escapeToken = false;
|
50130 |
} else {
|
50131 |
if (token === '\\') {
|
@@ -50135,7 +50112,7 @@ webpackJsonp([3],[
|
|
50135 |
} else if (replacements[token] !== undefined) {
|
50136 |
convertedFormat.push(replacements[token]);
|
50137 |
} else {
|
50138 |
-
convertedFormat.push('['+token+']');
|
50139 |
}
|
50140 |
}
|
50141 |
}
|
@@ -50152,7 +50129,7 @@ webpackJsonp([3],[
|
|
50152 |
|
50153 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
50154 |
__webpack_require__(274)
|
50155 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
50156 |
mp
|
50157 |
) {
|
50158 |
'use strict';
|
@@ -50162,13 +50139,13 @@ webpackJsonp([3],[
|
|
50162 |
var translations = {};
|
50163 |
|
50164 |
MailPoet.I18n = {
|
50165 |
-
add: function(key, value) {
|
50166 |
translations[key] = value;
|
50167 |
},
|
50168 |
-
t: function(key) {
|
50169 |
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
|
50170 |
},
|
50171 |
-
all: function() {
|
50172 |
return translations;
|
50173 |
}
|
50174 |
};
|
@@ -50180,11 +50157,11 @@ webpackJsonp([3],[
|
|
50180 |
/* 555 */
|
50181 |
/***/ function(module, exports, __webpack_require__) {
|
50182 |
|
50183 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery) {
|
50184 |
'use strict';
|
50185 |
|
50186 |
var MailPoet = mp;
|
50187 |
-
|
50188 |
MailPoet Modal:
|
50189 |
|
50190 |
version: 0.9
|
@@ -50201,7 +50178,7 @@ webpackJsonp([3],[
|
|
50201 |
|
50202 |
// loading mode
|
50203 |
MailPoet.Modal.loading(bool);
|
50204 |
-
|
50205 |
|
50206 |
MailPoet.Modal = {
|
50207 |
version: 0.9,
|
@@ -50260,44 +50237,44 @@ webpackJsonp([3],[
|
|
50260 |
options: {},
|
50261 |
templates: {
|
50262 |
overlay: '<div id="mailpoet_modal_overlay" style="display:none;"></div>',
|
50263 |
-
popup: '<div id="mailpoet_popup" tabindex="-1">'+
|
50264 |
-
'<div class="mailpoet_popup_wrapper">'+
|
50265 |
-
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
|
50266 |
-
'<div id="mailpoet_popup_title"><h2></h2></div>'+
|
50267 |
-
'<div class="mailpoet_popup_body clearfix"></div>'+
|
50268 |
-
'</div>'+
|
50269 |
'</div>',
|
50270 |
-
loading: '<div id="mailpoet_loading" style="display:none;">'+
|
50271 |
-
'<div id="mailpoet_modal_loading_1" class="mailpoet_modal_loading"></div>'+
|
50272 |
-
'<div id="mailpoet_modal_loading_2" class="mailpoet_modal_loading"></div>'+
|
50273 |
-
'<div id="mailpoet_modal_loading_3" class="mailpoet_modal_loading"></div>'+
|
50274 |
'</div>',
|
50275 |
-
panel: '<div id="mailpoet_panel">'+
|
50276 |
-
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
|
50277 |
-
'<div class="mailpoet_panel_wrapper" tabindex="-1">'+
|
50278 |
-
'<div class="mailpoet_panel_body clearfix"></div>'+
|
50279 |
-
'</div>'+
|
50280 |
'</div>',
|
50281 |
-
subpanel: '<div class="mailpoet_panel_wrapper" tabindex="-1">'+
|
50282 |
-
'<div class="mailpoet_panel_body clearfix"></div>'+
|
50283 |
'</div>'
|
50284 |
},
|
50285 |
-
getContentContainer: function() {
|
50286 |
-
return jQuery('.mailpoet_'+this.options.type+'_body');
|
50287 |
},
|
50288 |
-
setRenderer: function(renderer) {
|
50289 |
this.renderer = renderer;
|
50290 |
return this;
|
50291 |
},
|
50292 |
-
compileTemplate: function(template) {
|
50293 |
-
if(this.renderer === 'html') {
|
50294 |
-
return function() { return template; };
|
50295 |
} else {
|
50296 |
return window.Handlebars.compile(template);
|
50297 |
}
|
50298 |
},
|
50299 |
-
init: function(options) {
|
50300 |
-
if(this.initialized === true) {
|
50301 |
this.close();
|
50302 |
}
|
50303 |
// merge options
|
@@ -50312,9 +50289,9 @@ webpackJsonp([3],[
|
|
50312 |
// toggle overlay
|
50313 |
this.toggleOverlay(this.options.overlay);
|
50314 |
|
50315 |
-
if(this.options.type !== null) {
|
50316 |
// insert modal depending on its type
|
50317 |
-
if(this.options.type === 'popup') {
|
50318 |
var modal = this.compileTemplate(
|
50319 |
this.templates[this.options.type]
|
50320 |
);
|
@@ -50324,7 +50301,7 @@ webpackJsonp([3],[
|
|
50324 |
// set title
|
50325 |
jQuery('#mailpoet_popup_title h2')
|
50326 |
.html(this.options.title);
|
50327 |
-
} else if(this.options.type === 'panel') {
|
50328 |
// create panel
|
50329 |
jQuery('#mailpoet_modal_overlay')
|
50330 |
.after(this.templates[this.options.type]);
|
@@ -50333,16 +50310,16 @@ webpackJsonp([3],[
|
|
50333 |
// add proper overlay class
|
50334 |
jQuery('#mailpoet_modal_overlay')
|
50335 |
.removeClass('mailpoet_popup_overlay mailpoet_panel_overlay')
|
50336 |
-
.addClass('mailpoet_'+this.options.type+'_overlay');
|
50337 |
}
|
50338 |
|
50339 |
// set "success" callback if specified
|
50340 |
-
if(options.onSuccess !== undefined) {
|
50341 |
this.options.onSuccess = options.onSuccess;
|
50342 |
}
|
50343 |
|
50344 |
// set "cancel" callback if specified
|
50345 |
-
if(options.onCancel !== undefined) {
|
50346 |
this.options.onCancel = options.onCancel;
|
50347 |
}
|
50348 |
|
@@ -50359,8 +50336,8 @@ webpackJsonp([3],[
|
|
50359 |
|
50360 |
return this;
|
50361 |
},
|
50362 |
-
initOverlay: function(toggle) {
|
50363 |
-
if(jQuery('#mailpoet_modal_overlay').length === 0) {
|
50364 |
// insert overlay into the DOM
|
50365 |
jQuery('body').append(this.templates.overlay);
|
50366 |
// insert loading indicator into overlay
|
@@ -50368,8 +50345,8 @@ webpackJsonp([3],[
|
|
50368 |
}
|
50369 |
return this;
|
50370 |
},
|
50371 |
-
toggleOverlay: function(toggle) {
|
50372 |
-
if(toggle === true) {
|
50373 |
jQuery('#mailpoet_modal_overlay')
|
50374 |
.removeClass('mailpoet_overlay_hidden');
|
50375 |
} else {
|
@@ -50379,77 +50356,77 @@ webpackJsonp([3],[
|
|
50379 |
|
50380 |
return this;
|
50381 |
},
|
50382 |
-
setupEvents: function() {
|
50383 |
// close popup when user clicks on close button
|
50384 |
jQuery('#mailpoet_modal_close').on('click', this.cancel.bind(this));
|
50385 |
|
50386 |
// close popup when user clicks on overlay
|
50387 |
-
jQuery('#mailpoet_modal_overlay').on('click', function(e) {
|
50388 |
// we need to make sure that we are actually clicking on the overlay
|
50389 |
// because when clicking on the popup content, it will trigger
|
50390 |
// the click event on the overlay
|
50391 |
-
if(e.target.id === 'mailpoet_modal_overlay') { this.cancel(); }
|
50392 |
}.bind(this));
|
50393 |
|
50394 |
// close popup when user presses ESC key
|
50395 |
-
jQuery(document).on('keyup.mailpoet_modal', function(e) {
|
50396 |
-
if(this.opened === false) { return false; }
|
50397 |
-
if(e.keyCode === 27) { this.cancel(); }
|
50398 |
}.bind(this));
|
50399 |
|
50400 |
// make sure the popup is repositioned when the window is resized
|
50401 |
-
jQuery(window).on('resize.mailpoet_modal', function() {
|
50402 |
this.setPosition();
|
50403 |
}.bind(this));
|
50404 |
|
50405 |
return this;
|
50406 |
},
|
50407 |
-
removeEvents: function() {
|
50408 |
jQuery(document).unbind('keyup.mailpoet_modal');
|
50409 |
jQuery(window).unbind('resize.mailpoet_modal');
|
50410 |
jQuery('#mailpoet_modal_close').off('click');
|
50411 |
-
if(this.options.overlay === true) {
|
50412 |
jQuery('#mailpoet_modal_overlay').off('click');
|
50413 |
}
|
50414 |
|
50415 |
return this;
|
50416 |
},
|
50417 |
-
lock: function() {
|
50418 |
this.locked = true;
|
50419 |
|
50420 |
return this;
|
50421 |
},
|
50422 |
-
unlock: function() {
|
50423 |
this.locked = false;
|
50424 |
|
50425 |
return this;
|
50426 |
},
|
50427 |
-
isLocked: function() {
|
50428 |
return this.locked;
|
50429 |
},
|
50430 |
-
loadTemplate: function() {
|
50431 |
-
if(this.subpanels.length > 0) {
|
50432 |
// hide panel
|
50433 |
-
jQuery('.mailpoet_'+this.options.type+'_wrapper').hide();
|
50434 |
|
50435 |
// add sub panel wrapper
|
50436 |
-
jQuery('#mailpoet_'+this.options.type)
|
50437 |
.append(this.templates['subpanel']);
|
50438 |
|
50439 |
// add sub panel content
|
50440 |
-
jQuery('.mailpoet_'+this.options.type+'_body').last()
|
50441 |
.html(this.subpanels[(this.subpanels.length - 1)].element);
|
50442 |
|
50443 |
// focus on sub panel
|
50444 |
-
if(this.options.focus) {
|
50445 |
this.focus();
|
50446 |
}
|
50447 |
} else if (this.options.element) {
|
50448 |
-
jQuery('.mailpoet_'+this.options.type+'_body').empty();
|
50449 |
-
jQuery('.mailpoet_'+this.options.type+'_body')
|
50450 |
.append(this.options.element);
|
50451 |
} else {
|
50452 |
-
jQuery('.mailpoet_'+this.options.type+'_body')
|
50453 |
.html(
|
50454 |
this.options.body_template(
|
50455 |
this.options.data
|
@@ -50459,11 +50436,11 @@ webpackJsonp([3],[
|
|
50459 |
|
50460 |
return this;
|
50461 |
},
|
50462 |
-
loadUrl: function() {
|
50463 |
-
if(this.options.method === 'get') {
|
50464 |
// make ajax request
|
50465 |
jQuery.getJSON(this.options.url,
|
50466 |
-
function(data) {
|
50467 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
50468 |
// load template using fetched data
|
50469 |
this.loadTemplate();
|
@@ -50471,10 +50448,10 @@ webpackJsonp([3],[
|
|
50471 |
this.showModal();
|
50472 |
}.bind(this)
|
50473 |
);
|
50474 |
-
} else if(this.options.method === 'post') {
|
50475 |
// make ajax request
|
50476 |
jQuery.post(this.options.url, JSON.stringify(this.options.params),
|
50477 |
-
function(data) {
|
50478 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
50479 |
// load template using fetched data
|
50480 |
this.loadTemplate();
|
@@ -50487,8 +50464,8 @@ webpackJsonp([3],[
|
|
50487 |
|
50488 |
return this;
|
50489 |
},
|
50490 |
-
setDimensions: function() {
|
50491 |
-
switch(this.options.type) {
|
50492 |
case 'popup':
|
50493 |
// set popup dimensions
|
50494 |
jQuery('#mailpoet_popup').css({
|
@@ -50502,14 +50479,14 @@ webpackJsonp([3],[
|
|
50502 |
break;
|
50503 |
case 'panel':
|
50504 |
// set dimensions
|
50505 |
-
if(this.options.position === 'right') {
|
50506 |
jQuery('#mailpoet_panel').css({
|
50507 |
width: this.options.width,
|
50508 |
right: 0,
|
50509 |
marginRight: '-' + this.options.width,
|
50510 |
left: 'auto'
|
50511 |
});
|
50512 |
-
} else if(this.options.position === 'left') {
|
50513 |
jQuery('#mailpoet_panel').css({
|
50514 |
width: this.options.width,
|
50515 |
left: 0,
|
@@ -50523,13 +50500,13 @@ webpackJsonp([3],[
|
|
50523 |
|
50524 |
return this;
|
50525 |
},
|
50526 |
-
setPosition: function() {
|
50527 |
-
switch(this.options.type) {
|
50528 |
case 'popup':
|
50529 |
var screenWidth = jQuery(window).width(),
|
50530 |
screenHeight = jQuery(window).height(),
|
50531 |
-
modalWidth = jQuery('.mailpoet_'+ this.options.type +'_wrapper').width(),
|
50532 |
-
modalHeight = jQuery('.mailpoet_'+ this.options.type +'_wrapper').height();
|
50533 |
|
50534 |
var top = Math.max(48, parseInt((screenHeight / 2) - (modalHeight / 2))),
|
50535 |
left = Math.max(0, parseInt((screenWidth / 2) - (modalWidth / 2)));
|
@@ -50541,13 +50518,13 @@ webpackJsonp([3],[
|
|
50541 |
});
|
50542 |
break;
|
50543 |
case 'panel':
|
50544 |
-
setTimeout(function() {
|
50545 |
// set position of popup depending on screen dimensions.
|
50546 |
-
if(this.options.position === 'right') {
|
50547 |
jQuery('#mailpoet_panel').css({
|
50548 |
marginRight: 0
|
50549 |
});
|
50550 |
-
} else if(this.options.position === 'left') {
|
50551 |
jQuery('#mailpoet_panel').css({
|
50552 |
marginLeft: 0
|
50553 |
});
|
@@ -50558,7 +50535,7 @@ webpackJsonp([3],[
|
|
50558 |
|
50559 |
return this;
|
50560 |
},
|
50561 |
-
showModal: function() {
|
50562 |
// set modal dimensions
|
50563 |
this.setDimensions();
|
50564 |
|
@@ -50569,7 +50546,7 @@ webpackJsonp([3],[
|
|
50569 |
jQuery('body').addClass('mailpoet_modal_opened');
|
50570 |
|
50571 |
// show popup
|
50572 |
-
jQuery('#mailpoet_'+this.options.type).show();
|
50573 |
|
50574 |
// display overlay
|
50575 |
this.showOverlay();
|
@@ -50578,13 +50555,13 @@ webpackJsonp([3],[
|
|
50578 |
this.setPosition();
|
50579 |
|
50580 |
// add class on highlighted elements
|
50581 |
-
if(this.options.highlight !== null) {
|
50582 |
-
if(this.options.highlight.length > 0) {
|
50583 |
this.highlightOn(this.options.highlight);
|
50584 |
}
|
50585 |
}
|
50586 |
|
50587 |
-
if(this.options.focus) {
|
50588 |
this.focus();
|
50589 |
}
|
50590 |
|
@@ -50592,37 +50569,37 @@ webpackJsonp([3],[
|
|
50592 |
this.opened = true;
|
50593 |
|
50594 |
// trigger init event if specified
|
50595 |
-
if(this.options.onInit !== null) {
|
50596 |
this.options.onInit(this);
|
50597 |
}
|
50598 |
|
50599 |
return this;
|
50600 |
},
|
50601 |
-
focus: function() {
|
50602 |
-
if(this.options.type == 'popup') {
|
50603 |
-
jQuery('#mailpoet_'+this.options.type).focus();
|
50604 |
} else {
|
50605 |
// panel and subpanel
|
50606 |
-
jQuery('#mailpoet_'+this.options.type+' .mailpoet_panel_wrapper')
|
50607 |
.filter(':visible').focus();
|
50608 |
}
|
50609 |
return this;
|
50610 |
},
|
50611 |
-
highlightOn: function(element) {
|
50612 |
jQuery(element).addClass('mailpoet_modal_highlight');
|
50613 |
return this;
|
50614 |
},
|
50615 |
-
highlightOff: function() {
|
50616 |
jQuery('.mailpoet_modal_highlight')
|
50617 |
.removeClass('mailpoet_modal_highlight');
|
50618 |
return this;
|
50619 |
},
|
50620 |
-
hideModal: function(callback) {
|
50621 |
// set modal as closed
|
50622 |
this.opened = false;
|
50623 |
|
50624 |
// hide modal
|
50625 |
-
jQuery('#mailpoet_'+this.options.type).hide();
|
50626 |
|
50627 |
// remove class on highlighted elements
|
50628 |
this.highlightOff();
|
@@ -50632,15 +50609,15 @@ webpackJsonp([3],[
|
|
50632 |
|
50633 |
return this;
|
50634 |
},
|
50635 |
-
showOverlay: function(force) {
|
50636 |
jQuery('#mailpoet_modal_overlay').show();
|
50637 |
return this;
|
50638 |
},
|
50639 |
-
hideOverlay: function() {
|
50640 |
jQuery('#mailpoet_modal_overlay').hide();
|
50641 |
return this;
|
50642 |
},
|
50643 |
-
popup: function(opts) {
|
50644 |
// get options
|
50645 |
var options = opts || {};
|
50646 |
// set modal type
|
@@ -50654,7 +50631,7 @@ webpackJsonp([3],[
|
|
50654 |
|
50655 |
return this;
|
50656 |
},
|
50657 |
-
panel: function(opts) {
|
50658 |
// get options
|
50659 |
var options = opts || {};
|
50660 |
// reset subpanels
|
@@ -50675,8 +50652,8 @@ webpackJsonp([3],[
|
|
50675 |
|
50676 |
return this;
|
50677 |
},
|
50678 |
-
subpanel: function(options) {
|
50679 |
-
if(this.opened === false) {
|
50680 |
// if no panel is already opened, let's create one instead
|
50681 |
this.panel(options);
|
50682 |
} else {
|
@@ -50687,11 +50664,11 @@ webpackJsonp([3],[
|
|
50687 |
|
50688 |
return this;
|
50689 |
},
|
50690 |
-
loading: function(toggle) {
|
50691 |
// make sure the overlay is initialized and that it's visible
|
50692 |
this.initOverlay(true);
|
50693 |
|
50694 |
-
if(toggle === true) {
|
50695 |
this.showLoading();
|
50696 |
} else {
|
50697 |
this.hideLoading();
|
@@ -50699,7 +50676,7 @@ webpackJsonp([3],[
|
|
50699 |
|
50700 |
return this;
|
50701 |
},
|
50702 |
-
showLoading: function() {
|
50703 |
jQuery('#mailpoet_loading').show();
|
50704 |
|
50705 |
// add loading class to overlay
|
@@ -50708,7 +50685,7 @@ webpackJsonp([3],[
|
|
50708 |
|
50709 |
return this;
|
50710 |
},
|
50711 |
-
hideLoading: function() {
|
50712 |
jQuery('#mailpoet_loading').hide();
|
50713 |
|
50714 |
// remove loading class from overlay
|
@@ -50717,11 +50694,11 @@ webpackJsonp([3],[
|
|
50717 |
|
50718 |
return this;
|
50719 |
},
|
50720 |
-
open: function() {
|
50721 |
// load template if specified
|
50722 |
-
if(this.options.template !== null) {
|
50723 |
// check if a url was specified to get extra data
|
50724 |
-
if(this.options.url !== null) {
|
50725 |
this.loadUrl();
|
50726 |
} else {
|
50727 |
// load template
|
@@ -50736,13 +50713,13 @@ webpackJsonp([3],[
|
|
50736 |
|
50737 |
return this;
|
50738 |
},
|
50739 |
-
success: function() {
|
50740 |
-
if(this.subpanels.length > 0) {
|
50741 |
-
if(this.subpanels[(this.subpanels.length - 1)].onSuccess !== undefined) {
|
50742 |
this.subpanels[(this.subpanels.length - 1)].onSuccess(this.subpanels[(this.subpanels.length - 1)].data);
|
50743 |
}
|
50744 |
} else {
|
50745 |
-
if(this.options.onSuccess !== null) {
|
50746 |
this.options.onSuccess(this.options.data);
|
50747 |
}
|
50748 |
}
|
@@ -50750,13 +50727,13 @@ webpackJsonp([3],[
|
|
50750 |
|
50751 |
return this;
|
50752 |
},
|
50753 |
-
cancel: function() {
|
50754 |
-
if(this.subpanels.length > 0) {
|
50755 |
-
if(this.subpanels[(this.subpanels.length - 1)].onCancel !== undefined) {
|
50756 |
this.subpanels[(this.subpanels.length - 1)].onCancel(this.subpanels[(this.subpanels.length - 1)].data);
|
50757 |
}
|
50758 |
} else {
|
50759 |
-
if(this.options.onCancel !== null) {
|
50760 |
this.options.onCancel(this.options.data);
|
50761 |
}
|
50762 |
}
|
@@ -50764,33 +50741,33 @@ webpackJsonp([3],[
|
|
50764 |
|
50765 |
return this;
|
50766 |
},
|
50767 |
-
destroy: function() {
|
50768 |
this.hideOverlay();
|
50769 |
|
50770 |
// remove extra modal
|
50771 |
-
if(jQuery('#mailpoet_'+this.options.type).length > 0) {
|
50772 |
-
jQuery('#mailpoet_'+this.options.type).remove();
|
50773 |
}
|
50774 |
|
50775 |
this.initialized = false;
|
50776 |
|
50777 |
return this;
|
50778 |
},
|
50779 |
-
close: function() {
|
50780 |
-
if(this.isLocked() === true) { return this; }
|
50781 |
|
50782 |
-
if(this.subpanels.length > 0) {
|
50783 |
// close subpanel
|
50784 |
-
jQuery('.mailpoet_'+this.options.type+'_wrapper').last().remove();
|
50785 |
|
50786 |
// show previous panel
|
50787 |
-
jQuery('.mailpoet_'+this.options.type+'_wrapper').last().show();
|
50788 |
|
50789 |
// remove last subpanels
|
50790 |
this.subpanels.pop();
|
50791 |
|
50792 |
// focus on previous panel
|
50793 |
-
if(this.options.focus) {
|
50794 |
this.focus();
|
50795 |
}
|
50796 |
|
@@ -50807,7 +50784,7 @@ webpackJsonp([3],[
|
|
50807 |
this.destroy();
|
50808 |
|
50809 |
// restore the previously focused element
|
50810 |
-
if(this.prevFocus !== undefined){
|
50811 |
this.prevFocus.focus();
|
50812 |
}
|
50813 |
|
@@ -50828,10 +50805,10 @@ webpackJsonp([3],[
|
|
50828 |
/* 556 */
|
50829 |
/***/ function(module, exports, __webpack_require__) {
|
50830 |
|
50831 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery) {
|
50832 |
'use strict';
|
50833 |
|
50834 |
-
|
50835 |
|
50836 |
MailPoet Notice:
|
50837 |
|
@@ -50852,7 +50829,7 @@ webpackJsonp([3],[
|
|
50852 |
// system message (static: true)
|
50853 |
MailPoet.Notice.system('You need to updated ASAP!');
|
50854 |
|
50855 |
-
|
50856 |
var MailPoet = mp;
|
50857 |
MailPoet.Notice = {
|
50858 |
version: 1.0,
|
@@ -50870,15 +50847,15 @@ webpackJsonp([3],[
|
|
50870 |
onClose: null
|
50871 |
},
|
50872 |
options: {},
|
50873 |
-
init: function(options) {
|
50874 |
// set options
|
50875 |
this.options = jQuery.extend({}, this.defaults, options);
|
50876 |
|
50877 |
return this;
|
50878 |
},
|
50879 |
-
createNotice: function() {
|
50880 |
// clone element
|
50881 |
-
this.element = jQuery('#mailpoet_notice_'+this.options.type).clone();
|
50882 |
|
50883 |
// add data-id to the element
|
50884 |
if (this.options.id) {
|
@@ -50898,7 +50875,7 @@ webpackJsonp([3],[
|
|
50898 |
} else if (typeof this.options.positionAfter === 'string') {
|
50899 |
positionAfter = jQuery(this.options.positionAfter);
|
50900 |
} else {
|
50901 |
-
positionAfter = jQuery('#mailpoet_notice_'+this.options.type);
|
50902 |
}
|
50903 |
positionAfter.after(this.element);
|
50904 |
|
@@ -50909,8 +50886,8 @@ webpackJsonp([3],[
|
|
50909 |
}
|
50910 |
|
50911 |
// listen to remove event
|
50912 |
-
jQuery(this.element).on('close', function() {
|
50913 |
-
jQuery(this).fadeOut(200, function() {
|
50914 |
// on close callback
|
50915 |
if (onClose !== null) {
|
50916 |
onClose();
|
@@ -50921,41 +50898,41 @@ webpackJsonp([3],[
|
|
50921 |
}.bind(this.element));
|
50922 |
|
50923 |
// listen to message event
|
50924 |
-
jQuery(this.element).on('setMessage', function(e, message) {
|
50925 |
MailPoet.Notice.setMessage(message);
|
50926 |
}.bind(this.element));
|
50927 |
|
50928 |
return this;
|
50929 |
},
|
50930 |
-
updateNotice: function() {
|
50931 |
// update notice's message
|
50932 |
-
jQuery('[data-id="'+this.options.id+'"').first().trigger(
|
50933 |
'setMessage', this.options.message
|
50934 |
);
|
50935 |
},
|
50936 |
-
setMessage: function(message) {
|
50937 |
var formattedMessage = this.formatMessage(message);
|
50938 |
|
50939 |
// let's sugar coat the message with a fancy <p>
|
50940 |
-
formattedMessage = '<p>'+formattedMessage+'</p>';
|
50941 |
// set message
|
50942 |
return this.element.html(formattedMessage);
|
50943 |
},
|
50944 |
-
formatMessage: function(message) {
|
50945 |
if (Array.isArray(message)) {
|
50946 |
return message.join('<br />');
|
50947 |
} else {
|
50948 |
return message;
|
50949 |
}
|
50950 |
},
|
50951 |
-
show: function(options) {
|
50952 |
// initialize
|
50953 |
this.init(options);
|
50954 |
|
50955 |
if (
|
50956 |
this.options.id !== null
|
50957 |
&&
|
50958 |
-
jQuery('[data-id="'+this.options.id+'"]').length > 0
|
50959 |
) {
|
50960 |
this.updateNotice();
|
50961 |
} else {
|
@@ -50963,7 +50940,7 @@ webpackJsonp([3],[
|
|
50963 |
}
|
50964 |
this.showNotice();
|
50965 |
},
|
50966 |
-
showNotice: function() {
|
50967 |
// set message
|
50968 |
this.setMessage(this.options.message);
|
50969 |
|
@@ -50996,7 +50973,7 @@ webpackJsonp([3],[
|
|
50996 |
this.element.delay(this.options.timeout).trigger('close');
|
50997 |
} else if (this.options.hideClose === false) {
|
50998 |
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
|
50999 |
-
this.element.find('.mailpoet_notice_close').on('click', function() {
|
51000 |
jQuery(this).trigger('close');
|
51001 |
});
|
51002 |
}
|
@@ -51006,7 +50983,7 @@ webpackJsonp([3],[
|
|
51006 |
this.options.onOpen(this.element);
|
51007 |
}
|
51008 |
},
|
51009 |
-
hide: function(all) {
|
51010 |
if (all !== undefined && all === true) {
|
51011 |
// all notices
|
51012 |
jQuery('.mailpoet_notice:not([id])').trigger('close');
|
@@ -51023,19 +51000,19 @@ webpackJsonp([3],[
|
|
51023 |
.trigger('close');
|
51024 |
}
|
51025 |
},
|
51026 |
-
error: function(message, options) {
|
51027 |
this.show(jQuery.extend({}, {
|
51028 |
type: 'error',
|
51029 |
message: message
|
51030 |
}, options));
|
51031 |
},
|
51032 |
-
success: function(message, options) {
|
51033 |
this.show(jQuery.extend({}, {
|
51034 |
type: 'success',
|
51035 |
message: message
|
51036 |
}, options));
|
51037 |
},
|
51038 |
-
system: function(message, options) {
|
51039 |
this.show(jQuery.extend({}, {
|
51040 |
type: 'system',
|
51041 |
static: true,
|
@@ -51052,7 +51029,7 @@ webpackJsonp([3],[
|
|
51052 |
|
51053 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
51054 |
__webpack_require__(274)
|
51055 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
51056 |
mp
|
51057 |
) {
|
51058 |
'use strict';
|
@@ -51065,7 +51042,7 @@ webpackJsonp([3],[
|
|
51065 |
return (Math.round(num * factor) / factor)
|
51066 |
.toLocaleString(
|
51067 |
undefined,
|
51068 |
-
{minimumFractionDigits: precision, maximumFractionDigits: precision}
|
51069 |
);
|
51070 |
}
|
51071 |
};
|
@@ -51079,7 +51056,7 @@ webpackJsonp([3],[
|
|
51079 |
|
51080 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
51081 |
__webpack_require__(273)
|
51082 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
51083 |
jQuery
|
51084 |
) {
|
51085 |
var $ = jQuery;
|
@@ -51100,12 +51077,12 @@ webpackJsonp([3],[
|
|
51100 |
* Dual licensed under the MIT and GPL licenses.
|
51101 |
* http://benalman.com/about/license/
|
51102 |
*/
|
51103 |
-
$.fn.serializeObject = function(coerce) {
|
51104 |
var obj = {},
|
51105 |
coerce_types = { true: !0, false: !1, null: null };
|
51106 |
|
51107 |
// Iterate over all name=value pairs.
|
51108 |
-
$.each(
|
51109 |
var key = v.name,
|
51110 |
val = v.value,
|
51111 |
cur = obj,
|
@@ -51113,18 +51090,18 @@ webpackJsonp([3],[
|
|
51113 |
|
51114 |
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
51115 |
// into its component parts.
|
51116 |
-
keys = key.split(
|
51117 |
keys_last = keys.length - 1;
|
51118 |
|
51119 |
// If the first keys part contains [ and the last ends with ], then []
|
51120 |
// are correctly balanced.
|
51121 |
-
if (
|
51122 |
// Remove the trailing ] from the last keys part.
|
51123 |
-
keys[
|
51124 |
|
51125 |
// Split first keys part into two parts on the [ and add them back onto
|
51126 |
// the beginning of the keys array.
|
51127 |
-
keys = keys.shift().split('[').concat(
|
51128 |
|
51129 |
keys_last = keys.length - 1;
|
51130 |
} else {
|
@@ -51133,14 +51110,14 @@ webpackJsonp([3],[
|
|
51133 |
}
|
51134 |
|
51135 |
// Coerce values.
|
51136 |
-
if (
|
51137 |
-
val = val && !isNaN(val)
|
51138 |
-
: val === 'undefined'
|
51139 |
: coerce_types[val] !== undefined ? coerce_types[val] // true, false, null
|
51140 |
: val; // string
|
51141 |
}
|
51142 |
|
51143 |
-
if (
|
51144 |
// Complex key, build deep object structure based on a few rules:
|
51145 |
// * The 'cur' pointer starts at the object top-level.
|
51146 |
// * [] = array push (n is set to array length), [n] = array if n is
|
@@ -51150,10 +51127,10 @@ webpackJsonp([3],[
|
|
51150 |
// object or array based on the type of the next keys part.
|
51151 |
// * Move the 'cur' pointer to the next level.
|
51152 |
// * Rinse & repeat.
|
51153 |
-
for (
|
51154 |
key = keys[i] === '' ? cur.length : keys[i];
|
51155 |
cur[key] = i < keys_last
|
51156 |
-
? cur[key] || (
|
51157 |
: val;
|
51158 |
cur = cur[key];
|
51159 |
}
|
@@ -51162,14 +51139,14 @@ webpackJsonp([3],[
|
|
51162 |
// Simple key, even simpler rules, since only scalars and shallow
|
51163 |
// arrays are allowed.
|
51164 |
|
51165 |
-
if (
|
51166 |
// val is already an array, so push on the next value.
|
51167 |
-
obj[key].push(
|
51168 |
|
51169 |
-
} else if (
|
51170 |
// val isn't an array, but since a second value has been specified,
|
51171 |
// convert val into an array.
|
51172 |
-
obj[key] = [
|
51173 |
|
51174 |
} else {
|
51175 |
// val is a scalar.
|
@@ -53706,7 +53683,7 @@ webpackJsonp([3],[
|
|
53706 |
*/
|
53707 |
var eventsCache = [];
|
53708 |
|
53709 |
-
function track(name, data){
|
53710 |
if (typeof window.mixpanel.track !== 'function') {
|
53711 |
window.mixpanel.init(window.mixpanelTrackingId);
|
53712 |
}
|
@@ -53740,7 +53717,7 @@ webpackJsonp([3],[
|
|
53740 |
});
|
53741 |
}
|
53742 |
|
53743 |
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, _) {
|
53744 |
var MailPoet = mp;
|
53745 |
|
53746 |
function initializeMixpanelWhenLoaded() {
|
775 |
|
776 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
777 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
778 |
*
|
779 |
+
* This source code is licensed under the MIT license found in the
|
780 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
781 |
*
|
782 |
*/
|
783 |
|
1214 |
/***/ function(module, exports, __webpack_require__) {
|
1215 |
|
1216 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1217 |
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
1218 |
*
|
1219 |
+
* This source code is licensed under the MIT license found in the
|
1220 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
1221 |
*
|
1222 |
*/
|
1223 |
|
1285 |
|
1286 |
/**
|
1287 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
1288 |
*
|
1289 |
+
* This source code is licensed under the MIT license found in the
|
1290 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
1291 |
*
|
1292 |
*
|
1293 |
*/
|
1892 |
|
1893 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
1894 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
1895 |
*
|
1896 |
+
* This source code is licensed under the MIT license found in the
|
1897 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
1898 |
*
|
1899 |
*/
|
1900 |
|
6334 |
|
6335 |
/**
|
6336 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
6337 |
*
|
6338 |
+
* This source code is licensed under the MIT license found in the
|
6339 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
6340 |
*
|
6341 |
*/
|
6342 |
|
8552 |
|
8553 |
/**
|
8554 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
8555 |
*
|
8556 |
+
* This source code is licensed under the MIT license found in the
|
8557 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
8558 |
*
|
8559 |
* @typechecks
|
8560 |
*/
|
8586 |
|
8587 |
/**
|
8588 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
8589 |
*
|
8590 |
+
* This source code is licensed under the MIT license found in the
|
8591 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
8592 |
*
|
8593 |
* @typechecks
|
8594 |
*/
|
10352 |
|
10353 |
/**
|
10354 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
10355 |
*
|
10356 |
+
* This source code is licensed under the MIT license found in the
|
10357 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
10358 |
*
|
10359 |
* @typechecks
|
10360 |
*/
|
10439 |
|
10440 |
/**
|
10441 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
10442 |
*
|
10443 |
+
* This source code is licensed under the MIT license found in the
|
10444 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
10445 |
*
|
10446 |
* @typechecks
|
10447 |
*/
|
10569 |
|
10570 |
/**
|
10571 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
10572 |
*
|
10573 |
+
* This source code is licensed under the MIT license found in the
|
10574 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
10575 |
*
|
10576 |
*/
|
10577 |
|
11737 |
|
11738 |
/**
|
11739 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
11740 |
*
|
11741 |
+
* This source code is licensed under the MIT license found in the
|
11742 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
11743 |
*
|
11744 |
*/
|
11745 |
|
12132 |
|
12133 |
/**
|
12134 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12135 |
*
|
12136 |
+
* This source code is licensed under the MIT license found in the
|
12137 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12138 |
*
|
12139 |
* @typechecks
|
12140 |
*/
|
12176 |
|
12177 |
/**
|
12178 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12179 |
*
|
12180 |
+
* This source code is licensed under the MIT license found in the
|
12181 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12182 |
*
|
12183 |
* @typechecks
|
12184 |
*/
|
12292 |
|
12293 |
/**
|
12294 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12295 |
*
|
12296 |
+
* This source code is licensed under the MIT license found in the
|
12297 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12298 |
*
|
12299 |
* @typechecks
|
12300 |
*/
|
12335 |
|
12336 |
/**
|
12337 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12338 |
*
|
12339 |
+
* This source code is licensed under the MIT license found in the
|
12340 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12341 |
*
|
12342 |
* @typechecks
|
12343 |
*/
|
12368 |
|
12369 |
/**
|
12370 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
12371 |
*
|
12372 |
+
* This source code is licensed under the MIT license found in the
|
12373 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
12374 |
*
|
12375 |
*
|
12376 |
* @typechecks static-only
|
16012 |
|
16013 |
/**
|
16014 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
16015 |
*
|
16016 |
+
* This source code is licensed under the MIT license found in the
|
16017 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
16018 |
*
|
16019 |
* @typechecks
|
16020 |
*
|
18118 |
|
18119 |
/**
|
18120 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18121 |
*
|
18122 |
+
* This source code is licensed under the MIT license found in the
|
18123 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18124 |
*
|
18125 |
* @typechecks
|
18126 |
*/
|
18196 |
|
18197 |
/**
|
18198 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18199 |
*
|
18200 |
+
* This source code is licensed under the MIT license found in the
|
18201 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18202 |
*
|
18203 |
* @typechecks
|
18204 |
*/
|
18882 |
|
18883 |
/**
|
18884 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18885 |
*
|
18886 |
+
* This source code is licensed under the MIT license found in the
|
18887 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18888 |
*
|
18889 |
*
|
18890 |
*/
|
18924 |
|
18925 |
/**
|
18926 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18927 |
*
|
18928 |
+
* This source code is licensed under the MIT license found in the
|
18929 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18930 |
*
|
18931 |
* @typechecks
|
18932 |
*/
|
18951 |
|
18952 |
/**
|
18953 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18954 |
*
|
18955 |
+
* This source code is licensed under the MIT license found in the
|
18956 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18957 |
*
|
18958 |
* @typechecks
|
18959 |
*/
|
18978 |
|
18979 |
/**
|
18980 |
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
18981 |
*
|
18982 |
+
* This source code is licensed under the MIT license found in the
|
18983 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
18984 |
*
|
18985 |
* @typechecks
|
18986 |
*/
|
21423 |
/***/ function(module, exports, __webpack_require__) {
|
21424 |
|
21425 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21426 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
21427 |
*
|
21428 |
+
* This source code is licensed under the MIT license found in the
|
21429 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
21430 |
*/
|
21431 |
|
21432 |
if (process.env.NODE_ENV !== 'production') {
|
21458 |
/***/ function(module, exports, __webpack_require__) {
|
21459 |
|
21460 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
21461 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
21462 |
*
|
21463 |
+
* This source code is licensed under the MIT license found in the
|
21464 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
21465 |
*/
|
21466 |
|
21467 |
'use strict';
|
21469 |
var emptyFunction = __webpack_require__(14);
|
21470 |
var invariant = __webpack_require__(10);
|
21471 |
var warning = __webpack_require__(13);
|
21472 |
+
var assign = __webpack_require__(6);
|
21473 |
|
21474 |
var ReactPropTypesSecret = __webpack_require__(186);
|
21475 |
var checkPropTypes = __webpack_require__(187);
|
21568 |
objectOf: createObjectOfTypeChecker,
|
21569 |
oneOf: createEnumTypeChecker,
|
21570 |
oneOfType: createUnionTypeChecker,
|
21571 |
+
shape: createShapeTypeChecker,
|
21572 |
+
exact: createStrictShapeTypeChecker,
|
21573 |
};
|
21574 |
|
21575 |
/**
|
21784 |
if (typeof checker !== 'function') {
|
21785 |
warning(
|
21786 |
false,
|
21787 |
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
21788 |
'received %s at index %s.',
|
21789 |
getPostfixForTypeWarning(checker),
|
21790 |
i
|
21838 |
return createChainableTypeChecker(validate);
|
21839 |
}
|
21840 |
|
21841 |
+
function createStrictShapeTypeChecker(shapeTypes) {
|
21842 |
+
function validate(props, propName, componentName, location, propFullName) {
|
21843 |
+
var propValue = props[propName];
|
21844 |
+
var propType = getPropType(propValue);
|
21845 |
+
if (propType !== 'object') {
|
21846 |
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
21847 |
+
}
|
21848 |
+
// We need to check all keys in case some are required but missing from
|
21849 |
+
// props.
|
21850 |
+
var allKeys = assign({}, props[propName], shapeTypes);
|
21851 |
+
for (var key in allKeys) {
|
21852 |
+
var checker = shapeTypes[key];
|
21853 |
+
if (!checker) {
|
21854 |
+
return new PropTypeError(
|
21855 |
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
21856 |
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
21857 |
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
21858 |
+
);
|
21859 |
+
}
|
21860 |
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
21861 |
+
if (error) {
|
21862 |
+
return error;
|
21863 |
+
}
|
21864 |
+
}
|
21865 |
+
return null;
|
21866 |
+
}
|
21867 |
+
|
21868 |
+
return createChainableTypeChecker(validate);
|
21869 |
+
}
|
21870 |
+
|
21871 |
function isNode(propValue) {
|
21872 |
switch (typeof propValue) {
|
21873 |
case 'number':
|
22007 |
/***/ function(module, exports) {
|
22008 |
|
22009 |
/**
|
22010 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22011 |
*
|
22012 |
+
* This source code is licensed under the MIT license found in the
|
22013 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22014 |
*/
|
22015 |
|
22016 |
'use strict';
|
22025 |
/***/ function(module, exports, __webpack_require__) {
|
22026 |
|
22027 |
/* WEBPACK VAR INJECTION */(function(process) {/**
|
22028 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22029 |
*
|
22030 |
+
* This source code is licensed under the MIT license found in the
|
22031 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22032 |
*/
|
22033 |
|
22034 |
'use strict';
|
22062 |
try {
|
22063 |
// This is intentionally an invariant that gets caught. It's the same
|
22064 |
// behavior as without this statement except with a better message.
|
22065 |
+
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
22066 |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
22067 |
} catch (ex) {
|
22068 |
error = ex;
|
22091 |
/***/ function(module, exports, __webpack_require__) {
|
22092 |
|
22093 |
/**
|
22094 |
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
|
22095 |
*
|
22096 |
+
* This source code is licensed under the MIT license found in the
|
22097 |
+
* LICENSE file in the root directory of this source tree.
|
|
|
22098 |
*/
|
22099 |
|
22100 |
'use strict';
|
22139 |
objectOf: getShim,
|
22140 |
oneOf: getShim,
|
22141 |
oneOfType: getShim,
|
22142 |
+
shape: getShim,
|
22143 |
+
exact: getShim
|
22144 |
};
|
22145 |
|
22146 |
ReactPropTypes.checkPropTypes = emptyFunction;
|
22244 |
/* 274 */
|
22245 |
/***/ function(module, exports, __webpack_require__) {
|
22246 |
|
22247 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
|
22248 |
// A placeholder for MailPoet object
|
22249 |
var MailPoet = {};
|
22250 |
|
49875 |
};
|
49876 |
}
|
49877 |
|
49878 |
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery, _) {
|
49879 |
var MailPoet = mp;
|
49880 |
|
49881 |
MailPoet.Ajax = {
|
49889 |
token: null,
|
49890 |
data: {}
|
49891 |
},
|
49892 |
+
post: function (options) {
|
49893 |
return this.request('post', options);
|
49894 |
},
|
49895 |
+
init: function (options) {
|
49896 |
// merge options
|
49897 |
this.options = jQuery.extend({}, this.defaults, options);
|
49898 |
|
49899 |
// set default url
|
49900 |
+
if (this.options.url === null) {
|
49901 |
this.options.url = window.ajaxurl;
|
49902 |
}
|
49903 |
|
49904 |
// set default token
|
49905 |
+
if (this.options.token === null) {
|
49906 |
this.options.token = window.mailpoet_token;
|
49907 |
}
|
49908 |
},
|
49909 |
+
getParams: function () {
|
49910 |
return {
|
49911 |
action: 'mailpoet',
|
49912 |
api_version: this.options.api_version,
|
49916 |
data: this.options.data || {}
|
49917 |
};
|
49918 |
},
|
49919 |
+
request: function (method, options) {
|
49920 |
// set options
|
49921 |
this.init(options);
|
49922 |
|
49925 |
|
49926 |
// remove null values from the data object
|
49927 |
if (_.isObject(params.data)) {
|
49928 |
+
params.data = _.pick(params.data, function (value) {
|
49929 |
return (value !== null);
|
49930 |
});
|
49931 |
}
|
49936 |
params,
|
49937 |
null,
|
49938 |
'json'
|
49939 |
+
).then(function (data) {
|
49940 |
return data;
|
49941 |
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
49942 |
|
49957 |
__webpack_require__(274),
|
49958 |
__webpack_require__(273),
|
49959 |
__webpack_require__(297)
|
49960 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
49961 |
mp,
|
49962 |
jQuery,
|
49963 |
Moment
|
49995 |
|
49996 |
return this;
|
49997 |
},
|
49998 |
+
format: function (date, opts) {
|
49999 |
var options = opts || {};
|
50000 |
this.init(options);
|
50001 |
|
50003 |
if (options.offset === 0) momentDate = momentDate.utc();
|
50004 |
return momentDate.format(this.convertFormat(this.options.format));
|
50005 |
},
|
50006 |
+
toDate: function (date, opts) {
|
50007 |
var options = opts || {};
|
50008 |
this.init(options);
|
50009 |
|
50010 |
return Moment(date, this.convertFormat(options.parseFormat)).toDate();
|
50011 |
},
|
50012 |
+
short: function (date) {
|
50013 |
return this.format(date, {
|
50014 |
format: 'F, j Y'
|
50015 |
});
|
50016 |
},
|
50017 |
+
full: function (date) {
|
50018 |
return this.format(date, {
|
50019 |
format: 'F, j Y H:i:s'
|
50020 |
});
|
50021 |
},
|
50022 |
+
time: function (date) {
|
50023 |
return this.format(date, {
|
50024 |
format: 'H:i:s'
|
50025 |
});
|
50026 |
},
|
50027 |
+
convertFormat: function (format) {
|
50028 |
var format_mappings = {
|
50029 |
date: {
|
50030 |
d: 'DD',
|
50099 |
var convertedFormat = [];
|
50100 |
var escapeToken = false;
|
50101 |
|
50102 |
+
for (var index = 0, token = ''; format.charAt(index); index += 1) {
|
50103 |
token = format.charAt(index);
|
50104 |
if (escapeToken === true) {
|
50105 |
+
convertedFormat.push('[' + token + ']');
|
50106 |
escapeToken = false;
|
50107 |
} else {
|
50108 |
if (token === '\\') {
|
50112 |
} else if (replacements[token] !== undefined) {
|
50113 |
convertedFormat.push(replacements[token]);
|
50114 |
} else {
|
50115 |
+
convertedFormat.push('[' + token + ']');
|
50116 |
}
|
50117 |
}
|
50118 |
}
|
50129 |
|
50130 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
50131 |
__webpack_require__(274)
|
50132 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
50133 |
mp
|
50134 |
) {
|
50135 |
'use strict';
|
50139 |
var translations = {};
|
50140 |
|
50141 |
MailPoet.I18n = {
|
50142 |
+
add: function (key, value) {
|
50143 |
translations[key] = value;
|
50144 |
},
|
50145 |
+
t: function (key) {
|
50146 |
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
|
50147 |
},
|
50148 |
+
all: function () {
|
50149 |
return translations;
|
50150 |
}
|
50151 |
};
|
50157 |
/* 555 */
|
50158 |
/***/ function(module, exports, __webpack_require__) {
|
50159 |
|
50160 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery) {
|
50161 |
'use strict';
|
50162 |
|
50163 |
var MailPoet = mp;
|
50164 |
+
/** *************************************************************************
|
50165 |
MailPoet Modal:
|
50166 |
|
50167 |
version: 0.9
|
50178 |
|
50179 |
// loading mode
|
50180 |
MailPoet.Modal.loading(bool);
|
50181 |
+
************************************************************************** */
|
50182 |
|
50183 |
MailPoet.Modal = {
|
50184 |
version: 0.9,
|
50237 |
options: {},
|
50238 |
templates: {
|
50239 |
overlay: '<div id="mailpoet_modal_overlay" style="display:none;"></div>',
|
50240 |
+
popup: '<div id="mailpoet_popup" tabindex="-1">' +
|
50241 |
+
'<div class="mailpoet_popup_wrapper">' +
|
50242 |
+
'<a href="javascript:;" id="mailpoet_modal_close"></a>' +
|
50243 |
+
'<div id="mailpoet_popup_title"><h2></h2></div>' +
|
50244 |
+
'<div class="mailpoet_popup_body clearfix"></div>' +
|
50245 |
+
'</div>' +
|
50246 |
'</div>',
|
50247 |
+
loading: '<div id="mailpoet_loading" style="display:none;">' +
|
50248 |
+
'<div id="mailpoet_modal_loading_1" class="mailpoet_modal_loading"></div>' +
|
50249 |
+
'<div id="mailpoet_modal_loading_2" class="mailpoet_modal_loading"></div>' +
|
50250 |
+
'<div id="mailpoet_modal_loading_3" class="mailpoet_modal_loading"></div>' +
|
50251 |
'</div>',
|
50252 |
+
panel: '<div id="mailpoet_panel">' +
|
50253 |
+
'<a href="javascript:;" id="mailpoet_modal_close"></a>' +
|
50254 |
+
'<div class="mailpoet_panel_wrapper" tabindex="-1">' +
|
50255 |
+
'<div class="mailpoet_panel_body clearfix"></div>' +
|
50256 |
+
'</div>' +
|
50257 |
'</div>',
|
50258 |
+
subpanel: '<div class="mailpoet_panel_wrapper" tabindex="-1">' +
|
50259 |
+
'<div class="mailpoet_panel_body clearfix"></div>' +
|
50260 |
'</div>'
|
50261 |
},
|
50262 |
+
getContentContainer: function () {
|
50263 |
+
return jQuery('.mailpoet_' + this.options.type + '_body');
|
50264 |
},
|
50265 |
+
setRenderer: function (renderer) {
|
50266 |
this.renderer = renderer;
|
50267 |
return this;
|
50268 |
},
|
50269 |
+
compileTemplate: function (template) {
|
50270 |
+
if (this.renderer === 'html') {
|
50271 |
+
return function () { return template; };
|
50272 |
} else {
|
50273 |
return window.Handlebars.compile(template);
|
50274 |
}
|
50275 |
},
|
50276 |
+
init: function (options) {
|
50277 |
+
if (this.initialized === true) {
|
50278 |
this.close();
|
50279 |
}
|
50280 |
// merge options
|
50289 |
// toggle overlay
|
50290 |
this.toggleOverlay(this.options.overlay);
|
50291 |
|
50292 |
+
if (this.options.type !== null) {
|
50293 |
// insert modal depending on its type
|
50294 |
+
if (this.options.type === 'popup') {
|
50295 |
var modal = this.compileTemplate(
|
50296 |
this.templates[this.options.type]
|
50297 |
);
|
50301 |
// set title
|
50302 |
jQuery('#mailpoet_popup_title h2')
|
50303 |
.html(this.options.title);
|
50304 |
+
} else if (this.options.type === 'panel') {
|
50305 |
// create panel
|
50306 |
jQuery('#mailpoet_modal_overlay')
|
50307 |
.after(this.templates[this.options.type]);
|
50310 |
// add proper overlay class
|
50311 |
jQuery('#mailpoet_modal_overlay')
|
50312 |
.removeClass('mailpoet_popup_overlay mailpoet_panel_overlay')
|
50313 |
+
.addClass('mailpoet_' + this.options.type + '_overlay');
|
50314 |
}
|
50315 |
|
50316 |
// set "success" callback if specified
|
50317 |
+
if (options.onSuccess !== undefined) {
|
50318 |
this.options.onSuccess = options.onSuccess;
|
50319 |
}
|
50320 |
|
50321 |
// set "cancel" callback if specified
|
50322 |
+
if (options.onCancel !== undefined) {
|
50323 |
this.options.onCancel = options.onCancel;
|
50324 |
}
|
50325 |
|
50336 |
|
50337 |
return this;
|
50338 |
},
|
50339 |
+
initOverlay: function (toggle) {
|
50340 |
+
if (jQuery('#mailpoet_modal_overlay').length === 0) {
|
50341 |
// insert overlay into the DOM
|
50342 |
jQuery('body').append(this.templates.overlay);
|
50343 |
// insert loading indicator into overlay
|
50345 |
}
|
50346 |
return this;
|
50347 |
},
|
50348 |
+
toggleOverlay: function (toggle) {
|
50349 |
+
if (toggle === true) {
|
50350 |
jQuery('#mailpoet_modal_overlay')
|
50351 |
.removeClass('mailpoet_overlay_hidden');
|
50352 |
} else {
|
50356 |
|
50357 |
return this;
|
50358 |
},
|
50359 |
+
setupEvents: function () {
|
50360 |
// close popup when user clicks on close button
|
50361 |
jQuery('#mailpoet_modal_close').on('click', this.cancel.bind(this));
|
50362 |
|
50363 |
// close popup when user clicks on overlay
|
50364 |
+
jQuery('#mailpoet_modal_overlay').on('click', function (e) {
|
50365 |
// we need to make sure that we are actually clicking on the overlay
|
50366 |
// because when clicking on the popup content, it will trigger
|
50367 |
// the click event on the overlay
|
50368 |
+
if (e.target.id === 'mailpoet_modal_overlay') { this.cancel(); }
|
50369 |
}.bind(this));
|
50370 |
|
50371 |
// close popup when user presses ESC key
|
50372 |
+
jQuery(document).on('keyup.mailpoet_modal', function (e) {
|
50373 |
+
if (this.opened === false) { return false; }
|
50374 |
+
if (e.keyCode === 27) { this.cancel(); }
|
50375 |
}.bind(this));
|
50376 |
|
50377 |
// make sure the popup is repositioned when the window is resized
|
50378 |
+
jQuery(window).on('resize.mailpoet_modal', function () {
|
50379 |
this.setPosition();
|
50380 |
}.bind(this));
|
50381 |
|
50382 |
return this;
|
50383 |
},
|
50384 |
+
removeEvents: function () {
|
50385 |
jQuery(document).unbind('keyup.mailpoet_modal');
|
50386 |
jQuery(window).unbind('resize.mailpoet_modal');
|
50387 |
jQuery('#mailpoet_modal_close').off('click');
|
50388 |
+
if (this.options.overlay === true) {
|
50389 |
jQuery('#mailpoet_modal_overlay').off('click');
|
50390 |
}
|
50391 |
|
50392 |
return this;
|
50393 |
},
|
50394 |
+
lock: function () {
|
50395 |
this.locked = true;
|
50396 |
|
50397 |
return this;
|
50398 |
},
|
50399 |
+
unlock: function () {
|
50400 |
this.locked = false;
|
50401 |
|
50402 |
return this;
|
50403 |
},
|
50404 |
+
isLocked: function () {
|
50405 |
return this.locked;
|
50406 |
},
|
50407 |
+
loadTemplate: function () {
|
50408 |
+
if (this.subpanels.length > 0) {
|
50409 |
// hide panel
|
50410 |
+
jQuery('.mailpoet_' + this.options.type + '_wrapper').hide();
|
50411 |
|
50412 |
// add sub panel wrapper
|
50413 |
+
jQuery('#mailpoet_' + this.options.type)
|
50414 |
.append(this.templates['subpanel']);
|
50415 |
|
50416 |
// add sub panel content
|
50417 |
+
jQuery('.mailpoet_' + this.options.type + '_body').last()
|
50418 |
.html(this.subpanels[(this.subpanels.length - 1)].element);
|
50419 |
|
50420 |
// focus on sub panel
|
50421 |
+
if (this.options.focus) {
|
50422 |
this.focus();
|
50423 |
}
|
50424 |
} else if (this.options.element) {
|
50425 |
+
jQuery('.mailpoet_' + this.options.type + '_body').empty();
|
50426 |
+
jQuery('.mailpoet_' + this.options.type + '_body')
|
50427 |
.append(this.options.element);
|
50428 |
} else {
|
50429 |
+
jQuery('.mailpoet_' + this.options.type + '_body')
|
50430 |
.html(
|
50431 |
this.options.body_template(
|
50432 |
this.options.data
|
50436 |
|
50437 |
return this;
|
50438 |
},
|
50439 |
+
loadUrl: function () {
|
50440 |
+
if (this.options.method === 'get') {
|
50441 |
// make ajax request
|
50442 |
jQuery.getJSON(this.options.url,
|
50443 |
+
function (data) {
|
50444 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
50445 |
// load template using fetched data
|
50446 |
this.loadTemplate();
|
50448 |
this.showModal();
|
50449 |
}.bind(this)
|
50450 |
);
|
50451 |
+
} else if (this.options.method === 'post') {
|
50452 |
// make ajax request
|
50453 |
jQuery.post(this.options.url, JSON.stringify(this.options.params),
|
50454 |
+
function (data) {
|
50455 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
50456 |
// load template using fetched data
|
50457 |
this.loadTemplate();
|
50464 |
|
50465 |
return this;
|
50466 |
},
|
50467 |
+
setDimensions: function () {
|
50468 |
+
switch (this.options.type) {
|
50469 |
case 'popup':
|
50470 |
// set popup dimensions
|
50471 |
jQuery('#mailpoet_popup').css({
|
50479 |
break;
|
50480 |
case 'panel':
|
50481 |
// set dimensions
|
50482 |
+
if (this.options.position === 'right') {
|
50483 |
jQuery('#mailpoet_panel').css({
|
50484 |
width: this.options.width,
|
50485 |
right: 0,
|
50486 |
marginRight: '-' + this.options.width,
|
50487 |
left: 'auto'
|
50488 |
});
|
50489 |
+
} else if (this.options.position === 'left') {
|
50490 |
jQuery('#mailpoet_panel').css({
|
50491 |
width: this.options.width,
|
50492 |
left: 0,
|
50500 |
|
50501 |
return this;
|
50502 |
},
|
50503 |
+
setPosition: function () {
|
50504 |
+
switch (this.options.type) {
|
50505 |
case 'popup':
|
50506 |
var screenWidth = jQuery(window).width(),
|
50507 |
screenHeight = jQuery(window).height(),
|
50508 |
+
modalWidth = jQuery('.mailpoet_' + this.options.type + '_wrapper').width(),
|
50509 |
+
modalHeight = jQuery('.mailpoet_' + this.options.type + '_wrapper').height();
|
50510 |
|
50511 |
var top = Math.max(48, parseInt((screenHeight / 2) - (modalHeight / 2))),
|
50512 |
left = Math.max(0, parseInt((screenWidth / 2) - (modalWidth / 2)));
|
50518 |
});
|
50519 |
break;
|
50520 |
case 'panel':
|
50521 |
+
setTimeout(function () {
|
50522 |
// set position of popup depending on screen dimensions.
|
50523 |
+
if (this.options.position === 'right') {
|
50524 |
jQuery('#mailpoet_panel').css({
|
50525 |
marginRight: 0
|
50526 |
});
|
50527 |
+
} else if (this.options.position === 'left') {
|
50528 |
jQuery('#mailpoet_panel').css({
|
50529 |
marginLeft: 0
|
50530 |
});
|
50535 |
|
50536 |
return this;
|
50537 |
},
|
50538 |
+
showModal: function () {
|
50539 |
// set modal dimensions
|
50540 |
this.setDimensions();
|
50541 |
|
50546 |
jQuery('body').addClass('mailpoet_modal_opened');
|
50547 |
|
50548 |
// show popup
|
50549 |
+
jQuery('#mailpoet_' + this.options.type).show();
|
50550 |
|
50551 |
// display overlay
|
50552 |
this.showOverlay();
|
50555 |
this.setPosition();
|
50556 |
|
50557 |
// add class on highlighted elements
|
50558 |
+
if (this.options.highlight !== null) {
|
50559 |
+
if (this.options.highlight.length > 0) {
|
50560 |
this.highlightOn(this.options.highlight);
|
50561 |
}
|
50562 |
}
|
50563 |
|
50564 |
+
if (this.options.focus) {
|
50565 |
this.focus();
|
50566 |
}
|
50567 |
|
50569 |
this.opened = true;
|
50570 |
|
50571 |
// trigger init event if specified
|
50572 |
+
if (this.options.onInit !== null) {
|
50573 |
this.options.onInit(this);
|
50574 |
}
|
50575 |
|
50576 |
return this;
|
50577 |
},
|
50578 |
+
focus: function () {
|
50579 |
+
if (this.options.type == 'popup') {
|
50580 |
+
jQuery('#mailpoet_' + this.options.type).focus();
|
50581 |
} else {
|
50582 |
// panel and subpanel
|
50583 |
+
jQuery('#mailpoet_' + this.options.type + ' .mailpoet_panel_wrapper')
|
50584 |
.filter(':visible').focus();
|
50585 |
}
|
50586 |
return this;
|
50587 |
},
|
50588 |
+
highlightOn: function (element) {
|
50589 |
jQuery(element).addClass('mailpoet_modal_highlight');
|
50590 |
return this;
|
50591 |
},
|
50592 |
+
highlightOff: function () {
|
50593 |
jQuery('.mailpoet_modal_highlight')
|
50594 |
.removeClass('mailpoet_modal_highlight');
|
50595 |
return this;
|
50596 |
},
|
50597 |
+
hideModal: function (callback) {
|
50598 |
// set modal as closed
|
50599 |
this.opened = false;
|
50600 |
|
50601 |
// hide modal
|
50602 |
+
jQuery('#mailpoet_' + this.options.type).hide();
|
50603 |
|
50604 |
// remove class on highlighted elements
|
50605 |
this.highlightOff();
|
50609 |
|
50610 |
return this;
|
50611 |
},
|
50612 |
+
showOverlay: function (force) {
|
50613 |
jQuery('#mailpoet_modal_overlay').show();
|
50614 |
return this;
|
50615 |
},
|
50616 |
+
hideOverlay: function () {
|
50617 |
jQuery('#mailpoet_modal_overlay').hide();
|
50618 |
return this;
|
50619 |
},
|
50620 |
+
popup: function (opts) {
|
50621 |
// get options
|
50622 |
var options = opts || {};
|
50623 |
// set modal type
|
50631 |
|
50632 |
return this;
|
50633 |
},
|
50634 |
+
panel: function (opts) {
|
50635 |
// get options
|
50636 |
var options = opts || {};
|
50637 |
// reset subpanels
|
50652 |
|
50653 |
return this;
|
50654 |
},
|
50655 |
+
subpanel: function (options) {
|
50656 |
+
if (this.opened === false) {
|
50657 |
// if no panel is already opened, let's create one instead
|
50658 |
this.panel(options);
|
50659 |
} else {
|
50664 |
|
50665 |
return this;
|
50666 |
},
|
50667 |
+
loading: function (toggle) {
|
50668 |
// make sure the overlay is initialized and that it's visible
|
50669 |
this.initOverlay(true);
|
50670 |
|
50671 |
+
if (toggle === true) {
|
50672 |
this.showLoading();
|
50673 |
} else {
|
50674 |
this.hideLoading();
|
50676 |
|
50677 |
return this;
|
50678 |
},
|
50679 |
+
showLoading: function () {
|
50680 |
jQuery('#mailpoet_loading').show();
|
50681 |
|
50682 |
// add loading class to overlay
|
50685 |
|
50686 |
return this;
|
50687 |
},
|
50688 |
+
hideLoading: function () {
|
50689 |
jQuery('#mailpoet_loading').hide();
|
50690 |
|
50691 |
// remove loading class from overlay
|
50694 |
|
50695 |
return this;
|
50696 |
},
|
50697 |
+
open: function () {
|
50698 |
// load template if specified
|
50699 |
+
if (this.options.template !== null) {
|
50700 |
// check if a url was specified to get extra data
|
50701 |
+
if (this.options.url !== null) {
|
50702 |
this.loadUrl();
|
50703 |
} else {
|
50704 |
// load template
|
50713 |
|
50714 |
return this;
|
50715 |
},
|
50716 |
+
success: function () {
|
50717 |
+
if (this.subpanels.length > 0) {
|
50718 |
+
if (this.subpanels[(this.subpanels.length - 1)].onSuccess !== undefined) {
|
50719 |
this.subpanels[(this.subpanels.length - 1)].onSuccess(this.subpanels[(this.subpanels.length - 1)].data);
|
50720 |
}
|
50721 |
} else {
|
50722 |
+
if (this.options.onSuccess !== null) {
|
50723 |
this.options.onSuccess(this.options.data);
|
50724 |
}
|
50725 |
}
|
50727 |
|
50728 |
return this;
|
50729 |
},
|
50730 |
+
cancel: function () {
|
50731 |
+
if (this.subpanels.length > 0) {
|
50732 |
+
if (this.subpanels[(this.subpanels.length - 1)].onCancel !== undefined) {
|
50733 |
this.subpanels[(this.subpanels.length - 1)].onCancel(this.subpanels[(this.subpanels.length - 1)].data);
|
50734 |
}
|
50735 |
} else {
|
50736 |
+
if (this.options.onCancel !== null) {
|
50737 |
this.options.onCancel(this.options.data);
|
50738 |
}
|
50739 |
}
|
50741 |
|
50742 |
return this;
|
50743 |
},
|
50744 |
+
destroy: function () {
|
50745 |
this.hideOverlay();
|
50746 |
|
50747 |
// remove extra modal
|
50748 |
+
if (jQuery('#mailpoet_' + this.options.type).length > 0) {
|
50749 |
+
jQuery('#mailpoet_' + this.options.type).remove();
|
50750 |
}
|
50751 |
|
50752 |
this.initialized = false;
|
50753 |
|
50754 |
return this;
|
50755 |
},
|
50756 |
+
close: function () {
|
50757 |
+
if (this.isLocked() === true) { return this; }
|
50758 |
|
50759 |
+
if (this.subpanels.length > 0) {
|
50760 |
// close subpanel
|
50761 |
+
jQuery('.mailpoet_' + this.options.type + '_wrapper').last().remove();
|
50762 |
|
50763 |
// show previous panel
|
50764 |
+
jQuery('.mailpoet_' + this.options.type + '_wrapper').last().show();
|
50765 |
|
50766 |
// remove last subpanels
|
50767 |
this.subpanels.pop();
|
50768 |
|
50769 |
// focus on previous panel
|
50770 |
+
if (this.options.focus) {
|
50771 |
this.focus();
|
50772 |
}
|
50773 |
|
50784 |
this.destroy();
|
50785 |
|
50786 |
// restore the previously focused element
|
50787 |
+
if (this.prevFocus !== undefined) {
|
50788 |
this.prevFocus.focus();
|
50789 |
}
|
50790 |
|
50805 |
/* 556 */
|
50806 |
/***/ function(module, exports, __webpack_require__) {
|
50807 |
|
50808 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery) {
|
50809 |
'use strict';
|
50810 |
|
50811 |
+
/*= =================================================================================================
|
50812 |
|
50813 |
MailPoet Notice:
|
50814 |
|
50829 |
// system message (static: true)
|
50830 |
MailPoet.Notice.system('You need to updated ASAP!');
|
50831 |
|
50832 |
+
================================================================================================== */
|
50833 |
var MailPoet = mp;
|
50834 |
MailPoet.Notice = {
|
50835 |
version: 1.0,
|
50847 |
onClose: null
|
50848 |
},
|
50849 |
options: {},
|
50850 |
+
init: function (options) {
|
50851 |
// set options
|
50852 |
this.options = jQuery.extend({}, this.defaults, options);
|
50853 |
|
50854 |
return this;
|
50855 |
},
|
50856 |
+
createNotice: function () {
|
50857 |
// clone element
|
50858 |
+
this.element = jQuery('#mailpoet_notice_' + this.options.type).clone();
|
50859 |
|
50860 |
// add data-id to the element
|
50861 |
if (this.options.id) {
|
50875 |
} else if (typeof this.options.positionAfter === 'string') {
|
50876 |
positionAfter = jQuery(this.options.positionAfter);
|
50877 |
} else {
|
50878 |
+
positionAfter = jQuery('#mailpoet_notice_' + this.options.type);
|
50879 |
}
|
50880 |
positionAfter.after(this.element);
|
50881 |
|
50886 |
}
|
50887 |
|
50888 |
// listen to remove event
|
50889 |
+
jQuery(this.element).on('close', function () {
|
50890 |
+
jQuery(this).fadeOut(200, function () {
|
50891 |
// on close callback
|
50892 |
if (onClose !== null) {
|
50893 |
onClose();
|
50898 |
}.bind(this.element));
|
50899 |
|
50900 |
// listen to message event
|
50901 |
+
jQuery(this.element).on('setMessage', function (e, message) {
|
50902 |
MailPoet.Notice.setMessage(message);
|
50903 |
}.bind(this.element));
|
50904 |
|
50905 |
return this;
|
50906 |
},
|
50907 |
+
updateNotice: function () {
|
50908 |
// update notice's message
|
50909 |
+
jQuery('[data-id="' + this.options.id + '"').first().trigger(
|
50910 |
'setMessage', this.options.message
|
50911 |
);
|
50912 |
},
|
50913 |
+
setMessage: function (message) {
|
50914 |
var formattedMessage = this.formatMessage(message);
|
50915 |
|
50916 |
// let's sugar coat the message with a fancy <p>
|
50917 |
+
formattedMessage = '<p>' + formattedMessage + '</p>';
|
50918 |
// set message
|
50919 |
return this.element.html(formattedMessage);
|
50920 |
},
|
50921 |
+
formatMessage: function (message) {
|
50922 |
if (Array.isArray(message)) {
|
50923 |
return message.join('<br />');
|
50924 |
} else {
|
50925 |
return message;
|
50926 |
}
|
50927 |
},
|
50928 |
+
show: function (options) {
|
50929 |
// initialize
|
50930 |
this.init(options);
|
50931 |
|
50932 |
if (
|
50933 |
this.options.id !== null
|
50934 |
&&
|
50935 |
+
jQuery('[data-id="' + this.options.id + '"]').length > 0
|
50936 |
) {
|
50937 |
this.updateNotice();
|
50938 |
} else {
|
50940 |
}
|
50941 |
this.showNotice();
|
50942 |
},
|
50943 |
+
showNotice: function () {
|
50944 |
// set message
|
50945 |
this.setMessage(this.options.message);
|
50946 |
|
50973 |
this.element.delay(this.options.timeout).trigger('close');
|
50974 |
} else if (this.options.hideClose === false) {
|
50975 |
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
|
50976 |
+
this.element.find('.mailpoet_notice_close').on('click', function () {
|
50977 |
jQuery(this).trigger('close');
|
50978 |
});
|
50979 |
}
|
50983 |
this.options.onOpen(this.element);
|
50984 |
}
|
50985 |
},
|
50986 |
+
hide: function (all) {
|
50987 |
if (all !== undefined && all === true) {
|
50988 |
// all notices
|
50989 |
jQuery('.mailpoet_notice:not([id])').trigger('close');
|
51000 |
.trigger('close');
|
51001 |
}
|
51002 |
},
|
51003 |
+
error: function (message, options) {
|
51004 |
this.show(jQuery.extend({}, {
|
51005 |
type: 'error',
|
51006 |
message: message
|
51007 |
}, options));
|
51008 |
},
|
51009 |
+
success: function (message, options) {
|
51010 |
this.show(jQuery.extend({}, {
|
51011 |
type: 'success',
|
51012 |
message: message
|
51013 |
}, options));
|
51014 |
},
|
51015 |
+
system: function (message, options) {
|
51016 |
this.show(jQuery.extend({}, {
|
51017 |
type: 'system',
|
51018 |
static: true,
|
51029 |
|
51030 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
51031 |
__webpack_require__(274)
|
51032 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
51033 |
mp
|
51034 |
) {
|
51035 |
'use strict';
|
51042 |
return (Math.round(num * factor) / factor)
|
51043 |
.toLocaleString(
|
51044 |
undefined,
|
51045 |
+
{ minimumFractionDigits: precision, maximumFractionDigits: precision }
|
51046 |
);
|
51047 |
}
|
51048 |
};
|
51056 |
|
51057 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
51058 |
__webpack_require__(273)
|
51059 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
51060 |
jQuery
|
51061 |
) {
|
51062 |
var $ = jQuery;
|
51077 |
* Dual licensed under the MIT and GPL licenses.
|
51078 |
* http://benalman.com/about/license/
|
51079 |
*/
|
51080 |
+
$.fn.serializeObject = function (coerce) {
|
51081 |
var obj = {},
|
51082 |
coerce_types = { true: !0, false: !1, null: null };
|
51083 |
|
51084 |
// Iterate over all name=value pairs.
|
51085 |
+
$.each(this.serializeArray(), function (j, v) {
|
51086 |
var key = v.name,
|
51087 |
val = v.value,
|
51088 |
cur = obj,
|
51090 |
|
51091 |
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
51092 |
// into its component parts.
|
51093 |
+
keys = key.split(']['),
|
51094 |
keys_last = keys.length - 1;
|
51095 |
|
51096 |
// If the first keys part contains [ and the last ends with ], then []
|
51097 |
// are correctly balanced.
|
51098 |
+
if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) {
|
51099 |
// Remove the trailing ] from the last keys part.
|
51100 |
+
keys[keys_last] = keys[keys_last].replace(/\]$/, '');
|
51101 |
|
51102 |
// Split first keys part into two parts on the [ and add them back onto
|
51103 |
// the beginning of the keys array.
|
51104 |
+
keys = keys.shift().split('[').concat(keys);
|
51105 |
|
51106 |
keys_last = keys.length - 1;
|
51107 |
} else {
|
51110 |
}
|
51111 |
|
51112 |
// Coerce values.
|
51113 |
+
if (coerce) {
|
51114 |
+
val = val && !isNaN(val) ? +val // number
|
51115 |
+
: val === 'undefined' ? undefined // undefined
|
51116 |
: coerce_types[val] !== undefined ? coerce_types[val] // true, false, null
|
51117 |
: val; // string
|
51118 |
}
|
51119 |
|
51120 |
+
if (keys_last) {
|
51121 |
// Complex key, build deep object structure based on a few rules:
|
51122 |
// * The 'cur' pointer starts at the object top-level.
|
51123 |
// * [] = array push (n is set to array length), [n] = array if n is
|
51127 |
// object or array based on the type of the next keys part.
|
51128 |
// * Move the 'cur' pointer to the next level.
|
51129 |
// * Rinse & repeat.
|
51130 |
+
for (; i <= keys_last; i++) {
|
51131 |
key = keys[i] === '' ? cur.length : keys[i];
|
51132 |
cur[key] = i < keys_last
|
51133 |
+
? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : [])
|
51134 |
: val;
|
51135 |
cur = cur[key];
|
51136 |
}
|
51139 |
// Simple key, even simpler rules, since only scalars and shallow
|
51140 |
// arrays are allowed.
|
51141 |
|
51142 |
+
if ($.isArray(obj[key])) {
|
51143 |
// val is already an array, so push on the next value.
|
51144 |
+
obj[key].push(val);
|
51145 |
|
51146 |
+
} else if (obj[key] !== undefined) {
|
51147 |
// val isn't an array, but since a second value has been specified,
|
51148 |
// convert val into an array.
|
51149 |
+
obj[key] = [obj[key], val];
|
51150 |
|
51151 |
} else {
|
51152 |
// val is a scalar.
|
53683 |
*/
|
53684 |
var eventsCache = [];
|
53685 |
|
53686 |
+
function track(name, data) {
|
53687 |
if (typeof window.mixpanel.track !== 'function') {
|
53688 |
window.mixpanel.init(window.mixpanelTrackingId);
|
53689 |
}
|
53717 |
});
|
53718 |
}
|
53719 |
|
53720 |
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, _) {
|
53721 |
var MailPoet = mp;
|
53722 |
|
53723 |
function initializeMixpanelWhenLoaded() {
|
assets/js/manifest.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
{
|
2 |
-
"mp2migrator.js": "mp2migrator.
|
3 |
-
"public.js": "public.
|
4 |
-
"admin.js": "admin.
|
5 |
-
"admin_vendor.js": "admin_vendor.
|
6 |
-
"form_editor.js": "form_editor.
|
7 |
-
"mailpoet.js": "mailpoet.
|
8 |
-
"newsletter_editor.js": "newsletter_editor.
|
9 |
-
"vendor.js": "vendor.
|
10 |
}
|
1 |
{
|
2 |
+
"mp2migrator.js": "mp2migrator.e755af46.js",
|
3 |
+
"public.js": "public.6e3f442a.js",
|
4 |
+
"admin.js": "admin.e3b1aa46.js",
|
5 |
+
"admin_vendor.js": "admin_vendor.53a6d3ec.js",
|
6 |
+
"form_editor.js": "form_editor.c4bc7e0b.js",
|
7 |
+
"mailpoet.js": "mailpoet.eab93337.js",
|
8 |
+
"newsletter_editor.js": "newsletter_editor.2627c560.js",
|
9 |
+
"vendor.js": "vendor.b4463523.js"
|
10 |
}
|
assets/js/{mp2migrator.923dd5b2.js → mp2migrator.e755af46.js}
RENAMED
@@ -51,7 +51,7 @@
|
|
51 |
/* 1 */
|
52 |
/***/ function(module, exports, __webpack_require__) {
|
53 |
|
54 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(2), __webpack_require__(3)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery) {
|
55 |
'use strict';
|
56 |
|
57 |
var MailPoet = mp;
|
@@ -85,11 +85,11 @@
|
|
85 |
jQuery('#logger').html('');
|
86 |
result.split('\n').forEach(function (resultRow) {
|
87 |
var row = resultRow;
|
88 |
-
if(row.substr(0, 7) === '[ERROR]' || row.substr(0, 9) === '[WARNING]' || row === MailPoet.I18n.t('import_stopped_by_user')) {
|
89 |
row = '<span class="error_msg">' + row + '</span>'; // Mark the errors in red
|
90 |
}
|
91 |
// Test if the import is complete
|
92 |
-
else if(row === MailPoet.I18n.t('import_complete')) {
|
93 |
jQuery('#import-actions').hide();
|
94 |
jQuery('#upgrade-completed').show();
|
95 |
}
|
@@ -98,7 +98,7 @@
|
|
98 |
});
|
99 |
jQuery('#logger').append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + '<br />\n');
|
100 |
}).always(function () {
|
101 |
-
if(MailPoet.MP2Migrator.is_logging) {
|
102 |
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);
|
103 |
}
|
104 |
});
|
@@ -112,17 +112,17 @@
|
|
112 |
}).always(function (result) {
|
113 |
// Move the progress bar
|
114 |
var progress = 0;
|
115 |
-
if((result.total !== undefined) && (Number(result.total) !== 0)) {
|
116 |
progress = Math.round(Number(result.current) / Number(result.total) * 100);
|
117 |
}
|
118 |
jQuery('#progressbar').progressbar('option', 'value', progress);
|
119 |
jQuery('#progresslabel').html(progress + '%');
|
120 |
-
if(Number(result.current) !== 0) {
|
121 |
jQuery('#skip-import').hide();
|
122 |
jQuery('#progressbar').show();
|
123 |
jQuery('#logger-container').show();
|
124 |
}
|
125 |
-
if(MailPoet.MP2Migrator.is_logging) {
|
126 |
MailPoet.MP2Migrator.updateProgressbar_timeout = setTimeout(MailPoet.MP2Migrator.updateProgressbar, 1000);
|
127 |
}
|
128 |
});
|
@@ -153,16 +153,16 @@
|
|
153 |
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
|
154 |
MailPoet.MP2Migrator.reactivateImportButton();
|
155 |
}).done(function (response) {
|
156 |
-
if(response) {
|
157 |
MailPoet.MP2Migrator.fatal_error = response.data;
|
158 |
}
|
159 |
}).fail(function (response) {
|
160 |
-
if(response.errors.length > 0) {
|
161 |
MailPoet.Notice.error(
|
162 |
response.errors.map(function (error) {
|
163 |
return error.message;
|
164 |
}),
|
165 |
-
{scroll: true}
|
166 |
);
|
167 |
}
|
168 |
});
|
@@ -188,12 +188,12 @@
|
|
188 |
MailPoet.MP2Migrator.reactivateImportButton();
|
189 |
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
|
190 |
}).fail(function (response) {
|
191 |
-
if(response.errors.length > 0) {
|
192 |
MailPoet.Notice.error(
|
193 |
response.errors.map(function (error) {
|
194 |
return error.message;
|
195 |
}),
|
196 |
-
{scroll: true}
|
197 |
);
|
198 |
}
|
199 |
});
|
@@ -211,12 +211,12 @@
|
|
211 |
}).done(function () {
|
212 |
MailPoet.MP2Migrator.gotoWelcomePage();
|
213 |
}).fail(function (response) {
|
214 |
-
if(response.errors.length > 0) {
|
215 |
MailPoet.Notice.error(
|
216 |
response.errors.map(function (error) {
|
217 |
return error.message;
|
218 |
}),
|
219 |
-
{scroll: true}
|
220 |
);
|
221 |
}
|
222 |
});
|
@@ -229,33 +229,33 @@
|
|
229 |
}
|
230 |
|
231 |
};
|
232 |
-
|
233 |
/**
|
234 |
* Actions to run when the DOM is ready
|
235 |
*/
|
236 |
jQuery(function () {
|
237 |
-
jQuery('#progressbar').progressbar({value: 0});
|
238 |
|
239 |
// Import button
|
240 |
-
jQuery('#import').click(function() {
|
241 |
MailPoet.MP2Migrator.startImport();
|
242 |
});
|
243 |
-
|
244 |
// Stop import button
|
245 |
-
jQuery('#stop-import').click(function() {
|
246 |
MailPoet.MP2Migrator.stopImport();
|
247 |
});
|
248 |
|
249 |
// Skip import link
|
250 |
-
jQuery('#skip-import').click(function() {
|
251 |
MailPoet.MP2Migrator.skipImport();
|
252 |
});
|
253 |
|
254 |
// Go to welcome page
|
255 |
-
jQuery('#goto-welcome').click(function() {
|
256 |
MailPoet.MP2Migrator.gotoWelcomePage();
|
257 |
});
|
258 |
-
|
259 |
// Update the display
|
260 |
MailPoet.MP2Migrator.updateDisplay();
|
261 |
});
|
51 |
/* 1 */
|
52 |
/***/ function(module, exports, __webpack_require__) {
|
53 |
|
54 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(2), __webpack_require__(3)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery) {
|
55 |
'use strict';
|
56 |
|
57 |
var MailPoet = mp;
|
85 |
jQuery('#logger').html('');
|
86 |
result.split('\n').forEach(function (resultRow) {
|
87 |
var row = resultRow;
|
88 |
+
if (row.substr(0, 7) === '[ERROR]' || row.substr(0, 9) === '[WARNING]' || row === MailPoet.I18n.t('import_stopped_by_user')) {
|
89 |
row = '<span class="error_msg">' + row + '</span>'; // Mark the errors in red
|
90 |
}
|
91 |
// Test if the import is complete
|
92 |
+
else if (row === MailPoet.I18n.t('import_complete')) {
|
93 |
jQuery('#import-actions').hide();
|
94 |
jQuery('#upgrade-completed').show();
|
95 |
}
|
98 |
});
|
99 |
jQuery('#logger').append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + '<br />\n');
|
100 |
}).always(function () {
|
101 |
+
if (MailPoet.MP2Migrator.is_logging) {
|
102 |
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);
|
103 |
}
|
104 |
});
|
112 |
}).always(function (result) {
|
113 |
// Move the progress bar
|
114 |
var progress = 0;
|
115 |
+
if ((result.total !== undefined) && (Number(result.total) !== 0)) {
|
116 |
progress = Math.round(Number(result.current) / Number(result.total) * 100);
|
117 |
}
|
118 |
jQuery('#progressbar').progressbar('option', 'value', progress);
|
119 |
jQuery('#progresslabel').html(progress + '%');
|
120 |
+
if (Number(result.current) !== 0) {
|
121 |
jQuery('#skip-import').hide();
|
122 |
jQuery('#progressbar').show();
|
123 |
jQuery('#logger-container').show();
|
124 |
}
|
125 |
+
if (MailPoet.MP2Migrator.is_logging) {
|
126 |
MailPoet.MP2Migrator.updateProgressbar_timeout = setTimeout(MailPoet.MP2Migrator.updateProgressbar, 1000);
|
127 |
}
|
128 |
});
|
153 |
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
|
154 |
MailPoet.MP2Migrator.reactivateImportButton();
|
155 |
}).done(function (response) {
|
156 |
+
if (response) {
|
157 |
MailPoet.MP2Migrator.fatal_error = response.data;
|
158 |
}
|
159 |
}).fail(function (response) {
|
160 |
+
if (response.errors.length > 0) {
|
161 |
MailPoet.Notice.error(
|
162 |
response.errors.map(function (error) {
|
163 |
return error.message;
|
164 |
}),
|
165 |
+
{ scroll: true }
|
166 |
);
|
167 |
}
|
168 |
});
|
188 |
MailPoet.MP2Migrator.reactivateImportButton();
|
189 |
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
|
190 |
}).fail(function (response) {
|
191 |
+
if (response.errors.length > 0) {
|
192 |
MailPoet.Notice.error(
|
193 |
response.errors.map(function (error) {
|
194 |
return error.message;
|
195 |
}),
|
196 |
+
{ scroll: true }
|
197 |
);
|
198 |
}
|
199 |
});
|
211 |
}).done(function () {
|
212 |
MailPoet.MP2Migrator.gotoWelcomePage();
|
213 |
}).fail(function (response) {
|
214 |
+
if (response.errors.length > 0) {
|
215 |
MailPoet.Notice.error(
|
216 |
response.errors.map(function (error) {
|
217 |
return error.message;
|
218 |
}),
|
219 |
+
{ scroll: true }
|
220 |
);
|
221 |
}
|
222 |
});
|
229 |
}
|
230 |
|
231 |
};
|
232 |
+
|
233 |
/**
|
234 |
* Actions to run when the DOM is ready
|
235 |
*/
|
236 |
jQuery(function () {
|
237 |
+
jQuery('#progressbar').progressbar({ value: 0 });
|
238 |
|
239 |
// Import button
|
240 |
+
jQuery('#import').click(function () {
|
241 |
MailPoet.MP2Migrator.startImport();
|
242 |
});
|
243 |
+
|
244 |
// Stop import button
|
245 |
+
jQuery('#stop-import').click(function () {
|
246 |
MailPoet.MP2Migrator.stopImport();
|
247 |
});
|
248 |
|
249 |
// Skip import link
|
250 |
+
jQuery('#skip-import').click(function () {
|
251 |
MailPoet.MP2Migrator.skipImport();
|
252 |
});
|
253 |
|
254 |
// Go to welcome page
|
255 |
+
jQuery('#goto-welcome').click(function () {
|
256 |
MailPoet.MP2Migrator.gotoWelcomePage();
|
257 |
});
|
258 |
+
|
259 |
// Update the display
|
260 |
MailPoet.MP2Migrator.updateDisplay();
|
261 |
});
|
assets/js/{newsletter_editor.cc3c87be.js → newsletter_editor.2627c560.js}
RENAMED
@@ -8,11 +8,11 @@ webpackJsonp([4],{
|
|
8 |
__webpack_require__(278),
|
9 |
__webpack_require__(274),
|
10 |
__webpack_require__(552)
|
11 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, _, MailPoet) {
|
12 |
|
13 |
var Module = {};
|
14 |
|
15 |
-
Module._query = function(args) {
|
16 |
return MailPoet.Ajax.post({
|
17 |
api_version: window.mailpoet_api_version,
|
18 |
endpoint: 'automatedLatestContent',
|
@@ -22,70 +22,70 @@ webpackJsonp([4],{
|
|
22 |
};
|
23 |
Module._cachedQuery = _.memoize(Module._query, JSON.stringify);
|
24 |
|
25 |
-
Module.getNewsletter = function(options) {
|
26 |
return Module._query({
|
27 |
action: 'get',
|
28 |
options: options
|
29 |
});
|
30 |
};
|
31 |
|
32 |
-
Module.getPostTypes = function() {
|
33 |
return Module._cachedQuery({
|
34 |
action: 'getPostTypes',
|
35 |
options: {}
|
36 |
-
}).then(function(response) {
|
37 |
return _.values(response.data);
|
38 |
});
|
39 |
};
|
40 |
|
41 |
-
Module.getTaxonomies = function(postType) {
|
42 |
return Module._cachedQuery({
|
43 |
action: 'getTaxonomies',
|
44 |
options: {
|
45 |
postType: postType
|
46 |
}
|
47 |
-
}).then(function(response) {
|
48 |
return response.data;
|
49 |
});
|
50 |
};
|
51 |
|
52 |
-
Module.getTerms = function(options) {
|
53 |
return Module._cachedQuery({
|
54 |
action: 'getTerms',
|
55 |
options: options
|
56 |
-
}).then(function(response) {
|
57 |
return response.data;
|
58 |
});
|
59 |
};
|
60 |
|
61 |
-
Module.getPosts = function(options) {
|
62 |
return Module._cachedQuery({
|
63 |
action: 'getPosts',
|
64 |
options: options
|
65 |
-
}).then(function(response) {
|
66 |
return response.data;
|
67 |
});
|
68 |
};
|
69 |
|
70 |
-
Module.getTransformedPosts = function(options) {
|
71 |
return Module._cachedQuery({
|
72 |
action: 'getTransformedPosts',
|
73 |
options: options
|
74 |
-
}).then(function(response) {
|
75 |
return response.data;
|
76 |
});
|
77 |
};
|
78 |
|
79 |
-
Module.getBulkTransformedPosts = function(options) {
|
80 |
return Module._query({
|
81 |
action: 'getBulkTransformedPosts',
|
82 |
options: options
|
83 |
-
}).then(function(response) {
|
84 |
return response.data;
|
85 |
});
|
86 |
};
|
87 |
|
88 |
-
Module.saveNewsletter = function(options) {
|
89 |
return MailPoet.Ajax.post({
|
90 |
api_version: window.mailpoet_api_version,
|
91 |
endpoint: 'newsletters',
|
@@ -94,7 +94,7 @@ webpackJsonp([4],{
|
|
94 |
});
|
95 |
};
|
96 |
|
97 |
-
Module.previewNewsletter = function(options) {
|
98 |
return MailPoet.Ajax.post({
|
99 |
api_version: window.mailpoet_api_version,
|
100 |
endpoint: 'newsletters',
|
@@ -103,7 +103,7 @@ webpackJsonp([4],{
|
|
103 |
});
|
104 |
};
|
105 |
|
106 |
-
App.on('start', function(App, options) {
|
107 |
// Prefetch post types
|
108 |
Module.getPostTypes();
|
109 |
});
|
@@ -167,7 +167,7 @@ webpackJsonp([4],{
|
|
167 |
/***/ 274:
|
168 |
/***/ function(module, exports, __webpack_require__) {
|
169 |
|
170 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
|
171 |
// A placeholder for MailPoet object
|
172 |
var MailPoet = {};
|
173 |
|
@@ -9428,7 +9428,7 @@ webpackJsonp([4],{
|
|
9428 |
};
|
9429 |
}
|
9430 |
|
9431 |
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery, _) {
|
9432 |
var MailPoet = mp;
|
9433 |
|
9434 |
MailPoet.Ajax = {
|
@@ -9442,24 +9442,24 @@ webpackJsonp([4],{
|
|
9442 |
token: null,
|
9443 |
data: {}
|
9444 |
},
|
9445 |
-
post: function(options) {
|
9446 |
return this.request('post', options);
|
9447 |
},
|
9448 |
-
init: function(options) {
|
9449 |
// merge options
|
9450 |
this.options = jQuery.extend({}, this.defaults, options);
|
9451 |
|
9452 |
// set default url
|
9453 |
-
if(this.options.url === null) {
|
9454 |
this.options.url = window.ajaxurl;
|
9455 |
}
|
9456 |
|
9457 |
// set default token
|
9458 |
-
if(this.options.token === null) {
|
9459 |
this.options.token = window.mailpoet_token;
|
9460 |
}
|
9461 |
},
|
9462 |
-
getParams: function() {
|
9463 |
return {
|
9464 |
action: 'mailpoet',
|
9465 |
api_version: this.options.api_version,
|
@@ -9469,7 +9469,7 @@ webpackJsonp([4],{
|
|
9469 |
data: this.options.data || {}
|
9470 |
};
|
9471 |
},
|
9472 |
-
request: function(method, options) {
|
9473 |
// set options
|
9474 |
this.init(options);
|
9475 |
|
@@ -9478,7 +9478,7 @@ webpackJsonp([4],{
|
|
9478 |
|
9479 |
// remove null values from the data object
|
9480 |
if (_.isObject(params.data)) {
|
9481 |
-
params.data = _.pick(params.data, function(value) {
|
9482 |
return (value !== null);
|
9483 |
});
|
9484 |
}
|
@@ -9489,7 +9489,7 @@ webpackJsonp([4],{
|
|
9489 |
params,
|
9490 |
null,
|
9491 |
'json'
|
9492 |
-
).then(function(data) {
|
9493 |
return data;
|
9494 |
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
9495 |
|
@@ -9507,11 +9507,11 @@ webpackJsonp([4],{
|
|
9507 |
/***/ 555:
|
9508 |
/***/ function(module, exports, __webpack_require__) {
|
9509 |
|
9510 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery) {
|
9511 |
'use strict';
|
9512 |
|
9513 |
var MailPoet = mp;
|
9514 |
-
|
9515 |
MailPoet Modal:
|
9516 |
|
9517 |
version: 0.9
|
@@ -9528,7 +9528,7 @@ webpackJsonp([4],{
|
|
9528 |
|
9529 |
// loading mode
|
9530 |
MailPoet.Modal.loading(bool);
|
9531 |
-
|
9532 |
|
9533 |
MailPoet.Modal = {
|
9534 |
version: 0.9,
|
@@ -9587,44 +9587,44 @@ webpackJsonp([4],{
|
|
9587 |
options: {},
|
9588 |
templates: {
|
9589 |
overlay: '<div id="mailpoet_modal_overlay" style="display:none;"></div>',
|
9590 |
-
popup: '<div id="mailpoet_popup" tabindex="-1">'+
|
9591 |
-
'<div class="mailpoet_popup_wrapper">'+
|
9592 |
-
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
|
9593 |
-
'<div id="mailpoet_popup_title"><h2></h2></div>'+
|
9594 |
-
'<div class="mailpoet_popup_body clearfix"></div>'+
|
9595 |
-
'</div>'+
|
9596 |
'</div>',
|
9597 |
-
loading: '<div id="mailpoet_loading" style="display:none;">'+
|
9598 |
-
'<div id="mailpoet_modal_loading_1" class="mailpoet_modal_loading"></div>'+
|
9599 |
-
'<div id="mailpoet_modal_loading_2" class="mailpoet_modal_loading"></div>'+
|
9600 |
-
'<div id="mailpoet_modal_loading_3" class="mailpoet_modal_loading"></div>'+
|
9601 |
'</div>',
|
9602 |
-
panel: '<div id="mailpoet_panel">'+
|
9603 |
-
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
|
9604 |
-
'<div class="mailpoet_panel_wrapper" tabindex="-1">'+
|
9605 |
-
'<div class="mailpoet_panel_body clearfix"></div>'+
|
9606 |
-
'</div>'+
|
9607 |
'</div>',
|
9608 |
-
subpanel: '<div class="mailpoet_panel_wrapper" tabindex="-1">'+
|
9609 |
-
'<div class="mailpoet_panel_body clearfix"></div>'+
|
9610 |
'</div>'
|
9611 |
},
|
9612 |
-
getContentContainer: function() {
|
9613 |
-
return jQuery('.mailpoet_'+this.options.type+'_body');
|
9614 |
},
|
9615 |
-
setRenderer: function(renderer) {
|
9616 |
this.renderer = renderer;
|
9617 |
return this;
|
9618 |
},
|
9619 |
-
compileTemplate: function(template) {
|
9620 |
-
if(this.renderer === 'html') {
|
9621 |
-
return function() { return template; };
|
9622 |
} else {
|
9623 |
return window.Handlebars.compile(template);
|
9624 |
}
|
9625 |
},
|
9626 |
-
init: function(options) {
|
9627 |
-
if(this.initialized === true) {
|
9628 |
this.close();
|
9629 |
}
|
9630 |
// merge options
|
@@ -9639,9 +9639,9 @@ webpackJsonp([4],{
|
|
9639 |
// toggle overlay
|
9640 |
this.toggleOverlay(this.options.overlay);
|
9641 |
|
9642 |
-
if(this.options.type !== null) {
|
9643 |
// insert modal depending on its type
|
9644 |
-
if(this.options.type === 'popup') {
|
9645 |
var modal = this.compileTemplate(
|
9646 |
this.templates[this.options.type]
|
9647 |
);
|
@@ -9651,7 +9651,7 @@ webpackJsonp([4],{
|
|
9651 |
// set title
|
9652 |
jQuery('#mailpoet_popup_title h2')
|
9653 |
.html(this.options.title);
|
9654 |
-
} else if(this.options.type === 'panel') {
|
9655 |
// create panel
|
9656 |
jQuery('#mailpoet_modal_overlay')
|
9657 |
.after(this.templates[this.options.type]);
|
@@ -9660,16 +9660,16 @@ webpackJsonp([4],{
|
|
9660 |
// add proper overlay class
|
9661 |
jQuery('#mailpoet_modal_overlay')
|
9662 |
.removeClass('mailpoet_popup_overlay mailpoet_panel_overlay')
|
9663 |
-
.addClass('mailpoet_'+this.options.type+'_overlay');
|
9664 |
}
|
9665 |
|
9666 |
// set "success" callback if specified
|
9667 |
-
if(options.onSuccess !== undefined) {
|
9668 |
this.options.onSuccess = options.onSuccess;
|
9669 |
}
|
9670 |
|
9671 |
// set "cancel" callback if specified
|
9672 |
-
if(options.onCancel !== undefined) {
|
9673 |
this.options.onCancel = options.onCancel;
|
9674 |
}
|
9675 |
|
@@ -9686,8 +9686,8 @@ webpackJsonp([4],{
|
|
9686 |
|
9687 |
return this;
|
9688 |
},
|
9689 |
-
initOverlay: function(toggle) {
|
9690 |
-
if(jQuery('#mailpoet_modal_overlay').length === 0) {
|
9691 |
// insert overlay into the DOM
|
9692 |
jQuery('body').append(this.templates.overlay);
|
9693 |
// insert loading indicator into overlay
|
@@ -9695,8 +9695,8 @@ webpackJsonp([4],{
|
|
9695 |
}
|
9696 |
return this;
|
9697 |
},
|
9698 |
-
toggleOverlay: function(toggle) {
|
9699 |
-
if(toggle === true) {
|
9700 |
jQuery('#mailpoet_modal_overlay')
|
9701 |
.removeClass('mailpoet_overlay_hidden');
|
9702 |
} else {
|
@@ -9706,77 +9706,77 @@ webpackJsonp([4],{
|
|
9706 |
|
9707 |
return this;
|
9708 |
},
|
9709 |
-
setupEvents: function() {
|
9710 |
// close popup when user clicks on close button
|
9711 |
jQuery('#mailpoet_modal_close').on('click', this.cancel.bind(this));
|
9712 |
|
9713 |
// close popup when user clicks on overlay
|
9714 |
-
jQuery('#mailpoet_modal_overlay').on('click', function(e) {
|
9715 |
// we need to make sure that we are actually clicking on the overlay
|
9716 |
// because when clicking on the popup content, it will trigger
|
9717 |
// the click event on the overlay
|
9718 |
-
if(e.target.id === 'mailpoet_modal_overlay') { this.cancel(); }
|
9719 |
}.bind(this));
|
9720 |
|
9721 |
// close popup when user presses ESC key
|
9722 |
-
jQuery(document).on('keyup.mailpoet_modal', function(e) {
|
9723 |
-
if(this.opened === false) { return false; }
|
9724 |
-
if(e.keyCode === 27) { this.cancel(); }
|
9725 |
}.bind(this));
|
9726 |
|
9727 |
// make sure the popup is repositioned when the window is resized
|
9728 |
-
jQuery(window).on('resize.mailpoet_modal', function() {
|
9729 |
this.setPosition();
|
9730 |
}.bind(this));
|
9731 |
|
9732 |
return this;
|
9733 |
},
|
9734 |
-
removeEvents: function() {
|
9735 |
jQuery(document).unbind('keyup.mailpoet_modal');
|
9736 |
jQuery(window).unbind('resize.mailpoet_modal');
|
9737 |
jQuery('#mailpoet_modal_close').off('click');
|
9738 |
-
if(this.options.overlay === true) {
|
9739 |
jQuery('#mailpoet_modal_overlay').off('click');
|
9740 |
}
|
9741 |
|
9742 |
return this;
|
9743 |
},
|
9744 |
-
lock: function() {
|
9745 |
this.locked = true;
|
9746 |
|
9747 |
return this;
|
9748 |
},
|
9749 |
-
unlock: function() {
|
9750 |
this.locked = false;
|
9751 |
|
9752 |
return this;
|
9753 |
},
|
9754 |
-
isLocked: function() {
|
9755 |
return this.locked;
|
9756 |
},
|
9757 |
-
loadTemplate: function() {
|
9758 |
-
if(this.subpanels.length > 0) {
|
9759 |
// hide panel
|
9760 |
-
jQuery('.mailpoet_'+this.options.type+'_wrapper').hide();
|
9761 |
|
9762 |
// add sub panel wrapper
|
9763 |
-
jQuery('#mailpoet_'+this.options.type)
|
9764 |
.append(this.templates['subpanel']);
|
9765 |
|
9766 |
// add sub panel content
|
9767 |
-
jQuery('.mailpoet_'+this.options.type+'_body').last()
|
9768 |
.html(this.subpanels[(this.subpanels.length - 1)].element);
|
9769 |
|
9770 |
// focus on sub panel
|
9771 |
-
if(this.options.focus) {
|
9772 |
this.focus();
|
9773 |
}
|
9774 |
} else if (this.options.element) {
|
9775 |
-
jQuery('.mailpoet_'+this.options.type+'_body').empty();
|
9776 |
-
jQuery('.mailpoet_'+this.options.type+'_body')
|
9777 |
.append(this.options.element);
|
9778 |
} else {
|
9779 |
-
jQuery('.mailpoet_'+this.options.type+'_body')
|
9780 |
.html(
|
9781 |
this.options.body_template(
|
9782 |
this.options.data
|
@@ -9786,11 +9786,11 @@ webpackJsonp([4],{
|
|
9786 |
|
9787 |
return this;
|
9788 |
},
|
9789 |
-
loadUrl: function() {
|
9790 |
-
if(this.options.method === 'get') {
|
9791 |
// make ajax request
|
9792 |
jQuery.getJSON(this.options.url,
|
9793 |
-
function(data) {
|
9794 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
9795 |
// load template using fetched data
|
9796 |
this.loadTemplate();
|
@@ -9798,10 +9798,10 @@ webpackJsonp([4],{
|
|
9798 |
this.showModal();
|
9799 |
}.bind(this)
|
9800 |
);
|
9801 |
-
} else if(this.options.method === 'post') {
|
9802 |
// make ajax request
|
9803 |
jQuery.post(this.options.url, JSON.stringify(this.options.params),
|
9804 |
-
function(data) {
|
9805 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
9806 |
// load template using fetched data
|
9807 |
this.loadTemplate();
|
@@ -9814,8 +9814,8 @@ webpackJsonp([4],{
|
|
9814 |
|
9815 |
return this;
|
9816 |
},
|
9817 |
-
setDimensions: function() {
|
9818 |
-
switch(this.options.type) {
|
9819 |
case 'popup':
|
9820 |
// set popup dimensions
|
9821 |
jQuery('#mailpoet_popup').css({
|
@@ -9829,14 +9829,14 @@ webpackJsonp([4],{
|
|
9829 |
break;
|
9830 |
case 'panel':
|
9831 |
// set dimensions
|
9832 |
-
if(this.options.position === 'right') {
|
9833 |
jQuery('#mailpoet_panel').css({
|
9834 |
width: this.options.width,
|
9835 |
right: 0,
|
9836 |
marginRight: '-' + this.options.width,
|
9837 |
left: 'auto'
|
9838 |
});
|
9839 |
-
} else if(this.options.position === 'left') {
|
9840 |
jQuery('#mailpoet_panel').css({
|
9841 |
width: this.options.width,
|
9842 |
left: 0,
|
@@ -9850,13 +9850,13 @@ webpackJsonp([4],{
|
|
9850 |
|
9851 |
return this;
|
9852 |
},
|
9853 |
-
setPosition: function() {
|
9854 |
-
switch(this.options.type) {
|
9855 |
case 'popup':
|
9856 |
var screenWidth = jQuery(window).width(),
|
9857 |
screenHeight = jQuery(window).height(),
|
9858 |
-
modalWidth = jQuery('.mailpoet_'+ this.options.type +'_wrapper').width(),
|
9859 |
-
modalHeight = jQuery('.mailpoet_'+ this.options.type +'_wrapper').height();
|
9860 |
|
9861 |
var top = Math.max(48, parseInt((screenHeight / 2) - (modalHeight / 2))),
|
9862 |
left = Math.max(0, parseInt((screenWidth / 2) - (modalWidth / 2)));
|
@@ -9868,13 +9868,13 @@ webpackJsonp([4],{
|
|
9868 |
});
|
9869 |
break;
|
9870 |
case 'panel':
|
9871 |
-
setTimeout(function() {
|
9872 |
// set position of popup depending on screen dimensions.
|
9873 |
-
if(this.options.position === 'right') {
|
9874 |
jQuery('#mailpoet_panel').css({
|
9875 |
marginRight: 0
|
9876 |
});
|
9877 |
-
} else if(this.options.position === 'left') {
|
9878 |
jQuery('#mailpoet_panel').css({
|
9879 |
marginLeft: 0
|
9880 |
});
|
@@ -9885,7 +9885,7 @@ webpackJsonp([4],{
|
|
9885 |
|
9886 |
return this;
|
9887 |
},
|
9888 |
-
showModal: function() {
|
9889 |
// set modal dimensions
|
9890 |
this.setDimensions();
|
9891 |
|
@@ -9896,7 +9896,7 @@ webpackJsonp([4],{
|
|
9896 |
jQuery('body').addClass('mailpoet_modal_opened');
|
9897 |
|
9898 |
// show popup
|
9899 |
-
jQuery('#mailpoet_'+this.options.type).show();
|
9900 |
|
9901 |
// display overlay
|
9902 |
this.showOverlay();
|
@@ -9905,13 +9905,13 @@ webpackJsonp([4],{
|
|
9905 |
this.setPosition();
|
9906 |
|
9907 |
// add class on highlighted elements
|
9908 |
-
if(this.options.highlight !== null) {
|
9909 |
-
if(this.options.highlight.length > 0) {
|
9910 |
this.highlightOn(this.options.highlight);
|
9911 |
}
|
9912 |
}
|
9913 |
|
9914 |
-
if(this.options.focus) {
|
9915 |
this.focus();
|
9916 |
}
|
9917 |
|
@@ -9919,37 +9919,37 @@ webpackJsonp([4],{
|
|
9919 |
this.opened = true;
|
9920 |
|
9921 |
// trigger init event if specified
|
9922 |
-
if(this.options.onInit !== null) {
|
9923 |
this.options.onInit(this);
|
9924 |
}
|
9925 |
|
9926 |
return this;
|
9927 |
},
|
9928 |
-
focus: function() {
|
9929 |
-
if(this.options.type == 'popup') {
|
9930 |
-
jQuery('#mailpoet_'+this.options.type).focus();
|
9931 |
} else {
|
9932 |
// panel and subpanel
|
9933 |
-
jQuery('#mailpoet_'+this.options.type+' .mailpoet_panel_wrapper')
|
9934 |
.filter(':visible').focus();
|
9935 |
}
|
9936 |
return this;
|
9937 |
},
|
9938 |
-
highlightOn: function(element) {
|
9939 |
jQuery(element).addClass('mailpoet_modal_highlight');
|
9940 |
return this;
|
9941 |
},
|
9942 |
-
highlightOff: function() {
|
9943 |
jQuery('.mailpoet_modal_highlight')
|
9944 |
.removeClass('mailpoet_modal_highlight');
|
9945 |
return this;
|
9946 |
},
|
9947 |
-
hideModal: function(callback) {
|
9948 |
// set modal as closed
|
9949 |
this.opened = false;
|
9950 |
|
9951 |
// hide modal
|
9952 |
-
jQuery('#mailpoet_'+this.options.type).hide();
|
9953 |
|
9954 |
// remove class on highlighted elements
|
9955 |
this.highlightOff();
|
@@ -9959,15 +9959,15 @@ webpackJsonp([4],{
|
|
9959 |
|
9960 |
return this;
|
9961 |
},
|
9962 |
-
showOverlay: function(force) {
|
9963 |
jQuery('#mailpoet_modal_overlay').show();
|
9964 |
return this;
|
9965 |
},
|
9966 |
-
hideOverlay: function() {
|
9967 |
jQuery('#mailpoet_modal_overlay').hide();
|
9968 |
return this;
|
9969 |
},
|
9970 |
-
popup: function(opts) {
|
9971 |
// get options
|
9972 |
var options = opts || {};
|
9973 |
// set modal type
|
@@ -9981,7 +9981,7 @@ webpackJsonp([4],{
|
|
9981 |
|
9982 |
return this;
|
9983 |
},
|
9984 |
-
panel: function(opts) {
|
9985 |
// get options
|
9986 |
var options = opts || {};
|
9987 |
// reset subpanels
|
@@ -10002,8 +10002,8 @@ webpackJsonp([4],{
|
|
10002 |
|
10003 |
return this;
|
10004 |
},
|
10005 |
-
subpanel: function(options) {
|
10006 |
-
if(this.opened === false) {
|
10007 |
// if no panel is already opened, let's create one instead
|
10008 |
this.panel(options);
|
10009 |
} else {
|
@@ -10014,11 +10014,11 @@ webpackJsonp([4],{
|
|
10014 |
|
10015 |
return this;
|
10016 |
},
|
10017 |
-
loading: function(toggle) {
|
10018 |
// make sure the overlay is initialized and that it's visible
|
10019 |
this.initOverlay(true);
|
10020 |
|
10021 |
-
if(toggle === true) {
|
10022 |
this.showLoading();
|
10023 |
} else {
|
10024 |
this.hideLoading();
|
@@ -10026,7 +10026,7 @@ webpackJsonp([4],{
|
|
10026 |
|
10027 |
return this;
|
10028 |
},
|
10029 |
-
showLoading: function() {
|
10030 |
jQuery('#mailpoet_loading').show();
|
10031 |
|
10032 |
// add loading class to overlay
|
@@ -10035,7 +10035,7 @@ webpackJsonp([4],{
|
|
10035 |
|
10036 |
return this;
|
10037 |
},
|
10038 |
-
hideLoading: function() {
|
10039 |
jQuery('#mailpoet_loading').hide();
|
10040 |
|
10041 |
// remove loading class from overlay
|
@@ -10044,11 +10044,11 @@ webpackJsonp([4],{
|
|
10044 |
|
10045 |
return this;
|
10046 |
},
|
10047 |
-
open: function() {
|
10048 |
// load template if specified
|
10049 |
-
if(this.options.template !== null) {
|
10050 |
// check if a url was specified to get extra data
|
10051 |
-
if(this.options.url !== null) {
|
10052 |
this.loadUrl();
|
10053 |
} else {
|
10054 |
// load template
|
@@ -10063,13 +10063,13 @@ webpackJsonp([4],{
|
|
10063 |
|
10064 |
return this;
|
10065 |
},
|
10066 |
-
success: function() {
|
10067 |
-
if(this.subpanels.length > 0) {
|
10068 |
-
if(this.subpanels[(this.subpanels.length - 1)].onSuccess !== undefined) {
|
10069 |
this.subpanels[(this.subpanels.length - 1)].onSuccess(this.subpanels[(this.subpanels.length - 1)].data);
|
10070 |
}
|
10071 |
} else {
|
10072 |
-
if(this.options.onSuccess !== null) {
|
10073 |
this.options.onSuccess(this.options.data);
|
10074 |
}
|
10075 |
}
|
@@ -10077,13 +10077,13 @@ webpackJsonp([4],{
|
|
10077 |
|
10078 |
return this;
|
10079 |
},
|
10080 |
-
cancel: function() {
|
10081 |
-
if(this.subpanels.length > 0) {
|
10082 |
-
if(this.subpanels[(this.subpanels.length - 1)].onCancel !== undefined) {
|
10083 |
this.subpanels[(this.subpanels.length - 1)].onCancel(this.subpanels[(this.subpanels.length - 1)].data);
|
10084 |
}
|
10085 |
} else {
|
10086 |
-
if(this.options.onCancel !== null) {
|
10087 |
this.options.onCancel(this.options.data);
|
10088 |
}
|
10089 |
}
|
@@ -10091,33 +10091,33 @@ webpackJsonp([4],{
|
|
10091 |
|
10092 |
return this;
|
10093 |
},
|
10094 |
-
destroy: function() {
|
10095 |
this.hideOverlay();
|
10096 |
|
10097 |
// remove extra modal
|
10098 |
-
if(jQuery('#mailpoet_'+this.options.type).length > 0) {
|
10099 |
-
jQuery('#mailpoet_'+this.options.type).remove();
|
10100 |
}
|
10101 |
|
10102 |
this.initialized = false;
|
10103 |
|
10104 |
return this;
|
10105 |
},
|
10106 |
-
close: function() {
|
10107 |
-
if(this.isLocked() === true) { return this; }
|
10108 |
|
10109 |
-
if(this.subpanels.length > 0) {
|
10110 |
// close subpanel
|
10111 |
-
jQuery('.mailpoet_'+this.options.type+'_wrapper').last().remove();
|
10112 |
|
10113 |
// show previous panel
|
10114 |
-
jQuery('.mailpoet_'+this.options.type+'_wrapper').last().show();
|
10115 |
|
10116 |
// remove last subpanels
|
10117 |
this.subpanels.pop();
|
10118 |
|
10119 |
// focus on previous panel
|
10120 |
-
if(this.options.focus) {
|
10121 |
this.focus();
|
10122 |
}
|
10123 |
|
@@ -10134,7 +10134,7 @@ webpackJsonp([4],{
|
|
10134 |
this.destroy();
|
10135 |
|
10136 |
// restore the previously focused element
|
10137 |
-
if(this.prevFocus !== undefined){
|
10138 |
this.prevFocus.focus();
|
10139 |
}
|
10140 |
|
@@ -10156,10 +10156,10 @@ webpackJsonp([4],{
|
|
10156 |
/***/ 556:
|
10157 |
/***/ function(module, exports, __webpack_require__) {
|
10158 |
|
10159 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery) {
|
10160 |
'use strict';
|
10161 |
|
10162 |
-
|
10163 |
|
10164 |
MailPoet Notice:
|
10165 |
|
@@ -10180,7 +10180,7 @@ webpackJsonp([4],{
|
|
10180 |
// system message (static: true)
|
10181 |
MailPoet.Notice.system('You need to updated ASAP!');
|
10182 |
|
10183 |
-
|
10184 |
var MailPoet = mp;
|
10185 |
MailPoet.Notice = {
|
10186 |
version: 1.0,
|
@@ -10198,15 +10198,15 @@ webpackJsonp([4],{
|
|
10198 |
onClose: null
|
10199 |
},
|
10200 |
options: {},
|
10201 |
-
init: function(options) {
|
10202 |
// set options
|
10203 |
this.options = jQuery.extend({}, this.defaults, options);
|
10204 |
|
10205 |
return this;
|
10206 |
},
|
10207 |
-
createNotice: function() {
|
10208 |
// clone element
|
10209 |
-
this.element = jQuery('#mailpoet_notice_'+this.options.type).clone();
|
10210 |
|
10211 |
// add data-id to the element
|
10212 |
if (this.options.id) {
|
@@ -10226,7 +10226,7 @@ webpackJsonp([4],{
|
|
10226 |
} else if (typeof this.options.positionAfter === 'string') {
|
10227 |
positionAfter = jQuery(this.options.positionAfter);
|
10228 |
} else {
|
10229 |
-
positionAfter = jQuery('#mailpoet_notice_'+this.options.type);
|
10230 |
}
|
10231 |
positionAfter.after(this.element);
|
10232 |
|
@@ -10237,8 +10237,8 @@ webpackJsonp([4],{
|
|
10237 |
}
|
10238 |
|
10239 |
// listen to remove event
|
10240 |
-
jQuery(this.element).on('close', function() {
|
10241 |
-
jQuery(this).fadeOut(200, function() {
|
10242 |
// on close callback
|
10243 |
if (onClose !== null) {
|
10244 |
onClose();
|
@@ -10249,41 +10249,41 @@ webpackJsonp([4],{
|
|
10249 |
}.bind(this.element));
|
10250 |
|
10251 |
// listen to message event
|
10252 |
-
jQuery(this.element).on('setMessage', function(e, message) {
|
10253 |
MailPoet.Notice.setMessage(message);
|
10254 |
}.bind(this.element));
|
10255 |
|
10256 |
return this;
|
10257 |
},
|
10258 |
-
updateNotice: function() {
|
10259 |
// update notice's message
|
10260 |
-
jQuery('[data-id="'+this.options.id+'"').first().trigger(
|
10261 |
'setMessage', this.options.message
|
10262 |
);
|
10263 |
},
|
10264 |
-
setMessage: function(message) {
|
10265 |
var formattedMessage = this.formatMessage(message);
|
10266 |
|
10267 |
// let's sugar coat the message with a fancy <p>
|
10268 |
-
formattedMessage = '<p>'+formattedMessage+'</p>';
|
10269 |
// set message
|
10270 |
return this.element.html(formattedMessage);
|
10271 |
},
|
10272 |
-
formatMessage: function(message) {
|
10273 |
if (Array.isArray(message)) {
|
10274 |
return message.join('<br />');
|
10275 |
} else {
|
10276 |
return message;
|
10277 |
}
|
10278 |
},
|
10279 |
-
show: function(options) {
|
10280 |
// initialize
|
10281 |
this.init(options);
|
10282 |
|
10283 |
if (
|
10284 |
this.options.id !== null
|
10285 |
&&
|
10286 |
-
jQuery('[data-id="'+this.options.id+'"]').length > 0
|
10287 |
) {
|
10288 |
this.updateNotice();
|
10289 |
} else {
|
@@ -10291,7 +10291,7 @@ webpackJsonp([4],{
|
|
10291 |
}
|
10292 |
this.showNotice();
|
10293 |
},
|
10294 |
-
showNotice: function() {
|
10295 |
// set message
|
10296 |
this.setMessage(this.options.message);
|
10297 |
|
@@ -10324,7 +10324,7 @@ webpackJsonp([4],{
|
|
10324 |
this.element.delay(this.options.timeout).trigger('close');
|
10325 |
} else if (this.options.hideClose === false) {
|
10326 |
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
|
10327 |
-
this.element.find('.mailpoet_notice_close').on('click', function() {
|
10328 |
jQuery(this).trigger('close');
|
10329 |
});
|
10330 |
}
|
@@ -10334,7 +10334,7 @@ webpackJsonp([4],{
|
|
10334 |
this.options.onOpen(this.element);
|
10335 |
}
|
10336 |
},
|
10337 |
-
hide: function(all) {
|
10338 |
if (all !== undefined && all === true) {
|
10339 |
// all notices
|
10340 |
jQuery('.mailpoet_notice:not([id])').trigger('close');
|
@@ -10351,19 +10351,19 @@ webpackJsonp([4],{
|
|
10351 |
.trigger('close');
|
10352 |
}
|
10353 |
},
|
10354 |
-
error: function(message, options) {
|
10355 |
this.show(jQuery.extend({}, {
|
10356 |
type: 'error',
|
10357 |
message: message
|
10358 |
}, options));
|
10359 |
},
|
10360 |
-
success: function(message, options) {
|
10361 |
this.show(jQuery.extend({}, {
|
10362 |
type: 'success',
|
10363 |
message: message
|
10364 |
}, options));
|
10365 |
},
|
10366 |
-
system: function(message, options) {
|
10367 |
this.show(jQuery.extend({}, {
|
10368 |
type: 'system',
|
10369 |
static: true,
|
@@ -27575,9 +27575,9 @@ webpackJsonp([4],{
|
|
27575 |
* Courtesy of https://gist.github.com/jmeas/7992474cdb1c5672d88b
|
27576 |
*/
|
27577 |
|
27578 |
-
(function(root, factory) {
|
27579 |
if (true) {
|
27580 |
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(562), __webpack_require__(563), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, Radio, _) {
|
27581 |
return factory(Marionette, Radio, _);
|
27582 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
27583 |
}
|
@@ -27590,7 +27590,7 @@ webpackJsonp([4],{
|
|
27590 |
else {
|
27591 |
factory(root.Backbone.Marionette, root.Backbone.Radio, root._);
|
27592 |
}
|
27593 |
-
}(this, function(Marionette, Radio, _) {
|
27594 |
'use strict';
|
27595 |
|
27596 |
var MarionetteApplication = Marionette.Application;
|
@@ -27614,7 +27614,7 @@ webpackJsonp([4],{
|
|
27614 |
__webpack_require__(278),
|
27615 |
__webpack_require__(543),
|
27616 |
__webpack_require__(575)
|
27617 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Backbone, Marionette, BackboneRadio, jQuery, _, Handlebars) {
|
27618 |
var Radio = BackboneRadio;
|
27619 |
|
27620 |
var AppView = Marionette.View.extend({
|
@@ -27631,12 +27631,12 @@ webpackJsonp([4],{
|
|
27631 |
var EditorApplication = Marionette.Application.extend({
|
27632 |
region: '#mailpoet_editor',
|
27633 |
|
27634 |
-
onStart: function() {
|
27635 |
this._appView = new AppView();
|
27636 |
this.showView(this._appView);
|
27637 |
},
|
27638 |
|
27639 |
-
getChannel: function(channel) {
|
27640 |
if (channel === undefined) {
|
27641 |
return Radio.channel('global');
|
27642 |
}
|
@@ -27660,7 +27660,7 @@ webpackJsonp([4],{
|
|
27660 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
27661 |
__webpack_require__(574),
|
27662 |
__webpack_require__(564)
|
27663 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, SuperModel) {
|
27664 |
|
27665 |
var Module = {};
|
27666 |
|
@@ -27677,13 +27677,13 @@ webpackJsonp([4],{
|
|
27677 |
|
27678 |
// Global and available styles for access in blocks and their settings
|
27679 |
Module._config = {};
|
27680 |
-
Module.getConfig = function() { return Module._config; };
|
27681 |
-
Module.setConfig = function(options) {
|
27682 |
Module._config = new Module.ConfigModel(options, { parse: true });
|
27683 |
return Module._config;
|
27684 |
};
|
27685 |
|
27686 |
-
App.on('before:start', function(App, options) {
|
27687 |
var Application = App;
|
27688 |
// Expose config methods globally
|
27689 |
Application.getConfig = Module.getConfig;
|
@@ -27706,7 +27706,7 @@ webpackJsonp([4],{
|
|
27706 |
__webpack_require__(562),
|
27707 |
__webpack_require__(564),
|
27708 |
__webpack_require__(278)
|
27709 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, Marionette, SuperModel, _) {
|
27710 |
|
27711 |
'use strict';
|
27712 |
|
@@ -27745,34 +27745,34 @@ webpackJsonp([4],{
|
|
27745 |
backgroundColor: '#cccccc'
|
27746 |
}
|
27747 |
},
|
27748 |
-
initialize: function() {
|
27749 |
-
this.on('change', function() { App.getChannel().trigger('autoSave'); });
|
27750 |
}
|
27751 |
});
|
27752 |
|
27753 |
Module.StylesView = Marionette.View.extend({
|
27754 |
-
getTemplate: function() { return window.templates.styles; },
|
27755 |
modelEvents: {
|
27756 |
change: 'render'
|
27757 |
},
|
27758 |
-
serializeData: function() {
|
27759 |
return this.model.toJSON();
|
27760 |
}
|
27761 |
});
|
27762 |
|
27763 |
Module._globalStyles = new SuperModel();
|
27764 |
-
Module.getGlobalStyles = function() {
|
27765 |
return Module._globalStyles;
|
27766 |
};
|
27767 |
-
Module.setGlobalStyles = function(options) {
|
27768 |
Module._globalStyles = new Module.StylesModel(options);
|
27769 |
return Module._globalStyles;
|
27770 |
};
|
27771 |
-
Module.getAvailableStyles = function() {
|
27772 |
return App.getConfig().get('availableStyles');
|
27773 |
};
|
27774 |
|
27775 |
-
App.on('before:start', function(App, options) {
|
27776 |
var Application = App;
|
27777 |
// Expose style methods to global application
|
27778 |
Application.getGlobalStyles = Module.getGlobalStyles;
|
@@ -27784,7 +27784,7 @@ webpackJsonp([4],{
|
|
27784 |
this.setGlobalStyles(globalStyles);
|
27785 |
});
|
27786 |
|
27787 |
-
App.on('start', function(App, options) {
|
27788 |
var stylesView = new Module.StylesView({ model: App.getGlobalStyles() });
|
27789 |
App._appView.showChildView('stylesRegion', stylesView);
|
27790 |
});
|
@@ -27808,7 +27808,7 @@ webpackJsonp([4],{
|
|
27808 |
__webpack_require__(278),
|
27809 |
__webpack_require__(273),
|
27810 |
__webpack_require__(567)
|
27811 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
27812 |
App,
|
27813 |
CommunicationComponent,
|
27814 |
MailPoet,
|
@@ -27835,8 +27835,8 @@ webpackJsonp([4],{
|
|
27835 |
}),
|
27836 |
comparator: 'priority'
|
27837 |
}))();
|
27838 |
-
Module.registerWidget = function(widget) { return Module._contentWidgets.add(widget); };
|
27839 |
-
Module.getWidgets = function() { return Module._contentWidgets; };
|
27840 |
|
27841 |
// Layout widget handlers for use to create new layout blocks via drag&drop
|
27842 |
Module._layoutWidgets = new (Backbone.Collection.extend({
|
@@ -27849,11 +27849,11 @@ webpackJsonp([4],{
|
|
27849 |
}),
|
27850 |
comparator: 'priority'
|
27851 |
}))();
|
27852 |
-
Module.registerLayoutWidget = function(widget) { return Module._layoutWidgets.add(widget); };
|
27853 |
-
Module.getLayoutWidgets = function() { return Module._layoutWidgets; };
|
27854 |
|
27855 |
var SidebarView = Marionette.View.extend({
|
27856 |
-
getTemplate: function() { return window.templates.sidebar; },
|
27857 |
regions: {
|
27858 |
contentRegion: '.mailpoet_content_region',
|
27859 |
layoutRegion: '.mailpoet_layout_region',
|
@@ -27861,7 +27861,7 @@ webpackJsonp([4],{
|
|
27861 |
previewRegion: '.mailpoet_preview_region'
|
27862 |
},
|
27863 |
events: {
|
27864 |
-
'click .mailpoet_sidebar_region h3, .mailpoet_sidebar_region .handlediv': function(event) {
|
27865 |
var $openRegion = this.$el.find('.mailpoet_sidebar_region:not(.closed)'),
|
27866 |
$targetRegion = this.$el.find(event.target).closest('.mailpoet_sidebar_region');
|
27867 |
|
@@ -27870,7 +27870,7 @@ webpackJsonp([4],{
|
|
27870 |
{
|
27871 |
duration: 250,
|
27872 |
easing: 'easeOut',
|
27873 |
-
complete: function() {
|
27874 |
$openRegion.addClass('closed');
|
27875 |
}.bind(this)
|
27876 |
}
|
@@ -27882,7 +27882,7 @@ webpackJsonp([4],{
|
|
27882 |
{
|
27883 |
duration: 250,
|
27884 |
easing: 'easeIn',
|
27885 |
-
complete: function() {
|
27886 |
$targetRegion.removeClass('closed');
|
27887 |
}
|
27888 |
}
|
@@ -27890,12 +27890,12 @@ webpackJsonp([4],{
|
|
27890 |
}
|
27891 |
}
|
27892 |
},
|
27893 |
-
initialize: function(options) {
|
27894 |
jQuery(window)
|
27895 |
.on('resize', this.updateHorizontalScroll.bind(this))
|
27896 |
.on('scroll', this.updateHorizontalScroll.bind(this));
|
27897 |
},
|
27898 |
-
onRender: function() {
|
27899 |
this.showChildView('contentRegion', new Module.SidebarWidgetsView(
|
27900 |
App.getWidgets()
|
27901 |
));
|
@@ -27908,7 +27908,7 @@ webpackJsonp([4],{
|
|
27908 |
}));
|
27909 |
this.showChildView('previewRegion', new Module.SidebarPreviewView());
|
27910 |
},
|
27911 |
-
updateHorizontalScroll: function() {
|
27912 |
// Fixes the sidebar so that on narrower screens the horizontal
|
27913 |
// position of the sidebar would be scrollable and not fixed
|
27914 |
// partially out of visible screen
|
@@ -27925,7 +27925,7 @@ webpackJsonp([4],{
|
|
27925 |
}
|
27926 |
});
|
27927 |
},
|
27928 |
-
onDomRefresh: function() {
|
27929 |
this.$el.parent().stick_in_parent({
|
27930 |
offset_top: 32
|
27931 |
});
|
@@ -27940,23 +27940,23 @@ webpackJsonp([4],{
|
|
27940 |
* Draggable widget collection view
|
27941 |
*/
|
27942 |
Module.SidebarWidgetsCollectionView = Marionette.CollectionView.extend({
|
27943 |
-
childView: function(item) { return item.get('widgetView'); }
|
27944 |
});
|
27945 |
|
27946 |
/**
|
27947 |
* Responsible for rendering draggable content widgets
|
27948 |
*/
|
27949 |
Module.SidebarWidgetsView = Marionette.View.extend({
|
27950 |
-
getTemplate: function() { return window.templates.sidebarContent; },
|
27951 |
regions: {
|
27952 |
widgets: '.mailpoet_region_content'
|
27953 |
},
|
27954 |
|
27955 |
-
initialize: function(widgets) {
|
27956 |
this.widgets = widgets;
|
27957 |
},
|
27958 |
|
27959 |
-
onRender: function() {
|
27960 |
this.showChildView('widgets', new Module.SidebarWidgetsCollectionView({
|
27961 |
collection: this.widgets
|
27962 |
}));
|
@@ -27967,68 +27967,68 @@ webpackJsonp([4],{
|
|
27967 |
* Responsible for rendering draggable layout widgets
|
27968 |
*/
|
27969 |
Module.SidebarLayoutWidgetsView = Module.SidebarWidgetsView.extend({
|
27970 |
-
getTemplate: function() { return window.templates.sidebarLayout; }
|
27971 |
});
|
27972 |
|
27973 |
/**
|
27974 |
* Responsible for managing global styles
|
27975 |
*/
|
27976 |
Module.SidebarStylesView = Marionette.View.extend({
|
27977 |
-
getTemplate: function() { return window.templates.sidebarStyles; },
|
27978 |
behaviors: {
|
27979 |
ColorPickerBehavior: {}
|
27980 |
},
|
27981 |
-
events: function() {
|
27982 |
return {
|
27983 |
'change #mailpoet_text_font_color': _.partial(this.changeColorField, 'text.fontColor'),
|
27984 |
-
'change #mailpoet_text_font_family': function(event) {
|
27985 |
this.model.set('text.fontFamily', event.target.value);
|
27986 |
},
|
27987 |
-
'change #mailpoet_text_font_size': function(event) {
|
27988 |
this.model.set('text.fontSize', event.target.value);
|
27989 |
},
|
27990 |
'change #mailpoet_h1_font_color': _.partial(this.changeColorField, 'h1.fontColor'),
|
27991 |
-
'change #mailpoet_h1_font_family': function(event) {
|
27992 |
this.model.set('h1.fontFamily', event.target.value);
|
27993 |
},
|
27994 |
-
'change #mailpoet_h1_font_size': function(event) {
|
27995 |
this.model.set('h1.fontSize', event.target.value);
|
27996 |
},
|
27997 |
'change #mailpoet_h2_font_color': _.partial(this.changeColorField, 'h2.fontColor'),
|
27998 |
-
'change #mailpoet_h2_font_family': function(event) {
|
27999 |
this.model.set('h2.fontFamily', event.target.value);
|
28000 |
},
|
28001 |
-
'change #mailpoet_h2_font_size': function(event) {
|
28002 |
this.model.set('h2.fontSize', event.target.value);
|
28003 |
},
|
28004 |
'change #mailpoet_h3_font_color': _.partial(this.changeColorField, 'h3.fontColor'),
|
28005 |
-
'change #mailpoet_h3_font_family': function(event) {
|
28006 |
this.model.set('h3.fontFamily', event.target.value);
|
28007 |
},
|
28008 |
-
'change #mailpoet_h3_font_size': function(event) {
|
28009 |
this.model.set('h3.fontSize', event.target.value);
|
28010 |
},
|
28011 |
'change #mailpoet_a_font_color': _.partial(this.changeColorField, 'link.fontColor'),
|
28012 |
-
'change #mailpoet_a_font_underline': function(event) {
|
28013 |
this.model.set('link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
28014 |
},
|
28015 |
'change #mailpoet_newsletter_background_color': _.partial(this.changeColorField, 'wrapper.backgroundColor'),
|
28016 |
'change #mailpoet_background_color': _.partial(this.changeColorField, 'body.backgroundColor')
|
28017 |
};
|
28018 |
},
|
28019 |
-
templateContext: function() {
|
28020 |
return {
|
28021 |
model: this.model.toJSON(),
|
28022 |
availableStyles: this.availableStyles.toJSON()
|
28023 |
};
|
28024 |
},
|
28025 |
-
initialize: function(options) {
|
28026 |
this.availableStyles = options.availableStyles;
|
28027 |
},
|
28028 |
-
changeField: function(field, event) {
|
28029 |
this.model.set(field, jQuery(event.target).val());
|
28030 |
},
|
28031 |
-
changeColorField: function(field, event) {
|
28032 |
var value = jQuery(event.target).val();
|
28033 |
if (value === '') {
|
28034 |
value = 'transparent';
|
@@ -28038,18 +28038,18 @@ webpackJsonp([4],{
|
|
28038 |
});
|
28039 |
|
28040 |
Module.SidebarPreviewView = Marionette.View.extend({
|
28041 |
-
getTemplate: function() { return window.templates.sidebarPreview; },
|
28042 |
events: {
|
28043 |
'click .mailpoet_show_preview': 'showPreview',
|
28044 |
'click #mailpoet_send_preview': 'sendPreview'
|
28045 |
},
|
28046 |
-
onBeforeDestroy: function() {
|
28047 |
if (this.previewView) {
|
28048 |
this.previewView.destroy();
|
28049 |
this.previewView = null;
|
28050 |
}
|
28051 |
},
|
28052 |
-
showPreview: function() {
|
28053 |
var json = App.toJSON();
|
28054 |
|
28055 |
// Stringify to enable transmission of primitive non-string value types
|
@@ -28064,23 +28064,23 @@ webpackJsonp([4],{
|
|
28064 |
endpoint: 'newsletters',
|
28065 |
action: 'showPreview',
|
28066 |
data: json
|
28067 |
-
}).always(function() {
|
28068 |
MailPoet.Modal.loading(false);
|
28069 |
-
}).done(function(response) {
|
28070 |
this.previewView = new Module.NewsletterPreviewView({
|
28071 |
previewUrl: response.meta.preview_url
|
28072 |
});
|
28073 |
|
28074 |
var view = this.previewView.render();
|
28075 |
this.previewView.$el.css('height', '100%');
|
28076 |
-
|
28077 |
MailPoet.Modal.popup({
|
28078 |
template: '',
|
28079 |
element: this.previewView.$el,
|
28080 |
width: '95%',
|
28081 |
height: '94%',
|
28082 |
title: MailPoet.I18n.t('newsletterPreview'),
|
28083 |
-
onCancel: function() {
|
28084 |
this.previewView.destroy();
|
28085 |
this.previewView = null;
|
28086 |
}.bind(this)
|
@@ -28089,16 +28089,16 @@ webpackJsonp([4],{
|
|
28089 |
MailPoet.trackEvent('Editor > Browser Preview', {
|
28090 |
'MailPoet Free version': window.mailpoet_version
|
28091 |
});
|
28092 |
-
}.bind(this)).fail(function(response) {
|
28093 |
if (response.errors.length > 0) {
|
28094 |
MailPoet.Notice.error(
|
28095 |
-
response.errors.map(function(error) { return error.message; }),
|
28096 |
{ scroll: true }
|
28097 |
);
|
28098 |
}
|
28099 |
});
|
28100 |
},
|
28101 |
-
sendPreview: function() {
|
28102 |
// get form data
|
28103 |
var $emailField = this.$('#mailpoet_preview_to_email');
|
28104 |
var data = {
|
@@ -28121,10 +28121,10 @@ webpackJsonp([4],{
|
|
28121 |
MailPoet.Modal.loading(true);
|
28122 |
|
28123 |
// save before sending
|
28124 |
-
App.getChannel().request('save').always(function() {
|
28125 |
-
CommunicationComponent.previewNewsletter(data).always(function() {
|
28126 |
MailPoet.Modal.loading(false);
|
28127 |
-
}).done(function(response) {
|
28128 |
MailPoet.Notice.success(
|
28129 |
MailPoet.I18n.t('newsletterPreviewSent'),
|
28130 |
{ scroll: true }
|
@@ -28133,10 +28133,10 @@ webpackJsonp([4],{
|
|
28133 |
'MailPoet Free version': window.mailpoet_version,
|
28134 |
'Domain name': data.subscriber.substring(data.subscriber.indexOf('@') + 1)
|
28135 |
});
|
28136 |
-
}).fail(function(response) {
|
28137 |
if (response.errors.length > 0) {
|
28138 |
MailPoet.Notice.error(
|
28139 |
-
response.errors.map(function(error) { return error.message; }),
|
28140 |
{ scroll: true, static: true }
|
28141 |
);
|
28142 |
}
|
@@ -28146,15 +28146,15 @@ webpackJsonp([4],{
|
|
28146 |
});
|
28147 |
|
28148 |
Module.NewsletterPreviewView = Marionette.View.extend({
|
28149 |
-
getTemplate: function() { return window.templates.newsletterPreview; },
|
28150 |
-
initialize: function(options) {
|
28151 |
this.previewUrl = options.previewUrl;
|
28152 |
this.width = '100%';
|
28153 |
this.height = '100%';
|
28154 |
// this.width = App.getConfig().get('newsletterPreview.width');
|
28155 |
// this.height = App.getConfig().get('newsletterPreview.height')
|
28156 |
},
|
28157 |
-
templateContext: function() {
|
28158 |
return {
|
28159 |
previewUrl: this.previewUrl,
|
28160 |
width: this.width,
|
@@ -28163,7 +28163,7 @@ webpackJsonp([4],{
|
|
28163 |
}
|
28164 |
});
|
28165 |
|
28166 |
-
App.on('before:start', function(App, options) {
|
28167 |
var Application = App;
|
28168 |
Application.registerWidget = Module.registerWidget;
|
28169 |
Application.getWidgets = Module.getWidgets;
|
@@ -28171,7 +28171,7 @@ webpackJsonp([4],{
|
|
28171 |
Application.getLayoutWidgets = Module.getLayoutWidgets;
|
28172 |
});
|
28173 |
|
28174 |
-
App.on('start', function(App, options) {
|
28175 |
var stylesModel = App.getGlobalStyles(),
|
28176 |
sidebarView = new SidebarView();
|
28177 |
|
@@ -28209,7 +28209,7 @@ webpackJsonp([4],{
|
|
28209 |
__webpack_require__(564),
|
28210 |
__webpack_require__(278),
|
28211 |
__webpack_require__(274)
|
28212 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, SuperModel, _, MailPoet) {
|
28213 |
'use strict';
|
28214 |
|
28215 |
var Module = {};
|
@@ -28219,12 +28219,12 @@ webpackJsonp([4],{
|
|
28219 |
// handled by other components.
|
28220 |
Module.NewsletterModel = SuperModel.extend({
|
28221 |
whitelisted: ['id', 'subject', 'preheader'],
|
28222 |
-
initialize: function(options) {
|
28223 |
-
this.on('change', function() {
|
28224 |
App.getChannel().trigger('autoSave');
|
28225 |
});
|
28226 |
},
|
28227 |
-
toJSON: function() {
|
28228 |
// Use only whitelisted properties to ensure properties editor
|
28229 |
// doesn't control don't change.
|
28230 |
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
|
@@ -28233,17 +28233,17 @@ webpackJsonp([4],{
|
|
28233 |
|
28234 |
// Content block view and model handlers for different content types
|
28235 |
Module._blockTypes = {};
|
28236 |
-
Module.registerBlockType = function(type, data) {
|
28237 |
Module._blockTypes[type] = data;
|
28238 |
};
|
28239 |
-
Module.getBlockTypeModel = function(type) {
|
28240 |
if (type in Module._blockTypes) {
|
28241 |
return Module._blockTypes[type].blockModel;
|
28242 |
} else {
|
28243 |
throw 'Block type not supported: ' + type;
|
28244 |
}
|
28245 |
};
|
28246 |
-
Module.getBlockTypeView = function(type) {
|
28247 |
if (type in Module._blockTypes) {
|
28248 |
return Module._blockTypes[type].blockView;
|
28249 |
} else {
|
@@ -28251,29 +28251,29 @@ webpackJsonp([4],{
|
|
28251 |
}
|
28252 |
};
|
28253 |
|
28254 |
-
Module.getBody = function() {
|
28255 |
return {
|
28256 |
content: App._contentContainer.toJSON(),
|
28257 |
globalStyles: App.getGlobalStyles().toJSON()
|
28258 |
};
|
28259 |
};
|
28260 |
|
28261 |
-
Module.toJSON = function() {
|
28262 |
return _.extend({
|
28263 |
body: Module.getBody()
|
28264 |
}, App.getNewsletter().toJSON());
|
28265 |
};
|
28266 |
|
28267 |
-
Module.getNewsletter = function() {
|
28268 |
return Module.newsletter;
|
28269 |
};
|
28270 |
|
28271 |
-
Module.findModels = function(predicate) {
|
28272 |
var blocks = App._contentContainer.getChildren();
|
28273 |
return _.filter(blocks, predicate);
|
28274 |
};
|
28275 |
|
28276 |
-
App.on('before:start', function(Application, options) {
|
28277 |
var App = Application;
|
28278 |
// Expose block methods globally
|
28279 |
App.registerBlockType = Module.registerBlockType;
|
@@ -28287,7 +28287,7 @@ webpackJsonp([4],{
|
|
28287 |
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
|
28288 |
});
|
28289 |
|
28290 |
-
App.on('start', function(Application, options) {
|
28291 |
var App = Application;
|
28292 |
var body = options.newsletter.body;
|
28293 |
var content = (_.has(body, 'content')) ? body.content : {};
|
@@ -28299,7 +28299,7 @@ webpackJsonp([4],{
|
|
28299 |
);
|
28300 |
}
|
28301 |
|
28302 |
-
App._contentContainer = new (App.getBlockTypeModel('container'))(content, {parse: true});
|
28303 |
App._contentContainerView = new (App.getBlockTypeView('container'))({
|
28304 |
model: App._contentContainer,
|
28305 |
renderOptions: { depth: 0 }
|
@@ -28325,31 +28325,31 @@ webpackJsonp([4],{
|
|
28325 |
__webpack_require__(278),
|
28326 |
__webpack_require__(273),
|
28327 |
__webpack_require__(274)
|
28328 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, Backbone, Marionette, _, jQuery, MailPoet) {
|
28329 |
|
28330 |
'use strict';
|
28331 |
|
28332 |
var Module = {};
|
28333 |
|
28334 |
Module.HeadingView = Marionette.View.extend({
|
28335 |
-
getTemplate: function() { return window.templates.heading; },
|
28336 |
-
templateContext: function() {
|
28337 |
return {
|
28338 |
model: this.model.toJSON()
|
28339 |
};
|
28340 |
},
|
28341 |
-
events: function() {
|
28342 |
return {
|
28343 |
'keyup .mailpoet_input_title': _.partial(this.changeField, 'subject'),
|
28344 |
'keyup .mailpoet_input_preheader': _.partial(this.changeField, 'preheader')
|
28345 |
};
|
28346 |
},
|
28347 |
-
changeField: function(field, event) {
|
28348 |
this.model.set(field, jQuery(event.target).val());
|
28349 |
}
|
28350 |
});
|
28351 |
|
28352 |
-
App.on('start', function(App, options) {
|
28353 |
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
|
28354 |
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
|
28355 |
tooltipId: 'tooltip-designer-subject-line-ti',
|
@@ -28384,7 +28384,7 @@ webpackJsonp([4],{
|
|
28384 |
__webpack_require__(583),
|
28385 |
__webpack_require__(278),
|
28386 |
__webpack_require__(273)
|
28387 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
28388 |
App,
|
28389 |
CommunicationComponent,
|
28390 |
MailPoet,
|
@@ -28405,7 +28405,7 @@ webpackJsonp([4],{
|
|
28405 |
saveTimeout;
|
28406 |
|
28407 |
// Save editor contents to server
|
28408 |
-
Module.save = function() {
|
28409 |
|
28410 |
var json = App.toJSON();
|
28411 |
|
@@ -28417,12 +28417,12 @@ webpackJsonp([4],{
|
|
28417 |
App.getChannel().trigger('beforeEditorSave', json);
|
28418 |
|
28419 |
// save newsletter
|
28420 |
-
return CommunicationComponent.saveNewsletter(json).done(function(response) {
|
28421 |
-
if(response.success !== undefined && response.success === true) {
|
28422 |
// TODO: Handle translations
|
28423 |
-
//MailPoet.Notice.success("<?php _e('Newsletter has been saved.'); ?>");
|
28424 |
-
} else if(response.error !== undefined) {
|
28425 |
-
if(response.error.length === 0) {
|
28426 |
MailPoet.Notice.error(
|
28427 |
MailPoet.I18n.t('templateSaveFailed'),
|
28428 |
{
|
@@ -28430,22 +28430,22 @@ webpackJsonp([4],{
|
|
28430 |
}
|
28431 |
);
|
28432 |
} else {
|
28433 |
-
$(response.error).each(function(i, error) {
|
28434 |
MailPoet.Notice.error(error, { scroll: true });
|
28435 |
});
|
28436 |
}
|
28437 |
}
|
28438 |
App.getChannel().trigger('afterEditorSave', json, response);
|
28439 |
-
}).fail(function(response) {
|
28440 |
// TODO: Handle saving errors
|
28441 |
App.getChannel().trigger('afterEditorSave', {}, response);
|
28442 |
});
|
28443 |
};
|
28444 |
|
28445 |
-
Module.getThumbnail = function(element, options) {
|
28446 |
var promise = html2canvas(element, options || {});
|
28447 |
|
28448 |
-
return promise.then(function(oldCanvas) {
|
28449 |
// Temporary workaround for html2canvas-alpha2.
|
28450 |
// Removes 1px left transparent border from resulting canvas.
|
28451 |
|
@@ -28467,11 +28467,11 @@ webpackJsonp([4],{
|
|
28467 |
});
|
28468 |
};
|
28469 |
|
28470 |
-
Module.saveTemplate = function(options) {
|
28471 |
var that = this,
|
28472 |
promise = jQuery.Deferred();
|
28473 |
|
28474 |
-
promise.then(function(thumbnail) {
|
28475 |
var data = _.extend(options || {}, {
|
28476 |
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
28477 |
body: JSON.stringify(App.getBody())
|
@@ -28487,18 +28487,18 @@ webpackJsonp([4],{
|
|
28487 |
|
28488 |
Module.getThumbnail(
|
28489 |
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
28490 |
-
).then(function(thumbnail) {
|
28491 |
promise.resolve(thumbnail);
|
28492 |
});
|
28493 |
|
28494 |
return promise;
|
28495 |
};
|
28496 |
|
28497 |
-
Module.exportTemplate = function(options) {
|
28498 |
var that = this;
|
28499 |
return Module.getThumbnail(
|
28500 |
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
28501 |
-
).then(function(thumbnail) {
|
28502 |
var data = _.extend(options || {}, {
|
28503 |
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
28504 |
body: App.getBody()
|
@@ -28516,7 +28516,7 @@ webpackJsonp([4],{
|
|
28516 |
};
|
28517 |
|
28518 |
Module.SaveView = Marionette.View.extend({
|
28519 |
-
getTemplate: function() { return window.templates.save; },
|
28520 |
events: {
|
28521 |
'click .mailpoet_save_button': 'save',
|
28522 |
'click .mailpoet_save_show_options': 'toggleSaveOptions',
|
@@ -28528,43 +28528,43 @@ webpackJsonp([4],{
|
|
28528 |
'click .mailpoet_save_export': 'toggleExportTemplate',
|
28529 |
'click .mailpoet_export_template': 'exportTemplate'
|
28530 |
},
|
28531 |
-
initialize: function(options) {
|
28532 |
App.getChannel().on('beforeEditorSave', this.beforeSave, this);
|
28533 |
App.getChannel().on('afterEditorSave', this.afterSave, this);
|
28534 |
},
|
28535 |
-
onRender: function() {
|
28536 |
this.validateNewsletter(App.toJSON());
|
28537 |
},
|
28538 |
-
save: function() {
|
28539 |
this.hideOptionContents();
|
28540 |
App.getChannel().request('save');
|
28541 |
},
|
28542 |
-
beforeSave: function() {
|
28543 |
// TODO: Add a loading animation instead
|
28544 |
this.$('.mailpoet_autosaved_at').text(MailPoet.I18n.t('saving'));
|
28545 |
},
|
28546 |
-
afterSave: function(json, response) {
|
28547 |
this.validateNewsletter(json);
|
28548 |
// Update 'Last saved timer'
|
28549 |
this.$('.mailpoet_editor_last_saved').removeClass('mailpoet_hidden');
|
28550 |
this.$('.mailpoet_autosaved_at').text('');
|
28551 |
},
|
28552 |
-
toggleSaveOptions: function() {
|
28553 |
this.$('.mailpoet_save_options').toggleClass('mailpoet_hidden');
|
28554 |
this.$('.mailpoet_save_show_options').toggleClass('mailpoet_save_show_options_active');
|
28555 |
},
|
28556 |
-
toggleSaveAsTemplate: function() {
|
28557 |
this.$('.mailpoet_save_as_template_container').toggleClass('mailpoet_hidden');
|
28558 |
this.toggleSaveOptions();
|
28559 |
},
|
28560 |
-
showSaveAsTemplate: function() {
|
28561 |
this.$('.mailpoet_save_as_template_container').removeClass('mailpoet_hidden');
|
28562 |
this.toggleSaveOptions();
|
28563 |
},
|
28564 |
-
hideSaveAsTemplate: function() {
|
28565 |
this.$('.mailpoet_save_as_template_container').addClass('mailpoet_hidden');
|
28566 |
},
|
28567 |
-
saveAsTemplate: function() {
|
28568 |
var templateName = this.$('.mailpoet_save_as_template_name').val(),
|
28569 |
templateDescription = this.$('.mailpoet_save_as_template_description').val(),
|
28570 |
that = this;
|
@@ -28589,7 +28589,7 @@ webpackJsonp([4],{
|
|
28589 |
Module.saveTemplate({
|
28590 |
name: templateName,
|
28591 |
description: templateDescription
|
28592 |
-
}).done(function() {
|
28593 |
MailPoet.Notice.success(
|
28594 |
MailPoet.I18n.t('templateSaved'),
|
28595 |
{
|
@@ -28600,7 +28600,7 @@ webpackJsonp([4],{
|
|
28600 |
MailPoet.trackEvent('Editor > Template saved', {
|
28601 |
'MailPoet Free version': window.mailpoet_version
|
28602 |
});
|
28603 |
-
}).fail(function() {
|
28604 |
MailPoet.Notice.error(
|
28605 |
MailPoet.I18n.t('templateSaveFailed'),
|
28606 |
{
|
@@ -28613,14 +28613,14 @@ webpackJsonp([4],{
|
|
28613 |
}
|
28614 |
|
28615 |
},
|
28616 |
-
toggleExportTemplate: function() {
|
28617 |
this.$('.mailpoet_export_template_container').toggleClass('mailpoet_hidden');
|
28618 |
this.toggleSaveOptions();
|
28619 |
},
|
28620 |
-
hideExportTemplate: function() {
|
28621 |
this.$('.mailpoet_export_template_container').addClass('mailpoet_hidden');
|
28622 |
},
|
28623 |
-
exportTemplate: function() {
|
28624 |
var templateName = this.$('.mailpoet_export_template_name').val(),
|
28625 |
templateDescription = this.$('.mailpoet_export_template_description').val(),
|
28626 |
that = this;
|
@@ -28649,21 +28649,21 @@ webpackJsonp([4],{
|
|
28649 |
this.hideExportTemplate();
|
28650 |
}
|
28651 |
},
|
28652 |
-
hideOptionContents: function() {
|
28653 |
this.hideSaveAsTemplate();
|
28654 |
this.hideExportTemplate();
|
28655 |
this.$('.mailpoet_save_options').addClass('mailpoet_hidden');
|
28656 |
},
|
28657 |
-
next: function() {
|
28658 |
this.hideOptionContents();
|
28659 |
-
if(!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
|
28660 |
Module._cancelAutosave();
|
28661 |
-
Module.save().done(function(response) {
|
28662 |
window.location.href = App.getConfig().get('urls.send');
|
28663 |
});
|
28664 |
}
|
28665 |
},
|
28666 |
-
validateNewsletter: function(jsonObject) {
|
28667 |
if (!App._contentContainer.isValid()) {
|
28668 |
this.showValidationError(App._contentContainer.validationError);
|
28669 |
return;
|
@@ -28679,40 +28679,40 @@ webpackJsonp([4],{
|
|
28679 |
|
28680 |
this.hideValidationError();
|
28681 |
},
|
28682 |
-
showValidationError: function(message) {
|
28683 |
var $el = this.$('.mailpoet_save_error');
|
28684 |
$el.text(message);
|
28685 |
$el.removeClass('mailpoet_hidden');
|
28686 |
|
28687 |
this.$('.mailpoet_save_next').addClass('button-disabled');
|
28688 |
},
|
28689 |
-
hideValidationError: function() {
|
28690 |
this.$('.mailpoet_save_error').addClass('mailpoet_hidden');
|
28691 |
this.$('.mailpoet_save_next').removeClass('button-disabled');
|
28692 |
}
|
28693 |
});
|
28694 |
|
28695 |
-
Module.autoSave = function() {
|
28696 |
// Delay in saving editor contents, during which a new autosave
|
28697 |
// may be requested
|
28698 |
var AUTOSAVE_DELAY_DURATION = 1000;
|
28699 |
|
28700 |
Module._cancelAutosave();
|
28701 |
-
saveTimeout = setTimeout(function() {
|
28702 |
-
App.getChannel().request('save').always(function() {
|
28703 |
Module._cancelAutosave();
|
28704 |
});
|
28705 |
}, AUTOSAVE_DELAY_DURATION);
|
28706 |
};
|
28707 |
|
28708 |
-
Module._cancelAutosave = function() {
|
28709 |
if (!saveTimeout) return;
|
28710 |
|
28711 |
clearTimeout(saveTimeout);
|
28712 |
saveTimeout = undefined;
|
28713 |
};
|
28714 |
|
28715 |
-
Module.beforeExitWithUnsavedChanges = function(e) {
|
28716 |
if (saveTimeout) {
|
28717 |
var message = MailPoet.I18n.t('unsavedChangesWillBeLost');
|
28718 |
var event = e || window.event;
|
@@ -28725,7 +28725,7 @@ webpackJsonp([4],{
|
|
28725 |
}
|
28726 |
};
|
28727 |
|
28728 |
-
App.on('before:start', function(App, options) {
|
28729 |
var Application = App;
|
28730 |
Application.save = Module.save;
|
28731 |
Application.getChannel().on('autoSave', Module.autoSave);
|
@@ -28735,7 +28735,7 @@ webpackJsonp([4],{
|
|
28735 |
Application.getChannel().reply('save', Application.save);
|
28736 |
});
|
28737 |
|
28738 |
-
App.on('start', function(App, options) {
|
28739 |
var saveView = new Module.SaveView();
|
28740 |
App._appView.showChildView('bottomRegion', saveView);
|
28741 |
});
|
@@ -33306,10 +33306,10 @@ webpackJsonp([4],{
|
|
33306 |
*/
|
33307 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
33308 |
__webpack_require__(562)
|
33309 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(BackboneMarionette) {
|
33310 |
var Marionette = BackboneMarionette;
|
33311 |
var BehaviorsLookup = {};
|
33312 |
-
Marionette.Behaviors.behaviorsLookup = function() {
|
33313 |
return BehaviorsLookup;
|
33314 |
};
|
33315 |
|
@@ -33334,17 +33334,17 @@ webpackJsonp([4],{
|
|
33334 |
__webpack_require__(585),
|
33335 |
__webpack_require__(274),
|
33336 |
__webpack_require__(566)
|
33337 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, BehaviorsLookup, MailPoet, Spectrum) {
|
33338 |
var BL = BehaviorsLookup;
|
33339 |
|
33340 |
BL.ColorPickerBehavior = Marionette.Behavior.extend({
|
33341 |
-
onRender: function() {
|
33342 |
-
var that = this,
|
33343 |
preferredFormat = 'hex6';
|
33344 |
this.view.$('.mailpoet_color').each(function () {
|
33345 |
var $input = that.view.$(this);
|
33346 |
-
var updateColorInput = function(color) {
|
33347 |
-
if(color && color.getAlpha() > 0) {
|
33348 |
$input.val(color.toString(preferredFormat));
|
33349 |
} else {
|
33350 |
$input.val('');
|
@@ -33367,7 +33367,7 @@ webpackJsonp([4],{
|
|
33367 |
move: updateColorInput,
|
33368 |
hide: updateColorInput
|
33369 |
});
|
33370 |
-
});
|
33371 |
}
|
33372 |
});
|
33373 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -33392,20 +33392,20 @@ webpackJsonp([4],{
|
|
33392 |
__webpack_require__(273),
|
33393 |
__webpack_require__(585),
|
33394 |
__webpack_require__(565)
|
33395 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, _, jQuery, BL, interact) {
|
33396 |
var BehaviorsLookup = BL;
|
33397 |
|
33398 |
BehaviorsLookup.ContainerDropZoneBehavior = Marionette.Behavior.extend({
|
33399 |
defaults: {
|
33400 |
columnLimit: 3
|
33401 |
},
|
33402 |
-
onRender: function() {
|
33403 |
var dragAndDropDisabled = _.isObject(this.view.options.renderOptions) && this.view.options.renderOptions.disableDragAndDrop === true;
|
33404 |
if (!dragAndDropDisabled) {
|
33405 |
this.addDropZone();
|
33406 |
}
|
33407 |
},
|
33408 |
-
addDropZone: function(_event) {
|
33409 |
var that = this,
|
33410 |
view = this.view,
|
33411 |
domElement = that.$el.get(0),
|
@@ -33427,16 +33427,16 @@ webpackJsonp([4],{
|
|
33427 |
interact(domElement).dropzone({
|
33428 |
accept: acceptableElementSelector,
|
33429 |
overlap: 'pointer', // Mouse pointer denotes location of a droppable
|
33430 |
-
ondragenter: function(event) {
|
33431 |
// 1. Visually mark block as active for dropping
|
33432 |
view.$el.addClass('mailpoet_drop_active');
|
33433 |
},
|
33434 |
-
ondragleave: function(event) {
|
33435 |
// 1. Remove visual markings of active dropping container
|
33436 |
// 2. Remove visual markings of drop position visualization
|
33437 |
that.cleanup();
|
33438 |
},
|
33439 |
-
ondropmove: function(event) {
|
33440 |
// 1. Compute actual location of the mouse within the container
|
33441 |
// 2. Check if insertion is regular (between blocks) or special (with container insertion)
|
33442 |
// 3a. If insertion is regular, compute position where insertion should happen
|
@@ -33530,7 +33530,7 @@ webpackJsonp([4],{
|
|
33530 |
// compensated for to position marker right in the middle of two
|
33531 |
// blocks
|
33532 |
if (dropPosition.position === 'before') {
|
33533 |
-
$targetBlock = that.getChildren().findByModel(viewCollection.at(dropPosition.index-1)).$el;
|
33534 |
} else {
|
33535 |
$targetBlock = that.getChildren().findByModel(viewCollection.at(dropPosition.index)).$el;
|
33536 |
}
|
@@ -33543,7 +33543,7 @@ webpackJsonp([4],{
|
|
33543 |
|
33544 |
element.append(marker);
|
33545 |
},
|
33546 |
-
ondrop: function(event) {
|
33547 |
// 1. Compute actual location of the mouse
|
33548 |
// 2. Check if insertion is regular (between blocks) or special (with container insertion)
|
33549 |
// 3a. If insertion is regular
|
@@ -33581,9 +33581,9 @@ webpackJsonp([4],{
|
|
33581 |
orientation: 'vertical'
|
33582 |
});
|
33583 |
tempCollection.get('blocks').add(droppableModel);
|
33584 |
-
viewCollection.add(tempCollection, {at: index});
|
33585 |
} else {
|
33586 |
-
viewCollection.add(droppableModel, {at: index});
|
33587 |
}
|
33588 |
|
33589 |
droppedView = that.getChildren().findByModel(droppableModel);
|
@@ -33627,7 +33627,7 @@ webpackJsonp([4],{
|
|
33627 |
tempCollection.get('blocks').add(droppableModel);
|
33628 |
}
|
33629 |
}
|
33630 |
-
viewCollection.add(tempCollection, {at: dropPosition.index});
|
33631 |
|
33632 |
// Call post add actions
|
33633 |
droppedView = that.getChildren().findByModel(tempCollection).children.findByModel(droppableModel);
|
@@ -33644,14 +33644,14 @@ webpackJsonp([4],{
|
|
33644 |
}
|
33645 |
});
|
33646 |
},
|
33647 |
-
cleanup: function() {
|
33648 |
// 1. Remove visual markings of active dropping container
|
33649 |
this.view.$el.removeClass('mailpoet_drop_active');
|
33650 |
|
33651 |
// 2. Remove visual markings of drop position visualization
|
33652 |
this.view.$('.mailpoet_drop_marker').remove();
|
33653 |
},
|
33654 |
-
getDropPosition: function(eventX, eventY, is_unsafe) {
|
33655 |
var SPECIAL_AREA_INSERTION_WIDTH = 0.00, // Disable special insertion. Default: 0.3
|
33656 |
|
33657 |
element = this.view.$el,
|
@@ -33733,7 +33733,7 @@ webpackJsonp([4],{
|
|
33733 |
position: position // 'inside'|'before'|'after'
|
33734 |
};
|
33735 |
},
|
33736 |
-
_computeNormalIndex: function(eventX, eventY) {
|
33737 |
// Normal insertion inserts dropModel before target element if
|
33738 |
// event happens on the first half of the element and after the
|
33739 |
// target element if event happens on the second half of the element.
|
@@ -33770,13 +33770,13 @@ webpackJsonp([4],{
|
|
33770 |
};
|
33771 |
}
|
33772 |
},
|
33773 |
-
_computeSpecialIndex: function(eventX, eventY) {
|
33774 |
return this._computeCellIndex(eventX, eventY);
|
33775 |
},
|
33776 |
-
_computeCellIndex: function(eventX, eventY) {
|
33777 |
var orientation = this.view.model.get('orientation'),
|
33778 |
eventOffset = (orientation === 'vertical') ? eventY : eventX,
|
33779 |
-
resultView = this.getChildren().find(function(view) {
|
33780 |
var element = view.$el,
|
33781 |
closeOffset, farOffset;
|
33782 |
|
@@ -33796,26 +33796,26 @@ webpackJsonp([4],{
|
|
33796 |
|
33797 |
return index;
|
33798 |
},
|
33799 |
-
_canAcceptNormalInsertion: function() {
|
33800 |
var orientation = this.view.model.get('orientation'),
|
33801 |
depth = this.view.renderOptions.depth,
|
33802 |
childCount = this.getChildren().length;
|
33803 |
// Note that depth is zero indexed. Root container has depth=0
|
33804 |
return orientation === 'vertical' || (orientation === 'horizontal' && depth === 1 && childCount < this.options.columnLimit);
|
33805 |
},
|
33806 |
-
_canAcceptSpecialInsertion: function() {
|
33807 |
var orientation = this.view.model.get('orientation'),
|
33808 |
depth = this.view.renderOptions.depth,
|
33809 |
childCount = this.getChildren().length;
|
33810 |
return depth === 0 || (depth === 1 && orientation === 'horizontal' && childCount <= this.options.columnLimit);
|
33811 |
},
|
33812 |
-
getCollectionView: function() {
|
33813 |
return this.view.getChildView('blocks');
|
33814 |
},
|
33815 |
-
getChildren: function() {
|
33816 |
return this.getCollectionView().children;
|
33817 |
},
|
33818 |
-
getCollection: function() {
|
33819 |
return this.getCollectionView().collection;
|
33820 |
}
|
33821 |
});
|
@@ -33839,7 +33839,7 @@ webpackJsonp([4],{
|
|
33839 |
__webpack_require__(273),
|
33840 |
__webpack_require__(585),
|
33841 |
__webpack_require__(565)
|
33842 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, _, jQuery, BehaviorsLookup, interact) {
|
33843 |
var BL = BehaviorsLookup;
|
33844 |
|
33845 |
BL.DraggableBehavior = Marionette.Behavior.extend({
|
@@ -33853,14 +33853,14 @@ webpackJsonp([4],{
|
|
33853 |
*
|
33854 |
* @return Backbone.Model A model that will be passed to the receiver
|
33855 |
*/
|
33856 |
-
getDropModel: function() {
|
33857 |
throw "Missing 'drop' function for DraggableBehavior";
|
33858 |
},
|
33859 |
|
33860 |
-
onDrop: function(model, view) {},
|
33861 |
-
testAttachToInstance: function(model, view) { return true; }
|
33862 |
},
|
33863 |
-
onRender: function() {
|
33864 |
var that = this,
|
33865 |
interactable;
|
33866 |
|
@@ -33876,7 +33876,7 @@ webpackJsonp([4],{
|
|
33876 |
// Scroll when dragging near edges of a window
|
33877 |
autoScroll: true,
|
33878 |
|
33879 |
-
onstart: function(startEvent) {
|
33880 |
var event = startEvent;
|
33881 |
|
33882 |
if (that.options.cloneOriginal === true) {
|
@@ -33900,7 +33900,7 @@ webpackJsonp([4],{
|
|
33900 |
// Accurate dimensions can only be taken after insertion to document
|
33901 |
centerXOffset = $clone.width() / 2;
|
33902 |
centerYOffset = $clone.height() / 2;
|
33903 |
-
$clone.css('top',
|
33904 |
$clone.css('left', event.pageX - centerXOffset);
|
33905 |
|
33906 |
event.interaction.element = clone;
|
@@ -33960,7 +33960,7 @@ webpackJsonp([4],{
|
|
33960 |
} else {
|
33961 |
interactable.getDropModel = this.view.getDropFunc();
|
33962 |
}
|
33963 |
-
interactable.onDrop = function(opts) {
|
33964 |
var options = opts;
|
33965 |
if (_.isObject(options)) {
|
33966 |
// Inject Draggable behavior if possible
|
@@ -33987,7 +33987,7 @@ webpackJsonp([4],{
|
|
33987 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
33988 |
__webpack_require__(562),
|
33989 |
__webpack_require__(585)
|
33990 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, BehaviorsLookup) {
|
33991 |
var BL = BehaviorsLookup;
|
33992 |
|
33993 |
BL.HighlightContainerBehavior = Marionette.Behavior.extend({
|
@@ -33995,10 +33995,10 @@ webpackJsonp([4],{
|
|
33995 |
'mouseenter @ui.tools': 'enableHighlight',
|
33996 |
'mouseleave @ui.tools': 'disableHighlight'
|
33997 |
},
|
33998 |
-
enableHighlight: function() {
|
33999 |
this.$el.addClass('mailpoet_highlight');
|
34000 |
},
|
34001 |
-
disableHighlight: function() {
|
34002 |
if (!this.view._isBeingEdited) {
|
34003 |
this.$el.removeClass('mailpoet_highlight');
|
34004 |
}
|
@@ -34020,7 +34020,7 @@ webpackJsonp([4],{
|
|
34020 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
34021 |
__webpack_require__(562),
|
34022 |
__webpack_require__(585)
|
34023 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, BehaviorsLookup) {
|
34024 |
var BL = BehaviorsLookup;
|
34025 |
|
34026 |
BL.HighlightEditingBehavior = Marionette.Behavior.extend({
|
@@ -34028,11 +34028,11 @@ webpackJsonp([4],{
|
|
34028 |
startEditing: 'enableHighlight',
|
34029 |
stopEditing: 'disableHighlight'
|
34030 |
},
|
34031 |
-
enableHighlight: function() {
|
34032 |
this.view._isBeingEdited = true;
|
34033 |
this.$el.addClass('mailpoet_highlight');
|
34034 |
},
|
34035 |
-
disableHighlight: function() {
|
34036 |
this.view._isBeingEdited = false;
|
34037 |
this.$el.removeClass('mailpoet_highlight');
|
34038 |
}
|
@@ -34054,61 +34054,65 @@ webpackJsonp([4],{
|
|
34054 |
__webpack_require__(562),
|
34055 |
__webpack_require__(585),
|
34056 |
__webpack_require__(565)
|
34057 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, BehaviorsLookup, interact) {
|
34058 |
var BL = BehaviorsLookup;
|
34059 |
|
34060 |
BL.ResizableBehavior = Marionette.Behavior.extend({
|
34061 |
defaults: {
|
34062 |
elementSelector: null,
|
34063 |
resizeHandleSelector: true, // true will use edges of the element itself
|
34064 |
-
transformationFunction: function(y) { return y; },
|
34065 |
minLength: 0,
|
34066 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34067 |
},
|
34068 |
events: {
|
34069 |
mouseenter: 'showResizeHandle',
|
34070 |
mouseleave: 'hideResizeHandle'
|
34071 |
},
|
34072 |
-
onRender: function() {
|
34073 |
this.attachResize();
|
34074 |
|
34075 |
if (this.isBeingResized !== true) {
|
34076 |
this.hideResizeHandle();
|
34077 |
}
|
34078 |
},
|
34079 |
-
attachResize: function() {
|
34080 |
var domElement = (this.options.elementSelector === null) ? this.view.$el.get(0) : this.view.$(this.options.elementSelector).get(0),
|
34081 |
that = this;
|
34082 |
interact(domElement).resizable({
|
34083 |
-
//axis: 'y',
|
34084 |
edges: {
|
34085 |
top: false,
|
34086 |
left: false,
|
34087 |
right: false,
|
34088 |
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
|
34089 |
}
|
34090 |
-
})
|
|
|
34091 |
that.isBeingResized = true;
|
34092 |
that.$el.addClass('mailpoet_resize_active');
|
34093 |
-
}).on('resizemove', function(event) {
|
34094 |
-
var currentLength = parseFloat(that.view.model.get(that.options.modelField)),
|
34095 |
-
newLength = currentLength + that.options.transformationFunction(event.dy);
|
34096 |
-
|
34097 |
-
if (newLength < that.options.minLength) newLength = that.options.minLength;
|
34098 |
-
|
34099 |
-
that.view.model.set(that.options.modelField, newLength + 'px');
|
34100 |
})
|
34101 |
-
.on('
|
|
|
|
|
|
|
|
|
34102 |
that.isBeingResized = null;
|
34103 |
that.$el.removeClass('mailpoet_resize_active');
|
34104 |
});
|
34105 |
},
|
34106 |
-
showResizeHandle: function() {
|
34107 |
if (typeof this.options.resizeHandleSelector === 'string') {
|
34108 |
this.view.$(this.options.resizeHandleSelector).removeClass('mailpoet_hidden');
|
34109 |
}
|
34110 |
},
|
34111 |
-
hideResizeHandle: function() {
|
34112 |
if (typeof this.options.resizeHandleSelector === 'string') {
|
34113 |
this.view.$(this.options.resizeHandleSelector).addClass('mailpoet_hidden');
|
34114 |
}
|
@@ -34131,23 +34135,23 @@ webpackJsonp([4],{
|
|
34131 |
__webpack_require__(562),
|
34132 |
__webpack_require__(278),
|
34133 |
__webpack_require__(585)
|
34134 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, _, BehaviorsLookup) {
|
34135 |
var BL = BehaviorsLookup;
|
34136 |
|
34137 |
BL.SortableBehavior = Marionette.Behavior.extend({
|
34138 |
-
onRender: function() {
|
34139 |
var collection = this.view.collection;
|
34140 |
|
34141 |
if (_.isFunction(this.$el.sortable)) {
|
34142 |
this.$el.sortable({
|
34143 |
cursor: 'move',
|
34144 |
-
start: function(event, ui) {
|
34145 |
ui.item.data('previousIndex', ui.item.index());
|
34146 |
},
|
34147 |
-
end: function(event, ui) {
|
34148 |
ui.item.removeData('previousIndex');
|
34149 |
},
|
34150 |
-
update: function(event, ui) {
|
34151 |
var previousIndex = ui.item.data('previousIndex'),
|
34152 |
newIndex = ui.item.index(),
|
34153 |
model = collection.at(previousIndex);
|
@@ -34179,7 +34183,7 @@ webpackJsonp([4],{
|
|
34179 |
__webpack_require__(562),
|
34180 |
__webpack_require__(273),
|
34181 |
__webpack_require__(585)
|
34182 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, jQuery, BehaviorsLookup) {
|
34183 |
var BL = BehaviorsLookup;
|
34184 |
|
34185 |
BL.ShowSettingsBehavior = Marionette.Behavior.extend({
|
@@ -34189,12 +34193,12 @@ webpackJsonp([4],{
|
|
34189 |
events: {
|
34190 |
'click .mailpoet_content': 'showSettings'
|
34191 |
},
|
34192 |
-
showSettings: function(event) {
|
34193 |
-
if(!this.isIgnoredElement(event.target)) {
|
34194 |
this.view.triggerMethod('showSettings');
|
34195 |
}
|
34196 |
},
|
34197 |
-
isIgnoredElement: function(element) {
|
34198 |
return this.options.ignoreFrom
|
34199 |
&& this.options.ignoreFrom.length > 0
|
34200 |
&& jQuery(element).is(this.options.ignoreFrom);
|
@@ -34218,7 +34222,7 @@ webpackJsonp([4],{
|
|
34218 |
__webpack_require__(562),
|
34219 |
__webpack_require__(278),
|
34220 |
__webpack_require__(585)
|
34221 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Marionette, _, BehaviorsLookup) {
|
34222 |
var BL = BehaviorsLookup;
|
34223 |
|
34224 |
BL.TextEditorBehavior = Marionette.Behavior.extend({
|
@@ -34230,9 +34234,9 @@ webpackJsonp([4],{
|
|
34230 |
invalidElements: 'script',
|
34231 |
blockFormats: 'Paragraph=p',
|
34232 |
plugins: 'link textcolor colorpicker mailpoet_shortcodes',
|
34233 |
-
configurationFilter: function(originalConfig) { return originalConfig; }
|
34234 |
},
|
34235 |
-
onDomRefresh: function() {
|
34236 |
var that = this;
|
34237 |
if (this.view.disableTextEditor === true) {
|
34238 |
return;
|
@@ -34253,7 +34257,7 @@ webpackJsonp([4],{
|
|
34253 |
relative_urls: false,
|
34254 |
remove_script_host: false,
|
34255 |
convert_urls: true,
|
34256 |
-
urlconverter_callback: function(url, node, on_save, name) {
|
34257 |
if (url.match(/\[.+\]/g)) {
|
34258 |
// Do not convert URLs with shortcodes
|
34259 |
return url;
|
@@ -34267,12 +34271,12 @@ webpackJsonp([4],{
|
|
34267 |
|
34268 |
plugins: this.options.plugins,
|
34269 |
|
34270 |
-
setup: function(editor) {
|
34271 |
-
editor.on('change', function(e) {
|
34272 |
that.view.triggerMethod('text:editor:change', editor.getContent());
|
34273 |
});
|
34274 |
|
34275 |
-
editor.on('click', function(e) {
|
34276 |
editor.focus();
|
34277 |
if (that._isActivationClick) {
|
34278 |
editor.selection.setRng(
|
@@ -34282,12 +34286,12 @@ webpackJsonp([4],{
|
|
34282 |
}
|
34283 |
});
|
34284 |
|
34285 |
-
editor.on('focus', function(e) {
|
34286 |
that.view.triggerMethod('text:editor:focus');
|
34287 |
that._isActivationClick = true;
|
34288 |
});
|
34289 |
|
34290 |
-
editor.on('blur', function(e) {
|
34291 |
that.view.triggerMethod('text:editor:blur');
|
34292 |
});
|
34293 |
}
|
@@ -34316,7 +34320,7 @@ webpackJsonp([4],{
|
|
34316 |
__webpack_require__(273),
|
34317 |
__webpack_require__(274),
|
34318 |
__webpack_require__(555)
|
34319 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
|
34320 |
|
34321 |
'use strict';
|
34322 |
|
@@ -34325,13 +34329,13 @@ webpackJsonp([4],{
|
|
34325 |
|
34326 |
Module.BlockModel = SuperModel.extend({
|
34327 |
stale: [], // Attributes to be removed upon saving
|
34328 |
-
initialize: function() {
|
34329 |
var that = this;
|
34330 |
-
this.on('change', function() {
|
34331 |
App.getChannel().trigger('autoSave');
|
34332 |
});
|
34333 |
},
|
34334 |
-
_getDefaults: function(blockDefaults, configDefaults) {
|
34335 |
var defaults = (_.isObject(configDefaults) && _.isFunction(configDefaults.toJSON)) ? configDefaults.toJSON() : configDefaults;
|
34336 |
|
34337 |
// Patch the resulting JSON object and fix it's constructors to be Object.
|
@@ -34340,11 +34344,11 @@ webpackJsonp([4],{
|
|
34340 |
// TODO: Investigate for a better solution
|
34341 |
return JSON.parse(JSON.stringify(jQuery.extend(blockDefaults, defaults || {})));
|
34342 |
},
|
34343 |
-
toJSON: function() {
|
34344 |
// Remove stale attributes from resulting JSON object
|
34345 |
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
|
34346 |
},
|
34347 |
-
getChildren: function() {
|
34348 |
return [];
|
34349 |
}
|
34350 |
});
|
@@ -34366,12 +34370,12 @@ webpackJsonp([4],{
|
|
34366 |
DraggableBehavior: {
|
34367 |
cloneOriginal: true,
|
34368 |
hideOriginal: true,
|
34369 |
-
onDrop: function(options) {
|
34370 |
// After a clone of model has been dropped, cleanup
|
34371 |
// and destroy self
|
34372 |
options.dragBehavior.view.model.destroy();
|
34373 |
},
|
34374 |
-
onDragSubstituteBy: function(behavior) {
|
34375 |
var WidgetView, node;
|
34376 |
// When block is being dragged, display the widget icon instead.
|
34377 |
// This will create an instance of block's widget view and
|
@@ -34387,76 +34391,76 @@ webpackJsonp([4],{
|
|
34387 |
},
|
34388 |
HighlightEditingBehavior: {}
|
34389 |
},
|
34390 |
-
templateContext: function() {
|
34391 |
return {
|
34392 |
model: this.model.toJSON(),
|
34393 |
viewCid: this.cid
|
34394 |
};
|
34395 |
},
|
34396 |
-
constructor: function() {
|
34397 |
AugmentedView.apply(this, arguments);
|
34398 |
this.$el.addClass('mailpoet_editor_view_' + this.cid);
|
34399 |
},
|
34400 |
-
initialize: function() {
|
34401 |
this.on('showSettings', this.showSettings, this);
|
34402 |
this.on('dom:refresh', this.showBlock, this);
|
34403 |
this._isFirstRender = true;
|
34404 |
},
|
34405 |
-
showTools: function(_event) {
|
34406 |
if (!this.showingToolsDisabled) {
|
34407 |
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
|
34408 |
this.toolsView.triggerMethod('showTools');
|
34409 |
}
|
34410 |
},
|
34411 |
-
hideTools: function(e) {
|
34412 |
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
|
34413 |
this.toolsView.triggerMethod('hideTools');
|
34414 |
},
|
34415 |
-
enableShowingTools: function() {
|
34416 |
this.showingToolsDisabled = false;
|
34417 |
},
|
34418 |
-
disableShowingTools: function() {
|
34419 |
this.showingToolsDisabled = true;
|
34420 |
this.hideTools();
|
34421 |
},
|
34422 |
-
showSettings: function(options) {
|
34423 |
this.toolsView.triggerMethod('showSettings', options);
|
34424 |
},
|
34425 |
/**
|
34426 |
* Defines drop behavior of BlockView instance
|
34427 |
*/
|
34428 |
-
getDropFunc: function() {
|
34429 |
-
return function() {
|
34430 |
return this.model.clone();
|
34431 |
}.bind(this);
|
34432 |
},
|
34433 |
-
disableDragging: function() {
|
34434 |
this.$el.addClass('mailpoet_ignore_drag');
|
34435 |
},
|
34436 |
-
enableDragging: function() {
|
34437 |
this.$el.removeClass('mailpoet_ignore_drag');
|
34438 |
},
|
34439 |
-
showBlock: function() {
|
34440 |
if (this._isFirstRender) {
|
34441 |
this.transitionIn();
|
34442 |
this._isFirstRender = false;
|
34443 |
}
|
34444 |
},
|
34445 |
-
deleteBlock: function() {
|
34446 |
-
this.transitionOut().then(function() {
|
34447 |
this.model.destroy();
|
34448 |
}.bind(this));
|
34449 |
},
|
34450 |
-
duplicateBlock: function() {
|
34451 |
-
this.model.collection.add(this.model.toJSON(), {at: this.model.collection.findIndex(this.model)});
|
34452 |
},
|
34453 |
-
transitionIn: function() {
|
34454 |
return this._transition('slideDown', 'fadeIn', 'easeOut');
|
34455 |
},
|
34456 |
-
transitionOut: function() {
|
34457 |
return this._transition('slideUp', 'fadeOut', 'easeIn');
|
34458 |
},
|
34459 |
-
_transition: function(slideDirection, fadeDirection, easing) {
|
34460 |
var promise = jQuery.Deferred();
|
34461 |
|
34462 |
this.$el.velocity(
|
@@ -34464,7 +34468,7 @@ webpackJsonp([4],{
|
|
34464 |
{
|
34465 |
duration: 250,
|
34466 |
easing: easing,
|
34467 |
-
complete: function() {
|
34468 |
promise.resolve();
|
34469 |
}.bind(this)
|
34470 |
}
|
@@ -34482,7 +34486,7 @@ webpackJsonp([4],{
|
|
34482 |
});
|
34483 |
|
34484 |
Module.BlockToolsView = AugmentedView.extend({
|
34485 |
-
getTemplate: function() { return window.templates.genericBlockTools; },
|
34486 |
events: {
|
34487 |
'click .mailpoet_edit_block': 'changeSettings',
|
34488 |
'click .mailpoet_delete_block_activate': 'showDeletionConfirmation',
|
@@ -34497,8 +34501,8 @@ webpackJsonp([4],{
|
|
34497 |
duplicate: true,
|
34498 |
move: true
|
34499 |
},
|
34500 |
-
getSettingsView: function() { return Module.BlockSettingsView; },
|
34501 |
-
initialize: function(opts) {
|
34502 |
var options = opts || {};
|
34503 |
if (!_.isUndefined(options.tools)) {
|
34504 |
// Make a new block specific tool config object
|
@@ -34509,29 +34513,29 @@ webpackJsonp([4],{
|
|
34509 |
this.on('hideTools', this.hideDeletionConfirmation, this);
|
34510 |
this.on('showSettings', this.changeSettings);
|
34511 |
},
|
34512 |
-
templateContext: function() {
|
34513 |
return {
|
34514 |
model: this.model.toJSON(),
|
34515 |
viewCid: this.cid,
|
34516 |
tools: this.tools
|
34517 |
};
|
34518 |
},
|
34519 |
-
changeSettings: function(options) {
|
34520 |
var ViewType = this.getSettingsView();
|
34521 |
(new ViewType(_.extend({ model: this.model }, options || {}))).render();
|
34522 |
},
|
34523 |
-
showDeletionConfirmation: function() {
|
34524 |
this.$('.mailpoet_delete_block').addClass('mailpoet_delete_block_activated');
|
34525 |
},
|
34526 |
-
hideDeletionConfirmation: function() {
|
34527 |
this.$('.mailpoet_delete_block').removeClass('mailpoet_delete_block_activated');
|
34528 |
},
|
34529 |
-
deleteBlock: function(event) {
|
34530 |
event.preventDefault();
|
34531 |
this.model.trigger('delete');
|
34532 |
return false;
|
34533 |
},
|
34534 |
-
duplicateBlock: function(event) {
|
34535 |
event.preventDefault();
|
34536 |
this.model.trigger('duplicate');
|
34537 |
return false;
|
@@ -34543,14 +34547,14 @@ webpackJsonp([4],{
|
|
34543 |
behaviors: {
|
34544 |
ColorPickerBehavior: {}
|
34545 |
},
|
34546 |
-
initialize: function(params) {
|
34547 |
this.model.trigger('startEditing');
|
34548 |
var panelParams = {
|
34549 |
element: this.$el,
|
34550 |
template: '',
|
34551 |
position: 'right',
|
34552 |
width: App.getConfig().get('sidepanelWidth'),
|
34553 |
-
onCancel: function() {
|
34554 |
this.destroy();
|
34555 |
}.bind(this)
|
34556 |
};
|
@@ -34561,37 +34565,37 @@ webpackJsonp([4],{
|
|
34561 |
MailPoet.Modal.panel(panelParams);
|
34562 |
}
|
34563 |
},
|
34564 |
-
templateContext: function() {
|
34565 |
return {
|
34566 |
model: this.model.toJSON()
|
34567 |
};
|
34568 |
},
|
34569 |
-
close: function(event) {
|
34570 |
this.destroy();
|
34571 |
},
|
34572 |
-
changeField: function(field, event) {
|
34573 |
this.model.set(field, jQuery(event.target).val());
|
34574 |
},
|
34575 |
-
changePixelField: function(field, event) {
|
34576 |
this.changeFieldWithSuffix(field, event, 'px');
|
34577 |
},
|
34578 |
-
changeFieldWithSuffix: function(field, event, suffix) {
|
34579 |
this.model.set(field, jQuery(event.target).val() + suffix);
|
34580 |
},
|
34581 |
-
changeBoolField: function(field, event) {
|
34582 |
this.model.set(field, (jQuery(event.target).val() === 'true'));
|
34583 |
},
|
34584 |
-
changeBoolCheckboxField: function(field, event) {
|
34585 |
this.model.set(field, (!!jQuery(event.target).prop('checked')));
|
34586 |
},
|
34587 |
-
changeColorField: function(field, event) {
|
34588 |
var value = jQuery(event.target).val();
|
34589 |
if (value === '') {
|
34590 |
value = 'transparent';
|
34591 |
}
|
34592 |
this.model.set(field, value);
|
34593 |
},
|
34594 |
-
onBeforeDestroy: function() {
|
34595 |
MailPoet.Modal.close();
|
34596 |
this.model.trigger('stopEditing');
|
34597 |
}
|
@@ -34601,7 +34605,7 @@ webpackJsonp([4],{
|
|
34601 |
className: 'mailpoet_widget mailpoet_droppable_block mailpoet_droppable_widget',
|
34602 |
behaviors: {
|
34603 |
DraggableBehavior: {
|
34604 |
-
drop: function() {
|
34605 |
throw 'Unsupported operation';
|
34606 |
}
|
34607 |
}
|
@@ -34629,7 +34633,7 @@ webpackJsonp([4],{
|
|
34629 |
__webpack_require__(273),
|
34630 |
__webpack_require__(574),
|
34631 |
__webpack_require__(595)
|
34632 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(Backbone, Marionette, _, jQuery, App, BaseBlock) {
|
34633 |
|
34634 |
'use strict';
|
34635 |
|
@@ -34639,15 +34643,15 @@ webpackJsonp([4],{
|
|
34639 |
|
34640 |
BlockCollection = Backbone.Collection.extend({
|
34641 |
model: base.BlockModel,
|
34642 |
-
initialize: function() {
|
34643 |
-
this.on('add change remove', function() { App.getChannel().trigger('autoSave'); });
|
34644 |
},
|
34645 |
-
parse: function(response) {
|
34646 |
var self = this;
|
34647 |
-
return _.map(response, function(block) {
|
34648 |
var Type = App.getBlockTypeModel(block.type);
|
34649 |
// TODO: If type has no registered model, use a backup one
|
34650 |
-
return new Type(block, {parse: true});
|
34651 |
});
|
34652 |
}
|
34653 |
});
|
@@ -34656,7 +34660,7 @@ webpackJsonp([4],{
|
|
34656 |
relations: {
|
34657 |
blocks: BlockCollection
|
34658 |
},
|
34659 |
-
defaults: function() {
|
34660 |
return this._getDefaults({
|
34661 |
type: 'container',
|
34662 |
orientation: 'vertical',
|
@@ -34668,14 +34672,14 @@ webpackJsonp([4],{
|
|
34668 |
blocks: new BlockCollection()
|
34669 |
}, App.getConfig().get('blockDefaults.container'));
|
34670 |
},
|
34671 |
-
validate: function() {
|
34672 |
// Recursively propagate validation checks to blocks in the tree
|
34673 |
-
var invalidBlock =
|
34674 |
if (invalidBlock) {
|
34675 |
return invalidBlock.validationError;
|
34676 |
}
|
34677 |
},
|
34678 |
-
parse: function(response) {
|
34679 |
// If container has any blocks - add them to a collection
|
34680 |
if (response.type === 'container' && _.has(response, 'blocks')) {
|
34681 |
response.blocks = new BlockCollection(response.blocks, {
|
@@ -34684,8 +34688,8 @@ webpackJsonp([4],{
|
|
34684 |
}
|
34685 |
return response;
|
34686 |
},
|
34687 |
-
getChildren: function() {
|
34688 |
-
var models = this.get('blocks').map(function(model, index, list) {
|
34689 |
return [model, model.getChildren()];
|
34690 |
});
|
34691 |
|
@@ -34695,10 +34699,10 @@ webpackJsonp([4],{
|
|
34695 |
|
34696 |
Module.ContainerBlocksView = Marionette.CollectionView.extend({
|
34697 |
className: 'mailpoet_container',
|
34698 |
-
childView: function(model) {
|
34699 |
return App.getBlockTypeView(model.get('type'));
|
34700 |
},
|
34701 |
-
childViewOptions: function() {
|
34702 |
var newRenderOptions = _.clone(this.renderOptions);
|
34703 |
if (newRenderOptions.depth !== undefined) {
|
34704 |
newRenderOptions.depth += 1;
|
@@ -34707,9 +34711,9 @@ webpackJsonp([4],{
|
|
34707 |
renderOptions: newRenderOptions
|
34708 |
};
|
34709 |
},
|
34710 |
-
emptyView: function() { return Module.ContainerBlockEmptyView; },
|
34711 |
-
emptyViewOptions: function() { return { renderOptions: this.renderOptions }; },
|
34712 |
-
initialize: function(options) {
|
34713 |
this.renderOptions = options.renderOptions;
|
34714 |
}
|
34715 |
});
|
@@ -34722,7 +34726,7 @@ webpackJsonp([4],{
|
|
34722 |
}
|
34723 |
}),
|
34724 |
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
|
34725 |
-
getTemplate: function() { return window.templates.containerBlock; },
|
34726 |
events: _.extend({}, base.BlockView.prototype.events, {
|
34727 |
'click .mailpoet_newsletter_layer_selector': 'toggleEditingLayer'
|
34728 |
}),
|
@@ -34734,12 +34738,12 @@ webpackJsonp([4],{
|
|
34734 |
DraggableBehavior: {
|
34735 |
cloneOriginal: true,
|
34736 |
hideOriginal: true,
|
34737 |
-
onDrop: function(options) {
|
34738 |
// After a clone of model has been dropped, cleanup
|
34739 |
// and destroy self
|
34740 |
options.dragBehavior.view.model.destroy();
|
34741 |
},
|
34742 |
-
onDragSubstituteBy: function(behavior) {
|
34743 |
var WidgetView, node;
|
34744 |
// When block is being dragged, display the widget icon instead.
|
34745 |
// This will create an instance of block's widget view and
|
@@ -34752,7 +34756,7 @@ webpackJsonp([4],{
|
|
34752 |
return node;
|
34753 |
}
|
34754 |
},
|
34755 |
-
testAttachToInstance: function(model, view) {
|
34756 |
// Attach Draggable only to layout containers and disable it
|
34757 |
// for root and column containers.
|
34758 |
return view.renderOptions.depth === 1;
|
@@ -34760,7 +34764,7 @@ webpackJsonp([4],{
|
|
34760 |
},
|
34761 |
HighlightContainerBehavior: {}
|
34762 |
}),
|
34763 |
-
onDragSubstituteBy: function() {
|
34764 |
// For two and three column layouts display their respective widgets,
|
34765 |
// otherwise always default to one column layout widget
|
34766 |
if (this.renderOptions.depth === 1) {
|
@@ -34770,12 +34774,12 @@ webpackJsonp([4],{
|
|
34770 |
return Module.OneColumnContainerWidgetView;
|
34771 |
|
34772 |
},
|
34773 |
-
initialize: function(options) {
|
34774 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
34775 |
|
34776 |
this.renderOptions = _.defaults(options.renderOptions || {}, {});
|
34777 |
},
|
34778 |
-
onRender: function() {
|
34779 |
this.toolsView = new Module.ContainerBlockToolsView({
|
34780 |
model: this.model,
|
34781 |
tools: {
|
@@ -34796,31 +34800,31 @@ webpackJsonp([4],{
|
|
34796 |
// Sets child container orientation HTML class here, as child CollectionView won't have access to model and will overwrite existing region element instead
|
34797 |
this.$('> .mailpoet_container').attr('class', 'mailpoet_container mailpoet_container_' + this.model.get('orientation'));
|
34798 |
},
|
34799 |
-
showTools: function() {
|
34800 |
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
34801 |
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
34802 |
this.toolsView.triggerMethod('showTools');
|
34803 |
}
|
34804 |
},
|
34805 |
-
hideTools: function() {
|
34806 |
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
34807 |
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
34808 |
this.toolsView.triggerMethod('hideTools');
|
34809 |
}
|
34810 |
},
|
34811 |
-
toggleEditingLayer: function(event) {
|
34812 |
var that = this,
|
34813 |
$toggleButton = this.$('> .mailpoet_tools .mailpoet_newsletter_layer_selector'),
|
34814 |
$overlay = jQuery('.mailpoet_layer_overlay'),
|
34815 |
$container = this.$('> .mailpoet_container'),
|
34816 |
-
enableContainerLayer = function() {
|
34817 |
that.$el.addClass('mailpoet_container_layer_active');
|
34818 |
$toggleButton.addClass('mailpoet_container_layer_active');
|
34819 |
$container.addClass('mailpoet_layer_highlight');
|
34820 |
$overlay.click(disableContainerLayer);
|
34821 |
$overlay.show();
|
34822 |
},
|
34823 |
-
disableContainerLayer = function() {
|
34824 |
that.$el.removeClass('mailpoet_container_layer_active');
|
34825 |
$toggleButton.removeClass('mailpoet_container_layer_active');
|
34826 |
$container.removeClass('mailpoet_layer_highlight');
|
@@ -34837,11 +34841,11 @@ webpackJsonp([4],{
|
|
34837 |
});
|
34838 |
|
34839 |
Module.ContainerBlockEmptyView = Marionette.View.extend({
|
34840 |
-
getTemplate: function() { return window.templates.containerEmpty; },
|
34841 |
-
initialize: function(options) {
|
34842 |
this.renderOptions = _.defaults(options.renderOptions || {}, {});
|
34843 |
},
|
34844 |
-
templateContext: function() {
|
34845 |
return {
|
34846 |
isRoot: this.renderOptions.depth === 0,
|
34847 |
emptyContainerMessage: this.renderOptions.emptyContainerMessage || ''
|
@@ -34850,12 +34854,12 @@ webpackJsonp([4],{
|
|
34850 |
});
|
34851 |
|
34852 |
Module.ContainerBlockToolsView = base.BlockToolsView.extend({
|
34853 |
-
getSettingsView: function() { return Module.ContainerBlockSettingsView; }
|
34854 |
});
|
34855 |
|
34856 |
Module.ContainerBlockSettingsView = base.BlockSettingsView.extend({
|
34857 |
-
getTemplate: function() { return window.templates.containerBlockSettings; },
|
34858 |
-
events: function() {
|
34859 |
return {
|
34860 |
'change .mailpoet_field_container_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
34861 |
'click .mailpoet_done_editing': 'close'
|
@@ -34864,21 +34868,21 @@ webpackJsonp([4],{
|
|
34864 |
regions: {
|
34865 |
columnsSettingsRegion: '.mailpoet_container_columns_settings'
|
34866 |
},
|
34867 |
-
initialize: function() {
|
34868 |
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
|
34869 |
|
34870 |
this._columnsSettingsView = new (Module.ContainerBlockColumnsSettingsView)({
|
34871 |
collection: this.model.get('blocks')
|
34872 |
});
|
34873 |
},
|
34874 |
-
onRender: function() {
|
34875 |
this.showChildView('columnsSettingsRegion', this._columnsSettingsView);
|
34876 |
}
|
34877 |
});
|
34878 |
|
34879 |
Module.ContainerBlockColumnsSettingsView = Marionette.CollectionView.extend({
|
34880 |
-
childView: function() { return Module.ContainerBlockColumnSettingsView; },
|
34881 |
-
childViewOptions: function(model, index) {
|
34882 |
return {
|
34883 |
columnIndex: index
|
34884 |
};
|
@@ -34886,11 +34890,11 @@ webpackJsonp([4],{
|
|
34886 |
});
|
34887 |
|
34888 |
Module.ContainerBlockColumnSettingsView = Marionette.View.extend({
|
34889 |
-
getTemplate: function() { return window.templates.containerBlockColumnSettings; },
|
34890 |
-
initialize: function(options) {
|
34891 |
this.columnNumber = (options.columnIndex || 0) + 1;
|
34892 |
},
|
34893 |
-
templateContext: function() {
|
34894 |
return {
|
34895 |
model: this.model.toJSON(),
|
34896 |
columnNumber: this.columnNumber
|
@@ -34900,11 +34904,11 @@ webpackJsonp([4],{
|
|
34900 |
|
34901 |
Module.OneColumnContainerWidgetView = base.WidgetView.extend({
|
34902 |
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
34903 |
-
getTemplate: function() { return window.templates.oneColumnLayoutInsertion; },
|
34904 |
behaviors: {
|
34905 |
DraggableBehavior: {
|
34906 |
cloneOriginal: true,
|
34907 |
-
drop: function() {
|
34908 |
return new Module.ContainerBlockModel({
|
34909 |
orientation: 'horizontal',
|
34910 |
blocks: [
|
@@ -34918,11 +34922,11 @@ webpackJsonp([4],{
|
|
34918 |
|
34919 |
Module.TwoColumnContainerWidgetView = base.WidgetView.extend({
|
34920 |
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
34921 |
-
getTemplate: function() { return window.templates.twoColumnLayoutInsertion; },
|
34922 |
behaviors: {
|
34923 |
DraggableBehavior: {
|
34924 |
cloneOriginal: true,
|
34925 |
-
drop: function() {
|
34926 |
return new Module.ContainerBlockModel({
|
34927 |
orientation: 'horizontal',
|
34928 |
blocks: [
|
@@ -34937,11 +34941,11 @@ webpackJsonp([4],{
|
|
34937 |
|
34938 |
Module.ThreeColumnContainerWidgetView = base.WidgetView.extend({
|
34939 |
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
34940 |
-
getTemplate: function() { return window.templates.threeColumnLayoutInsertion; },
|
34941 |
behaviors: {
|
34942 |
DraggableBehavior: {
|
34943 |
cloneOriginal: true,
|
34944 |
-
drop: function() {
|
34945 |
return new Module.ContainerBlockModel({
|
34946 |
orientation: 'horizontal',
|
34947 |
blocks: [
|
@@ -34955,7 +34959,7 @@ webpackJsonp([4],{
|
|
34955 |
}
|
34956 |
});
|
34957 |
|
34958 |
-
App.on('before:start', function(App, options) {
|
34959 |
App.registerBlockType('container', {
|
34960 |
blockModel: Module.ContainerBlockModel,
|
34961 |
blockView: Module.ContainerBlockView
|
@@ -34998,7 +35002,7 @@ webpackJsonp([4],{
|
|
34998 |
__webpack_require__(274),
|
34999 |
__webpack_require__(278),
|
35000 |
__webpack_require__(273)
|
35001 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, MailPoet, _, jQuery) {
|
35002 |
|
35003 |
'use strict';
|
35004 |
|
@@ -35006,7 +35010,7 @@ webpackJsonp([4],{
|
|
35006 |
base = BaseBlock;
|
35007 |
|
35008 |
Module.ButtonBlockModel = base.BlockModel.extend({
|
35009 |
-
defaults: function() {
|
35010 |
return this._getDefaults({
|
35011 |
type: 'button',
|
35012 |
text: 'Button',
|
@@ -35033,31 +35037,31 @@ webpackJsonp([4],{
|
|
35033 |
|
35034 |
Module.ButtonBlockView = base.BlockView.extend({
|
35035 |
className: 'mailpoet_block mailpoet_button_block mailpoet_droppable_block',
|
35036 |
-
getTemplate: function() { return window.templates.buttonBlock; },
|
35037 |
-
onDragSubstituteBy: function() { return Module.ButtonWidgetView; },
|
35038 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35039 |
ShowSettingsBehavior: {}
|
35040 |
}),
|
35041 |
-
initialize: function() {
|
35042 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35043 |
|
35044 |
// Listen for attempts to change all dividers in one go
|
35045 |
-
this._replaceButtonStylesHandler = function(data) { this.model.set(data); }.bind(this);
|
35046 |
App.getChannel().on('replaceAllButtonStyles', this._replaceButtonStylesHandler);
|
35047 |
},
|
35048 |
-
onRender: function() {
|
35049 |
this.toolsView = new Module.ButtonBlockToolsView({ model: this.model });
|
35050 |
this.showChildView('toolsRegion', this.toolsView);
|
35051 |
}
|
35052 |
});
|
35053 |
|
35054 |
Module.ButtonBlockToolsView = base.BlockToolsView.extend({
|
35055 |
-
getSettingsView: function() { return Module.ButtonBlockSettingsView; }
|
35056 |
});
|
35057 |
|
35058 |
Module.ButtonBlockSettingsView = base.BlockSettingsView.extend({
|
35059 |
-
getTemplate: function() { return window.templates.buttonBlockSettings; },
|
35060 |
-
events: function() {
|
35061 |
return {
|
35062 |
'input .mailpoet_field_button_text': _.partial(this.changeField, 'text'),
|
35063 |
'input .mailpoet_field_button_url': _.partial(this.changeField, 'url'),
|
@@ -35089,20 +35093,20 @@ webpackJsonp([4],{
|
|
35089 |
'click .mailpoet_done_editing': 'close'
|
35090 |
};
|
35091 |
},
|
35092 |
-
templateContext: function() {
|
35093 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
35094 |
availableStyles: App.getAvailableStyles().toJSON(),
|
35095 |
renderOptions: this.renderOptions
|
35096 |
});
|
35097 |
},
|
35098 |
-
applyToAll: function() {
|
35099 |
App.getChannel().trigger('replaceAllButtonStyles', _.pick(this.model.toJSON(), 'styles', 'type'));
|
35100 |
},
|
35101 |
-
updateValueAndCall: function(fieldToUpdate, callable, event) {
|
35102 |
this.$(fieldToUpdate).val(jQuery(event.target).val());
|
35103 |
callable(event);
|
35104 |
},
|
35105 |
-
changeFontWeight: function(event) {
|
35106 |
var checked = !!jQuery(event.target).prop('checked');
|
35107 |
this.model.set(
|
35108 |
'styles.block.fontWeight',
|
@@ -35112,18 +35116,18 @@ webpackJsonp([4],{
|
|
35112 |
});
|
35113 |
|
35114 |
Module.ButtonWidgetView = base.WidgetView.extend({
|
35115 |
-
getTemplate: function() { return window.templates.buttonInsertion; },
|
35116 |
behaviors: {
|
35117 |
DraggableBehavior: {
|
35118 |
cloneOriginal: true,
|
35119 |
-
drop: function() {
|
35120 |
return new Module.ButtonBlockModel();
|
35121 |
}
|
35122 |
}
|
35123 |
}
|
35124 |
});
|
35125 |
|
35126 |
-
App.on('before:start', function(App, options) {
|
35127 |
App.registerBlockType('button', {
|
35128 |
blockModel: Module.ButtonBlockModel,
|
35129 |
blockView: Module.ButtonBlockView
|
@@ -35154,7 +35158,7 @@ webpackJsonp([4],{
|
|
35154 |
__webpack_require__(278),
|
35155 |
__webpack_require__(274),
|
35156 |
__webpack_require__(273)
|
35157 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, _, MailPoet, jQuery) {
|
35158 |
|
35159 |
'use strict';
|
35160 |
|
@@ -35163,7 +35167,7 @@ webpackJsonp([4],{
|
|
35163 |
ImageWidgetView;
|
35164 |
|
35165 |
Module.ImageBlockModel = base.BlockModel.extend({
|
35166 |
-
defaults: function() {
|
35167 |
return this._getDefaults({
|
35168 |
type: 'image',
|
35169 |
link: '',
|
@@ -35183,34 +35187,45 @@ webpackJsonp([4],{
|
|
35183 |
|
35184 |
Module.ImageBlockView = base.BlockView.extend({
|
35185 |
className: 'mailpoet_block mailpoet_image_block mailpoet_droppable_block',
|
35186 |
-
getTemplate: function() { return window.templates.imageBlock; },
|
35187 |
-
onDragSubstituteBy: function() { return Module.ImageWidgetView; },
|
35188 |
-
templateContext: function() {
|
35189 |
return _.extend({
|
35190 |
imageMissingSrc: App.getConfig().get('urls.imageMissing')
|
35191 |
}, base.BlockView.prototype.templateContext.apply(this));
|
35192 |
},
|
35193 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35195 |
}),
|
35196 |
-
onRender: function() {
|
35197 |
this.toolsView = new Module.ImageBlockToolsView({ model: this.model });
|
35198 |
this.showChildView('toolsRegion', this.toolsView);
|
35199 |
-
|
35200 |
if (this.model.get('fullWidth')) {
|
35201 |
this.$el.addClass('mailpoet_full_image');
|
35202 |
} else {
|
35203 |
this.$el.removeClass('mailpoet_full_image');
|
35204 |
}
|
|
|
35205 |
}
|
35206 |
});
|
35207 |
|
35208 |
Module.ImageBlockToolsView = base.BlockToolsView.extend({
|
35209 |
-
getSettingsView: function() { return Module.ImageBlockSettingsView; }
|
35210 |
});
|
35211 |
|
35212 |
Module.ImageBlockSettingsView = base.BlockSettingsView.extend({
|
35213 |
-
onRender: function() {
|
35214 |
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-full-width'), {
|
35215 |
tooltipId: 'tooltip-editor-full-width',
|
35216 |
tooltip: MailPoet.I18n.t('helpTooltipDesignerFullWidth')
|
@@ -35220,8 +35235,8 @@ webpackJsonp([4],{
|
|
35220 |
tooltip: MailPoet.I18n.t('helpTooltipDesignerIdealWidth')
|
35221 |
});
|
35222 |
},
|
35223 |
-
getTemplate: function() { return window.templates.imageBlockSettings; },
|
35224 |
-
events: function() {
|
35225 |
return {
|
35226 |
'input .mailpoet_field_image_link': _.partial(this.changeField, 'link'),
|
35227 |
'input .mailpoet_field_image_address': 'changeAddress',
|
@@ -35229,17 +35244,40 @@ webpackJsonp([4],{
|
|
35229 |
'change .mailpoet_field_image_full_width': _.partial(this.changeBoolCheckboxField, 'fullWidth'),
|
35230 |
'change .mailpoet_field_image_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
|
35231 |
'click .mailpoet_field_image_select_another_image': 'showMediaManager',
|
35232 |
-
'click .mailpoet_done_editing': 'close'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35233 |
};
|
35234 |
},
|
35235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35236 |
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
|
35237 |
|
35238 |
if (options.showImageManager) {
|
35239 |
this.showMediaManager();
|
35240 |
}
|
35241 |
},
|
35242 |
-
showMediaManager: function() {
|
35243 |
if (this._mediaManager) {
|
35244 |
this._mediaManager.resetSelections();
|
35245 |
this._mediaManager.open();
|
@@ -35248,7 +35286,7 @@ webpackJsonp([4],{
|
|
35248 |
|
35249 |
var MediaManager = window.wp.media.view.MediaFrame.Select.extend({
|
35250 |
|
35251 |
-
initialize: function() {
|
35252 |
window.wp.media.view.MediaFrame.prototype.initialize.apply(this, arguments);
|
35253 |
|
35254 |
_.defaults(this.options, {
|
@@ -35266,16 +35304,16 @@ webpackJsonp([4],{
|
|
35266 |
this.$el.addClass('hide-title');
|
35267 |
},
|
35268 |
|
35269 |
-
resetSelections: function() {
|
35270 |
this.state().get('selection').reset();
|
35271 |
},
|
35272 |
|
35273 |
-
createQuery: function(options) {
|
35274 |
var query = window.wp.media.query(options);
|
35275 |
return query;
|
35276 |
},
|
35277 |
|
35278 |
-
createStates: function() {
|
35279 |
var options = this.options;
|
35280 |
|
35281 |
// Add the default states.
|
@@ -35303,12 +35341,12 @@ webpackJsonp([4],{
|
|
35303 |
})
|
35304 |
]);
|
35305 |
|
35306 |
-
if(window.wp.media.view.settings.post.featuredImageId) {
|
35307 |
this.states.add(new window.wp.media.controller.FeaturedImage());
|
35308 |
}
|
35309 |
},
|
35310 |
|
35311 |
-
bindHandlers: function() {
|
35312 |
// from Select
|
35313 |
this.on('router:create:browse', this.createRouter, this);
|
35314 |
this.on('router:render:browse', this.browseRouter, this);
|
@@ -35333,20 +35371,20 @@ webpackJsonp([4],{
|
|
35333 |
}
|
35334 |
};
|
35335 |
|
35336 |
-
_.each(handlers, function(regionHandlers, region) {
|
35337 |
-
_.each(regionHandlers, function(callback, handler) {
|
35338 |
this.on(region + ':render:' + handler, this[callback], this);
|
35339 |
}, this);
|
35340 |
}, this);
|
35341 |
},
|
35342 |
|
35343 |
-
uploadContent: function() {
|
35344 |
window.wp.media.view.MediaFrame.Select.prototype.uploadContent.apply(this, arguments);
|
35345 |
this.$el.addClass('hide-toolbar');
|
35346 |
},
|
35347 |
|
35348 |
// Content
|
35349 |
-
embedContent: function() {
|
35350 |
var view = new window.wp.media.view.Embed({
|
35351 |
controller: this,
|
35352 |
model: this.state()
|
@@ -35356,7 +35394,7 @@ webpackJsonp([4],{
|
|
35356 |
view.url.focus();
|
35357 |
},
|
35358 |
|
35359 |
-
editSelectionContent: function() {
|
35360 |
var state = this.state(),
|
35361 |
selection = state.get('selection'),
|
35362 |
view;
|
@@ -35377,7 +35415,7 @@ webpackJsonp([4],{
|
|
35377 |
text: 'Return to library',
|
35378 |
priority: -100,
|
35379 |
|
35380 |
-
click: function() {
|
35381 |
this.controller.content.mode('browse');
|
35382 |
}
|
35383 |
});
|
@@ -35387,7 +35425,7 @@ webpackJsonp([4],{
|
|
35387 |
},
|
35388 |
|
35389 |
// Toolbars
|
35390 |
-
selectionStatusToolbar: function(view) {
|
35391 |
var editable = this.state().get('editable');
|
35392 |
|
35393 |
view.set('selection', new window.wp.media.view.Selection({
|
@@ -35397,13 +35435,13 @@ webpackJsonp([4],{
|
|
35397 |
|
35398 |
// If the selection is editable, pass the callback to
|
35399 |
// switch the content mode.
|
35400 |
-
editable: editable && function() {
|
35401 |
this.controller.content.mode('edit-selection');
|
35402 |
}
|
35403 |
-
}).render()
|
35404 |
},
|
35405 |
|
35406 |
-
mainInsertToolbar: function(view) {
|
35407 |
var controller = this;
|
35408 |
|
35409 |
this.selectionStatusToolbar(view);
|
@@ -35414,7 +35452,7 @@ webpackJsonp([4],{
|
|
35414 |
text: 'Select Image',
|
35415 |
requires: { selection: true },
|
35416 |
|
35417 |
-
click: function() {
|
35418 |
var state = controller.state(),
|
35419 |
selection = state.get('selection');
|
35420 |
|
@@ -35424,7 +35462,7 @@ webpackJsonp([4],{
|
|
35424 |
});
|
35425 |
},
|
35426 |
|
35427 |
-
mainEmbedToolbar: function(toolbar) {
|
35428 |
var tbar = toolbar;
|
35429 |
tbar.view = new window.wp.media.view.Toolbar.Embed({
|
35430 |
controller: this,
|
@@ -35451,10 +35489,10 @@ webpackJsonp([4],{
|
|
35451 |
that = this;
|
35452 |
this._mediaManager = theFrame;
|
35453 |
|
35454 |
-
this._mediaManager.on('insert', function() {
|
35455 |
// Append media manager image selections to Images tab
|
35456 |
var selection = theFrame.state().get('selection');
|
35457 |
-
selection.each(function(attachment) {
|
35458 |
var sizes = attachment.get('sizes'),
|
35459 |
// Following advice from Becs, the target width should
|
35460 |
// be a double of one column width to render well on
|
@@ -35467,13 +35505,13 @@ webpackJsonp([4],{
|
|
35467 |
// Pick the width that is closest to target width
|
35468 |
increasingByWidthDifference = _.sortBy(
|
35469 |
_.keys(sizes),
|
35470 |
-
function(size) { return Math.abs(targetImageWidth - sizes[size].width); }
|
35471 |
),
|
35472 |
bestWidth = sizes[_.first(increasingByWidthDifference)].width,
|
35473 |
-
imagesOfBestWidth = _.filter(_.values(sizes), function(size) { return size.width === bestWidth; }),
|
35474 |
|
35475 |
// Maximize the height if there are multiple images with same width
|
35476 |
-
mainSize = _.max(imagesOfBestWidth, function(size) { return size.height; });
|
35477 |
|
35478 |
that.model.set({
|
35479 |
height: mainSize.height + 'px',
|
@@ -35488,11 +35526,11 @@ webpackJsonp([4],{
|
|
35488 |
|
35489 |
this._mediaManager.open();
|
35490 |
},
|
35491 |
-
changeAddress: function(event) {
|
35492 |
var src = jQuery(event.target).val();
|
35493 |
var image = new Image();
|
35494 |
|
35495 |
-
image.onload = function() {
|
35496 |
this.model.set({
|
35497 |
src: src,
|
35498 |
width: image.naturalWidth + 'px',
|
@@ -35502,7 +35540,7 @@ webpackJsonp([4],{
|
|
35502 |
|
35503 |
image.src = src;
|
35504 |
},
|
35505 |
-
onBeforeDestroy: function() {
|
35506 |
base.BlockSettingsView.prototype.onBeforeDestroy.apply(this, arguments);
|
35507 |
if (typeof this._mediaManager === 'object') {
|
35508 |
this._mediaManager.remove();
|
@@ -35511,14 +35549,14 @@ webpackJsonp([4],{
|
|
35511 |
});
|
35512 |
|
35513 |
ImageWidgetView = base.WidgetView.extend({
|
35514 |
-
getTemplate: function() { return window.templates.imageInsertion; },
|
35515 |
behaviors: {
|
35516 |
DraggableBehavior: {
|
35517 |
cloneOriginal: true,
|
35518 |
-
drop: function() {
|
35519 |
return new Module.ImageBlockModel();
|
35520 |
},
|
35521 |
-
onDrop: function(options) {
|
35522 |
options.droppedView.triggerMethod('showSettings', { showImageManager: true });
|
35523 |
}
|
35524 |
}
|
@@ -35526,7 +35564,7 @@ webpackJsonp([4],{
|
|
35526 |
});
|
35527 |
Module.ImageWidgetView = ImageWidgetView;
|
35528 |
|
35529 |
-
App.on('before:start', function(App, options) {
|
35530 |
App.registerBlockType('image', {
|
35531 |
blockModel: Module.ImageBlockModel,
|
35532 |
blockView: Module.ImageBlockView
|
@@ -35557,7 +35595,7 @@ webpackJsonp([4],{
|
|
35557 |
__webpack_require__(278),
|
35558 |
__webpack_require__(273),
|
35559 |
__webpack_require__(274)
|
35560 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, _, jQuery, MailPoet) {
|
35561 |
|
35562 |
'use strict';
|
35563 |
|
@@ -35565,7 +35603,7 @@ webpackJsonp([4],{
|
|
35565 |
base = BaseBlock;
|
35566 |
|
35567 |
Module.DividerBlockModel = base.BlockModel.extend({
|
35568 |
-
defaults: function() {
|
35569 |
return this._getDefaults({
|
35570 |
type: 'divider',
|
35571 |
styles: {
|
@@ -35583,13 +35621,13 @@ webpackJsonp([4],{
|
|
35583 |
|
35584 |
Module.DividerBlockView = base.BlockView.extend({
|
35585 |
className: 'mailpoet_block mailpoet_divider_block mailpoet_droppable_block',
|
35586 |
-
getTemplate: function() { return window.templates.dividerBlock; },
|
35587 |
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
35588 |
behaviors: _.defaults({
|
35589 |
ResizableBehavior: {
|
35590 |
elementSelector: '.mailpoet_content',
|
35591 |
resizeHandleSelector: '.mailpoet_resize_handle',
|
35592 |
-
transformationFunction: function(y) { return y / 2; },
|
35593 |
minLength: 0, // TODO: Move this number to editor configuration
|
35594 |
modelField: 'styles.block.padding'
|
35595 |
},
|
@@ -35597,45 +35635,45 @@ webpackJsonp([4],{
|
|
35597 |
ignoreFrom: '.mailpoet_resize_handle'
|
35598 |
}
|
35599 |
}, base.BlockView.prototype.behaviors),
|
35600 |
-
onDragSubstituteBy: function() { return Module.DividerWidgetView; },
|
35601 |
-
initialize: function() {
|
35602 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35603 |
var that = this;
|
35604 |
|
35605 |
// Listen for attempts to change all dividers in one go
|
35606 |
-
this._replaceDividerHandler = function(data) { that.model.set(data); that.model.trigger('applyToAll'); };
|
35607 |
App.getChannel().on('replaceAllDividers', this._replaceDividerHandler);
|
35608 |
|
35609 |
this.listenTo(this.model, 'change:src change:styles.block.backgroundColor change:styles.block.borderStyle change:styles.block.borderWidth change:styles.block.borderColor applyToAll', this.render);
|
35610 |
this.listenTo(this.model, 'change:styles.block.padding', this.changePadding);
|
35611 |
},
|
35612 |
-
templateContext: function() {
|
35613 |
return _.extend({
|
35614 |
-
totalHeight: parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px'
|
35615 |
}, base.BlockView.prototype.templateContext.apply(this));
|
35616 |
},
|
35617 |
-
onRender: function() {
|
35618 |
this.toolsView = new Module.DividerBlockToolsView({ model: this.model });
|
35619 |
this.showChildView('toolsRegion', this.toolsView);
|
35620 |
},
|
35621 |
-
onBeforeDestroy: function() {
|
35622 |
App.getChannel().off('replaceAllDividers', this._replaceDividerHandler);
|
35623 |
this.stopListening(this.model);
|
35624 |
},
|
35625 |
-
changePadding: function() {
|
35626 |
this.$('.mailpoet_content').css('padding-top', this.model.get('styles.block.padding'));
|
35627 |
this.$('.mailpoet_content').css('padding-bottom', this.model.get('styles.block.padding'));
|
35628 |
-
this.$('.mailpoet_resize_handle_text').text(parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px');
|
35629 |
}
|
35630 |
});
|
35631 |
|
35632 |
Module.DividerBlockToolsView = base.BlockToolsView.extend({
|
35633 |
-
getSettingsView: function() { return Module.DividerBlockSettingsView; }
|
35634 |
});
|
35635 |
|
35636 |
Module.DividerBlockSettingsView = base.BlockSettingsView.extend({
|
35637 |
-
getTemplate: function() { return window.templates.dividerBlockSettings; },
|
35638 |
-
events: function() {
|
35639 |
return {
|
35640 |
'click .mailpoet_field_divider_style': 'changeStyle',
|
35641 |
|
@@ -35649,47 +35687,47 @@ webpackJsonp([4],{
|
|
35649 |
'click .mailpoet_done_editing': 'close'
|
35650 |
};
|
35651 |
},
|
35652 |
-
modelEvents: function() {
|
35653 |
return {
|
35654 |
'change:styles.block.borderColor': 'repaintDividerStyleOptions'
|
35655 |
};
|
35656 |
},
|
35657 |
-
templateContext: function() {
|
35658 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
35659 |
availableStyles: App.getAvailableStyles().toJSON(),
|
35660 |
renderOptions: this.renderOptions
|
35661 |
});
|
35662 |
},
|
35663 |
-
changeStyle: function(event) {
|
35664 |
var style = jQuery(event.currentTarget).data('style');
|
35665 |
this.model.set('styles.block.borderStyle', style);
|
35666 |
this.$('.mailpoet_field_divider_style').removeClass('mailpoet_active_divider_style');
|
35667 |
this.$('.mailpoet_field_divider_style[data-style="' + style + '"]').addClass('mailpoet_active_divider_style');
|
35668 |
},
|
35669 |
-
repaintDividerStyleOptions: function() {
|
35670 |
this.$('.mailpoet_field_divider_style > div').css('border-top-color', this.model.get('styles.block.borderColor'));
|
35671 |
},
|
35672 |
-
applyToAll: function(event) {
|
35673 |
App.getChannel().trigger('replaceAllDividers', this.model.toJSON());
|
35674 |
},
|
35675 |
-
updateValueAndCall: function(fieldToUpdate, callable, event) {
|
35676 |
this.$(fieldToUpdate).val(jQuery(event.target).val());
|
35677 |
callable(event);
|
35678 |
}
|
35679 |
});
|
35680 |
|
35681 |
Module.DividerWidgetView = base.WidgetView.extend({
|
35682 |
-
getTemplate: function() { return window.templates.dividerInsertion; },
|
35683 |
behaviors: {
|
35684 |
DraggableBehavior: {
|
35685 |
cloneOriginal: true,
|
35686 |
-
drop: function() {
|
35687 |
return new Module.DividerBlockModel();
|
35688 |
}
|
35689 |
}
|
35690 |
}
|
35691 |
});
|
35692 |
-
App.on('before:start', function(App, options) {
|
35693 |
App.registerBlockType('divider', {
|
35694 |
blockModel: Module.DividerBlockModel,
|
35695 |
blockView: Module.DividerBlockView
|
@@ -35719,7 +35757,7 @@ webpackJsonp([4],{
|
|
35719 |
__webpack_require__(595),
|
35720 |
__webpack_require__(278),
|
35721 |
__webpack_require__(274)
|
35722 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, _, MailPoet) {
|
35723 |
|
35724 |
'use strict';
|
35725 |
|
@@ -35727,7 +35765,7 @@ webpackJsonp([4],{
|
|
35727 |
base = BaseBlock;
|
35728 |
|
35729 |
Module.TextBlockModel = base.BlockModel.extend({
|
35730 |
-
defaults: function() {
|
35731 |
return this._getDefaults({
|
35732 |
type: 'text',
|
35733 |
text: 'Edit this to insert text'
|
@@ -35737,7 +35775,7 @@ webpackJsonp([4],{
|
|
35737 |
|
35738 |
Module.TextBlockView = base.BlockView.extend({
|
35739 |
className: 'mailpoet_block mailpoet_text_block mailpoet_droppable_block',
|
35740 |
-
getTemplate: function() { return window.templates.textBlock; },
|
35741 |
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), // Prevent rerendering on model change due to text editor redrawing
|
35742 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35743 |
TextEditorBehavior: {
|
@@ -35747,7 +35785,7 @@ webpackJsonp([4],{
|
|
35747 |
invalidElements: 'script',
|
35748 |
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
|
35749 |
plugins: 'link lists code textcolor colorpicker mailpoet_shortcodes paste',
|
35750 |
-
configurationFilter: function(originalSettings) {
|
35751 |
return _.extend({}, originalSettings, {
|
35752 |
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
35753 |
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
@@ -35755,7 +35793,7 @@ webpackJsonp([4],{
|
|
35755 |
}
|
35756 |
}
|
35757 |
}),
|
35758 |
-
initialize: function(options) {
|
35759 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35760 |
|
35761 |
this.renderOptions = _.defaults(options.renderOptions || {}, {
|
@@ -35764,8 +35802,8 @@ webpackJsonp([4],{
|
|
35764 |
|
35765 |
this.disableTextEditor = this.renderOptions.disableTextEditor;
|
35766 |
},
|
35767 |
-
onDragSubstituteBy: function() { return Module.TextWidgetView; },
|
35768 |
-
onRender: function() {
|
35769 |
this.toolsView = new Module.TextBlockToolsView({
|
35770 |
model: this.model,
|
35771 |
tools: {
|
@@ -35774,40 +35812,40 @@ webpackJsonp([4],{
|
|
35774 |
});
|
35775 |
this.showChildView('toolsRegion', this.toolsView);
|
35776 |
},
|
35777 |
-
onTextEditorChange: function(newContent) {
|
35778 |
this.model.set('text', newContent);
|
35779 |
},
|
35780 |
-
onTextEditorFocus: function() {
|
35781 |
this.disableDragging();
|
35782 |
this.disableShowingTools();
|
35783 |
},
|
35784 |
-
onTextEditorBlur: function() {
|
35785 |
this.enableDragging();
|
35786 |
this.enableShowingTools();
|
35787 |
}
|
35788 |
});
|
35789 |
|
35790 |
Module.TextBlockToolsView = base.BlockToolsView.extend({
|
35791 |
-
getSettingsView: function() { return Module.TextBlockSettingsView; }
|
35792 |
});
|
35793 |
|
35794 |
Module.TextBlockSettingsView = base.BlockSettingsView.extend({
|
35795 |
-
getTemplate: function() { return window.templates.textBlockSettings; }
|
35796 |
});
|
35797 |
|
35798 |
Module.TextWidgetView = base.WidgetView.extend({
|
35799 |
-
getTemplate: function() { return window.templates.textInsertion; },
|
35800 |
behaviors: {
|
35801 |
DraggableBehavior: {
|
35802 |
cloneOriginal: true,
|
35803 |
-
drop: function() {
|
35804 |
return new Module.TextBlockModel();
|
35805 |
}
|
35806 |
}
|
35807 |
}
|
35808 |
});
|
35809 |
|
35810 |
-
App.on('before:start', function(App, options) {
|
35811 |
App.registerBlockType('text', {
|
35812 |
blockModel: Module.TextBlockModel,
|
35813 |
blockView: Module.TextBlockView
|
@@ -35837,7 +35875,7 @@ webpackJsonp([4],{
|
|
35837 |
__webpack_require__(574),
|
35838 |
__webpack_require__(595),
|
35839 |
__webpack_require__(278)
|
35840 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, _) {
|
35841 |
|
35842 |
'use strict';
|
35843 |
|
@@ -35845,7 +35883,7 @@ webpackJsonp([4],{
|
|
35845 |
base = BaseBlock;
|
35846 |
|
35847 |
Module.SpacerBlockModel = base.BlockModel.extend({
|
35848 |
-
defaults: function() {
|
35849 |
return this._getDefaults({
|
35850 |
type: 'spacer',
|
35851 |
styles: {
|
@@ -35860,7 +35898,7 @@ webpackJsonp([4],{
|
|
35860 |
|
35861 |
Module.SpacerBlockView = base.BlockView.extend({
|
35862 |
className: 'mailpoet_block mailpoet_spacer_block mailpoet_droppable_block',
|
35863 |
-
getTemplate: function() { return window.templates.spacerBlock; },
|
35864 |
behaviors: _.defaults({
|
35865 |
ResizableBehavior: {
|
35866 |
elementSelector: '.mailpoet_spacer',
|
@@ -35873,33 +35911,33 @@ webpackJsonp([4],{
|
|
35873 |
}
|
35874 |
}, base.BlockView.prototype.behaviors),
|
35875 |
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
35876 |
-
onDragSubstituteBy: function() { return Module.SpacerWidgetView; },
|
35877 |
-
initialize: function() {
|
35878 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35879 |
|
35880 |
this.listenTo(this.model, 'change:styles.block.backgroundColor', this.render);
|
35881 |
this.listenTo(this.model, 'change:styles.block.height', this.changeHeight);
|
35882 |
},
|
35883 |
-
onRender: function() {
|
35884 |
this.toolsView = new Module.SpacerBlockToolsView({ model: this.model });
|
35885 |
this.showChildView('toolsRegion', this.toolsView);
|
35886 |
},
|
35887 |
-
changeHeight: function() {
|
35888 |
this.$('.mailpoet_spacer').css('height', this.model.get('styles.block.height'));
|
35889 |
this.$('.mailpoet_resize_handle_text').text(this.model.get('styles.block.height'));
|
35890 |
},
|
35891 |
-
onBeforeDestroy: function() {
|
35892 |
this.stopListening(this.model);
|
35893 |
}
|
35894 |
});
|
35895 |
|
35896 |
Module.SpacerBlockToolsView = base.BlockToolsView.extend({
|
35897 |
-
getSettingsView: function() { return Module.SpacerBlockSettingsView; }
|
35898 |
});
|
35899 |
|
35900 |
Module.SpacerBlockSettingsView = base.BlockSettingsView.extend({
|
35901 |
-
getTemplate: function() { return window.templates.spacerBlockSettings; },
|
35902 |
-
events: function() {
|
35903 |
return {
|
35904 |
'change .mailpoet_field_spacer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
35905 |
'click .mailpoet_done_editing': 'close'
|
@@ -35908,18 +35946,18 @@ webpackJsonp([4],{
|
|
35908 |
});
|
35909 |
|
35910 |
Module.SpacerWidgetView = base.WidgetView.extend({
|
35911 |
-
getTemplate: function() { return window.templates.spacerInsertion; },
|
35912 |
behaviors: {
|
35913 |
DraggableBehavior: {
|
35914 |
cloneOriginal: true,
|
35915 |
-
drop: function() {
|
35916 |
return new Module.SpacerBlockModel();
|
35917 |
}
|
35918 |
}
|
35919 |
}
|
35920 |
});
|
35921 |
|
35922 |
-
App.on('before:start', function(App, options) {
|
35923 |
App.registerBlockType('spacer', {
|
35924 |
blockModel: Module.SpacerBlockModel,
|
35925 |
blockView: Module.SpacerBlockView
|
@@ -35949,7 +35987,7 @@ webpackJsonp([4],{
|
|
35949 |
__webpack_require__(595),
|
35950 |
__webpack_require__(278),
|
35951 |
__webpack_require__(274)
|
35952 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, _, MailPoet) {
|
35953 |
|
35954 |
'use strict';
|
35955 |
|
@@ -35957,7 +35995,7 @@ webpackJsonp([4],{
|
|
35957 |
base = BaseBlock;
|
35958 |
|
35959 |
Module.FooterBlockModel = base.BlockModel.extend({
|
35960 |
-
defaults: function() {
|
35961 |
return this._getDefaults({
|
35962 |
type: 'footer',
|
35963 |
text: '<a href="[link:subscription_unsubscribe_url]">Unsubscribe</a> | <a href="[link:subscription_manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>',
|
@@ -35982,13 +36020,13 @@ webpackJsonp([4],{
|
|
35982 |
|
35983 |
Module.FooterBlockView = base.BlockView.extend({
|
35984 |
className: 'mailpoet_block mailpoet_footer_block mailpoet_droppable_block',
|
35985 |
-
getTemplate: function() { return window.templates.footerBlock; },
|
35986 |
modelEvents: _.extend({
|
35987 |
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
|
35988 |
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
|
35989 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35990 |
TextEditorBehavior: {
|
35991 |
-
configurationFilter: function(originalSettings) {
|
35992 |
return _.extend({}, originalSettings, {
|
35993 |
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
35994 |
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
@@ -35996,37 +36034,37 @@ webpackJsonp([4],{
|
|
35996 |
}
|
35997 |
}
|
35998 |
}),
|
35999 |
-
onDragSubstituteBy: function() { return Module.FooterWidgetView; },
|
36000 |
-
onRender: function() {
|
36001 |
this.toolsView = new Module.FooterBlockToolsView({ model: this.model });
|
36002 |
this.showChildView('toolsRegion', this.toolsView);
|
36003 |
},
|
36004 |
-
onTextEditorChange: function(newContent) {
|
36005 |
this.model.set('text', newContent);
|
36006 |
},
|
36007 |
-
onTextEditorFocus: function() {
|
36008 |
this.disableDragging();
|
36009 |
this.disableShowingTools();
|
36010 |
},
|
36011 |
-
onTextEditorBlur: function() {
|
36012 |
this.enableDragging();
|
36013 |
this.enableShowingTools();
|
36014 |
}
|
36015 |
});
|
36016 |
|
36017 |
Module.FooterBlockToolsView = base.BlockToolsView.extend({
|
36018 |
-
getSettingsView: function() { return Module.FooterBlockSettingsView; }
|
36019 |
});
|
36020 |
|
36021 |
Module.FooterBlockSettingsView = base.BlockSettingsView.extend({
|
36022 |
-
getTemplate: function() { return window.templates.footerBlockSettings; },
|
36023 |
-
events: function() {
|
36024 |
return {
|
36025 |
'change .mailpoet_field_footer_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
|
36026 |
'change .mailpoet_field_footer_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
|
36027 |
'change .mailpoet_field_footer_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
|
36028 |
'change #mailpoet_field_footer_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
|
36029 |
-
'change #mailpoet_field_footer_link_underline': function(event) {
|
36030 |
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
36031 |
},
|
36032 |
'change .mailpoet_field_footer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
@@ -36034,7 +36072,7 @@ webpackJsonp([4],{
|
|
36034 |
'click .mailpoet_done_editing': 'close'
|
36035 |
};
|
36036 |
},
|
36037 |
-
templateContext: function() {
|
36038 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
36039 |
availableStyles: App.getAvailableStyles().toJSON()
|
36040 |
});
|
@@ -36042,18 +36080,18 @@ webpackJsonp([4],{
|
|
36042 |
});
|
36043 |
|
36044 |
Module.FooterWidgetView = base.WidgetView.extend({
|
36045 |
-
getTemplate: function() { return window.templates.footerInsertion; },
|
36046 |
behaviors: {
|
36047 |
DraggableBehavior: {
|
36048 |
cloneOriginal: true,
|
36049 |
-
drop: function() {
|
36050 |
return new Module.FooterBlockModel();
|
36051 |
}
|
36052 |
}
|
36053 |
}
|
36054 |
});
|
36055 |
|
36056 |
-
App.on('before:start', function(App, options) {
|
36057 |
App.registerBlockType('footer', {
|
36058 |
blockModel: Module.FooterBlockModel,
|
36059 |
blockView: Module.FooterBlockView
|
@@ -36083,7 +36121,7 @@ webpackJsonp([4],{
|
|
36083 |
__webpack_require__(595),
|
36084 |
__webpack_require__(278),
|
36085 |
__webpack_require__(274)
|
36086 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, _, MailPoet) {
|
36087 |
|
36088 |
'use strict';
|
36089 |
|
@@ -36091,7 +36129,7 @@ webpackJsonp([4],{
|
|
36091 |
base = BaseBlock;
|
36092 |
|
36093 |
Module.HeaderBlockModel = base.BlockModel.extend({
|
36094 |
-
defaults: function() {
|
36095 |
return this._getDefaults({
|
36096 |
type: 'header',
|
36097 |
text: 'Display problems? <a href="[link:newsletter_view_in_browser_url]">View it in your browser</a>',
|
@@ -36116,13 +36154,13 @@ webpackJsonp([4],{
|
|
36116 |
|
36117 |
Module.HeaderBlockView = base.BlockView.extend({
|
36118 |
className: 'mailpoet_block mailpoet_header_block mailpoet_droppable_block',
|
36119 |
-
getTemplate: function() { return window.templates.headerBlock; },
|
36120 |
modelEvents: _.extend({
|
36121 |
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
|
36122 |
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
|
36123 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
36124 |
TextEditorBehavior: {
|
36125 |
-
configurationFilter: function(originalSettings) {
|
36126 |
return _.extend({}, originalSettings, {
|
36127 |
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
36128 |
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
@@ -36130,37 +36168,37 @@ webpackJsonp([4],{
|
|
36130 |
}
|
36131 |
}
|
36132 |
}),
|
36133 |
-
onDragSubstituteBy: function() { return Module.HeaderWidgetView; },
|
36134 |
-
onRender: function() {
|
36135 |
this.toolsView = new Module.HeaderBlockToolsView({ model: this.model });
|
36136 |
this.showChildView('toolsRegion', this.toolsView);
|
36137 |
},
|
36138 |
-
onTextEditorChange: function(newContent) {
|
36139 |
this.model.set('text', newContent);
|
36140 |
},
|
36141 |
-
onTextEditorFocus: function() {
|
36142 |
this.disableDragging();
|
36143 |
this.disableShowingTools();
|
36144 |
},
|
36145 |
-
onTextEditorBlur: function() {
|
36146 |
this.enableDragging();
|
36147 |
this.enableShowingTools();
|
36148 |
}
|
36149 |
});
|
36150 |
|
36151 |
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
|
36152 |
-
getSettingsView: function() { return Module.HeaderBlockSettingsView; }
|
36153 |
});
|
36154 |
|
36155 |
Module.HeaderBlockSettingsView = base.BlockSettingsView.extend({
|
36156 |
-
getTemplate: function() { return window.templates.headerBlockSettings; },
|
36157 |
-
events: function() {
|
36158 |
return {
|
36159 |
'change .mailpoet_field_header_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
|
36160 |
'change .mailpoet_field_header_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
|
36161 |
'change .mailpoet_field_header_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
|
36162 |
'change #mailpoet_field_header_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
|
36163 |
-
'change #mailpoet_field_header_link_underline': function(event) {
|
36164 |
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
36165 |
},
|
36166 |
'change .mailpoet_field_header_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
@@ -36168,7 +36206,7 @@ webpackJsonp([4],{
|
|
36168 |
'click .mailpoet_done_editing': 'close'
|
36169 |
};
|
36170 |
},
|
36171 |
-
templateContext: function() {
|
36172 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
36173 |
availableStyles: App.getAvailableStyles().toJSON()
|
36174 |
});
|
@@ -36176,18 +36214,18 @@ webpackJsonp([4],{
|
|
36176 |
});
|
36177 |
|
36178 |
Module.HeaderWidgetView = base.WidgetView.extend({
|
36179 |
-
getTemplate: function() { return window.templates.headerInsertion; },
|
36180 |
behaviors: {
|
36181 |
DraggableBehavior: {
|
36182 |
cloneOriginal: true,
|
36183 |
-
drop: function() {
|
36184 |
return new Module.HeaderBlockModel();
|
36185 |
}
|
36186 |
}
|
36187 |
}
|
36188 |
});
|
36189 |
|
36190 |
-
App.on('before:start', function(App, options) {
|
36191 |
App.registerBlockType('header', {
|
36192 |
blockModel: Module.HeaderBlockModel,
|
36193 |
blockView: Module.HeaderBlockView
|
@@ -36227,7 +36265,7 @@ webpackJsonp([4],{
|
|
36227 |
__webpack_require__(564),
|
36228 |
__webpack_require__(278),
|
36229 |
__webpack_require__(273)
|
36230 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
36231 |
App,
|
36232 |
BaseBlock,
|
36233 |
ButtonBlock,
|
@@ -36245,7 +36283,7 @@ webpackJsonp([4],{
|
|
36245 |
base = BaseBlock;
|
36246 |
|
36247 |
Module.ALCSupervisor = SuperModel.extend({
|
36248 |
-
initialize: function() {
|
36249 |
var DELAY_REFRESH_FOR_MS = 500;
|
36250 |
this.listenTo(
|
36251 |
App.getChannel(),
|
@@ -36253,13 +36291,13 @@ webpackJsonp([4],{
|
|
36253 |
_.debounce(this.refresh, DELAY_REFRESH_FOR_MS)
|
36254 |
);
|
36255 |
},
|
36256 |
-
refresh: function() {
|
36257 |
-
var models = App.findModels(function(model) {
|
36258 |
return model.get('type') === 'automatedLatestContent';
|
36259 |
}) || [];
|
36260 |
|
36261 |
if (models.length === 0) return;
|
36262 |
-
var blocks = _.map(models, function(model) {
|
36263 |
return model.toJSON();
|
36264 |
});
|
36265 |
|
@@ -36267,10 +36305,10 @@ webpackJsonp([4],{
|
|
36267 |
blocks: blocks
|
36268 |
}).then(_.partial(this.refreshBlocks, models));
|
36269 |
},
|
36270 |
-
refreshBlocks: function(models, renderedBlocks) {
|
36271 |
_.each(
|
36272 |
_.zip(models, renderedBlocks),
|
36273 |
-
function(args) {
|
36274 |
var model = args[0],
|
36275 |
contents = args[1];
|
36276 |
model.trigger('refreshPosts', contents);
|
@@ -36281,7 +36319,7 @@ webpackJsonp([4],{
|
|
36281 |
|
36282 |
Module.AutomatedLatestContentBlockModel = base.BlockModel.extend({
|
36283 |
stale: ['_container'],
|
36284 |
-
defaults: function() {
|
36285 |
return this._getDefaults({
|
36286 |
type: 'automatedLatestContent',
|
36287 |
amount: '5',
|
@@ -36294,7 +36332,7 @@ webpackJsonp([4],{
|
|
36294 |
titleIsLink: false, // false|true
|
36295 |
imageFullWidth: false, // true|false
|
36296 |
featuredImagePosition: 'belowTitle', // 'aboveTitle'|'belowTitle'|'none'
|
36297 |
-
//imageAlignment: 'centerPadded', // 'centerFull'|'centerPadded'|'left'|'right'|'alternate'|'none'
|
36298 |
showAuthor: 'no', // 'no'|'aboveText'|'belowText'
|
36299 |
authorPrecededBy: 'Author:',
|
36300 |
showCategories: 'no', // 'no'|'aboveText'|'belowText'
|
@@ -36311,14 +36349,14 @@ webpackJsonp([4],{
|
|
36311 |
_container: new (App.getBlockTypeModel('container'))()
|
36312 |
}, App.getConfig().get('blockDefaults.automatedLatestContent'));
|
36313 |
},
|
36314 |
-
relations: function() {
|
36315 |
return {
|
36316 |
readMoreButton: App.getBlockTypeModel('button'),
|
36317 |
divider: App.getBlockTypeModel('divider'),
|
36318 |
_container: App.getBlockTypeModel('container')
|
36319 |
};
|
36320 |
},
|
36321 |
-
initialize: function() {
|
36322 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
36323 |
this.on('change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider', this._scheduleFetchPosts, this);
|
36324 |
this.listenTo(this.get('readMoreButton'), 'change', this._scheduleFetchPosts);
|
@@ -36326,27 +36364,27 @@ webpackJsonp([4],{
|
|
36326 |
this.on('add remove update reset', this._scheduleFetchPosts);
|
36327 |
this.on('refreshPosts', this.updatePosts, this);
|
36328 |
},
|
36329 |
-
updatePosts: function(posts) {
|
36330 |
-
this.get('_container.blocks').reset(posts, {parse: true});
|
36331 |
},
|
36332 |
/**
|
36333 |
* Batch more changes during a specific time, instead of fetching
|
36334 |
* ALC posts on each model change
|
36335 |
*/
|
36336 |
-
_scheduleFetchPosts: function() {
|
36337 |
App.getChannel().trigger('automatedLatestContentRefresh');
|
36338 |
}
|
36339 |
});
|
36340 |
|
36341 |
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
|
36342 |
className: 'mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block',
|
36343 |
-
initialize: function() {
|
36344 |
function replaceButtonStylesHandler(data) {
|
36345 |
-
this.model.set({readMoreButton: data});
|
36346 |
}
|
36347 |
App.getChannel().on('replaceAllButtonStyles', replaceButtonStylesHandler.bind(this));
|
36348 |
},
|
36349 |
-
getTemplate: function() { return window.templates.automatedLatestContentBlock; },
|
36350 |
regions: {
|
36351 |
toolsRegion: '.mailpoet_tools',
|
36352 |
postsRegion: '.mailpoet_automated_latest_content_block_posts'
|
@@ -36359,8 +36397,8 @@ webpackJsonp([4],{
|
|
36359 |
events: _.extend(base.BlockView.prototype.events, {
|
36360 |
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
|
36361 |
}),
|
36362 |
-
onDragSubstituteBy: function() { return Module.AutomatedLatestContentWidgetView; },
|
36363 |
-
onRender: function() {
|
36364 |
var ContainerView = App.getBlockTypeView('container'),
|
36365 |
renderOptions = {
|
36366 |
disableTextEditor: true,
|
@@ -36374,13 +36412,13 @@ webpackJsonp([4],{
|
|
36374 |
});
|
36375 |
|
36376 |
Module.AutomatedLatestContentBlockToolsView = base.BlockToolsView.extend({
|
36377 |
-
getSettingsView: function() { return Module.AutomatedLatestContentBlockSettingsView; }
|
36378 |
});
|
36379 |
|
36380 |
// Sidebar view container
|
36381 |
Module.AutomatedLatestContentBlockSettingsView = base.BlockSettingsView.extend({
|
36382 |
-
getTemplate: function() { return window.templates.automatedLatestContentBlockSettings; },
|
36383 |
-
events: function() {
|
36384 |
return {
|
36385 |
'click .mailpoet_automated_latest_content_hide_display_options': 'toggleDisplayOptions',
|
36386 |
'click .mailpoet_automated_latest_content_show_display_options': 'toggleDisplayOptions',
|
@@ -36406,7 +36444,7 @@ webpackJsonp([4],{
|
|
36406 |
'click .mailpoet_done_editing': 'close'
|
36407 |
};
|
36408 |
},
|
36409 |
-
onRender: function() {
|
36410 |
var that = this;
|
36411 |
|
36412 |
// Dynamically update available post types
|
@@ -36422,17 +36460,17 @@ webpackJsonp([4],{
|
|
36422 |
term: params.term
|
36423 |
};
|
36424 |
},
|
36425 |
-
transport: function(options, success, failure) {
|
36426 |
var taxonomies;
|
36427 |
var promise = CommunicationComponent.getTaxonomies(
|
36428 |
that.model.get('contentType')
|
36429 |
-
).then(function(tax) {
|
36430 |
taxonomies = tax;
|
36431 |
// Fetch available terms based on the list of taxonomies already fetched
|
36432 |
var promise = CommunicationComponent.getTerms({
|
36433 |
search: options.data.term,
|
36434 |
taxonomies: _.keys(taxonomies)
|
36435 |
-
}).then(function(terms) {
|
36436 |
return {
|
36437 |
taxonomies: taxonomies,
|
36438 |
terms: terms
|
@@ -36445,12 +36483,12 @@ webpackJsonp([4],{
|
|
36445 |
promise.fail(failure);
|
36446 |
return promise;
|
36447 |
},
|
36448 |
-
processResults: function(data) {
|
36449 |
// Transform taxonomies and terms into select2 compatible format
|
36450 |
return {
|
36451 |
results: _.map(
|
36452 |
data.terms,
|
36453 |
-
function(item) {
|
36454 |
return _.defaults({
|
36455 |
text: data.taxonomies[item.taxonomy].labels.singular_name + ': ' + item.name,
|
36456 |
id: item.term_id
|
@@ -36461,21 +36499,21 @@ webpackJsonp([4],{
|
|
36461 |
}
|
36462 |
}
|
36463 |
}).on({
|
36464 |
-
'select2:select': function(event) {
|
36465 |
var terms = that.model.get('terms');
|
36466 |
terms.add(event.params.data);
|
36467 |
// Reset whole model in order for change events to propagate properly
|
36468 |
that.model.set('terms', terms.toJSON());
|
36469 |
},
|
36470 |
-
'select2:unselect': function(event) {
|
36471 |
var terms = that.model.get('terms');
|
36472 |
terms.remove(event.params.data);
|
36473 |
// Reset whole model in order for change events to propagate properly
|
36474 |
that.model.set('terms', terms.toJSON());
|
36475 |
}
|
36476 |
-
}).trigger(
|
36477 |
},
|
36478 |
-
toggleDisplayOptions: function(event) {
|
36479 |
var el = this.$('.mailpoet_automated_latest_content_display_options'),
|
36480 |
showControl = this.$('.mailpoet_automated_latest_content_show_display_options');
|
36481 |
if (el.hasClass('mailpoet_closed')) {
|
@@ -36486,7 +36524,7 @@ webpackJsonp([4],{
|
|
36486 |
showControl.removeClass('mailpoet_hidden');
|
36487 |
}
|
36488 |
},
|
36489 |
-
showButtonSettings: function(event) {
|
36490 |
var buttonModule = ButtonBlock;
|
36491 |
(new buttonModule.ButtonBlockSettingsView({
|
36492 |
model: this.model.get('readMoreButton'),
|
@@ -36497,7 +36535,7 @@ webpackJsonp([4],{
|
|
36497 |
}
|
36498 |
})).render();
|
36499 |
},
|
36500 |
-
showDividerSettings: function(event) {
|
36501 |
var dividerModule = DividerBlock;
|
36502 |
(new dividerModule.DividerBlockSettingsView({
|
36503 |
model: this.model.get('divider'),
|
@@ -36507,7 +36545,7 @@ webpackJsonp([4],{
|
|
36507 |
}
|
36508 |
})).render();
|
36509 |
},
|
36510 |
-
changeReadMoreType: function(event) {
|
36511 |
var value = jQuery(event.target).val();
|
36512 |
if (value == 'link') {
|
36513 |
this.$('.mailpoet_automated_latest_content_read_more_text').removeClass('mailpoet_hidden');
|
@@ -36518,7 +36556,7 @@ webpackJsonp([4],{
|
|
36518 |
}
|
36519 |
this.changeField('readMoreType', event);
|
36520 |
},
|
36521 |
-
changeDisplayType: function(event) {
|
36522 |
var value = jQuery(event.target).val();
|
36523 |
|
36524 |
if (value == 'titleOnly') {
|
@@ -36545,7 +36583,7 @@ webpackJsonp([4],{
|
|
36545 |
}
|
36546 |
this.changeField('displayType', event);
|
36547 |
},
|
36548 |
-
changeTitleFormat: function(event) {
|
36549 |
var value = jQuery(event.target).val();
|
36550 |
if (value == 'ul') {
|
36551 |
this.$('.mailpoet_automated_latest_content_non_title_list_options').addClass('mailpoet_hidden');
|
@@ -36559,12 +36597,12 @@ webpackJsonp([4],{
|
|
36559 |
}
|
36560 |
this.changeField('titleFormat', event);
|
36561 |
},
|
36562 |
-
_updateContentTypes: function(postTypes) {
|
36563 |
var select = this.$('.mailpoet_automated_latest_content_content_type'),
|
36564 |
selectedValue = this.model.get('contentType');
|
36565 |
|
36566 |
select.find('option').remove();
|
36567 |
-
_.each(postTypes, function(type) {
|
36568 |
select.append(jQuery('<option>', {
|
36569 |
value: type.name,
|
36570 |
text: type.label
|
@@ -36575,21 +36613,21 @@ webpackJsonp([4],{
|
|
36575 |
});
|
36576 |
|
36577 |
Module.AutomatedLatestContentWidgetView = base.WidgetView.extend({
|
36578 |
-
getTemplate: function() { return window.templates.automatedLatestContentInsertion; },
|
36579 |
behaviors: {
|
36580 |
DraggableBehavior: {
|
36581 |
cloneOriginal: true,
|
36582 |
-
drop: function() {
|
36583 |
return new Module.AutomatedLatestContentBlockModel({}, { parse: true });
|
36584 |
},
|
36585 |
-
onDrop: function(options) {
|
36586 |
options.droppedView.triggerMethod('showSettings');
|
36587 |
}
|
36588 |
}
|
36589 |
}
|
36590 |
});
|
36591 |
|
36592 |
-
App.on('before:start', function(App, options) {
|
36593 |
App.registerBlockType('automatedLatestContent', {
|
36594 |
blockModel: Module.AutomatedLatestContentBlockModel,
|
36595 |
blockView: Module.AutomatedLatestContentBlockView
|
@@ -36602,7 +36640,7 @@ webpackJsonp([4],{
|
|
36602 |
});
|
36603 |
});
|
36604 |
|
36605 |
-
App.on('start', function(App, options) {
|
36606 |
var Application = App;
|
36607 |
Application._ALCSupervisor = new Module.ALCSupervisor();
|
36608 |
Application._ALCSupervisor.refresh();
|
@@ -36642,7 +36680,7 @@ webpackJsonp([4],{
|
|
36642 |
__webpack_require__(597),
|
36643 |
__webpack_require__(599),
|
36644 |
__webpack_require__(287)
|
36645 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
36646 |
Backbone,
|
36647 |
Marionette,
|
36648 |
Radio,
|
@@ -36663,7 +36701,7 @@ webpackJsonp([4],{
|
|
36663 |
|
36664 |
Module.PostsBlockModel = base.BlockModel.extend({
|
36665 |
stale: ['_selectedPosts', '_availablePosts', '_transformedPosts'],
|
36666 |
-
defaults: function() {
|
36667 |
return this._getDefaults({
|
36668 |
type: 'posts',
|
36669 |
amount: '10',
|
@@ -36679,7 +36717,7 @@ webpackJsonp([4],{
|
|
36679 |
titleIsLink: false, // false|true
|
36680 |
imageFullWidth: false, // true|false
|
36681 |
featuredImagePosition: 'belowTitle', // 'aboveTitle'|'belowTitle'|'none'
|
36682 |
-
//imageAlignment: 'centerPadded', // 'centerFull'|'centerPadded'|'left'|'right'|'alternate'|'none'
|
36683 |
showAuthor: 'no', // 'no'|'aboveText'|'belowText'
|
36684 |
authorPrecededBy: 'Author:',
|
36685 |
showCategories: 'no', // 'no'|'aboveText'|'belowText'
|
@@ -36698,7 +36736,7 @@ webpackJsonp([4],{
|
|
36698 |
_transformedPosts: new (App.getBlockTypeModel('container'))()
|
36699 |
}, App.getConfig().get('blockDefaults.posts'));
|
36700 |
},
|
36701 |
-
relations: function() {
|
36702 |
return {
|
36703 |
readMoreButton: App.getBlockTypeModel('button'),
|
36704 |
divider: App.getBlockTypeModel('divider'),
|
@@ -36707,7 +36745,7 @@ webpackJsonp([4],{
|
|
36707 |
_transformedPosts: App.getBlockTypeModel('container')
|
36708 |
};
|
36709 |
},
|
36710 |
-
initialize: function() {
|
36711 |
var that = this,
|
36712 |
POST_REFRESH_DELAY_MS = 500,
|
36713 |
refreshAvailablePosts = _.debounce(this.fetchAvailablePosts.bind(this), POST_REFRESH_DELAY_MS),
|
@@ -36727,39 +36765,39 @@ webpackJsonp([4],{
|
|
36727 |
|
36728 |
this.on('insertSelectedPosts', this._insertSelectedPosts, this);
|
36729 |
},
|
36730 |
-
fetchAvailablePosts: function() {
|
36731 |
var that = this;
|
36732 |
this.set('offset', 0);
|
36733 |
-
CommunicationComponent.getPosts(this.toJSON()).done(function(posts) {
|
36734 |
that.get('_availablePosts').reset(posts);
|
36735 |
that.get('_selectedPosts').reset(); // Empty out the collection
|
36736 |
that.trigger('change:_availablePosts');
|
36737 |
-
}).fail(function() {
|
36738 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchAvailablePosts'));
|
36739 |
});
|
36740 |
},
|
36741 |
-
_loadMorePosts: function() {
|
36742 |
var that = this,
|
36743 |
postCount = this.get('_availablePosts').length,
|
36744 |
nextOffset = this.get('offset') + Number(this.get('amount'));
|
36745 |
|
36746 |
-
if(postCount === 0 || postCount < nextOffset) {
|
36747 |
// No more posts to load
|
36748 |
return false;
|
36749 |
}
|
36750 |
this.set('offset', nextOffset);
|
36751 |
this.trigger('loadingMorePosts');
|
36752 |
|
36753 |
-
CommunicationComponent.getPosts(this.toJSON()).done(function(posts) {
|
36754 |
that.get('_availablePosts').add(posts);
|
36755 |
that.trigger('change:_availablePosts');
|
36756 |
-
}).fail(function() {
|
36757 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchAvailablePosts'));
|
36758 |
-
}).always(function() {
|
36759 |
that.trigger('morePostsLoaded');
|
36760 |
});
|
36761 |
},
|
36762 |
-
_refreshTransformedPosts: function() {
|
36763 |
var that = this,
|
36764 |
data = this.toJSON();
|
36765 |
|
@@ -36770,13 +36808,13 @@ webpackJsonp([4],{
|
|
36770 |
return;
|
36771 |
}
|
36772 |
|
36773 |
-
CommunicationComponent.getTransformedPosts(data).done(function(posts) {
|
36774 |
-
that.get('_transformedPosts').get('blocks').reset(posts, {parse: true});
|
36775 |
-
}).fail(function() {
|
36776 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
|
36777 |
});
|
36778 |
},
|
36779 |
-
_insertSelectedPosts: function() {
|
36780 |
var that = this,
|
36781 |
data = this.toJSON(),
|
36782 |
index = this.collection.indexOf(this),
|
@@ -36786,9 +36824,9 @@ webpackJsonp([4],{
|
|
36786 |
|
36787 |
if (data.posts.length === 0) return;
|
36788 |
|
36789 |
-
CommunicationComponent.getTransformedPosts(data).done(function(posts) {
|
36790 |
collection.add(posts, { at: index });
|
36791 |
-
}).fail(function() {
|
36792 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
|
36793 |
});
|
36794 |
}
|
@@ -36796,19 +36834,19 @@ webpackJsonp([4],{
|
|
36796 |
|
36797 |
Module.PostsBlockView = base.BlockView.extend({
|
36798 |
className: 'mailpoet_block mailpoet_posts_block mailpoet_droppable_block',
|
36799 |
-
getTemplate: function() { return window.templates.postsBlock; },
|
36800 |
modelEvents: {}, // Forcefully disable all events
|
36801 |
regions: _.extend({
|
36802 |
postsRegion: '.mailpoet_posts_block_posts'
|
36803 |
}, base.BlockView.prototype.regions),
|
36804 |
-
onDragSubstituteBy: function() { return Module.PostsWidgetView; },
|
36805 |
-
initialize: function() {
|
36806 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
36807 |
|
36808 |
this.toolsView = new Module.PostsBlockToolsView({ model: this.model });
|
36809 |
this.model.reply('blockView', this.notifyAboutSelf, this);
|
36810 |
},
|
36811 |
-
onRender: function() {
|
36812 |
if (!this.getRegion('toolsRegion').hasView()) {
|
36813 |
this.showChildView('toolsRegion', this.toolsView);
|
36814 |
}
|
@@ -36822,20 +36860,20 @@ webpackJsonp([4],{
|
|
36822 |
};
|
36823 |
this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_transformedPosts'), renderOptions: renderOptions }));
|
36824 |
},
|
36825 |
-
notifyAboutSelf: function() {
|
36826 |
return this;
|
36827 |
},
|
36828 |
-
onBeforeDestroy: function() {
|
36829 |
this.model.stopReplying('blockView', this.notifyAboutSelf, this);
|
36830 |
}
|
36831 |
});
|
36832 |
|
36833 |
Module.PostsBlockToolsView = base.BlockToolsView.extend({
|
36834 |
-
getSettingsView: function() { return Module.PostsBlockSettingsView; }
|
36835 |
});
|
36836 |
|
36837 |
Module.PostsBlockSettingsView = base.BlockSettingsView.extend({
|
36838 |
-
getTemplate: function() { return window.templates.postsBlockSettings; },
|
36839 |
regions: {
|
36840 |
selectionRegion: '.mailpoet_settings_posts_selection',
|
36841 |
displayOptionsRegion: '.mailpoet_settings_posts_display_options'
|
@@ -36845,17 +36883,17 @@ webpackJsonp([4],{
|
|
36845 |
'click .mailpoet_settings_posts_show_post_selection': 'switchToPostSelection',
|
36846 |
'click .mailpoet_settings_posts_insert_selected': 'insertPosts'
|
36847 |
},
|
36848 |
-
templateContext: function() {
|
36849 |
return {
|
36850 |
model: this.model.toJSON()
|
36851 |
};
|
36852 |
},
|
36853 |
-
initialize: function() {
|
36854 |
this.model.trigger('startEditing');
|
36855 |
this.selectionView = new PostSelectionSettingsView({ model: this.model });
|
36856 |
this.displayOptionsView = new PostsDisplayOptionsSettingsView({ model: this.model });
|
36857 |
},
|
36858 |
-
onRender: function() {
|
36859 |
var that = this,
|
36860 |
blockView = this.model.request('blockView');
|
36861 |
|
@@ -36867,7 +36905,7 @@ webpackJsonp([4],{
|
|
36867 |
template: '',
|
36868 |
position: 'right',
|
36869 |
width: App.getConfig().get('sidepanelWidth'),
|
36870 |
-
onCancel: function() {
|
36871 |
// Self destroy the block if the user closes settings modal
|
36872 |
that.model.destroy();
|
36873 |
}
|
@@ -36877,7 +36915,7 @@ webpackJsonp([4],{
|
|
36877 |
this.selectionView.triggerMethod('attach');
|
36878 |
this.displayOptionsView.triggerMethod('attach');
|
36879 |
},
|
36880 |
-
switchToDisplayOptions: function() {
|
36881 |
// Switch content view
|
36882 |
this.$('.mailpoet_settings_posts_selection').addClass('mailpoet_closed');
|
36883 |
this.$('.mailpoet_settings_posts_display_options').removeClass('mailpoet_closed');
|
@@ -36886,7 +36924,7 @@ webpackJsonp([4],{
|
|
36886 |
this.$('.mailpoet_settings_posts_show_display_options').addClass('mailpoet_hidden');
|
36887 |
this.$('.mailpoet_settings_posts_show_post_selection').removeClass('mailpoet_hidden');
|
36888 |
},
|
36889 |
-
switchToPostSelection: function() {
|
36890 |
// Switch content view
|
36891 |
this.$('.mailpoet_settings_posts_display_options').addClass('mailpoet_closed');
|
36892 |
this.$('.mailpoet_settings_posts_selection').removeClass('mailpoet_closed');
|
@@ -36895,7 +36933,7 @@ webpackJsonp([4],{
|
|
36895 |
this.$('.mailpoet_settings_posts_show_post_selection').addClass('mailpoet_hidden');
|
36896 |
this.$('.mailpoet_settings_posts_show_display_options').removeClass('mailpoet_hidden');
|
36897 |
},
|
36898 |
-
insertPosts: function() {
|
36899 |
this.model.trigger('insertSelectedPosts');
|
36900 |
this.model.destroy();
|
36901 |
this.close();
|
@@ -36904,22 +36942,22 @@ webpackJsonp([4],{
|
|
36904 |
|
36905 |
var PostsSelectionCollectionView = Marionette.CollectionView.extend({
|
36906 |
className: 'mailpoet_post_scroll_container',
|
36907 |
-
childView: function() { return SinglePostSelectionSettingsView; },
|
36908 |
-
emptyView: function() { return EmptyPostSelectionSettingsView; },
|
36909 |
-
childViewOptions: function() {
|
36910 |
return {
|
36911 |
blockModel: this.blockModel
|
36912 |
};
|
36913 |
},
|
36914 |
-
initialize: function(options) {
|
36915 |
this.blockModel = options.blockModel;
|
36916 |
},
|
36917 |
events: {
|
36918 |
scroll: 'onPostsScroll'
|
36919 |
},
|
36920 |
-
onPostsScroll: function(event) {
|
36921 |
var $postsBox = jQuery(event.target);
|
36922 |
-
if($postsBox.scrollTop() + $postsBox.innerHeight() >= $postsBox[0].scrollHeight){
|
36923 |
// Load more posts if scrolled to bottom
|
36924 |
this.blockModel.trigger('loadMorePosts');
|
36925 |
}
|
@@ -36927,11 +36965,11 @@ webpackJsonp([4],{
|
|
36927 |
});
|
36928 |
|
36929 |
var PostSelectionSettingsView = Marionette.View.extend({
|
36930 |
-
getTemplate: function() { return window.templates.postSelectionPostsBlockSettings; },
|
36931 |
regions: {
|
36932 |
posts: '.mailpoet_post_selection_container'
|
36933 |
},
|
36934 |
-
events: function() {
|
36935 |
return {
|
36936 |
'change .mailpoet_settings_posts_content_type': _.partial(this.changeField, 'contentType'),
|
36937 |
'change .mailpoet_posts_post_status': _.partial(this.changeField, 'postStatus'),
|
@@ -36939,20 +36977,20 @@ webpackJsonp([4],{
|
|
36939 |
};
|
36940 |
},
|
36941 |
modelEvents: {
|
36942 |
-
'change:offset': function(model, value) {
|
36943 |
// Scroll posts view to top if settings are changed
|
36944 |
if (value === 0) {
|
36945 |
this.$('.mailpoet_post_scroll_container').scrollTop(0);
|
36946 |
}
|
36947 |
},
|
36948 |
-
loadingMorePosts: function() {
|
36949 |
this.$('.mailpoet_post_selection_loading').css('visibility', 'visible');
|
36950 |
},
|
36951 |
-
morePostsLoaded: function() {
|
36952 |
this.$('.mailpoet_post_selection_loading').css('visibility', 'hidden');
|
36953 |
}
|
36954 |
},
|
36955 |
-
onRender: function() {
|
36956 |
// Dynamically update available post types
|
36957 |
CommunicationComponent.getPostTypes().done(_.bind(this._updateContentTypes, this));
|
36958 |
var postsView = new PostsSelectionCollectionView({
|
@@ -36962,7 +37000,7 @@ webpackJsonp([4],{
|
|
36962 |
|
36963 |
this.showChildView('posts', postsView);
|
36964 |
},
|
36965 |
-
onAttach: function() {
|
36966 |
var that = this;
|
36967 |
|
36968 |
this.$('.mailpoet_posts_categories_and_tags').select2({
|
@@ -36975,17 +37013,17 @@ webpackJsonp([4],{
|
|
36975 |
term: params.term
|
36976 |
};
|
36977 |
},
|
36978 |
-
transport: function(options, success, failure) {
|
36979 |
var taxonomies;
|
36980 |
var promise = CommunicationComponent.getTaxonomies(
|
36981 |
that.model.get('contentType')
|
36982 |
-
).then(function(tax) {
|
36983 |
taxonomies = tax;
|
36984 |
// Fetch available terms based on the list of taxonomies already fetched
|
36985 |
var promise = CommunicationComponent.getTerms({
|
36986 |
search: options.data.term,
|
36987 |
taxonomies: _.keys(taxonomies)
|
36988 |
-
}).then(function(terms) {
|
36989 |
return {
|
36990 |
taxonomies: taxonomies,
|
36991 |
terms: terms
|
@@ -36998,12 +37036,12 @@ webpackJsonp([4],{
|
|
36998 |
promise.fail(failure);
|
36999 |
return promise;
|
37000 |
},
|
37001 |
-
processResults: function(data) {
|
37002 |
// Transform taxonomies and terms into select2 compatible format
|
37003 |
return {
|
37004 |
results: _.map(
|
37005 |
data.terms,
|
37006 |
-
function(item) {
|
37007 |
return _.defaults({
|
37008 |
text: data.taxonomies[item.taxonomy].labels.singular_name + ': ' + item.name,
|
37009 |
id: item.term_id
|
@@ -37014,29 +37052,29 @@ webpackJsonp([4],{
|
|
37014 |
}
|
37015 |
}
|
37016 |
}).on({
|
37017 |
-
'select2:select': function(event) {
|
37018 |
var terms = that.model.get('terms');
|
37019 |
terms.add(event.params.data);
|
37020 |
// Reset whole model in order for change events to propagate properly
|
37021 |
that.model.set('terms', terms.toJSON());
|
37022 |
},
|
37023 |
-
'select2:unselect': function(event) {
|
37024 |
var terms = that.model.get('terms');
|
37025 |
terms.remove(event.params.data);
|
37026 |
// Reset whole model in order for change events to propagate properly
|
37027 |
that.model.set('terms', terms.toJSON());
|
37028 |
}
|
37029 |
-
}).trigger(
|
37030 |
},
|
37031 |
-
changeField: function(field, event) {
|
37032 |
this.model.set(field, jQuery(event.target).val());
|
37033 |
},
|
37034 |
-
_updateContentTypes: function(postTypes) {
|
37035 |
var select = this.$('.mailpoet_settings_posts_content_type'),
|
37036 |
selectedValue = this.model.get('contentType');
|
37037 |
|
37038 |
select.find('option').remove();
|
37039 |
-
_.each(postTypes, function(type) {
|
37040 |
select.append(jQuery('<option>', {
|
37041 |
value: type.name,
|
37042 |
text: type.label
|
@@ -37047,26 +37085,26 @@ webpackJsonp([4],{
|
|
37047 |
});
|
37048 |
|
37049 |
var EmptyPostSelectionSettingsView = Marionette.View.extend({
|
37050 |
-
getTemplate: function() { return window.templates.emptyPostPostsBlockSettings; }
|
37051 |
});
|
37052 |
|
37053 |
var SinglePostSelectionSettingsView = Marionette.View.extend({
|
37054 |
-
getTemplate: function() { return window.templates.singlePostPostsBlockSettings; },
|
37055 |
-
events: function() {
|
37056 |
return {
|
37057 |
'change .mailpoet_select_post_checkbox': 'postSelectionChange'
|
37058 |
};
|
37059 |
},
|
37060 |
-
templateContext: function() {
|
37061 |
return {
|
37062 |
model: this.model.toJSON(),
|
37063 |
index: this._index
|
37064 |
};
|
37065 |
},
|
37066 |
-
initialize: function(options) {
|
37067 |
this.blockModel = options.blockModel;
|
37068 |
},
|
37069 |
-
postSelectionChange: function(event) {
|
37070 |
var checkBox = jQuery(event.target),
|
37071 |
selectedPostsCollection = this.blockModel.get('_selectedPosts');
|
37072 |
if (checkBox.prop('checked')) {
|
@@ -37078,8 +37116,8 @@ webpackJsonp([4],{
|
|
37078 |
});
|
37079 |
|
37080 |
var PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({
|
37081 |
-
getTemplate: function() { return window.templates.displayOptionsPostsBlockSettings; },
|
37082 |
-
events: function() {
|
37083 |
return {
|
37084 |
'click .mailpoet_posts_select_button': 'showButtonSettings',
|
37085 |
'click .mailpoet_posts_select_divider': 'showDividerSettings',
|
@@ -37102,12 +37140,12 @@ webpackJsonp([4],{
|
|
37102 |
'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy')
|
37103 |
};
|
37104 |
},
|
37105 |
-
templateContext: function() {
|
37106 |
return {
|
37107 |
model: this.model.toJSON()
|
37108 |
};
|
37109 |
},
|
37110 |
-
showButtonSettings: function(event) {
|
37111 |
var buttonModule = ButtonBlock;
|
37112 |
(new buttonModule.ButtonBlockSettingsView({
|
37113 |
model: this.model.get('readMoreButton'),
|
@@ -37118,7 +37156,7 @@ webpackJsonp([4],{
|
|
37118 |
}
|
37119 |
})).render();
|
37120 |
},
|
37121 |
-
showDividerSettings: function(event) {
|
37122 |
var dividerModule = DividerBlock;
|
37123 |
(new dividerModule.DividerBlockSettingsView({
|
37124 |
model: this.model.get('divider'),
|
@@ -37128,7 +37166,7 @@ webpackJsonp([4],{
|
|
37128 |
}
|
37129 |
})).render();
|
37130 |
},
|
37131 |
-
changeReadMoreType: function(event) {
|
37132 |
var value = jQuery(event.target).val();
|
37133 |
if (value == 'link') {
|
37134 |
this.$('.mailpoet_posts_read_more_text').removeClass('mailpoet_hidden');
|
@@ -37139,7 +37177,7 @@ webpackJsonp([4],{
|
|
37139 |
}
|
37140 |
this.changeField('readMoreType', event);
|
37141 |
},
|
37142 |
-
changeDisplayType: function(event) {
|
37143 |
var value = jQuery(event.target).val();
|
37144 |
if (value == 'titleOnly') {
|
37145 |
this.$('.mailpoet_posts_title_as_list').removeClass('mailpoet_hidden');
|
@@ -37166,7 +37204,7 @@ webpackJsonp([4],{
|
|
37166 |
|
37167 |
this.changeField('displayType', event);
|
37168 |
},
|
37169 |
-
changeTitleFormat: function(event) {
|
37170 |
var value = jQuery(event.target).val();
|
37171 |
if (value == 'ul') {
|
37172 |
this.$('.mailpoet_posts_non_title_list_options').addClass('mailpoet_hidden');
|
@@ -37183,18 +37221,18 @@ webpackJsonp([4],{
|
|
37183 |
});
|
37184 |
|
37185 |
Module.PostsWidgetView = base.WidgetView.extend({
|
37186 |
-
getTemplate: function() { return window.templates.postsInsertion; },
|
37187 |
behaviors: {
|
37188 |
DraggableBehavior: {
|
37189 |
cloneOriginal: true,
|
37190 |
-
drop: function() {
|
37191 |
return new Module.PostsBlockModel({}, { parse: true });
|
37192 |
}
|
37193 |
}
|
37194 |
}
|
37195 |
});
|
37196 |
|
37197 |
-
App.on('before:start', function(App, options) {
|
37198 |
App.registerBlockType('posts', {
|
37199 |
blockModel: Module.PostsBlockModel,
|
37200 |
blockView: Module.PostsBlockView
|
@@ -37227,7 +37265,7 @@ webpackJsonp([4],{
|
|
37227 |
__webpack_require__(564),
|
37228 |
__webpack_require__(278),
|
37229 |
__webpack_require__(273)
|
37230 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(App, BaseBlock, Backbone, Marionette, SuperModel, _, jQuery) {
|
37231 |
|
37232 |
'use strict';
|
37233 |
|
@@ -37239,7 +37277,7 @@ webpackJsonp([4],{
|
|
37239 |
SocialBlockSettingsStylesView;
|
37240 |
|
37241 |
Module.SocialIconModel = SuperModel.extend({
|
37242 |
-
defaults: function() {
|
37243 |
var defaultValues = App.getConfig().get('socialIcons.custom');
|
37244 |
return {
|
37245 |
type: 'socialIcon',
|
@@ -37251,10 +37289,10 @@ webpackJsonp([4],{
|
|
37251 |
text: defaultValues.get('title')
|
37252 |
};
|
37253 |
},
|
37254 |
-
initialize: function(options) {
|
37255 |
var that = this;
|
37256 |
// Make model swap to default values for that type when iconType changes
|
37257 |
-
this.on('change:iconType', function() {
|
37258 |
var defaultValues = App.getConfig().get('socialIcons').get(that.get('iconType')),
|
37259 |
iconSet = that.collection.iconBlockModel.getIconSet();
|
37260 |
this.set({
|
@@ -37263,7 +37301,7 @@ webpackJsonp([4],{
|
|
37263 |
text: defaultValues.get('title')
|
37264 |
});
|
37265 |
}, this);
|
37266 |
-
this.on('change', function() { App.getChannel().trigger('autoSave'); });
|
37267 |
}
|
37268 |
});
|
37269 |
|
@@ -37273,7 +37311,7 @@ webpackJsonp([4],{
|
|
37273 |
|
37274 |
Module.SocialBlockModel = base.BlockModel.extend({
|
37275 |
name: 'iconBlockModel',
|
37276 |
-
defaults: function() {
|
37277 |
return this._getDefaults({
|
37278 |
type: 'social',
|
37279 |
iconSet: 'default',
|
@@ -37283,31 +37321,31 @@ webpackJsonp([4],{
|
|
37283 |
relations: {
|
37284 |
icons: Module.SocialIconCollectionModel
|
37285 |
},
|
37286 |
-
initialize: function() {
|
37287 |
this.get('icons').on('add remove change', this._iconsChanged, this);
|
37288 |
this.on('change:iconSet', this.changeIconSet, this);
|
37289 |
},
|
37290 |
-
getIconSet: function() {
|
37291 |
return App.getAvailableStyles().get('socialIconSets').get(this.get('iconSet'));
|
37292 |
},
|
37293 |
-
changeIconSet: function() {
|
37294 |
var iconSet = this.getIconSet();
|
37295 |
-
_.each(this.get('icons').models, function(model) {
|
37296 |
model.set('image', iconSet.get(model.get('iconType')));
|
37297 |
});
|
37298 |
},
|
37299 |
-
_iconsChanged: function() {
|
37300 |
-
App.getChannel().trigger('autoSave');
|
37301 |
}
|
37302 |
});
|
37303 |
|
37304 |
var SocialIconView = Marionette.View.extend({
|
37305 |
tagName: 'span',
|
37306 |
-
getTemplate: function() { return window.templates.socialIconBlock; },
|
37307 |
modelEvents: {
|
37308 |
change: 'render'
|
37309 |
},
|
37310 |
-
templateContext: function() {
|
37311 |
var allIconSets = App.getAvailableStyles().get('socialIconSets');
|
37312 |
return {
|
37313 |
model: this.model.toJSON(),
|
@@ -37323,7 +37361,7 @@ webpackJsonp([4],{
|
|
37323 |
|
37324 |
Module.SocialBlockView = base.BlockView.extend({
|
37325 |
className: 'mailpoet_block mailpoet_social_block mailpoet_droppable_block',
|
37326 |
-
getTemplate: function() { return window.templates.socialBlock; },
|
37327 |
regions: _.extend({}, base.BlockView.prototype.regions, {
|
37328 |
icons: '.mailpoet_social'
|
37329 |
}),
|
@@ -37333,8 +37371,8 @@ webpackJsonp([4],{
|
|
37333 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
37334 |
ShowSettingsBehavior: {}
|
37335 |
}),
|
37336 |
-
onDragSubstituteBy: function() { return Module.SocialWidgetView; },
|
37337 |
-
onRender: function() {
|
37338 |
this.toolsView = new Module.SocialBlockToolsView({ model: this.model });
|
37339 |
this.showChildView('toolsRegion', this.toolsView);
|
37340 |
this.showChildView('icons', new Module.SocialIconCollectionView({
|
@@ -37344,28 +37382,28 @@ webpackJsonp([4],{
|
|
37344 |
});
|
37345 |
|
37346 |
Module.SocialBlockToolsView = base.BlockToolsView.extend({
|
37347 |
-
getSettingsView: function() { return Module.SocialBlockSettingsView; }
|
37348 |
});
|
37349 |
|
37350 |
// Sidebar view container
|
37351 |
Module.SocialBlockSettingsView = base.BlockSettingsView.extend({
|
37352 |
-
getTemplate: function() { return window.templates.socialBlockSettings; },
|
37353 |
regions: {
|
37354 |
iconRegion: '#mailpoet_social_icons_selection',
|
37355 |
stylesRegion: '#mailpoet_social_icons_styles'
|
37356 |
},
|
37357 |
-
events: function() {
|
37358 |
return {
|
37359 |
'click .mailpoet_done_editing': 'close'
|
37360 |
};
|
37361 |
},
|
37362 |
-
initialize: function() {
|
37363 |
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
|
37364 |
|
37365 |
this._iconSelectorView = new SocialBlockSettingsIconSelectorView({ model: this.model });
|
37366 |
this._stylesView = new SocialBlockSettingsStylesView({ model: this.model });
|
37367 |
},
|
37368 |
-
onRender: function() {
|
37369 |
this.showChildView('iconRegion', this._iconSelectorView);
|
37370 |
this.showChildView('stylesRegion', this._stylesView);
|
37371 |
}
|
@@ -37373,8 +37411,8 @@ webpackJsonp([4],{
|
|
37373 |
|
37374 |
// Single icon settings view, used by the selector view
|
37375 |
SocialBlockSettingsIconView = Marionette.View.extend({
|
37376 |
-
getTemplate: function() { return window.templates.socialSettingsIcon; },
|
37377 |
-
events: function() {
|
37378 |
return {
|
37379 |
'click .mailpoet_delete_block': 'deleteIcon',
|
37380 |
'change .mailpoet_social_icon_field_type': _.partial(this.changeField, 'iconType'),
|
@@ -37385,17 +37423,17 @@ webpackJsonp([4],{
|
|
37385 |
},
|
37386 |
modelEvents: {
|
37387 |
'change:iconType': 'render',
|
37388 |
-
'change:image': function() {
|
37389 |
this.$('.mailpoet_social_icon_image').attr('src', this.model.get('image'));
|
37390 |
},
|
37391 |
-
'change:text': function() {
|
37392 |
this.$('.mailpoet_social_icon_image').attr('alt', this.model.get('text'));
|
37393 |
}
|
37394 |
},
|
37395 |
-
templateContext: function() {
|
37396 |
var icons = App.getConfig().get('socialIcons'),
|
37397 |
// Construct icon type list of format [{iconType: 'type', title: 'Title'}, ...]
|
37398 |
-
availableIconTypes = _.map(_.keys(icons.attributes), function(key) { return { iconType: key, title: icons.get(key).get('title') }; }),
|
37399 |
allIconSets = App.getAvailableStyles().get('socialIconSets');
|
37400 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
37401 |
iconTypes: availableIconTypes,
|
@@ -37403,17 +37441,17 @@ webpackJsonp([4],{
|
|
37403 |
allIconSets: allIconSets.toJSON()
|
37404 |
});
|
37405 |
},
|
37406 |
-
deleteIcon: function() {
|
37407 |
this.model.destroy();
|
37408 |
},
|
37409 |
-
changeLink: function(event) {
|
37410 |
if (this.model.get('iconType') === 'email') {
|
37411 |
this.model.set('link', 'mailto:' + jQuery(event.target).val());
|
37412 |
} else {
|
37413 |
return this.changeField('link', event);
|
37414 |
}
|
37415 |
},
|
37416 |
-
changeField: function(field, event) {
|
37417 |
this.model.set(field, jQuery(event.target).val());
|
37418 |
}
|
37419 |
});
|
@@ -37430,7 +37468,7 @@ webpackJsonp([4],{
|
|
37430 |
|
37431 |
// Select icons section container view
|
37432 |
SocialBlockSettingsIconSelectorView = Marionette.View.extend({
|
37433 |
-
getTemplate: function() { return window.templates.socialSettingsIconSelector; },
|
37434 |
regions: {
|
37435 |
icons: '#mailpoet_social_icon_selector_contents'
|
37436 |
},
|
@@ -37440,11 +37478,11 @@ webpackJsonp([4],{
|
|
37440 |
modelEvents: {
|
37441 |
'change:iconSet': 'render'
|
37442 |
},
|
37443 |
-
addSocialIcon: function() {
|
37444 |
// Add a social icon with default values
|
37445 |
this.model.get('icons').add({});
|
37446 |
},
|
37447 |
-
onRender: function() {
|
37448 |
this.showChildView('icons', new SocialBlockSettingsIconCollectionView({
|
37449 |
collection: this.model.get('icons')
|
37450 |
}));
|
@@ -37453,17 +37491,17 @@ webpackJsonp([4],{
|
|
37453 |
});
|
37454 |
|
37455 |
SocialBlockSettingsStylesView = Marionette.View.extend({
|
37456 |
-
getTemplate: function() { return window.templates.socialSettingsStyles; },
|
37457 |
modelEvents: {
|
37458 |
change: 'render'
|
37459 |
},
|
37460 |
events: {
|
37461 |
'click .mailpoet_social_icon_set': 'changeSocialIconSet'
|
37462 |
},
|
37463 |
-
initialize: function() {
|
37464 |
this.listenTo(this.model.get('icons'), 'add remove change', this.render);
|
37465 |
},
|
37466 |
-
templateContext: function() {
|
37467 |
var allIconSets = App.getAvailableStyles().get('socialIconSets');
|
37468 |
return {
|
37469 |
activeSet: this.model.get('iconSet'),
|
@@ -37472,20 +37510,20 @@ webpackJsonp([4],{
|
|
37472 |
availableSocialIcons: this.model.get('icons').pluck('iconType')
|
37473 |
};
|
37474 |
},
|
37475 |
-
changeSocialIconSet: function(event) {
|
37476 |
this.model.set('iconSet', jQuery(event.currentTarget).data('setname'));
|
37477 |
},
|
37478 |
-
onBeforeDestroy: function() {
|
37479 |
this.model.get('icons').off('add remove', this.render, this);
|
37480 |
}
|
37481 |
});
|
37482 |
|
37483 |
Module.SocialWidgetView = base.WidgetView.extend({
|
37484 |
-
getTemplate: function() { return window.templates.socialInsertion; },
|
37485 |
behaviors: {
|
37486 |
DraggableBehavior: {
|
37487 |
cloneOriginal: true,
|
37488 |
-
drop: function() {
|
37489 |
return new Module.SocialBlockModel({
|
37490 |
type: 'social',
|
37491 |
iconSet: 'default',
|
@@ -37515,7 +37553,7 @@ webpackJsonp([4],{
|
|
37515 |
}
|
37516 |
});
|
37517 |
|
37518 |
-
App.on('before:start', function(App, options) {
|
37519 |
App.registerBlockType('social', {
|
37520 |
blockModel: Module.SocialBlockModel,
|
37521 |
blockView: Module.SocialBlockView
|
8 |
__webpack_require__(278),
|
9 |
__webpack_require__(274),
|
10 |
__webpack_require__(552)
|
11 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, _, MailPoet) {
|
12 |
|
13 |
var Module = {};
|
14 |
|
15 |
+
Module._query = function (args) {
|
16 |
return MailPoet.Ajax.post({
|
17 |
api_version: window.mailpoet_api_version,
|
18 |
endpoint: 'automatedLatestContent',
|
22 |
};
|
23 |
Module._cachedQuery = _.memoize(Module._query, JSON.stringify);
|
24 |
|
25 |
+
Module.getNewsletter = function (options) {
|
26 |
return Module._query({
|
27 |
action: 'get',
|
28 |
options: options
|
29 |
});
|
30 |
};
|
31 |
|
32 |
+
Module.getPostTypes = function () {
|
33 |
return Module._cachedQuery({
|
34 |
action: 'getPostTypes',
|
35 |
options: {}
|
36 |
+
}).then(function (response) {
|
37 |
return _.values(response.data);
|
38 |
});
|
39 |
};
|
40 |
|
41 |
+
Module.getTaxonomies = function (postType) {
|
42 |
return Module._cachedQuery({
|
43 |
action: 'getTaxonomies',
|
44 |
options: {
|
45 |
postType: postType
|
46 |
}
|
47 |
+
}).then(function (response) {
|
48 |
return response.data;
|
49 |
});
|
50 |
};
|
51 |
|
52 |
+
Module.getTerms = function (options) {
|
53 |
return Module._cachedQuery({
|
54 |
action: 'getTerms',
|
55 |
options: options
|
56 |
+
}).then(function (response) {
|
57 |
return response.data;
|
58 |
});
|
59 |
};
|
60 |
|
61 |
+
Module.getPosts = function (options) {
|
62 |
return Module._cachedQuery({
|
63 |
action: 'getPosts',
|
64 |
options: options
|
65 |
+
}).then(function (response) {
|
66 |
return response.data;
|
67 |
});
|
68 |
};
|
69 |
|
70 |
+
Module.getTransformedPosts = function (options) {
|
71 |
return Module._cachedQuery({
|
72 |
action: 'getTransformedPosts',
|
73 |
options: options
|
74 |
+
}).then(function (response) {
|
75 |
return response.data;
|
76 |
});
|
77 |
};
|
78 |
|
79 |
+
Module.getBulkTransformedPosts = function (options) {
|
80 |
return Module._query({
|
81 |
action: 'getBulkTransformedPosts',
|
82 |
options: options
|
83 |
+
}).then(function (response) {
|
84 |
return response.data;
|
85 |
});
|
86 |
};
|
87 |
|
88 |
+
Module.saveNewsletter = function (options) {
|
89 |
return MailPoet.Ajax.post({
|
90 |
api_version: window.mailpoet_api_version,
|
91 |
endpoint: 'newsletters',
|
94 |
});
|
95 |
};
|
96 |
|
97 |
+
Module.previewNewsletter = function (options) {
|
98 |
return MailPoet.Ajax.post({
|
99 |
api_version: window.mailpoet_api_version,
|
100 |
endpoint: 'newsletters',
|
103 |
});
|
104 |
};
|
105 |
|
106 |
+
App.on('start', function (App, options) {
|
107 |
// Prefetch post types
|
108 |
Module.getPostTypes();
|
109 |
});
|
167 |
/***/ 274:
|
168 |
/***/ function(module, exports, __webpack_require__) {
|
169 |
|
170 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
|
171 |
// A placeholder for MailPoet object
|
172 |
var MailPoet = {};
|
173 |
|
9428 |
};
|
9429 |
}
|
9430 |
|
9431 |
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery, _) {
|
9432 |
var MailPoet = mp;
|
9433 |
|
9434 |
MailPoet.Ajax = {
|
9442 |
token: null,
|
9443 |
data: {}
|
9444 |
},
|
9445 |
+
post: function (options) {
|
9446 |
return this.request('post', options);
|
9447 |
},
|
9448 |
+
init: function (options) {
|
9449 |
// merge options
|
9450 |
this.options = jQuery.extend({}, this.defaults, options);
|
9451 |
|
9452 |
// set default url
|
9453 |
+
if (this.options.url === null) {
|
9454 |
this.options.url = window.ajaxurl;
|
9455 |
}
|
9456 |
|
9457 |
// set default token
|
9458 |
+
if (this.options.token === null) {
|
9459 |
this.options.token = window.mailpoet_token;
|
9460 |
}
|
9461 |
},
|
9462 |
+
getParams: function () {
|
9463 |
return {
|
9464 |
action: 'mailpoet',
|
9465 |
api_version: this.options.api_version,
|
9469 |
data: this.options.data || {}
|
9470 |
};
|
9471 |
},
|
9472 |
+
request: function (method, options) {
|
9473 |
// set options
|
9474 |
this.init(options);
|
9475 |
|
9478 |
|
9479 |
// remove null values from the data object
|
9480 |
if (_.isObject(params.data)) {
|
9481 |
+
params.data = _.pick(params.data, function (value) {
|
9482 |
return (value !== null);
|
9483 |
});
|
9484 |
}
|
9489 |
params,
|
9490 |
null,
|
9491 |
'json'
|
9492 |
+
).then(function (data) {
|
9493 |
return data;
|
9494 |
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
9495 |
|
9507 |
/***/ 555:
|
9508 |
/***/ function(module, exports, __webpack_require__) {
|
9509 |
|
9510 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery) {
|
9511 |
'use strict';
|
9512 |
|
9513 |
var MailPoet = mp;
|
9514 |
+
/** *************************************************************************
|
9515 |
MailPoet Modal:
|
9516 |
|
9517 |
version: 0.9
|
9528 |
|
9529 |
// loading mode
|
9530 |
MailPoet.Modal.loading(bool);
|
9531 |
+
************************************************************************** */
|
9532 |
|
9533 |
MailPoet.Modal = {
|
9534 |
version: 0.9,
|
9587 |
options: {},
|
9588 |
templates: {
|
9589 |
overlay: '<div id="mailpoet_modal_overlay" style="display:none;"></div>',
|
9590 |
+
popup: '<div id="mailpoet_popup" tabindex="-1">' +
|
9591 |
+
'<div class="mailpoet_popup_wrapper">' +
|
9592 |
+
'<a href="javascript:;" id="mailpoet_modal_close"></a>' +
|
9593 |
+
'<div id="mailpoet_popup_title"><h2></h2></div>' +
|
9594 |
+
'<div class="mailpoet_popup_body clearfix"></div>' +
|
9595 |
+
'</div>' +
|
9596 |
'</div>',
|
9597 |
+
loading: '<div id="mailpoet_loading" style="display:none;">' +
|
9598 |
+
'<div id="mailpoet_modal_loading_1" class="mailpoet_modal_loading"></div>' +
|
9599 |
+
'<div id="mailpoet_modal_loading_2" class="mailpoet_modal_loading"></div>' +
|
9600 |
+
'<div id="mailpoet_modal_loading_3" class="mailpoet_modal_loading"></div>' +
|
9601 |
'</div>',
|
9602 |
+
panel: '<div id="mailpoet_panel">' +
|
9603 |
+
'<a href="javascript:;" id="mailpoet_modal_close"></a>' +
|
9604 |
+
'<div class="mailpoet_panel_wrapper" tabindex="-1">' +
|
9605 |
+
'<div class="mailpoet_panel_body clearfix"></div>' +
|
9606 |
+
'</div>' +
|
9607 |
'</div>',
|
9608 |
+
subpanel: '<div class="mailpoet_panel_wrapper" tabindex="-1">' +
|
9609 |
+
'<div class="mailpoet_panel_body clearfix"></div>' +
|
9610 |
'</div>'
|
9611 |
},
|
9612 |
+
getContentContainer: function () {
|
9613 |
+
return jQuery('.mailpoet_' + this.options.type + '_body');
|
9614 |
},
|
9615 |
+
setRenderer: function (renderer) {
|
9616 |
this.renderer = renderer;
|
9617 |
return this;
|
9618 |
},
|
9619 |
+
compileTemplate: function (template) {
|
9620 |
+
if (this.renderer === 'html') {
|
9621 |
+
return function () { return template; };
|
9622 |
} else {
|
9623 |
return window.Handlebars.compile(template);
|
9624 |
}
|
9625 |
},
|
9626 |
+
init: function (options) {
|
9627 |
+
if (this.initialized === true) {
|
9628 |
this.close();
|
9629 |
}
|
9630 |
// merge options
|
9639 |
// toggle overlay
|
9640 |
this.toggleOverlay(this.options.overlay);
|
9641 |
|
9642 |
+
if (this.options.type !== null) {
|
9643 |
// insert modal depending on its type
|
9644 |
+
if (this.options.type === 'popup') {
|
9645 |
var modal = this.compileTemplate(
|
9646 |
this.templates[this.options.type]
|
9647 |
);
|
9651 |
// set title
|
9652 |
jQuery('#mailpoet_popup_title h2')
|
9653 |
.html(this.options.title);
|
9654 |
+
} else if (this.options.type === 'panel') {
|
9655 |
// create panel
|
9656 |
jQuery('#mailpoet_modal_overlay')
|
9657 |
.after(this.templates[this.options.type]);
|
9660 |
// add proper overlay class
|
9661 |
jQuery('#mailpoet_modal_overlay')
|
9662 |
.removeClass('mailpoet_popup_overlay mailpoet_panel_overlay')
|
9663 |
+
.addClass('mailpoet_' + this.options.type + '_overlay');
|
9664 |
}
|
9665 |
|
9666 |
// set "success" callback if specified
|
9667 |
+
if (options.onSuccess !== undefined) {
|
9668 |
this.options.onSuccess = options.onSuccess;
|
9669 |
}
|
9670 |
|
9671 |
// set "cancel" callback if specified
|
9672 |
+
if (options.onCancel !== undefined) {
|
9673 |
this.options.onCancel = options.onCancel;
|
9674 |
}
|
9675 |
|
9686 |
|
9687 |
return this;
|
9688 |
},
|
9689 |
+
initOverlay: function (toggle) {
|
9690 |
+
if (jQuery('#mailpoet_modal_overlay').length === 0) {
|
9691 |
// insert overlay into the DOM
|
9692 |
jQuery('body').append(this.templates.overlay);
|
9693 |
// insert loading indicator into overlay
|
9695 |
}
|
9696 |
return this;
|
9697 |
},
|
9698 |
+
toggleOverlay: function (toggle) {
|
9699 |
+
if (toggle === true) {
|
9700 |
jQuery('#mailpoet_modal_overlay')
|
9701 |
.removeClass('mailpoet_overlay_hidden');
|
9702 |
} else {
|
9706 |
|
9707 |
return this;
|
9708 |
},
|
9709 |
+
setupEvents: function () {
|
9710 |
// close popup when user clicks on close button
|
9711 |
jQuery('#mailpoet_modal_close').on('click', this.cancel.bind(this));
|
9712 |
|
9713 |
// close popup when user clicks on overlay
|
9714 |
+
jQuery('#mailpoet_modal_overlay').on('click', function (e) {
|
9715 |
// we need to make sure that we are actually clicking on the overlay
|
9716 |
// because when clicking on the popup content, it will trigger
|
9717 |
// the click event on the overlay
|
9718 |
+
if (e.target.id === 'mailpoet_modal_overlay') { this.cancel(); }
|
9719 |
}.bind(this));
|
9720 |
|
9721 |
// close popup when user presses ESC key
|
9722 |
+
jQuery(document).on('keyup.mailpoet_modal', function (e) {
|
9723 |
+
if (this.opened === false) { return false; }
|
9724 |
+
if (e.keyCode === 27) { this.cancel(); }
|
9725 |
}.bind(this));
|
9726 |
|
9727 |
// make sure the popup is repositioned when the window is resized
|
9728 |
+
jQuery(window).on('resize.mailpoet_modal', function () {
|
9729 |
this.setPosition();
|
9730 |
}.bind(this));
|
9731 |
|
9732 |
return this;
|
9733 |
},
|
9734 |
+
removeEvents: function () {
|
9735 |
jQuery(document).unbind('keyup.mailpoet_modal');
|
9736 |
jQuery(window).unbind('resize.mailpoet_modal');
|
9737 |
jQuery('#mailpoet_modal_close').off('click');
|
9738 |
+
if (this.options.overlay === true) {
|
9739 |
jQuery('#mailpoet_modal_overlay').off('click');
|
9740 |
}
|
9741 |
|
9742 |
return this;
|
9743 |
},
|
9744 |
+
lock: function () {
|
9745 |
this.locked = true;
|
9746 |
|
9747 |
return this;
|
9748 |
},
|
9749 |
+
unlock: function () {
|
9750 |
this.locked = false;
|
9751 |
|
9752 |
return this;
|
9753 |
},
|
9754 |
+
isLocked: function () {
|
9755 |
return this.locked;
|
9756 |
},
|
9757 |
+
loadTemplate: function () {
|
9758 |
+
if (this.subpanels.length > 0) {
|
9759 |
// hide panel
|
9760 |
+
jQuery('.mailpoet_' + this.options.type + '_wrapper').hide();
|
9761 |
|
9762 |
// add sub panel wrapper
|
9763 |
+
jQuery('#mailpoet_' + this.options.type)
|
9764 |
.append(this.templates['subpanel']);
|
9765 |
|
9766 |
// add sub panel content
|
9767 |
+
jQuery('.mailpoet_' + this.options.type + '_body').last()
|
9768 |
.html(this.subpanels[(this.subpanels.length - 1)].element);
|
9769 |
|
9770 |
// focus on sub panel
|
9771 |
+
if (this.options.focus) {
|
9772 |
this.focus();
|
9773 |
}
|
9774 |
} else if (this.options.element) {
|
9775 |
+
jQuery('.mailpoet_' + this.options.type + '_body').empty();
|
9776 |
+
jQuery('.mailpoet_' + this.options.type + '_body')
|
9777 |
.append(this.options.element);
|
9778 |
} else {
|
9779 |
+
jQuery('.mailpoet_' + this.options.type + '_body')
|
9780 |
.html(
|
9781 |
this.options.body_template(
|
9782 |
this.options.data
|
9786 |
|
9787 |
return this;
|
9788 |
},
|
9789 |
+
loadUrl: function () {
|
9790 |
+
if (this.options.method === 'get') {
|
9791 |
// make ajax request
|
9792 |
jQuery.getJSON(this.options.url,
|
9793 |
+
function (data) {
|
9794 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
9795 |
// load template using fetched data
|
9796 |
this.loadTemplate();
|
9798 |
this.showModal();
|
9799 |
}.bind(this)
|
9800 |
);
|
9801 |
+
} else if (this.options.method === 'post') {
|
9802 |
// make ajax request
|
9803 |
jQuery.post(this.options.url, JSON.stringify(this.options.params),
|
9804 |
+
function (data) {
|
9805 |
this.options.data = jQuery.extend({}, this.options.data, data);
|
9806 |
// load template using fetched data
|
9807 |
this.loadTemplate();
|
9814 |
|
9815 |
return this;
|
9816 |
},
|
9817 |
+
setDimensions: function () {
|
9818 |
+
switch (this.options.type) {
|
9819 |
case 'popup':
|
9820 |
// set popup dimensions
|
9821 |
jQuery('#mailpoet_popup').css({
|
9829 |
break;
|
9830 |
case 'panel':
|
9831 |
// set dimensions
|
9832 |
+
if (this.options.position === 'right') {
|
9833 |
jQuery('#mailpoet_panel').css({
|
9834 |
width: this.options.width,
|
9835 |
right: 0,
|
9836 |
marginRight: '-' + this.options.width,
|
9837 |
left: 'auto'
|
9838 |
});
|
9839 |
+
} else if (this.options.position === 'left') {
|
9840 |
jQuery('#mailpoet_panel').css({
|
9841 |
width: this.options.width,
|
9842 |
left: 0,
|
9850 |
|
9851 |
return this;
|
9852 |
},
|
9853 |
+
setPosition: function () {
|
9854 |
+
switch (this.options.type) {
|
9855 |
case 'popup':
|
9856 |
var screenWidth = jQuery(window).width(),
|
9857 |
screenHeight = jQuery(window).height(),
|
9858 |
+
modalWidth = jQuery('.mailpoet_' + this.options.type + '_wrapper').width(),
|
9859 |
+
modalHeight = jQuery('.mailpoet_' + this.options.type + '_wrapper').height();
|
9860 |
|
9861 |
var top = Math.max(48, parseInt((screenHeight / 2) - (modalHeight / 2))),
|
9862 |
left = Math.max(0, parseInt((screenWidth / 2) - (modalWidth / 2)));
|
9868 |
});
|
9869 |
break;
|
9870 |
case 'panel':
|
9871 |
+
setTimeout(function () {
|
9872 |
// set position of popup depending on screen dimensions.
|
9873 |
+
if (this.options.position === 'right') {
|
9874 |
jQuery('#mailpoet_panel').css({
|
9875 |
marginRight: 0
|
9876 |
});
|
9877 |
+
} else if (this.options.position === 'left') {
|
9878 |
jQuery('#mailpoet_panel').css({
|
9879 |
marginLeft: 0
|
9880 |
});
|
9885 |
|
9886 |
return this;
|
9887 |
},
|
9888 |
+
showModal: function () {
|
9889 |
// set modal dimensions
|
9890 |
this.setDimensions();
|
9891 |
|
9896 |
jQuery('body').addClass('mailpoet_modal_opened');
|
9897 |
|
9898 |
// show popup
|
9899 |
+
jQuery('#mailpoet_' + this.options.type).show();
|
9900 |
|
9901 |
// display overlay
|
9902 |
this.showOverlay();
|
9905 |
this.setPosition();
|
9906 |
|
9907 |
// add class on highlighted elements
|
9908 |
+
if (this.options.highlight !== null) {
|
9909 |
+
if (this.options.highlight.length > 0) {
|
9910 |
this.highlightOn(this.options.highlight);
|
9911 |
}
|
9912 |
}
|
9913 |
|
9914 |
+
if (this.options.focus) {
|
9915 |
this.focus();
|
9916 |
}
|
9917 |
|
9919 |
this.opened = true;
|
9920 |
|
9921 |
// trigger init event if specified
|
9922 |
+
if (this.options.onInit !== null) {
|
9923 |
this.options.onInit(this);
|
9924 |
}
|
9925 |
|
9926 |
return this;
|
9927 |
},
|
9928 |
+
focus: function () {
|
9929 |
+
if (this.options.type == 'popup') {
|
9930 |
+
jQuery('#mailpoet_' + this.options.type).focus();
|
9931 |
} else {
|
9932 |
// panel and subpanel
|
9933 |
+
jQuery('#mailpoet_' + this.options.type + ' .mailpoet_panel_wrapper')
|
9934 |
.filter(':visible').focus();
|
9935 |
}
|
9936 |
return this;
|
9937 |
},
|
9938 |
+
highlightOn: function (element) {
|
9939 |
jQuery(element).addClass('mailpoet_modal_highlight');
|
9940 |
return this;
|
9941 |
},
|
9942 |
+
highlightOff: function () {
|
9943 |
jQuery('.mailpoet_modal_highlight')
|
9944 |
.removeClass('mailpoet_modal_highlight');
|
9945 |
return this;
|
9946 |
},
|
9947 |
+
hideModal: function (callback) {
|
9948 |
// set modal as closed
|
9949 |
this.opened = false;
|
9950 |
|
9951 |
// hide modal
|
9952 |
+
jQuery('#mailpoet_' + this.options.type).hide();
|
9953 |
|
9954 |
// remove class on highlighted elements
|
9955 |
this.highlightOff();
|
9959 |
|
9960 |
return this;
|
9961 |
},
|
9962 |
+
showOverlay: function (force) {
|
9963 |
jQuery('#mailpoet_modal_overlay').show();
|
9964 |
return this;
|
9965 |
},
|
9966 |
+
hideOverlay: function () {
|
9967 |
jQuery('#mailpoet_modal_overlay').hide();
|
9968 |
return this;
|
9969 |
},
|
9970 |
+
popup: function (opts) {
|
9971 |
// get options
|
9972 |
var options = opts || {};
|
9973 |
// set modal type
|
9981 |
|
9982 |
return this;
|
9983 |
},
|
9984 |
+
panel: function (opts) {
|
9985 |
// get options
|
9986 |
var options = opts || {};
|
9987 |
// reset subpanels
|
10002 |
|
10003 |
return this;
|
10004 |
},
|
10005 |
+
subpanel: function (options) {
|
10006 |
+
if (this.opened === false) {
|
10007 |
// if no panel is already opened, let's create one instead
|
10008 |
this.panel(options);
|
10009 |
} else {
|
10014 |
|
10015 |
return this;
|
10016 |
},
|
10017 |
+
loading: function (toggle) {
|
10018 |
// make sure the overlay is initialized and that it's visible
|
10019 |
this.initOverlay(true);
|
10020 |
|
10021 |
+
if (toggle === true) {
|
10022 |
this.showLoading();
|
10023 |
} else {
|
10024 |
this.hideLoading();
|
10026 |
|
10027 |
return this;
|
10028 |
},
|
10029 |
+
showLoading: function () {
|
10030 |
jQuery('#mailpoet_loading').show();
|
10031 |
|
10032 |
// add loading class to overlay
|
10035 |
|
10036 |
return this;
|
10037 |
},
|
10038 |
+
hideLoading: function () {
|
10039 |
jQuery('#mailpoet_loading').hide();
|
10040 |
|
10041 |
// remove loading class from overlay
|
10044 |
|
10045 |
return this;
|
10046 |
},
|
10047 |
+
open: function () {
|
10048 |
// load template if specified
|
10049 |
+
if (this.options.template !== null) {
|
10050 |
// check if a url was specified to get extra data
|
10051 |
+
if (this.options.url !== null) {
|
10052 |
this.loadUrl();
|
10053 |
} else {
|
10054 |
// load template
|
10063 |
|
10064 |
return this;
|
10065 |
},
|
10066 |
+
success: function () {
|
10067 |
+
if (this.subpanels.length > 0) {
|
10068 |
+
if (this.subpanels[(this.subpanels.length - 1)].onSuccess !== undefined) {
|
10069 |
this.subpanels[(this.subpanels.length - 1)].onSuccess(this.subpanels[(this.subpanels.length - 1)].data);
|
10070 |
}
|
10071 |
} else {
|
10072 |
+
if (this.options.onSuccess !== null) {
|
10073 |
this.options.onSuccess(this.options.data);
|
10074 |
}
|
10075 |
}
|
10077 |
|
10078 |
return this;
|
10079 |
},
|
10080 |
+
cancel: function () {
|
10081 |
+
if (this.subpanels.length > 0) {
|
10082 |
+
if (this.subpanels[(this.subpanels.length - 1)].onCancel !== undefined) {
|
10083 |
this.subpanels[(this.subpanels.length - 1)].onCancel(this.subpanels[(this.subpanels.length - 1)].data);
|
10084 |
}
|
10085 |
} else {
|
10086 |
+
if (this.options.onCancel !== null) {
|
10087 |
this.options.onCancel(this.options.data);
|
10088 |
}
|
10089 |
}
|
10091 |
|
10092 |
return this;
|
10093 |
},
|
10094 |
+
destroy: function () {
|
10095 |
this.hideOverlay();
|
10096 |
|
10097 |
// remove extra modal
|
10098 |
+
if (jQuery('#mailpoet_' + this.options.type).length > 0) {
|
10099 |
+
jQuery('#mailpoet_' + this.options.type).remove();
|
10100 |
}
|
10101 |
|
10102 |
this.initialized = false;
|
10103 |
|
10104 |
return this;
|
10105 |
},
|
10106 |
+
close: function () {
|
10107 |
+
if (this.isLocked() === true) { return this; }
|
10108 |
|
10109 |
+
if (this.subpanels.length > 0) {
|
10110 |
// close subpanel
|
10111 |
+
jQuery('.mailpoet_' + this.options.type + '_wrapper').last().remove();
|
10112 |
|
10113 |
// show previous panel
|
10114 |
+
jQuery('.mailpoet_' + this.options.type + '_wrapper').last().show();
|
10115 |
|
10116 |
// remove last subpanels
|
10117 |
this.subpanels.pop();
|
10118 |
|
10119 |
// focus on previous panel
|
10120 |
+
if (this.options.focus) {
|
10121 |
this.focus();
|
10122 |
}
|
10123 |
|
10134 |
this.destroy();
|
10135 |
|
10136 |
// restore the previously focused element
|
10137 |
+
if (this.prevFocus !== undefined) {
|
10138 |
this.prevFocus.focus();
|
10139 |
}
|
10140 |
|
10156 |
/***/ 556:
|
10157 |
/***/ function(module, exports, __webpack_require__) {
|
10158 |
|
10159 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(274), __webpack_require__(273)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery) {
|
10160 |
'use strict';
|
10161 |
|
10162 |
+
/*= =================================================================================================
|
10163 |
|
10164 |
MailPoet Notice:
|
10165 |
|
10180 |
// system message (static: true)
|
10181 |
MailPoet.Notice.system('You need to updated ASAP!');
|
10182 |
|
10183 |
+
================================================================================================== */
|
10184 |
var MailPoet = mp;
|
10185 |
MailPoet.Notice = {
|
10186 |
version: 1.0,
|
10198 |
onClose: null
|
10199 |
},
|
10200 |
options: {},
|
10201 |
+
init: function (options) {
|
10202 |
// set options
|
10203 |
this.options = jQuery.extend({}, this.defaults, options);
|
10204 |
|
10205 |
return this;
|
10206 |
},
|
10207 |
+
createNotice: function () {
|
10208 |
// clone element
|
10209 |
+
this.element = jQuery('#mailpoet_notice_' + this.options.type).clone();
|
10210 |
|
10211 |
// add data-id to the element
|
10212 |
if (this.options.id) {
|
10226 |
} else if (typeof this.options.positionAfter === 'string') {
|
10227 |
positionAfter = jQuery(this.options.positionAfter);
|
10228 |
} else {
|
10229 |
+
positionAfter = jQuery('#mailpoet_notice_' + this.options.type);
|
10230 |
}
|
10231 |
positionAfter.after(this.element);
|
10232 |
|
10237 |
}
|
10238 |
|
10239 |
// listen to remove event
|
10240 |
+
jQuery(this.element).on('close', function () {
|
10241 |
+
jQuery(this).fadeOut(200, function () {
|
10242 |
// on close callback
|
10243 |
if (onClose !== null) {
|
10244 |
onClose();
|
10249 |
}.bind(this.element));
|
10250 |
|
10251 |
// listen to message event
|
10252 |
+
jQuery(this.element).on('setMessage', function (e, message) {
|
10253 |
MailPoet.Notice.setMessage(message);
|
10254 |
}.bind(this.element));
|
10255 |
|
10256 |
return this;
|
10257 |
},
|
10258 |
+
updateNotice: function () {
|
10259 |
// update notice's message
|
10260 |
+
jQuery('[data-id="' + this.options.id + '"').first().trigger(
|
10261 |
'setMessage', this.options.message
|
10262 |
);
|
10263 |
},
|
10264 |
+
setMessage: function (message) {
|
10265 |
var formattedMessage = this.formatMessage(message);
|
10266 |
|
10267 |
// let's sugar coat the message with a fancy <p>
|
10268 |
+
formattedMessage = '<p>' + formattedMessage + '</p>';
|
10269 |
// set message
|
10270 |
return this.element.html(formattedMessage);
|
10271 |
},
|
10272 |
+
formatMessage: function (message) {
|
10273 |
if (Array.isArray(message)) {
|
10274 |
return message.join('<br />');
|
10275 |
} else {
|
10276 |
return message;
|
10277 |
}
|
10278 |
},
|
10279 |
+
show: function (options) {
|
10280 |
// initialize
|
10281 |
this.init(options);
|
10282 |
|
10283 |
if (
|
10284 |
this.options.id !== null
|
10285 |
&&
|
10286 |
+
jQuery('[data-id="' + this.options.id + '"]').length > 0
|
10287 |
) {
|
10288 |
this.updateNotice();
|
10289 |
} else {
|
10291 |
}
|
10292 |
this.showNotice();
|
10293 |
},
|
10294 |
+
showNotice: function () {
|
10295 |
// set message
|
10296 |
this.setMessage(this.options.message);
|
10297 |
|
10324 |
this.element.delay(this.options.timeout).trigger('close');
|
10325 |
} else if (this.options.hideClose === false) {
|
10326 |
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
|
10327 |
+
this.element.find('.mailpoet_notice_close').on('click', function () {
|
10328 |
jQuery(this).trigger('close');
|
10329 |
});
|
10330 |
}
|
10334 |
this.options.onOpen(this.element);
|
10335 |
}
|
10336 |
},
|
10337 |
+
hide: function (all) {
|
10338 |
if (all !== undefined && all === true) {
|
10339 |
// all notices
|
10340 |
jQuery('.mailpoet_notice:not([id])').trigger('close');
|
10351 |
.trigger('close');
|
10352 |
}
|
10353 |
},
|
10354 |
+
error: function (message, options) {
|
10355 |
this.show(jQuery.extend({}, {
|
10356 |
type: 'error',
|
10357 |
message: message
|
10358 |
}, options));
|
10359 |
},
|
10360 |
+
success: function (message, options) {
|
10361 |
this.show(jQuery.extend({}, {
|
10362 |
type: 'success',
|
10363 |
message: message
|
10364 |
}, options));
|
10365 |
},
|
10366 |
+
system: function (message, options) {
|
10367 |
this.show(jQuery.extend({}, {
|
10368 |
type: 'system',
|
10369 |
static: true,
|
27575 |
* Courtesy of https://gist.github.com/jmeas/7992474cdb1c5672d88b
|
27576 |
*/
|
27577 |
|
27578 |
+
(function (root, factory) {
|
27579 |
if (true) {
|
27580 |
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(562), __webpack_require__(563), __webpack_require__(278)], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, Radio, _) {
|
27581 |
return factory(Marionette, Radio, _);
|
27582 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
27583 |
}
|
27590 |
else {
|
27591 |
factory(root.Backbone.Marionette, root.Backbone.Radio, root._);
|
27592 |
}
|
27593 |
+
}(this, function (Marionette, Radio, _) {
|
27594 |
'use strict';
|
27595 |
|
27596 |
var MarionetteApplication = Marionette.Application;
|
27614 |
__webpack_require__(278),
|
27615 |
__webpack_require__(543),
|
27616 |
__webpack_require__(575)
|
27617 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Backbone, Marionette, BackboneRadio, jQuery, _, Handlebars) {
|
27618 |
var Radio = BackboneRadio;
|
27619 |
|
27620 |
var AppView = Marionette.View.extend({
|
27631 |
var EditorApplication = Marionette.Application.extend({
|
27632 |
region: '#mailpoet_editor',
|
27633 |
|
27634 |
+
onStart: function () {
|
27635 |
this._appView = new AppView();
|
27636 |
this.showView(this._appView);
|
27637 |
},
|
27638 |
|
27639 |
+
getChannel: function (channel) {
|
27640 |
if (channel === undefined) {
|
27641 |
return Radio.channel('global');
|
27642 |
}
|
27660 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
27661 |
__webpack_require__(574),
|
27662 |
__webpack_require__(564)
|
27663 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, SuperModel) {
|
27664 |
|
27665 |
var Module = {};
|
27666 |
|
27677 |
|
27678 |
// Global and available styles for access in blocks and their settings
|
27679 |
Module._config = {};
|
27680 |
+
Module.getConfig = function () { return Module._config; };
|
27681 |
+
Module.setConfig = function (options) {
|
27682 |
Module._config = new Module.ConfigModel(options, { parse: true });
|
27683 |
return Module._config;
|
27684 |
};
|
27685 |
|
27686 |
+
App.on('before:start', function (App, options) {
|
27687 |
var Application = App;
|
27688 |
// Expose config methods globally
|
27689 |
Application.getConfig = Module.getConfig;
|
27706 |
__webpack_require__(562),
|
27707 |
__webpack_require__(564),
|
27708 |
__webpack_require__(278)
|
27709 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, Marionette, SuperModel, _) {
|
27710 |
|
27711 |
'use strict';
|
27712 |
|
27745 |
backgroundColor: '#cccccc'
|
27746 |
}
|
27747 |
},
|
27748 |
+
initialize: function () {
|
27749 |
+
this.on('change', function () { App.getChannel().trigger('autoSave'); });
|
27750 |
}
|
27751 |
});
|
27752 |
|
27753 |
Module.StylesView = Marionette.View.extend({
|
27754 |
+
getTemplate: function () { return window.templates.styles; },
|
27755 |
modelEvents: {
|
27756 |
change: 'render'
|
27757 |
},
|
27758 |
+
serializeData: function () {
|
27759 |
return this.model.toJSON();
|
27760 |
}
|
27761 |
});
|
27762 |
|
27763 |
Module._globalStyles = new SuperModel();
|
27764 |
+
Module.getGlobalStyles = function () {
|
27765 |
return Module._globalStyles;
|
27766 |
};
|
27767 |
+
Module.setGlobalStyles = function (options) {
|
27768 |
Module._globalStyles = new Module.StylesModel(options);
|
27769 |
return Module._globalStyles;
|
27770 |
};
|
27771 |
+
Module.getAvailableStyles = function () {
|
27772 |
return App.getConfig().get('availableStyles');
|
27773 |
};
|
27774 |
|
27775 |
+
App.on('before:start', function (App, options) {
|
27776 |
var Application = App;
|
27777 |
// Expose style methods to global application
|
27778 |
Application.getGlobalStyles = Module.getGlobalStyles;
|
27784 |
this.setGlobalStyles(globalStyles);
|
27785 |
});
|
27786 |
|
27787 |
+
App.on('start', function (App, options) {
|
27788 |
var stylesView = new Module.StylesView({ model: App.getGlobalStyles() });
|
27789 |
App._appView.showChildView('stylesRegion', stylesView);
|
27790 |
});
|
27808 |
__webpack_require__(278),
|
27809 |
__webpack_require__(273),
|
27810 |
__webpack_require__(567)
|
27811 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
27812 |
App,
|
27813 |
CommunicationComponent,
|
27814 |
MailPoet,
|
27835 |
}),
|
27836 |
comparator: 'priority'
|
27837 |
}))();
|
27838 |
+
Module.registerWidget = function (widget) { return Module._contentWidgets.add(widget); };
|
27839 |
+
Module.getWidgets = function () { return Module._contentWidgets; };
|
27840 |
|
27841 |
// Layout widget handlers for use to create new layout blocks via drag&drop
|
27842 |
Module._layoutWidgets = new (Backbone.Collection.extend({
|
27849 |
}),
|
27850 |
comparator: 'priority'
|
27851 |
}))();
|
27852 |
+
Module.registerLayoutWidget = function (widget) { return Module._layoutWidgets.add(widget); };
|
27853 |
+
Module.getLayoutWidgets = function () { return Module._layoutWidgets; };
|
27854 |
|
27855 |
var SidebarView = Marionette.View.extend({
|
27856 |
+
getTemplate: function () { return window.templates.sidebar; },
|
27857 |
regions: {
|
27858 |
contentRegion: '.mailpoet_content_region',
|
27859 |
layoutRegion: '.mailpoet_layout_region',
|
27861 |
previewRegion: '.mailpoet_preview_region'
|
27862 |
},
|
27863 |
events: {
|
27864 |
+
'click .mailpoet_sidebar_region h3, .mailpoet_sidebar_region .handlediv': function (event) {
|
27865 |
var $openRegion = this.$el.find('.mailpoet_sidebar_region:not(.closed)'),
|
27866 |
$targetRegion = this.$el.find(event.target).closest('.mailpoet_sidebar_region');
|
27867 |
|
27870 |
{
|
27871 |
duration: 250,
|
27872 |
easing: 'easeOut',
|
27873 |
+
complete: function () {
|
27874 |
$openRegion.addClass('closed');
|
27875 |
}.bind(this)
|
27876 |
}
|
27882 |
{
|
27883 |
duration: 250,
|
27884 |
easing: 'easeIn',
|
27885 |
+
complete: function () {
|
27886 |
$targetRegion.removeClass('closed');
|
27887 |
}
|
27888 |
}
|
27890 |
}
|
27891 |
}
|
27892 |
},
|
27893 |
+
initialize: function (options) {
|
27894 |
jQuery(window)
|
27895 |
.on('resize', this.updateHorizontalScroll.bind(this))
|
27896 |
.on('scroll', this.updateHorizontalScroll.bind(this));
|
27897 |
},
|
27898 |
+
onRender: function () {
|
27899 |
this.showChildView('contentRegion', new Module.SidebarWidgetsView(
|
27900 |
App.getWidgets()
|
27901 |
));
|
27908 |
}));
|
27909 |
this.showChildView('previewRegion', new Module.SidebarPreviewView());
|
27910 |
},
|
27911 |
+
updateHorizontalScroll: function () {
|
27912 |
// Fixes the sidebar so that on narrower screens the horizontal
|
27913 |
// position of the sidebar would be scrollable and not fixed
|
27914 |
// partially out of visible screen
|
27925 |
}
|
27926 |
});
|
27927 |
},
|
27928 |
+
onDomRefresh: function () {
|
27929 |
this.$el.parent().stick_in_parent({
|
27930 |
offset_top: 32
|
27931 |
});
|
27940 |
* Draggable widget collection view
|
27941 |
*/
|
27942 |
Module.SidebarWidgetsCollectionView = Marionette.CollectionView.extend({
|
27943 |
+
childView: function (item) { return item.get('widgetView'); }
|
27944 |
});
|
27945 |
|
27946 |
/**
|
27947 |
* Responsible for rendering draggable content widgets
|
27948 |
*/
|
27949 |
Module.SidebarWidgetsView = Marionette.View.extend({
|
27950 |
+
getTemplate: function () { return window.templates.sidebarContent; },
|
27951 |
regions: {
|
27952 |
widgets: '.mailpoet_region_content'
|
27953 |
},
|
27954 |
|
27955 |
+
initialize: function (widgets) {
|
27956 |
this.widgets = widgets;
|
27957 |
},
|
27958 |
|
27959 |
+
onRender: function () {
|
27960 |
this.showChildView('widgets', new Module.SidebarWidgetsCollectionView({
|
27961 |
collection: this.widgets
|
27962 |
}));
|
27967 |
* Responsible for rendering draggable layout widgets
|
27968 |
*/
|
27969 |
Module.SidebarLayoutWidgetsView = Module.SidebarWidgetsView.extend({
|
27970 |
+
getTemplate: function () { return window.templates.sidebarLayout; }
|
27971 |
});
|
27972 |
|
27973 |
/**
|
27974 |
* Responsible for managing global styles
|
27975 |
*/
|
27976 |
Module.SidebarStylesView = Marionette.View.extend({
|
27977 |
+
getTemplate: function () { return window.templates.sidebarStyles; },
|
27978 |
behaviors: {
|
27979 |
ColorPickerBehavior: {}
|
27980 |
},
|
27981 |
+
events: function () {
|
27982 |
return {
|
27983 |
'change #mailpoet_text_font_color': _.partial(this.changeColorField, 'text.fontColor'),
|
27984 |
+
'change #mailpoet_text_font_family': function (event) {
|
27985 |
this.model.set('text.fontFamily', event.target.value);
|
27986 |
},
|
27987 |
+
'change #mailpoet_text_font_size': function (event) {
|
27988 |
this.model.set('text.fontSize', event.target.value);
|
27989 |
},
|
27990 |
'change #mailpoet_h1_font_color': _.partial(this.changeColorField, 'h1.fontColor'),
|
27991 |
+
'change #mailpoet_h1_font_family': function (event) {
|
27992 |
this.model.set('h1.fontFamily', event.target.value);
|
27993 |
},
|
27994 |
+
'change #mailpoet_h1_font_size': function (event) {
|
27995 |
this.model.set('h1.fontSize', event.target.value);
|
27996 |
},
|
27997 |
'change #mailpoet_h2_font_color': _.partial(this.changeColorField, 'h2.fontColor'),
|
27998 |
+
'change #mailpoet_h2_font_family': function (event) {
|
27999 |
this.model.set('h2.fontFamily', event.target.value);
|
28000 |
},
|
28001 |
+
'change #mailpoet_h2_font_size': function (event) {
|
28002 |
this.model.set('h2.fontSize', event.target.value);
|
28003 |
},
|
28004 |
'change #mailpoet_h3_font_color': _.partial(this.changeColorField, 'h3.fontColor'),
|
28005 |
+
'change #mailpoet_h3_font_family': function (event) {
|
28006 |
this.model.set('h3.fontFamily', event.target.value);
|
28007 |
},
|
28008 |
+
'change #mailpoet_h3_font_size': function (event) {
|
28009 |
this.model.set('h3.fontSize', event.target.value);
|
28010 |
},
|
28011 |
'change #mailpoet_a_font_color': _.partial(this.changeColorField, 'link.fontColor'),
|
28012 |
+
'change #mailpoet_a_font_underline': function (event) {
|
28013 |
this.model.set('link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
28014 |
},
|
28015 |
'change #mailpoet_newsletter_background_color': _.partial(this.changeColorField, 'wrapper.backgroundColor'),
|
28016 |
'change #mailpoet_background_color': _.partial(this.changeColorField, 'body.backgroundColor')
|
28017 |
};
|
28018 |
},
|
28019 |
+
templateContext: function () {
|
28020 |
return {
|
28021 |
model: this.model.toJSON(),
|
28022 |
availableStyles: this.availableStyles.toJSON()
|
28023 |
};
|
28024 |
},
|
28025 |
+
initialize: function (options) {
|
28026 |
this.availableStyles = options.availableStyles;
|
28027 |
},
|
28028 |
+
changeField: function (field, event) {
|
28029 |
this.model.set(field, jQuery(event.target).val());
|
28030 |
},
|
28031 |
+
changeColorField: function (field, event) {
|
28032 |
var value = jQuery(event.target).val();
|
28033 |
if (value === '') {
|
28034 |
value = 'transparent';
|
28038 |
});
|
28039 |
|
28040 |
Module.SidebarPreviewView = Marionette.View.extend({
|
28041 |
+
getTemplate: function () { return window.templates.sidebarPreview; },
|
28042 |
events: {
|
28043 |
'click .mailpoet_show_preview': 'showPreview',
|
28044 |
'click #mailpoet_send_preview': 'sendPreview'
|
28045 |
},
|
28046 |
+
onBeforeDestroy: function () {
|
28047 |
if (this.previewView) {
|
28048 |
this.previewView.destroy();
|
28049 |
this.previewView = null;
|
28050 |
}
|
28051 |
},
|
28052 |
+
showPreview: function () {
|
28053 |
var json = App.toJSON();
|
28054 |
|
28055 |
// Stringify to enable transmission of primitive non-string value types
|
28064 |
endpoint: 'newsletters',
|
28065 |
action: 'showPreview',
|
28066 |
data: json
|
28067 |
+
}).always(function () {
|
28068 |
MailPoet.Modal.loading(false);
|
28069 |
+
}).done(function (response) {
|
28070 |
this.previewView = new Module.NewsletterPreviewView({
|
28071 |
previewUrl: response.meta.preview_url
|
28072 |
});
|
28073 |
|
28074 |
var view = this.previewView.render();
|
28075 |
this.previewView.$el.css('height', '100%');
|
28076 |
+
|
28077 |
MailPoet.Modal.popup({
|
28078 |
template: '',
|
28079 |
element: this.previewView.$el,
|
28080 |
width: '95%',
|
28081 |
height: '94%',
|
28082 |
title: MailPoet.I18n.t('newsletterPreview'),
|
28083 |
+
onCancel: function () {
|
28084 |
this.previewView.destroy();
|
28085 |
this.previewView = null;
|
28086 |
}.bind(this)
|
28089 |
MailPoet.trackEvent('Editor > Browser Preview', {
|
28090 |
'MailPoet Free version': window.mailpoet_version
|
28091 |
});
|
28092 |
+
}.bind(this)).fail(function (response) {
|
28093 |
if (response.errors.length > 0) {
|
28094 |
MailPoet.Notice.error(
|
28095 |
+
response.errors.map(function (error) { return error.message; }),
|
28096 |
{ scroll: true }
|
28097 |
);
|
28098 |
}
|
28099 |
});
|
28100 |
},
|
28101 |
+
sendPreview: function () {
|
28102 |
// get form data
|
28103 |
var $emailField = this.$('#mailpoet_preview_to_email');
|
28104 |
var data = {
|
28121 |
MailPoet.Modal.loading(true);
|
28122 |
|
28123 |
// save before sending
|
28124 |
+
App.getChannel().request('save').always(function () {
|
28125 |
+
CommunicationComponent.previewNewsletter(data).always(function () {
|
28126 |
MailPoet.Modal.loading(false);
|
28127 |
+
}).done(function (response) {
|
28128 |
MailPoet.Notice.success(
|
28129 |
MailPoet.I18n.t('newsletterPreviewSent'),
|
28130 |
{ scroll: true }
|
28133 |
'MailPoet Free version': window.mailpoet_version,
|
28134 |
'Domain name': data.subscriber.substring(data.subscriber.indexOf('@') + 1)
|
28135 |
});
|
28136 |
+
}).fail(function (response) {
|
28137 |
if (response.errors.length > 0) {
|
28138 |
MailPoet.Notice.error(
|
28139 |
+
response.errors.map(function (error) { return error.message; }),
|
28140 |
{ scroll: true, static: true }
|
28141 |
);
|
28142 |
}
|
28146 |
});
|
28147 |
|
28148 |
Module.NewsletterPreviewView = Marionette.View.extend({
|
28149 |
+
getTemplate: function () { return window.templates.newsletterPreview; },
|
28150 |
+
initialize: function (options) {
|
28151 |
this.previewUrl = options.previewUrl;
|
28152 |
this.width = '100%';
|
28153 |
this.height = '100%';
|
28154 |
// this.width = App.getConfig().get('newsletterPreview.width');
|
28155 |
// this.height = App.getConfig().get('newsletterPreview.height')
|
28156 |
},
|
28157 |
+
templateContext: function () {
|
28158 |
return {
|
28159 |
previewUrl: this.previewUrl,
|
28160 |
width: this.width,
|
28163 |
}
|
28164 |
});
|
28165 |
|
28166 |
+
App.on('before:start', function (App, options) {
|
28167 |
var Application = App;
|
28168 |
Application.registerWidget = Module.registerWidget;
|
28169 |
Application.getWidgets = Module.getWidgets;
|
28171 |
Application.getLayoutWidgets = Module.getLayoutWidgets;
|
28172 |
});
|
28173 |
|
28174 |
+
App.on('start', function (App, options) {
|
28175 |
var stylesModel = App.getGlobalStyles(),
|
28176 |
sidebarView = new SidebarView();
|
28177 |
|
28209 |
__webpack_require__(564),
|
28210 |
__webpack_require__(278),
|
28211 |
__webpack_require__(274)
|
28212 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, SuperModel, _, MailPoet) {
|
28213 |
'use strict';
|
28214 |
|
28215 |
var Module = {};
|
28219 |
// handled by other components.
|
28220 |
Module.NewsletterModel = SuperModel.extend({
|
28221 |
whitelisted: ['id', 'subject', 'preheader'],
|
28222 |
+
initialize: function (options) {
|
28223 |
+
this.on('change', function () {
|
28224 |
App.getChannel().trigger('autoSave');
|
28225 |
});
|
28226 |
},
|
28227 |
+
toJSON: function () {
|
28228 |
// Use only whitelisted properties to ensure properties editor
|
28229 |
// doesn't control don't change.
|
28230 |
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
|
28233 |
|
28234 |
// Content block view and model handlers for different content types
|
28235 |
Module._blockTypes = {};
|
28236 |
+
Module.registerBlockType = function (type, data) {
|
28237 |
Module._blockTypes[type] = data;
|
28238 |
};
|
28239 |
+
Module.getBlockTypeModel = function (type) {
|
28240 |
if (type in Module._blockTypes) {
|
28241 |
return Module._blockTypes[type].blockModel;
|
28242 |
} else {
|
28243 |
throw 'Block type not supported: ' + type;
|
28244 |
}
|
28245 |
};
|
28246 |
+
Module.getBlockTypeView = function (type) {
|
28247 |
if (type in Module._blockTypes) {
|
28248 |
return Module._blockTypes[type].blockView;
|
28249 |
} else {
|
28251 |
}
|
28252 |
};
|
28253 |
|
28254 |
+
Module.getBody = function () {
|
28255 |
return {
|
28256 |
content: App._contentContainer.toJSON(),
|
28257 |
globalStyles: App.getGlobalStyles().toJSON()
|
28258 |
};
|
28259 |
};
|
28260 |
|
28261 |
+
Module.toJSON = function () {
|
28262 |
return _.extend({
|
28263 |
body: Module.getBody()
|
28264 |
}, App.getNewsletter().toJSON());
|
28265 |
};
|
28266 |
|
28267 |
+
Module.getNewsletter = function () {
|
28268 |
return Module.newsletter;
|
28269 |
};
|
28270 |
|
28271 |
+
Module.findModels = function (predicate) {
|
28272 |
var blocks = App._contentContainer.getChildren();
|
28273 |
return _.filter(blocks, predicate);
|
28274 |
};
|
28275 |
|
28276 |
+
App.on('before:start', function (Application, options) {
|
28277 |
var App = Application;
|
28278 |
// Expose block methods globally
|
28279 |
App.registerBlockType = Module.registerBlockType;
|
28287 |
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
|
28288 |
});
|
28289 |
|
28290 |
+
App.on('start', function (Application, options) {
|
28291 |
var App = Application;
|
28292 |
var body = options.newsletter.body;
|
28293 |
var content = (_.has(body, 'content')) ? body.content : {};
|
28299 |
);
|
28300 |
}
|
28301 |
|
28302 |
+
App._contentContainer = new (App.getBlockTypeModel('container'))(content, { parse: true });
|
28303 |
App._contentContainerView = new (App.getBlockTypeView('container'))({
|
28304 |
model: App._contentContainer,
|
28305 |
renderOptions: { depth: 0 }
|
28325 |
__webpack_require__(278),
|
28326 |
__webpack_require__(273),
|
28327 |
__webpack_require__(274)
|
28328 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, Backbone, Marionette, _, jQuery, MailPoet) {
|
28329 |
|
28330 |
'use strict';
|
28331 |
|
28332 |
var Module = {};
|
28333 |
|
28334 |
Module.HeadingView = Marionette.View.extend({
|
28335 |
+
getTemplate: function () { return window.templates.heading; },
|
28336 |
+
templateContext: function () {
|
28337 |
return {
|
28338 |
model: this.model.toJSON()
|
28339 |
};
|
28340 |
},
|
28341 |
+
events: function () {
|
28342 |
return {
|
28343 |
'keyup .mailpoet_input_title': _.partial(this.changeField, 'subject'),
|
28344 |
'keyup .mailpoet_input_preheader': _.partial(this.changeField, 'preheader')
|
28345 |
};
|
28346 |
},
|
28347 |
+
changeField: function (field, event) {
|
28348 |
this.model.set(field, jQuery(event.target).val());
|
28349 |
}
|
28350 |
});
|
28351 |
|
28352 |
+
App.on('start', function (App, options) {
|
28353 |
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
|
28354 |
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
|
28355 |
tooltipId: 'tooltip-designer-subject-line-ti',
|
28384 |
__webpack_require__(583),
|
28385 |
__webpack_require__(278),
|
28386 |
__webpack_require__(273)
|
28387 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
28388 |
App,
|
28389 |
CommunicationComponent,
|
28390 |
MailPoet,
|
28405 |
saveTimeout;
|
28406 |
|
28407 |
// Save editor contents to server
|
28408 |
+
Module.save = function () {
|
28409 |
|
28410 |
var json = App.toJSON();
|
28411 |
|
28417 |
App.getChannel().trigger('beforeEditorSave', json);
|
28418 |
|
28419 |
// save newsletter
|
28420 |
+
return CommunicationComponent.saveNewsletter(json).done(function (response) {
|
28421 |
+
if (response.success !== undefined && response.success === true) {
|
28422 |
// TODO: Handle translations
|
28423 |
+
// MailPoet.Notice.success("<?php _e('Newsletter has been saved.'); ?>");
|
28424 |
+
} else if (response.error !== undefined) {
|
28425 |
+
if (response.error.length === 0) {
|
28426 |
MailPoet.Notice.error(
|
28427 |
MailPoet.I18n.t('templateSaveFailed'),
|
28428 |
{
|
28430 |
}
|
28431 |
);
|
28432 |
} else {
|
28433 |
+
$(response.error).each(function (i, error) {
|
28434 |
MailPoet.Notice.error(error, { scroll: true });
|
28435 |
});
|
28436 |
}
|
28437 |
}
|
28438 |
App.getChannel().trigger('afterEditorSave', json, response);
|
28439 |
+
}).fail(function (response) {
|
28440 |
// TODO: Handle saving errors
|
28441 |
App.getChannel().trigger('afterEditorSave', {}, response);
|
28442 |
});
|
28443 |
};
|
28444 |
|
28445 |
+
Module.getThumbnail = function (element, options) {
|
28446 |
var promise = html2canvas(element, options || {});
|
28447 |
|
28448 |
+
return promise.then(function (oldCanvas) {
|
28449 |
// Temporary workaround for html2canvas-alpha2.
|
28450 |
// Removes 1px left transparent border from resulting canvas.
|
28451 |
|
28467 |
});
|
28468 |
};
|
28469 |
|
28470 |
+
Module.saveTemplate = function (options) {
|
28471 |
var that = this,
|
28472 |
promise = jQuery.Deferred();
|
28473 |
|
28474 |
+
promise.then(function (thumbnail) {
|
28475 |
var data = _.extend(options || {}, {
|
28476 |
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
28477 |
body: JSON.stringify(App.getBody())
|
28487 |
|
28488 |
Module.getThumbnail(
|
28489 |
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
28490 |
+
).then(function (thumbnail) {
|
28491 |
promise.resolve(thumbnail);
|
28492 |
});
|
28493 |
|
28494 |
return promise;
|
28495 |
};
|
28496 |
|
28497 |
+
Module.exportTemplate = function (options) {
|
28498 |
var that = this;
|
28499 |
return Module.getThumbnail(
|
28500 |
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
|
28501 |
+
).then(function (thumbnail) {
|
28502 |
var data = _.extend(options || {}, {
|
28503 |
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
28504 |
body: App.getBody()
|
28516 |
};
|
28517 |
|
28518 |
Module.SaveView = Marionette.View.extend({
|
28519 |
+
getTemplate: function () { return window.templates.save; },
|
28520 |
events: {
|
28521 |
'click .mailpoet_save_button': 'save',
|
28522 |
'click .mailpoet_save_show_options': 'toggleSaveOptions',
|
28528 |
'click .mailpoet_save_export': 'toggleExportTemplate',
|
28529 |
'click .mailpoet_export_template': 'exportTemplate'
|
28530 |
},
|
28531 |
+
initialize: function (options) {
|
28532 |
App.getChannel().on('beforeEditorSave', this.beforeSave, this);
|
28533 |
App.getChannel().on('afterEditorSave', this.afterSave, this);
|
28534 |
},
|
28535 |
+
onRender: function () {
|
28536 |
this.validateNewsletter(App.toJSON());
|
28537 |
},
|
28538 |
+
save: function () {
|
28539 |
this.hideOptionContents();
|
28540 |
App.getChannel().request('save');
|
28541 |
},
|
28542 |
+
beforeSave: function () {
|
28543 |
// TODO: Add a loading animation instead
|
28544 |
this.$('.mailpoet_autosaved_at').text(MailPoet.I18n.t('saving'));
|
28545 |
},
|
28546 |
+
afterSave: function (json, response) {
|
28547 |
this.validateNewsletter(json);
|
28548 |
// Update 'Last saved timer'
|
28549 |
this.$('.mailpoet_editor_last_saved').removeClass('mailpoet_hidden');
|
28550 |
this.$('.mailpoet_autosaved_at').text('');
|
28551 |
},
|
28552 |
+
toggleSaveOptions: function () {
|
28553 |
this.$('.mailpoet_save_options').toggleClass('mailpoet_hidden');
|
28554 |
this.$('.mailpoet_save_show_options').toggleClass('mailpoet_save_show_options_active');
|
28555 |
},
|
28556 |
+
toggleSaveAsTemplate: function () {
|
28557 |
this.$('.mailpoet_save_as_template_container').toggleClass('mailpoet_hidden');
|
28558 |
this.toggleSaveOptions();
|
28559 |
},
|
28560 |
+
showSaveAsTemplate: function () {
|
28561 |
this.$('.mailpoet_save_as_template_container').removeClass('mailpoet_hidden');
|
28562 |
this.toggleSaveOptions();
|
28563 |
},
|
28564 |
+
hideSaveAsTemplate: function () {
|
28565 |
this.$('.mailpoet_save_as_template_container').addClass('mailpoet_hidden');
|
28566 |
},
|
28567 |
+
saveAsTemplate: function () {
|
28568 |
var templateName = this.$('.mailpoet_save_as_template_name').val(),
|
28569 |
templateDescription = this.$('.mailpoet_save_as_template_description').val(),
|
28570 |
that = this;
|
28589 |
Module.saveTemplate({
|
28590 |
name: templateName,
|
28591 |
description: templateDescription
|
28592 |
+
}).done(function () {
|
28593 |
MailPoet.Notice.success(
|
28594 |
MailPoet.I18n.t('templateSaved'),
|
28595 |
{
|
28600 |
MailPoet.trackEvent('Editor > Template saved', {
|
28601 |
'MailPoet Free version': window.mailpoet_version
|
28602 |
});
|
28603 |
+
}).fail(function () {
|
28604 |
MailPoet.Notice.error(
|
28605 |
MailPoet.I18n.t('templateSaveFailed'),
|
28606 |
{
|
28613 |
}
|
28614 |
|
28615 |
},
|
28616 |
+
toggleExportTemplate: function () {
|
28617 |
this.$('.mailpoet_export_template_container').toggleClass('mailpoet_hidden');
|
28618 |
this.toggleSaveOptions();
|
28619 |
},
|
28620 |
+
hideExportTemplate: function () {
|
28621 |
this.$('.mailpoet_export_template_container').addClass('mailpoet_hidden');
|
28622 |
},
|
28623 |
+
exportTemplate: function () {
|
28624 |
var templateName = this.$('.mailpoet_export_template_name').val(),
|
28625 |
templateDescription = this.$('.mailpoet_export_template_description').val(),
|
28626 |
that = this;
|
28649 |
this.hideExportTemplate();
|
28650 |
}
|
28651 |
},
|
28652 |
+
hideOptionContents: function () {
|
28653 |
this.hideSaveAsTemplate();
|
28654 |
this.hideExportTemplate();
|
28655 |
this.$('.mailpoet_save_options').addClass('mailpoet_hidden');
|
28656 |
},
|
28657 |
+
next: function () {
|
28658 |
this.hideOptionContents();
|
28659 |
+
if (!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
|
28660 |
Module._cancelAutosave();
|
28661 |
+
Module.save().done(function (response) {
|
28662 |
window.location.href = App.getConfig().get('urls.send');
|
28663 |
});
|
28664 |
}
|
28665 |
},
|
28666 |
+
validateNewsletter: function (jsonObject) {
|
28667 |
if (!App._contentContainer.isValid()) {
|
28668 |
this.showValidationError(App._contentContainer.validationError);
|
28669 |
return;
|
28679 |
|
28680 |
this.hideValidationError();
|
28681 |
},
|
28682 |
+
showValidationError: function (message) {
|
28683 |
var $el = this.$('.mailpoet_save_error');
|
28684 |
$el.text(message);
|
28685 |
$el.removeClass('mailpoet_hidden');
|
28686 |
|
28687 |
this.$('.mailpoet_save_next').addClass('button-disabled');
|
28688 |
},
|
28689 |
+
hideValidationError: function () {
|
28690 |
this.$('.mailpoet_save_error').addClass('mailpoet_hidden');
|
28691 |
this.$('.mailpoet_save_next').removeClass('button-disabled');
|
28692 |
}
|
28693 |
});
|
28694 |
|
28695 |
+
Module.autoSave = function () {
|
28696 |
// Delay in saving editor contents, during which a new autosave
|
28697 |
// may be requested
|
28698 |
var AUTOSAVE_DELAY_DURATION = 1000;
|
28699 |
|
28700 |
Module._cancelAutosave();
|
28701 |
+
saveTimeout = setTimeout(function () {
|
28702 |
+
App.getChannel().request('save').always(function () {
|
28703 |
Module._cancelAutosave();
|
28704 |
});
|
28705 |
}, AUTOSAVE_DELAY_DURATION);
|
28706 |
};
|
28707 |
|
28708 |
+
Module._cancelAutosave = function () {
|
28709 |
if (!saveTimeout) return;
|
28710 |
|
28711 |
clearTimeout(saveTimeout);
|
28712 |
saveTimeout = undefined;
|
28713 |
};
|
28714 |
|
28715 |
+
Module.beforeExitWithUnsavedChanges = function (e) {
|
28716 |
if (saveTimeout) {
|
28717 |
var message = MailPoet.I18n.t('unsavedChangesWillBeLost');
|
28718 |
var event = e || window.event;
|
28725 |
}
|
28726 |
};
|
28727 |
|
28728 |
+
App.on('before:start', function (App, options) {
|
28729 |
var Application = App;
|
28730 |
Application.save = Module.save;
|
28731 |
Application.getChannel().on('autoSave', Module.autoSave);
|
28735 |
Application.getChannel().reply('save', Application.save);
|
28736 |
});
|
28737 |
|
28738 |
+
App.on('start', function (App, options) {
|
28739 |
var saveView = new Module.SaveView();
|
28740 |
App._appView.showChildView('bottomRegion', saveView);
|
28741 |
});
|
33306 |
*/
|
33307 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
33308 |
__webpack_require__(562)
|
33309 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (BackboneMarionette) {
|
33310 |
var Marionette = BackboneMarionette;
|
33311 |
var BehaviorsLookup = {};
|
33312 |
+
Marionette.Behaviors.behaviorsLookup = function () {
|
33313 |
return BehaviorsLookup;
|
33314 |
};
|
33315 |
|
33334 |
__webpack_require__(585),
|
33335 |
__webpack_require__(274),
|
33336 |
__webpack_require__(566)
|
33337 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, BehaviorsLookup, MailPoet, Spectrum) {
|
33338 |
var BL = BehaviorsLookup;
|
33339 |
|
33340 |
BL.ColorPickerBehavior = Marionette.Behavior.extend({
|
33341 |
+
onRender: function () {
|
33342 |
+
var that = this,
|
33343 |
preferredFormat = 'hex6';
|
33344 |
this.view.$('.mailpoet_color').each(function () {
|
33345 |
var $input = that.view.$(this);
|
33346 |
+
var updateColorInput = function (color) {
|
33347 |
+
if (color && color.getAlpha() > 0) {
|
33348 |
$input.val(color.toString(preferredFormat));
|
33349 |
} else {
|
33350 |
$input.val('');
|
33367 |
move: updateColorInput,
|
33368 |
hide: updateColorInput
|
33369 |
});
|
33370 |
+
});
|
33371 |
}
|
33372 |
});
|
33373 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
33392 |
__webpack_require__(273),
|
33393 |
__webpack_require__(585),
|
33394 |
__webpack_require__(565)
|
33395 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, _, jQuery, BL, interact) {
|
33396 |
var BehaviorsLookup = BL;
|
33397 |
|
33398 |
BehaviorsLookup.ContainerDropZoneBehavior = Marionette.Behavior.extend({
|
33399 |
defaults: {
|
33400 |
columnLimit: 3
|
33401 |
},
|
33402 |
+
onRender: function () {
|
33403 |
var dragAndDropDisabled = _.isObject(this.view.options.renderOptions) && this.view.options.renderOptions.disableDragAndDrop === true;
|
33404 |
if (!dragAndDropDisabled) {
|
33405 |
this.addDropZone();
|
33406 |
}
|
33407 |
},
|
33408 |
+
addDropZone: function (_event) {
|
33409 |
var that = this,
|
33410 |
view = this.view,
|
33411 |
domElement = that.$el.get(0),
|
33427 |
interact(domElement).dropzone({
|
33428 |
accept: acceptableElementSelector,
|
33429 |
overlap: 'pointer', // Mouse pointer denotes location of a droppable
|
33430 |
+
ondragenter: function (event) {
|
33431 |
// 1. Visually mark block as active for dropping
|
33432 |
view.$el.addClass('mailpoet_drop_active');
|
33433 |
},
|
33434 |
+
ondragleave: function (event) {
|
33435 |
// 1. Remove visual markings of active dropping container
|
33436 |
// 2. Remove visual markings of drop position visualization
|
33437 |
that.cleanup();
|
33438 |
},
|
33439 |
+
ondropmove: function (event) {
|
33440 |
// 1. Compute actual location of the mouse within the container
|
33441 |
// 2. Check if insertion is regular (between blocks) or special (with container insertion)
|
33442 |
// 3a. If insertion is regular, compute position where insertion should happen
|
33530 |
// compensated for to position marker right in the middle of two
|
33531 |
// blocks
|
33532 |
if (dropPosition.position === 'before') {
|
33533 |
+
$targetBlock = that.getChildren().findByModel(viewCollection.at(dropPosition.index - 1)).$el;
|
33534 |
} else {
|
33535 |
$targetBlock = that.getChildren().findByModel(viewCollection.at(dropPosition.index)).$el;
|
33536 |
}
|
33543 |
|
33544 |
element.append(marker);
|
33545 |
},
|
33546 |
+
ondrop: function (event) {
|
33547 |
// 1. Compute actual location of the mouse
|
33548 |
// 2. Check if insertion is regular (between blocks) or special (with container insertion)
|
33549 |
// 3a. If insertion is regular
|
33581 |
orientation: 'vertical'
|
33582 |
});
|
33583 |
tempCollection.get('blocks').add(droppableModel);
|
33584 |
+
viewCollection.add(tempCollection, { at: index });
|
33585 |
} else {
|
33586 |
+
viewCollection.add(droppableModel, { at: index });
|
33587 |
}
|
33588 |
|
33589 |
droppedView = that.getChildren().findByModel(droppableModel);
|
33627 |
tempCollection.get('blocks').add(droppableModel);
|
33628 |
}
|
33629 |
}
|
33630 |
+
viewCollection.add(tempCollection, { at: dropPosition.index });
|
33631 |
|
33632 |
// Call post add actions
|
33633 |
droppedView = that.getChildren().findByModel(tempCollection).children.findByModel(droppableModel);
|
33644 |
}
|
33645 |
});
|
33646 |
},
|
33647 |
+
cleanup: function () {
|
33648 |
// 1. Remove visual markings of active dropping container
|
33649 |
this.view.$el.removeClass('mailpoet_drop_active');
|
33650 |
|
33651 |
// 2. Remove visual markings of drop position visualization
|
33652 |
this.view.$('.mailpoet_drop_marker').remove();
|
33653 |
},
|
33654 |
+
getDropPosition: function (eventX, eventY, is_unsafe) {
|
33655 |
var SPECIAL_AREA_INSERTION_WIDTH = 0.00, // Disable special insertion. Default: 0.3
|
33656 |
|
33657 |
element = this.view.$el,
|
33733 |
position: position // 'inside'|'before'|'after'
|
33734 |
};
|
33735 |
},
|
33736 |
+
_computeNormalIndex: function (eventX, eventY) {
|
33737 |
// Normal insertion inserts dropModel before target element if
|
33738 |
// event happens on the first half of the element and after the
|
33739 |
// target element if event happens on the second half of the element.
|
33770 |
};
|
33771 |
}
|
33772 |
},
|
33773 |
+
_computeSpecialIndex: function (eventX, eventY) {
|
33774 |
return this._computeCellIndex(eventX, eventY);
|
33775 |
},
|
33776 |
+
_computeCellIndex: function (eventX, eventY) {
|
33777 |
var orientation = this.view.model.get('orientation'),
|
33778 |
eventOffset = (orientation === 'vertical') ? eventY : eventX,
|
33779 |
+
resultView = this.getChildren().find(function (view) {
|
33780 |
var element = view.$el,
|
33781 |
closeOffset, farOffset;
|
33782 |
|
33796 |
|
33797 |
return index;
|
33798 |
},
|
33799 |
+
_canAcceptNormalInsertion: function () {
|
33800 |
var orientation = this.view.model.get('orientation'),
|
33801 |
depth = this.view.renderOptions.depth,
|
33802 |
childCount = this.getChildren().length;
|
33803 |
// Note that depth is zero indexed. Root container has depth=0
|
33804 |
return orientation === 'vertical' || (orientation === 'horizontal' && depth === 1 && childCount < this.options.columnLimit);
|
33805 |
},
|
33806 |
+
_canAcceptSpecialInsertion: function () {
|
33807 |
var orientation = this.view.model.get('orientation'),
|
33808 |
depth = this.view.renderOptions.depth,
|
33809 |
childCount = this.getChildren().length;
|
33810 |
return depth === 0 || (depth === 1 && orientation === 'horizontal' && childCount <= this.options.columnLimit);
|
33811 |
},
|
33812 |
+
getCollectionView: function () {
|
33813 |
return this.view.getChildView('blocks');
|
33814 |
},
|
33815 |
+
getChildren: function () {
|
33816 |
return this.getCollectionView().children;
|
33817 |
},
|
33818 |
+
getCollection: function () {
|
33819 |
return this.getCollectionView().collection;
|
33820 |
}
|
33821 |
});
|
33839 |
__webpack_require__(273),
|
33840 |
__webpack_require__(585),
|
33841 |
__webpack_require__(565)
|
33842 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, _, jQuery, BehaviorsLookup, interact) {
|
33843 |
var BL = BehaviorsLookup;
|
33844 |
|
33845 |
BL.DraggableBehavior = Marionette.Behavior.extend({
|
33853 |
*
|
33854 |
* @return Backbone.Model A model that will be passed to the receiver
|
33855 |
*/
|
33856 |
+
getDropModel: function () {
|
33857 |
throw "Missing 'drop' function for DraggableBehavior";
|
33858 |
},
|
33859 |
|
33860 |
+
onDrop: function (model, view) {},
|
33861 |
+
testAttachToInstance: function (model, view) { return true; }
|
33862 |
},
|
33863 |
+
onRender: function () {
|
33864 |
var that = this,
|
33865 |
interactable;
|
33866 |
|
33876 |
// Scroll when dragging near edges of a window
|
33877 |
autoScroll: true,
|
33878 |
|
33879 |
+
onstart: function (startEvent) {
|
33880 |
var event = startEvent;
|
33881 |
|
33882 |
if (that.options.cloneOriginal === true) {
|
33900 |
// Accurate dimensions can only be taken after insertion to document
|
33901 |
centerXOffset = $clone.width() / 2;
|
33902 |
centerYOffset = $clone.height() / 2;
|
33903 |
+
$clone.css('top', event.pageY - centerYOffset);
|
33904 |
$clone.css('left', event.pageX - centerXOffset);
|
33905 |
|
33906 |
event.interaction.element = clone;
|
33960 |
} else {
|
33961 |
interactable.getDropModel = this.view.getDropFunc();
|
33962 |
}
|
33963 |
+
interactable.onDrop = function (opts) {
|
33964 |
var options = opts;
|
33965 |
if (_.isObject(options)) {
|
33966 |
// Inject Draggable behavior if possible
|
33987 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
33988 |
__webpack_require__(562),
|
33989 |
__webpack_require__(585)
|
33990 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, BehaviorsLookup) {
|
33991 |
var BL = BehaviorsLookup;
|
33992 |
|
33993 |
BL.HighlightContainerBehavior = Marionette.Behavior.extend({
|
33995 |
'mouseenter @ui.tools': 'enableHighlight',
|
33996 |
'mouseleave @ui.tools': 'disableHighlight'
|
33997 |
},
|
33998 |
+
enableHighlight: function () {
|
33999 |
this.$el.addClass('mailpoet_highlight');
|
34000 |
},
|
34001 |
+
disableHighlight: function () {
|
34002 |
if (!this.view._isBeingEdited) {
|
34003 |
this.$el.removeClass('mailpoet_highlight');
|
34004 |
}
|
34020 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
34021 |
__webpack_require__(562),
|
34022 |
__webpack_require__(585)
|
34023 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, BehaviorsLookup) {
|
34024 |
var BL = BehaviorsLookup;
|
34025 |
|
34026 |
BL.HighlightEditingBehavior = Marionette.Behavior.extend({
|
34028 |
startEditing: 'enableHighlight',
|
34029 |
stopEditing: 'disableHighlight'
|
34030 |
},
|
34031 |
+
enableHighlight: function () {
|
34032 |
this.view._isBeingEdited = true;
|
34033 |
this.$el.addClass('mailpoet_highlight');
|
34034 |
},
|
34035 |
+
disableHighlight: function () {
|
34036 |
this.view._isBeingEdited = false;
|
34037 |
this.$el.removeClass('mailpoet_highlight');
|
34038 |
}
|
34054 |
__webpack_require__(562),
|
34055 |
__webpack_require__(585),
|
34056 |
__webpack_require__(565)
|
34057 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, BehaviorsLookup, interact) {
|
34058 |
var BL = BehaviorsLookup;
|
34059 |
|
34060 |
BL.ResizableBehavior = Marionette.Behavior.extend({
|
34061 |
defaults: {
|
34062 |
elementSelector: null,
|
34063 |
resizeHandleSelector: true, // true will use edges of the element itself
|
|
|
34064 |
minLength: 0,
|
34065 |
+
maxLength: Infinity,
|
34066 |
+
modelField: 'styles.block.height',
|
34067 |
+
onResize: function (event) {
|
34068 |
+
var currentLength = parseFloat(this.view.model.get(this.options.modelField)),
|
34069 |
+
newLength = currentLength + event.y;
|
34070 |
+
newLength = Math.min(this.options.maxLength, Math.max(this.options.minLength, newLength));
|
34071 |
+
this.view.model.set(this.options.modelField, newLength + 'px');
|
34072 |
+
}
|
34073 |
},
|
34074 |
events: {
|
34075 |
mouseenter: 'showResizeHandle',
|
34076 |
mouseleave: 'hideResizeHandle'
|
34077 |
},
|
34078 |
+
onRender: function () {
|
34079 |
this.attachResize();
|
34080 |
|
34081 |
if (this.isBeingResized !== true) {
|
34082 |
this.hideResizeHandle();
|
34083 |
}
|
34084 |
},
|
34085 |
+
attachResize: function () {
|
34086 |
var domElement = (this.options.elementSelector === null) ? this.view.$el.get(0) : this.view.$(this.options.elementSelector).get(0),
|
34087 |
that = this;
|
34088 |
interact(domElement).resizable({
|
34089 |
+
// axis: 'y',
|
34090 |
edges: {
|
34091 |
top: false,
|
34092 |
left: false,
|
34093 |
right: false,
|
34094 |
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
|
34095 |
}
|
34096 |
+
})
|
34097 |
+
.on('resizestart', function (event) {
|
34098 |
that.isBeingResized = true;
|
34099 |
that.$el.addClass('mailpoet_resize_active');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34100 |
})
|
34101 |
+
.on('resizemove', function (event) {
|
34102 |
+
var onResize = that.options.onResize.bind(that);
|
34103 |
+
return onResize(event);
|
34104 |
+
})
|
34105 |
+
.on('resizeend', function (event) {
|
34106 |
that.isBeingResized = null;
|
34107 |
that.$el.removeClass('mailpoet_resize_active');
|
34108 |
});
|
34109 |
},
|
34110 |
+
showResizeHandle: function () {
|
34111 |
if (typeof this.options.resizeHandleSelector === 'string') {
|
34112 |
this.view.$(this.options.resizeHandleSelector).removeClass('mailpoet_hidden');
|
34113 |
}
|
34114 |
},
|
34115 |
+
hideResizeHandle: function () {
|
34116 |
if (typeof this.options.resizeHandleSelector === 'string') {
|
34117 |
this.view.$(this.options.resizeHandleSelector).addClass('mailpoet_hidden');
|
34118 |
}
|
34135 |
__webpack_require__(562),
|
34136 |
__webpack_require__(278),
|
34137 |
__webpack_require__(585)
|
34138 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, _, BehaviorsLookup) {
|
34139 |
var BL = BehaviorsLookup;
|
34140 |
|
34141 |
BL.SortableBehavior = Marionette.Behavior.extend({
|
34142 |
+
onRender: function () {
|
34143 |
var collection = this.view.collection;
|
34144 |
|
34145 |
if (_.isFunction(this.$el.sortable)) {
|
34146 |
this.$el.sortable({
|
34147 |
cursor: 'move',
|
34148 |
+
start: function (event, ui) {
|
34149 |
ui.item.data('previousIndex', ui.item.index());
|
34150 |
},
|
34151 |
+
end: function (event, ui) {
|
34152 |
ui.item.removeData('previousIndex');
|
34153 |
},
|
34154 |
+
update: function (event, ui) {
|
34155 |
var previousIndex = ui.item.data('previousIndex'),
|
34156 |
newIndex = ui.item.index(),
|
34157 |
model = collection.at(previousIndex);
|
34183 |
__webpack_require__(562),
|
34184 |
__webpack_require__(273),
|
34185 |
__webpack_require__(585)
|
34186 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, jQuery, BehaviorsLookup) {
|
34187 |
var BL = BehaviorsLookup;
|
34188 |
|
34189 |
BL.ShowSettingsBehavior = Marionette.Behavior.extend({
|
34193 |
events: {
|
34194 |
'click .mailpoet_content': 'showSettings'
|
34195 |
},
|
34196 |
+
showSettings: function (event) {
|
34197 |
+
if (!this.isIgnoredElement(event.target)) {
|
34198 |
this.view.triggerMethod('showSettings');
|
34199 |
}
|
34200 |
},
|
34201 |
+
isIgnoredElement: function (element) {
|
34202 |
return this.options.ignoreFrom
|
34203 |
&& this.options.ignoreFrom.length > 0
|
34204 |
&& jQuery(element).is(this.options.ignoreFrom);
|
34222 |
__webpack_require__(562),
|
34223 |
__webpack_require__(278),
|
34224 |
__webpack_require__(585)
|
34225 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Marionette, _, BehaviorsLookup) {
|
34226 |
var BL = BehaviorsLookup;
|
34227 |
|
34228 |
BL.TextEditorBehavior = Marionette.Behavior.extend({
|
34234 |
invalidElements: 'script',
|
34235 |
blockFormats: 'Paragraph=p',
|
34236 |
plugins: 'link textcolor colorpicker mailpoet_shortcodes',
|
34237 |
+
configurationFilter: function (originalConfig) { return originalConfig; }
|
34238 |
},
|
34239 |
+
onDomRefresh: function () {
|
34240 |
var that = this;
|
34241 |
if (this.view.disableTextEditor === true) {
|
34242 |
return;
|
34257 |
relative_urls: false,
|
34258 |
remove_script_host: false,
|
34259 |
convert_urls: true,
|
34260 |
+
urlconverter_callback: function (url, node, on_save, name) {
|
34261 |
if (url.match(/\[.+\]/g)) {
|
34262 |
// Do not convert URLs with shortcodes
|
34263 |
return url;
|
34271 |
|
34272 |
plugins: this.options.plugins,
|
34273 |
|
34274 |
+
setup: function (editor) {
|
34275 |
+
editor.on('change', function (e) {
|
34276 |
that.view.triggerMethod('text:editor:change', editor.getContent());
|
34277 |
});
|
34278 |
|
34279 |
+
editor.on('click', function (e) {
|
34280 |
editor.focus();
|
34281 |
if (that._isActivationClick) {
|
34282 |
editor.selection.setRng(
|
34286 |
}
|
34287 |
});
|
34288 |
|
34289 |
+
editor.on('focus', function (e) {
|
34290 |
that.view.triggerMethod('text:editor:focus');
|
34291 |
that._isActivationClick = true;
|
34292 |
});
|
34293 |
|
34294 |
+
editor.on('blur', function (e) {
|
34295 |
that.view.triggerMethod('text:editor:blur');
|
34296 |
});
|
34297 |
}
|
34320 |
__webpack_require__(273),
|
34321 |
__webpack_require__(274),
|
34322 |
__webpack_require__(555)
|
34323 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
|
34324 |
|
34325 |
'use strict';
|
34326 |
|
34329 |
|
34330 |
Module.BlockModel = SuperModel.extend({
|
34331 |
stale: [], // Attributes to be removed upon saving
|
34332 |
+
initialize: function () {
|
34333 |
var that = this;
|
34334 |
+
this.on('change', function () {
|
34335 |
App.getChannel().trigger('autoSave');
|
34336 |
});
|
34337 |
},
|
34338 |
+
_getDefaults: function (blockDefaults, configDefaults) {
|
34339 |
var defaults = (_.isObject(configDefaults) && _.isFunction(configDefaults.toJSON)) ? configDefaults.toJSON() : configDefaults;
|
34340 |
|
34341 |
// Patch the resulting JSON object and fix it's constructors to be Object.
|
34344 |
// TODO: Investigate for a better solution
|
34345 |
return JSON.parse(JSON.stringify(jQuery.extend(blockDefaults, defaults || {})));
|
34346 |
},
|
34347 |
+
toJSON: function () {
|
34348 |
// Remove stale attributes from resulting JSON object
|
34349 |
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
|
34350 |
},
|
34351 |
+
getChildren: function () {
|
34352 |
return [];
|
34353 |
}
|
34354 |
});
|
34370 |
DraggableBehavior: {
|
34371 |
cloneOriginal: true,
|
34372 |
hideOriginal: true,
|
34373 |
+
onDrop: function (options) {
|
34374 |
// After a clone of model has been dropped, cleanup
|
34375 |
// and destroy self
|
34376 |
options.dragBehavior.view.model.destroy();
|
34377 |
},
|
34378 |
+
onDragSubstituteBy: function (behavior) {
|
34379 |
var WidgetView, node;
|
34380 |
// When block is being dragged, display the widget icon instead.
|
34381 |
// This will create an instance of block's widget view and
|
34391 |
},
|
34392 |
HighlightEditingBehavior: {}
|
34393 |
},
|
34394 |
+
templateContext: function () {
|
34395 |
return {
|
34396 |
model: this.model.toJSON(),
|
34397 |
viewCid: this.cid
|
34398 |
};
|
34399 |
},
|
34400 |
+
constructor: function () {
|
34401 |
AugmentedView.apply(this, arguments);
|
34402 |
this.$el.addClass('mailpoet_editor_view_' + this.cid);
|
34403 |
},
|
34404 |
+
initialize: function () {
|
34405 |
this.on('showSettings', this.showSettings, this);
|
34406 |
this.on('dom:refresh', this.showBlock, this);
|
34407 |
this._isFirstRender = true;
|
34408 |
},
|
34409 |
+
showTools: function (_event) {
|
34410 |
if (!this.showingToolsDisabled) {
|
34411 |
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
|
34412 |
this.toolsView.triggerMethod('showTools');
|
34413 |
}
|
34414 |
},
|
34415 |
+
hideTools: function (e) {
|
34416 |
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
|
34417 |
this.toolsView.triggerMethod('hideTools');
|
34418 |
},
|
34419 |
+
enableShowingTools: function () {
|
34420 |
this.showingToolsDisabled = false;
|
34421 |
},
|
34422 |
+
disableShowingTools: function () {
|
34423 |
this.showingToolsDisabled = true;
|
34424 |
this.hideTools();
|
34425 |
},
|
34426 |
+
showSettings: function (options) {
|
34427 |
this.toolsView.triggerMethod('showSettings', options);
|
34428 |
},
|
34429 |
/**
|
34430 |
* Defines drop behavior of BlockView instance
|
34431 |
*/
|
34432 |
+
getDropFunc: function () {
|
34433 |
+
return function () {
|
34434 |
return this.model.clone();
|
34435 |
}.bind(this);
|
34436 |
},
|
34437 |
+
disableDragging: function () {
|
34438 |
this.$el.addClass('mailpoet_ignore_drag');
|
34439 |
},
|
34440 |
+
enableDragging: function () {
|
34441 |
this.$el.removeClass('mailpoet_ignore_drag');
|
34442 |
},
|
34443 |
+
showBlock: function () {
|
34444 |
if (this._isFirstRender) {
|
34445 |
this.transitionIn();
|
34446 |
this._isFirstRender = false;
|
34447 |
}
|
34448 |
},
|
34449 |
+
deleteBlock: function () {
|
34450 |
+
this.transitionOut().then(function () {
|
34451 |
this.model.destroy();
|
34452 |
}.bind(this));
|
34453 |
},
|
34454 |
+
duplicateBlock: function () {
|
34455 |
+
this.model.collection.add(this.model.toJSON(), { at: this.model.collection.findIndex(this.model) });
|
34456 |
},
|
34457 |
+
transitionIn: function () {
|
34458 |
return this._transition('slideDown', 'fadeIn', 'easeOut');
|
34459 |
},
|
34460 |
+
transitionOut: function () {
|
34461 |
return this._transition('slideUp', 'fadeOut', 'easeIn');
|
34462 |
},
|
34463 |
+
_transition: function (slideDirection, fadeDirection, easing) {
|
34464 |
var promise = jQuery.Deferred();
|
34465 |
|
34466 |
this.$el.velocity(
|
34468 |
{
|
34469 |
duration: 250,
|
34470 |
easing: easing,
|
34471 |
+
complete: function () {
|
34472 |
promise.resolve();
|
34473 |
}.bind(this)
|
34474 |
}
|
34486 |
});
|
34487 |
|
34488 |
Module.BlockToolsView = AugmentedView.extend({
|
34489 |
+
getTemplate: function () { return window.templates.genericBlockTools; },
|
34490 |
events: {
|
34491 |
'click .mailpoet_edit_block': 'changeSettings',
|
34492 |
'click .mailpoet_delete_block_activate': 'showDeletionConfirmation',
|
34501 |
duplicate: true,
|
34502 |
move: true
|
34503 |
},
|
34504 |
+
getSettingsView: function () { return Module.BlockSettingsView; },
|
34505 |
+
initialize: function (opts) {
|
34506 |
var options = opts || {};
|
34507 |
if (!_.isUndefined(options.tools)) {
|
34508 |
// Make a new block specific tool config object
|
34513 |
this.on('hideTools', this.hideDeletionConfirmation, this);
|
34514 |
this.on('showSettings', this.changeSettings);
|
34515 |
},
|
34516 |
+
templateContext: function () {
|
34517 |
return {
|
34518 |
model: this.model.toJSON(),
|
34519 |
viewCid: this.cid,
|
34520 |
tools: this.tools
|
34521 |
};
|
34522 |
},
|
34523 |
+
changeSettings: function (options) {
|
34524 |
var ViewType = this.getSettingsView();
|
34525 |
(new ViewType(_.extend({ model: this.model }, options || {}))).render();
|
34526 |
},
|
34527 |
+
showDeletionConfirmation: function () {
|
34528 |
this.$('.mailpoet_delete_block').addClass('mailpoet_delete_block_activated');
|
34529 |
},
|
34530 |
+
hideDeletionConfirmation: function () {
|
34531 |
this.$('.mailpoet_delete_block').removeClass('mailpoet_delete_block_activated');
|
34532 |
},
|
34533 |
+
deleteBlock: function (event) {
|
34534 |
event.preventDefault();
|
34535 |
this.model.trigger('delete');
|
34536 |
return false;
|
34537 |
},
|
34538 |
+
duplicateBlock: function (event) {
|
34539 |
event.preventDefault();
|
34540 |
this.model.trigger('duplicate');
|
34541 |
return false;
|
34547 |
behaviors: {
|
34548 |
ColorPickerBehavior: {}
|
34549 |
},
|
34550 |
+
initialize: function (params) {
|
34551 |
this.model.trigger('startEditing');
|
34552 |
var panelParams = {
|
34553 |
element: this.$el,
|
34554 |
template: '',
|
34555 |
position: 'right',
|
34556 |
width: App.getConfig().get('sidepanelWidth'),
|
34557 |
+
onCancel: function () {
|
34558 |
this.destroy();
|
34559 |
}.bind(this)
|
34560 |
};
|
34565 |
MailPoet.Modal.panel(panelParams);
|
34566 |
}
|
34567 |
},
|
34568 |
+
templateContext: function () {
|
34569 |
return {
|
34570 |
model: this.model.toJSON()
|
34571 |
};
|
34572 |
},
|
34573 |
+
close: function (event) {
|
34574 |
this.destroy();
|
34575 |
},
|
34576 |
+
changeField: function (field, event) {
|
34577 |
this.model.set(field, jQuery(event.target).val());
|
34578 |
},
|
34579 |
+
changePixelField: function (field, event) {
|
34580 |
this.changeFieldWithSuffix(field, event, 'px');
|
34581 |
},
|
34582 |
+
changeFieldWithSuffix: function (field, event, suffix) {
|
34583 |
this.model.set(field, jQuery(event.target).val() + suffix);
|
34584 |
},
|
34585 |
+
changeBoolField: function (field, event) {
|
34586 |
this.model.set(field, (jQuery(event.target).val() === 'true'));
|
34587 |
},
|
34588 |
+
changeBoolCheckboxField: function (field, event) {
|
34589 |
this.model.set(field, (!!jQuery(event.target).prop('checked')));
|
34590 |
},
|
34591 |
+
changeColorField: function (field, event) {
|
34592 |
var value = jQuery(event.target).val();
|
34593 |
if (value === '') {
|
34594 |
value = 'transparent';
|
34595 |
}
|
34596 |
this.model.set(field, value);
|
34597 |
},
|
34598 |
+
onBeforeDestroy: function () {
|
34599 |
MailPoet.Modal.close();
|
34600 |
this.model.trigger('stopEditing');
|
34601 |
}
|
34605 |
className: 'mailpoet_widget mailpoet_droppable_block mailpoet_droppable_widget',
|
34606 |
behaviors: {
|
34607 |
DraggableBehavior: {
|
34608 |
+
drop: function () {
|
34609 |
throw 'Unsupported operation';
|
34610 |
}
|
34611 |
}
|
34633 |
__webpack_require__(273),
|
34634 |
__webpack_require__(574),
|
34635 |
__webpack_require__(595)
|
34636 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (Backbone, Marionette, _, jQuery, App, BaseBlock) {
|
34637 |
|
34638 |
'use strict';
|
34639 |
|
34643 |
|
34644 |
BlockCollection = Backbone.Collection.extend({
|
34645 |
model: base.BlockModel,
|
34646 |
+
initialize: function () {
|
34647 |
+
this.on('add change remove', function () { App.getChannel().trigger('autoSave'); });
|
34648 |
},
|
34649 |
+
parse: function (response) {
|
34650 |
var self = this;
|
34651 |
+
return _.map(response, function (block) {
|
34652 |
var Type = App.getBlockTypeModel(block.type);
|
34653 |
// TODO: If type has no registered model, use a backup one
|
34654 |
+
return new Type(block, { parse: true });
|
34655 |
});
|
34656 |
}
|
34657 |
});
|
34660 |
relations: {
|
34661 |
blocks: BlockCollection
|
34662 |
},
|
34663 |
+
defaults: function () {
|
34664 |
return this._getDefaults({
|
34665 |
type: 'container',
|
34666 |
orientation: 'vertical',
|
34672 |
blocks: new BlockCollection()
|
34673 |
}, App.getConfig().get('blockDefaults.container'));
|
34674 |
},
|
34675 |
+
validate: function () {
|
34676 |
// Recursively propagate validation checks to blocks in the tree
|
34677 |
+
var invalidBlock = this.get('blocks').find(function (block) { return !block.isValid(); });
|
34678 |
if (invalidBlock) {
|
34679 |
return invalidBlock.validationError;
|
34680 |
}
|
34681 |
},
|
34682 |
+
parse: function (response) {
|
34683 |
// If container has any blocks - add them to a collection
|
34684 |
if (response.type === 'container' && _.has(response, 'blocks')) {
|
34685 |
response.blocks = new BlockCollection(response.blocks, {
|
34688 |
}
|
34689 |
return response;
|
34690 |
},
|
34691 |
+
getChildren: function () {
|
34692 |
+
var models = this.get('blocks').map(function (model, index, list) {
|
34693 |
return [model, model.getChildren()];
|
34694 |
});
|
34695 |
|
34699 |
|
34700 |
Module.ContainerBlocksView = Marionette.CollectionView.extend({
|
34701 |
className: 'mailpoet_container',
|
34702 |
+
childView: function (model) {
|
34703 |
return App.getBlockTypeView(model.get('type'));
|
34704 |
},
|
34705 |
+
childViewOptions: function () {
|
34706 |
var newRenderOptions = _.clone(this.renderOptions);
|
34707 |
if (newRenderOptions.depth !== undefined) {
|
34708 |
newRenderOptions.depth += 1;
|
34711 |
renderOptions: newRenderOptions
|
34712 |
};
|
34713 |
},
|
34714 |
+
emptyView: function () { return Module.ContainerBlockEmptyView; },
|
34715 |
+
emptyViewOptions: function () { return { renderOptions: this.renderOptions }; },
|
34716 |
+
initialize: function (options) {
|
34717 |
this.renderOptions = options.renderOptions;
|
34718 |
}
|
34719 |
});
|
34726 |
}
|
34727 |
}),
|
34728 |
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
|
34729 |
+
getTemplate: function () { return window.templates.containerBlock; },
|
34730 |
events: _.extend({}, base.BlockView.prototype.events, {
|
34731 |
'click .mailpoet_newsletter_layer_selector': 'toggleEditingLayer'
|
34732 |
}),
|
34738 |
DraggableBehavior: {
|
34739 |
cloneOriginal: true,
|
34740 |
hideOriginal: true,
|
34741 |
+
onDrop: function (options) {
|
34742 |
// After a clone of model has been dropped, cleanup
|
34743 |
// and destroy self
|
34744 |
options.dragBehavior.view.model.destroy();
|
34745 |
},
|
34746 |
+
onDragSubstituteBy: function (behavior) {
|
34747 |
var WidgetView, node;
|
34748 |
// When block is being dragged, display the widget icon instead.
|
34749 |
// This will create an instance of block's widget view and
|
34756 |
return node;
|
34757 |
}
|
34758 |
},
|
34759 |
+
testAttachToInstance: function (model, view) {
|
34760 |
// Attach Draggable only to layout containers and disable it
|
34761 |
// for root and column containers.
|
34762 |
return view.renderOptions.depth === 1;
|
34764 |
},
|
34765 |
HighlightContainerBehavior: {}
|
34766 |
}),
|
34767 |
+
onDragSubstituteBy: function () {
|
34768 |
// For two and three column layouts display their respective widgets,
|
34769 |
// otherwise always default to one column layout widget
|
34770 |
if (this.renderOptions.depth === 1) {
|
34774 |
return Module.OneColumnContainerWidgetView;
|
34775 |
|
34776 |
},
|
34777 |
+
initialize: function (options) {
|
34778 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
34779 |
|
34780 |
this.renderOptions = _.defaults(options.renderOptions || {}, {});
|
34781 |
},
|
34782 |
+
onRender: function () {
|
34783 |
this.toolsView = new Module.ContainerBlockToolsView({
|
34784 |
model: this.model,
|
34785 |
tools: {
|
34800 |
// Sets child container orientation HTML class here, as child CollectionView won't have access to model and will overwrite existing region element instead
|
34801 |
this.$('> .mailpoet_container').attr('class', 'mailpoet_container mailpoet_container_' + this.model.get('orientation'));
|
34802 |
},
|
34803 |
+
showTools: function () {
|
34804 |
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
34805 |
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
34806 |
this.toolsView.triggerMethod('showTools');
|
34807 |
}
|
34808 |
},
|
34809 |
+
hideTools: function () {
|
34810 |
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
34811 |
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
34812 |
this.toolsView.triggerMethod('hideTools');
|
34813 |
}
|
34814 |
},
|
34815 |
+
toggleEditingLayer: function (event) {
|
34816 |
var that = this,
|
34817 |
$toggleButton = this.$('> .mailpoet_tools .mailpoet_newsletter_layer_selector'),
|
34818 |
$overlay = jQuery('.mailpoet_layer_overlay'),
|
34819 |
$container = this.$('> .mailpoet_container'),
|
34820 |
+
enableContainerLayer = function () {
|
34821 |
that.$el.addClass('mailpoet_container_layer_active');
|
34822 |
$toggleButton.addClass('mailpoet_container_layer_active');
|
34823 |
$container.addClass('mailpoet_layer_highlight');
|
34824 |
$overlay.click(disableContainerLayer);
|
34825 |
$overlay.show();
|
34826 |
},
|
34827 |
+
disableContainerLayer = function () {
|
34828 |
that.$el.removeClass('mailpoet_container_layer_active');
|
34829 |
$toggleButton.removeClass('mailpoet_container_layer_active');
|
34830 |
$container.removeClass('mailpoet_layer_highlight');
|
34841 |
});
|
34842 |
|
34843 |
Module.ContainerBlockEmptyView = Marionette.View.extend({
|
34844 |
+
getTemplate: function () { return window.templates.containerEmpty; },
|
34845 |
+
initialize: function (options) {
|
34846 |
this.renderOptions = _.defaults(options.renderOptions || {}, {});
|
34847 |
},
|
34848 |
+
templateContext: function () {
|
34849 |
return {
|
34850 |
isRoot: this.renderOptions.depth === 0,
|
34851 |
emptyContainerMessage: this.renderOptions.emptyContainerMessage || ''
|
34854 |
});
|
34855 |
|
34856 |
Module.ContainerBlockToolsView = base.BlockToolsView.extend({
|
34857 |
+
getSettingsView: function () { return Module.ContainerBlockSettingsView; }
|
34858 |
});
|
34859 |
|
34860 |
Module.ContainerBlockSettingsView = base.BlockSettingsView.extend({
|
34861 |
+
getTemplate: function () { return window.templates.containerBlockSettings; },
|
34862 |
+
events: function () {
|
34863 |
return {
|
34864 |
'change .mailpoet_field_container_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
34865 |
'click .mailpoet_done_editing': 'close'
|
34868 |
regions: {
|
34869 |
columnsSettingsRegion: '.mailpoet_container_columns_settings'
|
34870 |
},
|
34871 |
+
initialize: function () {
|
34872 |
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
|
34873 |
|
34874 |
this._columnsSettingsView = new (Module.ContainerBlockColumnsSettingsView)({
|
34875 |
collection: this.model.get('blocks')
|
34876 |
});
|
34877 |
},
|
34878 |
+
onRender: function () {
|
34879 |
this.showChildView('columnsSettingsRegion', this._columnsSettingsView);
|
34880 |
}
|
34881 |
});
|
34882 |
|
34883 |
Module.ContainerBlockColumnsSettingsView = Marionette.CollectionView.extend({
|
34884 |
+
childView: function () { return Module.ContainerBlockColumnSettingsView; },
|
34885 |
+
childViewOptions: function (model, index) {
|
34886 |
return {
|
34887 |
columnIndex: index
|
34888 |
};
|
34890 |
});
|
34891 |
|
34892 |
Module.ContainerBlockColumnSettingsView = Marionette.View.extend({
|
34893 |
+
getTemplate: function () { return window.templates.containerBlockColumnSettings; },
|
34894 |
+
initialize: function (options) {
|
34895 |
this.columnNumber = (options.columnIndex || 0) + 1;
|
34896 |
},
|
34897 |
+
templateContext: function () {
|
34898 |
return {
|
34899 |
model: this.model.toJSON(),
|
34900 |
columnNumber: this.columnNumber
|
34904 |
|
34905 |
Module.OneColumnContainerWidgetView = base.WidgetView.extend({
|
34906 |
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
34907 |
+
getTemplate: function () { return window.templates.oneColumnLayoutInsertion; },
|
34908 |
behaviors: {
|
34909 |
DraggableBehavior: {
|
34910 |
cloneOriginal: true,
|
34911 |
+
drop: function () {
|
34912 |
return new Module.ContainerBlockModel({
|
34913 |
orientation: 'horizontal',
|
34914 |
blocks: [
|
34922 |
|
34923 |
Module.TwoColumnContainerWidgetView = base.WidgetView.extend({
|
34924 |
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
34925 |
+
getTemplate: function () { return window.templates.twoColumnLayoutInsertion; },
|
34926 |
behaviors: {
|
34927 |
DraggableBehavior: {
|
34928 |
cloneOriginal: true,
|
34929 |
+
drop: function () {
|
34930 |
return new Module.ContainerBlockModel({
|
34931 |
orientation: 'horizontal',
|
34932 |
blocks: [
|
34941 |
|
34942 |
Module.ThreeColumnContainerWidgetView = base.WidgetView.extend({
|
34943 |
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
34944 |
+
getTemplate: function () { return window.templates.threeColumnLayoutInsertion; },
|
34945 |
behaviors: {
|
34946 |
DraggableBehavior: {
|
34947 |
cloneOriginal: true,
|
34948 |
+
drop: function () {
|
34949 |
return new Module.ContainerBlockModel({
|
34950 |
orientation: 'horizontal',
|
34951 |
blocks: [
|
34959 |
}
|
34960 |
});
|
34961 |
|
34962 |
+
App.on('before:start', function (App, options) {
|
34963 |
App.registerBlockType('container', {
|
34964 |
blockModel: Module.ContainerBlockModel,
|
34965 |
blockView: Module.ContainerBlockView
|
35002 |
__webpack_require__(274),
|
35003 |
__webpack_require__(278),
|
35004 |
__webpack_require__(273)
|
35005 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, MailPoet, _, jQuery) {
|
35006 |
|
35007 |
'use strict';
|
35008 |
|
35010 |
base = BaseBlock;
|
35011 |
|
35012 |
Module.ButtonBlockModel = base.BlockModel.extend({
|
35013 |
+
defaults: function () {
|
35014 |
return this._getDefaults({
|
35015 |
type: 'button',
|
35016 |
text: 'Button',
|
35037 |
|
35038 |
Module.ButtonBlockView = base.BlockView.extend({
|
35039 |
className: 'mailpoet_block mailpoet_button_block mailpoet_droppable_block',
|
35040 |
+
getTemplate: function () { return window.templates.buttonBlock; },
|
35041 |
+
onDragSubstituteBy: function () { return Module.ButtonWidgetView; },
|
35042 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35043 |
ShowSettingsBehavior: {}
|
35044 |
}),
|
35045 |
+
initialize: function () {
|
35046 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35047 |
|
35048 |
// Listen for attempts to change all dividers in one go
|
35049 |
+
this._replaceButtonStylesHandler = function (data) { this.model.set(data); }.bind(this);
|
35050 |
App.getChannel().on('replaceAllButtonStyles', this._replaceButtonStylesHandler);
|
35051 |
},
|
35052 |
+
onRender: function () {
|
35053 |
this.toolsView = new Module.ButtonBlockToolsView({ model: this.model });
|
35054 |
this.showChildView('toolsRegion', this.toolsView);
|
35055 |
}
|
35056 |
});
|
35057 |
|
35058 |
Module.ButtonBlockToolsView = base.BlockToolsView.extend({
|
35059 |
+
getSettingsView: function () { return Module.ButtonBlockSettingsView; }
|
35060 |
});
|
35061 |
|
35062 |
Module.ButtonBlockSettingsView = base.BlockSettingsView.extend({
|
35063 |
+
getTemplate: function () { return window.templates.buttonBlockSettings; },
|
35064 |
+
events: function () {
|
35065 |
return {
|
35066 |
'input .mailpoet_field_button_text': _.partial(this.changeField, 'text'),
|
35067 |
'input .mailpoet_field_button_url': _.partial(this.changeField, 'url'),
|
35093 |
'click .mailpoet_done_editing': 'close'
|
35094 |
};
|
35095 |
},
|
35096 |
+
templateContext: function () {
|
35097 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
35098 |
availableStyles: App.getAvailableStyles().toJSON(),
|
35099 |
renderOptions: this.renderOptions
|
35100 |
});
|
35101 |
},
|
35102 |
+
applyToAll: function () {
|
35103 |
App.getChannel().trigger('replaceAllButtonStyles', _.pick(this.model.toJSON(), 'styles', 'type'));
|
35104 |
},
|
35105 |
+
updateValueAndCall: function (fieldToUpdate, callable, event) {
|
35106 |
this.$(fieldToUpdate).val(jQuery(event.target).val());
|
35107 |
callable(event);
|
35108 |
},
|
35109 |
+
changeFontWeight: function (event) {
|
35110 |
var checked = !!jQuery(event.target).prop('checked');
|
35111 |
this.model.set(
|
35112 |
'styles.block.fontWeight',
|
35116 |
});
|
35117 |
|
35118 |
Module.ButtonWidgetView = base.WidgetView.extend({
|
35119 |
+
getTemplate: function () { return window.templates.buttonInsertion; },
|
35120 |
behaviors: {
|
35121 |
DraggableBehavior: {
|
35122 |
cloneOriginal: true,
|
35123 |
+
drop: function () {
|
35124 |
return new Module.ButtonBlockModel();
|
35125 |
}
|
35126 |
}
|
35127 |
}
|
35128 |
});
|
35129 |
|
35130 |
+
App.on('before:start', function (App, options) {
|
35131 |
App.registerBlockType('button', {
|
35132 |
blockModel: Module.ButtonBlockModel,
|
35133 |
blockView: Module.ButtonBlockView
|
35158 |
__webpack_require__(278),
|
35159 |
__webpack_require__(274),
|
35160 |
__webpack_require__(273)
|
35161 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, _, MailPoet, jQuery) {
|
35162 |
|
35163 |
'use strict';
|
35164 |
|
35167 |
ImageWidgetView;
|
35168 |
|
35169 |
Module.ImageBlockModel = base.BlockModel.extend({
|
35170 |
+
defaults: function () {
|
35171 |
return this._getDefaults({
|
35172 |
type: 'image',
|
35173 |
link: '',
|
35187 |
|
35188 |
Module.ImageBlockView = base.BlockView.extend({
|
35189 |
className: 'mailpoet_block mailpoet_image_block mailpoet_droppable_block',
|
35190 |
+
getTemplate: function () { return window.templates.imageBlock; },
|
35191 |
+
onDragSubstituteBy: function () { return Module.ImageWidgetView; },
|
35192 |
+
templateContext: function () {
|
35193 |
return _.extend({
|
35194 |
imageMissingSrc: App.getConfig().get('urls.imageMissing')
|
35195 |
}, base.BlockView.prototype.templateContext.apply(this));
|
35196 |
},
|
35197 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35198 |
+
ResizableBehavior: {
|
35199 |
+
elementSelector: '.mailpoet_image',
|
35200 |
+
resizeHandleSelector: '.mailpoet_image_resize_handle',
|
35201 |
+
onResize: function (event) {
|
35202 |
+
var corner = this.$('.mailpoet_image').offset(),
|
35203 |
+
width = event.pageX - corner.left;
|
35204 |
+
this.view.model.set('width', width + 'px');
|
35205 |
+
}
|
35206 |
+
},
|
35207 |
+
ShowSettingsBehavior: {
|
35208 |
+
ignoreFrom: '.mailpoet_image_resize_handle'
|
35209 |
+
}
|
35210 |
}),
|
35211 |
+
onRender: function () {
|
35212 |
this.toolsView = new Module.ImageBlockToolsView({ model: this.model });
|
35213 |
this.showChildView('toolsRegion', this.toolsView);
|
|
|
35214 |
if (this.model.get('fullWidth')) {
|
35215 |
this.$el.addClass('mailpoet_full_image');
|
35216 |
} else {
|
35217 |
this.$el.removeClass('mailpoet_full_image');
|
35218 |
}
|
35219 |
+
this.$('.mailpoet_content').css('width', this.model.get('width'));
|
35220 |
}
|
35221 |
});
|
35222 |
|
35223 |
Module.ImageBlockToolsView = base.BlockToolsView.extend({
|
35224 |
+
getSettingsView: function () { return Module.ImageBlockSettingsView; }
|
35225 |
});
|
35226 |
|
35227 |
Module.ImageBlockSettingsView = base.BlockSettingsView.extend({
|
35228 |
+
onRender: function () {
|
35229 |
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-full-width'), {
|
35230 |
tooltipId: 'tooltip-editor-full-width',
|
35231 |
tooltip: MailPoet.I18n.t('helpTooltipDesignerFullWidth')
|
35235 |
tooltip: MailPoet.I18n.t('helpTooltipDesignerIdealWidth')
|
35236 |
});
|
35237 |
},
|
35238 |
+
getTemplate: function () { return window.templates.imageBlockSettings; },
|
35239 |
+
events: function () {
|
35240 |
return {
|
35241 |
'input .mailpoet_field_image_link': _.partial(this.changeField, 'link'),
|
35242 |
'input .mailpoet_field_image_address': 'changeAddress',
|
35244 |
'change .mailpoet_field_image_full_width': _.partial(this.changeBoolCheckboxField, 'fullWidth'),
|
35245 |
'change .mailpoet_field_image_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
|
35246 |
'click .mailpoet_field_image_select_another_image': 'showMediaManager',
|
35247 |
+
'click .mailpoet_done_editing': 'close',
|
35248 |
+
'input .mailpoet_field_image_width': _.partial(this.updateValueAndCall, '.mailpoet_field_image_width_input', _.partial(this.changePixelField, 'width').bind(this)),
|
35249 |
+
'change .mailpoet_field_image_width': _.partial(this.updateValueAndCall, '.mailpoet_field_image_width_input', _.partial(this.changePixelField, 'width').bind(this)),
|
35250 |
+
'input .mailpoet_field_image_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_image_width', _.partial(this.changePixelField, 'width').bind(this))
|
35251 |
+
};
|
35252 |
+
},
|
35253 |
+
modelEvents: function () {
|
35254 |
+
return {
|
35255 |
+
'change:maxWidth': 'updateMaxWidth',
|
35256 |
+
'change:width': 'updateWidth'
|
35257 |
};
|
35258 |
},
|
35259 |
+
updateValueAndCall: function (fieldToUpdate, callable, event) {
|
35260 |
+
this.$(fieldToUpdate).val(jQuery(event.target).val());
|
35261 |
+
callable(event);
|
35262 |
+
},
|
35263 |
+
updateMaxWidth: function () {
|
35264 |
+
var maxWidth = parseInt(this.model.get('maxWidth'));
|
35265 |
+
this.$('.mailpoet_field_image_width').attr('max', maxWidth);
|
35266 |
+
this.$('.mailpoet_field_image_width_input').attr('max', maxWidth);
|
35267 |
+
},
|
35268 |
+
updateWidth: function () {
|
35269 |
+
var width = parseInt(this.model.get('width'));
|
35270 |
+
this.$('.mailpoet_field_image_width').val(width);
|
35271 |
+
this.$('.mailpoet_field_image_width_input').val(width);
|
35272 |
+
},
|
35273 |
+
initialize: function (options) {
|
35274 |
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
|
35275 |
|
35276 |
if (options.showImageManager) {
|
35277 |
this.showMediaManager();
|
35278 |
}
|
35279 |
},
|
35280 |
+
showMediaManager: function () {
|
35281 |
if (this._mediaManager) {
|
35282 |
this._mediaManager.resetSelections();
|
35283 |
this._mediaManager.open();
|
35286 |
|
35287 |
var MediaManager = window.wp.media.view.MediaFrame.Select.extend({
|
35288 |
|
35289 |
+
initialize: function () {
|
35290 |
window.wp.media.view.MediaFrame.prototype.initialize.apply(this, arguments);
|
35291 |
|
35292 |
_.defaults(this.options, {
|
35304 |
this.$el.addClass('hide-title');
|
35305 |
},
|
35306 |
|
35307 |
+
resetSelections: function () {
|
35308 |
this.state().get('selection').reset();
|
35309 |
},
|
35310 |
|
35311 |
+
createQuery: function (options) {
|
35312 |
var query = window.wp.media.query(options);
|
35313 |
return query;
|
35314 |
},
|
35315 |
|
35316 |
+
createStates: function () {
|
35317 |
var options = this.options;
|
35318 |
|
35319 |
// Add the default states.
|
35341 |
})
|
35342 |
]);
|
35343 |
|
35344 |
+
if (window.wp.media.view.settings.post.featuredImageId) {
|
35345 |
this.states.add(new window.wp.media.controller.FeaturedImage());
|
35346 |
}
|
35347 |
},
|
35348 |
|
35349 |
+
bindHandlers: function () {
|
35350 |
// from Select
|
35351 |
this.on('router:create:browse', this.createRouter, this);
|
35352 |
this.on('router:render:browse', this.browseRouter, this);
|
35371 |
}
|
35372 |
};
|
35373 |
|
35374 |
+
_.each(handlers, function (regionHandlers, region) {
|
35375 |
+
_.each(regionHandlers, function (callback, handler) {
|
35376 |
this.on(region + ':render:' + handler, this[callback], this);
|
35377 |
}, this);
|
35378 |
}, this);
|
35379 |
},
|
35380 |
|
35381 |
+
uploadContent: function () {
|
35382 |
window.wp.media.view.MediaFrame.Select.prototype.uploadContent.apply(this, arguments);
|
35383 |
this.$el.addClass('hide-toolbar');
|
35384 |
},
|
35385 |
|
35386 |
// Content
|
35387 |
+
embedContent: function () {
|
35388 |
var view = new window.wp.media.view.Embed({
|
35389 |
controller: this,
|
35390 |
model: this.state()
|
35394 |
view.url.focus();
|
35395 |
},
|
35396 |
|
35397 |
+
editSelectionContent: function () {
|
35398 |
var state = this.state(),
|
35399 |
selection = state.get('selection'),
|
35400 |
view;
|
35415 |
text: 'Return to library',
|
35416 |
priority: -100,
|
35417 |
|
35418 |
+
click: function () {
|
35419 |
this.controller.content.mode('browse');
|
35420 |
}
|
35421 |
});
|
35425 |
},
|
35426 |
|
35427 |
// Toolbars
|
35428 |
+
selectionStatusToolbar: function (view) {
|
35429 |
var editable = this.state().get('editable');
|
35430 |
|
35431 |
view.set('selection', new window.wp.media.view.Selection({
|
35435 |
|
35436 |
// If the selection is editable, pass the callback to
|
35437 |
// switch the content mode.
|
35438 |
+
editable: editable && function () {
|
35439 |
this.controller.content.mode('edit-selection');
|
35440 |
}
|
35441 |
+
}).render());
|
35442 |
},
|
35443 |
|
35444 |
+
mainInsertToolbar: function (view) {
|
35445 |
var controller = this;
|
35446 |
|
35447 |
this.selectionStatusToolbar(view);
|
35452 |
text: 'Select Image',
|
35453 |
requires: { selection: true },
|
35454 |
|
35455 |
+
click: function () {
|
35456 |
var state = controller.state(),
|
35457 |
selection = state.get('selection');
|
35458 |
|
35462 |
});
|
35463 |
},
|
35464 |
|
35465 |
+
mainEmbedToolbar: function (toolbar) {
|
35466 |
var tbar = toolbar;
|
35467 |
tbar.view = new window.wp.media.view.Toolbar.Embed({
|
35468 |
controller: this,
|
35489 |
that = this;
|
35490 |
this._mediaManager = theFrame;
|
35491 |
|
35492 |
+
this._mediaManager.on('insert', function () {
|
35493 |
// Append media manager image selections to Images tab
|
35494 |
var selection = theFrame.state().get('selection');
|
35495 |
+
selection.each(function (attachment) {
|
35496 |
var sizes = attachment.get('sizes'),
|
35497 |
// Following advice from Becs, the target width should
|
35498 |
// be a double of one column width to render well on
|
35505 |
// Pick the width that is closest to target width
|
35506 |
increasingByWidthDifference = _.sortBy(
|
35507 |
_.keys(sizes),
|
35508 |
+
function (size) { return Math.abs(targetImageWidth - sizes[size].width); }
|
35509 |
),
|
35510 |
bestWidth = sizes[_.first(increasingByWidthDifference)].width,
|
35511 |
+
imagesOfBestWidth = _.filter(_.values(sizes), function (size) { return size.width === bestWidth; }),
|
35512 |
|
35513 |
// Maximize the height if there are multiple images with same width
|
35514 |
+
mainSize = _.max(imagesOfBestWidth, function (size) { return size.height; });
|
35515 |
|
35516 |
that.model.set({
|
35517 |
height: mainSize.height + 'px',
|
35526 |
|
35527 |
this._mediaManager.open();
|
35528 |
},
|
35529 |
+
changeAddress: function (event) {
|
35530 |
var src = jQuery(event.target).val();
|
35531 |
var image = new Image();
|
35532 |
|
35533 |
+
image.onload = function () {
|
35534 |
this.model.set({
|
35535 |
src: src,
|
35536 |
width: image.naturalWidth + 'px',
|
35540 |
|
35541 |
image.src = src;
|
35542 |
},
|
35543 |
+
onBeforeDestroy: function () {
|
35544 |
base.BlockSettingsView.prototype.onBeforeDestroy.apply(this, arguments);
|
35545 |
if (typeof this._mediaManager === 'object') {
|
35546 |
this._mediaManager.remove();
|
35549 |
});
|
35550 |
|
35551 |
ImageWidgetView = base.WidgetView.extend({
|
35552 |
+
getTemplate: function () { return window.templates.imageInsertion; },
|
35553 |
behaviors: {
|
35554 |
DraggableBehavior: {
|
35555 |
cloneOriginal: true,
|
35556 |
+
drop: function () {
|
35557 |
return new Module.ImageBlockModel();
|
35558 |
},
|
35559 |
+
onDrop: function (options) {
|
35560 |
options.droppedView.triggerMethod('showSettings', { showImageManager: true });
|
35561 |
}
|
35562 |
}
|
35564 |
});
|
35565 |
Module.ImageWidgetView = ImageWidgetView;
|
35566 |
|
35567 |
+
App.on('before:start', function (App, options) {
|
35568 |
App.registerBlockType('image', {
|
35569 |
blockModel: Module.ImageBlockModel,
|
35570 |
blockView: Module.ImageBlockView
|
35595 |
__webpack_require__(278),
|
35596 |
__webpack_require__(273),
|
35597 |
__webpack_require__(274)
|
35598 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, _, jQuery, MailPoet) {
|
35599 |
|
35600 |
'use strict';
|
35601 |
|
35603 |
base = BaseBlock;
|
35604 |
|
35605 |
Module.DividerBlockModel = base.BlockModel.extend({
|
35606 |
+
defaults: function () {
|
35607 |
return this._getDefaults({
|
35608 |
type: 'divider',
|
35609 |
styles: {
|
35621 |
|
35622 |
Module.DividerBlockView = base.BlockView.extend({
|
35623 |
className: 'mailpoet_block mailpoet_divider_block mailpoet_droppable_block',
|
35624 |
+
getTemplate: function () { return window.templates.dividerBlock; },
|
35625 |
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
35626 |
behaviors: _.defaults({
|
35627 |
ResizableBehavior: {
|
35628 |
elementSelector: '.mailpoet_content',
|
35629 |
resizeHandleSelector: '.mailpoet_resize_handle',
|
35630 |
+
transformationFunction: function (y) { return y / 2; },
|
35631 |
minLength: 0, // TODO: Move this number to editor configuration
|
35632 |
modelField: 'styles.block.padding'
|
35633 |
},
|
35635 |
ignoreFrom: '.mailpoet_resize_handle'
|
35636 |
}
|
35637 |
}, base.BlockView.prototype.behaviors),
|
35638 |
+
onDragSubstituteBy: function () { return Module.DividerWidgetView; },
|
35639 |
+
initialize: function () {
|
35640 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35641 |
var that = this;
|
35642 |
|
35643 |
// Listen for attempts to change all dividers in one go
|
35644 |
+
this._replaceDividerHandler = function (data) { that.model.set(data); that.model.trigger('applyToAll'); };
|
35645 |
App.getChannel().on('replaceAllDividers', this._replaceDividerHandler);
|
35646 |
|
35647 |
this.listenTo(this.model, 'change:src change:styles.block.backgroundColor change:styles.block.borderStyle change:styles.block.borderWidth change:styles.block.borderColor applyToAll', this.render);
|
35648 |
this.listenTo(this.model, 'change:styles.block.padding', this.changePadding);
|
35649 |
},
|
35650 |
+
templateContext: function () {
|
35651 |
return _.extend({
|
35652 |
+
totalHeight: parseInt(this.model.get('styles.block.padding'), 10) * 2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px'
|
35653 |
}, base.BlockView.prototype.templateContext.apply(this));
|
35654 |
},
|
35655 |
+
onRender: function () {
|
35656 |
this.toolsView = new Module.DividerBlockToolsView({ model: this.model });
|
35657 |
this.showChildView('toolsRegion', this.toolsView);
|
35658 |
},
|
35659 |
+
onBeforeDestroy: function () {
|
35660 |
App.getChannel().off('replaceAllDividers', this._replaceDividerHandler);
|
35661 |
this.stopListening(this.model);
|
35662 |
},
|
35663 |
+
changePadding: function () {
|
35664 |
this.$('.mailpoet_content').css('padding-top', this.model.get('styles.block.padding'));
|
35665 |
this.$('.mailpoet_content').css('padding-bottom', this.model.get('styles.block.padding'));
|
35666 |
+
this.$('.mailpoet_resize_handle_text').text(parseInt(this.model.get('styles.block.padding'), 10) * 2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px');
|
35667 |
}
|
35668 |
});
|
35669 |
|
35670 |
Module.DividerBlockToolsView = base.BlockToolsView.extend({
|
35671 |
+
getSettingsView: function () { return Module.DividerBlockSettingsView; }
|
35672 |
});
|
35673 |
|
35674 |
Module.DividerBlockSettingsView = base.BlockSettingsView.extend({
|
35675 |
+
getTemplate: function () { return window.templates.dividerBlockSettings; },
|
35676 |
+
events: function () {
|
35677 |
return {
|
35678 |
'click .mailpoet_field_divider_style': 'changeStyle',
|
35679 |
|
35687 |
'click .mailpoet_done_editing': 'close'
|
35688 |
};
|
35689 |
},
|
35690 |
+
modelEvents: function () {
|
35691 |
return {
|
35692 |
'change:styles.block.borderColor': 'repaintDividerStyleOptions'
|
35693 |
};
|
35694 |
},
|
35695 |
+
templateContext: function () {
|
35696 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
35697 |
availableStyles: App.getAvailableStyles().toJSON(),
|
35698 |
renderOptions: this.renderOptions
|
35699 |
});
|
35700 |
},
|
35701 |
+
changeStyle: function (event) {
|
35702 |
var style = jQuery(event.currentTarget).data('style');
|
35703 |
this.model.set('styles.block.borderStyle', style);
|
35704 |
this.$('.mailpoet_field_divider_style').removeClass('mailpoet_active_divider_style');
|
35705 |
this.$('.mailpoet_field_divider_style[data-style="' + style + '"]').addClass('mailpoet_active_divider_style');
|
35706 |
},
|
35707 |
+
repaintDividerStyleOptions: function () {
|
35708 |
this.$('.mailpoet_field_divider_style > div').css('border-top-color', this.model.get('styles.block.borderColor'));
|
35709 |
},
|
35710 |
+
applyToAll: function (event) {
|
35711 |
App.getChannel().trigger('replaceAllDividers', this.model.toJSON());
|
35712 |
},
|
35713 |
+
updateValueAndCall: function (fieldToUpdate, callable, event) {
|
35714 |
this.$(fieldToUpdate).val(jQuery(event.target).val());
|
35715 |
callable(event);
|
35716 |
}
|
35717 |
});
|
35718 |
|
35719 |
Module.DividerWidgetView = base.WidgetView.extend({
|
35720 |
+
getTemplate: function () { return window.templates.dividerInsertion; },
|
35721 |
behaviors: {
|
35722 |
DraggableBehavior: {
|
35723 |
cloneOriginal: true,
|
35724 |
+
drop: function () {
|
35725 |
return new Module.DividerBlockModel();
|
35726 |
}
|
35727 |
}
|
35728 |
}
|
35729 |
});
|
35730 |
+
App.on('before:start', function (App, options) {
|
35731 |
App.registerBlockType('divider', {
|
35732 |
blockModel: Module.DividerBlockModel,
|
35733 |
blockView: Module.DividerBlockView
|
35757 |
__webpack_require__(595),
|
35758 |
__webpack_require__(278),
|
35759 |
__webpack_require__(274)
|
35760 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, _, MailPoet) {
|
35761 |
|
35762 |
'use strict';
|
35763 |
|
35765 |
base = BaseBlock;
|
35766 |
|
35767 |
Module.TextBlockModel = base.BlockModel.extend({
|
35768 |
+
defaults: function () {
|
35769 |
return this._getDefaults({
|
35770 |
type: 'text',
|
35771 |
text: 'Edit this to insert text'
|
35775 |
|
35776 |
Module.TextBlockView = base.BlockView.extend({
|
35777 |
className: 'mailpoet_block mailpoet_text_block mailpoet_droppable_block',
|
35778 |
+
getTemplate: function () { return window.templates.textBlock; },
|
35779 |
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), // Prevent rerendering on model change due to text editor redrawing
|
35780 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
35781 |
TextEditorBehavior: {
|
35785 |
invalidElements: 'script',
|
35786 |
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
|
35787 |
plugins: 'link lists code textcolor colorpicker mailpoet_shortcodes paste',
|
35788 |
+
configurationFilter: function (originalSettings) {
|
35789 |
return _.extend({}, originalSettings, {
|
35790 |
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
35791 |
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
35793 |
}
|
35794 |
}
|
35795 |
}),
|
35796 |
+
initialize: function (options) {
|
35797 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35798 |
|
35799 |
this.renderOptions = _.defaults(options.renderOptions || {}, {
|
35802 |
|
35803 |
this.disableTextEditor = this.renderOptions.disableTextEditor;
|
35804 |
},
|
35805 |
+
onDragSubstituteBy: function () { return Module.TextWidgetView; },
|
35806 |
+
onRender: function () {
|
35807 |
this.toolsView = new Module.TextBlockToolsView({
|
35808 |
model: this.model,
|
35809 |
tools: {
|
35812 |
});
|
35813 |
this.showChildView('toolsRegion', this.toolsView);
|
35814 |
},
|
35815 |
+
onTextEditorChange: function (newContent) {
|
35816 |
this.model.set('text', newContent);
|
35817 |
},
|
35818 |
+
onTextEditorFocus: function () {
|
35819 |
this.disableDragging();
|
35820 |
this.disableShowingTools();
|
35821 |
},
|
35822 |
+
onTextEditorBlur: function () {
|
35823 |
this.enableDragging();
|
35824 |
this.enableShowingTools();
|
35825 |
}
|
35826 |
});
|
35827 |
|
35828 |
Module.TextBlockToolsView = base.BlockToolsView.extend({
|
35829 |
+
getSettingsView: function () { return Module.TextBlockSettingsView; }
|
35830 |
});
|
35831 |
|
35832 |
Module.TextBlockSettingsView = base.BlockSettingsView.extend({
|
35833 |
+
getTemplate: function () { return window.templates.textBlockSettings; }
|
35834 |
});
|
35835 |
|
35836 |
Module.TextWidgetView = base.WidgetView.extend({
|
35837 |
+
getTemplate: function () { return window.templates.textInsertion; },
|
35838 |
behaviors: {
|
35839 |
DraggableBehavior: {
|
35840 |
cloneOriginal: true,
|
35841 |
+
drop: function () {
|
35842 |
return new Module.TextBlockModel();
|
35843 |
}
|
35844 |
}
|
35845 |
}
|
35846 |
});
|
35847 |
|
35848 |
+
App.on('before:start', function (App, options) {
|
35849 |
App.registerBlockType('text', {
|
35850 |
blockModel: Module.TextBlockModel,
|
35851 |
blockView: Module.TextBlockView
|
35875 |
__webpack_require__(574),
|
35876 |
__webpack_require__(595),
|
35877 |
__webpack_require__(278)
|
35878 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, _) {
|
35879 |
|
35880 |
'use strict';
|
35881 |
|
35883 |
base = BaseBlock;
|
35884 |
|
35885 |
Module.SpacerBlockModel = base.BlockModel.extend({
|
35886 |
+
defaults: function () {
|
35887 |
return this._getDefaults({
|
35888 |
type: 'spacer',
|
35889 |
styles: {
|
35898 |
|
35899 |
Module.SpacerBlockView = base.BlockView.extend({
|
35900 |
className: 'mailpoet_block mailpoet_spacer_block mailpoet_droppable_block',
|
35901 |
+
getTemplate: function () { return window.templates.spacerBlock; },
|
35902 |
behaviors: _.defaults({
|
35903 |
ResizableBehavior: {
|
35904 |
elementSelector: '.mailpoet_spacer',
|
35911 |
}
|
35912 |
}, base.BlockView.prototype.behaviors),
|
35913 |
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
35914 |
+
onDragSubstituteBy: function () { return Module.SpacerWidgetView; },
|
35915 |
+
initialize: function () {
|
35916 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
35917 |
|
35918 |
this.listenTo(this.model, 'change:styles.block.backgroundColor', this.render);
|
35919 |
this.listenTo(this.model, 'change:styles.block.height', this.changeHeight);
|
35920 |
},
|
35921 |
+
onRender: function () {
|
35922 |
this.toolsView = new Module.SpacerBlockToolsView({ model: this.model });
|
35923 |
this.showChildView('toolsRegion', this.toolsView);
|
35924 |
},
|
35925 |
+
changeHeight: function () {
|
35926 |
this.$('.mailpoet_spacer').css('height', this.model.get('styles.block.height'));
|
35927 |
this.$('.mailpoet_resize_handle_text').text(this.model.get('styles.block.height'));
|
35928 |
},
|
35929 |
+
onBeforeDestroy: function () {
|
35930 |
this.stopListening(this.model);
|
35931 |
}
|
35932 |
});
|
35933 |
|
35934 |
Module.SpacerBlockToolsView = base.BlockToolsView.extend({
|
35935 |
+
getSettingsView: function () { return Module.SpacerBlockSettingsView; }
|
35936 |
});
|
35937 |
|
35938 |
Module.SpacerBlockSettingsView = base.BlockSettingsView.extend({
|
35939 |
+
getTemplate: function () { return window.templates.spacerBlockSettings; },
|
35940 |
+
events: function () {
|
35941 |
return {
|
35942 |
'change .mailpoet_field_spacer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
35943 |
'click .mailpoet_done_editing': 'close'
|
35946 |
});
|
35947 |
|
35948 |
Module.SpacerWidgetView = base.WidgetView.extend({
|
35949 |
+
getTemplate: function () { return window.templates.spacerInsertion; },
|
35950 |
behaviors: {
|
35951 |
DraggableBehavior: {
|
35952 |
cloneOriginal: true,
|
35953 |
+
drop: function () {
|
35954 |
return new Module.SpacerBlockModel();
|
35955 |
}
|
35956 |
}
|
35957 |
}
|
35958 |
});
|
35959 |
|
35960 |
+
App.on('before:start', function (App, options) {
|
35961 |
App.registerBlockType('spacer', {
|
35962 |
blockModel: Module.SpacerBlockModel,
|
35963 |
blockView: Module.SpacerBlockView
|
35987 |
__webpack_require__(595),
|
35988 |
__webpack_require__(278),
|
35989 |
__webpack_require__(274)
|
35990 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, _, MailPoet) {
|
35991 |
|
35992 |
'use strict';
|
35993 |
|
35995 |
base = BaseBlock;
|
35996 |
|
35997 |
Module.FooterBlockModel = base.BlockModel.extend({
|
35998 |
+
defaults: function () {
|
35999 |
return this._getDefaults({
|
36000 |
type: 'footer',
|
36001 |
text: '<a href="[link:subscription_unsubscribe_url]">Unsubscribe</a> | <a href="[link:subscription_manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>',
|
36020 |
|
36021 |
Module.FooterBlockView = base.BlockView.extend({
|
36022 |
className: 'mailpoet_block mailpoet_footer_block mailpoet_droppable_block',
|
36023 |
+
getTemplate: function () { return window.templates.footerBlock; },
|
36024 |
modelEvents: _.extend({
|
36025 |
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
|
36026 |
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
|
36027 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
36028 |
TextEditorBehavior: {
|
36029 |
+
configurationFilter: function (originalSettings) {
|
36030 |
return _.extend({}, originalSettings, {
|
36031 |
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
36032 |
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
36034 |
}
|
36035 |
}
|
36036 |
}),
|
36037 |
+
onDragSubstituteBy: function () { return Module.FooterWidgetView; },
|
36038 |
+
onRender: function () {
|
36039 |
this.toolsView = new Module.FooterBlockToolsView({ model: this.model });
|
36040 |
this.showChildView('toolsRegion', this.toolsView);
|
36041 |
},
|
36042 |
+
onTextEditorChange: function (newContent) {
|
36043 |
this.model.set('text', newContent);
|
36044 |
},
|
36045 |
+
onTextEditorFocus: function () {
|
36046 |
this.disableDragging();
|
36047 |
this.disableShowingTools();
|
36048 |
},
|
36049 |
+
onTextEditorBlur: function () {
|
36050 |
this.enableDragging();
|
36051 |
this.enableShowingTools();
|
36052 |
}
|
36053 |
});
|
36054 |
|
36055 |
Module.FooterBlockToolsView = base.BlockToolsView.extend({
|
36056 |
+
getSettingsView: function () { return Module.FooterBlockSettingsView; }
|
36057 |
});
|
36058 |
|
36059 |
Module.FooterBlockSettingsView = base.BlockSettingsView.extend({
|
36060 |
+
getTemplate: function () { return window.templates.footerBlockSettings; },
|
36061 |
+
events: function () {
|
36062 |
return {
|
36063 |
'change .mailpoet_field_footer_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
|
36064 |
'change .mailpoet_field_footer_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
|
36065 |
'change .mailpoet_field_footer_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
|
36066 |
'change #mailpoet_field_footer_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
|
36067 |
+
'change #mailpoet_field_footer_link_underline': function (event) {
|
36068 |
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
36069 |
},
|
36070 |
'change .mailpoet_field_footer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
36072 |
'click .mailpoet_done_editing': 'close'
|
36073 |
};
|
36074 |
},
|
36075 |
+
templateContext: function () {
|
36076 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
36077 |
availableStyles: App.getAvailableStyles().toJSON()
|
36078 |
});
|
36080 |
});
|
36081 |
|
36082 |
Module.FooterWidgetView = base.WidgetView.extend({
|
36083 |
+
getTemplate: function () { return window.templates.footerInsertion; },
|
36084 |
behaviors: {
|
36085 |
DraggableBehavior: {
|
36086 |
cloneOriginal: true,
|
36087 |
+
drop: function () {
|
36088 |
return new Module.FooterBlockModel();
|
36089 |
}
|
36090 |
}
|
36091 |
}
|
36092 |
});
|
36093 |
|
36094 |
+
App.on('before:start', function (App, options) {
|
36095 |
App.registerBlockType('footer', {
|
36096 |
blockModel: Module.FooterBlockModel,
|
36097 |
blockView: Module.FooterBlockView
|
36121 |
__webpack_require__(595),
|
36122 |
__webpack_require__(278),
|
36123 |
__webpack_require__(274)
|
36124 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, _, MailPoet) {
|
36125 |
|
36126 |
'use strict';
|
36127 |
|
36129 |
base = BaseBlock;
|
36130 |
|
36131 |
Module.HeaderBlockModel = base.BlockModel.extend({
|
36132 |
+
defaults: function () {
|
36133 |
return this._getDefaults({
|
36134 |
type: 'header',
|
36135 |
text: 'Display problems? <a href="[link:newsletter_view_in_browser_url]">View it in your browser</a>',
|
36154 |
|
36155 |
Module.HeaderBlockView = base.BlockView.extend({
|
36156 |
className: 'mailpoet_block mailpoet_header_block mailpoet_droppable_block',
|
36157 |
+
getTemplate: function () { return window.templates.headerBlock; },
|
36158 |
modelEvents: _.extend({
|
36159 |
'change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration': 'render'
|
36160 |
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
|
36161 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
36162 |
TextEditorBehavior: {
|
36163 |
+
configurationFilter: function (originalSettings) {
|
36164 |
return _.extend({}, originalSettings, {
|
36165 |
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
|
36166 |
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
|
36168 |
}
|
36169 |
}
|
36170 |
}),
|
36171 |
+
onDragSubstituteBy: function () { return Module.HeaderWidgetView; },
|
36172 |
+
onRender: function () {
|
36173 |
this.toolsView = new Module.HeaderBlockToolsView({ model: this.model });
|
36174 |
this.showChildView('toolsRegion', this.toolsView);
|
36175 |
},
|
36176 |
+
onTextEditorChange: function (newContent) {
|
36177 |
this.model.set('text', newContent);
|
36178 |
},
|
36179 |
+
onTextEditorFocus: function () {
|
36180 |
this.disableDragging();
|
36181 |
this.disableShowingTools();
|
36182 |
},
|
36183 |
+
onTextEditorBlur: function () {
|
36184 |
this.enableDragging();
|
36185 |
this.enableShowingTools();
|
36186 |
}
|
36187 |
});
|
36188 |
|
36189 |
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
|
36190 |
+
getSettingsView: function () { return Module.HeaderBlockSettingsView; }
|
36191 |
});
|
36192 |
|
36193 |
Module.HeaderBlockSettingsView = base.BlockSettingsView.extend({
|
36194 |
+
getTemplate: function () { return window.templates.headerBlockSettings; },
|
36195 |
+
events: function () {
|
36196 |
return {
|
36197 |
'change .mailpoet_field_header_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
|
36198 |
'change .mailpoet_field_header_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
|
36199 |
'change .mailpoet_field_header_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
|
36200 |
'change #mailpoet_field_header_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
|
36201 |
+
'change #mailpoet_field_header_link_underline': function (event) {
|
36202 |
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
|
36203 |
},
|
36204 |
'change .mailpoet_field_header_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
|
36206 |
'click .mailpoet_done_editing': 'close'
|
36207 |
};
|
36208 |
},
|
36209 |
+
templateContext: function () {
|
36210 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
36211 |
availableStyles: App.getAvailableStyles().toJSON()
|
36212 |
});
|
36214 |
});
|
36215 |
|
36216 |
Module.HeaderWidgetView = base.WidgetView.extend({
|
36217 |
+
getTemplate: function () { return window.templates.headerInsertion; },
|
36218 |
behaviors: {
|
36219 |
DraggableBehavior: {
|
36220 |
cloneOriginal: true,
|
36221 |
+
drop: function () {
|
36222 |
return new Module.HeaderBlockModel();
|
36223 |
}
|
36224 |
}
|
36225 |
}
|
36226 |
});
|
36227 |
|
36228 |
+
App.on('before:start', function (App, options) {
|
36229 |
App.registerBlockType('header', {
|
36230 |
blockModel: Module.HeaderBlockModel,
|
36231 |
blockView: Module.HeaderBlockView
|
36265 |
__webpack_require__(564),
|
36266 |
__webpack_require__(278),
|
36267 |
__webpack_require__(273)
|
36268 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
36269 |
App,
|
36270 |
BaseBlock,
|
36271 |
ButtonBlock,
|
36283 |
base = BaseBlock;
|
36284 |
|
36285 |
Module.ALCSupervisor = SuperModel.extend({
|
36286 |
+
initialize: function () {
|
36287 |
var DELAY_REFRESH_FOR_MS = 500;
|
36288 |
this.listenTo(
|
36289 |
App.getChannel(),
|
36291 |
_.debounce(this.refresh, DELAY_REFRESH_FOR_MS)
|
36292 |
);
|
36293 |
},
|
36294 |
+
refresh: function () {
|
36295 |
+
var models = App.findModels(function (model) {
|
36296 |
return model.get('type') === 'automatedLatestContent';
|
36297 |
}) || [];
|
36298 |
|
36299 |
if (models.length === 0) return;
|
36300 |
+
var blocks = _.map(models, function (model) {
|
36301 |
return model.toJSON();
|
36302 |
});
|
36303 |
|
36305 |
blocks: blocks
|
36306 |
}).then(_.partial(this.refreshBlocks, models));
|
36307 |
},
|
36308 |
+
refreshBlocks: function (models, renderedBlocks) {
|
36309 |
_.each(
|
36310 |
_.zip(models, renderedBlocks),
|
36311 |
+
function (args) {
|
36312 |
var model = args[0],
|
36313 |
contents = args[1];
|
36314 |
model.trigger('refreshPosts', contents);
|
36319 |
|
36320 |
Module.AutomatedLatestContentBlockModel = base.BlockModel.extend({
|
36321 |
stale: ['_container'],
|
36322 |
+
defaults: function () {
|
36323 |
return this._getDefaults({
|
36324 |
type: 'automatedLatestContent',
|
36325 |
amount: '5',
|
36332 |
titleIsLink: false, // false|true
|
36333 |
imageFullWidth: false, // true|false
|
36334 |
featuredImagePosition: 'belowTitle', // 'aboveTitle'|'belowTitle'|'none'
|
36335 |
+
// imageAlignment: 'centerPadded', // 'centerFull'|'centerPadded'|'left'|'right'|'alternate'|'none'
|
36336 |
showAuthor: 'no', // 'no'|'aboveText'|'belowText'
|
36337 |
authorPrecededBy: 'Author:',
|
36338 |
showCategories: 'no', // 'no'|'aboveText'|'belowText'
|
36349 |
_container: new (App.getBlockTypeModel('container'))()
|
36350 |
}, App.getConfig().get('blockDefaults.automatedLatestContent'));
|
36351 |
},
|
36352 |
+
relations: function () {
|
36353 |
return {
|
36354 |
readMoreButton: App.getBlockTypeModel('button'),
|
36355 |
divider: App.getBlockTypeModel('divider'),
|
36356 |
_container: App.getBlockTypeModel('container')
|
36357 |
};
|
36358 |
},
|
36359 |
+
initialize: function () {
|
36360 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
36361 |
this.on('change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider', this._scheduleFetchPosts, this);
|
36362 |
this.listenTo(this.get('readMoreButton'), 'change', this._scheduleFetchPosts);
|
36364 |
this.on('add remove update reset', this._scheduleFetchPosts);
|
36365 |
this.on('refreshPosts', this.updatePosts, this);
|
36366 |
},
|
36367 |
+
updatePosts: function (posts) {
|
36368 |
+
this.get('_container.blocks').reset(posts, { parse: true });
|
36369 |
},
|
36370 |
/**
|
36371 |
* Batch more changes during a specific time, instead of fetching
|
36372 |
* ALC posts on each model change
|
36373 |
*/
|
36374 |
+
_scheduleFetchPosts: function () {
|
36375 |
App.getChannel().trigger('automatedLatestContentRefresh');
|
36376 |
}
|
36377 |
});
|
36378 |
|
36379 |
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
|
36380 |
className: 'mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block',
|
36381 |
+
initialize: function () {
|
36382 |
function replaceButtonStylesHandler(data) {
|
36383 |
+
this.model.set({ readMoreButton: data });
|
36384 |
}
|
36385 |
App.getChannel().on('replaceAllButtonStyles', replaceButtonStylesHandler.bind(this));
|
36386 |
},
|
36387 |
+
getTemplate: function () { return window.templates.automatedLatestContentBlock; },
|
36388 |
regions: {
|
36389 |
toolsRegion: '.mailpoet_tools',
|
36390 |
postsRegion: '.mailpoet_automated_latest_content_block_posts'
|
36397 |
events: _.extend(base.BlockView.prototype.events, {
|
36398 |
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
|
36399 |
}),
|
36400 |
+
onDragSubstituteBy: function () { return Module.AutomatedLatestContentWidgetView; },
|
36401 |
+
onRender: function () {
|
36402 |
var ContainerView = App.getBlockTypeView('container'),
|
36403 |
renderOptions = {
|
36404 |
disableTextEditor: true,
|
36412 |
});
|
36413 |
|
36414 |
Module.AutomatedLatestContentBlockToolsView = base.BlockToolsView.extend({
|
36415 |
+
getSettingsView: function () { return Module.AutomatedLatestContentBlockSettingsView; }
|
36416 |
});
|
36417 |
|
36418 |
// Sidebar view container
|
36419 |
Module.AutomatedLatestContentBlockSettingsView = base.BlockSettingsView.extend({
|
36420 |
+
getTemplate: function () { return window.templates.automatedLatestContentBlockSettings; },
|
36421 |
+
events: function () {
|
36422 |
return {
|
36423 |
'click .mailpoet_automated_latest_content_hide_display_options': 'toggleDisplayOptions',
|
36424 |
'click .mailpoet_automated_latest_content_show_display_options': 'toggleDisplayOptions',
|
36444 |
'click .mailpoet_done_editing': 'close'
|
36445 |
};
|
36446 |
},
|
36447 |
+
onRender: function () {
|
36448 |
var that = this;
|
36449 |
|
36450 |
// Dynamically update available post types
|
36460 |
term: params.term
|
36461 |
};
|
36462 |
},
|
36463 |
+
transport: function (options, success, failure) {
|
36464 |
var taxonomies;
|
36465 |
var promise = CommunicationComponent.getTaxonomies(
|
36466 |
that.model.get('contentType')
|
36467 |
+
).then(function (tax) {
|
36468 |
taxonomies = tax;
|
36469 |
// Fetch available terms based on the list of taxonomies already fetched
|
36470 |
var promise = CommunicationComponent.getTerms({
|
36471 |
search: options.data.term,
|
36472 |
taxonomies: _.keys(taxonomies)
|
36473 |
+
}).then(function (terms) {
|
36474 |
return {
|
36475 |
taxonomies: taxonomies,
|
36476 |
terms: terms
|
36483 |
promise.fail(failure);
|
36484 |
return promise;
|
36485 |
},
|
36486 |
+
processResults: function (data) {
|
36487 |
// Transform taxonomies and terms into select2 compatible format
|
36488 |
return {
|
36489 |
results: _.map(
|
36490 |
data.terms,
|
36491 |
+
function (item) {
|
36492 |
return _.defaults({
|
36493 |
text: data.taxonomies[item.taxonomy].labels.singular_name + ': ' + item.name,
|
36494 |
id: item.term_id
|
36499 |
}
|
36500 |
}
|
36501 |
}).on({
|
36502 |
+
'select2:select': function (event) {
|
36503 |
var terms = that.model.get('terms');
|
36504 |
terms.add(event.params.data);
|
36505 |
// Reset whole model in order for change events to propagate properly
|
36506 |
that.model.set('terms', terms.toJSON());
|
36507 |
},
|
36508 |
+
'select2:unselect': function (event) {
|
36509 |
var terms = that.model.get('terms');
|
36510 |
terms.remove(event.params.data);
|
36511 |
// Reset whole model in order for change events to propagate properly
|
36512 |
that.model.set('terms', terms.toJSON());
|
36513 |
}
|
36514 |
+
}).trigger('change');
|
36515 |
},
|
36516 |
+
toggleDisplayOptions: function (event) {
|
36517 |
var el = this.$('.mailpoet_automated_latest_content_display_options'),
|
36518 |
showControl = this.$('.mailpoet_automated_latest_content_show_display_options');
|
36519 |
if (el.hasClass('mailpoet_closed')) {
|
36524 |
showControl.removeClass('mailpoet_hidden');
|
36525 |
}
|
36526 |
},
|
36527 |
+
showButtonSettings: function (event) {
|
36528 |
var buttonModule = ButtonBlock;
|
36529 |
(new buttonModule.ButtonBlockSettingsView({
|
36530 |
model: this.model.get('readMoreButton'),
|
36535 |
}
|
36536 |
})).render();
|
36537 |
},
|
36538 |
+
showDividerSettings: function (event) {
|
36539 |
var dividerModule = DividerBlock;
|
36540 |
(new dividerModule.DividerBlockSettingsView({
|
36541 |
model: this.model.get('divider'),
|
36545 |
}
|
36546 |
})).render();
|
36547 |
},
|
36548 |
+
changeReadMoreType: function (event) {
|
36549 |
var value = jQuery(event.target).val();
|
36550 |
if (value == 'link') {
|
36551 |
this.$('.mailpoet_automated_latest_content_read_more_text').removeClass('mailpoet_hidden');
|
36556 |
}
|
36557 |
this.changeField('readMoreType', event);
|
36558 |
},
|
36559 |
+
changeDisplayType: function (event) {
|
36560 |
var value = jQuery(event.target).val();
|
36561 |
|
36562 |
if (value == 'titleOnly') {
|
36583 |
}
|
36584 |
this.changeField('displayType', event);
|
36585 |
},
|
36586 |
+
changeTitleFormat: function (event) {
|
36587 |
var value = jQuery(event.target).val();
|
36588 |
if (value == 'ul') {
|
36589 |
this.$('.mailpoet_automated_latest_content_non_title_list_options').addClass('mailpoet_hidden');
|
36597 |
}
|
36598 |
this.changeField('titleFormat', event);
|
36599 |
},
|
36600 |
+
_updateContentTypes: function (postTypes) {
|
36601 |
var select = this.$('.mailpoet_automated_latest_content_content_type'),
|
36602 |
selectedValue = this.model.get('contentType');
|
36603 |
|
36604 |
select.find('option').remove();
|
36605 |
+
_.each(postTypes, function (type) {
|
36606 |
select.append(jQuery('<option>', {
|
36607 |
value: type.name,
|
36608 |
text: type.label
|
36613 |
});
|
36614 |
|
36615 |
Module.AutomatedLatestContentWidgetView = base.WidgetView.extend({
|
36616 |
+
getTemplate: function () { return window.templates.automatedLatestContentInsertion; },
|
36617 |
behaviors: {
|
36618 |
DraggableBehavior: {
|
36619 |
cloneOriginal: true,
|
36620 |
+
drop: function () {
|
36621 |
return new Module.AutomatedLatestContentBlockModel({}, { parse: true });
|
36622 |
},
|
36623 |
+
onDrop: function (options) {
|
36624 |
options.droppedView.triggerMethod('showSettings');
|
36625 |
}
|
36626 |
}
|
36627 |
}
|
36628 |
});
|
36629 |
|
36630 |
+
App.on('before:start', function (App, options) {
|
36631 |
App.registerBlockType('automatedLatestContent', {
|
36632 |
blockModel: Module.AutomatedLatestContentBlockModel,
|
36633 |
blockView: Module.AutomatedLatestContentBlockView
|
36640 |
});
|
36641 |
});
|
36642 |
|
36643 |
+
App.on('start', function (App, options) {
|
36644 |
var Application = App;
|
36645 |
Application._ALCSupervisor = new Module.ALCSupervisor();
|
36646 |
Application._ALCSupervisor.refresh();
|
36680 |
__webpack_require__(597),
|
36681 |
__webpack_require__(599),
|
36682 |
__webpack_require__(287)
|
36683 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
36684 |
Backbone,
|
36685 |
Marionette,
|
36686 |
Radio,
|
36701 |
|
36702 |
Module.PostsBlockModel = base.BlockModel.extend({
|
36703 |
stale: ['_selectedPosts', '_availablePosts', '_transformedPosts'],
|
36704 |
+
defaults: function () {
|
36705 |
return this._getDefaults({
|
36706 |
type: 'posts',
|
36707 |
amount: '10',
|
36717 |
titleIsLink: false, // false|true
|
36718 |
imageFullWidth: false, // true|false
|
36719 |
featuredImagePosition: 'belowTitle', // 'aboveTitle'|'belowTitle'|'none'
|
36720 |
+
// imageAlignment: 'centerPadded', // 'centerFull'|'centerPadded'|'left'|'right'|'alternate'|'none'
|
36721 |
showAuthor: 'no', // 'no'|'aboveText'|'belowText'
|
36722 |
authorPrecededBy: 'Author:',
|
36723 |
showCategories: 'no', // 'no'|'aboveText'|'belowText'
|
36736 |
_transformedPosts: new (App.getBlockTypeModel('container'))()
|
36737 |
}, App.getConfig().get('blockDefaults.posts'));
|
36738 |
},
|
36739 |
+
relations: function () {
|
36740 |
return {
|
36741 |
readMoreButton: App.getBlockTypeModel('button'),
|
36742 |
divider: App.getBlockTypeModel('divider'),
|
36745 |
_transformedPosts: App.getBlockTypeModel('container')
|
36746 |
};
|
36747 |
},
|
36748 |
+
initialize: function () {
|
36749 |
var that = this,
|
36750 |
POST_REFRESH_DELAY_MS = 500,
|
36751 |
refreshAvailablePosts = _.debounce(this.fetchAvailablePosts.bind(this), POST_REFRESH_DELAY_MS),
|
36765 |
|
36766 |
this.on('insertSelectedPosts', this._insertSelectedPosts, this);
|
36767 |
},
|
36768 |
+
fetchAvailablePosts: function () {
|
36769 |
var that = this;
|
36770 |
this.set('offset', 0);
|
36771 |
+
CommunicationComponent.getPosts(this.toJSON()).done(function (posts) {
|
36772 |
that.get('_availablePosts').reset(posts);
|
36773 |
that.get('_selectedPosts').reset(); // Empty out the collection
|
36774 |
that.trigger('change:_availablePosts');
|
36775 |
+
}).fail(function () {
|
36776 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchAvailablePosts'));
|
36777 |
});
|
36778 |
},
|
36779 |
+
_loadMorePosts: function () {
|
36780 |
var that = this,
|
36781 |
postCount = this.get('_availablePosts').length,
|
36782 |
nextOffset = this.get('offset') + Number(this.get('amount'));
|
36783 |
|
36784 |
+
if (postCount === 0 || postCount < nextOffset) {
|
36785 |
// No more posts to load
|
36786 |
return false;
|
36787 |
}
|
36788 |
this.set('offset', nextOffset);
|
36789 |
this.trigger('loadingMorePosts');
|
36790 |
|
36791 |
+
CommunicationComponent.getPosts(this.toJSON()).done(function (posts) {
|
36792 |
that.get('_availablePosts').add(posts);
|
36793 |
that.trigger('change:_availablePosts');
|
36794 |
+
}).fail(function () {
|
36795 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchAvailablePosts'));
|
36796 |
+
}).always(function () {
|
36797 |
that.trigger('morePostsLoaded');
|
36798 |
});
|
36799 |
},
|
36800 |
+
_refreshTransformedPosts: function () {
|
36801 |
var that = this,
|
36802 |
data = this.toJSON();
|
36803 |
|
36808 |
return;
|
36809 |
}
|
36810 |
|
36811 |
+
CommunicationComponent.getTransformedPosts(data).done(function (posts) {
|
36812 |
+
that.get('_transformedPosts').get('blocks').reset(posts, { parse: true });
|
36813 |
+
}).fail(function () {
|
36814 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
|
36815 |
});
|
36816 |
},
|
36817 |
+
_insertSelectedPosts: function () {
|
36818 |
var that = this,
|
36819 |
data = this.toJSON(),
|
36820 |
index = this.collection.indexOf(this),
|
36824 |
|
36825 |
if (data.posts.length === 0) return;
|
36826 |
|
36827 |
+
CommunicationComponent.getTransformedPosts(data).done(function (posts) {
|
36828 |
collection.add(posts, { at: index });
|
36829 |
+
}).fail(function () {
|
36830 |
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
|
36831 |
});
|
36832 |
}
|
36834 |
|
36835 |
Module.PostsBlockView = base.BlockView.extend({
|
36836 |
className: 'mailpoet_block mailpoet_posts_block mailpoet_droppable_block',
|
36837 |
+
getTemplate: function () { return window.templates.postsBlock; },
|
36838 |
modelEvents: {}, // Forcefully disable all events
|
36839 |
regions: _.extend({
|
36840 |
postsRegion: '.mailpoet_posts_block_posts'
|
36841 |
}, base.BlockView.prototype.regions),
|
36842 |
+
onDragSubstituteBy: function () { return Module.PostsWidgetView; },
|
36843 |
+
initialize: function () {
|
36844 |
base.BlockView.prototype.initialize.apply(this, arguments);
|
36845 |
|
36846 |
this.toolsView = new Module.PostsBlockToolsView({ model: this.model });
|
36847 |
this.model.reply('blockView', this.notifyAboutSelf, this);
|
36848 |
},
|
36849 |
+
onRender: function () {
|
36850 |
if (!this.getRegion('toolsRegion').hasView()) {
|
36851 |
this.showChildView('toolsRegion', this.toolsView);
|
36852 |
}
|
36860 |
};
|
36861 |
this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_transformedPosts'), renderOptions: renderOptions }));
|
36862 |
},
|
36863 |
+
notifyAboutSelf: function () {
|
36864 |
return this;
|
36865 |
},
|
36866 |
+
onBeforeDestroy: function () {
|
36867 |
this.model.stopReplying('blockView', this.notifyAboutSelf, this);
|
36868 |
}
|
36869 |
});
|
36870 |
|
36871 |
Module.PostsBlockToolsView = base.BlockToolsView.extend({
|
36872 |
+
getSettingsView: function () { return Module.PostsBlockSettingsView; }
|
36873 |
});
|
36874 |
|
36875 |
Module.PostsBlockSettingsView = base.BlockSettingsView.extend({
|
36876 |
+
getTemplate: function () { return window.templates.postsBlockSettings; },
|
36877 |
regions: {
|
36878 |
selectionRegion: '.mailpoet_settings_posts_selection',
|
36879 |
displayOptionsRegion: '.mailpoet_settings_posts_display_options'
|
36883 |
'click .mailpoet_settings_posts_show_post_selection': 'switchToPostSelection',
|
36884 |
'click .mailpoet_settings_posts_insert_selected': 'insertPosts'
|
36885 |
},
|
36886 |
+
templateContext: function () {
|
36887 |
return {
|
36888 |
model: this.model.toJSON()
|
36889 |
};
|
36890 |
},
|
36891 |
+
initialize: function () {
|
36892 |
this.model.trigger('startEditing');
|
36893 |
this.selectionView = new PostSelectionSettingsView({ model: this.model });
|
36894 |
this.displayOptionsView = new PostsDisplayOptionsSettingsView({ model: this.model });
|
36895 |
},
|
36896 |
+
onRender: function () {
|
36897 |
var that = this,
|
36898 |
blockView = this.model.request('blockView');
|
36899 |
|
36905 |
template: '',
|
36906 |
position: 'right',
|
36907 |
width: App.getConfig().get('sidepanelWidth'),
|
36908 |
+
onCancel: function () {
|
36909 |
// Self destroy the block if the user closes settings modal
|
36910 |
that.model.destroy();
|
36911 |
}
|
36915 |
this.selectionView.triggerMethod('attach');
|
36916 |
this.displayOptionsView.triggerMethod('attach');
|
36917 |
},
|
36918 |
+
switchToDisplayOptions: function () {
|
36919 |
// Switch content view
|
36920 |
this.$('.mailpoet_settings_posts_selection').addClass('mailpoet_closed');
|
36921 |
this.$('.mailpoet_settings_posts_display_options').removeClass('mailpoet_closed');
|
36924 |
this.$('.mailpoet_settings_posts_show_display_options').addClass('mailpoet_hidden');
|
36925 |
this.$('.mailpoet_settings_posts_show_post_selection').removeClass('mailpoet_hidden');
|
36926 |
},
|
36927 |
+
switchToPostSelection: function () {
|
36928 |
// Switch content view
|
36929 |
this.$('.mailpoet_settings_posts_display_options').addClass('mailpoet_closed');
|
36930 |
this.$('.mailpoet_settings_posts_selection').removeClass('mailpoet_closed');
|
36933 |
this.$('.mailpoet_settings_posts_show_post_selection').addClass('mailpoet_hidden');
|
36934 |
this.$('.mailpoet_settings_posts_show_display_options').removeClass('mailpoet_hidden');
|
36935 |
},
|
36936 |
+
insertPosts: function () {
|
36937 |
this.model.trigger('insertSelectedPosts');
|
36938 |
this.model.destroy();
|
36939 |
this.close();
|
36942 |
|
36943 |
var PostsSelectionCollectionView = Marionette.CollectionView.extend({
|
36944 |
className: 'mailpoet_post_scroll_container',
|
36945 |
+
childView: function () { return SinglePostSelectionSettingsView; },
|
36946 |
+
emptyView: function () { return EmptyPostSelectionSettingsView; },
|
36947 |
+
childViewOptions: function () {
|
36948 |
return {
|
36949 |
blockModel: this.blockModel
|
36950 |
};
|
36951 |
},
|
36952 |
+
initialize: function (options) {
|
36953 |
this.blockModel = options.blockModel;
|
36954 |
},
|
36955 |
events: {
|
36956 |
scroll: 'onPostsScroll'
|
36957 |
},
|
36958 |
+
onPostsScroll: function (event) {
|
36959 |
var $postsBox = jQuery(event.target);
|
36960 |
+
if ($postsBox.scrollTop() + $postsBox.innerHeight() >= $postsBox[0].scrollHeight) {
|
36961 |
// Load more posts if scrolled to bottom
|
36962 |
this.blockModel.trigger('loadMorePosts');
|
36963 |
}
|
36965 |
});
|
36966 |
|
36967 |
var PostSelectionSettingsView = Marionette.View.extend({
|
36968 |
+
getTemplate: function () { return window.templates.postSelectionPostsBlockSettings; },
|
36969 |
regions: {
|
36970 |
posts: '.mailpoet_post_selection_container'
|
36971 |
},
|
36972 |
+
events: function () {
|
36973 |
return {
|
36974 |
'change .mailpoet_settings_posts_content_type': _.partial(this.changeField, 'contentType'),
|
36975 |
'change .mailpoet_posts_post_status': _.partial(this.changeField, 'postStatus'),
|
36977 |
};
|
36978 |
},
|
36979 |
modelEvents: {
|
36980 |
+
'change:offset': function (model, value) {
|
36981 |
// Scroll posts view to top if settings are changed
|
36982 |
if (value === 0) {
|
36983 |
this.$('.mailpoet_post_scroll_container').scrollTop(0);
|
36984 |
}
|
36985 |
},
|
36986 |
+
loadingMorePosts: function () {
|
36987 |
this.$('.mailpoet_post_selection_loading').css('visibility', 'visible');
|
36988 |
},
|
36989 |
+
morePostsLoaded: function () {
|
36990 |
this.$('.mailpoet_post_selection_loading').css('visibility', 'hidden');
|
36991 |
}
|
36992 |
},
|
36993 |
+
onRender: function () {
|
36994 |
// Dynamically update available post types
|
36995 |
CommunicationComponent.getPostTypes().done(_.bind(this._updateContentTypes, this));
|
36996 |
var postsView = new PostsSelectionCollectionView({
|
37000 |
|
37001 |
this.showChildView('posts', postsView);
|
37002 |
},
|
37003 |
+
onAttach: function () {
|
37004 |
var that = this;
|
37005 |
|
37006 |
this.$('.mailpoet_posts_categories_and_tags').select2({
|
37013 |
term: params.term
|
37014 |
};
|
37015 |
},
|
37016 |
+
transport: function (options, success, failure) {
|
37017 |
var taxonomies;
|
37018 |
var promise = CommunicationComponent.getTaxonomies(
|
37019 |
that.model.get('contentType')
|
37020 |
+
).then(function (tax) {
|
37021 |
taxonomies = tax;
|
37022 |
// Fetch available terms based on the list of taxonomies already fetched
|
37023 |
var promise = CommunicationComponent.getTerms({
|
37024 |
search: options.data.term,
|
37025 |
taxonomies: _.keys(taxonomies)
|
37026 |
+
}).then(function (terms) {
|
37027 |
return {
|
37028 |
taxonomies: taxonomies,
|
37029 |
terms: terms
|
37036 |
promise.fail(failure);
|
37037 |
return promise;
|
37038 |
},
|
37039 |
+
processResults: function (data) {
|
37040 |
// Transform taxonomies and terms into select2 compatible format
|
37041 |
return {
|
37042 |
results: _.map(
|
37043 |
data.terms,
|
37044 |
+
function (item) {
|
37045 |
return _.defaults({
|
37046 |
text: data.taxonomies[item.taxonomy].labels.singular_name + ': ' + item.name,
|
37047 |
id: item.term_id
|
37052 |
}
|
37053 |
}
|
37054 |
}).on({
|
37055 |
+
'select2:select': function (event) {
|
37056 |
var terms = that.model.get('terms');
|
37057 |
terms.add(event.params.data);
|
37058 |
// Reset whole model in order for change events to propagate properly
|
37059 |
that.model.set('terms', terms.toJSON());
|
37060 |
},
|
37061 |
+
'select2:unselect': function (event) {
|
37062 |
var terms = that.model.get('terms');
|
37063 |
terms.remove(event.params.data);
|
37064 |
// Reset whole model in order for change events to propagate properly
|
37065 |
that.model.set('terms', terms.toJSON());
|
37066 |
}
|
37067 |
+
}).trigger('change');
|
37068 |
},
|
37069 |
+
changeField: function (field, event) {
|
37070 |
this.model.set(field, jQuery(event.target).val());
|
37071 |
},
|
37072 |
+
_updateContentTypes: function (postTypes) {
|
37073 |
var select = this.$('.mailpoet_settings_posts_content_type'),
|
37074 |
selectedValue = this.model.get('contentType');
|
37075 |
|
37076 |
select.find('option').remove();
|
37077 |
+
_.each(postTypes, function (type) {
|
37078 |
select.append(jQuery('<option>', {
|
37079 |
value: type.name,
|
37080 |
text: type.label
|
37085 |
});
|
37086 |
|
37087 |
var EmptyPostSelectionSettingsView = Marionette.View.extend({
|
37088 |
+
getTemplate: function () { return window.templates.emptyPostPostsBlockSettings; }
|
37089 |
});
|
37090 |
|
37091 |
var SinglePostSelectionSettingsView = Marionette.View.extend({
|
37092 |
+
getTemplate: function () { return window.templates.singlePostPostsBlockSettings; },
|
37093 |
+
events: function () {
|
37094 |
return {
|
37095 |
'change .mailpoet_select_post_checkbox': 'postSelectionChange'
|
37096 |
};
|
37097 |
},
|
37098 |
+
templateContext: function () {
|
37099 |
return {
|
37100 |
model: this.model.toJSON(),
|
37101 |
index: this._index
|
37102 |
};
|
37103 |
},
|
37104 |
+
initialize: function (options) {
|
37105 |
this.blockModel = options.blockModel;
|
37106 |
},
|
37107 |
+
postSelectionChange: function (event) {
|
37108 |
var checkBox = jQuery(event.target),
|
37109 |
selectedPostsCollection = this.blockModel.get('_selectedPosts');
|
37110 |
if (checkBox.prop('checked')) {
|
37116 |
});
|
37117 |
|
37118 |
var PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({
|
37119 |
+
getTemplate: function () { return window.templates.displayOptionsPostsBlockSettings; },
|
37120 |
+
events: function () {
|
37121 |
return {
|
37122 |
'click .mailpoet_posts_select_button': 'showButtonSettings',
|
37123 |
'click .mailpoet_posts_select_divider': 'showDividerSettings',
|
37140 |
'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy')
|
37141 |
};
|
37142 |
},
|
37143 |
+
templateContext: function () {
|
37144 |
return {
|
37145 |
model: this.model.toJSON()
|
37146 |
};
|
37147 |
},
|
37148 |
+
showButtonSettings: function (event) {
|
37149 |
var buttonModule = ButtonBlock;
|
37150 |
(new buttonModule.ButtonBlockSettingsView({
|
37151 |
model: this.model.get('readMoreButton'),
|
37156 |
}
|
37157 |
})).render();
|
37158 |
},
|
37159 |
+
showDividerSettings: function (event) {
|
37160 |
var dividerModule = DividerBlock;
|
37161 |
(new dividerModule.DividerBlockSettingsView({
|
37162 |
model: this.model.get('divider'),
|
37166 |
}
|
37167 |
})).render();
|
37168 |
},
|
37169 |
+
changeReadMoreType: function (event) {
|
37170 |
var value = jQuery(event.target).val();
|
37171 |
if (value == 'link') {
|
37172 |
this.$('.mailpoet_posts_read_more_text').removeClass('mailpoet_hidden');
|
37177 |
}
|
37178 |
this.changeField('readMoreType', event);
|
37179 |
},
|
37180 |
+
changeDisplayType: function (event) {
|
37181 |
var value = jQuery(event.target).val();
|
37182 |
if (value == 'titleOnly') {
|
37183 |
this.$('.mailpoet_posts_title_as_list').removeClass('mailpoet_hidden');
|
37204 |
|
37205 |
this.changeField('displayType', event);
|
37206 |
},
|
37207 |
+
changeTitleFormat: function (event) {
|
37208 |
var value = jQuery(event.target).val();
|
37209 |
if (value == 'ul') {
|
37210 |
this.$('.mailpoet_posts_non_title_list_options').addClass('mailpoet_hidden');
|
37221 |
});
|
37222 |
|
37223 |
Module.PostsWidgetView = base.WidgetView.extend({
|
37224 |
+
getTemplate: function () { return window.templates.postsInsertion; },
|
37225 |
behaviors: {
|
37226 |
DraggableBehavior: {
|
37227 |
cloneOriginal: true,
|
37228 |
+
drop: function () {
|
37229 |
return new Module.PostsBlockModel({}, { parse: true });
|
37230 |
}
|
37231 |
}
|
37232 |
}
|
37233 |
});
|
37234 |
|
37235 |
+
App.on('before:start', function (App, options) {
|
37236 |
App.registerBlockType('posts', {
|
37237 |
blockModel: Module.PostsBlockModel,
|
37238 |
blockView: Module.PostsBlockView
|
37265 |
__webpack_require__(564),
|
37266 |
__webpack_require__(278),
|
37267 |
__webpack_require__(273)
|
37268 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (App, BaseBlock, Backbone, Marionette, SuperModel, _, jQuery) {
|
37269 |
|
37270 |
'use strict';
|
37271 |
|
37277 |
SocialBlockSettingsStylesView;
|
37278 |
|
37279 |
Module.SocialIconModel = SuperModel.extend({
|
37280 |
+
defaults: function () {
|
37281 |
var defaultValues = App.getConfig().get('socialIcons.custom');
|
37282 |
return {
|
37283 |
type: 'socialIcon',
|
37289 |
text: defaultValues.get('title')
|
37290 |
};
|
37291 |
},
|
37292 |
+
initialize: function (options) {
|
37293 |
var that = this;
|
37294 |
// Make model swap to default values for that type when iconType changes
|
37295 |
+
this.on('change:iconType', function () {
|
37296 |
var defaultValues = App.getConfig().get('socialIcons').get(that.get('iconType')),
|
37297 |
iconSet = that.collection.iconBlockModel.getIconSet();
|
37298 |
this.set({
|
37301 |
text: defaultValues.get('title')
|
37302 |
});
|
37303 |
}, this);
|
37304 |
+
this.on('change', function () { App.getChannel().trigger('autoSave'); });
|
37305 |
}
|
37306 |
});
|
37307 |
|
37311 |
|
37312 |
Module.SocialBlockModel = base.BlockModel.extend({
|
37313 |
name: 'iconBlockModel',
|
37314 |
+
defaults: function () {
|
37315 |
return this._getDefaults({
|
37316 |
type: 'social',
|
37317 |
iconSet: 'default',
|
37321 |
relations: {
|
37322 |
icons: Module.SocialIconCollectionModel
|
37323 |
},
|
37324 |
+
initialize: function () {
|
37325 |
this.get('icons').on('add remove change', this._iconsChanged, this);
|
37326 |
this.on('change:iconSet', this.changeIconSet, this);
|
37327 |
},
|
37328 |
+
getIconSet: function () {
|
37329 |
return App.getAvailableStyles().get('socialIconSets').get(this.get('iconSet'));
|
37330 |
},
|
37331 |
+
changeIconSet: function () {
|
37332 |
var iconSet = this.getIconSet();
|
37333 |
+
_.each(this.get('icons').models, function (model) {
|
37334 |
model.set('image', iconSet.get(model.get('iconType')));
|
37335 |
});
|
37336 |
},
|
37337 |
+
_iconsChanged: function () {
|
37338 |
+
App.getChannel().trigger('autoSave');
|
37339 |
}
|
37340 |
});
|
37341 |
|
37342 |
var SocialIconView = Marionette.View.extend({
|
37343 |
tagName: 'span',
|
37344 |
+
getTemplate: function () { return window.templates.socialIconBlock; },
|
37345 |
modelEvents: {
|
37346 |
change: 'render'
|
37347 |
},
|
37348 |
+
templateContext: function () {
|
37349 |
var allIconSets = App.getAvailableStyles().get('socialIconSets');
|
37350 |
return {
|
37351 |
model: this.model.toJSON(),
|
37361 |
|
37362 |
Module.SocialBlockView = base.BlockView.extend({
|
37363 |
className: 'mailpoet_block mailpoet_social_block mailpoet_droppable_block',
|
37364 |
+
getTemplate: function () { return window.templates.socialBlock; },
|
37365 |
regions: _.extend({}, base.BlockView.prototype.regions, {
|
37366 |
icons: '.mailpoet_social'
|
37367 |
}),
|
37371 |
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
37372 |
ShowSettingsBehavior: {}
|
37373 |
}),
|
37374 |
+
onDragSubstituteBy: function () { return Module.SocialWidgetView; },
|
37375 |
+
onRender: function () {
|
37376 |
this.toolsView = new Module.SocialBlockToolsView({ model: this.model });
|
37377 |
this.showChildView('toolsRegion', this.toolsView);
|
37378 |
this.showChildView('icons', new Module.SocialIconCollectionView({
|
37382 |
});
|
37383 |
|
37384 |
Module.SocialBlockToolsView = base.BlockToolsView.extend({
|
37385 |
+
getSettingsView: function () { return Module.SocialBlockSettingsView; }
|
37386 |
});
|
37387 |
|
37388 |
// Sidebar view container
|
37389 |
Module.SocialBlockSettingsView = base.BlockSettingsView.extend({
|
37390 |
+
getTemplate: function () { return window.templates.socialBlockSettings; },
|
37391 |
regions: {
|
37392 |
iconRegion: '#mailpoet_social_icons_selection',
|
37393 |
stylesRegion: '#mailpoet_social_icons_styles'
|
37394 |
},
|
37395 |
+
events: function () {
|
37396 |
return {
|
37397 |
'click .mailpoet_done_editing': 'close'
|
37398 |
};
|
37399 |
},
|
37400 |
+
initialize: function () {
|
37401 |
base.BlockSettingsView.prototype.initialize.apply(this, arguments);
|
37402 |
|
37403 |
this._iconSelectorView = new SocialBlockSettingsIconSelectorView({ model: this.model });
|
37404 |
this._stylesView = new SocialBlockSettingsStylesView({ model: this.model });
|
37405 |
},
|
37406 |
+
onRender: function () {
|
37407 |
this.showChildView('iconRegion', this._iconSelectorView);
|
37408 |
this.showChildView('stylesRegion', this._stylesView);
|
37409 |
}
|
37411 |
|
37412 |
// Single icon settings view, used by the selector view
|
37413 |
SocialBlockSettingsIconView = Marionette.View.extend({
|
37414 |
+
getTemplate: function () { return window.templates.socialSettingsIcon; },
|
37415 |
+
events: function () {
|
37416 |
return {
|
37417 |
'click .mailpoet_delete_block': 'deleteIcon',
|
37418 |
'change .mailpoet_social_icon_field_type': _.partial(this.changeField, 'iconType'),
|
37423 |
},
|
37424 |
modelEvents: {
|
37425 |
'change:iconType': 'render',
|
37426 |
+
'change:image': function () {
|
37427 |
this.$('.mailpoet_social_icon_image').attr('src', this.model.get('image'));
|
37428 |
},
|
37429 |
+
'change:text': function () {
|
37430 |
this.$('.mailpoet_social_icon_image').attr('alt', this.model.get('text'));
|
37431 |
}
|
37432 |
},
|
37433 |
+
templateContext: function () {
|
37434 |
var icons = App.getConfig().get('socialIcons'),
|
37435 |
// Construct icon type list of format [{iconType: 'type', title: 'Title'}, ...]
|
37436 |
+
availableIconTypes = _.map(_.keys(icons.attributes), function (key) { return { iconType: key, title: icons.get(key).get('title') }; }),
|
37437 |
allIconSets = App.getAvailableStyles().get('socialIconSets');
|
37438 |
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
|
37439 |
iconTypes: availableIconTypes,
|
37441 |
allIconSets: allIconSets.toJSON()
|
37442 |
});
|
37443 |
},
|
37444 |
+
deleteIcon: function () {
|
37445 |
this.model.destroy();
|
37446 |
},
|
37447 |
+
changeLink: function (event) {
|
37448 |
if (this.model.get('iconType') === 'email') {
|
37449 |
this.model.set('link', 'mailto:' + jQuery(event.target).val());
|
37450 |
} else {
|
37451 |
return this.changeField('link', event);
|
37452 |
}
|
37453 |
},
|
37454 |
+
changeField: function (field, event) {
|
37455 |
this.model.set(field, jQuery(event.target).val());
|
37456 |
}
|
37457 |
});
|
37468 |
|
37469 |
// Select icons section container view
|
37470 |
SocialBlockSettingsIconSelectorView = Marionette.View.extend({
|
37471 |
+
getTemplate: function () { return window.templates.socialSettingsIconSelector; },
|
37472 |
regions: {
|
37473 |
icons: '#mailpoet_social_icon_selector_contents'
|
37474 |
},
|
37478 |
modelEvents: {
|
37479 |
'change:iconSet': 'render'
|
37480 |
},
|
37481 |
+
addSocialIcon: function () {
|
37482 |
// Add a social icon with default values
|
37483 |
this.model.get('icons').add({});
|
37484 |
},
|
37485 |
+
onRender: function () {
|
37486 |
this.showChildView('icons', new SocialBlockSettingsIconCollectionView({
|
37487 |
collection: this.model.get('icons')
|
37488 |
}));
|
37491 |
});
|
37492 |
|
37493 |
SocialBlockSettingsStylesView = Marionette.View.extend({
|
37494 |
+
getTemplate: function () { return window.templates.socialSettingsStyles; },
|
37495 |
modelEvents: {
|
37496 |
change: 'render'
|
37497 |
},
|
37498 |
events: {
|
37499 |
'click .mailpoet_social_icon_set': 'changeSocialIconSet'
|
37500 |
},
|
37501 |
+
initialize: function () {
|
37502 |
this.listenTo(this.model.get('icons'), 'add remove change', this.render);
|
37503 |
},
|
37504 |
+
templateContext: function () {
|
37505 |
var allIconSets = App.getAvailableStyles().get('socialIconSets');
|
37506 |
return {
|
37507 |
activeSet: this.model.get('iconSet'),
|
37510 |
availableSocialIcons: this.model.get('icons').pluck('iconType')
|
37511 |
};
|
37512 |
},
|
37513 |
+
changeSocialIconSet: function (event) {
|
37514 |
this.model.set('iconSet', jQuery(event.currentTarget).data('setname'));
|
37515 |
},
|
37516 |
+
onBeforeDestroy: function () {
|
37517 |
this.model.get('icons').off('add remove', this.render, this);
|
37518 |
}
|
37519 |
});
|
37520 |
|
37521 |
Module.SocialWidgetView = base.WidgetView.extend({
|
37522 |
+
getTemplate: function () { return window.templates.socialInsertion; },
|
37523 |
behaviors: {
|
37524 |
DraggableBehavior: {
|
37525 |
cloneOriginal: true,
|
37526 |
+
drop: function () {
|
37527 |
return new Module.SocialBlockModel({
|
37528 |
type: 'social',
|
37529 |
iconSet: 'default',
|
37553 |
}
|
37554 |
});
|
37555 |
|
37556 |
+
App.on('before:start', function (App, options) {
|
37557 |
App.registerBlockType('social', {
|
37558 |
blockModel: Module.SocialBlockModel,
|
37559 |
blockView: Module.SocialBlockView
|
assets/js/{public.5b18b937.js → public.6e3f442a.js}
RENAMED
@@ -56,7 +56,7 @@
|
|
56 |
/* 1 */
|
57 |
/***/ function(module, exports, __webpack_require__) {
|
58 |
|
59 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
|
60 |
// A placeholder for MailPoet object
|
61 |
var MailPoet = {};
|
62 |
|
@@ -73,7 +73,7 @@
|
|
73 |
|
74 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
75 |
__webpack_require__(1)
|
76 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
77 |
mp
|
78 |
) {
|
79 |
'use strict';
|
@@ -83,13 +83,13 @@
|
|
83 |
var translations = {};
|
84 |
|
85 |
MailPoet.I18n = {
|
86 |
-
add: function(key, value) {
|
87 |
translations[key] = value;
|
88 |
},
|
89 |
-
t: function(key) {
|
90 |
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
|
91 |
},
|
92 |
-
all: function() {
|
93 |
return translations;
|
94 |
}
|
95 |
};
|
@@ -115,7 +115,7 @@
|
|
115 |
};
|
116 |
}
|
117 |
|
118 |
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __webpack_require__(4), __webpack_require__(5)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp, jQuery, _) {
|
119 |
var MailPoet = mp;
|
120 |
|
121 |
MailPoet.Ajax = {
|
@@ -129,24 +129,24 @@
|
|
129 |
token: null,
|
130 |
data: {}
|
131 |
},
|
132 |
-
post: function(options) {
|
133 |
return this.request('post', options);
|
134 |
},
|
135 |
-
init: function(options) {
|
136 |
// merge options
|
137 |
this.options = jQuery.extend({}, this.defaults, options);
|
138 |
|
139 |
// set default url
|
140 |
-
if(this.options.url === null) {
|
141 |
this.options.url = window.ajaxurl;
|
142 |
}
|
143 |
|
144 |
// set default token
|
145 |
-
if(this.options.token === null) {
|
146 |
this.options.token = window.mailpoet_token;
|
147 |
}
|
148 |
},
|
149 |
-
getParams: function() {
|
150 |
return {
|
151 |
action: 'mailpoet',
|
152 |
api_version: this.options.api_version,
|
@@ -156,7 +156,7 @@
|
|
156 |
data: this.options.data || {}
|
157 |
};
|
158 |
},
|
159 |
-
request: function(method, options) {
|
160 |
// set options
|
161 |
this.init(options);
|
162 |
|
@@ -165,7 +165,7 @@
|
|
165 |
|
166 |
// remove null values from the data object
|
167 |
if (_.isObject(params.data)) {
|
168 |
-
params.data = _.pick(params.data, function(value) {
|
169 |
return (value !== null);
|
170 |
});
|
171 |
}
|
@@ -176,7 +176,7 @@
|
|
176 |
params,
|
177 |
null,
|
178 |
'json'
|
179 |
-
).then(function(data) {
|
180 |
return data;
|
181 |
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
182 |
|
@@ -1760,23 +1760,23 @@
|
|
1760 |
/* 7 */
|
1761 |
/***/ function(module, exports, __webpack_require__) {
|
1762 |
|
1763 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1)], __WEBPACK_AMD_DEFINE_RESULT__ = function(mp) {
|
1764 |
'use strict';
|
1765 |
|
1766 |
var MailPoet = mp;
|
1767 |
MailPoet.Iframe = {
|
1768 |
marginY: 20,
|
1769 |
-
autoSize: function(iframe) {
|
1770 |
-
if(!iframe) return;
|
1771 |
|
1772 |
this.setSize(
|
1773 |
iframe,
|
1774 |
iframe.contentWindow.document.body.scrollHeight
|
1775 |
);
|
1776 |
},
|
1777 |
-
setSize: function(sizeIframe, i) {
|
1778 |
var iframe = sizeIframe;
|
1779 |
-
if(!iframe) return;
|
1780 |
|
1781 |
iframe.style.height = (
|
1782 |
parseInt(i, 10) + this.marginY
|
@@ -1794,7 +1794,7 @@
|
|
1794 |
|
1795 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
1796 |
__webpack_require__(4)
|
1797 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
1798 |
jQuery
|
1799 |
) {
|
1800 |
var $ = jQuery;
|
@@ -1815,12 +1815,12 @@
|
|
1815 |
* Dual licensed under the MIT and GPL licenses.
|
1816 |
* http://benalman.com/about/license/
|
1817 |
*/
|
1818 |
-
$.fn.serializeObject = function(coerce) {
|
1819 |
var obj = {},
|
1820 |
coerce_types = { true: !0, false: !1, null: null };
|
1821 |
|
1822 |
// Iterate over all name=value pairs.
|
1823 |
-
$.each(
|
1824 |
var key = v.name,
|
1825 |
val = v.value,
|
1826 |
cur = obj,
|
@@ -1828,18 +1828,18 @@
|
|
1828 |
|
1829 |
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
1830 |
// into its component parts.
|
1831 |
-
keys = key.split(
|
1832 |
keys_last = keys.length - 1;
|
1833 |
|
1834 |
// If the first keys part contains [ and the last ends with ], then []
|
1835 |
// are correctly balanced.
|
1836 |
-
if (
|
1837 |
// Remove the trailing ] from the last keys part.
|
1838 |
-
keys[
|
1839 |
|
1840 |
// Split first keys part into two parts on the [ and add them back onto
|
1841 |
// the beginning of the keys array.
|
1842 |
-
keys = keys.shift().split('[').concat(
|
1843 |
|
1844 |
keys_last = keys.length - 1;
|
1845 |
} else {
|
@@ -1848,14 +1848,14 @@
|
|
1848 |
}
|
1849 |
|
1850 |
// Coerce values.
|
1851 |
-
if (
|
1852 |
-
val = val && !isNaN(val)
|
1853 |
-
: val === 'undefined'
|
1854 |
: coerce_types[val] !== undefined ? coerce_types[val] // true, false, null
|
1855 |
: val; // string
|
1856 |
}
|
1857 |
|
1858 |
-
if (
|
1859 |
// Complex key, build deep object structure based on a few rules:
|
1860 |
// * The 'cur' pointer starts at the object top-level.
|
1861 |
// * [] = array push (n is set to array length), [n] = array if n is
|
@@ -1865,10 +1865,10 @@
|
|
1865 |
// object or array based on the type of the next keys part.
|
1866 |
// * Move the 'cur' pointer to the next level.
|
1867 |
// * Rinse & repeat.
|
1868 |
-
for (
|
1869 |
key = keys[i] === '' ? cur.length : keys[i];
|
1870 |
cur[key] = i < keys_last
|
1871 |
-
? cur[key] || (
|
1872 |
: val;
|
1873 |
cur = cur[key];
|
1874 |
}
|
@@ -1877,14 +1877,14 @@
|
|
1877 |
// Simple key, even simpler rules, since only scalars and shallow
|
1878 |
// arrays are allowed.
|
1879 |
|
1880 |
-
if (
|
1881 |
// val is already an array, so push on the next value.
|
1882 |
-
obj[key].push(
|
1883 |
|
1884 |
-
} else if (
|
1885 |
// val isn't an array, but since a second value has been specified,
|
1886 |
// convert val into an array.
|
1887 |
-
obj[key] = [
|
1888 |
|
1889 |
} else {
|
1890 |
// val is a scalar.
|
@@ -1907,37 +1907,37 @@
|
|
1907 |
__webpack_require__(1),
|
1908 |
__webpack_require__(4),
|
1909 |
__webpack_require__(10)
|
1910 |
-
], __WEBPACK_AMD_DEFINE_RESULT__ = function(
|
1911 |
MailPoet,
|
1912 |
jQuery,
|
1913 |
Parsley
|
1914 |
) {
|
1915 |
-
jQuery(function($) {
|
1916 |
function isSameDomain(url) {
|
1917 |
var link = document.createElement('a');
|
1918 |
link.href = url;
|
1919 |
return (window.location.hostname === link.hostname);
|
1920 |
}
|
1921 |
|
1922 |
-
$(function() {
|
1923 |
// setup form validation
|
1924 |
-
$('form.mailpoet_form').each(function() {
|
1925 |
var form = $(this);
|
1926 |
|
1927 |
-
form.parsley().on('form:validated', function(parsley) {
|
1928 |
// clear messages
|
1929 |
form.find('.mailpoet_message > p').hide();
|
1930 |
|
1931 |
// resize iframe
|
1932 |
-
if(window.frameElement !== null) {
|
1933 |
MailPoet.Iframe.autoSize(window.frameElement);
|
1934 |
}
|
1935 |
});
|
1936 |
|
1937 |
-
form.parsley().on('form:submit', function(parsley) {
|
1938 |
var form_data = form.serializeObject() || {};
|
1939 |
// check if we're on the same domain
|
1940 |
-
if(isSameDomain(window.MailPoetForm.ajax_url) === false) {
|
1941 |
// non ajax post request
|
1942 |
return true;
|
1943 |
} else {
|
@@ -1949,13 +1949,13 @@
|
|
1949 |
endpoint: 'subscribers',
|
1950 |
action: 'subscribe',
|
1951 |
data: form_data.data
|
1952 |
-
}).fail(function(response) {
|
1953 |
form.find('.mailpoet_validate_error').html(
|
1954 |
-
response.errors.map(function(error) {
|
1955 |
return error.message;
|
1956 |
}).join('<br />')
|
1957 |
).show();
|
1958 |
-
}).done(function(response) {
|
1959 |
// successfully subscribed
|
1960 |
if (
|
1961 |
response.meta !== undefined
|
56 |
/* 1 */
|
57 |
/***/ function(module, exports, __webpack_require__) {
|
58 |
|
59 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
|
60 |
// A placeholder for MailPoet object
|
61 |
var MailPoet = {};
|
62 |
|
73 |
|
74 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
75 |
__webpack_require__(1)
|
76 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
77 |
mp
|
78 |
) {
|
79 |
'use strict';
|
83 |
var translations = {};
|
84 |
|
85 |
MailPoet.I18n = {
|
86 |
+
add: function (key, value) {
|
87 |
translations[key] = value;
|
88 |
},
|
89 |
+
t: function (key) {
|
90 |
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
|
91 |
},
|
92 |
+
all: function () {
|
93 |
return translations;
|
94 |
}
|
95 |
};
|
115 |
};
|
116 |
}
|
117 |
|
118 |
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __webpack_require__(4), __webpack_require__(5)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp, jQuery, _) {
|
119 |
var MailPoet = mp;
|
120 |
|
121 |
MailPoet.Ajax = {
|
129 |
token: null,
|
130 |
data: {}
|
131 |
},
|
132 |
+
post: function (options) {
|
133 |
return this.request('post', options);
|
134 |
},
|
135 |
+
init: function (options) {
|
136 |
// merge options
|
137 |
this.options = jQuery.extend({}, this.defaults, options);
|
138 |
|
139 |
// set default url
|
140 |
+
if (this.options.url === null) {
|
141 |
this.options.url = window.ajaxurl;
|
142 |
}
|
143 |
|
144 |
// set default token
|
145 |
+
if (this.options.token === null) {
|
146 |
this.options.token = window.mailpoet_token;
|
147 |
}
|
148 |
},
|
149 |
+
getParams: function () {
|
150 |
return {
|
151 |
action: 'mailpoet',
|
152 |
api_version: this.options.api_version,
|
156 |
data: this.options.data || {}
|
157 |
};
|
158 |
},
|
159 |
+
request: function (method, options) {
|
160 |
// set options
|
161 |
this.init(options);
|
162 |
|
165 |
|
166 |
// remove null values from the data object
|
167 |
if (_.isObject(params.data)) {
|
168 |
+
params.data = _.pick(params.data, function (value) {
|
169 |
return (value !== null);
|
170 |
});
|
171 |
}
|
176 |
params,
|
177 |
null,
|
178 |
'json'
|
179 |
+
).then(function (data) {
|
180 |
return data;
|
181 |
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
|
182 |
|
1760 |
/* 7 */
|
1761 |
/***/ function(module, exports, __webpack_require__) {
|
1762 |
|
1763 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1)], __WEBPACK_AMD_DEFINE_RESULT__ = function (mp) {
|
1764 |
'use strict';
|
1765 |
|
1766 |
var MailPoet = mp;
|
1767 |
MailPoet.Iframe = {
|
1768 |
marginY: 20,
|
1769 |
+
autoSize: function (iframe) {
|
1770 |
+
if (!iframe) return;
|
1771 |
|
1772 |
this.setSize(
|
1773 |
iframe,
|
1774 |
iframe.contentWindow.document.body.scrollHeight
|
1775 |
);
|
1776 |
},
|
1777 |
+
setSize: function (sizeIframe, i) {
|
1778 |
var iframe = sizeIframe;
|
1779 |
+
if (!iframe) return;
|
1780 |
|
1781 |
iframe.style.height = (
|
1782 |
parseInt(i, 10) + this.marginY
|
1794 |
|
1795 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
|
1796 |
__webpack_require__(4)
|
1797 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
1798 |
jQuery
|
1799 |
) {
|
1800 |
var $ = jQuery;
|
1815 |
* Dual licensed under the MIT and GPL licenses.
|
1816 |
* http://benalman.com/about/license/
|
1817 |
*/
|
1818 |
+
$.fn.serializeObject = function (coerce) {
|
1819 |
var obj = {},
|
1820 |
coerce_types = { true: !0, false: !1, null: null };
|
1821 |
|
1822 |
// Iterate over all name=value pairs.
|
1823 |
+
$.each(this.serializeArray(), function (j, v) {
|
1824 |
var key = v.name,
|
1825 |
val = v.value,
|
1826 |
cur = obj,
|
1828 |
|
1829 |
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
1830 |
// into its component parts.
|
1831 |
+
keys = key.split(']['),
|
1832 |
keys_last = keys.length - 1;
|
1833 |
|
1834 |
// If the first keys part contains [ and the last ends with ], then []
|
1835 |
// are correctly balanced.
|
1836 |
+
if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) {
|
1837 |
// Remove the trailing ] from the last keys part.
|
1838 |
+
keys[keys_last] = keys[keys_last].replace(/\]$/, '');
|
1839 |
|
1840 |
// Split first keys part into two parts on the [ and add them back onto
|
1841 |
// the beginning of the keys array.
|
1842 |
+
keys = keys.shift().split('[').concat(keys);
|
1843 |
|
1844 |
keys_last = keys.length - 1;
|
1845 |
} else {
|
1848 |
}
|
1849 |
|
1850 |
// Coerce values.
|
1851 |
+
if (coerce) {
|
1852 |
+
val = val && !isNaN(val) ? +val // number
|
1853 |
+
: val === 'undefined' ? undefined // undefined
|
1854 |
: coerce_types[val] !== undefined ? coerce_types[val] // true, false, null
|
1855 |
: val; // string
|
1856 |
}
|
1857 |
|
1858 |
+
if (keys_last) {
|
1859 |
// Complex key, build deep object structure based on a few rules:
|
1860 |
// * The 'cur' pointer starts at the object top-level.
|
1861 |
// * [] = array push (n is set to array length), [n] = array if n is
|
1865 |
// object or array based on the type of the next keys part.
|
1866 |
// * Move the 'cur' pointer to the next level.
|
1867 |
// * Rinse & repeat.
|
1868 |
+
for (; i <= keys_last; i++) {
|
1869 |
key = keys[i] === '' ? cur.length : keys[i];
|
1870 |
cur[key] = i < keys_last
|
1871 |
+
? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : [])
|
1872 |
: val;
|
1873 |
cur = cur[key];
|
1874 |
}
|
1877 |
// Simple key, even simpler rules, since only scalars and shallow
|
1878 |
// arrays are allowed.
|
1879 |
|
1880 |
+
if ($.isArray(obj[key])) {
|
1881 |
// val is already an array, so push on the next value.
|
1882 |
+
obj[key].push(val);
|
1883 |
|
1884 |
+
} else if (obj[key] !== undefined) {
|
1885 |
// val isn't an array, but since a second value has been specified,
|
1886 |
// convert val into an array.
|
1887 |
+
obj[key] = [obj[key], val];
|
1888 |
|
1889 |
} else {
|
1890 |
// val is a scalar.
|
1907 |
__webpack_require__(1),
|
1908 |
__webpack_require__(4),
|
1909 |
__webpack_require__(10)
|
1910 |
+
], __WEBPACK_AMD_DEFINE_RESULT__ = function (
|
1911 |
MailPoet,
|
1912 |
jQuery,
|
1913 |
Parsley
|
1914 |
) {
|
1915 |
+
jQuery(function ($) {
|
1916 |
function isSameDomain(url) {
|
1917 |
var link = document.createElement('a');
|
1918 |
link.href = url;
|
1919 |
return (window.location.hostname === link.hostname);
|
1920 |
}
|
1921 |
|
1922 |
+
$(function () {
|
1923 |
// setup form validation
|
1924 |
+
$('form.mailpoet_form').each(function () {
|
1925 |
var form = $(this);
|
1926 |
|
1927 |
+
form.parsley().on('form:validated', function (parsley) {
|
1928 |
// clear messages
|
1929 |
form.find('.mailpoet_message > p').hide();
|
1930 |
|
1931 |
// resize iframe
|
1932 |
+
if (window.frameElement !== null) {
|
1933 |
MailPoet.Iframe.autoSize(window.frameElement);
|
1934 |
}
|
1935 |
});
|
1936 |
|
1937 |
+
form.parsley().on('form:submit', function (parsley) {
|
1938 |
var form_data = form.serializeObject() || {};
|
1939 |
// check if we're on the same domain
|
1940 |
+
if (isSameDomain(window.MailPoetForm.ajax_url) === false) {
|
1941 |
// non ajax post request
|
1942 |
return true;
|
1943 |
} else {
|
1949 |
endpoint: 'subscribers',
|
1950 |
action: 'subscribe',
|
1951 |
data: form_data.data
|
1952 |
+
}).fail(function (response) {
|
1953 |
form.find('.mailpoet_validate_error').html(
|
1954 |
+
response.errors.map(function (error) {
|
1955 |
return error.message;
|
1956 |
}).join('<br />')
|
1957 |
).show();
|
1958 |
+
}).done(function (response) {
|
1959 |
// successfully subscribed
|
1960 |
if (
|
1961 |
response.meta !== undefined
|
assets/js/{vendor.2e3b215c.js → vendor.b4463523.js}
RENAMED
@@ -76,7 +76,7 @@
|
|
76 |
/******/ script.charset = 'utf-8';
|
77 |
/******/ script.async = true;
|
78 |
|
79 |
-
/******/ script.src = __webpack_require__.p + "" + ({"0":"admin","1":"admin_vendor","2":"form_editor","3":"mailpoet","4":"newsletter_editor"}[chunkId]||chunkId) + "." + {"0":"
|
80 |
/******/ head.appendChild(script);
|
81 |
/******/ }
|
82 |
/******/ };
|
@@ -109,30 +109,30 @@
|
|
109 |
/***/ 575:
|
110 |
/***/ function(module, exports, __webpack_require__) {
|
111 |
|
112 |
-
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(543)], __WEBPACK_AMD_DEFINE_RESULT__ = function(Handlebars) {
|
113 |
// Handlebars helpers
|
114 |
-
Handlebars.registerHelper('concat', function() {
|
115 |
var size = (arguments.length - 1),
|
116 |
output = '';
|
117 |
-
for(var i = 0; i < size; i++) {
|
118 |
output += arguments[i];
|
119 |
}
|
120 |
return output;
|
121 |
});
|
122 |
|
123 |
-
Handlebars.registerHelper('number_format', function(value, block) {
|
124 |
return Number(value).toLocaleString();
|
125 |
});
|
126 |
-
Handlebars.registerHelper('date_format', function(timestamp, block) {
|
127 |
-
if(window.moment) {
|
128 |
-
if(timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
|
129 |
return;
|
130 |
}
|
131 |
|
132 |
// set date format
|
133 |
var f = block.hash.format || 'MMM Do, YYYY';
|
134 |
// check if we passed a timestamp
|
135 |
-
if(parseInt(timestamp, 10) == timestamp) {
|
136 |
return window.moment.unix(timestamp).format(f);
|
137 |
} else {
|
138 |
return window.moment.utc(timestamp).format(f);
|
@@ -142,7 +142,7 @@
|
|
142 |
}
|
143 |
});
|
144 |
|
145 |
-
Handlebars.registerHelper('cycle', function(value, block) {
|
146 |
var values = value.split(' ');
|
147 |
return values[block.data.index % (values.length + 1)];
|
148 |
});
|
@@ -177,23 +177,23 @@
|
|
177 |
}
|
178 |
});
|
179 |
|
180 |
-
Handlebars.registerHelper('nl2br', function(value, block) {
|
181 |
return value.gsub('\n', '<br />');
|
182 |
});
|
183 |
|
184 |
-
Handlebars.registerHelper('json_encode', function(value, block) {
|
185 |
return JSON.stringify(value);
|
186 |
});
|
187 |
|
188 |
-
Handlebars.registerHelper('json_decode', function(value, block) {
|
189 |
return JSON.parse(value);
|
190 |
});
|
191 |
-
Handlebars.registerHelper('url', function(value, block) {
|
192 |
var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
193 |
|
194 |
return url + value;
|
195 |
});
|
196 |
-
Handlebars.registerHelper('emailFromMailto', function(value) {
|
197 |
var mailtoMatchingRegex = /^mailto\:/i;
|
198 |
if (typeof value === 'string' && value.match(mailtoMatchingRegex)) {
|
199 |
return value.replace(mailtoMatchingRegex, '');
|
@@ -201,14 +201,14 @@
|
|
201 |
return value;
|
202 |
}
|
203 |
});
|
204 |
-
Handlebars.registerHelper('lookup', function(obj, field, options) {
|
205 |
return obj && obj[field];
|
206 |
});
|
207 |
|
208 |
|
209 |
-
Handlebars.registerHelper('rsa_key', function(value, block) {
|
210 |
// extract all lines into an array
|
211 |
-
if(value === undefined) return '';
|
212 |
|
213 |
var lines = value.trim().split('\n');
|
214 |
|
@@ -220,8 +220,8 @@
|
|
220 |
return lines.join('');
|
221 |
});
|
222 |
|
223 |
-
Handlebars.registerHelper('trim', function(value, block) {
|
224 |
-
if(value === null || value === undefined) return '';
|
225 |
return value.trim();
|
226 |
});
|
227 |
|
@@ -252,8 +252,8 @@
|
|
252 |
return parseInt(string, 10);
|
253 |
});
|
254 |
|
255 |
-
Handlebars.registerHelper('fontWithFallback', function(font) {
|
256 |
-
switch(font) {
|
257 |
case 'Arial': return new Handlebars.SafeString("Arial, 'Helvetica Neue', Helvetica, sans-serif");
|
258 |
case 'Comic Sans MS': return new Handlebars.SafeString("'Comic Sans MS', 'Marker Felt-Thin', Arial, sans-serif");
|
259 |
case 'Courier New': return new Handlebars.SafeString("'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace");
|
76 |
/******/ script.charset = 'utf-8';
|
77 |
/******/ script.async = true;
|
78 |
|
79 |
+
/******/ script.src = __webpack_require__.p + "" + ({"0":"admin","1":"admin_vendor","2":"form_editor","3":"mailpoet","4":"newsletter_editor"}[chunkId]||chunkId) + "." + {"0":"e3b1aa46","1":"53a6d3ec","2":"c4bc7e0b","3":"eab93337","4":"2627c560"}[chunkId] + ".chunk.js";
|
80 |
/******/ head.appendChild(script);
|
81 |
/******/ }
|
82 |
/******/ };
|
109 |
/***/ 575:
|
110 |
/***/ function(module, exports, __webpack_require__) {
|
111 |
|
112 |
+
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(543)], __WEBPACK_AMD_DEFINE_RESULT__ = function (Handlebars) {
|
113 |
// Handlebars helpers
|
114 |
+
Handlebars.registerHelper('concat', function () {
|
115 |
var size = (arguments.length - 1),
|
116 |
output = '';
|
117 |
+
for (var i = 0; i < size; i++) {
|
118 |
output += arguments[i];
|
119 |
}
|
120 |
return output;
|
121 |
});
|
122 |
|
123 |
+
Handlebars.registerHelper('number_format', function (value, block) {
|
124 |
return Number(value).toLocaleString();
|
125 |
});
|
126 |
+
Handlebars.registerHelper('date_format', function (timestamp, block) {
|
127 |
+
if (window.moment) {
|
128 |
+
if (timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
|
129 |
return;
|
130 |
}
|
131 |
|
132 |
// set date format
|
133 |
var f = block.hash.format || 'MMM Do, YYYY';
|
134 |
// check if we passed a timestamp
|
135 |
+
if (parseInt(timestamp, 10) == timestamp) {
|
136 |
return window.moment.unix(timestamp).format(f);
|
137 |
} else {
|
138 |
return window.moment.utc(timestamp).format(f);
|
142 |
}
|
143 |
});
|
144 |
|
145 |
+
Handlebars.registerHelper('cycle', function (value, block) {
|
146 |
var values = value.split(' ');
|
147 |
return values[block.data.index % (values.length + 1)];
|
148 |
});
|
177 |
}
|
178 |
});
|
179 |
|
180 |
+
Handlebars.registerHelper('nl2br', function (value, block) {
|
181 |
return value.gsub('\n', '<br />');
|
182 |
});
|
183 |
|
184 |
+
Handlebars.registerHelper('json_encode', function (value, block) {
|
185 |
return JSON.stringify(value);
|
186 |
});
|
187 |
|
188 |
+
Handlebars.registerHelper('json_decode', function (value, block) {
|
189 |
return JSON.parse(value);
|
190 |
});
|
191 |
+
Handlebars.registerHelper('url', function (value, block) {
|
192 |
var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
193 |
|
194 |
return url + value;
|
195 |
});
|
196 |
+
Handlebars.registerHelper('emailFromMailto', function (value) {
|
197 |
var mailtoMatchingRegex = /^mailto\:/i;
|
198 |
if (typeof value === 'string' && value.match(mailtoMatchingRegex)) {
|
199 |
return value.replace(mailtoMatchingRegex, '');
|
201 |
return value;
|
202 |
}
|
203 |
});
|
204 |
+
Handlebars.registerHelper('lookup', function (obj, field, options) {
|
205 |
return obj && obj[field];
|
206 |
});
|
207 |
|
208 |
|
209 |
+
Handlebars.registerHelper('rsa_key', function (value, block) {
|
210 |
// extract all lines into an array
|
211 |
+
if (value === undefined) return '';
|
212 |
|
213 |
var lines = value.trim().split('\n');
|
214 |
|
220 |
return lines.join('');
|
221 |
});
|
222 |
|
223 |
+
Handlebars.registerHelper('trim', function (value, block) {
|
224 |
+
if (value === null || value === undefined) return '';
|
225 |
return value.trim();
|
226 |
});
|
227 |
|
252 |
return parseInt(string, 10);
|
253 |
});
|
254 |
|
255 |
+
Handlebars.registerHelper('fontWithFallback', function (font) {
|
256 |
+
switch (font) {
|
257 |
case 'Arial': return new Handlebars.SafeString("Arial, 'Helvetica Neue', Helvetica, sans-serif");
|
258 |
case 'Comic Sans MS': return new Handlebars.SafeString("'Comic Sans MS', 'Marker Felt-Thin', Arial, sans-serif");
|
259 |
case 'Courier New': return new Handlebars.SafeString("'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace");
|
lang/index.php
CHANGED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Silence is golden
|
lang/mailpoet-da_DK.mo
CHANGED
Binary file
|
lang/mailpoet-de_DE.mo
CHANGED
Binary file
|
lang/mailpoet-en_GB.mo
CHANGED
Binary file
|
lang/mailpoet-es_ES.mo
CHANGED
Binary file
|
lang/mailpoet-fa_IR.mo
CHANGED
Binary file
|
lang/mailpoet-fr_CA.mo
CHANGED
Binary file
|
lang/mailpoet-fr_FR.mo
CHANGED
Binary file
|
lang/mailpoet-it_IT.mo
CHANGED
Binary file
|
lang/mailpoet-ja.mo
CHANGED
Binary file
|
lang/mailpoet-nl_NL.mo
CHANGED
Binary file
|
lang/mailpoet-pl_PL.mo
CHANGED
Binary file
|
lang/mailpoet-pt_BR.mo
CHANGED
Binary file
|
lang/mailpoet-pt_PT.mo
CHANGED
Binary file
|
lang/mailpoet-ru_RU.mo
CHANGED
Binary file
|
lang/mailpoet-sv_SE.mo
CHANGED
Binary file
|
lang/mailpoet-tr_TR.mo
CHANGED
Binary file
|
lang/mailpoet.pot
CHANGED
@@ -4,7 +4,7 @@ msgid ""
|
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: \n"
|
6 |
"Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
|
7 |
-
"POT-Creation-Date: 2017-09-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -46,7 +46,7 @@ msgstr ""
|
|
46 |
msgid "You do not have the required permissions."
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: lib/API/JSON/Endpoint.php:26
|
50 |
msgid "An unknown error occurred."
|
51 |
msgstr ""
|
52 |
|
@@ -87,12 +87,12 @@ msgstr ""
|
|
87 |
msgid "Check your inbox or spam folder to confirm your subscription."
|
88 |
msgstr ""
|
89 |
|
90 |
-
#: lib/API/JSON/v1/Forms.php:265 lib/API/JSON/v1/Newsletters.php:
|
91 |
#: lib/API/JSON/v1/Segments.php:125
|
92 |
msgid "Copy of %s"
|
93 |
msgstr ""
|
94 |
|
95 |
-
#: lib/API/JSON/v1/Mailer.php:36 lib/API/JSON/v1/Newsletters.php:
|
96 |
msgid "The email could not be sent: %s"
|
97 |
msgstr ""
|
98 |
|
@@ -101,24 +101,24 @@ msgstr ""
|
|
101 |
msgid "This template does not exist."
|
102 |
msgstr ""
|
103 |
|
104 |
-
#: lib/API/JSON/v1/Newsletters.php:37 lib/API/JSON/v1/Newsletters.php:
|
105 |
-
#: lib/API/JSON/v1/Newsletters.php:
|
106 |
-
#: lib/API/JSON/v1/Newsletters.php:
|
107 |
-
#: lib/API/JSON/v1/Newsletters.php:
|
108 |
#: lib/API/JSON/v1/SendingQueue.php:34 lib/API/JSON/v1/SendingQueue.php:121
|
109 |
#: lib/API/JSON/v1/SendingQueue.php:147
|
110 |
msgid "This newsletter does not exist."
|
111 |
msgstr ""
|
112 |
|
113 |
-
#: lib/API/JSON/v1/Newsletters.php:
|
114 |
msgid "You need to specify a status."
|
115 |
msgstr ""
|
116 |
|
117 |
-
#: lib/API/JSON/v1/Newsletters.php:
|
118 |
msgid "Newsletter data is missing."
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: lib/API/JSON/v1/Newsletters.php:
|
122 |
msgid "Please specify receiver information."
|
123 |
msgstr ""
|
124 |
|
@@ -1019,11 +1019,11 @@ msgid ""
|
|
1019 |
"license[/link] by %s to keep enjoying automatic updates and Premium support."
|
1020 |
msgstr ""
|
1021 |
|
1022 |
-
#: lib/Config/Shortcodes.php:
|
1023 |
msgid "Oops! There are no newsletters to display."
|
1024 |
msgstr ""
|
1025 |
|
1026 |
-
#: lib/Config/Shortcodes.php:
|
1027 |
msgid "Preview in a new tab"
|
1028 |
msgstr ""
|
1029 |
|
@@ -1053,20 +1053,20 @@ msgid ""
|
|
1053 |
"please contact us and report this issue."
|
1054 |
msgstr ""
|
1055 |
|
1056 |
-
#: lib/Form/Block/Base.php:
|
1057 |
msgid "Please specify a valid email address."
|
1058 |
msgstr ""
|
1059 |
|
1060 |
-
#: lib/Form/Block/Base.php:
|
1061 |
#: views/newsletters.html:169
|
1062 |
msgid "Please select a list"
|
1063 |
msgstr ""
|
1064 |
|
1065 |
-
#: lib/Form/Block/Base.php:
|
1066 |
msgid "Please specify a valid phone number"
|
1067 |
msgstr ""
|
1068 |
|
1069 |
-
#: lib/Form/Block/Base.php:
|
1070 |
msgid "Please select at least one option"
|
1071 |
msgstr ""
|
1072 |
|
@@ -1955,7 +1955,7 @@ msgstr ""
|
|
1955 |
#: views/newsletter/templates/blocks/divider/settings.hbs:37
|
1956 |
#: views/newsletter/templates/blocks/footer/settings.hbs:59
|
1957 |
#: views/newsletter/templates/blocks/header/settings.hbs:59
|
1958 |
-
#: views/newsletter/templates/blocks/image/settings.hbs:
|
1959 |
#: views/newsletter/templates/blocks/social/settings.hbs:6
|
1960 |
#: views/newsletter/templates/blocks/spacer/settings.hbs:10
|
1961 |
#: views/subscribers/importExport/import/step2.html:148
|
@@ -2749,7 +2749,7 @@ msgid "Image width"
|
|
2749 |
msgstr ""
|
2750 |
|
2751 |
#: views/newsletter/templates/blocks/automatedLatestContent/settings.hbs:165
|
2752 |
-
#: views/newsletter/templates/blocks/image/settings.hbs:
|
2753 |
#: views/newsletter/templates/blocks/posts/settingsDisplayOptions.hbs:121
|
2754 |
msgid "Full width"
|
2755 |
msgstr ""
|
@@ -2893,6 +2893,7 @@ msgid "Rounded corners"
|
|
2893 |
msgstr ""
|
2894 |
|
2895 |
#: views/newsletter/templates/blocks/button/settings.hbs:94
|
|
|
2896 |
msgid "Width"
|
2897 |
msgstr ""
|
2898 |
|
@@ -2979,7 +2980,7 @@ msgstr ""
|
|
2979 |
msgid "Alternative text"
|
2980 |
msgstr ""
|
2981 |
|
2982 |
-
#: views/newsletter/templates/blocks/image/settings.hbs:
|
2983 |
msgid "Select another image"
|
2984 |
msgstr ""
|
2985 |
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: \n"
|
6 |
"Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
|
7 |
+
"POT-Creation-Date: 2017-09-26 13:56:26+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
46 |
msgid "You do not have the required permissions."
|
47 |
msgstr ""
|
48 |
|
49 |
+
#: lib/API/JSON/Endpoint.php:26 lib/API/JSON/ErrorResponse.php:23
|
50 |
msgid "An unknown error occurred."
|
51 |
msgstr ""
|
52 |
|
87 |
msgid "Check your inbox or spam folder to confirm your subscription."
|
88 |
msgstr ""
|
89 |
|
90 |
+
#: lib/API/JSON/v1/Forms.php:265 lib/API/JSON/v1/Newsletters.php:231
|
91 |
#: lib/API/JSON/v1/Segments.php:125
|
92 |
msgid "Copy of %s"
|
93 |
msgstr ""
|
94 |
|
95 |
+
#: lib/API/JSON/v1/Mailer.php:36 lib/API/JSON/v1/Newsletters.php:335
|
96 |
msgid "The email could not be sent: %s"
|
97 |
msgstr ""
|
98 |
|
101 |
msgid "This template does not exist."
|
102 |
msgstr ""
|
103 |
|
104 |
+
#: lib/API/JSON/v1/Newsletters.php:37 lib/API/JSON/v1/Newsletters.php:149
|
105 |
+
#: lib/API/JSON/v1/Newsletters.php:181 lib/API/JSON/v1/Newsletters.php:197
|
106 |
+
#: lib/API/JSON/v1/Newsletters.php:213 lib/API/JSON/v1/Newsletters.php:227
|
107 |
+
#: lib/API/JSON/v1/Newsletters.php:260 lib/API/JSON/v1/Newsletters.php:293
|
108 |
#: lib/API/JSON/v1/SendingQueue.php:34 lib/API/JSON/v1/SendingQueue.php:121
|
109 |
#: lib/API/JSON/v1/SendingQueue.php:147
|
110 |
msgid "This newsletter does not exist."
|
111 |
msgstr ""
|
112 |
|
113 |
+
#: lib/API/JSON/v1/Newsletters.php:140
|
114 |
msgid "You need to specify a status."
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: lib/API/JSON/v1/Newsletters.php:251
|
118 |
msgid "Newsletter data is missing."
|
119 |
msgstr ""
|
120 |
|
121 |
+
#: lib/API/JSON/v1/Newsletters.php:284
|
122 |
msgid "Please specify receiver information."
|
123 |
msgstr ""
|
124 |
|
1019 |
"license[/link] by %s to keep enjoying automatic updates and Premium support."
|
1020 |
msgstr ""
|
1021 |
|
1022 |
+
#: lib/Config/Shortcodes.php:85
|
1023 |
msgid "Oops! There are no newsletters to display."
|
1024 |
msgstr ""
|
1025 |
|
1026 |
+
#: lib/Config/Shortcodes.php:124
|
1027 |
msgid "Preview in a new tab"
|
1028 |
msgstr ""
|
1029 |
|
1053 |
"please contact us and report this issue."
|
1054 |
msgstr ""
|
1055 |
|
1056 |
+
#: lib/Form/Block/Base.php:16
|
1057 |
msgid "Please specify a valid email address."
|
1058 |
msgstr ""
|
1059 |
|
1060 |
+
#: lib/Form/Block/Base.php:24 views/form/editor.html:55
|
1061 |
#: views/newsletters.html:169
|
1062 |
msgid "Please select a list"
|
1063 |
msgstr ""
|
1064 |
|
1065 |
+
#: lib/Form/Block/Base.php:34
|
1066 |
msgid "Please specify a valid phone number"
|
1067 |
msgstr ""
|
1068 |
|
1069 |
+
#: lib/Form/Block/Base.php:43
|
1070 |
msgid "Please select at least one option"
|
1071 |
msgstr ""
|
1072 |
|
1955 |
#: views/newsletter/templates/blocks/divider/settings.hbs:37
|
1956 |
#: views/newsletter/templates/blocks/footer/settings.hbs:59
|
1957 |
#: views/newsletter/templates/blocks/header/settings.hbs:59
|
1958 |
+
#: views/newsletter/templates/blocks/image/settings.hbs:66
|
1959 |
#: views/newsletter/templates/blocks/social/settings.hbs:6
|
1960 |
#: views/newsletter/templates/blocks/spacer/settings.hbs:10
|
1961 |
#: views/subscribers/importExport/import/step2.html:148
|
2749 |
msgstr ""
|
2750 |
|
2751 |
#: views/newsletter/templates/blocks/automatedLatestContent/settings.hbs:165
|
2752 |
+
#: views/newsletter/templates/blocks/image/settings.hbs:55
|
2753 |
#: views/newsletter/templates/blocks/posts/settingsDisplayOptions.hbs:121
|
2754 |
msgid "Full width"
|
2755 |
msgstr ""
|
2893 |
msgstr ""
|
2894 |
|
2895 |
#: views/newsletter/templates/blocks/button/settings.hbs:94
|
2896 |
+
#: views/newsletter/templates/blocks/image/settings.hbs:28
|
2897 |
msgid "Width"
|
2898 |
msgstr ""
|
2899 |
|
2980 |
msgid "Alternative text"
|
2981 |
msgstr ""
|
2982 |
|
2983 |
+
#: views/newsletter/templates/blocks/image/settings.hbs:62
|
2984 |
msgid "Select another image"
|
2985 |
msgstr ""
|
2986 |
|
lib/API/JSON/ErrorResponse.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
namespace MailPoet\API\JSON;
|
3 |
|
4 |
if(!defined('ABSPATH')) exit;
|
@@ -12,23 +13,19 @@ class ErrorResponse extends Response {
|
|
12 |
}
|
13 |
|
14 |
function getData() {
|
15 |
-
|
16 |
-
return null;
|
17 |
-
} else {
|
18 |
-
return array(
|
19 |
-
'errors' => $this->errors
|
20 |
-
);
|
21 |
-
}
|
22 |
}
|
23 |
|
24 |
function formatErrors($errors = array()) {
|
25 |
-
$
|
26 |
-
|
27 |
-
$
|
|
|
|
|
|
|
28 |
'error' => $error,
|
29 |
'message' => $message
|
30 |
);
|
31 |
-
}
|
32 |
-
return $formatted_errors;
|
33 |
}
|
34 |
}
|
1 |
<?php
|
2 |
+
|
3 |
namespace MailPoet\API\JSON;
|
4 |
|
5 |
if(!defined('ABSPATH')) exit;
|
13 |
}
|
14 |
|
15 |
function getData() {
|
16 |
+
return (empty($this->errors)) ? null : array('errors' => $this->errors);
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
|
19 |
function formatErrors($errors = array()) {
|
20 |
+
return array_map(function($error, $message) {
|
21 |
+
// sanitize SQL error
|
22 |
+
if(preg_match('/^SQLSTATE/i', $message)) {
|
23 |
+
$message = __('An unknown error occurred.', 'mailpoet');
|
24 |
+
}
|
25 |
+
return array(
|
26 |
'error' => $error,
|
27 |
'message' => $message
|
28 |
);
|
29 |
+
}, array_keys($errors), array_values($errors));
|
|
|
30 |
}
|
31 |
}
|
lib/API/JSON/v1/Newsletters.php
CHANGED
@@ -65,70 +65,71 @@ class Newsletters extends APIEndpoint {
|
|
65 |
$newsletter = Newsletter::createOrUpdate($data);
|
66 |
$errors = $newsletter->getErrors();
|
67 |
|
68 |
-
if(!empty($errors))
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$relation->newsletter_id = $newsletter->id;
|
80 |
-
$relation->save();
|
81 |
-
}
|
82 |
}
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
);
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
// reload newsletter with updated options
|
104 |
-
$newsletter = Newsletter::filter('filterWithOptions')
|
105 |
-
->findOne($newsletter->id);
|
106 |
-
|
107 |
-
// if this is a post notification, process newsletter options and update its schedule
|
108 |
-
if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
109 |
-
// generate the new schedule from options and get the new "next run" date
|
110 |
-
$newsletter->schedule = Scheduler::processPostNotificationSchedule($newsletter);
|
111 |
-
$next_run_date = Scheduler::getNextRunDate($newsletter->schedule);
|
112 |
-
// find previously scheduled jobs and reschedule them using the new "next run" date
|
113 |
-
SendingQueue::where('newsletter_id', $newsletter->id)
|
114 |
-
->where('status', SendingQueue::STATUS_SCHEDULED)
|
115 |
-
->findResultSet()
|
116 |
-
->set('scheduled_at', $next_run_date)
|
117 |
-
->save();
|
118 |
}
|
119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
$queue->newsletter_rendered_body = null;
|
124 |
$queue->newsletter_rendered_subject = null;
|
125 |
$queue->save();
|
126 |
}
|
|
|
127 |
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
}
|
132 |
}
|
133 |
|
134 |
function setStatus($data = array()) {
|
65 |
$newsletter = Newsletter::createOrUpdate($data);
|
66 |
$errors = $newsletter->getErrors();
|
67 |
|
68 |
+
if(!empty($errors)) return $this->badRequest($errors);
|
69 |
+
|
70 |
+
if(!empty($segments)) {
|
71 |
+
NewsletterSegment::where('newsletter_id', $newsletter->id)
|
72 |
+
->deleteMany();
|
73 |
+
foreach($segments as $segment) {
|
74 |
+
if(!is_array($segment)) continue;
|
75 |
+
$relation = NewsletterSegment::create();
|
76 |
+
$relation->segment_id = (int)$segment['id'];
|
77 |
+
$relation->newsletter_id = $newsletter->id;
|
78 |
+
$relation->save();
|
|
|
|
|
|
|
79 |
}
|
80 |
+
}
|
81 |
|
82 |
+
if(!empty($options)) {
|
83 |
+
$option_fields = NewsletterOptionField::where(
|
84 |
+
'newsletter_type',
|
85 |
+
$newsletter->type
|
86 |
+
)->findMany();
|
87 |
+
// update newsletter options
|
88 |
+
foreach($option_fields as $option_field) {
|
89 |
+
if(isset($options[$option_field->name])) {
|
90 |
+
$newsletter_option = NewsletterOption::createOrUpdate(
|
91 |
+
array(
|
92 |
+
'newsletter_id' => $newsletter->id,
|
93 |
+
'option_field_id' => $option_field->id,
|
94 |
+
'value' => $options[$option_field->name]
|
95 |
+
)
|
96 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
}
|
99 |
+
// reload newsletter with updated options
|
100 |
+
$newsletter = Newsletter::filter('filterWithOptions')
|
101 |
+
->findOne($newsletter->id);
|
102 |
+
// if this is a post notification, process newsletter options and update its schedule
|
103 |
+
if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
104 |
+
// generate the new schedule from options and get the new "next run" date
|
105 |
+
$newsletter->schedule = Scheduler::processPostNotificationSchedule($newsletter);
|
106 |
+
$next_run_date = Scheduler::getNextRunDate($newsletter->schedule);
|
107 |
+
// find previously scheduled jobs and reschedule them using the new "next run" date
|
108 |
+
SendingQueue::where('newsletter_id', $newsletter->id)
|
109 |
+
->where('status', SendingQueue::STATUS_SCHEDULED)
|
110 |
+
->findResultSet()
|
111 |
+
->set('scheduled_at', $next_run_date)
|
112 |
+
->save();
|
113 |
+
}
|
114 |
+
}
|
115 |
|
116 |
+
$queue = $newsletter->getQueue();
|
117 |
+
if($queue) {
|
118 |
+
// if newsletter was previously scheduled and is now unscheduled, set its status to DRAFT and delete associated queue record
|
119 |
+
if($newsletter->status === Newsletter::STATUS_SCHEDULED && isset($options['isScheduled']) && empty($options['isScheduled'])) {
|
120 |
+
$queue->delete();
|
121 |
+
$newsletter->status = Newsletter::STATUS_DRAFT;
|
122 |
+
$newsletter->save();
|
123 |
+
} else {
|
124 |
$queue->newsletter_rendered_body = null;
|
125 |
$queue->newsletter_rendered_subject = null;
|
126 |
$queue->save();
|
127 |
}
|
128 |
+
}
|
129 |
|
130 |
+
Hooks::doAction('mailpoet_api_newsletters_save_after', $newsletter);
|
131 |
|
132 |
+
return $this->successResponse($newsletter->asArray());
|
|
|
133 |
}
|
134 |
|
135 |
function setStatus($data = array()) {
|
lib/Config/Migrator.php
CHANGED
@@ -187,7 +187,8 @@ class Migrator {
|
|
187 |
'created_at TIMESTAMP NULL,',
|
188 |
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
189 |
'PRIMARY KEY (id),',
|
190 |
-
'UNIQUE KEY subscriber_segment (subscriber_id,segment_id)'
|
|
|
191 |
);
|
192 |
return $this->sqlify(__FUNCTION__, $attributes);
|
193 |
}
|
187 |
'created_at TIMESTAMP NULL,',
|
188 |
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
189 |
'PRIMARY KEY (id),',
|
190 |
+
'UNIQUE KEY subscriber_segment (subscriber_id,segment_id),',
|
191 |
+
'KEY segment_id (segment_id)',
|
192 |
);
|
193 |
return $this->sqlify(__FUNCTION__, $attributes);
|
194 |
}
|
lib/Config/PopulatorData/Templates/AppWelcome.php
CHANGED
@@ -8,7 +8,7 @@ class AppWelcome {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/app_welcome';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/BurgerJoint.php
CHANGED
@@ -8,7 +8,7 @@ class BurgerJoint {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
$this->template_image_url = '
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/burger_joint';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/ChocolateStore.php
CHANGED
@@ -8,7 +8,7 @@ class ChocolateStore {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/chocolate_store';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/CoffeeShop.php
CHANGED
@@ -8,7 +8,7 @@ class CoffeeShop {
|
|
8 |
private $template_image_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $template_image_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/franks-roast-house';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/Discount.php
CHANGED
@@ -8,7 +8,7 @@ class Discount {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/discount';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/Faith.php
CHANGED
@@ -8,7 +8,7 @@ class Faith {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
@@ -485,4 +485,4 @@ class Faith {
|
|
485 |
return $this->template_image_url . '/faith.jpg';
|
486 |
}
|
487 |
|
488 |
-
}
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/faith';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
485 |
return $this->template_image_url . '/faith.jpg';
|
486 |
}
|
487 |
|
488 |
+
}
|
lib/Config/PopulatorData/Templates/FestivalEvent.php
CHANGED
@@ -8,7 +8,7 @@ class FestivalEvent {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/festival_event';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/FoodBox.php
CHANGED
@@ -9,7 +9,7 @@ class FoodBox {
|
|
9 |
private $social_icon_url;
|
10 |
|
11 |
function __construct($assets_url) {
|
12 |
-
|
13 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
14 |
}
|
15 |
|
9 |
private $social_icon_url;
|
10 |
|
11 |
function __construct($assets_url) {
|
12 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/food_box';
|
13 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
14 |
}
|
15 |
|
lib/Config/PopulatorData/Templates/KickOff.php
CHANGED
@@ -8,7 +8,7 @@ class KickOff {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/kick_off';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/NewsDay.php
CHANGED
@@ -8,7 +8,7 @@ class NewsDay {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/news_day';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php
CHANGED
@@ -7,7 +7,7 @@ class NewsletterBlank121Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-2-1-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php
CHANGED
@@ -7,7 +7,7 @@ class NewsletterBlank12Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-2-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php
CHANGED
@@ -7,7 +7,7 @@ class NewsletterBlank13Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-3-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php
CHANGED
@@ -7,7 +7,7 @@ class NewsletterBlank1Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/PieceOfCake.php
CHANGED
@@ -8,7 +8,7 @@ class PieceOfCake {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/piece_of_cake';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php
CHANGED
@@ -7,7 +7,7 @@ class PostNotificationsBlank1Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/post-notifications-blank-1-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/ScienceWeekly.php
CHANGED
@@ -8,7 +8,7 @@ class ScienceWeekly {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/science_weekly';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/Shoes.php
CHANGED
@@ -8,7 +8,7 @@ class Shoes {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/shoes';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/SimpleText.php
CHANGED
@@ -7,7 +7,7 @@ class SimpleText {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/simple-text';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/TakeAHike.php
CHANGED
@@ -8,7 +8,7 @@ class TakeAHike {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
@@ -766,4 +766,4 @@ class TakeAHike {
|
|
766 |
return $this->template_image_url . '/take-a-hike.jpg';
|
767 |
}
|
768 |
|
769 |
-
}
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/take_a_hike';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
766 |
return $this->template_image_url . '/take-a-hike.jpg';
|
767 |
}
|
768 |
|
769 |
+
}
|
lib/Config/PopulatorData/Templates/TravelNomads.php
CHANGED
@@ -8,7 +8,7 @@ class TravelNomads {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
@@ -600,4 +600,4 @@ class TravelNomads {
|
|
600 |
return $this->template_image_url . '/travel-nomads.jpg';
|
601 |
}
|
602 |
|
603 |
-
}
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/travel_nomads';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
600 |
return $this->template_image_url . '/travel-nomads.jpg';
|
601 |
}
|
602 |
|
603 |
+
}
|
lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php
CHANGED
@@ -7,7 +7,7 @@ class WelcomeBlank12Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/welcome-email-blank-1-2-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php
CHANGED
@@ -7,7 +7,7 @@ class WelcomeBlank1Column {
|
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
-
$this->external_template_image_url = '
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
7 |
|
8 |
function __construct($assets_url) {
|
9 |
$this->assets_url = $assets_url;
|
10 |
+
$this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/welcome-email-blank-1-column';
|
11 |
$this->template_image_url = $this->assets_url . '/img/blank_templates';
|
12 |
$this->social_icon_url = $this->assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
lib/Config/PopulatorData/Templates/WorldCup.php
CHANGED
@@ -8,7 +8,7 @@ class WorldCup {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/world_cup';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/PopulatorData/Templates/YogaStudio.php
CHANGED
@@ -8,7 +8,7 @@ class YogaStudio {
|
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
-
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
8 |
private $social_icon_url;
|
9 |
|
10 |
function __construct($assets_url) {
|
11 |
+
$this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/yoga_studio';
|
12 |
$this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons';
|
13 |
}
|
14 |
|
lib/Config/Shortcodes.php
CHANGED
@@ -4,6 +4,7 @@ use MailPoet\Models\Newsletter;
|
|
4 |
use MailPoet\Models\Subscriber;
|
5 |
use MailPoet\Models\SubscriberSegment;
|
6 |
use MailPoet\Newsletter\Url as NewsletterUrl;
|
|
|
7 |
|
8 |
class Shortcodes {
|
9 |
function __construct() {
|
@@ -26,10 +27,10 @@ class Shortcodes {
|
|
26 |
$this, 'getArchive'
|
27 |
));
|
28 |
|
29 |
-
|
30 |
$this, 'renderArchiveDate'
|
31 |
), 2);
|
32 |
-
|
33 |
$this, 'renderArchiveSubject'
|
34 |
), 2, 3);
|
35 |
}
|
@@ -79,12 +80,12 @@ class Shortcodes {
|
|
79 |
$subscriber = Subscriber::getCurrentWPUser();
|
80 |
|
81 |
if(empty($newsletters)) {
|
82 |
-
return
|
83 |
'mailpoet_archive_no_newsletters',
|
84 |
__('Oops! There are no newsletters to display.', 'mailpoet')
|
85 |
);
|
86 |
} else {
|
87 |
-
$title =
|
88 |
if(!empty($title)) {
|
89 |
$html .= '<h3 class="mailpoet_archive_title">'.$title.'</h3>';
|
90 |
}
|
@@ -93,10 +94,10 @@ class Shortcodes {
|
|
93 |
$queue = $newsletter->queue()->findOne();
|
94 |
$html .= '<li>'.
|
95 |
'<span class="mailpoet_archive_date">'.
|
96 |
-
|
97 |
'</span>
|
98 |
<span class="mailpoet_archive_subject">'.
|
99 |
-
|
100 |
'</span>
|
101 |
</li>';
|
102 |
}
|
@@ -124,4 +125,4 @@ class Shortcodes {
|
|
124 |
.esc_attr($newsletter->newsletter_rendered_subject).
|
125 |
'</a>';
|
126 |
}
|
127 |
-
}
|
4 |
use MailPoet\Models\Subscriber;
|
5 |
use MailPoet\Models\SubscriberSegment;
|
6 |
use MailPoet\Newsletter\Url as NewsletterUrl;
|
7 |
+
use MailPoet\WP\Hooks;
|
8 |
|
9 |
class Shortcodes {
|
10 |
function __construct() {
|
27 |
$this, 'getArchive'
|
28 |
));
|
29 |
|
30 |
+
Hooks::addFilter('mailpoet_archive_date', array(
|
31 |
$this, 'renderArchiveDate'
|
32 |
), 2);
|
33 |
+
Hooks::addFilter('mailpoet_archive_subject', array(
|
34 |
$this, 'renderArchiveSubject'
|
35 |
), 2, 3);
|
36 |
}
|
80 |
$subscriber = Subscriber::getCurrentWPUser();
|
81 |
|
82 |
if(empty($newsletters)) {
|
83 |
+
return Hooks::applyFilters(
|
84 |
'mailpoet_archive_no_newsletters',
|
85 |
__('Oops! There are no newsletters to display.', 'mailpoet')
|
86 |
);
|
87 |
} else {
|
88 |
+
$title = Hooks::applyFilters('mailpoet_archive_title', '');
|
89 |
if(!empty($title)) {
|
90 |
$html .= '<h3 class="mailpoet_archive_title">'.$title.'</h3>';
|
91 |
}
|
94 |
$queue = $newsletter->queue()->findOne();
|
95 |
$html .= '<li>'.
|
96 |
'<span class="mailpoet_archive_date">'.
|
97 |
+
Hooks::applyFilters('mailpoet_archive_date', $newsletter).
|
98 |
'</span>
|
99 |
<span class="mailpoet_archive_subject">'.
|
100 |
+
Hooks::applyFilters('mailpoet_archive_subject', $newsletter, $subscriber, $queue).
|
101 |
'</span>
|
102 |
</li>';
|
103 |
}
|
125 |
.esc_attr($newsletter->newsletter_rendered_subject).
|
126 |
'</a>';
|
127 |
}
|
128 |
+
}
|
lib/Form/Block/Base.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
|
|
2 |
namespace MailPoet\Form\Block;
|
3 |
|
4 |
use MailPoet\Form\Util\FieldNameObfuscator;
|
|
|
5 |
|
6 |
abstract class Base {
|
7 |
protected static function getInputValidation($block, $extra_rules = array()) {
|
@@ -9,6 +11,8 @@ abstract class Base {
|
|
9 |
|
10 |
if($block['id'] === 'email') {
|
11 |
$rules['required'] = true;
|
|
|
|
|
12 |
$rules['error-message'] = __('Please specify a valid email address.', 'mailpoet');
|
13 |
}
|
14 |
|
@@ -135,4 +139,4 @@ abstract class Base {
|
|
135 |
}
|
136 |
return join(' ', $modifiers);
|
137 |
}
|
138 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
namespace MailPoet\Form\Block;
|
4 |
|
5 |
use MailPoet\Form\Util\FieldNameObfuscator;
|
6 |
+
use MailPoet\Models\ModelValidator;
|
7 |
|
8 |
abstract class Base {
|
9 |
protected static function getInputValidation($block, $extra_rules = array()) {
|
11 |
|
12 |
if($block['id'] === 'email') {
|
13 |
$rules['required'] = true;
|
14 |
+
$rules['minlength'] = ModelValidator::EMAIL_MIN_LENGTH;
|
15 |
+
$rules['maxlength'] = ModelValidator::EMAIL_MAX_LENGTH;
|
16 |
$rules['error-message'] = __('Please specify a valid email address.', 'mailpoet');
|
17 |
}
|
18 |
|
139 |
}
|
140 |
return join(' ', $modifiers);
|
141 |
}
|
142 |
+
}
|
lib/Models/ModelValidator.php
CHANGED
@@ -7,6 +7,9 @@ if(!defined('ABSPATH')) exit;
|
|
7 |
class ModelValidator extends \Sudzy\Engine {
|
8 |
public $validators;
|
9 |
|
|
|
|
|
|
|
10 |
function __construct() {
|
11 |
parent::__construct();
|
12 |
$this->validators = array(
|
@@ -26,7 +29,9 @@ class ModelValidator extends \Sudzy\Engine {
|
|
26 |
}
|
27 |
|
28 |
function validateEmail($email) {
|
29 |
-
|
|
|
|
|
30 |
}
|
31 |
|
32 |
function validateRenderedNewsletterBody($newsletter_body) {
|
7 |
class ModelValidator extends \Sudzy\Engine {
|
8 |
public $validators;
|
9 |
|
10 |
+
const EMAIL_MIN_LENGTH = 6;
|
11 |
+
const EMAIL_MAX_LENGTH = 150;
|
12 |
+
|
13 |
function __construct() {
|
14 |
parent::__construct();
|
15 |
$this->validators = array(
|
29 |
}
|
30 |
|
31 |
function validateEmail($email) {
|
32 |
+
$permitted_length = (strlen($email) >= self::EMAIL_MIN_LENGTH && strlen($email) <= self::EMAIL_MAX_LENGTH);
|
33 |
+
$valid_email = (is_email($email) !== false);
|
34 |
+
return ($permitted_length && $valid_email);
|
35 |
}
|
36 |
|
37 |
function validateRenderedNewsletterBody($newsletter_body) {
|
mailpoet.php
CHANGED
@@ -4,7 +4,7 @@ if(!defined('ABSPATH')) exit;
|
|
4 |
|
5 |
/*
|
6 |
* Plugin Name: MailPoet 3 (new)
|
7 |
-
* Version: 3.0.
|
8 |
* Plugin URI: http://www.mailpoet.com
|
9 |
* Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
|
10 |
* Author: MailPoet
|
@@ -21,7 +21,7 @@ if(!defined('ABSPATH')) exit;
|
|
21 |
*/
|
22 |
|
23 |
$mailpoet_plugin = array(
|
24 |
-
'version' => '3.0.
|
25 |
'filename' => __FILE__,
|
26 |
'path' => dirname(__FILE__),
|
27 |
'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
|
4 |
|
5 |
/*
|
6 |
* Plugin Name: MailPoet 3 (new)
|
7 |
+
* Version: 3.0.1
|
8 |
* Plugin URI: http://www.mailpoet.com
|
9 |
* Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
|
10 |
* Author: MailPoet
|
21 |
*/
|
22 |
|
23 |
$mailpoet_plugin = array(
|
24 |
+
'version' => '3.0.1',
|
25 |
'filename' => __FILE__,
|
26 |
'path' => dirname(__FILE__),
|
27 |
'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: newsletter, email, welcome email, post notification, autoresponder, signup
|
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 4.8
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -114,6 +114,12 @@ Stop by our [support site](https://www.mailpoet.com/support).
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
= 3.0.0 - 2017-09-20 =
|
118 |
* Official launch of the new MailPoet. :)
|
119 |
* Improved: MailPoet 3 now works with other plugins that use a supported version of Twig templating engine. Thanks @supsysticcom;
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 4.8
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 3.0.1
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
= 3.0.1 - 2017-09-26 =
|
118 |
+
* Added: images can be resized in newsletter editor;
|
119 |
+
* Fixed: scheduled newsletters that are unscheduled will not be mistakenly sent. Thx Georges in Provence;
|
120 |
+
* Fixed: plugin does not time out on sites with a large number of lists and subscribers. Thanks Roy;
|
121 |
+
* Fixed: long email addresses no longer trigger MySQL errors during subscription. Thank you Sameer Bhatt and Bits of Freedom!
|
122 |
+
|
123 |
= 3.0.0 - 2017-09-20 =
|
124 |
* Official launch of the new MailPoet. :)
|
125 |
* Improved: MailPoet 3 now works with other plugins that use a supported version of Twig templating engine. Thanks @supsysticcom;
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitf2444e07caaed476ec8d2343d153c0ec::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit5d9881c444dc082c214fb3c84d951ad4
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit5d9881c444dc082c214fb3c84d951ad4
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitf2444e07caaed476ec8d2343d153c0ec
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitf2444e07caaed476ec8d2343d153c0ec', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitf2444e07caaed476ec8d2343d153c0ec', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequiref2444e07caaed476ec8d2343d153c0ec($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequiref2444e07caaed476ec8d2343d153c0ec($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
@@ -835,10 +835,10 @@ class ComposerStaticInit5d9881c444dc082c214fb3c84d951ad4
|
|
835 |
public static function getInitializer(ClassLoader $loader)
|
836 |
{
|
837 |
return \Closure::bind(function () use ($loader) {
|
838 |
-
$loader->prefixLengthsPsr4 =
|
839 |
-
$loader->prefixDirsPsr4 =
|
840 |
-
$loader->prefixesPsr0 =
|
841 |
-
$loader->classMap =
|
842 |
|
843 |
}, null, ClassLoader::class);
|
844 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
835 |
public static function getInitializer(ClassLoader $loader)
|
836 |
{
|
837 |
return \Closure::bind(function () use ($loader) {
|
838 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec::$prefixLengthsPsr4;
|
839 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec::$prefixDirsPsr4;
|
840 |
+
$loader->prefixesPsr0 = ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec::$prefixesPsr0;
|
841 |
+
$loader->classMap = ComposerStaticInitf2444e07caaed476ec8d2343d153c0ec::$classMap;
|
842 |
|
843 |
}, null, ClassLoader::class);
|
844 |
}
|
views/newsletter/templates/blocks/image/block.hbs
CHANGED
@@ -1,3 +1,14 @@
|
|
1 |
<div class="mailpoet_tools"></div>
|
2 |
-
<div class="mailpoet_content" style="text-align: {{ model.styles.block.textAlign }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
<div class="mailpoet_block_highlight"></div>
|
1 |
<div class="mailpoet_tools"></div>
|
2 |
+
<div class="mailpoet_content" style="text-align: {{ model.styles.block.textAlign }}; width: {{model.width}}">
|
3 |
+
<div class="mailpoet_image">
|
4 |
+
<a href="{{ model.link }}" onClick="return false;">
|
5 |
+
<img src="{{#ifCond model.src '!=' ''}}{{ model.src }}{{ else }}{{ imageMissingSrc }}{{/ifCond}}" alt="{{ model.alt }}" onerror="if(this.src != '{{ imageMissingSrc }}') {this.src = '{{ imageMissingSrc }}'; this.style.width='auto';}" width="{{model.width}}" />
|
6 |
+
</a>
|
7 |
+
<div class="mailpoet_image_resize_handle_container">
|
8 |
+
<div class="mailpoet_image_resize_handle">
|
9 |
+
<span class="mailpoet_image_resize_handle_icon"><%= source('newsletter/templates/svg/block-tools/resize.svg') %></span>
|
10 |
+
</div>
|
11 |
+
</div>
|
12 |
+
</div>
|
13 |
+
</div>
|
14 |
<div class="mailpoet_block_highlight"></div>
|
views/newsletter/templates/blocks/image/settings.hbs
CHANGED
@@ -23,6 +23,31 @@
|
|
23 |
</div>
|
24 |
</label>
|
25 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
<div class="mailpoet_form_field">
|
27 |
<div class="mailpoet_form_field_checkbox_option">
|
28 |
<label>
|
23 |
</div>
|
24 |
</label>
|
25 |
</div>
|
26 |
+
<div class="mailpoet_form_field">
|
27 |
+
<label>
|
28 |
+
<div class="mailpoet_form_field_title"><%= __('Width') %></div>
|
29 |
+
<div class="mailpoet_form_field_input_option">
|
30 |
+
<input
|
31 |
+
class="mailpoet_input mailpoet_input_small mailpoet_field_image_width_input"
|
32 |
+
name="image-width-input"
|
33 |
+
type="number"
|
34 |
+
value="{{getNumber model.width}}"
|
35 |
+
min="36"
|
36 |
+
max="660"
|
37 |
+
step="2"
|
38 |
+
/> px
|
39 |
+
<input
|
40 |
+
class="mailpoet_range mailpoet_range_small mailpoet_field_image_width"
|
41 |
+
name="image-width"
|
42 |
+
type="range"
|
43 |
+
value="{{getNumber model.width}}"
|
44 |
+
min="36"
|
45 |
+
max="660"
|
46 |
+
step="2"
|
47 |
+
/>
|
48 |
+
</div>
|
49 |
+
</label>
|
50 |
+
</div>
|
51 |
<div class="mailpoet_form_field">
|
52 |
<div class="mailpoet_form_field_checkbox_option">
|
53 |
<label>
|
views/newsletter/templates/svg/block-icons/spacer.svg
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
2 |
-
viewBox="239.062 263.438 153 284.25" enable-background="new 239.062 263.438 153 284.25" xml:space="preserve">
|
3 |
-
<path d="M315.563,263.438l76.5,76.538h-153L315.563,263.438z M315.563,547.688l-76.5-76.537h153L315.563,547.688z"/>
|
4 |
-
</svg>
|
1 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
2 |
+
viewBox="239.062 263.438 153 284.25" enable-background="new 239.062 263.438 153 284.25" xml:space="preserve">
|
3 |
+
<path d="M315.563,263.438l76.5,76.538h-153L315.563,263.438z M315.563,547.688l-76.5-76.537h153L315.563,547.688z"/>
|
4 |
+
</svg>
|
views/newsletter/templates/svg/block-tools/resize.svg
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
2 |
+
viewBox="0 0 150 150" enable-background="new 0 0 150 150" xml:space="preserve">
|
3 |
+
<path d="M30,30L100,30L30,100ZM120,120L120,50L50,120Z"/>
|
4 |
+
</svg>
|