Compare commits

..

260 Commits

Author SHA1 Message Date
c3db7d8148 Release 3.0.0-rc.2.0.3 2017-09-12 15:41:06 +03:00
4a2187ff32 Merge pull request #1096 from mailpoet/translation_strings_update
Removes escape character in translations [MAILPOET-1093]
2017-09-12 14:24:38 +03:00
279c36a30d Merge pull request #1094 from mailpoet/initializer_update
Updates plugin initialization logic [MAILPOET-1097]
2017-09-12 12:34:27 +03:00
9305beace3 Removes escape character in translations 2017-09-11 19:27:03 -04:00
ba86cbfb18 Updates unit test 2017-09-11 11:40:14 -04:00
2ac7d1d4ab Breaks plugin initialization into 3 stages: preInit, init and postInit 2017-09-11 11:33:03 -04:00
e9c55260c8 Merge pull request #1092 from mailpoet/db_version_settings_logic_update
Uses plugin's settings to store DB version [MAILPOET-1095]
2017-09-11 18:15:17 +03:00
99b6a287f8 Highlight a container block when hovering over its tools [MAILPOET-1088] 2017-09-11 15:32:45 +01:00
d645f0cad4 Merge pull request #1087 from mailpoet/eslint-un
Eslint un [MAILPOET-1073]
2017-09-11 16:16:51 +02:00
b0343254c0 Renames db version setting value 2017-09-11 10:05:09 -04:00
cc368f015b Remove redundant argument
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
4e508855fc Fix eslint no-unused-expressions in tests
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
72c0a6f165 Fix eslint no-undef in tests
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
f266508654 Fix eslint no-undef in ES6
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
1893d82b2d Fix eslint no-unused-expressions in ES6
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
bb1dd6a2ec Fix eslint import/no-unresolved in ES6
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
7097ea5d9b Fix eslint no-unreachable in ES6
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
b4092e0641 Fix eslint no-unneeded-ternary in ES5
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
2c068c7bb6 Fix eslint no-unreachable in ES5
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
a1a4fcb978 Fix eslint no-unused-expressions in ES5
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
f77620d649 Fix eslint no-undef in ES5
[MAILPOET-1085]
2017-09-11 15:03:30 +01:00
9e932c9078 Merge pull request #1085 from mailpoet/improve-user-sync
Improve user sync [MAILPOET-1073]
2017-09-11 14:56:41 +03:00
de47dbe41b Removes arrow functions that are not supported in IE 2017-09-11 10:25:43 +01:00
6d36d67a60 Delete orphaned subscribers instead of updating their id
[MAILPOET-1073]
2017-09-11 10:09:32 +01:00
607bf51b37 Merge two test cases for one class
[MAILPOET-1073]
2017-09-11 09:28:39 +01:00
f38ed0272c Merge pull request #1093 from mailpoet/cron_helper_improvement
Cron helper improvement [MAILPOET-1096]
2017-09-11 11:23:01 +03:00
eef969439b Code comment
[MAILPOET-1073]
2017-09-11 09:22:40 +01:00
272f552f3c Clean data befre and after test run
[MAILPOET-1073]
2017-09-11 09:22:18 +01:00
dff9c1012b Moves widget initialization back to widgets_init hook
Removes priority from plugin initialization
2017-09-10 19:49:05 -04:00
52470360a1 Returns ping response body instead of boolean 2017-09-10 18:49:15 -04:00
6c62459ed4 Adds filter to override default cron request URL 2017-09-10 18:36:22 -04:00
98482cebf9 Uses plugin's settings to store DB version 2017-09-10 16:31:36 -04:00
509880119e Merge pull request #1090 from mailpoet/eslint-indent
Eslint indent [MAILPOET-1029]
2017-09-07 20:13:20 -04:00
195ccb5eed Fix indent rule in tests
[MAILPOET-1029]
2017-09-07 16:05:45 +01:00
122af1c943 Fix react/jsx-indent rule in ES6
[MAILPOET-1029]
2017-09-07 15:59:38 +01:00
169940058b Fix react/jsx-indent-props rule in ES6
[MAILPOET-1029]
2017-09-07 15:52:46 +01:00
478e60d60e Fix indent rule in ES5
[MAILPOET-1029]
2017-09-07 15:51:25 +01:00
9fc0ac8c4f Merge pull request #1089 from mailpoet/color_picker
Change color on click, add history to color picker [MAILPOET-1087]
2017-09-07 17:08:09 +03:00
e86b780479 Fix build`
[MAILPOET-1073]
2017-09-07 14:44:55 +01:00
42f08bdc65 Fix handling of empty color and transparent color selected from palette [MAILPOET-1087] 2017-09-07 15:48:14 +03:00
c2789cdac3 Don't load all ids to memory, PHP could crash
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
8a362f49f8 Add test for users synchronisation
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
784a80d1a5 Use ->prefix instead of wp_
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
922d2b4b5f Fix migration
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
91e8461cac Clean the code
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
8757598a2d Add index
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
524aabea1d Split users sync into multiple queries
[MAILPOET-1073]
2017-09-07 13:42:18 +01:00
513181ff47 Change color on click, add history to color picker [MAILPOET-1087] 2017-09-07 13:17:57 +03:00
6bc288ed54 Merge pull request #1088 from mailpoet/depreciated_twig_notice_fix
Fixed Twig's deprecated notice [MAILPOET-1092]
2017-09-07 12:48:11 +03:00
77f3a875dd Does not set global is_rtl variable 2017-09-06 20:56:52 -04:00
6584250d1a Adds is_rtl() function to Twig 2017-09-06 20:55:44 -04:00
e42db162aa Merge pull request #1086 from mailpoet/translation_fixes
Fix translations based on translator feedback on TX [MAILPOET-1091]
2017-09-06 16:30:13 +03:00
2762096167 Switch strtoupper to mb_strtoupper based on feedback 2017-09-06 16:14:52 +03:00
b2ec3e5f7b Fix translations based on translator feedback on TX [MAILPOET-1091] 2017-09-06 13:45:42 +03:00
e012bd6cbe Updates changelog & bumps up release version to 3.0.0-rc.2.0.2 2017-09-05 11:17:32 -04:00
a02e64e805 Merge pull request #1084 from mailpoet/editor_get_post_type_optimization
Removes unused properties from the object used to display post types in editor [MAILPOET-1086]
2017-09-05 17:43:27 +03:00
e4bb3e1133 Adds unit test 2017-09-05 10:33:10 -04:00
998795e0e0 Fix tests semi eslint rule [MAILPOET-1030] 2017-09-05 12:31:51 +01:00
ec44b84cc9 Fix ES6 no-extra-semi eslint rule [MAILPOET-1030] 2017-09-05 12:31:51 +01:00
efece061d0 Fix ES5 semi eslint rule [MAILPOET-1030] 2017-09-05 12:31:51 +01:00
e347fc74a2 Fix ES5 no-extra-semi eslint rule [MAILPOET-1030] 2017-09-05 12:31:51 +01:00
027418a86c Fix ES5 semi-spacing eslint rule [MAILPOET-1030] 2017-09-05 12:31:51 +01:00
864187aa02 Merge pull request #1080 from mailpoet/json_api_method_check_fix
Throws error when JSON API endpoint method is not found [MAILPOET-1074]
2017-09-05 13:08:37 +03:00
59ae6619c0 Browser preview mixed content error fix
Strips protocol from preview URL

[MAILPOET-1080]
2017-09-05 08:54:23 +01:00
6aa0be8d01 Removes unused properties from the object 2017-09-04 21:07:15 -04:00
657658ea2b Adds new poll 2017-09-04 10:49:11 +02:00
8647128e12 Merge pull request #1081 from mailpoet/default_status_update
Default status is set depending on the signup confirmation option [MAILPOET-1079]
2017-09-04 10:02:45 +03:00
c8d92b3cd2 Default status is set depending on the signup confirmation option 2017-08-31 18:48:43 -04:00
cc8b7b45ed Throws error when endpoint method is not found 2017-08-31 15:18:22 -04:00
5b8b8c8441 Merge pull request #1077 from mailpoet/helpscout
Split support inquiries into Free and Premium inboxes [MAILPOET-869]
2017-08-31 12:38:18 -04:00
7106c640ef Refactor HelpScout Beacon embed script 2017-08-31 19:24:32 +03:00
300b84983d Merge pull request #1078 from mailpoet/spellchecker
Enable browser spellchecker [MAILPOET-1078]
2017-08-31 18:14:47 +03:00
49c1b92838 Enable browser spellchecker 2017-08-31 18:03:19 +03:00
d900827850 Merge pull request #1076 from mailpoet/lint-lines
Lint lines [MAILPOET-1031]
2017-08-31 12:49:10 +03:00
1688d4dbe1 Split support inquiries into Free and Premium inboxes [MAILPOET-869] 2017-08-31 12:02:20 +03:00
856c636089 Releasing 3.0.0-rc.2.0.1 2017-08-30 16:06:39 +00:00
8f9e8ea185 Merge pull request #1075 from mailpoet/forms-bug
Fix form issue when using list selection field [MAILPOET-1077]
2017-08-30 18:10:33 +03:00
b0b88693f1 Merge pull request #1071 from mailpoet/initializer_cleanup
Fixes activation on MS environments and cleans up Initializer [MAILPOET-1076]
2017-08-30 17:56:16 +03:00
9916eb9da8 updated tests 2017-08-30 14:52:17 +00:00
79b5426e01 Fix a constant name [MAILPOET-1076] 2017-08-30 17:47:53 +03:00
5807fd2e02 Merge pull request #1067 from mailpoet/emoji
Add emoji support to newsletter body [MAILPOET-1009]
2017-08-30 10:04:26 -04:00
0ee39143f4 Runs hooks setup only when plugin is initilized 2017-08-30 09:50:49 -04:00
10c39bd650 Removes unused constructor 2017-08-30 09:47:34 -04:00
20593cc5a5 Fix form issue when using list selection field 2017-08-30 13:29:41 +00:00
f438eee842 Fix ESLint newline-per-chained-call in tests
[MAILPOET-1031]
2017-08-30 15:26:02 +02:00
cb4b599d97 Merge pull request #1073 from mailpoet/fix-notice
Fix php notice
2017-08-30 16:25:50 +03:00
33733219f6 Fix ESLint object-property-newline in tests
[MAILPOET-1031]
2017-08-30 15:20:39 +02:00
737a83cdf3 Fix ESLint linebreak-style in tests
[MAILPOET-1031]
2017-08-30 15:19:15 +02:00
9061e1b495 Fix ESLint no-multipe-empty-lines ES6
[MAILPOET-1031]
2017-08-30 15:11:56 +02:00
09199e41a1 Fix ESLint linebreak-style ES5
[MAILPOET-1031]
2017-08-30 14:59:34 +02:00
4e91932613 Fix ESLint lines-around-directive ES5
[MAILPOET-1031]
2017-08-30 14:45:25 +02:00
227de4ecfa Fix ESLint newline-per-chained-call ES5
[MAILPOET-1031]
2017-08-30 14:40:42 +02:00
c1ccacf851 Fix ESLint newline-per-chained-call
[MAILPOET-1031]
2017-08-30 14:30:48 +02:00
53f7953566 Fix browser preview bypassing emoji encoding [MAILPOET-1009] 2017-08-30 14:39:38 +03:00
61ae2da1e3 Fix a constant not defined in PHP 5.3 [MAILPOET-1009] 2017-08-30 14:02:29 +03:00
36abd8e5e6 Don't show network activation notice for other plugins
[MAILPOET-1072]
2017-08-30 11:39:42 +02:00
7e9de1fd07 Fix php notice 2017-08-30 11:25:42 +02:00
7ac5e65963 Fix php notice 2017-08-30 10:30:16 +02:00
cf992852b5 Validate for unsubscribe link only for MSS sending method [MAILPOET-1050] 2017-08-30 10:16:24 +02:00
59482b2bfa Uses init hook to initilize AccessControl 2017-08-29 23:30:35 -04:00
053f9e0cdf Adds higher priority to init hook so that it fires before the widgets hook 2017-08-29 23:20:46 -04:00
e1cc25239b Maintains code consistency when setting up JSON API
Updates exception handler return statement
2017-08-29 20:33:50 -04:00
2f4452ad36 Removes redundant exception handler 2017-08-29 20:28:20 -04:00
f453d685d6 Fixes translation not being picked up by makepot 2017-08-29 20:24:04 -04:00
2d2b4ca7f0 Moves setup actions from plugins_loaded hook to init hook
Rearranges class methods to follow the order by which they are called
2017-08-29 20:22:19 -04:00
546e012fbf releasing 3.0.0-rc.2.0.0 2017-08-29 13:43:15 +00:00
83adf089c5 Merge pull request #1070 from mailpoet/permissions
Fix Endpoint to use single global permission and not array of them [MAILPOET-1057]
2017-08-29 14:47:18 +02:00
2f45bb05d7 Fix Endpoint to use single global permission and not array of them
[MAILPOET-1057]
2017-08-29 15:34:35 +03:00
9ef8ab3e28 Merge pull request #1065 from mailpoet/events
Track extra events on MixPanel [MAILPOET-970]
2017-08-29 15:26:24 +03:00
f4db4f05c4 minor fixes 2017-08-29 12:18:12 +00:00
e7e08dbb3a minor fixes 2017-08-29 12:07:57 +00:00
02e2f0c07a Merge pull request #1066 from mailpoet/premium-update-warning
Premium update warning [PREMIUM-28]
2017-08-29 12:52:18 +03:00
c75b6bd7eb Show warning only on plugins page
[PREMIUM-28]
2017-08-29 11:22:51 +02:00
b74be8777a Display warning on Email pages
[PREMIUM-28]
2017-08-29 11:22:51 +02:00
7463e0d1f1 Update invalid key message
[PREMIUM-28]
2017-08-29 11:22:51 +02:00
a378880cf8 Merge pull request #1069 from mailpoet/bridge_forbidden_response
Adds 403 response code that mirrors 401 behavior [MAILPOET-1070]
2017-08-29 11:20:56 +03:00
33fa496913 Add a message for an already used MSS key [MAILPOET-1070] 2017-08-29 11:10:09 +03:00
eff996e1f8 Unify key state constant names, leave back compat with unlocker [MAILPOET-1070] 2017-08-29 10:58:16 +03:00
28b894b26b Add test cases [MAILPOET-1070] 2017-08-29 09:20:03 +03:00
c914aedc0d Simplify API response codes handling [MAILPOET-1070] 2017-08-29 09:18:08 +03:00
1745b67d64 Adds 403 response code that mirrors 401 behavior 2017-08-28 21:25:54 -04:00
2d25974fdc Merge pull request #1068 from mailpoet/helpscout
Update HS Beacon icon to question mark [MAILPOET-869]
2017-08-28 19:49:12 -04:00
51a02784e2 Update HS Beacon icon to question mark [MAILPOET-869] 2017-08-28 19:12:27 +03:00
b9bdc86fd9 Add emoji support to newsletter body [MAILPOET-1009] 2017-08-28 19:07:17 +03:00
e580e6b92b Merge pull request #1041 from mailpoet/access_control
Allows granular control of access to various parts of the plugin [MAILPOET-1057] [MAILPOET-1048]
2017-08-28 16:48:47 +03:00
96f77498f7 Merge pull request #1061 from mailpoet/safari-error-fix
Safari error fix [MAILPOET-1011]
2017-08-28 13:33:43 +02:00
62ce7c0437 Merge pull request #1062 from mailpoet/wp_user_subscription_update_fix
Prevents WP subscribers' first/last name from being erased [MAILPOET-1062]
2017-08-28 12:57:25 +03:00
c1e542cb5a Reschedules past due scheduled queues when reactivating notification 2017-08-28 09:20:17 +02:00
544bf0ddfd Merge pull request #1064 from mailpoet/welcome_alc_fix
Don't track sent ALC posts for welcome and standard emails, always send the latest posts [MAILPOET-1069]
2017-08-25 10:36:46 -04:00
609f1b5e67 Tracking new events 2017-08-25 13:19:52 +00:00
4616cf67bf Fix a test [MAILPOET-1069] 2017-08-25 16:10:01 +03:00
cc5227ca0d Don't track sent ALC posts for welcome and standard emails (always send the latest posts) [MAILPOET-1069] 2017-08-25 15:51:45 +03:00
26bccd95d4 Uses method vs. accessing class internals to get user capability 2017-08-24 13:58:54 -04:00
af58814fe7 Moves AccessControl intialization outside of Router to Initializer 2017-08-24 13:56:17 -04:00
7d9b4b31aa Removes unused constructor parameter 2017-08-24 13:37:49 -04:00
8a8108b41d Prevents WP subscribers' first/last name from being erased when updating
subscription
2017-08-24 13:19:42 -04:00
d92b1f57bd Merge pull request #1060 from mailpoet/mp2_forms_fix
Don't process the wysija_form shortcode to allow MP2 forms to work [MAILPOET-1067]
2017-08-24 10:40:10 -04:00
52ef7bece4 Merge pull request #1053 from mailpoet/editor_save
Save newsletter when clicked on "Next" button [MAILPOET-1051]
2017-08-24 09:03:34 -04:00
dc11046ad1 Fixes undefined JS error when vendor.js is loaded deferred
[MAILPOET-1026]
2017-08-24 13:37:15 +02:00
01f41b9798 Fix App and Application argument naming 2017-08-24 14:17:32 +03:00
9c0d9c31f8 Refactor cancelAutosave to return early 2017-08-24 13:48:13 +03:00
df499095c4 Fix test indentation 2017-08-24 13:40:46 +03:00
05dca3d2ce Excludes honeypot from subscription management form 2017-08-24 11:17:40 +02:00
ec35b90f3e Fix react warning
[MAILPOET-1011]
2017-08-24 11:01:33 +02:00
1b7e3a997f Fix not fully formated selector
[MAILPOET-1011]
2017-08-24 10:23:42 +02:00
c598537025 Remove empty lines 2017-08-24 09:16:51 +02:00
6f149e3ec4 tests: quote-props 2017-08-24 09:16:51 +02:00
d181bde0e9 tests: quotes 2017-08-24 09:16:51 +02:00
2985705b14 ES6: quote-props 2017-08-24 09:16:51 +02:00
6ce925fbe8 ES6: quotes 2017-08-24 09:16:51 +02:00
b8aceff61f ES5: quote-props 2017-08-24 09:16:51 +02:00
cd091c2af6 ES5: quotes 2017-08-24 09:16:51 +02:00
510cacf2fd Don't process the wysija_form shortcode to allow MP2 forms to work [MAILPOET-1067] 2017-08-24 08:22:10 +03:00
eac6b1b414 Corrects coding style 2017-08-23 11:45:33 -04:00
316fa91a10 Moves AccessControl initialization outside of API to Initializer 2017-08-23 11:28:09 -04:00
7c23415d26 Updates unit test as a result of AccessControl implementation 2017-08-23 11:28:09 -04:00
28320cdbb6 Updates permission validation method on AccessControl
Adds/updates unit tests
2017-08-23 11:28:08 -04:00
48f3ae4ea1 Adds access control unit tests 2017-08-23 11:28:08 -04:00
e47c8bc701 Adds access control tests for Router 2017-08-23 11:28:08 -04:00
78429d8f91 Validates global permission at the AccessControl level
Changes error response code on invalid permission
2017-08-23 11:27:54 -04:00
80c4eeed5e Merge pull request #1055 from mailpoet/new-poll
New poll [MAILPOET-1040]
2017-08-23 14:45:05 +02:00
5985d659f9 New poll
[MAILPOET-1040]
2017-08-23 14:11:35 +02:00
638de3cf55 Merge pull request #1054 from mailpoet/coverage-fix
Coverage fix [MAILPOET-1064]
2017-08-23 13:41:43 +03:00
967fa09f4f Remove redundant build
[MAILPOET-1064]
2017-08-23 12:32:34 +02:00
a15e1200b5 Upgrade codeception version
[MAILPOET-1064]
2017-08-23 12:32:34 +02:00
a15b46cbab Fix Code coverage reporting
[MAILPOET-1064]
2017-08-23 12:15:56 +02:00
dcb0b45c21 Save newsletter before navigating away when clicked on "Next" button 2017-08-22 17:34:23 +03:00
14810a22b5 Bump up release version to 3.0.0-rc.1.0.4 2017-08-22 16:26:48 +03:00
1b756ef0b2 Adds access management to router and updates endpoints accordingly 2017-08-22 09:06:20 -04:00
5553817f9a Creates method to get user's first capability 2017-08-22 09:06:20 -04:00
4b7fb3ae3d Updates access permission names to improve clarity 2017-08-22 09:06:20 -04:00
efa231b08f Removes AccessControl from Migrator and Changelog 2017-08-22 09:06:20 -04:00
8d8dfaa11f Uses Intializer to check permissions before running Activator 2017-08-22 09:06:20 -04:00
5ba2c4bc3a Removes AccessControl from individual API endpoints 2017-08-22 09:06:20 -04:00
788494ec47 Updates API initialization 2017-08-22 09:06:20 -04:00
5e7f9e3edf Passes AccessControl to JSON API via constructor parameter
Removes passing AccessControl to individual API endpoints
2017-08-22 09:06:20 -04:00
2e5554a3af Refactors AccessControl and passes it as dependency to JSON API and Menu 2017-08-22 09:06:20 -04:00
51fbf29031 Modifies Activator to use AccessControl 2017-08-22 09:06:19 -04:00
c3c6ce989c Modifies Menu to use AccessControl 2017-08-22 09:06:19 -04:00
a241d0c7bc Modifies JSON API to use AccessControl 2017-08-22 09:06:19 -04:00
632bce7894 Adds AccessControl class that defines permissions for major plugin
operations
2017-08-22 09:04:39 -04:00
1151354278 Conditionally uses set_time_limit() when function is not disabled 2017-08-22 09:04:39 -04:00
c12752403f Fix build 2017-08-22 13:40:11 +02:00
d3ff174e9f Fix inability to deactivate MSS [MAILPOET-1058] 2017-08-22 13:35:51 +02:00
03df7e723c Merge pull request #1051 from mailpoet/composer-fix
Fix composer.lock [PREMIUM-35]
2017-08-22 12:24:40 +03:00
6c8fe8413a Merge pull request #1047 from mailpoet/eslint-assignment
Eslint assignment [MAILPOET-1033]
2017-08-22 09:59:35 +02:00
89b0b51980 Merge pull request #1050 from mailpoet/new-poll
New poll [MAILPOET-1042]
2017-08-21 11:57:26 -04:00
fa1ab733f8 Fix composer.lock
[PREMIUM-35]
2017-08-21 16:34:43 +02:00
127022645e Revert "Update composer.lock"
This reverts commit b1d26b8cee.
2017-08-21 13:39:15 +02:00
b1d26b8cee Update composer.lock
[PREMIUM-35]
2017-08-21 13:26:13 +02:00
f07b90adde Merge pull request #1049 from mailpoet/safari-unsafe
This is a non-secure form. [MAILPOET-1063]
2017-08-21 13:31:50 +03:00
b3884d06a8 New poll
[MAILPOET-1042]
2017-08-21 11:02:49 +02:00
abf1d817f4 Remove form action
[MAILPOET-1063]
2017-08-21 10:37:13 +02:00
c7b7b0abad Merge pull request #1011 from mailpoet/acceptance-tests
Initial acceptance testing setup [MAILPOET-997]
2017-08-17 19:28:27 -04:00
8540e5eea9 Merge pull request #1017 from mailpoet/rerender-newsletter
Rerender newsletter [MAILPOET-675]
2017-08-17 16:19:16 +03:00
09ed3d4fa6 refactoring the code 2017-08-17 12:16:40 +00:00
b96dc8b3f7 Merge pull request #1048 from mailpoet/migration-fix
Skip migration on empty db
2017-08-17 14:04:47 +03:00
0a4dc3eb38 Skip all migration on empty db 2017-08-17 12:58:33 +02:00
a78af28943 Track newsletter UI events with MixPanel
[MAILPOET-999]
2017-08-17 12:45:12 +02:00
f035d12aaf Skip migration on empty db 2017-08-17 11:55:51 +02:00
6353075f1e Don't delete vendor
[MAILPOET-997]
2017-08-17 08:13:11 +02:00
6c91ca9d31 Reinstall vendor
[MAILPOET-997]
2017-08-17 08:13:11 +02:00
6f8634570c Replace repo directory
[MAILPOET-997]
2017-08-17 08:13:11 +02:00
0efcfad3d1 Increase docker compose timeout
[MAILPOET-997]
2017-08-17 08:13:11 +02:00
5d7b54ab22 Add circle ci configuration
[MAILPOET-997]
2017-08-17 08:13:11 +02:00
ad1f6e2a8e Fix caching problem
[MAILPOET-997]
2017-08-17 08:13:11 +02:00
d844b7e47f Initial acceptance testing setup
[MAILPOET-997]
2017-08-17 08:13:10 +02:00
36d4e3eb15 Merge pull request #1034 from mailpoet/ui-help-tooltips
Ui help tooltips [MAILPOET-976]
2017-08-16 19:23:13 -04:00
853f686dde List and scheduling inputs are disabled instead of being hidden 2017-08-16 14:44:42 +00:00
d17486bac4 Merge pull request #1046 from mailpoet/spambot-forms
Add honeypot field for spambot [MAILPOET-1014]
2017-08-16 16:47:21 +03:00
4226684c5a Make tests more obvious
[MAILPOET-1014]
2017-08-16 15:32:07 +02:00
364dd1b2a3 Move field obfuscation into own class
[MAILPOET-1014]
2017-08-16 14:58:31 +02:00
eaf10e8a96 Fix no-param-reassign in tests
[MAILPOET-1033]
2017-08-16 12:34:59 +02:00
bac494ac0d Fix no-multi-assign in tests
[MAILPOET-1033]
2017-08-16 12:25:15 +02:00
acd2b9f51e Fix no-param-reassign in ES5
[MAILPOET-1033]
2017-08-16 12:22:56 +02:00
27c6fa5ff4 Fix no-multi-assign in ES5
[MAILPOET-1033]
2017-08-16 10:44:33 +02:00
89b51b6215 Fix no-cond-assign in ES5
[MAILPOET-1033]
2017-08-16 10:39:43 +02:00
7725391eff Fix no-return-assign in ES5
[MAILPOET-1033]
2017-08-16 10:30:11 +02:00
a37117cfa3 Fix no-param-reassign in ES6
[MAILPOET-1033]
2017-08-16 10:25:18 +02:00
856331caa4 Merge pull request #1044 from mailpoet/post_excerpt_hook
Adds a hook to specify custom max post excerpt length [MAILPOET-1056]
2017-08-15 16:45:26 +02:00
9117ae1a27 Fixing more bugs. Lists and scheduling options are hidden when editing a newsletter that is being sent 2017-08-15 14:39:02 +00:00
4aae8d56e5 Tooltip improvements
[MAILPOET-976]
2017-08-15 16:08:30 +02:00
033d527db9 fix some bugs 2017-08-15 12:55:06 +00:00
b2b1f7ff71 tests fixed 2017-08-15 12:55:06 +00:00
de261d6179 Added confirmation when 'edit' is clicked 2017-08-15 12:55:05 +00:00
a587b0a966 Links are not re-hashed when re-rendering the same newsletter 2017-08-15 12:55:05 +00:00
441aa14bcb fix js typo 2017-08-15 12:55:04 +00:00
4b4b5dd556 show 'Resume' button if the Newsletter was paused. 2017-08-15 12:55:04 +00:00
df9ba7e6c8 clearing the sending queue rendered body and subject
The new body and subject would be automatically rendered when
resuming sending
2017-08-15 12:55:04 +00:00
ca4f1c9387 Pause sending queue when editting the newsletter
An ajax request is sent to pause the sending queue when the editor
is displayed. If the newsletter is still a draft or has been already
sent; the error reponse is simply ignored. Otherwise a notice is
displayed specifying that the Email sending has been paused.
2017-08-15 12:55:03 +00:00
8c151d2d11 Fix failling test
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
78fb9ba46f Fix "Unexpected trailing comma"
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
3a0669e1a2 Fix react/no-danger eslint problem
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
c466e53681 Add tooltip to image heading
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
d02aed870e Add tooltip to image full width
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
fad7ff0018 Add tooltip to preheader
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
84a3f98725 Add tooltip to subject line
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
1c3e968ec4 Add tooltip to editor styles
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
c090a8260b Add tooltip to editor previw
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
65726de7de Add tooltip to send
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
33fe302f0d Add tooltip to import a template
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
2d702dd5d3 Add simple tooltip to help
[MAILPOET-976]
2017-08-15 14:49:22 +02:00
18f208cf47 Add honeypot field for spambot
[MAILPOET-1014]
2017-08-15 14:33:45 +02:00
f7b1016e63 Release 3.0.0-rc.1.0.3 2017-08-15 11:35:44 +02:00
223fedba72 Update vendor dependencies
Bump down codeception version to 2.2.11 for code coverage compatibility
with php 5.6

[MAILPOET-1049]
2017-08-15 10:12:48 +02:00
bf7e7e414f Adds hook to modify rendered form widget 2017-08-15 09:49:38 +02:00
618d0c0c9d Explicitly sets form target to _self as default 2017-08-15 09:49:38 +02:00
49318791fc Adds hook to modify max post excerpt 2017-08-14 20:55:49 -04:00
a5abdd28e1 Removes unused constructor parameter 2017-08-14 20:55:42 -04:00
70860a676c Merge pull request #1036 from mailpoet/date_shortcode_update
Translates and updates date shortcode to display WP time [MAILPOET-1046]
2017-08-14 13:09:08 +03:00
469e9fd8e1 Update poll to "how would you rate MailPoet's reliability?"
[MAILPOET-1043]
2017-08-14 08:49:44 +02:00
715b48df8d Merge pull request #1040 from mailpoet/preview-popup
Fit newsletter browser preview modal popup to screen [MAILPOET-975]
2017-08-13 11:31:05 -04:00
27ae0a9f16 Merge pull request #1039 from mailpoet/set_time_limit_update
Conditionally uses set_time_limit() when function is not disabled [MAILPOET-1054]
2017-08-11 19:52:15 +02:00
b92329a6b5 Fix popup dimensions to the viewport and show the close button 2017-08-11 17:30:13 +00:00
6fe5b7e0c5 Conditionally uses set_time_limit() when function is not disabled 2017-08-11 12:16:31 -04:00
7e0c500e4f Uses WP's date_i18n() to localize date shortcode 2017-08-10 12:46:27 -04:00
eec35c8ab6 Merge pull request #1037 from mailpoet/build-failures
Break the build when errors happen during build steps [MAILPOET-1052]
2017-08-10 16:35:55 +02:00
4096c4b31b Break the build when errors happen during build steps [MAILPOET-1052] 2017-08-10 14:51:37 +03:00
40cbefd1f4 Uses WP time vs. system time 2017-08-09 18:59:55 -04:00
fb5d43e975 Adds helper method to translate shortcodes
Adds translations to Date shortcode
2017-08-09 18:56:33 -04:00
272 changed files with 9349 additions and 5266 deletions

View File

@ -55,6 +55,48 @@ jobs:
- store_artifacts:
path: /tmp/fake-mailer/
destination: fake-mailer
acceptance_tests:
working_directory: /home/circleci/mailpoet
machine: true
steps:
- checkout
- run:
name: "Set up virtual host"
command: echo 127.0.0.1 mailpoet.loc | sudo tee -a /etc/hosts
- restore_cache:
key: composer-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
- restore_cache:
key: npm-{{ checksum "package.json" }}
- run:
name: "Set up test environment"
command: |
sudo apt-get update
sudo apt-get install circleci-php-5.6.23
sudo rm /usr/bin/php
sudo ln -s /opt/circleci/php/5.6.23/bin/php /usr/bin/php
# Install NodeJS+NPM
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install nodejs build-essential
# install plugin dependencies
curl -sS https://getcomposer.org/installer | php
php composer.phar install
./do install
- save_cache:
key: composer-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
paths:
- vendor
- save_cache:
key: npm-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: Run acceptance tests
command: |
docker-compose run codeception --steps --debug -vvv --html --xml
- store_artifacts:
path: ~/mailpoet/tests/acceptance-tests/_output
- store_test_results:
path: ~/mailpoet/tests/acceptance-tests/_output
php7:
working_directory: /home/circleci/mailpoet
docker:
@ -92,3 +134,4 @@ workflows:
jobs:
- qa_js_php5
- php7
- acceptance_tests

View File

@ -9,14 +9,8 @@
},
"rules": {
"import/no-amd": 0,
"space-before-function-paren": 0,
"prefer-arrow-callback": 0,
"no-undef": 0,
"key-spacing": 0,
"radix": 0,
"no-alert": 0,
@ -24,43 +18,32 @@
"guard-for-in": 0,
"no-prototype-builtins": 0,
"no-restricted-syntax": 0,
"newline-per-chained-call": 0,
"no-useless-concat": 0,
"no-multi-spaces": 0,
"no-nested-ternary": 0,
"semi-spacing": 0,
"no-sequences": 0,
"no-useless-return": 0,
"array-callback-return": 0,
"new-cap": 0,
"no-return-assign": 0,
"no-continue": 0,
"no-new": 0,
"no-cond-assign": 0,
"space-unary-ops": 0,
"no-redeclare": 0,
"no-console": 0,
"no-empty": 0,
"no-extra-semi": 0,
"no-useless-escape": 0,
"wrap-iife": 0,
"no-unused-expressions": 0,
"block-spacing": 0,
"computed-property-spacing": 0,
"no-plusplus": 0,
"array-bracket-spacing": 0,
"lines-around-directive": 0,
"no-unreachable": 0,
"default-case": 0,
"no-lonely-if": 0,
"space-before-blocks": 0,
"no-unneeded-ternary": 0,
"no-mixed-operators": 0,
"eqeqeq": 0,
"space-in-parens": 0,
"semi": 0,
"max-len": 0,
"no-multi-assign": 0,
"no-trailing-spaces": 0,
"global-require": 0,
"no-throw-literal": 0,
@ -75,7 +58,6 @@
"one-var": 0,
"camelcase": 0,
"spaced-comment": 0,
"quotes": 0,
"padded-blocks": 0,
"object-curly-spacing": 0,
"strict": 0,
@ -85,13 +67,9 @@
"no-unused-vars": 0,
"object-shorthand": 0,
"new-parens": 0,
"no-param-reassign": 0,
"keyword-spacing": 0,
"eol-last": 0,
"dot-notation": 0,
"linebreak-style": 0,
"indent": 0,
"quote-props": 0,
"prefer-template": 0,
"func-names": 0
}

View File

@ -10,24 +10,21 @@
"jsx": true
}
},
"settings": {
"import/resolver": "webpack"
},
"rules": {
"comma-dangle": ["error", "always-multiline"],
"import/no-amd": 0,
"react/no-multi-comp": 0,
"react/sort-comp": 0,
"react/jsx-max-props-per-line": 0,
"react/prop-types": 0,
"react/jsx-first-prop-new-line": 0,
"react/jsx-indent-props": 0,
"react/no-is-mounted": 0,
"react/jsx-no-target-blank": 0,
"react/no-render-return-value": 0,
"react/jsx-boolean-value": 0,
"react/jsx-indent": 0,
"react/jsx-no-bind": 0,
"react/no-array-index-key": 0,
"react/self-closing-comp": 0,
@ -37,11 +34,9 @@
"react/jsx-curly-spacing": 0,
"react/no-did-mount-set-state": 0,
"react/prefer-stateless-function": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/alt-text": 0,
"func-names": 0,
"object-shorthand": 0,
"no-bitwise": 0,
@ -49,17 +44,12 @@
"prefer-template": 0,
"keyword-spacing": 0,
"default-case": 0,
"quote-props": 0,
"array-callback-return": 0,
"consistent-return": 0,
"no-unreachable": 0,
"no-extra-semi": 0,
"import/no-unresolved": 0,
"import/extensions": 0,
"import/no-extraneous-dependencies": 0,
"camelcase": 0,
"template-curly-spacing": 0,
"quotes": 0,
"eqeqeq": 0,
"no-lonely-if": 0,
"space-unary-ops": 0,
@ -68,19 +58,15 @@
"no-multi-spaces": 0,
"class-methods-use-this": 0,
"key-spacing": 0,
"no-multiple-empty-lines": 0,
"space-in-parens": 0,
"no-case-declarations": 0,
"array-bracket-spacing": 0,
"newline-per-chained-call": 0,
"no-else-return": 0,
"max-len": 0,
"no-useless-concat": 0,
"no-unused-expressions": 0,
"no-sequences": 0,
"no-extra-boolean-cast": 0,
"dot-notation": 0,
"no-param-reassign": 0,
"no-shadow": 0,
"one-var": 0,
"no-alert": 0,
@ -91,7 +77,6 @@
"space-infix-ops": 0,
"no-irregular-whitespace": 0,
"padded-blocks": 0,
"no-underscore-dangle": 0,
"no-undef": 0
"no-underscore-dangle": 0
}
}

View File

@ -9,36 +9,22 @@
},
"rules": {
"import/no-amd": 0,
"no-undef": 0,
"one-var": 0,
"indent": 0,
"linebreak-style": 0,
"no-whitespace-before-property": 0,
"object-property-newline": 0,
"global-require": 0,
"semi": 0,
"keyword-spacing": 0,
"no-bitwise": 0,
"no-multi-assign": 0,
"newline-per-chained-call": 0,
"no-spaced-func": 0,
"func-call-spacing": 0,
"max-len": 0,
"space-unary-ops": 0,
"quotes": 0,
"no-unused-vars": 0,
"no-unused-expressions": 0,
"no-underscore-dangle": 0,
"quote-props": 0,
"no-shadow": 0,
"padded-blocks": 0,
"vars-on-top": 0,
"space-before-blocks": 0,
"object-curly-spacing": 0,
"no-param-reassign": 0,
"one-var-declaration-per-line": 0,
"func-names": 0,
"space-before-function-paren": 0

1
.gitignore vendored
View File

@ -3,7 +3,6 @@ TODO
composer.phar
/vendor
tests/_output/*
tests/acceptance.suite.yml
tests/_support/_generated/*
node_modules
.env

39
Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM php:5.6-cli
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN apt-get update && \
apt-get -y install \
git \
zlib1g-dev \
libssl-dev \
mysql-client \
sudo less \
--no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
docker-php-ext-install bcmath zip mysqli pdo pdo_mysql && \
echo "date.timezone = UTC" >> /usr/local/etc/php/php.ini && \
curl -sS https://getcomposer.org/installer | php -- \
--filename=composer \
--install-dir=/usr/local/bin && \
composer global require --optimize-autoloader "hirak/prestissimo" && \
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp
# Prepare application
WORKDIR /repo
# Install vendor
COPY ./composer.json /repo/composer.json
# Add source-code
COPY . /repo
WORKDIR /wp-core/wp-content/plugins/mailpoet
ENV WP_TEST_PATH=/wp-core
ADD docker-entrypoint.sh /
RUN ["chmod", "+x", "/docker-entrypoint.sh"]

View File

@ -180,3 +180,21 @@ Run 'svn copy ...' to tag the release
It's quite literal: you can review the changes to be pushed and if you're satisfied, run the suggested command to finish the release publishing process.
If you're confident, execute `./do publish --force` and your release will be published to the remote SVN repository without manual intervention (automatically). For easier authentication you might want to set `WP_SVN_USERNAME` and `WP_SVN_PASSWORD` environment variables.
# Acceptance testing
We are using Gravity Flow plugin's setup as an example for our acceptance test suite: https://www.stevenhenty.com/learn-acceptance-testing-deeply/
From the article above:
_Windows users only: enable hard drive sharing in the Docker settings._
The browser runs in a docker container. You can use a VNC client to watch the test run, follow instructions in official
repo: https://github.com/SeleniumHQ/docker-selenium
If youre on a Mac, you can open vnc://localhost:5900 in Safari to watch the tests running in Chrome. If youre on Windows, youll need a VNC client. Password: secret.
To run tests:
```sh
$ ./do test:acceptance
```

View File

@ -154,9 +154,8 @@ class RoboFile extends \Robo\Tasks {
function testUnit($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$command = 'vendor/bin/codecept run unit -f '.(($opts['file']) ? $opts['file'] : '');
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml -f '.(($opts['file']) ? $opts['file'] : '');
if($opts['xml']) {
$command .= ' --xml';
@ -166,9 +165,8 @@ class RoboFile extends \Robo\Tasks {
function testCoverage($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$command = join(' ', array(
'vendor/bin/codecept run',
'vendor/bin/codecept run unit -c codeception.unit.yml ',
(($opts['file']) ? $opts['file'] : ''),
'--coverage',
($opts['xml']) ? '--coverage-xml' : '--coverage-html'
@ -201,9 +199,9 @@ class RoboFile extends \Robo\Tasks {
function testDebug($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
$command = 'vendor/bin/codecept run unit --debug -f '.(($opts['file']) ? $opts['file'] : '');
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml --debug -f '.(($opts['file']) ? $opts['file'] : '');
if($opts['xml']) {
$command .= ' --xml';
@ -211,10 +209,14 @@ class RoboFile extends \Robo\Tasks {
return $this->_exec($command);
}
function testAcceptance() {
return $this->_exec('COMPOSE_HTTP_TIMEOUT=200 docker-compose run codeception --steps --debug -vvv');
}
function testFailed() {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
return $this->_exec('vendor/bin/codecept run -g failed');
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
return $this->_exec('vendor/bin/codecept run -c codeception.unit.yml -g failed');
}
function qa() {

View File

@ -45,7 +45,6 @@ body.mailpoet_modal_opened
position: absolute
z-index: 25
top: 48px
padding-bottom: 48px
margin: 0
.mailpoet_popup_wrapper
@ -54,6 +53,7 @@ body.mailpoet_modal_opened
position: relative
width: 100%
z-index: 0
height: 96%
.mailpoet_overlay_hidden .mailpoet_popup_wrapper
border: 1px solid #333
@ -75,6 +75,7 @@ body.mailpoet_modal_opened
.mailpoet_popup_body
padding: 10px 10px 10px 10px
height: 92%
// modal panel
#mailpoet_modal_overlay.mailpoet_panel_overlay

View File

@ -179,6 +179,28 @@ select.mailpoet_font-size
width: 100%
box-sizing: border-box
.tooltip-help-designer-subject-line div, .tooltip-help-designer-preheader div
z-index: 100001
.tooltip-help-send-preview
position: absolute
right: 15px
.tooltip-help-designer-ideal-width
color: #656565
text-transform: none
margin-left: 5px
font-weight: normal
.tooltip-help-designer-styles
position: absolute
top: 40px
.tooltip-help-designer-full-width .dashicons
line-height 34px
.tooltip-help-designer-full-width span
line-height 1.4em
.mailpoet_button_primary
border-color: $button-primary-border-color
background-color: $button-primary-background-color

View File

@ -23,8 +23,10 @@ $block-text-line-height = $text-line-height
border: 1px solid $transparent-color
&:hover > .mailpoet_block_highlight
&.mailpoet_highlight > .mailpoet_block_highlight
border: 1px dashed $block-hover-highlight-color
&.mailpoet_highlight > .mailpoet_block_highlight
border: 1px dashed $block-hover-highlight-color !important
.mailpoet_content
position: relative

View File

@ -127,9 +127,6 @@ body
background-color: $primary-background-color
border: 1px solid $content-border-color
#mailpoet_modal_close
display: none
.wrap > .mailpoet_notice,
.notice
.update-nag

View File

@ -54,6 +54,9 @@
#mailpoet_mta_activate
visibility hidden
.tooltip.dashicons.dashicons-editor-help
line-height: 1.4
ul.sending-method-benefits
list-style-type: none
margin-bottom: 2em

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 814 B

View File

@ -1,12 +1,12 @@
define('admin', [
'jquery'
],
function(jQuery) {
jQuery(function($) {
// dom ready
$(function() {
});
});
}
);
define('admin', [
'jquery'
],
function(jQuery) {
jQuery(function($) {
// dom ready
$(function() {
});
});
}
);

View File

@ -2,7 +2,7 @@ function requestFailed(errorMessage, xhr) {
if (xhr.responseJSON) {
return xhr.responseJSON;
}
var message = errorMessage.replace("%d", xhr.status);
var message = errorMessage.replace('%d', xhr.status);
return {
errors: [
{
@ -12,62 +12,63 @@ function requestFailed(errorMessage, xhr) {
};
}
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(mp, jQuery, _) {
var MailPoet = mp;
MailPoet.Ajax = {
version: 0.5,
options: {},
defaults: {
url: null,
api_version: null,
endpoint: null,
action: null,
token: null,
data: {}
},
post: function(options) {
return this.request('post', options);
},
init: function(options) {
// merge options
this.options = jQuery.extend({}, this.defaults, options);
version: 0.5,
options: {},
defaults: {
url: null,
api_version: null,
endpoint: null,
action: null,
token: null,
data: {}
},
post: function(options) {
return this.request('post', options);
},
init: function(options) {
// merge options
this.options = jQuery.extend({}, this.defaults, options);
// set default url
if(this.options.url === null) {
this.options.url = ajaxurl;
}
// set default url
if(this.options.url === null) {
this.options.url = window.ajaxurl;
}
// set default token
if(this.options.token === null) {
this.options.token = window.mailpoet_token;
}
},
getParams: function() {
return {
action: 'mailpoet',
api_version: this.options.api_version,
token: this.options.token,
endpoint: this.options.endpoint,
method: this.options.action,
data: this.options.data || {}
};
},
request: function(method, options) {
// set default token
if(this.options.token === null) {
this.options.token = window.mailpoet_token;
}
},
getParams: function() {
return {
action: 'mailpoet',
api_version: this.options.api_version,
token: this.options.token,
endpoint: this.options.endpoint,
method: this.options.action,
data: this.options.data || {}
};
},
request: function(method, options) {
// set options
this.init(options);
this.init(options);
// set request params
var params = this.getParams();
var params = this.getParams();
// remove null values from the data object
if (_.isObject(params.data)) {
params.data = _.pick(params.data, function(value) {
return (value !== null);
});
}
if (_.isObject(params.data)) {
params.data = _.pick(params.data, function(value) {
return (value !== null);
});
}
// ajax request
var deferred = jQuery.post(
var deferred = jQuery.post(
this.options.url,
params,
null,
@ -77,9 +78,9 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
}, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
// clear options
this.options = {};
this.options = {};
return deferred;
}
return deferred;
}
};
});

View File

@ -18,13 +18,14 @@
var eventsCache = [];
function track(name, data){
if (typeof window.mixpanel.track !== "function") {
if (typeof window.mixpanel.track !== 'function') {
window.mixpanel.init(window.mixpanelTrackingId);
}
window.mixpanel.track(name, data);
}
function exportMixpanel(MailPoet) {
function exportMixpanel(mp) {
var MailPoet = mp;
MailPoet.forceTrackEvent = track;
if (window.mailpoet_analytics_enabled) {
@ -37,20 +38,11 @@ function exportMixpanel(MailPoet) {
function trackCachedEvents() {
eventsCache.map(function (event) {
if (window.mailpoet_analytics_enabled || event.forced) {
window.mixpanel.track(event.name, event.data)
window.mixpanel.track(event.name, event.data);
}
});
}
function initializeMixpanelWhenLoaded() {
if (typeof window.mixpanel === "object") {
exportMixpanel(MailPoet);
trackCachedEvents();
} else {
setTimeout(initializeMixpanelWhenLoaded, 100);
}
}
function cacheEvent(forced, name, data) {
eventsCache.push({
name: name,
@ -61,7 +53,17 @@ function cacheEvent(forced, name, data) {
define(
['mailpoet', 'underscore'],
function(MailPoet, _) {
function(mp, _) {
var MailPoet = mp;
function initializeMixpanelWhenLoaded() {
if (typeof window.mixpanel === 'object') {
exportMixpanel(MailPoet);
trackCachedEvents();
} else {
setTimeout(initializeMixpanelWhenLoaded, 100);
}
}
MailPoet.trackEvent = _.partial(cacheEvent, false);
MailPoet.forceTrackEvent = _.partial(cacheEvent, true);

View File

@ -4,163 +4,166 @@ define('date',
'jquery',
'moment'
], function(
MailPoet,
mp,
jQuery,
Moment
) {
'use strict';
'use strict';
MailPoet.Date = {
version: 0.1,
options: {},
defaults: {
offset: 0,
format: 'F, d Y H:i:s'
},
init: function(options) {
options = options || {};
var MailPoet = mp;
MailPoet.Date = {
version: 0.1,
options: {},
defaults: {
offset: 0,
format: 'F, d Y H:i:s'
},
init: function (opts) {
var options = opts || {};
// set UTC offset
if (
if (
options.offset === undefined
&& window.mailpoet_date_offset !== undefined
) {
options.offset = window.mailpoet_date_offset;
}
options.offset = window.mailpoet_date_offset;
}
// set date format
if (
if (
options.format === undefined
&& window.mailpoet_date_format !== undefined
) {
options.format = window.mailpoet_date_format;
}
// merge options
this.options = jQuery.extend({}, this.defaults, options);
return this;
},
format: function(date, options) {
options = options || {};
this.init(options);
var date = Moment(date, this.convertFormat(options.parseFormat));
if (options.offset === 0) date = date.utc();
return date.format(this.convertFormat(this.options.format));
},
toDate: function(date, options) {
options = options || {};
this.init(options);
return Moment(date, this.convertFormat(options.parseFormat)).toDate();
},
short: function(date) {
return this.format(date, {
format: 'F, j Y'
});
},
full: function(date) {
return this.format(date, {
format: 'F, j Y H:i:s'
});
},
time: function(date) {
return this.format(date, {
format: 'H:i:s'
});
},
convertFormat: function(format) {
var format_mappings = {
date: {
d: 'DD',
D: 'ddd',
j: 'D',
l: 'dddd',
N: 'E',
S: 'o',
w: 'e',
z: 'DDD',
W: 'W',
F: 'MMMM',
m: 'MM',
M: 'MMM',
n: 'M',
t: '', // no equivalent
L: '', // no equivalent
o: 'YYYY',
Y: 'YYYY',
y: 'YY',
a: 'a',
A: 'A',
B: '', // no equivalent
g: 'h',
G: 'H',
h: 'hh',
H: 'HH',
i: 'mm',
s: 'ss',
u: 'SSS',
e: 'zz', // deprecated since version 1.6.0 of moment.js
I: '', // no equivalent
O: '', // no equivalent
P: '', // no equivalent
T: '', // no equivalent
Z: '', // no equivalent
c: '', // no equivalent
r: '', // no equivalent
U: 'X'
},
strftime: {
a: 'ddd',
A: 'dddd',
b: 'MMM',
B: 'MMMM',
d: 'DD',
e: 'D',
F: 'YYYY-MM-DD',
H: 'HH',
I: 'hh',
j: 'DDDD',
k: 'H',
l: 'h',
m: 'MM',
M: 'mm',
p: 'A',
S: 'ss',
u: 'E',
w: 'd',
W: 'WW',
y: 'YY',
Y: 'YYYY',
z: 'ZZ',
Z: 'z'
options.format = window.mailpoet_date_format;
}
};
// merge options
this.options = jQuery.extend({}, this.defaults, options);
if (!format || format.length <= 0) return format;
return this;
},
format: function(date, opts) {
var options = opts || {};
this.init(options);
var replacements = format_mappings['date'];
var momentDate = Moment(date, this.convertFormat(options.parseFormat));
if (options.offset === 0) momentDate = momentDate.utc();
return momentDate.format(this.convertFormat(this.options.format));
},
toDate: function(date, opts) {
var options = opts || {};
this.init(options);
var convertedFormat = [];
var escapeToken = false;
return Moment(date, this.convertFormat(options.parseFormat)).toDate();
},
short: function(date) {
return this.format(date, {
format: 'F, j Y'
});
},
full: function(date) {
return this.format(date, {
format: 'F, j Y H:i:s'
});
},
time: function(date) {
return this.format(date, {
format: 'H:i:s'
});
},
convertFormat: function(format) {
var format_mappings = {
date: {
d: 'DD',
D: 'ddd',
j: 'D',
l: 'dddd',
N: 'E',
S: 'o',
w: 'e',
z: 'DDD',
W: 'W',
F: 'MMMM',
m: 'MM',
M: 'MMM',
n: 'M',
t: '', // no equivalent
L: '', // no equivalent
o: 'YYYY',
Y: 'YYYY',
y: 'YY',
a: 'a',
A: 'A',
B: '', // no equivalent
g: 'h',
G: 'H',
h: 'hh',
H: 'HH',
i: 'mm',
s: 'ss',
u: 'SSS',
e: 'zz', // deprecated since version 1.6.0 of moment.js
I: '', // no equivalent
O: '', // no equivalent
P: '', // no equivalent
T: '', // no equivalent
Z: '', // no equivalent
c: '', // no equivalent
r: '', // no equivalent
U: 'X'
},
strftime: {
a: 'ddd',
A: 'dddd',
b: 'MMM',
B: 'MMMM',
d: 'DD',
e: 'D',
F: 'YYYY-MM-DD',
H: 'HH',
I: 'hh',
j: 'DDDD',
k: 'H',
l: 'h',
m: 'MM',
M: 'mm',
p: 'A',
S: 'ss',
u: 'E',
w: 'd',
W: 'WW',
y: 'YY',
Y: 'YYYY',
z: 'ZZ',
Z: 'z'
}
};
for(var index = 0, token = ''; token = format.charAt(index); index++){
if (escapeToken === true) {
convertedFormat.push('['+token+']');
escapeToken = false;
} else {
if (token === '\\') {
// Slash escapes the next symbol to be treated as literal
escapeToken = true;
continue;
} else if (replacements[token] !== undefined) {
convertedFormat.push(replacements[token]);
} else {
if (!format || format.length <= 0) return format;
var replacements = format_mappings['date'];
var convertedFormat = [];
var escapeToken = false;
for(var index = 0, token = ''; format.charAt(index); index += 1){
token = format.charAt(index);
if (escapeToken === true) {
convertedFormat.push('['+token+']');
escapeToken = false;
} else {
if (token === '\\') {
// Slash escapes the next symbol to be treated as literal
escapeToken = true;
continue;
} else if (replacements[token] !== undefined) {
convertedFormat.push(replacements[token]);
} else {
convertedFormat.push('['+token+']');
}
}
}
}
return convertedFormat.join('');
}
};
});
return convertedFormat.join('');
}
};
});

View File

@ -143,28 +143,28 @@ define([
switch(dateType) {
case 'year_month_day':
value = {
'year': this.state.year,
'month': this.state.month,
'day': this.state.day,
year: this.state.year,
month: this.state.month,
day: this.state.day,
};
break;
case 'year_month':
value = {
'year': this.state.year,
'month': this.state.month,
year: this.state.year,
month: this.state.month,
};
break;
case 'month':
value = {
'month': this.state.month,
month: this.state.month,
};
break;
case 'year':
value = {
'year': this.state.year,
year: this.state.year,
};
break;
}
@ -212,7 +212,6 @@ define([
year={ this.state.year }
placeholder={ this.props.field.year_placeholder }
/>);
break;
case 'MM':
return (<FormFieldDateMonth
@ -224,7 +223,6 @@ define([
monthNames={ monthNames }
placeholder={ this.props.field.month_placeholder }
/>);
break;
case 'DD':
return (<FormFieldDateDay
@ -235,7 +233,6 @@ define([
day={ this.state.day }
placeholder={ this.props.field.day_placeholder }
/>);
break;
}
});
@ -245,7 +242,7 @@ define([
</div>
);
}
};
}
return FormFieldDate;
});

View File

@ -7,6 +7,7 @@ define([
'form/fields/checkbox.jsx',
'form/fields/selection.jsx',
'form/fields/date.jsx',
'jquery',
],
(
React,
@ -16,7 +17,8 @@ define([
FormFieldRadio,
FormFieldCheckbox,
FormFieldSelection,
FormFieldDate
FormFieldDate,
jQuery
) => {
const FormField = React.createClass({
renderField: function (data, inline = false) {
@ -28,12 +30,13 @@ define([
}
let field = false;
let dataField = data.field;
if(data.field['field'] !== undefined) {
data.field = jQuery.merge(data.field, data.field.field);
dataField = jQuery.merge(dataField, data.field.field);
}
switch(data.field.type) {
switch(dataField.type) {
case 'text':
field = (<FormFieldText {...data} />);
break;

View File

@ -116,6 +116,7 @@ define([
}
},
handleChange: function (e) {
let value;
if(this.props.onValueChange !== undefined) {
if(this.props.field.multiple) {
value = jQuery('#'+this.refs.select.id).val();
@ -180,6 +181,7 @@ define([
<select
id={ this.props.field.id || this.props.field.name }
ref="select"
disabled={this.props.field.disabled}
data-placeholder={ this.props.field.placeholder }
multiple={ this.props.field.multiple }
defaultValue={ this.getSelectedValues() }

View File

@ -5,13 +5,15 @@ define(
'classnames',
'react-router',
'form/fields/field.jsx',
'jquery',
],
(
React,
MailPoet,
classNames,
Router,
FormField
FormField,
jQuery
) => {
const Form = React.createClass({
@ -166,7 +168,7 @@ define(
const formClasses = classNames(
'mailpoet_form',
{ 'mailpoet_form_loading': this.state.loading || this.props.loading }
{ mailpoet_form_loading: this.state.loading || this.props.loading }
);
let beforeFormContent = false;

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, useRouterHistory } from 'react-router';
import { createHashHistory } from 'history';
import FormList from 'forms/list.jsx';
import FormList from './list.jsx';
const history = useRouterHistory(createHashHistory)({ queryKey: false });

View File

@ -1,7 +1,8 @@
import React from 'react';
import Listing from 'listing/listing.jsx';
import classNames from 'classnames';
import MailPoet from 'mailpoet';
import jQuery from 'jquery';
import Listing from '../listing/listing.jsx';
const columns = [
{
@ -128,7 +129,7 @@ const FormList = React.createClass({
endpoint: 'forms',
action: 'create',
}).done((response) => {
window.location = mailpoet_form_edit_url + response.data.id;
window.location = window.mailpoet_form_edit_url + response.data.id;
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
@ -145,7 +146,7 @@ const FormList = React.createClass({
'has-row-actions'
);
let segments = mailpoet_segments.filter((segment) => {
let segments = window.mailpoet_segments.filter((segment) => {
return (jQuery.inArray(segment.id, form.segments) !== -1);
}).map((segment) => {
return segment.name;
@ -190,7 +191,7 @@ const FormList = React.createClass({
</h1>
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
messages={ messages }

View File

@ -1,34 +1,34 @@
define('handlebars_helpers', ['handlebars'], function(Handlebars) {
// Handlebars helpers
Handlebars.registerHelper('concat', function() {
var size = (arguments.length - 1),
output = '';
for(var i = 0; i < size; i++) {
output += arguments[i];
};
return output;
var size = (arguments.length - 1),
output = '';
for(var i = 0; i < size; i++) {
output += arguments[i];
}
return output;
});
Handlebars.registerHelper('number_format', function(value, block) {
return Number(value).toLocaleString();
return Number(value).toLocaleString();
});
Handlebars.registerHelper('date_format', function(timestamp, block) {
if(window.moment) {
if(timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
return;
}
if(timestamp === undefined || isNaN(timestamp) || timestamp <= 0) {
return;
}
// set date format
var f = block.hash.format || "MMM Do, YYYY";
var f = block.hash.format || 'MMM Do, YYYY';
// check if we passed a timestamp
if(parseInt(timestamp, 10) == timestamp) {
return moment.unix(timestamp).format(f);
} else {
return moment.utc(timestamp).format(f);
}
if(parseInt(timestamp, 10) == timestamp) {
return window.moment.unix(timestamp).format(f);
} else {
return window.moment.utc(timestamp).format(f);
}
} else {
return timestamp;
};
}
});
Handlebars.registerHelper('cycle', function(value, block) {
@ -37,81 +37,81 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
});
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '!=':
return (v1 != v2) ? options.fn(this) : options.inverse(this);
case '!==':
return (v1 !== v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
case 'in':
var values = v2.split(',');
return (v2.indexOf(v1) !== -1) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '!=':
return (v1 != v2) ? options.fn(this) : options.inverse(this);
case '!==':
return (v1 !== v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
case 'in':
var values = v2.split(',');
return (v2.indexOf(v1) !== -1) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
});
Handlebars.registerHelper('nl2br', function(value, block) {
return value.gsub("\n", "<br />");
return value.gsub('\n', '<br />');
});
Handlebars.registerHelper('json_encode', function(value, block) {
return JSON.stringify(value);
return JSON.stringify(value);
});
Handlebars.registerHelper('json_decode', function(value, block) {
return JSON.parse(value);
return JSON.parse(value);
});
Handlebars.registerHelper('url', function(value, block) {
var url = window.location.protocol + "//" + window.location.host + window.location.pathname;
var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
return url + value;
return url + value;
});
Handlebars.registerHelper('emailFromMailto', function(value) {
var mailtoMatchingRegex = /^mailto\:/i;
if (typeof value === 'string' && value.match(mailtoMatchingRegex)) {
return value.replace(mailtoMatchingRegex, '');
} else {
return value;
}
var mailtoMatchingRegex = /^mailto\:/i;
if (typeof value === 'string' && value.match(mailtoMatchingRegex)) {
return value.replace(mailtoMatchingRegex, '');
} else {
return value;
}
});
Handlebars.registerHelper('lookup', function(obj, field, options) {
return obj && obj[field];
return obj && obj[field];
});
Handlebars.registerHelper('rsa_key', function(value, block) {
// extract all lines into an array
if(value === undefined) return '';
if(value === undefined) return '';
var lines = value.trim().split("\n");
var lines = value.trim().split('\n');
// remove header & footer
lines.shift();
lines.pop();
lines.shift();
lines.pop();
// return concatenated lines
return lines.join('');
return lines.join('');
});
Handlebars.registerHelper('trim', function(value, block) {
if(value === null || value === undefined) return '';
return value.trim();
if(value === null || value === undefined) return '';
return value.trim();
});
/**
@ -125,19 +125,20 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
* @return {String} The truncated string.
*/
Handlebars.registerHelper('ellipsis', function (str, limit, append) {
if (append === undefined) {
append = '';
}
var sanitized = str.replace(/(<([^>]+)>)/g, '');
if (sanitized.length > limit) {
return sanitized.substr(0, limit - append.length) + append;
} else {
return sanitized;
}
var strAppend = append;
if (strAppend === undefined) {
strAppend = '';
}
var sanitized = str.replace(/(<([^>]+)>)/g, '');
if (sanitized.length > limit) {
return sanitized.substr(0, limit - strAppend.length) + strAppend;
} else {
return sanitized;
}
});
Handlebars.registerHelper('getNumber', function (string) {
return parseInt(string, 10);
return parseInt(string, 10);
});
Handlebars.registerHelper('fontWithFallback', function(font) {
@ -147,10 +148,10 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
case 'Courier New': return new Handlebars.SafeString("'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace");
case 'Georgia': return new Handlebars.SafeString("Georgia, Times, 'Times New Roman', serif");
case 'Lucida': return new Handlebars.SafeString("'Lucida Sans Unicode', 'Lucida Grande', sans-serif");
case 'Tahoma': return new Handlebars.SafeString("Tahoma, Verdana, Segoe, sans-serif");
case 'Tahoma': return new Handlebars.SafeString('Tahoma, Verdana, Segoe, sans-serif');
case 'Times New Roman': return new Handlebars.SafeString("'Times New Roman', Times, Baskerville, Georgia, serif");
case 'Trebuchet MS': return new Handlebars.SafeString("'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif");
case 'Verdana': return new Handlebars.SafeString("Verdana, Geneva, sans-serif");
case 'Verdana': return new Handlebars.SafeString('Verdana, Geneva, sans-serif');
default: return font;
}
});

View File

@ -0,0 +1,22 @@
define('helpTooltip', ['mailpoet', 'react', 'react-dom', 'help-tooltip.jsx'],
function (mp, React, ReactDOM, TooltipComponent) {
'use strict';
var MailPoet = mp;
MailPoet.helpTooltip = {
show: function (domContainerNode, opts) {
ReactDOM.render(React.createElement(
TooltipComponent, {
tooltip: opts.tooltip,
tooltipId: opts.tooltipId,
place: opts.place
}
), domContainerNode);
}
};
}
);

View File

@ -0,0 +1,63 @@
import React from 'react';
import ReactTooltip from 'react-tooltip';
import ReactHtmlParser from 'react-html-parser';
function Tooltip(props) {
let tooltipId = props.tooltipId;
let tooltip = props.tooltip;
// tooltip ID must be unique, defaults to tooltip text
if(!props.tooltipId && typeof props.tooltip === 'string') {
tooltipId = props.tooltip;
}
if(typeof props.tooltip === 'string') {
tooltip = (<span
style={{
pointerEvents: 'all',
maxWidth: '400',
display: 'inline-block',
}}
>
{ReactHtmlParser(props.tooltip)}
</span>);
}
return (
<span className={props.className}>
<span
style={{
cursor: 'pointer',
}}
className="tooltip dashicons dashicons-editor-help"
data-event="click"
data-tip
data-for={tooltipId}
>
</span>
<ReactTooltip
globalEventOff="click"
multiline={true}
id={tooltipId}
efect="solid"
place={props.place}
>
{tooltip}
</ReactTooltip>
</span>
);
}
Tooltip.propTypes = {
tooltipId: React.PropTypes.string,
tooltip: React.PropTypes.node.isRequired,
place: React.PropTypes.string,
className: React.PropTypes.string,
};
Tooltip.defaultProps = {
tooltipId: undefined,
place: undefined,
className: undefined,
};
module.exports = Tooltip;

View File

@ -24,6 +24,6 @@ function KnowledgeBase() {
<a target="_blank" href="http://beta.docs.mailpoet.com/" className="button button-primary">{MailPoet.I18n.t('knowledgeBaseButton')}</a>
</div>
);
};
}
module.exports = KnowledgeBase;

View File

@ -17,10 +17,10 @@ function printData(data) {
return (<textarea
readOnly={true}
onFocus={handleFocus}
value={printableData.join("\n")}
value={printableData.join('\n')}
style={{
width: "100%",
height: "400px",
width: '100%',
height: '400px',
}}
/>);
} else {
@ -35,13 +35,13 @@ function KnowledgeBase() {
<Tabs tab="systemInfo" />
<div className="mailpoet_notice notice inline notice-success" style={{ marginTop: "1em" }}>
<div className="mailpoet_notice notice inline notice-success" style={{ marginTop: '1em' }}>
<p>{MailPoet.I18n.t('systemInfoIntro')}</p>
</div>
{printData(data)}
</div>
);
};
}
module.exports = KnowledgeBase;

View File

@ -38,9 +38,9 @@ function Tabs(props) {
{ tabLinks }
</h2>
);
};
}
Tabs.propTypes = { tab: React.PropTypes.string };
Tabs.defaultProps = { tab: "knowledgeBase" };
Tabs.defaultProps = { tab: 'knowledgeBase' };
module.exports = Tabs;

View File

@ -1,3 +0,0 @@
define([], function() {
!function(e, o, n){window.HSCW=o, window.HS=n, n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={}, t.readyQueue=[], t.config=function(e){this.userConfig=e}, t.ready=function(e){this.readyQueue.push(e)}, o.config={docs:{enabled:!0, baseUrl:"//mailpoet3.helpscoutdocs.com/"}, contact:{enabled:!0, formId:"aa21ca80-a4f5-11e6-91aa-0a5fecc78a4d"}};var r=e.getElementsByTagName("script")[0], c=e.createElement("script");c.type="text/javascript", c.async=!0, c.src="https://djtflbt20bdde.cloudfront.net/", r.parentNode.insertBefore(c, r)}(document, window.HSCW||{}, window.HS||{});
});

View File

@ -2,22 +2,24 @@ define('i18n',
[
'mailpoet'
], function(
MailPoet
mp
) {
'use strict';
'use strict';
var translations = {};
var MailPoet = mp;
MailPoet.I18n = {
add: function(key, value) {
translations[key] = value;
},
t: function(key) {
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace("%$1s", key);
},
all: function() {
return translations;
}
};
var translations = {};
});
MailPoet.I18n = {
add: function(key, value) {
translations[key] = value;
},
t: function(key) {
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
},
all: function() {
return translations;
}
};
});

View File

@ -1,5 +1,7 @@
define('iframe', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
define('iframe', ['mailpoet'], function(mp) {
'use strict';
var MailPoet = mp;
MailPoet.Iframe = {
marginY: 20,
autoSize: function(iframe) {
@ -10,12 +12,13 @@ define('iframe', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
iframe.contentWindow.document.body.scrollHeight
);
},
setSize: function(iframe, i) {
setSize: function(sizeIframe, i) {
var iframe = sizeIframe;
if(!iframe) return;
iframe.style.height = (
parseInt(i) + this.marginY
) + "px";
parseInt(i, 10) + this.marginY
) + 'px';
}
};

View File

@ -3,8 +3,9 @@ define(
'jquery'
],
function(
$
jQuery
) {
var $ = jQuery;
// Combination of jQuery.deparam and jQuery.serializeObject by Ben Alman.
/*!
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
@ -24,7 +25,7 @@ define(
*/
$.fn.serializeObject = function(coerce) {
var obj = {},
coerce_types = { 'true': !0, 'false': !1, 'null': null };
coerce_types = { true: !0, false: !1, null: null };
// Iterate over all name=value pairs.
$.each( this.serializeArray(), function(j, v){
@ -74,9 +75,10 @@ define(
// * Rinse & repeat.
for ( ; i <= keys_last; i++ ) {
key = keys[i] === '' ? cur.length : keys[i];
cur = cur[key] = i < keys_last
cur[key] = i < keys_last
? cur[key] || ( keys[i+1] && isNaN( keys[i+1] ) ? {} : [] )
: val;
cur = cur[key];
}
} else {

View File

@ -56,7 +56,7 @@ define([
const promise = this.props.onBulkAction(selected_ids, data);
if (promise !== false) {
promise.then(onSuccess);
};
}
}
this.setState({
@ -112,7 +112,7 @@ define([
defaultValue={MailPoet.I18n.t('apply')}
className="button action" />
{ this.state.extra }
{ this.state.extra }
</div>
);
},

View File

@ -56,14 +56,14 @@ define([
key={ `filter-${i}` }
name={ filter }
>
{ filters[filter].map((option, j) => {
return (
<option
value={ option.value }
key={ 'filter-option-' + j }
{ filters[filter].map((option, j) => {
return (
<option
value={ option.value }
key={ 'filter-option-' + j }
>{ option.label }</option>
);
}) }
);
}) }
</select>
);
});

View File

@ -11,26 +11,26 @@ define(['react', 'classnames'], (React, classNames) => {
}
const classes = classNames(
{ 'current' : (group.name === this.props.group) }
{ current : (group.name === this.props.group) }
);
return (
<li key={index}>
{(index > 0) ? ' |' : ''}
<a
href="javascript:;"
className={classes}
onClick={this.handleSelect.bind(this, group.name)} >
{group.label} <span className="count">({ group.count.toLocaleString() })</span>
</a>
</li>
<li key={index}>
{(index > 0) ? ' |' : ''}
<a
href="javascript:;"
className={classes}
onClick={this.handleSelect.bind(this, group.name)} >
{group.label} <span className="count">({ group.count.toLocaleString() })</span>
</a>
</li>
);
});
return (
<ul className="subsubsub">
{ groups }
</ul>
<ul className="subsubsub">
{ groups }
</ul>
);
},
});

View File

@ -10,8 +10,9 @@ const ListingHeader = React.createClass({
},
render: function () {
const columns = this.props.columns.map((column, index) => {
column.is_primary = (index === 0);
column.sorted = (this.props.sort_by === column.name)
const renderColumn = column;
renderColumn.is_primary = (index === 0);
renderColumn.sorted = (this.props.sort_by === column.name)
? this.props.sort_order
: 'desc';
return (
@ -19,7 +20,7 @@ const ListingHeader = React.createClass({
onSort={this.props.onSort}
sort_by={this.props.sort_by}
key={ 'column-' + index }
column={column} />
column={renderColumn} />
);
});
@ -61,9 +62,9 @@ const ListingColumn = React.createClass({
const classes = classNames(
'manage-column',
{ 'column-primary': this.props.column.is_primary },
{ 'sortable': this.props.column.sortable },
{ sortable: this.props.column.sortable },
this.props.column.sorted,
{ 'sorted': (this.props.sort_by === this.props.column.name) }
{ sorted: (this.props.sort_by === this.props.column.name) }
);
let label;

View File

@ -226,7 +226,7 @@ const ListingItems = React.createClass({
} else {
const select_all_classes = classNames(
'mailpoet_select_all',
{ 'mailpoet_hidden': (
{ mailpoet_hidden: (
this.props.selection === false
|| (this.props.count <= this.props.limit)
),
@ -260,8 +260,9 @@ const ListingItems = React.createClass({
</tr>
{this.props.items.map((item, index) => {
item.id = parseInt(item.id, 10);
item.selected = (this.props.selected_ids.indexOf(item.id) !== -1);
const renderItem = item;
renderItem.id = parseInt(item.id, 10);
renderItem.selected = (this.props.selected_ids.indexOf(renderItem.id) !== -1);
return (
<ListingItem
@ -276,8 +277,8 @@ const ListingItems = React.createClass({
is_selectable={ this.props.is_selectable }
item_actions={ this.props.item_actions }
group={ this.props.group }
key={ `item-${item.id}-${index}` }
item={ item } />
key={ `item-${renderItem.id}-${index}` }
item={ renderItem } />
);
})}
</tbody>
@ -418,16 +419,17 @@ const Listing = React.createClass({
}
},
setBaseUrlParams: function (base_url) {
if (base_url.indexOf(':') !== -1) {
let ret = base_url;
if (ret.indexOf(':') !== -1) {
const params = this.getParams();
Object.keys(params).map((key) => {
if (base_url.indexOf(':'+key) !== -1) {
base_url = base_url.replace(':'+key, params[key]);
if (ret.indexOf(':'+key) !== -1) {
ret = ret.replace(':'+key, params[key]);
}
});
}
return base_url;
return ret;
},
componentDidMount: function () {
if (this.isMounted()) {
@ -781,7 +783,7 @@ const Listing = React.createClass({
'widefat',
'fixed',
'striped',
{ 'mailpoet_listing_loading': this.state.loading }
{ mailpoet_listing_loading: this.state.loading }
);
// search

View File

@ -24,7 +24,7 @@ define([
<form name="search" onSubmit={this.handleSearch}>
<p className="search-box">
<label htmlFor="search_input" className="screen-reader-text">
{MailPoet.I18n.t('searchLabel')}
{MailPoet.I18n.t('searchLabel')}
</label>
<input
type="search"

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
define('mp2migrator', ['mailpoet', 'jquery'], function(mp, jQuery) {
'use strict';
var MailPoet = mp;
MailPoet.MP2Migrator = {
fatal_error: '',
@ -10,7 +12,7 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
clearTimeout(MailPoet.MP2Migrator.displayLogs_timeout);
clearTimeout(MailPoet.MP2Migrator.updateProgressbar_timeout);
clearTimeout(MailPoet.MP2Migrator.update_wordpress_info_timeout);
setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000)
setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000);
},
stopLogger: function () {
@ -24,11 +26,12 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
displayLogs: function () {
jQuery.ajax({
url: mailpoet_mp2_migrator.log_file_url,
url: window.mailpoet_mp2_migrator.log_file_url,
cache: false
}).done(function (result) {
jQuery("#logger").html('');
result.split("\n").forEach(function (row) {
jQuery('#logger').html('');
result.split('\n').forEach(function (resultRow) {
var row = resultRow;
if(row.substr(0, 7) === '[ERROR]' || row.substr(0, 9) === '[WARNING]' || row === MailPoet.I18n.t('import_stopped_by_user')) {
row = '<span class="error_msg">' + row + '</span>'; // Mark the errors in red
}
@ -37,10 +40,10 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
jQuery('#import-actions').hide();
jQuery('#upgrade-completed').show();
}
jQuery("#logger").append(row + "<br />\n");
jQuery('#logger').append(row + '<br />\n');
});
jQuery("#logger").append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + "<br />\n");
jQuery('#logger').append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + '<br />\n');
}).always(function () {
if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);
@ -50,7 +53,7 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
updateProgressbar: function () {
jQuery.ajax({
url: mailpoet_mp2_migrator.progress_url,
url: window.mailpoet_mp2_migrator.progress_url,
cache: false,
dataType: 'json'
}).always(function (result) {

View File

@ -1,12 +1,13 @@
define([
'backbone',
'backbone.marionette',
'backbone.radio',
'jquery',
'underscore',
'handlebars',
'handlebars_helpers'
], function(Backbone, Marionette, Radio, jQuery, _, Handlebars) {
'backbone',
'backbone.marionette',
'backbone.radio',
'jquery',
'underscore',
'handlebars',
'handlebars_helpers'
], function(Backbone, Marionette, BackboneRadio, jQuery, _, Handlebars) {
var Radio = BackboneRadio;
var AppView = Marionette.View.extend({
el: '#mailpoet_editor',
@ -28,7 +29,9 @@ define([
},
getChannel: function(channel) {
if (channel === undefined) channel = 'global';
if (channel === undefined) {
return Radio.channel('global');
}
return Radio.channel(channel);
}
});

View File

@ -5,9 +5,9 @@
* For more check: http://marionettejs.com/docs/marionette.behaviors.html#behaviorslookup
*/
define([
'backbone.marionette'
], function(Marionette) {
'backbone.marionette'
], function(BackboneMarionette) {
var Marionette = BackboneMarionette;
var BehaviorsLookup = {};
Marionette.Behaviors.behaviorsLookup = function() {
return BehaviorsLookup;

View File

@ -4,23 +4,44 @@
* Adds a color picker integration with the view
*/
define([
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup',
'mailpoet',
'spectrum'
], function(Marionette, BehaviorsLookup, MailPoet, Spectrum) {
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup',
'mailpoet',
'spectrum'
], function(Marionette, BehaviorsLookup, MailPoet, Spectrum) {
var BL = BehaviorsLookup;
BehaviorsLookup.ColorPickerBehavior = Marionette.Behavior.extend({
BL.ColorPickerBehavior = Marionette.Behavior.extend({
onRender: function() {
this.view.$('.mailpoet_color').spectrum({
clickoutFiresChange: true,
showInput: true,
showInitial: true,
preferredFormat: "hex6",
allowEmpty: true,
chooseText: MailPoet.I18n.t('selectColor'),
cancelText: MailPoet.I18n.t('cancelColorSelection')
});
var that = this,
preferredFormat = 'hex6';
this.view.$('.mailpoet_color').each(function () {
var $input = that.view.$(this);
var updateColorInput = function(color) {
if(color && color.getAlpha() > 0) {
$input.val(color.toString(preferredFormat));
} else {
$input.val('');
}
$input.trigger('change');
};
$input.spectrum({
clickoutFiresChange: true,
showInput: true,
showInitial: true,
showPalette: true,
showSelectionPalette: true,
palette: [],
localStorageKey: 'newsletter_editor.spectrum.palette',
preferredFormat: preferredFormat,
allowEmpty: true,
chooseText: MailPoet.I18n.t('selectColor'),
cancelText: MailPoet.I18n.t('cancelColorSelection'),
change: updateColorInput,
move: updateColorInput,
hide: updateColorInput
});
});
}
});
});

View File

@ -1,3 +1,4 @@
/**
* ContainerDropZoneBehavior
*
@ -6,12 +7,13 @@
* accept droppables
*/
define([
'backbone.marionette',
'underscore',
'jquery',
'newsletter_editor/behaviors/BehaviorsLookup',
'interact'
], function(Marionette, _, jQuery, BehaviorsLookup, interact) {
'backbone.marionette',
'underscore',
'jquery',
'newsletter_editor/behaviors/BehaviorsLookup',
'interact'
], function(Marionette, _, jQuery, BL, interact) {
var BehaviorsLookup = BL;
BehaviorsLookup.ContainerDropZoneBehavior = Marionette.Behavior.extend({
defaults: {
@ -20,7 +22,7 @@ define([
onRender: function() {
var dragAndDropDisabled = _.isObject(this.view.options.renderOptions) && this.view.options.renderOptions.disableDragAndDrop === true;
if (!dragAndDropDisabled) {
this.addDropZone();
this.addDropZone();
}
},
addDropZone: function(_event) {
@ -194,8 +196,9 @@ define([
if (view.model.get('orientation') === 'horizontal' && droppableModel.get('type') !== 'container') {
// Regular blocks always need to be inserted into columns - vertical containers
tempCollection = new (EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical'
tempCollection = new (window.EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical'
});
tempCollection.get('blocks').add(droppableModel);
viewCollection.add(tempCollection, {at: index});
@ -209,27 +212,27 @@ define([
// and inserting dropModel into that
var tempModel = viewCollection.at(dropPosition.index);
tempCollection = new (EditorApplication.getBlockTypeModel('container'))({
orientation: (view.model.get('orientation') === 'vertical') ? 'horizontal' : 'vertical'
tempCollection = new (window.EditorApplication.getBlockTypeModel('container'))({
orientation: (view.model.get('orientation') === 'vertical') ? 'horizontal' : 'vertical'
});
viewCollection.remove(tempModel);
if (tempCollection.get('orientation') === 'horizontal') {
if (dropPosition.position === 'before') {
tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({
tempCollection2 = new (window.EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical'
});
tempCollection2.get('blocks').add(droppableModel);
tempCollection.get('blocks').add(tempCollection2);
}
tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({
tempCollection2 = new (window.EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical'
});
tempCollection2.get('blocks').add(tempModel);
tempCollection.get('blocks').add(tempCollection2);
if (dropPosition.position === 'after') {
tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({
tempCollection2 = new (window.EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical'
});
tempCollection2.get('blocks').add(droppableModel);
@ -268,7 +271,7 @@ define([
// 2. Remove visual markings of drop position visualization
this.view.$('.mailpoet_drop_marker').remove();
},
getDropPosition: function(eventX, eventY, unsafe) {
getDropPosition: function(eventX, eventY, is_unsafe) {
var SPECIAL_AREA_INSERTION_WIDTH = 0.00, // Disable special insertion. Default: 0.3
element = this.view.$el,
@ -290,7 +293,7 @@ define([
insertionType, index, position, indexAndPosition;
unsafe = !!unsafe;
var unsafe = !!is_unsafe;
if (this.getCollection().length === 0) {
return {
@ -376,14 +379,14 @@ define([
if (eventOffset <= closeOffset + elementDimension / 2) {
// First half of the element
return {
index: index,
position: 'before'
index: index,
position: 'before'
};
} else {
// Second half of the element
return {
index: index,
position: 'after'
index: index,
position: 'after'
};
}
},

View File

@ -5,14 +5,15 @@
* Part of the drag&drop behavior.
*/
define([
'backbone.marionette',
'underscore',
'jquery',
'newsletter_editor/behaviors/BehaviorsLookup',
'interact'
], function(Marionette, _, jQuery, BehaviorsLookup, interact) {
'backbone.marionette',
'underscore',
'jquery',
'newsletter_editor/behaviors/BehaviorsLookup',
'interact'
], function(Marionette, _, jQuery, BehaviorsLookup, interact) {
var BL = BehaviorsLookup;
BehaviorsLookup.DraggableBehavior = Marionette.Behavior.extend({
BL.DraggableBehavior = Marionette.Behavior.extend({
defaults: {
cloneOriginal: false,
hideOriginal: false,
@ -32,13 +33,13 @@ define([
},
onRender: function() {
var that = this,
interactable;
interactable;
// Give instances more control over whether Draggable should be applied
if (!this.options.testAttachToInstance(this.view.model, this.view)) return;
interactable = interact(this.$el.get(0), {
ignoreFrom: this.options.ignoreSelector
ignoreFrom: this.options.ignoreSelector
}).draggable({
// allow dragging of multple elements at the same time
max: Infinity,
@ -46,13 +47,14 @@ define([
// Scroll when dragging near edges of a window
autoScroll: true,
onstart: function(event) {
onstart: function(startEvent) {
var event = startEvent;
if (that.options.cloneOriginal === true) {
// Use substitution instead of a clone
var tempClone = (_.isFunction(that.options.onDragSubstituteBy)) ? that.options.onDragSubstituteBy(that) : undefined,
// Or use a clone
clone = tempClone ? tempClone : event.target.cloneNode(true),
clone = tempClone || event.target.cloneNode(true),
$original = jQuery(event.target),
$clone = jQuery(clone),
@ -89,9 +91,8 @@ define([
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
target.style.transform = 'translate(' + x + 'px, ' + y + 'px)';
target.style.webkitTransform = target.style.transform;
// update the posiion attributes
target.setAttribute('data-x', x);
@ -99,7 +100,8 @@ define([
},
onend: function (event) {
var target = event.target;
target.style.webkitTransform = target.style.transform = '';
target.style.transform = '';
target.style.webkitTransform = target.style.transform;
target.removeAttribute('data-x');
target.removeAttribute('data-y');
jQuery(event.interaction.element).addClass('mailpoet_droppable_active');
@ -129,7 +131,8 @@ define([
} else {
interactable.getDropModel = this.view.getDropFunc();
}
interactable.onDrop = function(options) {
interactable.onDrop = function(opts) {
var options = opts;
if (_.isObject(options)) {
// Inject Draggable behavior if possible
options.dragBehavior = that;

View File

@ -0,0 +1,26 @@
/**
* Highlight Container Behavior
*
* Highlights a container block when hovering over its tools
*/
define([
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, BehaviorsLookup) {
var BL = BehaviorsLookup;
BL.HighlightContainerBehavior = Marionette.Behavior.extend({
events: {
'mouseenter @ui.tools': 'enableHighlight',
'mouseleave @ui.tools': 'disableHighlight'
},
enableHighlight: function() {
this.$el.addClass('mailpoet_highlight');
},
disableHighlight: function() {
if (!this.view._isBeingEdited) {
this.$el.removeClass('mailpoet_highlight');
}
}
});
});

View File

@ -4,19 +4,22 @@
* Highlights a block that is being edited
*/
define([
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, BehaviorsLookup) {
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.HighlightEditingBehavior = Marionette.Behavior.extend({
BL.HighlightEditingBehavior = Marionette.Behavior.extend({
modelEvents: {
'startEditing': 'enableHighlight',
'stopEditing': 'disableHighlight'
startEditing: 'enableHighlight',
stopEditing: 'disableHighlight'
},
enableHighlight: function() {
this.view._isBeingEdited = true;
this.$el.addClass('mailpoet_highlight');
},
disableHighlight: function() {
this.view._isBeingEdited = false;
this.$el.removeClass('mailpoet_highlight');
}
});

View File

@ -4,12 +4,13 @@
* Allows resizing elements within a block
*/
define([
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup',
'interact'
], function(Marionette, BehaviorsLookup, interact) {
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup',
'interact'
], function(Marionette, BehaviorsLookup, interact) {
var BL = BehaviorsLookup;
BehaviorsLookup.ResizableBehavior = Marionette.Behavior.extend({
BL.ResizableBehavior = Marionette.Behavior.extend({
defaults: {
elementSelector: null,
resizeHandleSelector: true, // true will use edges of the element itself
@ -18,8 +19,8 @@ define([
modelField: 'styles.block.height'
},
events: {
"mouseenter": 'showResizeHandle',
"mouseleave": 'hideResizeHandle'
mouseenter: 'showResizeHandle',
mouseleave: 'hideResizeHandle'
},
onRender: function() {
this.attachResize();
@ -30,7 +31,7 @@ define([
},
attachResize: function() {
var domElement = (this.options.elementSelector === null) ? this.view.$el.get(0) : this.view.$(this.options.elementSelector).get(0),
that = this;
that = this;
interact(domElement).resizable({
//axis: 'y',
edges: {
@ -49,7 +50,8 @@ define([
if (newLength < that.options.minLength) newLength = that.options.minLength;
that.view.model.set(that.options.modelField, newLength + 'px');
}).on('resizeend', function(event) {
})
.on('resizeend', function(event) {
that.isBeingResized = null;
that.$el.removeClass('mailpoet_resize_active');
});

View File

@ -4,12 +4,13 @@
* Opens up settings of a BlockView if contents are clicked upon
*/
define([
'backbone.marionette',
'jquery',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, jQuery, BehaviorsLookup) {
'backbone.marionette',
'jquery',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, jQuery, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.ShowSettingsBehavior = Marionette.Behavior.extend({
BL.ShowSettingsBehavior = Marionette.Behavior.extend({
defaults: {
ignoreFrom: '' // selector
},

View File

@ -4,18 +4,19 @@
* Allows sorting elements within a collection
*/
define([
'backbone.marionette',
'underscore',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, _, BehaviorsLookup) {
'backbone.marionette',
'underscore',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, _, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.SortableBehavior = Marionette.Behavior.extend({
BL.SortableBehavior = Marionette.Behavior.extend({
onRender: function() {
var collection = this.view.collection;
if (_.isFunction(this.$el.sortable)) {
this.$el.sortable({
cursor: "move",
cursor: 'move',
start: function(event, ui) {
ui.item.data('previousIndex', ui.item.index());
},

View File

@ -4,20 +4,21 @@
* Adds TinyMCE text editing capabilities to a view
*/
define([
'backbone.marionette',
'underscore',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, _, BehaviorsLookup) {
'backbone.marionette',
'underscore',
'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, _, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.TextEditorBehavior = Marionette.Behavior.extend({
BL.TextEditorBehavior = Marionette.Behavior.extend({
defaults: {
selector: '.mailpoet_content',
toolbar1: "bold italic link unlink forecolor mailpoet_shortcodes",
toolbar2: "",
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
invalidElements: "script",
toolbar1: 'bold italic link unlink forecolor mailpoet_shortcodes',
toolbar2: '',
validElements: 'p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br',
invalidElements: 'script',
blockFormats: 'Paragraph=p',
plugins: "link textcolor colorpicker mailpoet_shortcodes",
plugins: 'link textcolor colorpicker mailpoet_shortcodes',
configurationFilter: function(originalConfig) { return originalConfig; }
},
onDomRefresh: function() {
@ -33,6 +34,8 @@ define([
toolbar1: this.options.toolbar1,
toolbar2: this.options.toolbar2,
browser_spellcheck: true,
valid_elements: this.options.validElements,
invalid_elements: this.options.invalidElements,
block_formats: this.options.blockFormats,
@ -62,7 +65,7 @@ define([
editor.focus();
if (that._isActivationClick) {
editor.selection.setRng(
tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc())
window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc())
);
that._isActivationClick = false;
}
@ -70,7 +73,7 @@ define([
editor.on('focus', function(e) {
that.view.triggerMethod('text:editor:focus');
that._isActivationClick = true;
that._isActivationClick = true;
});
editor.on('blur', function(e) {

View File

@ -7,31 +7,31 @@
* block settings view.
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'newsletter_editor/blocks/button',
'newsletter_editor/blocks/divider',
'newsletter_editor/components/communication',
'mailpoet',
'backbone.supermodel',
'underscore',
'jquery'
], function(
App,
BaseBlock,
ButtonBlock,
DividerBlock,
CommunicationComponent,
MailPoet,
SuperModel,
_,
jQuery
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'newsletter_editor/blocks/button',
'newsletter_editor/blocks/divider',
'newsletter_editor/components/communication',
'mailpoet',
'backbone.supermodel',
'underscore',
'jquery'
], function(
App,
BaseBlock,
ButtonBlock,
DividerBlock,
CommunicationComponent,
MailPoet,
SuperModel,
_,
jQuery
) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.ALCSupervisor = SuperModel.extend({
initialize: function() {
@ -61,7 +61,7 @@ define([
_.zip(models, renderedBlocks),
function(args) {
var model = args[0],
contents = args[1];
contents = args[1];
model.trigger('refreshPosts', contents);
}
);
@ -128,14 +128,14 @@ define([
});
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block',
initialize: function() {
function replaceButtonStylesHandler(data) {
this.model.set({"readMoreButton": data});
this.model.set({readMoreButton: data});
}
App.getChannel().on("replaceAllButtonStyles", replaceButtonStylesHandler.bind(this));
App.getChannel().on('replaceAllButtonStyles', replaceButtonStylesHandler.bind(this));
},
getTemplate: function() { return templates.automatedLatestContentBlock; },
getTemplate: function() { return window.templates.automatedLatestContentBlock; },
regions: {
toolsRegion: '.mailpoet_tools',
postsRegion: '.mailpoet_automated_latest_content_block_posts'
@ -143,7 +143,7 @@ define([
modelEvents: _.extend(
_.omit(base.BlockView.prototype.modelEvents, 'change'),
{
'postsChanged': 'render'
postsChanged: 'render'
}),
events: _.extend(base.BlockView.prototype.events, {
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
@ -168,31 +168,31 @@ define([
// Sidebar view container
Module.AutomatedLatestContentBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.automatedLatestContentBlockSettings; },
getTemplate: function() { return window.templates.automatedLatestContentBlockSettings; },
events: function() {
return {
"click .mailpoet_automated_latest_content_hide_display_options": 'toggleDisplayOptions',
"click .mailpoet_automated_latest_content_show_display_options": 'toggleDisplayOptions',
"click .mailpoet_automated_latest_content_select_button": 'showButtonSettings',
"click .mailpoet_automated_latest_content_select_divider": 'showDividerSettings',
"change .mailpoet_automated_latest_content_read_more_type": 'changeReadMoreType',
"change .mailpoet_automated_latest_content_display_type": 'changeDisplayType',
"change .mailpoet_automated_latest_content_title_format": 'changeTitleFormat',
"change .mailpoet_automated_latest_content_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
"change .mailpoet_automated_latest_content_show_divider": _.partial(this.changeBoolField, 'showDivider'),
"input .mailpoet_automated_latest_content_show_amount": _.partial(this.changeField, "amount"),
"change .mailpoet_automated_latest_content_content_type": _.partial(this.changeField, "contentType"),
"change .mailpoet_automated_latest_content_include_or_exclude": _.partial(this.changeField, "inclusionType"),
"change .mailpoet_automated_latest_content_title_alignment": _.partial(this.changeField, "titleAlignment"),
"change .mailpoet_automated_latest_content_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
"change .mailpoet_automated_latest_content_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
"change .mailpoet_automated_latest_content_show_author": _.partial(this.changeField, "showAuthor"),
"input .mailpoet_automated_latest_content_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
"change .mailpoet_automated_latest_content_show_categories": _.partial(this.changeField, "showCategories"),
"input .mailpoet_automated_latest_content_categories": _.partial(this.changeField, "categoriesPrecededBy"),
"input .mailpoet_automated_latest_content_read_more_text": _.partial(this.changeField, "readMoreText"),
"change .mailpoet_automated_latest_content_sort_by": _.partial(this.changeField, "sortBy"),
"click .mailpoet_done_editing": "close"
'click .mailpoet_automated_latest_content_hide_display_options': 'toggleDisplayOptions',
'click .mailpoet_automated_latest_content_show_display_options': 'toggleDisplayOptions',
'click .mailpoet_automated_latest_content_select_button': 'showButtonSettings',
'click .mailpoet_automated_latest_content_select_divider': 'showDividerSettings',
'change .mailpoet_automated_latest_content_read_more_type': 'changeReadMoreType',
'change .mailpoet_automated_latest_content_display_type': 'changeDisplayType',
'change .mailpoet_automated_latest_content_title_format': 'changeTitleFormat',
'change .mailpoet_automated_latest_content_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'),
'change .mailpoet_automated_latest_content_show_divider': _.partial(this.changeBoolField, 'showDivider'),
'input .mailpoet_automated_latest_content_show_amount': _.partial(this.changeField, 'amount'),
'change .mailpoet_automated_latest_content_content_type': _.partial(this.changeField, 'contentType'),
'change .mailpoet_automated_latest_content_include_or_exclude': _.partial(this.changeField, 'inclusionType'),
'change .mailpoet_automated_latest_content_title_alignment': _.partial(this.changeField, 'titleAlignment'),
'change .mailpoet_automated_latest_content_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'),
'change .mailpoet_automated_latest_content_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'),
'change .mailpoet_automated_latest_content_show_author': _.partial(this.changeField, 'showAuthor'),
'input .mailpoet_automated_latest_content_author_preceded_by': _.partial(this.changeField, 'authorPrecededBy'),
'change .mailpoet_automated_latest_content_show_categories': _.partial(this.changeField, 'showCategories'),
'input .mailpoet_automated_latest_content_categories': _.partial(this.changeField, 'categoriesPrecededBy'),
'input .mailpoet_automated_latest_content_read_more_text': _.partial(this.changeField, 'readMoreText'),
'change .mailpoet_automated_latest_content_sort_by': _.partial(this.changeField, 'sortBy'),
'click .mailpoet_done_editing': 'close'
};
},
onRender: function() {
@ -350,7 +350,7 @@ define([
},
_updateContentTypes: function(postTypes) {
var select = this.$('.mailpoet_automated_latest_content_content_type'),
selectedValue = this.model.get('contentType');
selectedValue = this.model.get('contentType');
select.find('option').remove();
_.each(postTypes, function(type) {
@ -364,7 +364,7 @@ define([
});
Module.AutomatedLatestContentWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.automatedLatestContentInsertion; },
getTemplate: function() { return window.templates.automatedLatestContentInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
@ -392,8 +392,9 @@ define([
});
App.on('start', function(App, options) {
App._ALCSupervisor = new Module.ALCSupervisor();
App._ALCSupervisor.refresh();
var Application = App;
Application._ALCSupervisor = new Module.ALCSupervisor();
Application._ALCSupervisor.refresh();
});
return Module;

View File

@ -5,19 +5,19 @@
* BlockToolsView, BlockSettingsView and BlockWidgetView are optional.
*/
define([
'newsletter_editor/App',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery',
'mailpoet',
'modal'
], function(App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
'newsletter_editor/App',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery',
'mailpoet',
'modal'
], function(App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
"use strict";
'use strict';
var Module = {},
AugmentedView = Marionette.View.extend({});
AugmentedView = Marionette.View.extend({});
Module.BlockModel = SuperModel.extend({
stale: [], // Attributes to be removed upon saving
@ -50,13 +50,13 @@ define([
toolsRegion: '> .mailpoet_tools'
},
modelEvents: {
'change': 'render',
'delete': 'deleteBlock',
'duplicate': 'duplicateBlock'
change: 'render',
delete: 'deleteBlock',
duplicate: 'duplicateBlock'
},
events: {
"mouseenter": "showTools",
"mouseleave": "hideTools"
mouseenter: 'showTools',
mouseleave: 'hideTools'
},
behaviors: {
DraggableBehavior: {
@ -178,13 +178,13 @@ define([
});
Module.BlockToolsView = AugmentedView.extend({
getTemplate: function() { return templates.genericBlockTools; },
getTemplate: function() { return window.templates.genericBlockTools; },
events: {
"click .mailpoet_edit_block": "changeSettings",
"click .mailpoet_delete_block_activate": "showDeletionConfirmation",
"click .mailpoet_delete_block_cancel": "hideDeletionConfirmation",
"click .mailpoet_delete_block_confirm": "deleteBlock",
"click .mailpoet_duplicate_block": "duplicateBlock"
'click .mailpoet_edit_block': 'changeSettings',
'click .mailpoet_delete_block_activate': 'showDeletionConfirmation',
'click .mailpoet_delete_block_cancel': 'hideDeletionConfirmation',
'click .mailpoet_delete_block_confirm': 'deleteBlock',
'click .mailpoet_duplicate_block': 'duplicateBlock'
},
// Markers of whether these particular tools will be used for this instance
tools: {
@ -194,8 +194,8 @@ define([
move: true
},
getSettingsView: function() { return Module.BlockSettingsView; },
initialize: function(options) {
options = options || {};
initialize: function(opts) {
var options = opts || {};
if (!_.isUndefined(options.tools)) {
// Make a new block specific tool config object
this.tools = jQuery.extend({}, this.tools, options.tools || {});
@ -275,7 +275,7 @@ define([
this.model.set(field, jQuery(event.target).val() + suffix);
},
changeBoolField: function(field, event) {
this.model.set(field, (jQuery(event.target).val() === 'true') ? true : false);
this.model.set(field, (jQuery(event.target).val() === 'true'));
},
changeBoolCheckboxField: function(field, event) {
this.model.set(field, (!!jQuery(event.target).prop('checked')));
@ -298,7 +298,7 @@ define([
behaviors: {
DraggableBehavior: {
drop: function() {
throw "Unsupported operation";
throw 'Unsupported operation';
}
}
}

View File

@ -2,17 +2,17 @@
* Button content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'mailpoet',
'underscore',
'jquery'
], function(App, BaseBlock, MailPoet, _, jQuery) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'mailpoet',
'underscore',
'jquery'
], function(App, BaseBlock, MailPoet, _, jQuery) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.ButtonBlockModel = base.BlockModel.extend({
defaults: function() {
@ -41,8 +41,8 @@ define([
});
Module.ButtonBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_button_block mailpoet_droppable_block",
getTemplate: function() { return templates.buttonBlock; },
className: 'mailpoet_block mailpoet_button_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.buttonBlock; },
onDragSubstituteBy: function() { return Module.ButtonWidgetView; },
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ShowSettingsBehavior: {}
@ -65,37 +65,37 @@ define([
});
Module.ButtonBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.buttonBlockSettings; },
getTemplate: function() { return window.templates.buttonBlockSettings; },
events: function() {
return {
"input .mailpoet_field_button_text": _.partial(this.changeField, "text"),
"input .mailpoet_field_button_url": _.partial(this.changeField, "url"),
"change .mailpoet_field_button_alignment": _.partial(this.changeField, "styles.block.textAlign"),
"change .mailpoet_field_button_font_color": _.partial(this.changeColorField, "styles.block.fontColor"),
"change .mailpoet_field_button_font_family": _.partial(this.changeField, "styles.block.fontFamily"),
"change .mailpoet_field_button_font_size": _.partial(this.changeField, "styles.block.fontSize"),
"change .mailpoet_field_button_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_button_border_color": _.partial(this.changeColorField, "styles.block.borderColor"),
"change .mailpoet_field_button_font_weight": "changeFontWeight",
'input .mailpoet_field_button_text': _.partial(this.changeField, 'text'),
'input .mailpoet_field_button_url': _.partial(this.changeField, 'url'),
'change .mailpoet_field_button_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
'change .mailpoet_field_button_font_color': _.partial(this.changeColorField, 'styles.block.fontColor'),
'change .mailpoet_field_button_font_family': _.partial(this.changeField, 'styles.block.fontFamily'),
'change .mailpoet_field_button_font_size': _.partial(this.changeField, 'styles.block.fontSize'),
'change .mailpoet_field_button_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_button_border_color': _.partial(this.changeColorField, 'styles.block.borderColor'),
'change .mailpoet_field_button_font_weight': 'changeFontWeight',
"input .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"change .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"input .mailpoet_field_button_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
'input .mailpoet_field_button_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'change .mailpoet_field_button_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'input .mailpoet_field_button_border_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
"input .mailpoet_field_button_border_radius": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
"change .mailpoet_field_button_border_radius": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
"input .mailpoet_field_button_border_radius_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
'input .mailpoet_field_button_border_radius': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, 'styles.block.borderRadius').bind(this)),
'change .mailpoet_field_button_border_radius': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, 'styles.block.borderRadius').bind(this)),
'input .mailpoet_field_button_border_radius_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, 'styles.block.borderRadius').bind(this)),
"input .mailpoet_field_button_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, "styles.block.width").bind(this)),
"change .mailpoet_field_button_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, "styles.block.width").bind(this)),
"input .mailpoet_field_button_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, "styles.block.width").bind(this)),
'input .mailpoet_field_button_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, 'styles.block.width').bind(this)),
'change .mailpoet_field_button_width': _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, 'styles.block.width').bind(this)),
'input .mailpoet_field_button_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, 'styles.block.width').bind(this)),
"input .mailpoet_field_button_line_height": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
"change .mailpoet_field_button_line_height": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
"input .mailpoet_field_button_line_height_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
'input .mailpoet_field_button_line_height': _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, 'styles.block.lineHeight').bind(this)),
'change .mailpoet_field_button_line_height': _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, 'styles.block.lineHeight').bind(this)),
'input .mailpoet_field_button_line_height_input': _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, 'styles.block.lineHeight').bind(this)),
"click .mailpoet_field_button_replace_all_styles": "applyToAll",
"click .mailpoet_done_editing": "close"
'click .mailpoet_field_button_replace_all_styles': 'applyToAll',
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {
@ -121,7 +121,7 @@ define([
});
Module.ButtonWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.buttonInsertion; },
getTemplate: function() { return window.templates.buttonInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -4,19 +4,19 @@
* as other containers.
*/
define([
'backbone',
'backbone.marionette',
'underscore',
'jquery',
'newsletter_editor/App',
'newsletter_editor/blocks/base'
], function(Backbone, Marionette, _, jQuery, App, BaseBlock) {
'backbone',
'backbone.marionette',
'underscore',
'jquery',
'newsletter_editor/App',
'newsletter_editor/blocks/base'
], function(Backbone, Marionette, _, jQuery, App, BaseBlock) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
BlockCollection;
base = BaseBlock,
BlockCollection;
BlockCollection = Backbone.Collection.extend({
model: base.BlockModel,
@ -103,9 +103,9 @@ define([
}
}),
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
getTemplate: function() { return templates.containerBlock; },
getTemplate: function() { return window.templates.containerBlock; },
events: _.extend({}, base.BlockView.prototype.events, {
"click .mailpoet_newsletter_layer_selector": "toggleEditingLayer"
'click .mailpoet_newsletter_layer_selector': 'toggleEditingLayer'
}),
ui: {
tools: '> .mailpoet_tools'
@ -138,7 +138,8 @@ define([
// for root and column containers.
return view.renderOptions.depth === 1;
}
}
},
HighlightContainerBehavior: {}
}),
onDragSubstituteBy: function() {
// For two and three column layouts display their respective widgets,
@ -217,7 +218,7 @@ define([
});
Module.ContainerBlockEmptyView = Marionette.View.extend({
getTemplate: function() { return templates.containerEmpty; },
getTemplate: function() { return window.templates.containerEmpty; },
initialize: function(options) {
this.renderOptions = _.defaults(options.renderOptions || {}, {});
},
@ -234,11 +235,11 @@ define([
});
Module.ContainerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.containerBlockSettings; },
getTemplate: function() { return window.templates.containerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_container_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_container_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_done_editing': 'close'
};
},
regions: {
@ -266,7 +267,7 @@ define([
});
Module.ContainerBlockColumnSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.containerBlockColumnSettings; },
getTemplate: function() { return window.templates.containerBlockColumnSettings; },
initialize: function(options) {
this.columnNumber = (options.columnIndex || 0) + 1;
},
@ -280,7 +281,7 @@ define([
Module.OneColumnContainerWidgetView = base.WidgetView.extend({
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
getTemplate: function() { return templates.oneColumnLayoutInsertion; },
getTemplate: function() { return window.templates.oneColumnLayoutInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
@ -298,7 +299,7 @@ define([
Module.TwoColumnContainerWidgetView = base.WidgetView.extend({
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
getTemplate: function() { return templates.twoColumnLayoutInsertion; },
getTemplate: function() { return window.templates.twoColumnLayoutInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
@ -317,7 +318,7 @@ define([
Module.ThreeColumnContainerWidgetView = base.WidgetView.extend({
className: base.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
getTemplate: function() { return templates.threeColumnLayoutInsertion; },
getTemplate: function() { return window.templates.threeColumnLayoutInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,17 +2,17 @@
* Divider content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore',
'jquery',
'mailpoet'
], function(App, BaseBlock, _, jQuery, MailPoet) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore',
'jquery',
'mailpoet'
], function(App, BaseBlock, _, jQuery, MailPoet) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.DividerBlockModel = base.BlockModel.extend({
defaults: function() {
@ -32,8 +32,8 @@ define([
});
Module.DividerBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_divider_block mailpoet_droppable_block",
getTemplate: function() { return templates.dividerBlock; },
className: 'mailpoet_block mailpoet_divider_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.dividerBlock; },
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
behaviors: _.defaults({
ResizableBehavior: {
@ -84,19 +84,19 @@ define([
});
Module.DividerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.dividerBlockSettings; },
getTemplate: function() { return window.templates.dividerBlockSettings; },
events: function() {
return {
"click .mailpoet_field_divider_style": 'changeStyle',
'click .mailpoet_field_divider_style': 'changeStyle',
"input .mailpoet_field_divider_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"change .mailpoet_field_divider_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
"input .mailpoet_field_divider_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
'input .mailpoet_field_divider_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'change .mailpoet_field_divider_border_width': _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
'input .mailpoet_field_divider_border_width_input': _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, 'styles.block.borderWidth').bind(this)),
"change .mailpoet_field_divider_border_color": _.partial(this.changeColorField, "styles.block.borderColor"),
"change .mailpoet_field_divider_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_button_divider_apply_to_all": "applyToAll",
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_divider_border_color': _.partial(this.changeColorField, 'styles.block.borderColor'),
'change .mailpoet_field_divider_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_button_divider_apply_to_all': 'applyToAll',
'click .mailpoet_done_editing': 'close'
};
},
modelEvents: function() {
@ -129,7 +129,7 @@ define([
});
Module.DividerWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.dividerInsertion; },
getTemplate: function() { return window.templates.dividerInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,15 +2,16 @@
* Footer content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore'
], function(App, BaseBlock, _) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore',
'mailpoet'
], function(App, BaseBlock, _, MailPoet) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.FooterBlockModel = base.BlockModel.extend({
defaults: function() {
@ -37,8 +38,8 @@ define([
});
Module.FooterBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_footer_block mailpoet_droppable_block",
getTemplate: function() { return templates.footerBlock; },
className: 'mailpoet_block mailpoet_footer_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.footerBlock; },
modelEvents: _.extend({
'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'
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
@ -75,19 +76,19 @@ define([
});
Module.FooterBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.footerBlockSettings; },
getTemplate: function() { return window.templates.footerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_footer_text_color": _.partial(this.changeColorField, "styles.text.fontColor"),
"change .mailpoet_field_footer_text_font_family": _.partial(this.changeField, "styles.text.fontFamily"),
"change .mailpoet_field_footer_text_size": _.partial(this.changeField, "styles.text.fontSize"),
"change #mailpoet_field_footer_link_color": _.partial(this.changeColorField, "styles.link.fontColor"),
"change #mailpoet_field_footer_link_underline": function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change .mailpoet_field_footer_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_footer_alignment": _.partial(this.changeField, "styles.text.textAlign"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_footer_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
'change .mailpoet_field_footer_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
'change .mailpoet_field_footer_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
'change #mailpoet_field_footer_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
'change #mailpoet_field_footer_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
'change .mailpoet_field_footer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_footer_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {
@ -98,7 +99,7 @@ define([
});
Module.FooterWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.footerInsertion; },
getTemplate: function() { return window.templates.footerInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,15 +2,16 @@
* Header content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore'
], function(App, BaseBlock, _) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore',
'mailpoet'
], function(App, BaseBlock, _, MailPoet) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.HeaderBlockModel = base.BlockModel.extend({
defaults: function() {
@ -37,8 +38,8 @@ define([
});
Module.HeaderBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_header_block mailpoet_droppable_block",
getTemplate: function() { return templates.headerBlock; },
className: 'mailpoet_block mailpoet_header_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.headerBlock; },
modelEvents: _.extend({
'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'
}, _.omit(base.BlockView.prototype.modelEvents, 'change')),
@ -75,19 +76,19 @@ define([
});
Module.HeaderBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.headerBlockSettings; },
getTemplate: function() { return window.templates.headerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_header_text_color": _.partial(this.changeColorField, "styles.text.fontColor"),
"change .mailpoet_field_header_text_font_family": _.partial(this.changeField, "styles.text.fontFamily"),
"change .mailpoet_field_header_text_size": _.partial(this.changeField, "styles.text.fontSize"),
"change #mailpoet_field_header_link_color": _.partial(this.changeColorField, "styles.link.fontColor"),
"change #mailpoet_field_header_link_underline": function(event) {
'change .mailpoet_field_header_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
'change .mailpoet_field_header_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
'change .mailpoet_field_header_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
'change #mailpoet_field_header_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
'change #mailpoet_field_header_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change .mailpoet_field_header_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_header_alignment": _.partial(this.changeField, "styles.text.textAlign"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_header_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_header_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {
@ -98,7 +99,7 @@ define([
});
Module.HeaderWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.headerInsertion; },
getTemplate: function() { return window.templates.headerInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,16 +2,18 @@
* Image content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore'
], function(App, BaseBlock, _) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore',
'mailpoet',
'jquery'
], function(App, BaseBlock, _, MailPoet, jQuery) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
ImageWidgetView;
base = BaseBlock,
ImageWidgetView;
Module.ImageBlockModel = base.BlockModel.extend({
defaults: function() {
@ -33,8 +35,8 @@ define([
});
Module.ImageBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_image_block mailpoet_droppable_block",
getTemplate: function() { return templates.imageBlock; },
className: 'mailpoet_block mailpoet_image_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.imageBlock; },
onDragSubstituteBy: function() { return Module.ImageWidgetView; },
templateContext: function() {
return _.extend({
@ -61,16 +63,26 @@ define([
});
Module.ImageBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.imageBlockSettings; },
onRender: function() {
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-full-width'), {
tooltipId: 'tooltip-editor-full-width',
tooltip: MailPoet.I18n.t('helpTooltipDesignerFullWidth')
});
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-ideal-width'), {
tooltipId: 'tooltip-editor-ideal-width',
tooltip: MailPoet.I18n.t('helpTooltipDesignerIdealWidth')
});
},
getTemplate: function() { return window.templates.imageBlockSettings; },
events: function() {
return {
"input .mailpoet_field_image_link": _.partial(this.changeField, "link"),
"input .mailpoet_field_image_address": 'changeAddress',
"input .mailpoet_field_image_alt_text": _.partial(this.changeField, "alt"),
"change .mailpoet_field_image_full_width": _.partial(this.changeBoolCheckboxField, "fullWidth"),
"change .mailpoet_field_image_alignment": _.partial(this.changeField, "styles.block.textAlign"),
"click .mailpoet_field_image_select_another_image": "showMediaManager",
"click .mailpoet_done_editing": "close"
'input .mailpoet_field_image_link': _.partial(this.changeField, 'link'),
'input .mailpoet_field_image_address': 'changeAddress',
'input .mailpoet_field_image_alt_text': _.partial(this.changeField, 'alt'),
'change .mailpoet_field_image_full_width': _.partial(this.changeBoolCheckboxField, 'fullWidth'),
'change .mailpoet_field_image_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
'click .mailpoet_field_image_select_another_image': 'showMediaManager',
'click .mailpoet_done_editing': 'close'
};
},
initialize: function(options) {
@ -87,10 +99,10 @@ define([
return;
}
var MediaManager = wp.media.view.MediaFrame.Select.extend({
var MediaManager = window.wp.media.view.MediaFrame.Select.extend({
initialize: function() {
wp.media.view.MediaFrame.prototype.initialize.apply(this, arguments);
window.wp.media.view.MediaFrame.prototype.initialize.apply(this, arguments);
_.defaults(this.options, {
multiple: true,
@ -112,7 +124,7 @@ define([
},
createQuery: function(options) {
var query = wp.media.query(options);
var query = window.wp.media.query(options);
return query;
},
@ -122,7 +134,7 @@ define([
// Add the default states.
this.states.add([
// Main states.
new wp.media.controller.Library({
new window.wp.media.controller.Library({
id: 'insert',
title: 'Add images',
priority: 20,
@ -144,8 +156,8 @@ define([
})
]);
if(wp.media.view.settings.post.featuredImageId) {
this.states.add(new wp.media.controller.FeaturedImage());
if(window.wp.media.view.settings.post.featuredImageId) {
this.states.add(new window.wp.media.controller.FeaturedImage());
}
},
@ -165,14 +177,14 @@ define([
this.on('updateExcluded', this.browseContent, this);
var handlers = {
content: {
'embed': 'embedContent',
'edit-selection': 'editSelectionContent'
},
toolbar: {
'main-insert': 'mainInsertToolbar'
}
};
content: {
embed: 'embedContent',
'edit-selection': 'editSelectionContent'
},
toolbar: {
'main-insert': 'mainInsertToolbar'
}
};
_.each(handlers, function(regionHandlers, region) {
_.each(regionHandlers, function(callback, handler) {
@ -182,13 +194,13 @@ define([
},
uploadContent: function() {
wp.media.view.MediaFrame.Select.prototype.uploadContent.apply(this, arguments);
window.wp.media.view.MediaFrame.Select.prototype.uploadContent.apply(this, arguments);
this.$el.addClass('hide-toolbar');
},
// Content
embedContent: function() {
var view = new wp.media.view.Embed({
var view = new window.wp.media.view.Embed({
controller: this,
model: this.state()
}).render();
@ -202,7 +214,7 @@ define([
selection = state.get('selection'),
view;
view = new wp.media.view.AttachmentsBrowser({
view = new window.wp.media.view.AttachmentsBrowser({
controller: this,
collection: selection,
selection: selection,
@ -211,7 +223,7 @@ define([
search: false,
dragInfo: true,
AttachmentView: wp.media.view.Attachment.EditSelection
AttachmentView: window.wp.media.view.Attachment.EditSelection
}).render();
view.toolbar.set('backToLibrary', {
@ -231,7 +243,7 @@ define([
selectionStatusToolbar: function(view) {
var editable = this.state().get('editable');
view.set('selection', new wp.media.view.Selection({
view.set('selection', new window.wp.media.view.Selection({
controller: this,
collection: this.state().get('selection'),
priority: -40,
@ -266,7 +278,8 @@ define([
},
mainEmbedToolbar: function(toolbar) {
toolbar.view = new wp.media.view.Toolbar.Embed({
var tbar = toolbar;
tbar.view = new window.wp.media.view.Toolbar.Embed({
controller: this,
text: 'Add images'
});
@ -274,7 +287,7 @@ define([
});
var theFrame = this._mediaManager = new MediaManager({
var theFrame = new MediaManager({
id: 'mailpoet-media-manager',
frame: 'select',
title: 'Select image',
@ -289,6 +302,7 @@ define([
}
}),
that = this;
this._mediaManager = theFrame;
this._mediaManager.on('insert', function() {
// Append media manager image selections to Images tab
@ -318,7 +332,7 @@ define([
height: mainSize.height + 'px',
width: mainSize.width + 'px',
src: mainSize.url,
alt: (attachment.get('alt') !== "" && attachment.get('alt') !== undefined) ? attachment.get('alt') : attachment.get('title')
alt: (attachment.get('alt') !== '' && attachment.get('alt') !== undefined) ? attachment.get('alt') : attachment.get('title')
});
// Rerender settings view due to changes from outside of settings view
that.render();
@ -350,7 +364,7 @@ define([
});
ImageWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.imageInsertion; },
getTemplate: function() { return window.templates.imageInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -11,36 +11,36 @@
* block settings view.
*/
define([
'backbone',
'backbone.marionette',
'backbone.radio',
'underscore',
'jquery',
'mailpoet',
'newsletter_editor/App',
'newsletter_editor/components/communication',
'newsletter_editor/blocks/base',
'newsletter_editor/blocks/button',
'newsletter_editor/blocks/divider',
'select2'
], function(
Backbone,
Marionette,
Radio,
_,
jQuery,
MailPoet,
App,
CommunicationComponent,
BaseBlock,
ButtonBlock,
DividerBlock
'backbone',
'backbone.marionette',
'backbone.radio',
'underscore',
'jquery',
'mailpoet',
'newsletter_editor/App',
'newsletter_editor/components/communication',
'newsletter_editor/blocks/base',
'newsletter_editor/blocks/button',
'newsletter_editor/blocks/divider',
'select2'
], function(
Backbone,
Marionette,
Radio,
_,
jQuery,
MailPoet,
App,
CommunicationComponent,
BaseBlock,
ButtonBlock,
DividerBlock
) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.PostsBlockModel = base.BlockModel.extend({
stale: ['_selectedPosts', '_availablePosts', '_transformedPosts'],
@ -176,8 +176,8 @@ define([
});
Module.PostsBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_posts_block mailpoet_droppable_block",
getTemplate: function() { return templates.postsBlock; },
className: 'mailpoet_block mailpoet_posts_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.postsBlock; },
modelEvents: {}, // Forcefully disable all events
regions: _.extend({
postsRegion: '.mailpoet_posts_block_posts'
@ -216,7 +216,7 @@ define([
});
Module.PostsBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.postsBlockSettings; },
getTemplate: function() { return window.templates.postsBlockSettings; },
regions: {
selectionRegion: '.mailpoet_settings_posts_selection',
displayOptionsRegion: '.mailpoet_settings_posts_display_options'
@ -296,7 +296,7 @@ define([
this.blockModel = options.blockModel;
},
events: {
'scroll': 'onPostsScroll'
scroll: 'onPostsScroll'
},
onPostsScroll: function(event) {
var $postsBox = jQuery(event.target);
@ -308,7 +308,7 @@ define([
});
var PostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.postSelectionPostsBlockSettings; },
getTemplate: function() { return window.templates.postSelectionPostsBlockSettings; },
regions: {
posts: '.mailpoet_post_selection_container'
},
@ -326,10 +326,10 @@ define([
this.$('.mailpoet_post_scroll_container').scrollTop(0);
}
},
'loadingMorePosts': function() {
loadingMorePosts: function() {
this.$('.mailpoet_post_selection_loading').css('visibility', 'visible');
},
'morePostsLoaded': function() {
morePostsLoaded: function() {
this.$('.mailpoet_post_selection_loading').css('visibility', 'hidden');
}
},
@ -414,7 +414,7 @@ define([
},
_updateContentTypes: function(postTypes) {
var select = this.$('.mailpoet_settings_posts_content_type'),
selectedValue = this.model.get('contentType');
selectedValue = this.model.get('contentType');
select.find('option').remove();
_.each(postTypes, function(type) {
@ -428,11 +428,11 @@ define([
});
var EmptyPostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.emptyPostPostsBlockSettings; }
getTemplate: function() { return window.templates.emptyPostPostsBlockSettings; }
});
var SinglePostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.singlePostPostsBlockSettings; },
getTemplate: function() { return window.templates.singlePostPostsBlockSettings; },
events: function() {
return {
'change .mailpoet_select_post_checkbox': 'postSelectionChange'
@ -459,28 +459,28 @@ define([
});
var PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.displayOptionsPostsBlockSettings; },
getTemplate: function() { return window.templates.displayOptionsPostsBlockSettings; },
events: function() {
return {
"click .mailpoet_posts_select_button": 'showButtonSettings',
"click .mailpoet_posts_select_divider": 'showDividerSettings',
"change .mailpoet_posts_read_more_type": 'changeReadMoreType',
"change .mailpoet_posts_display_type": 'changeDisplayType',
"change .mailpoet_posts_title_format": 'changeTitleFormat',
"change .mailpoet_posts_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
"change .mailpoet_posts_show_divider": _.partial(this.changeBoolField, 'showDivider'),
"input .mailpoet_posts_show_amount": _.partial(this.changeField, "amount"),
"change .mailpoet_posts_content_type": _.partial(this.changeField, "contentType"),
"change .mailpoet_posts_include_or_exclude": _.partial(this.changeField, "inclusionType"),
"change .mailpoet_posts_title_alignment": _.partial(this.changeField, "titleAlignment"),
"change .mailpoet_posts_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
"change .mailpoet_posts_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
"change .mailpoet_posts_show_author": _.partial(this.changeField, "showAuthor"),
"input .mailpoet_posts_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
"change .mailpoet_posts_show_categories": _.partial(this.changeField, "showCategories"),
"input .mailpoet_posts_categories": _.partial(this.changeField, "categoriesPrecededBy"),
"input .mailpoet_posts_read_more_text": _.partial(this.changeField, "readMoreText"),
"change .mailpoet_posts_sort_by": _.partial(this.changeField, "sortBy")
'click .mailpoet_posts_select_button': 'showButtonSettings',
'click .mailpoet_posts_select_divider': 'showDividerSettings',
'change .mailpoet_posts_read_more_type': 'changeReadMoreType',
'change .mailpoet_posts_display_type': 'changeDisplayType',
'change .mailpoet_posts_title_format': 'changeTitleFormat',
'change .mailpoet_posts_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'),
'change .mailpoet_posts_show_divider': _.partial(this.changeBoolField, 'showDivider'),
'input .mailpoet_posts_show_amount': _.partial(this.changeField, 'amount'),
'change .mailpoet_posts_content_type': _.partial(this.changeField, 'contentType'),
'change .mailpoet_posts_include_or_exclude': _.partial(this.changeField, 'inclusionType'),
'change .mailpoet_posts_title_alignment': _.partial(this.changeField, 'titleAlignment'),
'change .mailpoet_posts_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'),
'change .mailpoet_posts_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'),
'change .mailpoet_posts_show_author': _.partial(this.changeField, 'showAuthor'),
'input .mailpoet_posts_author_preceded_by': _.partial(this.changeField, 'authorPrecededBy'),
'change .mailpoet_posts_show_categories': _.partial(this.changeField, 'showCategories'),
'input .mailpoet_posts_categories': _.partial(this.changeField, 'categoriesPrecededBy'),
'input .mailpoet_posts_read_more_text': _.partial(this.changeField, 'readMoreText'),
'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy')
};
},
templateContext: function() {
@ -564,7 +564,7 @@ define([
});
Module.PostsWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.postsInsertion; },
getTemplate: function() { return window.templates.postsInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,23 +2,23 @@
* Social icons content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'backbone',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery'
], function(App, BaseBlock, Backbone, Marionette, SuperModel, _, jQuery) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'backbone',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery'
], function(App, BaseBlock, Backbone, Marionette, SuperModel, _, jQuery) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
SocialBlockSettingsIconSelectorView,
SocialBlockSettingsIconView,
SocialBlockSettingsIconCollectionView,
SocialBlockSettingsStylesView;
base = BaseBlock,
SocialBlockSettingsIconSelectorView,
SocialBlockSettingsIconView,
SocialBlockSettingsIconCollectionView,
SocialBlockSettingsStylesView;
Module.SocialIconModel = SuperModel.extend({
defaults: function() {
@ -85,9 +85,9 @@ define([
var SocialIconView = Marionette.View.extend({
tagName: 'span',
getTemplate: function() { return templates.socialIconBlock; },
getTemplate: function() { return window.templates.socialIconBlock; },
modelEvents: {
'change': 'render'
change: 'render'
},
templateContext: function() {
var allIconSets = App.getAvailableStyles().get('socialIconSets');
@ -105,7 +105,7 @@ define([
Module.SocialBlockView = base.BlockView.extend({
className: 'mailpoet_block mailpoet_social_block mailpoet_droppable_block',
getTemplate: function() { return templates.socialBlock; },
getTemplate: function() { return window.templates.socialBlock; },
regions: _.extend({}, base.BlockView.prototype.regions, {
icons: '.mailpoet_social'
}),
@ -121,7 +121,7 @@ define([
this.showChildView('toolsRegion', this.toolsView);
this.showChildView('icons', new Module.SocialIconCollectionView({
collection: this.model.get('icons')
}))
}));
}
});
@ -131,14 +131,14 @@ define([
// Sidebar view container
Module.SocialBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.socialBlockSettings; },
getTemplate: function() { return window.templates.socialBlockSettings; },
regions: {
iconRegion: '#mailpoet_social_icons_selection',
stylesRegion: '#mailpoet_social_icons_styles'
},
events: function() {
return {
"click .mailpoet_done_editing": "close"
'click .mailpoet_done_editing': 'close'
};
},
initialize: function() {
@ -155,14 +155,14 @@ define([
// Single icon settings view, used by the selector view
SocialBlockSettingsIconView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsIcon; },
getTemplate: function() { return window.templates.socialSettingsIcon; },
events: function() {
return {
"click .mailpoet_delete_block": "deleteIcon",
"change .mailpoet_social_icon_field_type": _.partial(this.changeField, "iconType"),
"input .mailpoet_social_icon_field_image": _.partial(this.changeField, "image"),
"input .mailpoet_social_icon_field_link": this.changeLink,
"input .mailpoet_social_icon_field_text": _.partial(this.changeField, "text")
'click .mailpoet_delete_block': 'deleteIcon',
'change .mailpoet_social_icon_field_type': _.partial(this.changeField, 'iconType'),
'input .mailpoet_social_icon_field_image': _.partial(this.changeField, 'image'),
'input .mailpoet_social_icon_field_link': this.changeLink,
'input .mailpoet_social_icon_field_text': _.partial(this.changeField, 'text')
};
},
modelEvents: {
@ -212,9 +212,9 @@ define([
// Select icons section container view
SocialBlockSettingsIconSelectorView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsIconSelector; },
getTemplate: function() { return window.templates.socialSettingsIconSelector; },
regions: {
'icons': '#mailpoet_social_icon_selector_contents'
icons: '#mailpoet_social_icon_selector_contents'
},
events: {
'click .mailpoet_add_social_icon': 'addSocialIcon'
@ -235,9 +235,9 @@ define([
});
SocialBlockSettingsStylesView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsStyles; },
getTemplate: function() { return window.templates.socialSettingsStyles; },
modelEvents: {
'change': 'render'
change: 'render'
},
events: {
'click .mailpoet_social_icon_set': 'changeSocialIconSet'
@ -263,7 +263,7 @@ define([
});
Module.SocialWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.socialInsertion; },
getTemplate: function() { return window.templates.socialInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,15 +2,15 @@
* Spacer content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore'
], function(App, BaseBlock, _) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.SpacerBlockModel = base.BlockModel.extend({
defaults: function() {
@ -27,8 +27,8 @@ define([
});
Module.SpacerBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_spacer_block mailpoet_droppable_block",
getTemplate: function() { return templates.spacerBlock; },
className: 'mailpoet_block mailpoet_spacer_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.spacerBlock; },
behaviors: _.defaults({
ResizableBehavior: {
elementSelector: '.mailpoet_spacer',
@ -66,17 +66,17 @@ define([
});
Module.SpacerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.spacerBlockSettings; },
getTemplate: function() { return window.templates.spacerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_spacer_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_done_editing": "close"
'change .mailpoet_field_spacer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_done_editing': 'close'
};
}
});
Module.SpacerWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.spacerInsertion; },
getTemplate: function() { return window.templates.spacerInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -2,15 +2,16 @@
* Text content block
*/
define([
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore'
], function(App, BaseBlock, _) {
'newsletter_editor/App',
'newsletter_editor/blocks/base',
'underscore',
'mailpoet'
], function(App, BaseBlock, _, MailPoet) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
base = BaseBlock;
Module.TextBlockModel = base.BlockModel.extend({
defaults: function() {
@ -22,17 +23,17 @@ define([
});
Module.TextBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_text_block mailpoet_droppable_block",
getTemplate: function() { return templates.textBlock; },
className: 'mailpoet_block mailpoet_text_block mailpoet_droppable_block',
getTemplate: function() { return window.templates.textBlock; },
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), // Prevent rerendering on model change due to text editor redrawing
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
TextEditorBehavior: {
toolbar1: "formatselect bold italic forecolor | link unlink",
toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes",
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
invalidElements: "script",
toolbar1: 'formatselect bold italic forecolor | link unlink',
toolbar2: 'alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes',
validElements: 'p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]',
invalidElements: 'script',
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
plugins: "link lists code textcolor colorpicker mailpoet_shortcodes paste",
plugins: 'link lists code textcolor colorpicker mailpoet_shortcodes paste',
configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, {
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
@ -78,11 +79,11 @@ define([
});
Module.TextBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.textBlockSettings; }
getTemplate: function() { return window.templates.textBlockSettings; }
});
Module.TextWidgetView = base.WidgetView.extend({
getTemplate: function() { return templates.textInsertion; },
getTemplate: function() { return window.templates.textInsertion; },
behaviors: {
DraggableBehavior: {
cloneOriginal: true,

View File

@ -24,7 +24,8 @@
}(this, function(Marionette, Radio, _) {
'use strict';
Marionette.Application.prototype._initChannel = function () {
var MarionetteApplication = Marionette.Application;
MarionetteApplication.prototype._initChannel = function () {
this.channelName = _.result(this, 'channelName') || 'global';
this.channel = _.result(this, 'channel') || Radio.channel(this.channelName);
};

View File

@ -1,9 +1,9 @@
define([
'newsletter_editor/App',
'underscore',
'mailpoet',
'ajax'
], function(App, _, MailPoet) {
'newsletter_editor/App',
'underscore',
'mailpoet',
'ajax'
], function(App, _, MailPoet) {
var Module = {};

View File

@ -1,7 +1,7 @@
define([
'newsletter_editor/App',
'backbone.supermodel'
], function(App, SuperModel) {
'newsletter_editor/App',
'backbone.supermodel'
], function(App, SuperModel) {
var Module = {};
@ -25,11 +25,12 @@ define([
};
App.on('before:start', function(App, options) {
var Application = App;
// Expose config methods globally
App.getConfig = Module.getConfig;
App.setConfig = Module.setConfig;
Application.getConfig = Module.getConfig;
Application.setConfig = Module.setConfig;
App.setConfig(options.config);
Application.setConfig(options.config);
});
return Module;

View File

@ -1,10 +1,10 @@
define([
'newsletter_editor/App',
'backbone.supermodel',
'underscore',
'mailpoet'
], function(App, SuperModel, _, MailPoet) {
"use strict";
'newsletter_editor/App',
'backbone.supermodel',
'underscore',
'mailpoet'
], function(App, SuperModel, _, MailPoet) {
'use strict';
var Module = {};
@ -15,7 +15,7 @@ define([
whitelisted: ['id', 'subject', 'preheader'],
initialize: function(options) {
this.on('change', function() {
App.getChannel().trigger('autoSave');
App.getChannel().trigger('autoSave');
});
},
toJSON: function() {
@ -34,14 +34,14 @@ define([
if (type in Module._blockTypes) {
return Module._blockTypes[type].blockModel;
} else {
throw "Block type not supported: " + type;
throw 'Block type not supported: ' + type;
}
};
Module.getBlockTypeView = function(type) {
if (type in Module._blockTypes) {
return Module._blockTypes[type].blockView;
} else {
throw "Block type not supported: " + type;
throw 'Block type not supported: ' + type;
}
};
@ -59,7 +59,7 @@ define([
};
Module.getNewsletter = function() {
return Module.newsletter;
return Module.newsletter;
};
Module.findModels = function(predicate) {
@ -67,7 +67,8 @@ define([
return _.filter(blocks, predicate);
};
App.on('before:start', function(App, options) {
App.on('before:start', function(Application, options) {
var App = Application;
// Expose block methods globally
App.registerBlockType = Module.registerBlockType;
App.getBlockTypeModel = Module.getBlockTypeModel;
@ -80,7 +81,8 @@ define([
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
});
App.on('start', function(App, options) {
App.on('start', function(Application, options) {
var App = Application;
var body = options.newsletter.body;
var content = (_.has(body, 'content')) ? body.content : {};

View File

@ -1,17 +1,18 @@
define([
'newsletter_editor/App',
'backbone',
'backbone.marionette',
'underscore',
'jquery'
], function(App, Backbone, Marionette, _, jQuery) {
'newsletter_editor/App',
'backbone',
'backbone.marionette',
'underscore',
'jquery',
'mailpoet'
], function(App, Backbone, Marionette, _, jQuery, MailPoet) {
"use strict";
'use strict';
var Module = {};
Module.HeadingView = Marionette.View.extend({
getTemplate: function() { return templates.heading; },
getTemplate: function() { return window.templates.heading; },
templateContext: function() {
return {
model: this.model.toJSON()
@ -19,8 +20,8 @@ define([
},
events: function() {
return {
'keyup .mailpoet_input_title': _.partial(this.changeField, "subject"),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, "preheader")
'keyup .mailpoet_input_title': _.partial(this.changeField, 'subject'),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, 'preheader')
};
},
changeField: function(field, event) {
@ -30,6 +31,15 @@ define([
App.on('start', function(App, options) {
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
tooltipId: 'tooltip-designer-subject-line-ti',
tooltip: MailPoet.I18n.t('helpTooltipDesignerSubjectLine'),
place: 'right'
});
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-preheader'), {
tooltipId: 'tooltip-designer-preheader-ti',
tooltip: MailPoet.I18n.t('helpTooltipDesignerPreheader')
});
});
return Module;

View File

@ -1,31 +1,35 @@
define([
'newsletter_editor/App',
'newsletter_editor/components/communication',
'mailpoet',
'notice',
'backbone',
'backbone.marionette',
'jquery',
'blob',
'file-saver',
'html2canvas'
], function(
App,
CommunicationComponent,
MailPoet,
Notice,
Backbone,
Marionette,
jQuery,
Blob,
FileSaver,
html2canvas
) {
'newsletter_editor/App',
'newsletter_editor/components/communication',
'mailpoet',
'notice',
'backbone',
'backbone.marionette',
'jquery',
'blob',
'file-saver',
'html2canvas',
'underscore',
'jquery'
], function(
App,
CommunicationComponent,
MailPoet,
Notice,
Backbone,
Marionette,
jQuery,
Blob,
FileSaver,
html2canvas,
_,
$
) {
"use strict";
'use strict';
var Module = {},
saveTimeout;
saveTimeout;
// Save editor contents to server
Module.save = function() {
@ -65,14 +69,6 @@ define([
});
};
// For getting a promise after triggering save event
Module.saveAndProvidePromise = function(saveResult) {
var promise = Module.save();
if (saveResult !== undefined) {
saveResult.promise = promise;
}
};
Module.getThumbnail = function(element, options) {
var promise = html2canvas(element, options || {});
@ -81,9 +77,9 @@ define([
// Removes 1px left transparent border from resulting canvas.
var oldContext = oldCanvas.getContext('2d'),
newCanvas = document.createElement("canvas"),
newContext = newCanvas.getContext("2d"),
leftBorderWidth = 1;
newCanvas = document.createElement('canvas'),
newContext = newCanvas.getContext('2d'),
leftBorderWidth = 1;
newCanvas.width = oldCanvas.width;
newCanvas.height = oldCanvas.height;
@ -100,7 +96,7 @@ define([
Module.saveTemplate = function(options) {
var that = this,
promise = jQuery.Deferred();
promise = jQuery.Deferred();
promise.then(function(thumbnail) {
var data = _.extend(options || {}, {
@ -140,11 +136,14 @@ define([
);
FileSaver.saveAs(blob, 'template.json');
MailPoet.trackEvent('Editor > Template exported', {
'MailPoet Free version': window.mailpoet_version
});
});
};
Module.SaveView = Marionette.View.extend({
getTemplate: function() { return templates.save; },
getTemplate: function() { return window.templates.save; },
events: {
'click .mailpoet_save_button': 'save',
'click .mailpoet_save_show_options': 'toggleSaveOptions',
@ -165,7 +164,7 @@ define([
},
save: function() {
this.hideOptionContents();
App.getChannel().trigger('save');
App.getChannel().request('save');
},
beforeSave: function() {
// TODO: Add a loading animation instead
@ -194,8 +193,8 @@ define([
},
saveAsTemplate: function() {
var templateName = this.$('.mailpoet_save_as_template_name').val(),
templateDescription = this.$('.mailpoet_save_as_template_description').val(),
that = this;
templateDescription = this.$('.mailpoet_save_as_template_description').val(),
that = this;
if (templateName === '') {
MailPoet.Notice.error(
@ -225,6 +224,9 @@ define([
scroll: true
}
);
MailPoet.trackEvent('Editor > Template saved', {
'MailPoet Free version': window.mailpoet_version
});
}).fail(function() {
MailPoet.Notice.error(
MailPoet.I18n.t('templateSaveFailed'),
@ -247,8 +249,8 @@ define([
},
exportTemplate: function() {
var templateName = this.$('.mailpoet_export_template_name').val(),
templateDescription = this.$('.mailpoet_export_template_description').val(),
that = this;
templateDescription = this.$('.mailpoet_export_template_description').val(),
that = this;
if (templateName === '') {
MailPoet.Notice.error(
@ -282,7 +284,10 @@ define([
next: function() {
this.hideOptionContents();
if(!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
window.location.href = App.getConfig().get('urls.send');
Module._cancelAutosave();
Module.save().done(function(response) {
window.location.href = App.getConfig().get('urls.send');
});
}
},
validateNewsletter: function(jsonObject) {
@ -293,8 +298,8 @@ define([
var contents = JSON.stringify(jsonObject);
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
contents.indexOf("[link:subscription_unsubscribe_url]") < 0 &&
contents.indexOf("[link:subscription_unsubscribe]") < 0) {
contents.indexOf('[link:subscription_unsubscribe_url]') < 0 &&
contents.indexOf('[link:subscription_unsubscribe]') < 0) {
this.showValidationError(MailPoet.I18n.t('unsubscribeLinkMissing'));
return;
}
@ -319,22 +324,28 @@ define([
// may be requested
var AUTOSAVE_DELAY_DURATION = 1000;
// Cancel save timer if another change happens before it completes
if (saveTimeout) clearTimeout(saveTimeout);
Module._cancelAutosave();
saveTimeout = setTimeout(function() {
App.getChannel().trigger('save');
clearTimeout(saveTimeout);
saveTimeout = undefined;
App.getChannel().request('save').always(function() {
Module._cancelAutosave();
});
}, AUTOSAVE_DELAY_DURATION);
};
Module._cancelAutosave = function() {
if (!saveTimeout) return;
clearTimeout(saveTimeout);
saveTimeout = undefined;
};
Module.beforeExitWithUnsavedChanges = function(e) {
if (saveTimeout) {
var message = MailPoet.I18n.t('unsavedChangesWillBeLost');
e = e || window.event;
var event = e || window.event;
if (e) {
e.returnValue = message;
if (event) {
event.returnValue = message;
}
return message;
@ -342,12 +353,13 @@ define([
};
App.on('before:start', function(App, options) {
App.save = Module.saveAndProvidePromise;
App.getChannel().on('autoSave', Module.autoSave);
var Application = App;
Application.save = Module.save;
Application.getChannel().on('autoSave', Module.autoSave);
window.onbeforeunload = Module.beforeExitWithUnsavedChanges;
App.getChannel().on('save', function(saveResult) { App.save(saveResult); });
Application.getChannel().reply('save', Application.save);
});
App.on('start', function(App, options) {

View File

@ -1,26 +1,26 @@
define([
'newsletter_editor/App',
'newsletter_editor/components/communication',
'mailpoet',
'backbone',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery',
'sticky-kit'
], function(
App,
CommunicationComponent,
MailPoet,
Backbone,
Marionette,
SuperModel,
_,
jQuery,
StickyKit
'newsletter_editor/App',
'newsletter_editor/components/communication',
'mailpoet',
'backbone',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery',
'sticky-kit'
], function(
App,
CommunicationComponent,
MailPoet,
Backbone,
Marionette,
SuperModel,
_,
jQuery,
StickyKit
) {
"use strict";
'use strict';
var Module = {};
@ -53,7 +53,7 @@ define([
Module.getLayoutWidgets = function() { return Module._layoutWidgets; };
var SidebarView = Marionette.View.extend({
getTemplate: function() { return templates.sidebar; },
getTemplate: function() { return window.templates.sidebar; },
regions: {
contentRegion: '.mailpoet_content_region',
layoutRegion: '.mailpoet_layout_region',
@ -69,7 +69,7 @@ define([
'slideUp',
{
duration: 250,
easing: "easeOut",
easing: 'easeOut',
complete: function() {
$openRegion.addClass('closed');
}.bind(this)
@ -81,7 +81,7 @@ define([
'slideDown',
{
duration: 250,
easing: "easeIn",
easing: 'easeIn',
complete: function() {
$targetRegion.removeClass('closed');
}
@ -147,7 +147,7 @@ define([
* Responsible for rendering draggable content widgets
*/
Module.SidebarWidgetsView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarContent; },
getTemplate: function() { return window.templates.sidebarContent; },
regions: {
widgets: '.mailpoet_region_content'
},
@ -167,53 +167,53 @@ define([
* Responsible for rendering draggable layout widgets
*/
Module.SidebarLayoutWidgetsView = Module.SidebarWidgetsView.extend({
getTemplate: function() { return templates.sidebarLayout; }
getTemplate: function() { return window.templates.sidebarLayout; }
});
/**
* Responsible for managing global styles
*/
Module.SidebarStylesView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarStyles; },
getTemplate: function() { return window.templates.sidebarStyles; },
behaviors: {
ColorPickerBehavior: {}
},
events: function() {
return {
"change #mailpoet_text_font_color": _.partial(this.changeColorField, 'text.fontColor'),
"change #mailpoet_text_font_family": function(event) {
'change #mailpoet_text_font_color': _.partial(this.changeColorField, 'text.fontColor'),
'change #mailpoet_text_font_family': function(event) {
this.model.set('text.fontFamily', event.target.value);
},
"change #mailpoet_text_font_size": function(event) {
'change #mailpoet_text_font_size': function(event) {
this.model.set('text.fontSize', event.target.value);
},
"change #mailpoet_h1_font_color": _.partial(this.changeColorField, 'h1.fontColor'),
"change #mailpoet_h1_font_family": function(event) {
'change #mailpoet_h1_font_color': _.partial(this.changeColorField, 'h1.fontColor'),
'change #mailpoet_h1_font_family': function(event) {
this.model.set('h1.fontFamily', event.target.value);
},
"change #mailpoet_h1_font_size": function(event) {
'change #mailpoet_h1_font_size': function(event) {
this.model.set('h1.fontSize', event.target.value);
},
"change #mailpoet_h2_font_color": _.partial(this.changeColorField, 'h2.fontColor'),
"change #mailpoet_h2_font_family": function(event) {
'change #mailpoet_h2_font_color': _.partial(this.changeColorField, 'h2.fontColor'),
'change #mailpoet_h2_font_family': function(event) {
this.model.set('h2.fontFamily', event.target.value);
},
"change #mailpoet_h2_font_size": function(event) {
'change #mailpoet_h2_font_size': function(event) {
this.model.set('h2.fontSize', event.target.value);
},
"change #mailpoet_h3_font_color": _.partial(this.changeColorField, 'h3.fontColor'),
"change #mailpoet_h3_font_family": function(event) {
'change #mailpoet_h3_font_color': _.partial(this.changeColorField, 'h3.fontColor'),
'change #mailpoet_h3_font_family': function(event) {
this.model.set('h3.fontFamily', event.target.value);
},
"change #mailpoet_h3_font_size": function(event) {
'change #mailpoet_h3_font_size': function(event) {
this.model.set('h3.fontSize', event.target.value);
},
"change #mailpoet_a_font_color": _.partial(this.changeColorField, 'link.fontColor'),
"change #mailpoet_a_font_underline": function(event) {
'change #mailpoet_a_font_color': _.partial(this.changeColorField, 'link.fontColor'),
'change #mailpoet_a_font_underline': function(event) {
this.model.set('link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change #mailpoet_newsletter_background_color": _.partial(this.changeColorField, 'wrapper.backgroundColor'),
"change #mailpoet_background_color": _.partial(this.changeColorField, 'body.backgroundColor')
'change #mailpoet_newsletter_background_color': _.partial(this.changeColorField, 'wrapper.backgroundColor'),
'change #mailpoet_background_color': _.partial(this.changeColorField, 'body.backgroundColor')
};
},
templateContext: function() {
@ -238,7 +238,7 @@ define([
});
Module.SidebarPreviewView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarPreview; },
getTemplate: function() { return window.templates.sidebarPreview; },
events: {
'click .mailpoet_show_preview': 'showPreview',
'click #mailpoet_send_preview': 'sendPreview'
@ -272,16 +272,23 @@ define([
});
var view = this.previewView.render();
this.previewView.$el.css('height', '100%');
MailPoet.Modal.popup({
template: '',
element: this.previewView.$el,
width: '95%',
height: '94%',
title: MailPoet.I18n.t('newsletterPreview'),
onCancel: function() {
this.previewView.destroy();
this.previewView = null;
}.bind(this)
});
MailPoet.trackEvent('Editor > Browser Preview', {
'MailPoet Free version': window.mailpoet_version
});
}.bind(this)).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
@ -314,16 +321,18 @@ define([
MailPoet.Modal.loading(true);
// save before sending
var saveResult = {promise: null};
App.getChannel().trigger('save', saveResult);
saveResult.promise.always(function() {
App.getChannel().request('save').always(function() {
CommunicationComponent.previewNewsletter(data).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterPreviewSent'),
{ scroll: true });
{ scroll: true }
);
MailPoet.trackEvent('Editor > Preview sent', {
'MailPoet Free version': window.mailpoet_version,
'Domain name': data.subscriber.substring(data.subscriber.indexOf('@') + 1)
});
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
@ -337,11 +346,13 @@ define([
});
Module.NewsletterPreviewView = Marionette.View.extend({
getTemplate: function() { return templates.newsletterPreview; },
getTemplate: function() { return window.templates.newsletterPreview; },
initialize: function(options) {
this.previewUrl = options.previewUrl;
this.width = App.getConfig().get('newsletterPreview.width');
this.height = App.getConfig().get('newsletterPreview.height')
this.width = '100%';
this.height = '100%';
// this.width = App.getConfig().get('newsletterPreview.width');
// this.height = App.getConfig().get('newsletterPreview.height')
},
templateContext: function() {
return {
@ -353,10 +364,11 @@ define([
});
App.on('before:start', function(App, options) {
App.registerWidget = Module.registerWidget;
App.getWidgets = Module.getWidgets;
App.registerLayoutWidget = Module.registerLayoutWidget;
App.getLayoutWidgets = Module.getLayoutWidgets;
var Application = App;
Application.registerWidget = Module.registerWidget;
Application.getWidgets = Module.getWidgets;
Application.registerLayoutWidget = Module.registerLayoutWidget;
Application.getLayoutWidgets = Module.getLayoutWidgets;
});
App.on('start', function(App, options) {
@ -364,6 +376,16 @@ define([
sidebarView = new SidebarView();
App._appView.showChildView('sidebarRegion', sidebarView);
MailPoet.helpTooltip.show(document.getElementById('tooltip-send-preview'), {
tooltipId: 'tooltip-editor-send-preview',
tooltip: MailPoet.I18n.t('helpTooltipSendPreview')
});
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-styles'), {
tooltipId: 'tooltip-editor-designer-styles',
tooltip: MailPoet.I18n.t('helpTooltipDesignerStyles')
});
});
return Module;

View File

@ -1,10 +1,11 @@
define([
'newsletter_editor/App',
'backbone.marionette',
'backbone.supermodel'
], function(App, Marionette, SuperModel) {
'newsletter_editor/App',
'backbone.marionette',
'backbone.supermodel',
'underscore'
], function(App, Marionette, SuperModel, _) {
"use strict";
'use strict';
var Module = {};
@ -47,9 +48,9 @@ define([
});
Module.StylesView = Marionette.View.extend({
getTemplate: function() { return templates.styles; },
getTemplate: function() { return window.templates.styles; },
modelEvents: {
'change': 'render'
change: 'render'
},
serializeData: function() {
return this.model.toJSON();
@ -69,10 +70,11 @@ define([
};
App.on('before:start', function(App, options) {
var Application = App;
// Expose style methods to global application
App.getGlobalStyles = Module.getGlobalStyles;
App.setGlobalStyles = Module.setGlobalStyles;
App.getAvailableStyles = Module.getAvailableStyles;
Application.getGlobalStyles = Module.getGlobalStyles;
Application.setGlobalStyles = Module.setGlobalStyles;
Application.getAvailableStyles = Module.getAvailableStyles;
var body = options.newsletter.body;
var globalStyles = (_.has(body, 'globalStyles')) ? body.globalStyles : {};

View File

@ -46,8 +46,8 @@ tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
// Open window
editor.windowManager.open({
height: parseInt(editor.getParam("plugin_mailpoet_shortcodes_height", 400)),
width: parseInt(editor.getParam("plugin_mailpoet_shortcodes_width", 450)),
height: parseInt(editor.getParam('plugin_mailpoet_shortcodes_height', 400)),
width: parseInt(editor.getParam('plugin_mailpoet_shortcodes_width', 450)),
autoScroll: true,
title: editor.settings.mailpoet_shortcodes_window_title,
body: shortcodes,

View File

@ -1,27 +0,0 @@
/**
* A sample implementation of template widgets.
* A draggable widget, on drop creates a container with (image|text) block.
*/
ImageAndTextTemplateWidgetView = EditorApplication.module('blocks.base').WidgetView.extend({
getTemplate: function() { return templates.imageAndTextInsertion; },
className: 'mailpoet_droppable_block mailpoet_droppable_widget',
behaviors: {
DraggableBehavior: {
drop: function() {
return new (EditorApplication.getBlockTypeModel('container'))({
type: 'container',
orientation: 'horizontal',
blocks: [
{
type: 'image'
},
{
type: 'text',
text: 'Some random text'
}
]
}, {parse: true});
}
}
}
});

View File

@ -41,7 +41,7 @@ define(
render: function () {
const steps = this.state.steps.map((step, index) => {
const stepClasses = classNames(
{ 'mailpoet_current': (this.props.step === step.name) }
{ mailpoet_current: (this.props.step === step.name) }
);
let label = step.label;

View File

@ -69,7 +69,7 @@ const _QueueMixin = {
}
const progressClasses = classNames(
'mailpoet_progress',
{ 'mailpoet_progress_complete': newsletter.queue.status === 'completed' }
{ mailpoet_progress_complete: newsletter.queue.status === 'completed' }
);
// calculate percentage done
@ -84,8 +84,8 @@ const _QueueMixin = {
<span>
{
MailPoet.I18n.t('newsletterQueueCompleted')
.replace("%$1d", newsletter.queue.count_processed)
.replace("%$2d", newsletter.queue.count_total)
.replace('%$1d', newsletter.queue.count_processed)
.replace('%$2d', newsletter.queue.count_total)
}
</span>
);
@ -120,19 +120,19 @@ const _QueueMixin = {
percentage = MailPoet.I18n.t('noSubscribers');
} else {
progress_bar_width = percentage;
percentage += "%";
percentage += '%';
}
return (
<div>
<div className={ progressClasses }>
<span
className="mailpoet_progress_bar"
style={ { width: progress_bar_width + "%" } }
<span
className="mailpoet_progress_bar"
style={ { width: progress_bar_width + '%' } }
></span>
<span className="mailpoet_progress_label">
{ percentage }
</span>
<span className="mailpoet_progress_label">
{ percentage }
</span>
</div>
<p style={{ textAlign:'center' }}>
{ label }
@ -145,13 +145,14 @@ const _QueueMixin = {
const _StatisticsMixin = {
renderStatistics: function (newsletter, is_sent, current_time) {
if (is_sent === undefined) {
let sent = is_sent;
if (sent === undefined) {
// condition for standard and post notification listings
is_sent = newsletter.statistics
sent = newsletter.statistics
&& newsletter.queue
&& newsletter.queue.status !== 'scheduled';
}
if (!is_sent) {
if (!sent) {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
);
@ -238,7 +239,7 @@ const _StatisticsMixin = {
<div>
<span className="mailpoet_stats_text">
{ percentage_opened_display }%,
{ " " }
{ ' ' }
{ percentage_clicked_display }%
<span className="mailpoet_stat_hidden">
, { percentage_unsubscribed_display }%
@ -326,7 +327,7 @@ const _MailerMixin = {
MailPoet.I18n.t('mailerCheckSettingsNotice'),
/\[link\](.*?)\[\/link\]/g,
match => (
<a href={`?page=mailpoet-settings#mta`}>{ match }</a>
<a href={'?page=mailpoet-settings#mta'} key="check-sending">{ match }</a>
)
);
if (state.meta.mta_log.error.operation === 'send') {
@ -345,8 +346,8 @@ const _MailerMixin = {
<p>{ mailer_check_settings_notice }</p>
<p>
<a href="javascript:;"
className="button"
onClick={ this.resumeMailerSending }
className="button"
onClick={ this.resumeMailerSending }
>{ MailPoet.I18n.t('mailerResumeSendingButton') }</a>
</p>
</div>
@ -373,8 +374,6 @@ const _MailerMixin = {
};
export { _QueueMixin as QueueMixin };
export { _StatisticsMixin as StatisticsMixin };
export { _MailerMixin as MailerMixin };

View File

@ -317,7 +317,7 @@ const NewsletterListNotification = React.createClass({
<ListingTabs tab="notification" />
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
endpoint="newsletters"

View File

@ -110,7 +110,7 @@ const NewsletterListNotificationHistory = React.createClass({
>{MailPoet.I18n.t('backToPostNotifications')}</Link>
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
endpoint="newsletters"

View File

@ -97,6 +97,17 @@ const bulk_actions = [
},
];
const confirmEdit = (newsletter) => {
if(
!newsletter.queue
|| newsletter.status != 'sending'
|| newsletter.queue.status !== null
|| window.confirm(MailPoet.I18n.t('confirmEdit'))
) {
window.location.href = `?page=mailpoet-newsletter-editor&id=${ newsletter.id }`;
}
};
let newsletter_actions = [
{
name: 'view',
@ -110,13 +121,8 @@ let newsletter_actions = [
},
{
name: 'edit',
link: function (newsletter) {
return (
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
{MailPoet.I18n.t('edit')}
</a>
);
},
label: MailPoet.I18n.t('edit'),
onClick: confirmEdit,
},
{
name: 'duplicate',
@ -172,7 +178,8 @@ const NewsletterListStandard = React.createClass({
<strong>
<a
className="row-title"
href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }
href="javascript:;"
onClick={() => confirmEdit(newsletter)}
>{ newsletter.queue.newsletter_rendered_subject || newsletter.subject }</a>
</strong>
{ actions }
@ -198,13 +205,20 @@ const NewsletterListStandard = React.createClass({
return (
<div>
<h1 className="title">
{MailPoet.I18n.t('pageTitle')} <Link className="page-title-action" to="/new">{MailPoet.I18n.t('new')}</Link>
{MailPoet.I18n.t('pageTitle')}
<Link className="page-title-action" to="/new"
onClick={() => MailPoet.trackEvent('Emails > Add New',
{ 'MailPoet Free version': window.mailpoet_version }
)}
>
{MailPoet.I18n.t('new')}
</Link>
</h1>
<ListingTabs tab="standard" />
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
endpoint="newsletters"

View File

@ -38,6 +38,9 @@ const ListingTabs = React.createClass({
key={ 'tab-'+index }
className={ tabClasses }
to={ tab.link }
onClick={() => MailPoet.trackEvent(`Tab Emails > ${tab.name} clicked`,
{ 'MailPoet Free version': window.mailpoet_version }
)}
>{ tab.label }</Link>
);
});

View File

@ -295,7 +295,7 @@ const NewsletterListWelcome = React.createClass({
<ListingTabs tab="welcome" />
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
endpoint="newsletters"

View File

@ -5,18 +5,18 @@ const timeFormat = window.mailpoet_time_format || 'H:i';
// welcome emails
const _timeDelayValues = {
'immediate': MailPoet.I18n.t('delayImmediately'),
'hours': MailPoet.I18n.t('delayHoursAfter'),
'days': MailPoet.I18n.t('delayDaysAfter'),
'weeks': MailPoet.I18n.t('delayWeeksAfter'),
immediate: MailPoet.I18n.t('delayImmediately'),
hours: MailPoet.I18n.t('delayHoursAfter'),
days: MailPoet.I18n.t('delayDaysAfter'),
weeks: MailPoet.I18n.t('delayWeeksAfter'),
};
const _intervalValues = {
'daily': MailPoet.I18n.t('daily'),
'weekly': MailPoet.I18n.t('weekly'),
'monthly': MailPoet.I18n.t('monthly'),
'nthWeekDay': MailPoet.I18n.t('monthlyEvery'),
'immediately': MailPoet.I18n.t('immediately'),
daily: MailPoet.I18n.t('daily'),
weekly: MailPoet.I18n.t('weekly'),
monthly: MailPoet.I18n.t('monthly'),
nthWeekDay: MailPoet.I18n.t('monthlyEvery'),
immediately: MailPoet.I18n.t('immediately'),
};
// notification emails
@ -60,7 +60,7 @@ const _monthDayValues = _.object(
if (labels[day] !== undefined) {
label = labels[day];
} else {
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
label = MailPoet.I18n.t('nth').replace('%$1d', day + 1);
}
return [day + 1, label];
}
@ -68,10 +68,10 @@ const _monthDayValues = _.object(
);
const _nthWeekDayValues = {
'1': MailPoet.I18n.t('first'),
'2': MailPoet.I18n.t('second'),
'3': MailPoet.I18n.t('third'),
'L': MailPoet.I18n.t('last'),
1: MailPoet.I18n.t('first'),
2: MailPoet.I18n.t('second'),
3: MailPoet.I18n.t('third'),
L: MailPoet.I18n.t('last'),
};
export { _timeDelayValues as timeDelayValues };

View File

@ -9,6 +9,8 @@ define(
'newsletters/send/notification.jsx',
'newsletters/send/welcome.jsx',
'newsletters/breadcrumb.jsx',
'help-tooltip.jsx',
'jquery',
],
(
React,
@ -19,7 +21,9 @@ define(
StandardNewsletterFields,
NotificationNewsletterFields,
WelcomeNewsletterFields,
Breadcrumb
Breadcrumb,
HelpTooltip,
jQuery
) => {
const NewsletterSend = React.createClass({
@ -108,16 +112,25 @@ define(
}).done((response) => {
// redirect to listing based on newsletter type
this.context.router.push(`/${ this.state.item.type || '' }`);
const opts = this.state.item.options;
// display success message depending on newsletter type
if (response.data.type === 'welcome') {
MailPoet.Notice.success(
MailPoet.I18n.t('welcomeEmailActivated')
);
MailPoet.trackEvent('Emails > Welcome email activated', {
'MailPoet Free version': window.mailpoet_version,
'List type': opts.event,
Delay: opts.afterTimeNumber + ' ' + opts.afterTimeType,
});
} else if (response.data.type === 'notification') {
MailPoet.Notice.success(
MailPoet.I18n.t('postNotificationActivated')
);
MailPoet.trackEvent('Emails > Post notifications activated', {
'MailPoet Free version': window.mailpoet_version,
Frequency: opts.intervalType,
});
}
}).fail(this._showError);
default:
@ -136,14 +149,60 @@ define(
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterHasBeenScheduled')
);
MailPoet.trackEvent('Emails > Newsletter sent', {
scheduled: true,
'MailPoet Free version': window.mailpoet_version,
});
} else {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterBeingSent')
);
MailPoet.trackEvent('Emails > Newsletter sent', {
scheduled: false,
'MailPoet Free version': window.mailpoet_version,
});
}
}).fail(this._showError);
}
}).fail(this._showError).always(() => {
})
.fail(this._showError)
.always(() => {
this.setState({ loading: false });
});
}
return false;
},
handleResume: function (e) {
e.preventDefault();
if(!this.isValid()) {
jQuery('#mailpoet_newsletter').parsley().validate();
} else {
this._save(e).done(() => {
this.setState({ loading: true });
}).done(() => {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
action: 'resume',
data: {
newsletter_id: this.state.item.id,
},
}).done(() => {
this.context.router.push(`/${ this.state.item.type || '' }`);
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterSendingHasBeenResumed')
);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
})
.fail(this._showError)
.always(() => {
this.setState({ loading: false });
});
}
@ -174,6 +233,7 @@ define(
},
_save: function () {
const data = this.state.item;
data.queue = undefined;
this.setState({ loading: true });
// Store only properties that can be changed on this page
@ -215,6 +275,16 @@ define(
return true;
},
render: function () {
const isPaused = this.state.item.status == 'sending'
&& this.state.item.queue
&& this.state.item.queue.status == 'paused';
const fields = this.state.fields.map((field) => {
const newField = field;
if (field.name == 'segments' || field.name == 'options') {
newField.disabled = isPaused;
}
return newField;
});
return (
<div>
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>
@ -223,20 +293,29 @@ define(
<Form
id="mailpoet_newsletter"
fields={ this.state.fields }
fields={ fields }
item={ this.state.item }
loading={ this.state.loading }
onChange={this.handleFormChange}
onSubmit={this.handleSave}
>
<p className="submit">
<input
className="button button-primary"
type="button"
onClick={ this.handleSend }
value={MailPoet.I18n.t('send')}
{...this.getSendButtonOptions()}
{
isPaused ?
<input
className="button button-primary"
type="button"
onClick={ this.handleResume }
value={MailPoet.I18n.t('resume')} />
:
<input
className="button button-primary"
type="button"
onClick={ this.handleSend }
value={MailPoet.I18n.t('send')}
{...this.getSendButtonOptions()}
/>
}
&nbsp;
<input
className="button button-secondary"
@ -251,6 +330,10 @@ define(
{MailPoet.I18n.t('goBackToDesign')}
</a>.
</p>
<HelpTooltip
tooltip={MailPoet.I18n.t('helpTooltipSendEmail')}
tooltipId="helpTooltipSendEmail"
/>
</Form>
</div>
);

View File

@ -8,12 +8,14 @@ define(
],
(
React,
jQuery,
jq,
_,
MailPoet,
Hooks
) => {
const jQuery = jq;
const currentTime = window.mailpoet_current_time || '00:00';
const defaultDateTime = window.mailpoet_current_date + ' ' + '00:00:00';
const timeOfDayItems = window.mailpoet_schedule_time_of_day;
@ -84,12 +86,13 @@ define(
const DateText = React.createClass({
onChange: function (event) {
const changeEvent = event;
// Swap display format to storage format
const displayDate = event.target.value;
const displayDate = changeEvent.target.value;
const storageDate = this.getStorageDate(displayDate);
event.target.value = storageDate;
this.props.onChange(event);
changeEvent.target.value = storageDate;
this.props.onChange(changeEvent);
},
componentDidMount: function () {
const $element = jQuery(this.refs.dateInput);
@ -155,6 +158,7 @@ define(
name={this.getFieldName()}
value={this.getDisplayDate(this.props.value)}
readOnly={ true }
disabled={this.props.disabled}
onChange={this.onChange}
ref="dateInput"
{...this.props.validation} />
@ -180,6 +184,7 @@ define(
<select
name={this.props.name || 'time'}
value={this.props.value}
disabled={this.props.disabled}
onChange={this.props.onChange}
{...this.props.validation}
>
@ -190,7 +195,7 @@ define(
});
const DateTime = React.createClass({
_DATE_TIME_SEPARATOR: " ",
_DATE_TIME_SEPARATOR: ' ',
getInitialState: function () {
return this._buildStateFromProps(this.props);
},
@ -235,11 +240,13 @@ define(
onChange={this.handleChange}
displayFormat={dateDisplayFormat}
storageFormat={dateStorageFormat}
disabled={this.props.disabled}
validation={this.props.dateValidation}/>
<TimeSelect
name="time"
value={this.state.time}
onChange={this.handleChange}
disabled={this.props.disabled}
validation={this.props.timeValidation} />
</span>
);
@ -269,8 +276,9 @@ define(
});
},
handleCheckboxChange: function (event) {
event.target.value = this.refs.isScheduled.checked ? '1' : '0';
return this.handleValueChange(event);
const changeEvent = event;
changeEvent.target.value = this.refs.isScheduled.checked ? '1' : '0';
return this.handleValueChange(changeEvent);
},
isScheduled: function () {
return this._getCurrentValue().isScheduled === '1';
@ -292,6 +300,7 @@ define(
name="scheduledAt"
value={this._getCurrentValue().scheduledAt}
onChange={this.handleValueChange}
disabled={this.props.field.disabled}
dateValidation={this.getDateValidation()} />
&nbsp;
<span>
@ -300,7 +309,6 @@ define(
</span>
);
}
return (
<div>
<input
@ -308,6 +316,7 @@ define(
type="checkbox"
value="1"
checked={this.isScheduled()}
disabled={this.props.field.disabled}
name="isScheduled"
onChange={this.handleCheckboxChange} />
@ -414,11 +423,11 @@ define(
return fields;
},
getSendButtonOptions: function (newsletter) {
newsletter = newsletter || {};
const newsletterOptions = newsletter || {};
const isScheduled = (
typeof newsletter.options === 'object'
&& newsletter.options.isScheduled === '1'
typeof newsletterOptions.options === 'object'
&& newsletterOptions.options.isScheduled === '1'
);
const options = {
value: (isScheduled
@ -426,8 +435,8 @@ define(
: MailPoet.I18n.t('send')),
};
if (newsletter.status === 'sent'
|| newsletter.status === 'sending') {
if (newsletterOptions.status === 'sent'
|| newsletterOptions.status === 'sending') {
options['disabled'] = 'disabled';
}

View File

@ -6,6 +6,7 @@ define(
'react-router',
'classnames',
'newsletters/breadcrumb.jsx',
'help-tooltip.jsx',
],
(
React,
@ -13,11 +14,13 @@ define(
MailPoet,
Router,
classNames,
Breadcrumb
Breadcrumb,
HelpTooltip
) => {
const ImportTemplate = React.createClass({
saveTemplate: function (template) {
saveTemplate: function (saveTemplate) {
const template = saveTemplate;
// Stringify to enable transmission of primitive non-string value types
if (!_.isUndefined(template.body)) {
@ -49,6 +52,7 @@ define(
if (_.size(this.refs.templateFile.files) <= 0) return false;
const file = _.first(this.refs.templateFile.files);
const reader = new FileReader();
const saveTemplate = this.saveTemplate;
@ -56,6 +60,9 @@ define(
reader.onload = (e) => {
try {
saveTemplate(JSON.parse(e.target.result));
MailPoet.trackEvent('Emails > Template imported', {
'MailPoet Free version': window.mailpoet_version,
});
} catch (err) {
MailPoet.Notice.error(MailPoet.I18n.t('templateFileMalformedError'));
}
@ -66,10 +73,13 @@ define(
render: function () {
return (
<div>
<h2>{MailPoet.I18n.t('importTemplateTitle')}</h2>
<h2>{MailPoet.I18n.t('importTemplateTitle')} <HelpTooltip
tooltip={MailPoet.I18n.t('helpTooltipTemplateUpload')}
place="right"
className="tooltip-help-import-template"
/></h2>
<form onSubmit={this.handleSubmit}>
<input type="file" placeholder={MailPoet.I18n.t('selectJsonFileToUpload')} ref="templateFile" />
<p className="submit">
<input
className="button button-primary"
@ -112,7 +122,7 @@ define(
MailPoet.I18n.t('mailpoetGuideTemplateTitle'),
description:
MailPoet.I18n.t('mailpoetGuideTemplateDescription'),
readonly: "1",
readonly: '1',
},
];
}
@ -138,6 +148,11 @@ define(
body = JSON.stringify(body);
}
MailPoet.trackEvent('Emails > Template selected', {
'MailPoet Free version': window.mailpoet_version,
'Email name': template.name,
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -164,7 +179,7 @@ define(
window.confirm(
(
MailPoet.I18n.t('confirmTemplateDeletion')
).replace("%$1s", template.name)
).replace('%$1s', template.name)
)
) {
MailPoet.Ajax.post({
@ -229,26 +244,26 @@ define(
</div>
<div className="mailpoet_description">
<h3>{ template.name }</h3>
<p>{ template.description }</p>
<h3>{ template.name }</h3>
<p>{ template.description }</p>
</div>
<div className="mailpoet_actions">
<a
className="button button-secondary"
onClick={ this.handleShowTemplate.bind(null, template) }
<a
className="button button-secondary"
onClick={ this.handleShowTemplate.bind(null, template) }
>
{MailPoet.I18n.t('preview')}
</a>
{MailPoet.I18n.t('preview')}
</a>
&nbsp;
<a
className="button button-primary"
onClick={ this.handleSelectTemplate.bind(null, template) }
<a
className="button button-primary"
onClick={ this.handleSelectTemplate.bind(null, template) }
>
{MailPoet.I18n.t('select')}
</a>
{MailPoet.I18n.t('select')}
</a>
</div>
{ (template.readonly === "1") ? false : deleteLink }
{ (template.readonly === '1') ? false : deleteLink }
</li>
);
});
@ -256,7 +271,7 @@ define(
const boxClasses = classNames(
'mailpoet_boxes',
'clearfix',
{ 'mailpoet_boxes_loading': this.state.loading }
{ mailpoet_boxes_loading: this.state.loading }
);
return (

View File

@ -20,9 +20,17 @@ define(
setupNewsletter: function (type) {
if(type !== undefined) {
this.context.router.push(`/new/${type}`);
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,
'Email type': type,
});
}
},
createNewsletter: function (type) {
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,
'Email type': type,
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -45,10 +53,10 @@ define(
render: function () {
let types = [
{
'id': 'standard',
'title': MailPoet.I18n.t('regularNewsletterTypeTitle'),
'description': MailPoet.I18n.t('regularNewsletterTypeDescription'),
'action': function () {
id: 'standard',
title: MailPoet.I18n.t('regularNewsletterTypeTitle'),
description: MailPoet.I18n.t('regularNewsletterTypeDescription'),
action: function () {
return (
<a className="button button-primary" onClick={ this.createNewsletter.bind(null, 'standard') }>
{MailPoet.I18n.t('create')}
@ -57,10 +65,10 @@ define(
}.bind(this)(),
},
{
'id': 'welcome',
'title': MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
'description': MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
'action': function () {
id: 'welcome',
title: MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
description: MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
action: function () {
return (
<div>
<a href="?page=mailpoet-premium" target="_blank">
@ -71,10 +79,10 @@ define(
}(),
},
{
'id': 'notification',
'title': MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
'description': MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
'action': function () {
id: 'notification',
title: MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
description: MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
action: function () {
return (
<a className="button button-primary" onClick={ this.setupNewsletter.bind(null, 'notification') }>
{MailPoet.I18n.t('setUp')}

View File

@ -16,8 +16,8 @@ const availableSegments = _.filter(
const events = {
name: 'event',
values: {
'segment': MailPoet.I18n.t('onSubscriptionToList'),
'user': MailPoet.I18n.t('onWPUserRegistration'),
segment: MailPoet.I18n.t('onSubscriptionToList'),
user: MailPoet.I18n.t('onWPUserRegistration'),
},
};

View File

@ -1,5 +1,6 @@
define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
"use strict";
define('notice', ['mailpoet', 'jquery'], function(mp, jQuery) {
'use strict';
/*==================================================================================================
MailPoet Notice:
@ -22,7 +23,7 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
MailPoet.Notice.system('You need to updated ASAP!');
==================================================================================================*/
var MailPoet = mp;
MailPoet.Notice = {
version: 1.0,
// default options
@ -74,7 +75,7 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
// setup onClose callback
var onClose = null;
if (this.options.onClose !== null) {
onClose = this.options.onClose;
onClose = this.options.onClose;
}
// listen to remove event
@ -82,7 +83,7 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
jQuery(this).fadeOut(200, function() {
// on close callback
if (onClose !== null) {
onClose();
onClose();
}
// remove notice
jQuery(this).remove();
@ -103,12 +104,12 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
);
},
setMessage: function(message) {
message = this.formatMessage(message);
var formattedMessage = this.formatMessage(message);
// let's sugar coat the message with a fancy <p>
message = '<p>'+message+'</p>';
formattedMessage = '<p>'+formattedMessage+'</p>';
// set message
return this.element.html(message);
return this.element.html(formattedMessage);
},
formatMessage: function(message) {
if (Array.isArray(message)) {
@ -124,7 +125,7 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
if (
this.options.id !== null
&&
jQuery('[data-id="'+this.options.id+'"').length > 0
jQuery('[data-id="'+this.options.id+'"]').length > 0
) {
this.updateNotice();
} else {
@ -143,13 +144,13 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
switch (this.options.type) {
case 'success':
this.element.addClass('notice notice-success');
break;
break;
case 'system':
this.element.addClass('notice notice-warning');
break;
break;
case 'error':
this.element.addClass('notice notice-error');
break;
break;
}
// make the notice appear
@ -166,7 +167,7 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
} else if (this.options.hideClose === false) {
this.element.append('<a href="javascript:;" class="mailpoet_notice_close"><span class="dashicons dashicons-dismiss"></span></a>');
this.element.find('.mailpoet_notice_close').on('click', function() {
jQuery(this).trigger('close');
jQuery(this).trigger('close');
});
}

View File

@ -2,20 +2,21 @@ define('num',
[
'mailpoet'
], function(
MailPoet
mp
) {
'use strict';
'use strict';
MailPoet.Num = {
toLocaleFixed: function (num, precision) {
precision = precision || 0;
var factor = Math.pow(10, precision);
return (Math.round(num * factor) / factor)
var MailPoet = mp;
MailPoet.Num = {
toLocaleFixed: function (num, precisionOpts) {
var precision = precisionOpts || 0;
var factor = Math.pow(10, precision);
return (Math.round(num * factor) / factor)
.toLocaleString(
undefined,
{minimumFractionDigits: precision, maximumFractionDigits: precision}
);
}
};
}
};
});
});

View File

@ -1,87 +1,87 @@
define([
'mailpoet',
'jquery',
'parsleyjs'
],
function(
MailPoet,
jQuery,
Parsley
) {
jQuery(function($) {
function isSameDomain(url) {
var link = document.createElement('a');
link.href = url;
return (window.location.hostname === link.hostname);
}
$(function() {
// setup form validation
$('form.mailpoet_form').each(function() {
var form = $(this);
form.parsley().on('form:validated', function(parsley) {
// clear messages
form.find('.mailpoet_message > p').hide();
// resize iframe
if(window.frameElement !== null) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});
form.parsley().on('form:submit', function(parsley) {
var form_data = form.serializeObject() || {};
// check if we're on the same domain
if(isSameDomain(MailPoetForm.ajax_url) === false) {
// non ajax post request
return true;
} else {
// ajax request
MailPoet.Ajax.post({
url: MailPoetForm.ajax_url,
token: form_data.token,
api_version: form_data.api_version,
endpoint: 'subscribers',
action: 'subscribe',
data: form_data.data
}).fail(function(response) {
form.find('.mailpoet_validate_error').html(
response.errors.map(function(error) {
return error.message;
}).join('<br />')
).show();
}).done(function(response) {
// successfully subscribed
if (
response.meta !== undefined
&& response.meta.redirect_url !== undefined
) {
// go to page
window.location.href = response.meta.redirect_url;
} else {
// display success message
form.find('.mailpoet_validate_success').show();
}
// reset form
form.trigger('reset');
// reset validation
parsley.reset();
// resize iframe
if (
window.frameElement !== null
&& MailPoet !== undefined
&& MailPoet['Iframe']
) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});
}
return false;
});
});
});
});
define([
'mailpoet',
'jquery',
'parsleyjs'
],
function(
MailPoet,
jQuery,
Parsley
) {
jQuery(function($) {
function isSameDomain(url) {
var link = document.createElement('a');
link.href = url;
return (window.location.hostname === link.hostname);
}
$(function() {
// setup form validation
$('form.mailpoet_form').each(function() {
var form = $(this);
form.parsley().on('form:validated', function(parsley) {
// clear messages
form.find('.mailpoet_message > p').hide();
// resize iframe
if(window.frameElement !== null) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});
form.parsley().on('form:submit', function(parsley) {
var form_data = form.serializeObject() || {};
// check if we're on the same domain
if(isSameDomain(window.MailPoetForm.ajax_url) === false) {
// non ajax post request
return true;
} else {
// ajax request
MailPoet.Ajax.post({
url: window.MailPoetForm.ajax_url,
token: form_data.token,
api_version: form_data.api_version,
endpoint: 'subscribers',
action: 'subscribe',
data: form_data.data
}).fail(function(response) {
form.find('.mailpoet_validate_error').html(
response.errors.map(function(error) {
return error.message;
}).join('<br />')
).show();
}).done(function(response) {
// successfully subscribed
if (
response.meta !== undefined
&& response.meta.redirect_url !== undefined
) {
// go to page
window.location.href = response.meta.redirect_url;
} else {
// display success message
form.find('.mailpoet_validate_success').show();
}
// reset form
form.trigger('reset');
// reset validation
parsley.reset();
// resize iframe
if (
window.frameElement !== null
&& MailPoet !== undefined
&& MailPoet['Iframe']
) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});
}
return false;
});
});
});
});
});

View File

@ -32,6 +32,9 @@ define(
},
onCreate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('segmentAdded'));
MailPoet.trackEvent('Lists > Add new', {
'MailPoet Free version': window.mailpoet_version,
});
},
};

View File

@ -258,7 +258,7 @@ const SegmentList = React.createClass({
</h1>
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
messages={ messages }

View File

@ -15,9 +15,9 @@ define(
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
'api_version': window.mailpoet_api_version,
'endpoint': 'setup',
'action': 'reset'
api_version: window.mailpoet_api_version,
endpoint: 'setup',
action: 'reset'
}).always(function () {
MailPoet.Modal.loading(false);
}).done(function () {

View File

@ -7,8 +7,9 @@ define(
function(
Backbone,
jQuery,
MailPoet
mp
) {
var MailPoet = mp;
if(jQuery('#mailpoet_settings').length === 0) {
return;
}
@ -50,9 +51,9 @@ define(
jQuery('#mailpoet_sending_method_setup').fadeIn();
}
},
tabs: function(tab, section) {
tabs: function(tabStr, section) {
// set default tab
tab = tab || 'mta';
var tab = tabStr || 'mta';
// reset all active tabs
jQuery('.nav-tab-wrapper a').removeClass('nav-tab-active');

View File

@ -43,10 +43,10 @@ define(
label: MailPoet.I18n.t('status'),
type: 'select',
values: {
'subscribed': MailPoet.I18n.t('subscribed'),
'unconfirmed': MailPoet.I18n.t('unconfirmed'),
'unsubscribed': MailPoet.I18n.t('unsubscribed'),
'bounced': MailPoet.I18n.t('bounced'),
subscribed: MailPoet.I18n.t('subscribed'),
unconfirmed: MailPoet.I18n.t('unconfirmed'),
unsubscribed: MailPoet.I18n.t('unsubscribed'),
bounced: MailPoet.I18n.t('bounced'),
},
filter: function (subscriber, value) {
if (~~(subscriber.wp_user_id) > 0 && value === 'unconfirmed') {
@ -144,6 +144,9 @@ define(
},
onCreate: function () {
MailPoet.Notice.success(MailPoet.I18n.t('subscriberAdded'));
MailPoet.trackEvent('Subscribers > Add new', {
'MailPoet Free version': window.mailpoet_version,
});
},
};

View File

@ -1,44 +1,44 @@
define(
[
'underscore',
'jquery',
'mailpoet',
'handlebars',
'select2'
],
[
'underscore',
'jquery',
'mailpoet',
'handlebars',
'select2'
],
function (
_,
jQuery,
MailPoet,
Handlebars,
select2
_,
jQuery,
MailPoet,
Handlebars,
select2
) {
if (!jQuery("#mailpoet_subscribers_export").length) {
if (!jQuery('#mailpoet_subscribers_export').length) {
return;
}
jQuery(document).ready(function () {
if (!exportData.segments) {
if (!window.exportData.segments) {
return;
}
var subscribers_export_template =
Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
//render template
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribers_export_template(exportData));
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribers_export_template(window.exportData));
// define reusable variables
var segmentsContainerElement = jQuery("#export_lists"),
subscriberFieldsContainerElement = jQuery("#export_columns"),
exportConfirmedOptionElement = jQuery(':radio[name="option_confirmed"]'),
groupBySegmentOptionElement = jQuery(':checkbox[name="option_group_by_list"]'),
nextStepButton = jQuery("a.mailpoet_export_process"),
renderSegmentsAndFields = function (container, data) {
if (container.data('select2')) {
container
var segmentsContainerElement = jQuery('#export_lists'),
subscriberFieldsContainerElement = jQuery('#export_columns'),
exportConfirmedOptionElement = jQuery(':radio[name="option_confirmed"]'),
groupBySegmentOptionElement = jQuery(':checkbox[name="option_group_by_list"]'),
nextStepButton = jQuery('a.mailpoet_export_process'),
renderSegmentsAndFields = function (container, data) {
if (container.data('select2')) {
container
.html('')
.select2('destroy');
}
container
}
container
.select2({
data: data,
width: '20em',
@ -55,11 +55,11 @@ define(
})
.on('select2:selecting', function (selectEvent) {
var selectElement = this,
selectedOptionId = selectEvent.params.args.data.id,
fieldsToExclude = [
'select',
'deselect'
];
selectedOptionId = selectEvent.params.args.data.id,
fieldsToExclude = [
'select',
'deselect'
];
if (_.contains(fieldsToExclude, selectedOptionId)) {
selectEvent.preventDefault();
if (selectedOptionId === 'deselect') {
@ -77,9 +77,9 @@ define(
}
})
.on('change', function () {
if ((exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
if ((window.exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
||
(!exportData.segments && subscriberFieldsContainerElement.select2('data').length)
(!window.exportData.segments && subscriberFieldsContainerElement.select2('data').length)
) {
toggleNextStepButton('on');
}
@ -87,37 +87,37 @@ define(
toggleNextStepButton('off');
}
if (segmentsContainerElement.select2('data').length > 1 && exportData.groupBySegmentOption) {
if (segmentsContainerElement.select2('data').length > 1 && window.exportData.groupBySegmentOption) {
jQuery('.mailpoet_group_by_list').show();
}
else if (exportData.groupBySegmentOption) {
else if (window.exportData.groupBySegmentOption) {
jQuery('.mailpoet_group_by_list').hide();
}
});
};
};
// set confirmed subscribers export option to false
exportData.exportConfirmedOption = false;
window.exportData.exportConfirmedOption = false;
renderSegmentsAndFields(subscriberFieldsContainerElement, subscriberFieldsSelect2);
renderSegmentsAndFields(segmentsContainerElement, segments);
renderSegmentsAndFields(subscriberFieldsContainerElement, window.subscriberFieldsSelect2);
renderSegmentsAndFields(segmentsContainerElement, window.segments);
subscriberFieldsContainerElement.val([
'email',
'first_name',
'last_name',
'status'
]).trigger("change");
]).trigger('change');
exportConfirmedOptionElement.change(function () {
var selectedSegments = segmentsContainerElement.val();
if (this.value == 1) {
exportData.exportConfirmedOption = true;
renderSegmentsAndFields(segmentsContainerElement, segmentsWithConfirmedSubscribers);
window.exportData.exportConfirmedOption = true;
renderSegmentsAndFields(segmentsContainerElement, window.segmentsWithConfirmedSubscribers);
}
else {
exportData.exportConfirmedOption = false;
renderSegmentsAndFields(segmentsContainerElement, segments);
window.exportData.exportConfirmedOption = false;
renderSegmentsAndFields(segmentsContainerElement, window.segments);
}
segmentsContainerElement.val(selectedSegments).trigger('change');
});
@ -137,34 +137,41 @@ define(
return;
}
MailPoet.Modal.loading(true);
var exportFormat = jQuery(':radio[name="option_format"]:checked').val();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processExport',
data: JSON.stringify({
'export_confirmed_option': exportData.exportConfirmedOption,
'export_format_option': jQuery(':radio[name="option_format"]:checked').val(),
'group_by_segment_option': (groupBySegmentOptionElement.is(":visible")) ? groupBySegmentOptionElement.prop('checked') : false,
'segments': (exportData.segments) ? segmentsContainerElement.val() : false,
'subscriber_fields': subscriberFieldsContainerElement.val()
})
}).always(function(response) {
MailPoet.Modal.loading(false);
}).done(function(response) {
resultMessage = MailPoet.I18n.t('exportMessage')
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
.replace('[/link]', '</a>');
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
window.location.href = response.data.exportFileURL;
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processExport',
data: JSON.stringify({
export_confirmed_option: window.exportData.exportConfirmedOption,
export_format_option: exportFormat,
group_by_segment_option: (groupBySegmentOptionElement.is(':visible')) ? groupBySegmentOptionElement.prop('checked') : false,
segments: (window.exportData.segments) ? segmentsContainerElement.val() : false,
subscriber_fields: subscriberFieldsContainerElement.val()
})
}).always(function(response) {
MailPoet.Modal.loading(false);
}).done(function(response) {
var resultMessage = MailPoet.I18n.t('exportMessage')
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
.replace('[/link]', '</a>');
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
window.location.href = response.data.exportFileURL;
MailPoet.trackEvent('Subscribers export completed', {
'Total exported': response.data.totalExported,
'Only confirmed?': window.exportData.exportConfirmedOption,
'File Format': exportFormat,
'MailPoet Free version': window.mailpoet_version
});
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
});
}
});
});
});
});

View File

@ -1,15 +1,15 @@
define(
[
'backbone',
'underscore',
'jquery',
'mailpoet',
'handlebars',
'papaparse',
'asyncqueue',
'moment',
'select2'
],
[
'backbone',
'underscore',
'jquery',
'mailpoet',
'handlebars',
'papaparse',
'asyncqueue',
'moment',
'select2'
],
function (
Backbone,
_,
@ -27,12 +27,12 @@ define(
jQuery(document).ready(function () {
jQuery('input[name="select_method"]').attr('checked', false);
// configure router
router = new (Backbone.Router.extend({
var router = new (Backbone.Router.extend({
routes: {
'': 'home',
'step1': 'step1',
'step2': 'step2',
'step3': 'step3'
step1: 'step1',
step2: 'step2',
step3: 'step3'
},
home: function () {
this.navigate('step1', {trigger: true});
@ -51,12 +51,13 @@ define(
*/
router.on('route:step1', function () {
// set or reset temporary validation rule on all columns
mailpoetColumns = jQuery.map(mailpoetColumns, function (column, columnIndex) {
column.validation_rule = false;
return column;
window.mailpoetColumns = jQuery.map(window.mailpoetColumns, function (column, columnIndex) {
var col = column;
col.validation_rule = false;
return col;
});
if (typeof (importData.step1) !== 'undefined') {
if (typeof (window.importData.step1) !== 'undefined') {
showCurrentStep();
return;
}
@ -68,21 +69,21 @@ define(
// define reusable variables
var currentStepE = jQuery(location.hash),
methodSelectionElement = jQuery('#select_method'),
pasteInputElement = jQuery('#paste_input'),
pasteInputPlaceholderElement =
methodSelectionElement = jQuery('#select_method'),
pasteInputElement = jQuery('#paste_input'),
pasteInputPlaceholderElement =
pasteInputElement.data('placeholder').replace(/\\n/g, '\n'),
pasteProcessButtonElement =
pasteProcessButtonElement =
jQuery('#method_paste > div.mailpoet_method_process')
.find('a.mailpoet_process'),
mailChimpKeyInputElement = jQuery('#mailchimp_key'),
mailChimpKeyVerifyButtonElement = jQuery('#mailchimp_key_verify'),
mailChimpListsContainerElement = jQuery('#mailchimp_lists'),
mailChimpProcessButtonElement =
mailChimpKeyInputElement = jQuery('#mailchimp_key'),
mailChimpKeyVerifyButtonElement = jQuery('#mailchimp_key_verify'),
mailChimpListsContainerElement = jQuery('#mailchimp_lists'),
mailChimpProcessButtonElement =
jQuery('#method_mailchimp > div.mailpoet_method_process')
.find('a.mailpoet_process'),
uploadElement = jQuery('#file_local'),
uploadProcessButtonElement =
uploadElement = jQuery('#file_local'),
uploadProcessButtonElement =
jQuery('#method_file > div.mailpoet_method_process')
.find('a.mailpoet_process');
@ -90,7 +91,7 @@ define(
methodSelectionElement.change(function () {
MailPoet.Notice.hide();
var available_methods = jQuery(':radio[name="select_method"]'),
selected_method =
selected_method =
available_methods.index(available_methods.filter(':checked'));
// hide all methods
currentStepE.find('.inside')
@ -111,7 +112,7 @@ define(
* Paste
*/
pasteInputElement
.attr('value', pasteInputPlaceholderElement).css('color', "#999")
.attr('value', pasteInputPlaceholderElement).css('color', '#999')
.focus(function () {
if (jQuery(this).val() === pasteInputPlaceholderElement) {
jQuery(this).attr('value', '').css('color', '#222');
@ -119,7 +120,7 @@ define(
})
.blur(function () {
if (jQuery(this).val() === '') {
jQuery(this).attr('value', pasteInputPlaceholderElement).css('color', "#999");
jQuery(this).attr('value', pasteInputPlaceholderElement).css('color', '#999');
}
})
.keyup(function () {
@ -133,14 +134,14 @@ define(
MailPoet.Notice.hide();
// get an approximate size of textarea paste in bytes
var pasteSize = encodeURI(pasteInputElement.val()).split(/%..|./).length - 1;
if (pasteSize > maxPostSizeBytes) {
if (pasteSize > window.maxPostSizeBytes) {
MailPoet.Notice.error(MailPoet.I18n.t('maxPostSizeNotice'));
return;
}
// delay loading indicator for 10ms or else it's just too fast :)
MailPoet.Modal.loading(true);
setTimeout(function () {
Papa.parse(pasteInputElement.val(), parseCSV());
Papa.parse(pasteInputElement.val(), parseCSV(false));
}, 10);
});
@ -149,11 +150,11 @@ define(
*/
uploadElement.change(function () {
MailPoet.Notice.hide();
var ext = this.value.match(/\.(.+)$/);
if (ext === null || ext[1].toLowerCase() !== 'csv') {
this.value = '';
MailPoet.Notice.error(MailPoet.I18n.t('wrongFileFormat'));
}
var ext = this.value.match(/\.(.+)$/);
if (ext === null || ext[1].toLowerCase() !== 'csv') {
this.value = '';
MailPoet.Notice.error(MailPoet.I18n.t('wrongFileFormat'));
}
toggleNextStepButton(
uploadProcessButtonElement,
@ -167,8 +168,8 @@ define(
MailPoet.Modal.loading(true);
setTimeout(function () {
uploadElement.parse({
config: parseCSV()
})
config: parseCSV(true)
});
}, 10);
}
});
@ -236,7 +237,11 @@ define(
}).always(function(response) {
MailPoet.Modal.loading(false);
}).done(function(response) {
importData.step1 = response.data;
window.importData.step1 = response.data;
MailPoet.trackEvent('Subscribers import started', {
source: 'MailChimp',
'MailPoet Free version': window.mailpoet_version
});
router.navigate('step2', {trigger: true});
}).fail(function(response) {
if (response.errors.length > 0) {
@ -288,25 +293,25 @@ define(
element.closest('table a').addClass(disabled);
}
function parseCSV() {
function parseCSV(isFile) {
var processedSubscribers = [],
parsedEmails = [],
duplicateEmails = [],
invalidEmails = [],
emailColumnPosition = null,
columnCount = null,
isHeaderFound = false,
advancedOptionHeader = true,
advancedOptionDelimiter = '',
advancedOptionNewline = '',
advancedOptionComments = false,
parsedEmails = [],
duplicateEmails = [],
invalidEmails = [],
emailColumnPosition = null,
columnCount = null,
isHeaderFound = false,
advancedOptionHeader = true,
advancedOptionDelimiter = '',
advancedOptionNewline = '',
advancedOptionComments = false,
// trim spaces, commas, periods,
// single/double quotes and convert to lowercase
detectAndCleanupEmail = function (email) {
var test;
detectAndCleanupEmail = function (emailString) {
var test;
// decode HTML entities
email = jQuery('<div />').html(email).text();
email = email
var email = jQuery('<div />').html(emailString).text();
email = email
.toLowerCase()
// left/right trim spaces, punctuation (e.g., " 'email@email.com'; ")
// right trim non-printable characters (e.g., "email@email.com<6F>")
@ -315,20 +320,22 @@ define(
// remove urlencoded characters
.replace(/\s+|%\d+|,+/g, '');
// detect e-mails that will be otherwise rejected by email regex
if (test = /<(.*?)>/.exec(email)) {
test = /<(.*?)>/.exec(email);
if (test) {
// is the email inside angle brackets (e.g., 'some@email.com <some@email.com>')?
email = test[1].trim();
}
if (test = /mailto:(?:\s+)?(.*)/.exec(email)) {
email = test[1].trim();
}
test = /mailto:(?:\s+)?(.*)/.exec(email);
if (test) {
// is the email in 'mailto:email' format?
email = test[1].trim();
}
email = test[1].trim();
}
// test for valid characters using WP's rule (https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/formatting.php#L2902)
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email) ) {
return false;
}
return email;
};
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email) ) {
return false;
}
return email;
};
return {
skipEmptyLines: true,
@ -361,7 +368,7 @@ define(
for (var column in rowData) {
var email = detectAndCleanupEmail(rowData[column]);
if (emailColumnPosition === null
&& emailRegex.test(email)) {
&& window.emailRegex.test(email)) {
emailColumnPosition = column;
parsedEmails[email] = true; // add current e-mail to an object index
rowData[column] = email;
@ -375,12 +382,12 @@ define(
processedSubscribers[0] = rowData;
}
}
else if (rowData[emailColumnPosition] !== "") {
else if (rowData[emailColumnPosition] !== '') {
var email = detectAndCleanupEmail(rowData[emailColumnPosition]);
if (_.has(parsedEmails, email)) {
duplicateEmails.push(email);
}
else if (!emailRegex.test(email)) {
else if (!window.emailRegex.test(email)) {
invalidEmails.push(rowData[emailColumnPosition]);
}
// if we haven't yet processed this e-mail and it passed
@ -403,15 +410,19 @@ define(
) {
// since we assume that the header line is always present, we need
// to detect the header by checking if it contains a valid e-mail address
importData.step1 = {
'header': (!emailRegex.test(
window.importData.step1 = {
header: (!window.emailRegex.test(
processedSubscribers[0][emailColumnPosition])
) ? processedSubscribers.shift() : null,
'subscribers': processedSubscribers,
'subscribersCount': processedSubscribers.length,
'duplicate': duplicateEmails,
'invalid': invalidEmails
subscribers: processedSubscribers,
subscribersCount: processedSubscribers.length,
duplicate: duplicateEmails,
invalid: invalidEmails
};
MailPoet.trackEvent('Subscribers import started', {
source: isFile ? 'file upload' : 'pasted data',
'MailPoet Free version': window.mailpoet_version
});
router.navigate('step2', {trigger: true});
}
else {
@ -422,42 +433,42 @@ define(
MailPoet.Notice.error(errorNotice);
}
}
}
};
}
});
router.on('route:step2', function () {
if (typeof (importData.step1) === 'undefined') {
if (typeof (window.importData.step1) === 'undefined') {
router.navigate('step1', {trigger: true});
return;
}
// define reusable variables
var nextStepButton = jQuery('#step2_process'),
previousStepButton = jQuery('#return_to_step1'),
previousStepButton = jQuery('#return_to_step1'),
// create a copy of subscribers object for further manipulation
subscribers = jQuery.extend(true, {}, importData.step1),
subscribersDataTemplate =
subscribers = jQuery.extend(true, {}, window.importData.step1),
subscribersDataTemplate =
Handlebars
.compile(jQuery('#subscribers_data_template')
.html()),
subscribersDataTemplatePartial =
subscribersDataTemplatePartial =
Handlebars
.compile(jQuery('#subscribers_data_template_partial')
.html()),
subscribersDataParseResultsTemplate =
subscribersDataParseResultsTemplate =
Handlebars
.compile(jQuery('#subscribers_data_parse_results_template')
.html()),
segmentSelectElement = jQuery('#mailpoet_segments_select'),
maxRowsToShow = 10,
filler = '. . .',
segmentSelectElement = jQuery('#mailpoet_segments_select'),
maxRowsToShow = 10,
filler = '. . .',
// create an array of filler data with the same number of
// elements as in the subscribers' data row
fillerArray = Array.apply(
fillerArray = Array.apply(
null,
new Array(subscribers.subscribers[0].length)
).map(String.prototype.valueOf, filler),
fillerPosition;
fillerPosition;
showCurrentStep();
@ -509,13 +520,13 @@ define(
var details = jQuery('.mailpoet_subscribers_data_parse_results_details');
jQuery(details).toggle();
this.text =
(jQuery(details).is(":visible"))
(jQuery(details).is(':visible'))
? MailPoet.I18n.t('hideDetails')
: MailPoet.I18n.t('showDetails');
});
// show available segments
if (mailpoetSegments.length) {
if (window.mailpoetSegments.length) {
jQuery('.mailpoet_segments').show();
}
else {
@ -534,12 +545,14 @@ define(
data: segments,
width: '20em',
templateResult: function (item) {
item.subscriberCount = parseInt(item.subscriberCount);
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
var i = item;
i.subscriberCount = parseInt(i.subscriberCount, 10);
return i.name + ' (' + i.subscriberCount.toLocaleString() + ')';
},
templateSelection: function (item) {
item.subscriberCount = parseInt(item.subscriberCount);
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
var i = item;
i.subscriberCount = parseInt(i.subscriberCount, 10);
return i.name + ' (' + i.subscriberCount.toLocaleString() + ')';
}
})
.change(function () {
@ -560,14 +573,14 @@ define(
toggleNextStepButton('on');
}
}
})
});
}
jQuery('.mailpoet_create_segment').click(function() {
MailPoet.Modal.popup({
title: MailPoet.I18n.t('addNewList'),
template: jQuery('#new_segment_template').html()
})
});
jQuery('#new_segment_name').keypress(function(e) {
if (e.which == 13) {
jQuery('#new_segment_process').click();
@ -586,20 +599,20 @@ define(
description: segmentDescription
}
}).done(function(response) {
mailpoetSegments.push({
'id': response.data.id,
'name': response.data.name,
'subscriberCount': 0
window.mailpoetSegments.push({
id: response.data.id,
name: response.data.name,
subscriberCount: 0
});
var selected_values = segmentSelectElement.val();
if (selected_values === null) {
selected_values = [response.data.id]
selected_values = [response.data.id];
} else {
selected_values.push(response.data.id);
}
enableSegmentSelection(mailpoetSegments);
enableSegmentSelection(window.mailpoetSegments);
segmentSelectElement.val(selected_values).trigger('change');
jQuery('.mailpoet_segments:hidden').show();
jQuery('.mailpoet_no_segments:visible').hide();
@ -621,7 +634,7 @@ define(
// register partial template that will contain subscribers data
Handlebars.registerPartial(
"subscribers_data_template_partial",
'subscribers_data_template_partial',
subscribersDataTemplatePartial
);
@ -630,22 +643,22 @@ define(
'show_and_match_columns',
function (subscribers, options) {
var displayedColumns = [],
displayedColumnsIds = [];
displayedColumnsIds = [];
// go through all elements of the first row in subscribers data
for (var i in subscribers.subscribers[0]) {
var columnData = subscribers.subscribers[0][i],
columnId = 'ignore'; // set default column type
columnId = 'ignore'; // set default column type
// if the column is not undefined and has a valid e-mail, set type as email
if (columnData % 1 !== 0 && emailRegex.test(columnData)) {
if (columnData % 1 !== 0 && window.emailRegex.test(columnData)) {
columnId = 'email';
} else if (subscribers.header) {
var headerName = subscribers.header[i],
headerNameMatch = mailpoetColumns.map(function (el) {
return el.name;
}).indexOf(headerName);
headerNameMatch = window.mailpoetColumns.map(function (el) {
return el.name;
}).indexOf(headerName);
// set column type using header
if (headerNameMatch !== -1) {
columnId = mailpoetColumns[headerNameMatch].id;
columnId = window.mailpoetColumns[headerNameMatch].id;
}// set column type using header name
else if (headerName) {
if (/first|first name|given name/i.test(headerName)) {
@ -665,7 +678,7 @@ define(
&& displayedColumnsIds.indexOf(columnId) === -1)
? columnId
: 'ignore';
displayedColumns[i] = {'column_id': columnId};
displayedColumns[i] = {column_id: columnId};
displayedColumnsIds.push(columnId);
}
return options.fn(displayedColumns);
@ -710,7 +723,7 @@ define(
// filter displayed data
jQuery('select.mailpoet_subscribers_column_data_match')
.select2({
data: mailpoetColumnsSelect2,
data: window.mailpoetColumnsSelect2,
width: '15em',
templateResult: function (item) {
return item.name;
@ -721,7 +734,7 @@ define(
})
.on('select2:selecting', function (selectEvent) {
var selectElement = this,
selectedOptionId = selectEvent.params.args.data.id;
selectedOptionId = selectEvent.params.args.data.id;
// CREATE CUSTOM FIELD
if (selectedOptionId === 'create') {
selectEvent.preventDefault();
@ -742,28 +755,28 @@ define(
data: data
}).done(function(response) {
var new_column_data = {
'id': response.data.id,
'name': response.data.name,
'type': response.data.type,
'params': response.data.params,
'custom': true
id: response.data.id,
name: response.data.name,
type: response.data.type,
params: response.data.params,
custom: true
};
// if this is the first custom column, create an "optgroup"
if (mailpoetColumnsSelect2.length === 2) {
mailpoetColumnsSelect2.push({
'name': MailPoet.I18n.t('userColumns'),
'children': []
if (window.mailpoetColumnsSelect2.length === 2) {
window.mailpoetColumnsSelect2.push({
name: MailPoet.I18n.t('userColumns'),
children: []
});
}
mailpoetColumnsSelect2[2].children.push(new_column_data);
mailpoetColumns.push(new_column_data);
window.mailpoetColumnsSelect2[2].children.push(new_column_data);
window.mailpoetColumns.push(new_column_data);
jQuery('select.mailpoet_subscribers_column_data_match')
.each(function () {
jQuery(this)
.html('')
.select2('destroy')
.select2({
data: mailpoetColumnsSelect2,
data: window.mailpoetColumnsSelect2,
width: '15em',
templateResult: function (item) {
return item.name;
@ -771,7 +784,7 @@ define(
templateSelection: function (item) {
return item.name;
}
})
});
});
jQuery(selectElement).data('column-id', new_column_data.id);
jQuery(selectElement).data('validation-rule', false);
@ -795,7 +808,7 @@ define(
jQuery('select.mailpoet_subscribers_column_data_match')
.each(function () {
var element = this,
elementId = jQuery(element).val();
elementId = jQuery(element).val();
// if another column has the same value and it's not an 'ignore', prompt user
if (elementId === selectedOptionId
&& elementId !== 'ignore') {
@ -812,7 +825,7 @@ define(
})
.on('select2:select', function (selectEvent) {
var selectElement = this,
selectedOptionId = selectEvent.params.data.id;
selectedOptionId = selectEvent.params.data.id;
jQuery(selectElement).data('column-id', selectedOptionId);
filterSubscribers();
});
@ -823,8 +836,8 @@ define(
'[data-id="notice_invalidEmail"], [data-id="notice_invalidDate"]')
.remove();
var subscribersClone = jQuery.extend(true, {}, subscribers),
preventNextStep = false,
displayedColumns = jQuery.map(
preventNextStep = false,
displayedColumns = jQuery.map(
jQuery('.mailpoet_subscribers_column_data_match'), function (element, elementIndex) {
var columnId = jQuery(element).data('column-id');
var validationRule = jQuery(element).data('validation-rule');
@ -832,14 +845,14 @@ define(
return { id: columnId, index: elementIndex, validationRule: validationRule, element: element };
});
// iterate through the object of mailpoet columns
jQuery.map(mailpoetColumns, function (column, columnIndex) {
jQuery.map(window.mailpoetColumns, function (column, columnIndex) {
// check if the column id matches the selected id of one of the
// subscriber's data columns
var matchedColumn = _.find(displayedColumns, function(data) { return data.id === column.id; });
// EMAIL filter: if the first value in the column doesn't have a valid
// email, hide the next button
if (column.id === 'email') {
if (!emailRegex.test(subscribersClone.subscribers[0][matchedColumn.index])) {
if (!window.emailRegex.test(subscribersClone.subscribers[0][matchedColumn.index])) {
preventNextStep = true;
if (!jQuery('[data-id="notice_invalidEmail"]').length) {
MailPoet.Notice.error(MailPoet.I18n.t('columnContainsInvalidElement'), {
@ -880,11 +893,11 @@ define(
}
else {
for (var format in allowedDateFormats) {
var testedFormat = allowedDateFormats[format]
var testedFormat = allowedDateFormats[format];
if (Moment(firstRowData, testedFormat, true).isValid()) {
var validationRule = (typeof(testedFormat) === 'function') ?
'datetime' :
testedFormat
testedFormat;
// set validation on the column element
jQuery(matchedColumn.element).data('validation-rule', validationRule);
break;
@ -894,7 +907,8 @@ define(
}
}
}
jQuery.map(subscribersClone.subscribers, function (data, index) {
jQuery.map(subscribersClone.subscribers, function (dataSubscribers, index) {
var data = dataSubscribers;
var rowData = data[matchedColumn.index];
if (index === fillerPosition || rowData.trim() === '') return;
var date = Moment(rowData, testedFormat, true);
@ -917,7 +931,7 @@ define(
+ '</span> '
);
preventNextStep = true;
};
}
});
if (preventNextStep && !jQuery('.mailpoet_invalidDate').length) {
MailPoet.Notice.error(MailPoet.I18n.t('columnContainsInvalidDate'), {
@ -968,10 +982,10 @@ define(
timestamp = Date.now() / 1000,
subscribers = [],
importResults = {
'created': 0,
'updated': 0,
'errors': [],
'segments': []
created: 0,
updated: 0,
errors: [],
segments: []
},
splitSubscribers = function (subscribers, size) {
return subscribers.reduce(function (res, item, index) {
@ -982,7 +996,7 @@ define(
return res;
}, []);
},
subscribers = splitSubscribers(importData.step1.subscribers, batchSize);
subscribers = splitSubscribers(window.importData.step1.subscribers, batchSize);
_.each(jQuery('select.mailpoet_subscribers_column_data_match'),
function (column, columnIndex) {
@ -1006,7 +1020,7 @@ define(
subscribers: subscribers[batchNumber],
timestamp: timestamp,
segments: segmentSelectElement.val(),
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes') ? true : false
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes')
})
}).done(function(response) {
importResults.created += response.data.created;
@ -1024,7 +1038,7 @@ define(
}
});
batchNumber++;
})
});
});
queue.run();
@ -1036,54 +1050,60 @@ define(
);
}
else {
mailpoetSegments = importResults.segments;
window.mailpoetSegments = importResults.segments;
importResults.segments = _.map(segmentSelectElement.select2('data'),
function (data) {
return data.name;
});
importData.step2 = importResults;
enableSegmentSelection(mailpoetSegments);
window.importData.step2 = importResults;
enableSegmentSelection(window.mailpoetSegments);
router.navigate('step3', {trigger: true});
}
});
});
filterSubscribers();
enableSegmentSelection(mailpoetSegments);
enableSegmentSelection(window.mailpoetSegments);
});
router.on('route:step3', function () {
if (typeof (importData.step2) === 'undefined') {
if (typeof (window.importData.step2) === 'undefined') {
router.navigate('step2', {trigger: true});
return;
}
showCurrentStep();
if (importData.step2.errors.length > 0) {
MailPoet.Notice.error(_.flatten(importData.step2.errors));
if (window.importData.step2.errors.length > 0) {
MailPoet.Notice.error(_.flatten(window.importData.step2.errors));
}
MailPoet.trackEvent('Subscribers import finished', {
'Subscribers created': window.importData.step2.created,
'Subscribers updated': window.importData.step2.updated,
'MailPoet Free version': window.mailpoet_version
});
// display statistics
var subscribersDataImportResultsTemplate =
Handlebars
.compile(jQuery('#subscribers_data_import_results_template')
.html()),
exportMenuElement = jQuery('span.mailpoet_export'),
importResults = {
created: (importData.step2.created)
exportMenuElement = jQuery('span.mailpoet_export'),
importResults = {
created: (window.importData.step2.created)
? MailPoet.I18n.t('subscribersCreated')
.replace('%1$s', '<strong>' + importData.step2.created.toLocaleString() + '</strong>')
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
.replace('%1$s', '<strong>' + window.importData.step2.created.toLocaleString() + '</strong>')
.replace('%2$s', '"' + window.importData.step2.segments.join('", "') + '"')
: false,
updated: (importData.step2.updated)
updated: (window.importData.step2.updated)
? MailPoet.I18n.t('subscribersUpdated')
.replace('%1$s', '<strong>' + importData.step2.updated.toLocaleString() + '</strong>')
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
.replace('%1$s', '<strong>' + window.importData.step2.updated.toLocaleString() + '</strong>')
.replace('%2$s', '"' + window.importData.step2.segments.join('", "') + '"')
: false,
no_action: (!importData.step2.created && !importData.step2.updated),
added_to_segment_with_welcome_notification: importData.step2.added_to_segment_with_welcome_notification
};
no_action: (!window.importData.step2.created && !window.importData.step2.updated),
added_to_segment_with_welcome_notification: window.importData.step2.added_to_segment_with_welcome_notification
};
jQuery('#subscribers_data_import_results')
.html(subscribersDataImportResultsTemplate(importResults))
@ -1105,11 +1125,11 @@ define(
}
// reset previous step's data so that coming back to this step is prevented
importData.step2 = undefined;
window.importData.step2 = undefined;
});
if (!Backbone.History.started) {
Backbone.history.start();
}
});
});
});

View File

@ -83,12 +83,12 @@ const messages = {
MailPoet.Notice.success(message);
},
onNoItemsFound: (group) => {
if (group === 'bounced' && !mailpoet_premium_active) {
if (group === 'bounced' && !window.mailpoet_premium_active) {
return (
<div>
<p>{MailPoet.I18n.t('bouncedSubscribersHelp')}</p>
<p>
<a href={ `admin.php?page=mailpoet-premium` } className="button-primary">
<a href={ 'admin.php?page=mailpoet-premium' } className="button-primary">
{MailPoet.I18n.t('bouncedSubscribersPremiumButtonText')}
</a>
</p>
@ -245,7 +245,7 @@ const item_actions = [
const SubscriberList = React.createClass({
getSegmentFromId: function (segment_id) {
let result = false;
mailpoet_segments.map((segment) => {
window.mailpoet_segments.map((segment) => {
if (segment.id === segment_id) {
result = segment;
}
@ -350,7 +350,7 @@ const SubscriberList = React.createClass({
</h1>
<Listing
limit={ mailpoet_listing_per_page }
limit={ window.mailpoet_listing_per_page }
location={ this.props.location }
params={ this.props.params }
endpoint="subscribers"

Some files were not shown because too many files have changed in this diff Show More