Compare commits

...

518 Commits

Author SHA1 Message Date
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
f35b66b3cf Release 3.0.0-rc.1.0.2 2017-08-08 17:45:04 +03:00
7900e7eb8d Merge pull request #1035 from mailpoet/new-poll
New poll [MAILPOET-1018]
2017-08-08 09:17:41 -04:00
849a24ced7 Merge pull request #1019 from mailpoet/translate
translate the DB error message [MAILPOET-1019]
2017-08-08 13:08:54 +03:00
f7e73b06be added missing argument 2017-08-08 10:02:51 +00:00
52cbb9fcb2 Merge pull request #1032 from mailpoet/css-form
Update form css [MAILPOET-593]
2017-08-08 11:48:09 +02:00
966ec0cb7a New poll
[MAILPOET-1018]
2017-08-03 13:17:37 +02:00
2ff0d40d10 Updates reference to the hook that displays IIS error 2017-08-03 08:14:46 +02:00
bb249ebe09 Removes leftover debug code 2017-08-02 10:24:35 -04:00
5a57029b38 Bumps up release version & updates changelog 2017-08-02 10:23:37 -04:00
84d427cc4c Upate poll url 2017-08-02 11:40:30 +02:00
22efd2109b Release 3.0.0-rc.1.0.0 2017-08-01 18:04:30 +00:00
f044db5745 Update form css
[MAILPOET-593]
2017-08-01 11:28:53 +02:00
0865995d21 Does not remove padding from the last element in a column 2017-08-01 09:47:29 +02:00
7c30192a03 Adds option to replace shortcodes in one string using contents from
another string
Adds unit tests
2017-08-01 09:32:42 +02:00
334c3ff420 Returns false when data-post-id tag is not found
Uses all post types, including custom, when querying posts
2017-08-01 09:32:42 +02:00
6d738ddb3b Merge pull request #1031 from mailpoet/mss-response
Mss response [MAILPOET-1035]
2017-07-31 14:37:13 -04:00
440052cf2c Remove duplicate code
[MAILPOET-1035]
2017-07-31 16:51:11 +02:00
ccb751b44a Adhere to updated MSS /me response
[MAILPOET-1035]
2017-07-31 16:47:20 +02:00
7cf3d0960d Unify API response constants
[MAILPOET-1035]
2017-07-31 13:51:23 +02:00
6e45856622 Merge pull request #1022 from mailpoet/mediumint_to_int
Switch ID fields from mediumint to int in DB [MAILPOET-1022]
2017-07-31 11:03:16 +02:00
9859df98b7 translate the DB error message 2017-07-31 08:53:30 +00:00
1071688924 Update a poll [MAILPOET-1017] 2017-07-31 09:41:45 +02:00
4f3b0234a4 Move exception rule to top
[MAILPOET-1028]
2017-07-31 09:27:26 +02:00
3e2bbeac11 Fix ES6 comma-dangle eslint rule (functions should be ignored pre-ES2017) [MAILPOET-1028] 2017-07-31 09:27:26 +02:00
08f81bd816 Fix ES5 comma-dangle eslint rule [MAILPOET-1028] 2017-07-31 09:27:26 +02:00
f0c59ff635 Fix tests comma-dangle eslint rule [MAILPOET-1028] 2017-07-31 09:27:26 +02:00
66c6f52646 Fix ES6 comma-spacing eslint rule [MAILPOET-1028] 2017-07-31 09:27:26 +02:00
4988aaf14f Fix ES5 comma-spacing eslint rule [MAILPOET-1028] 2017-07-31 09:27:26 +02:00
5773d46f1c Merge pull request #1029 from mailpoet/alc-rendering
Enable blockquotes and fix image positioning in ALC blocks [MAILPOET-1037] [MAILPOET-1038]
2017-07-30 12:01:39 -04:00
f3a1e1b447 Update Robo test debug rule to accept individual test file paths 2017-07-28 14:36:40 +03:00
6de746162e Update Posts transformer to extract images by splitting the DOM tree 2017-07-28 14:36:12 +03:00
60b3c066a5 Allow rendering blockquote tags 2017-07-28 11:10:57 +03:00
63158dc2d5 Merge pull request #1024 from mailpoet/mta-frequency-fix
Mta frequency fix [MAILPOET-1021]
2017-07-27 19:17:14 +03:00
dede6e56c4 Merge pull request #1026 from mailpoet/beta_end
Remove concept of "Beta" on readme.txt, update banners [MAILPOET-1023]
2017-07-27 15:49:22 +03:00
dd366dde18 Remove concept of "Beta" on readme.txt, update banners [MAILPOET-1023] 2017-07-27 14:04:00 +03:00
2fedafe483 Merge pull request #1025 from mailpoet/tests_sniffs
Enable remaining CodeSniffer rules for PHP tests [MAILPOET-1025]
2017-07-26 21:34:48 -04:00
feae98ac3f Use a single ruleset for both the plugin and its tests [MAILPOET-1025] 2017-07-26 18:56:14 +03:00
6fb18ad321 Fix PSR1.Classes.ClassDeclaration sniffer rule in tests [MAILPOET-1025] 2017-07-26 18:28:56 +03:00
6c843e35b0 Update warning text
[MAILPOET-1021]
2017-07-26 16:27:53 +02:00
cfdb86eb6e Replace default option text
[MAILPOET-1021]
2017-07-26 16:24:31 +02:00
41fb93e453 Remove the number of emails per day calculation
[MAILPOET-1021]
2017-07-26 16:22:23 +02:00
19813b5dad Fix host frequency override
[MAILPOET-1021]
2017-07-26 16:08:49 +02:00
321393f119 Fix Squiz.Classes.ClassFileName sniffer rule in tests [MAIPOET-1025] 2017-07-26 17:03:43 +03:00
ab3f41302c Merge pull request #1023 from mailpoet/remove-subquery
Use Joins instead subqueries [MAILPOET-1027]
2017-07-26 13:56:32 +03:00
9dff4539e6 Use Joins instead subqueries
[MAILPOET-1027]
2017-07-26 11:46:36 +02:00
6520d5eca3 Merge branch 'master' of github.com:mailpoet/mailpoet 2017-07-25 16:45:42 +03:00
f5b152cdfa Bump up release version to 3.0.0-beta.37.0.0 2017-07-25 16:40:12 +03:00
1d2cab1249 Merge pull request #1021 from mailpoet/prevent-mss-override
Prevent to override sending group [MAILPOET-1024]
2017-07-25 15:24:28 +03:00
90b93bd76e Merge pull request #1018 from mailpoet/prevent_sending_with_broken_newsletter_body
Prevents sending emails when rendered newsletter is broken [MAILPOET-1020]
2017-07-25 13:13:03 +03:00
563ca3e605 Switch ID fields from mediumint to int in DB [MAILPOET-1022] 2017-07-25 13:11:56 +03:00
08bbfcb5e8 Track MixPanel events for Settings [MAILPOET-998] 2017-07-25 10:53:28 +02:00
5572a7f1e5 Prevent to override sending group
[MAILPOET-1024]
2017-07-25 08:32:10 +02:00
9dd326e7db Updates class to use newly added validate() method on the model
Validates existing queue's rendered newsletter body
Cleans code formatting
2017-07-24 12:49:39 -04:00
cf00813c7f Adds new method to validate model on request
Cleans up code formatting
2017-07-24 11:20:43 -04:00
4c898b76b2 Uses ValidModel to validate rendered newsletter body
Removes previous validation method
Does not serialize null values
2017-07-24 11:15:00 -04:00
81a2ba8e03 Adds new validation method for rendered newsletter body 2017-07-24 11:11:22 -04:00
7e6d900b53 Merge pull request #997 from mailpoet/scheduled_task_subscribers
Extract subscribers to a separate table in the Bounce worker [MAILPOET-987]
2017-07-24 17:14:38 +03:00
1a522794d6 Adds method to validate rendered newsletter body on sending queue
Prevents sending queue worker from sending when sending queue's rendered
newsletter body is invalid
2017-07-23 11:50:35 -04:00
197537d6ca Merge pull request #1015 from mailpoet/custom_field_shortcodes
Add missing brackets to custom field shortcodes [MAILPOET-1013]
2017-07-21 21:40:25 -04:00
b212ca801b Merge pull request #1016 from mailpoet/sync_deleted_wp_users
Remove deleted WP users from subscribers [MAILPOET-1012]
2017-07-21 21:39:53 -04:00
db8f3216d7 Add tests for syncing deleted WP users [MAILPOET-1012] 2017-07-21 18:43:29 +03:00
78f9945296 Remove deleted WP users from subscribers [MAILPOET-1012] 2017-07-21 17:48:48 +03:00
0cebcd3965 Add missing brackets to custom field shortcodes [MAILPOET-1013] 2017-07-21 14:40:56 +03:00
4062e0662d Merge pull request #1009 from mailpoet/share_data_kb_link
Update link to "Share your data" in Welcome tabs [MAILPOET-1010]
2017-07-20 19:24:53 +02:00
20b7e82d3c Merge pull request #1014 from mailpoet/new-poll
Update poll [MAILPOET-1016]
2017-07-20 19:16:36 +02:00
9ab8a80567 Merge pull request #992 from mailpoet/circleci
Set up CircleCI tests to run on PHP 5.6 and 7.1 [MAILPOET-986]
2017-07-20 09:55:44 -04:00
f98d02121b Fix BatchIterator skipping rows when subscribers' processed status is modified [MAILPOET-987] 2017-07-20 16:31:27 +03:00
e68e212ad0 Update poll
[MAILPOET-1016]
2017-07-20 12:48:55 +01:00
cb1a1e51ba Use fixtures instead of IDs in the sheduled task subscriber test [MAILPOET-987] 2017-07-20 13:26:31 +03:00
b42d8e68d9 Rename removeSubscribers() method and encapsulate task completion logic [MAILPOET-987] 2017-07-20 11:22:47 +03:00
e88d130ebb Remove side-effects from Update page styles [MAILPOET-1001]
Example: Premium page comparison table rows centered
2017-07-20 08:59:03 +01:00
c924778d50 Rename unprocessed status, refactor counting a bit more clearly [MAILPOET-987] 2017-07-20 10:56:34 +03:00
a9051c6d09 merging qa_js and php5 builds to gain execution time 2017-07-19 19:11:35 -04:00
f6243b5d79 Merge pull request #1005 from mailpoet/mixpanel-more-data
MixPanel: extend summarized data collection [MAILPOET-974]
2017-07-19 20:25:14 +03:00
68c0b93586 Fix Premium page scaling on mobile screens [MAILPOET-1001] 2017-07-19 18:14:50 +01:00
0e8be8040c Move custom page styles from views to a separate *.styl file [MAILPOET-1001] 2017-07-19 18:14:50 +01:00
f3ea548d65 Update the Premium page [MAILPOET-1001] 2017-07-19 18:14:50 +01:00
1ab6be8acd Fix Notice and remove redundant field
[MAILPOET-974]
2017-07-19 16:16:08 +01:00
c413acd93d display a warning when unable to connect to database 2017-07-19 16:05:34 +01:00
7614a4d8dc Update link to "Share your data" in Welcome tabs [MAILPOET-1010] 2017-07-19 10:27:59 +03:00
4a94c29b85 Merge pull request #1008 from mailpoet/model_unit_test_update
Uses MailPoet's Model class vs. Idiorm's in test
2017-07-19 09:32:51 +03:00
b5b9531ff3 Merge pull request #1006 from mailpoet/premium_mixpanel
Add handlers for Premium events tracking, expose Premium version to JS [PREMIUM-24]
2017-07-18 16:14:24 +02:00
e2a048a65f Uses MP Model class vs. Idiorm's in test 2017-07-18 09:49:01 -04:00
c28726f118 Release 3.0.0-beta.36.3.1 2017-07-18 13:58:35 +03:00
7c74885669 Merge pull request #1003 from mailpoet/php53_listing_fix
Adds asArray() method to the base Model class [MAILPOET-1007]
2017-07-17 20:00:10 +03:00
5f74f34cba Adds notes explaining the fix 2017-07-17 12:15:39 -04:00
d6ef526a9d Add handlers for Premium events tracking, expose Premium version [PREMIUM-24] 2017-07-17 18:57:18 +03:00
0da0507e0a Fixes SMTP timing out on slow hosts
Increases default connection timeout value
Adds filter to specify custom connection timeout value

[MAILPOET-1004]
2017-07-17 15:21:33 +01:00
3f03c985bf Collect plugins info for analytics
[MAILPOET-974]
2017-07-17 14:46:26 +01:00
77f6e13aa3 Merge pull request #999 from mailpoet/url_extraction_fix
Replaces URL extraction regex with DOM parser [MAILPOET-1003]
2017-07-17 16:32:59 +03:00
213d0e8627 Distinguishes between link TYPE and link CATEGORY NAME
Uses $replacement_link variable for clarity
2017-07-17 09:14:11 -04:00
1d019bc11e Merge pull request #1004 from mailpoet/filter_to_whitelist_plugins_from_conflict_resolver
Adds filters to whitelist styles/scripts unloaded by our plugin [MAILPOET-1008]
2017-07-17 15:11:37 +02:00
ca12487416 moving shell code into a bash file 2017-07-17 11:38:41 +00:00
c5d42a5033 Merge pull request #995 from mailpoet/welcome-tab-update
Welcome tab update [MAILPOET-979]
2017-07-17 07:17:26 -04:00
3b079440b5 try without sharing workspace 2017-07-17 10:52:48 +00:00
419697991f Adding workflows to CircleCI
Splitting build into 2 builds:

- `build_qa_js`: Builds the project and runs the qa checks and JS tests.

- `php_5`: Runs the PHP tests with PHP 5.6.3

and adding a new build

- `php_7`: Runs the PHP tests with PHP 7.1
2017-07-17 10:26:17 +00:00
d119a1e5fa Send settings values to Mixpanel
[MAILPOET-974]
2017-07-17 11:15:29 +01:00
1bd4264dd5 Fix code style
[MAILPOET-979]
2017-07-17 09:20:28 +01:00
21ee60b7d7 Merge pull request #1002 from mailpoet/newsletter_duplication_update
Resets sent at data when duplicating a sent newsletter [MAILPOET-1005]
2017-07-17 10:07:29 +02:00
849ca27d1f Adds filters to whitelist styles or scripts 2017-07-15 14:57:40 -04:00
a4dad46fb7 Adds asArray() method to the base Model that's used as proxy for
Idiorm's as_array()
2017-07-15 14:25:50 -04:00
fac4c8fb41 Merge pull request #1000 from mailpoet/fix-frequency-smtp
Fix default frequency
2017-07-15 13:04:40 -04:00
cdc87c23ea Resets sent at data when duplicating a sent newsletter 2017-07-15 13:00:25 -04:00
34d09ce0c9 Sets mailer log error when queue cannot be saved during newsletter
pre-processing
2017-07-14 23:15:14 -04:00
fe9ae392f2 Replaces URL extraction regex with DOM parser
Simplifies link replacement logic
Cleans up code
2017-07-14 23:15:08 -04:00
9501640f4f Prevents double UTF-8 encoding 2017-07-14 14:03:48 -04:00
ad028ab55d Fix devault frequency 2017-07-14 08:01:54 +01:00
74cb8d9735 Merge pull request #998 from mailpoet/settings_flex_fix
Fix broken layout in IE 11 on a big screen + make it look like in previous versions [MAILPOET-1002]
2017-07-13 14:11:24 -04:00
381608df22 Fix broken layout in IE 11 on a big screen + make it look like in previous versions [MAILPOET-1002] 2017-07-13 21:03:24 +03:00
6aca598dc3 Fix tests: unneeded migration was triggered by resetting the DB version to 1.0.0 (after EnvTest)
This caused errors when pinging the daemon [MAILPOET-940]
2017-07-13 16:26:53 +03:00
acbe2e383a Add tests [MAILPOET-940] 2017-07-13 13:27:28 +03:00
55d3b67a2a Extract common and task-specific methods for subscribers [MAILPOET-940] 2017-07-13 13:27:28 +03:00
c02394b576 Prepare subscribers in the Bounce worker DB-side for performance reasons [MAILPOET-940] 2017-07-13 13:27:27 +03:00
6a9b8d88c2 Extract subscribers to a separate table in the Bounce worker [MAILPOET-940] 2017-07-13 13:27:27 +03:00
b24c51d800 Merge pull request #996 from mailpoet/add-extra-text
Add extra text on Send with... [MAILPOET-954]
2017-07-13 13:24:22 +03:00
d3a3d3b277 Merge pull request #993 from mailpoet/duplicate-content
Add an option to duplicate content blocks [MAILPOET-968]
2017-07-13 13:14:36 +03:00
3dcff8eb8a Update styles to handle more text
[MAILPOET-954]
2017-07-13 09:41:08 +01:00
401339244c Merge pull request #991 from mailpoet/fix-duplicate-smtp
Remove a duplicate field [MAILPOET-995]
2017-07-12 19:30:37 +03:00
653ecdc4d0 Add extra copy
[MAILPOET-954]
2017-07-12 16:54:49 +01:00
88d5952684 Remove duplicate id
[MAILPOET-979]
2017-07-12 14:55:53 +01:00
c4d6c19c67 Merge pull request #990 from mailpoet/eslint-no-var
Eslint fixes [MAILPOET-994]
2017-07-12 15:51:26 +02:00
0554a84f77 Apply new styles
[MAILPOET-979]
2017-07-12 13:38:56 +01:00
c01b57a383 Add poll
[MAILPOET-979]
2017-07-12 10:28:35 +01:00
65f4f493f1 Add sharing section
[MAILPOET-979]
2017-07-12 10:09:17 +01:00
8a7ea791b0 Move button to see all changelogs
[MAILPOET-979]
2017-07-12 09:35:10 +01:00
1823985172 Display only one set of changelog
[MAILPOET-979]
2017-07-12 09:19:22 +01:00
e735b5f3e0 Replace title
[MAILPOET-979]
2017-07-12 08:44:04 +01:00
cd5c57b7e9 Merge pull request #994 from mailpoet/fixing-readme
Fixing 'Get in touch' URL [MAILPOET-996]
2017-07-11 13:35:36 -04:00
fbf59723d8 Fixing 'Get in touch' URL 2017-07-11 16:57:56 +00:00
2e166a233b Update duplicate icon
[MAILPOET-968]
2017-07-11 17:19:41 +01:00
1608ba5893 Remove a duplicate field
[MAILPOET-995]
2017-07-11 15:39:22 +01:00
9d7eb8038d Fix eslint rule arrow-parens 2017-07-11 14:31:19 +01:00
c9c78a7160 Fix eslint rule indent 2017-07-11 14:31:19 +01:00
53df10dc2b Fix eslint rule eol-last 2017-07-11 14:31:19 +01:00
a746c124a3 Fix eslint rule object-curly-spacing 2017-07-11 14:31:19 +01:00
ca5a5301a8 Fix eslint rule no-var 2017-07-11 14:31:19 +01:00
7a2aaa86cf Tests that populator method is not run for versions below
3.0.0-beta.36.2.1
2017-07-11 14:26:29 +01:00
b626c7ea3c Release 3.0.0-beta.36.3.0 2017-07-11 12:50:33 +01:00
695152e947 Allow duplicate content
[MAILPOET-968]
2017-07-11 10:53:52 +01:00
a36fe400ed Merge pull request #966 from mailpoet/mp2tomp3migration
Settings migration from MP2 to MP3
2017-07-11 12:43:19 +03:00
22bb971db5 Merge pull request #980 from mailpoet/newsletter_listing_update
Sorts standard/history notification records by sent_at date in listings [MAILPOET-932]
2017-07-11 12:43:06 +03:00
b88452c5a2 Fixed: the "Skip Import" link was hidden after unit tests 2017-07-10 18:37:23 +02:00
4a2f9ad1f9 Remove unused code 2017-07-10 18:37:22 +02:00
593a7de9fe New: Add extra text when the migration is completed 2017-07-10 18:37:21 +02:00
e5ecf870c7 Fixed: SendGrid provider was selected even when Sendgrid was not selected in MP2 2017-07-10 18:37:21 +02:00
11cc97b201 Fixed: Unit tests failed if the database prefix was not "wp_" 2017-07-10 18:37:20 +02:00
e352b5bfad New: Migrate installation date 2017-07-10 18:37:19 +02:00
334448c964 New: Add paragraph below "What will be kept in MailPoet 3" 2017-07-10 18:37:18 +02:00
7d8d535cb3 New: Hide the progress bar and the logs if the import has not started yet 2017-07-10 18:37:17 +02:00
68988edd7e Fixed: Change the emails number if the frequency is greater than 15 minutes 2017-07-10 18:37:17 +02:00
f164e9bb95 Fixed: Leave the Newsletter task scheduler (cron) to its default value 2017-07-10 18:37:16 +02:00
fe83435d14 Fixed: "Subscribe in comments" always on 2017-07-10 18:37:15 +02:00
453b7683bc Fixed: SendGrid method and provider were not selected 2017-07-10 18:37:14 +02:00
25625b1ce1 Add unit tests for the settings migration 2017-07-10 18:37:13 +02:00
048d71164a Migrate the settings 2017-07-10 18:31:51 +02:00
24e682e92e Corrects typo 2017-07-10 12:20:37 -04:00
23d90c9f73 Merge pull request #985 from mailpoet/fix-mailpoet-activation
Fix firefox double submit [MAILPOET-992]
2017-07-10 15:53:17 +03:00
a9f190661f Remove unnecessary return statement [MAILPOET-992] 2017-07-10 15:51:19 +03:00
c1e56e5fa1 Update button type to prevent form submit
[MAILPOET-992]
2017-07-10 13:28:06 +01:00
e2bb2679e4 Fix firefox double submit
[MAILPOET-992]
2017-07-10 12:07:07 +01:00
d49530da0f Merge pull request #979 from mailpoet/update-readme
Update readme [MAILPOET-978]
2017-07-10 13:58:36 +03:00
0bc28ef3c7 Remove duplication
[MAILPOET-978]
2017-07-10 11:27:08 +01:00
563b7eccb0 Update video link in readme
[MAILPOET-978]
2017-07-10 11:06:42 +01:00
94a9b63136 Merge pull request #984 from mailpoet/fix-mailpoet-activation
Send the correct group to server [MAILPOET-992]
2017-07-10 12:53:48 +03:00
91ff008485 Make key check error messages more descriptive [MAILPOET-990] 2017-07-10 10:34:55 +01:00
cb8fa23c3f Send the correct group to server
[MAILPOET-992]
2017-07-10 09:18:43 +01:00
3499de05e8 Merge pull request #983 from mailpoet/link_tags_replacement_update
Updates the way link tags are replaced in translations [MAILPOET-991]
2017-07-09 12:14:42 +03:00
77ed4d34e8 Uses Helper's replaceLinkTags method to replace activation link in
subscription confirmation email
2017-07-08 12:00:45 -04:00
cfc5f5a88d Allows defining custom link tag 2017-07-08 11:56:51 -04:00
2514d87a00 Uses Helper's replaceLinkTags method to replace tags in translation
strings
2017-07-08 10:31:33 -04:00
23c6750ccc Removes leftover debug condition 2017-07-07 13:12:45 -04:00
bb2af5176b Tests that newsletters can be sorted by sent_at column 2017-07-07 11:05:39 -04:00
95b5206e8b Updates sending queue worker to set newsletter's sent_at field when
newsletter is sent
2017-07-07 11:05:39 -04:00
394118f113 Adds sent_at column to the newsletters table
Modifies populator to update existing newsletters' sent_at field
2017-07-07 11:05:33 -04:00
b691fb5a48 Adds sorting by sent_at to standard & notification history newsletter listings 2017-07-07 11:04:19 -04:00
1ba2492929 Combines Twig's "replaceLink" and Util/Helper's "replaceLinkTags"
methods into one
2017-07-07 11:02:20 -04:00
d08243b0ce Merge pull request #981 from mailpoet/tests_lint_rules
Fix ScopeClosingBrace, EmptyNonVariable sniffer rules in tests [MAILPOET-989]
2017-07-07 11:01:21 -04:00
189656fdc8 Fixes malformed URL 2017-07-07 09:52:08 -04:00
0be872eea9 Fix PHPCompatibility.PHP.EmptyNonVariable rule [MAILPOET-989] 2017-07-07 11:30:16 +03:00
22c39c0092 Fix PEAR.WhiteSpace.ScopeClosingBrace rule in tests [MAILPOET-989] 2017-07-07 11:11:16 +03:00
1b54e356b2 Merge pull request #978 from mailpoet/add-missing-callbacks
Add missing callbacks to ajax calls [MAILPOET-982]
2017-07-06 19:29:30 -04:00
9079d7d4db Merge pull request #977 from mailpoet/subscription_confirmation_update
Prevents repeat subscription confirmation/duplicate welcome notifications [MAILPOET-988]
2017-07-06 22:52:44 +03:00
160b28a632 Merge pull request #976 from mailpoet/editor-drag-and-drop
Fix reverting to mouse cursor auto icon after clicking Draggable object [MAILPOET-965]
2017-07-06 21:54:28 +03:00
03ebb30ac2 Update readme
[MAILPOET-978]
2017-07-06 15:43:04 +01:00
56eac1ae86 Add missing callbacks to ajax calls
[MAILPOET-982]
2017-07-06 13:06:14 +01:00
89da4c9aae Prevents repeat subscription confirmation
Prevents scheduling of duplicate welcome notifications
2017-07-05 19:50:57 -04:00
b510071857 Merge pull request #972 from mailpoet/merge-sending-method
Merge sending method [MAILPOET-953]
2017-07-05 19:59:30 +03:00
4bbec4700d Stub out interact.styleCursor method 2017-07-05 19:45:13 +03:00
29a2af2555 Fix reverting to mouse cursor auto icon after clicking Draggable object 2017-07-05 19:26:33 +03:00
94d57b5287 Make sure all frequency changes are displayed correctly
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
6b7bc8a731 Make sure frequency is always set
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
3dd0f00b7f Fix sending method
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
b58f6cc4e0 Fix broken reporting
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
7c942147ec Show frequency fields on initial page render
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
6fca2061e6 Show fields on initial page render
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
0acc41c887 Pre select the sending method
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
20d1ac81e2 Save correct values
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
cdb7b99728 Merge sending methods
[MAILPOET-953]
2017-07-05 16:37:08 +01:00
54cb838d71 Merge pull request #959 from mailpoet/scheduled_tasks
Refactor simple workers to use a ScheduledTask model [MAILPOET-940]
2017-07-05 17:28:08 +03:00
0b9ea23f0b Temporarily remove pause/resume methods from scheduled tasks [MAILPOET-940] 2017-07-05 17:12:35 +03:00
3e40f768b4 Add migration of simple scheduled tasks [MAILPOET-940] 2017-07-05 17:12:34 +03:00
6e929dcf79 Refactor simple workers to use a ScheduledTask model [MAILPOET-940] 2017-07-05 17:00:23 +03:00
7be01f0e4e Merge pull request #975 from mailpoet/eslint-fix-rules-rad
Bunch of fixed eslint rules
2017-07-05 14:20:24 +03:00
9cb08734a3 Return back function which is needed
[MAILPOET-985]
2017-07-05 11:36:39 +01:00
55fda047f6 Fix prefer-const eslint rule
[MAILPOET-985]
2017-07-05 09:55:00 +01:00
4706c5fc25 Fix prefer-arrow-callback eslint rule
[MAILPOET-985]
2017-07-05 09:48:35 +01:00
3ba857d03f Fix no-unused-vars eslint rule
[MAILPOET-985]
2017-07-05 09:46:08 +01:00
f39cbe6b55 Fix space-before-function-paren eslint rule
[MAILPOET-985]
2017-07-05 09:46:08 +01:00
6dc1bf4e95 Fix semi eslint rule
[MAILPOET-985]
2017-07-05 09:46:08 +01:00
5b65a8f0ac Fix radix eslint rule
[MAILPOET-985]
2017-07-05 09:46:08 +01:00
583adf86da Fix no-plusplus eslint rule
[MAILPOET-985]
2017-07-05 09:46:08 +01:00
3b4a1b686d Make build find command work cross-platform (Linux/Mac/Win) [MAILPOET-984] 2017-07-05 08:33:43 +01:00
5390dd8421 Merge branch 'master' of github.com:mailpoet/mailpoet 2017-07-04 18:15:16 +03:00
fe8452711f Bump up release version to 3.0.0-beta.36.2.0 2017-07-04 18:14:04 +03:00
f7cb53de2c Fix composer.lock (remove AspectMock from prod dependencies) 2017-07-04 18:13:17 +03:00
1ac6dd8ccb Switch to using CircleCI 2.0
We end up using Docker images for PHP 5.6 and MySQL, handle our own
Composer and NPM caches.
2017-07-04 15:56:02 +01:00
b1425198b6 Merge pull request #967 from mailpoet/subscription_form_unit_test
Adds test for subscription form submission class [MAILPOET-961]
2017-07-04 14:46:26 +03:00
00a45f3214 Make Codeception report all errors (incl. E_STRICT and E_DEPRECATED) when running tests [MAILPOET-961] 2017-07-04 14:30:15 +03:00
8e46451337 Fixes non static methods called statically (good practice + PHP 7
compatibility)
2017-07-03 19:39:11 -04:00
b0d0cc09c8 Programmatically sets input width after Select2 initialization
[MAILPOET-973]
2017-07-03 17:05:06 +01:00
af559a6fac Merge pull request #971 from mailpoet/tests_qa
Add a copy of MailPoet PHP coding standard for tests [MAILPOET-981]
2017-07-03 18:03:43 +03:00
67acceb968 Merge pull request #965 from mailpoet/posts_dynamic_loading
Add dynamic post loading in Posts widget settings [MAILPOET-971]
2017-07-03 17:18:12 +03:00
703ee7ff71 Fix line breaks in tests [MAILPOET-981] 2017-07-03 16:29:21 +03:00
29491dfd3e Fix active coding standard rule violations in tests [MAILPOET-981] 2017-07-03 16:20:44 +03:00
a49a230983 Disable a few failing rules for further fixing [MAILPOET-981] 2017-07-03 14:57:48 +03:00
b8d285a1d9 Add a copy of MailPoet PHP coding standard for tests [MAILPOET-981] 2017-07-03 14:54:04 +03:00
d5227a9f2c Add tests for PDO exceptions rethrowing [MAILPOET-966] 2017-07-03 10:59:38 +01:00
693117eb40 Merge pull request #964 from mailpoet/add-help
Add help [MAILPOET-949]
2017-07-03 12:06:51 +03:00
f3aab6095e Standardizes helper string look (https://goo.gl/r3jqJ8) 2017-07-03 09:35:01 +01:00
d70587a550 Adds helper text to the bottom of forms view 2017-07-03 09:35:01 +01:00
82226f2c36 Updates existing code that replaces links with the new "replaceLink"
filter
2017-07-03 09:35:01 +01:00
2774101380 Adds Twig filter to replace [link] tags inside strings
Adds unit tests
2017-07-03 09:35:01 +01:00
ee0e3ff95e Move <h1> from react
Wordpress moves admin notices bellow the first heading. If we re-render
our heading inside react router we remove those notices. This way the
admin notice stays in the page.

[MAILPOET-949]
2017-07-03 09:08:30 +01:00
17584dde43 Fix help rendering
[MAILPOET-949]
2017-07-03 08:39:02 +01:00
3ac416de56 Allows passing request data to form submission class
Adds unit tests
2017-07-01 11:17:04 -04:00
1e4c00169f Adds AspectMock library to mock static methods/etc. 2017-07-01 11:15:15 -04:00
11bbf54aad Merge pull request #963 from mailpoet/new-templates
New templates [MAILPOET-922]
2017-06-30 11:37:29 -04:00
688e78560e Add minor corrections [MAILPOET-949] 2017-06-30 12:47:47 +03:00
5ca577a718 Fix lint errors [MAILPOET-966] 2017-06-30 09:29:48 +01:00
605df7dff1 Don't open a second (actually, third) DB connection [MAILPOET-966] 2017-06-30 09:29:48 +01:00
fb1a3a80ff Catch a DB connection exception earlier [MAILPOET-966] 2017-06-30 09:29:48 +01:00
d3db755489 Handle exceptions during initialization better [MAILPOET-966] 2017-06-30 09:29:48 +01:00
a4282b6a3e Don't leak connection data in PDO exceptions [MAILPOET-966] 2017-06-30 09:29:48 +01:00
bc17984030 Fix coffee shop template
[MAILPOET-922]
2017-06-30 09:19:26 +01:00
b823991867 Fix lint errors [MAILPOET-971] 2017-06-29 16:45:12 +03:00
04e238634d Add unit tests [MAILPOET-971] 2017-06-29 15:34:26 +03:00
eba482cc67 Add dynamic post loading in Posts widget settings [MAILPOET-971] 2017-06-29 13:13:36 +03:00
e6663f0f3e Hide a horizontal scrollbar in Posts widget listing [MAILPOET-971] 2017-06-29 13:13:23 +03:00
7fa94a67c9 Add data to system info help page
[MAILPOET-949]
2017-06-29 09:34:28 +01:00
b4be9e1d28 Add notice to system info
[MAILPOET-949]
2017-06-28 16:50:31 +01:00
a7504136a2 Add knowledge base page content
[MAILPOET-949]
2017-06-28 15:36:51 +01:00
43fa12ec08 Add help without any content
[MAILPOET-949]
2017-06-28 15:00:53 +01:00
6723a563ed Add yoga studio thumb
[MAILPOET-922]
2017-06-28 11:27:33 +01:00
15e3e93c99 Add Foodbox thumb
[MAILPOET-922]
2017-06-28 10:57:16 +01:00
cbce789ac8 Add thumbnails to templates
[MAILPOET-922]
2017-06-28 10:57:16 +01:00
97607993fb Add newsletter assets to plugin folder
[MAILPOET-922]
2017-06-28 10:57:16 +01:00
334b119bb3 Add News Day template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
ed0b2e6231 Add Coffee Shop template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
ad7ad05ec7 Add Travel Nomads template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
bfba6d459c Add Faith template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
344eecbf11 Add Chocolate Store template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
14dc022d2d Add Science Weekly template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
eff75cce94 Add Piece Of Cake template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
51084fc57d Add Piece Of Cake template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
298270f86c Add Festival Event template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
fe6d5d1523 Add Take a Hike template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
3cceb32ec1 Add Kick-Off template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
c8251a3bcd Add Discount template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
58888505b5 Add Food box template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
558c493dd7 Add World Cup template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
8cdb7d77f6 Add App Welcome template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
539e6d3ee1 Add Burger Joint template
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
c9a0939ddd Remove old templates
[MAILPOET-922]
2017-06-28 10:57:15 +01:00
2add301b9f Bumps up version to 3.0.0-beta.36.1.0 and updates changelog 2017-06-27 16:23:22 -04:00
2d217e416a Merge pull request #960 from mailpoet/fix-build-find
Make build script work on Mac os [MAILPOET-969]
2017-06-27 12:21:25 +03:00
77e0ace951 Merge pull request #961 from mailpoet/post_notification_unit_test_update
Updates the way we test for next run date in newsletter scheduler [MAILPOET-967]
2017-06-27 11:42:30 +03:00
933749f8f0 Merge pull request #941 from mailpoet/mp2tomp3migration
Mp2tomp3migration phase 2
2017-06-26 18:47:58 +03:00
7b13babf3f Merge pull request #958 from mailpoet/improve-ajax-errors
Improve ajax errors [MAILPOET-929]
2017-06-26 17:31:15 +03:00
8c673f78d7 Make build script work on Mac os
[MAILPOET-969]
2017-06-26 15:00:48 +01:00
2285c08c01 Revert "Revert "Improve ajax errors [MAILPOET-929]""
This reverts commit 81c3e2facf.
2017-06-26 13:51:53 +01:00
836b7179e9 Improve ajax errors on form submission
[MAILPOET-929]
2017-06-26 13:43:32 +01:00
f89a728c38 Uses predetermined timestamps from which next run date is calculated 2017-06-24 15:59:28 -04:00
58f2c32362 Allows passing custom time value to calculate the next run date from 2017-06-24 15:59:17 -04:00
99c4fc71c4 Release 3.0.0-beta.36.0.1 2017-06-23 15:48:04 +03:00
ce456af962 Merge pull request #957 from mailpoet/forms_assets_fix
Updates subscription forms to use assets manifest [MAILPOET-964]
2017-06-23 14:59:51 +03:00
faa035a7c3 Updates subscription forms to use assets manifest
Adds unit tests
2017-06-22 20:42:04 -04:00
9066be6544 Merge pull request #956 from mailpoet/revert-955-improve-ajax-errors
Revert "Improve ajax errors [MAILPOET-929]"
2017-06-22 20:35:42 -04:00
81c3e2facf Revert "Improve ajax errors [MAILPOET-929]" 2017-06-22 20:04:10 -04:00
3fafe2bd6a Merge pull request #955 from mailpoet/improve-ajax-errors
Improve ajax errors [MAILPOET-929]
2017-06-22 21:37:47 +03:00
2f6fe8c804 Translate error message
[MAILPOET-929]
2017-06-22 16:47:36 +01:00
ec3e88e658 Improve error handling for failed AJAX requests
[MAILPOET-929]
2017-06-22 13:35:55 +01:00
b346a8846a Merge pull request #949 from mailpoet/shortcodes-subject-archive
Print rendered subject in archive [MAILPOET-826]
2017-06-22 07:41:11 -04:00
6ff3895940 Add missing this for stubs expecting a number of method calls to work 2017-06-22 11:55:15 +01:00
0e5401dd68 Fix keys being invalidated after saving settings [MAILPOET-963] 2017-06-22 11:55:15 +01:00
ea059ac0e4 Merge pull request #954 from mailpoet/android-gmail-fix
Hide preheader in gmail on android [MAILPOET-802]
2017-06-22 12:50:42 +03:00
f874ae6ca8 Fix line endings
[MAILPOET-929]
2017-06-22 10:25:07 +01:00
5bd6c6533a Fixed: Skip button is vanishinig by itself in seconds 2017-06-21 19:24:07 +02:00
f539860922 Remove trailing spaces 2017-06-21 19:24:06 +02:00
536267c8f5 Fixed: Form fields were not inactive when used 2017-06-21 19:24:05 +02:00
5b905a60e8 Fixed: Unit test testReplaceMP2Shortcodes 2017-06-21 19:24:05 +02:00
5e152ebaa1 Fixed: Wrong date format on front-end 2017-06-21 19:24:04 +02:00
2c35c7061e Fixed: Display "Invalid e-mail" on the front-end whereas the e-mail is correct 2017-06-21 19:24:03 +02:00
2515dcf4ce Fixed: Wrong HTML encoding of the text fields 2017-06-21 19:24:02 +02:00
9458bf7418 Add Unit tests for MP2 to MP3 migration phase 2 2017-06-21 19:24:01 +02:00
44bf4b98b8 MP2 to MP3 migration phase 2: Forms migration 2017-06-21 19:24:01 +02:00
ff46784adf Merge pull request #952 from mailpoet/assets_manifest
Uses cross-env to set environment variables [MAILPOET-919]
2017-06-21 19:31:20 +03:00
088d4f800d Hide preheader in gmail on android
[MAILPOET-802]
2017-06-21 17:23:57 +01:00
bb73e257db Uses cross-env to set environment variables
Adds manifests to .gitingore
2017-06-21 10:28:40 -04:00
53fd3fe07c Update lstings to display rendered subject line
[MAILPOET-826]
2017-06-21 13:43:16 +01:00
27a734d005 Not include sensitive data in rendered subject
[MAILPOET-826]
2017-06-21 10:25:40 +01:00
fb059f585e Print rendered subject in archive
[MAILPOET-826]
2017-06-21 10:25:40 +01:00
c99f990dbf Fixes undefined index notice when analytics option is not present in the
DB
2017-06-21 08:31:37 +01:00
574 changed files with 27656 additions and 11463 deletions

View File

@ -1,8 +0,0 @@
#!/usr/bin/ruby
path = "/tmp"
Dir.mkdir(path) if !File.exists?(path)
File.open("#{path}/mailpoet-#{Time.now.to_f}.txt", "w") do |f|
sleep 5
f.puts ARGV.inspect
$stdin.each_line { |line| f.puts line }
end

View File

@ -1,3 +0,0 @@
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /home/ubuntu/mailpoet/.circle_ci/fake-sendmail.rb

View File

@ -3,11 +3,11 @@ Listen 8080
<VirtualHost *:8080> <VirtualHost *:8080>
UseCanonicalName Off UseCanonicalName Off
ServerName mailpoet.loc ServerName mailpoet.loc
DocumentRoot /home/ubuntu/mailpoet/wordpress DocumentRoot /home/circleci/mailpoet/wordpress
DirectoryIndex index.php DirectoryIndex index.php
LogLevel notice LogLevel notice
<Directory /home/ubuntu/mailpoet/wordpress> <Directory /home/circleci/mailpoet/wordpress>
Require all granted Require all granted
</Directory> </Directory>
</VirtualHost> </VirtualHost>

137
.circleci/config.yml Normal file
View File

@ -0,0 +1,137 @@
version: 2
jobs:
qa_js_php5:
working_directory: /home/circleci/mailpoet
docker:
- image: circleci/php:5.6.30-apache-browsers
- image: circleci/mysql:5.7
environment:
TZ: /usr/share/zoneinfo/Etc/UTC
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: source ./.circleci/setup.bash && setup php5
- save_cache:
key: composer-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
paths:
- vendor
- save_cache:
key: npm-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: "QA Scripts"
command: ./do qa
- run:
name: "Preparing test results folder"
command: mkdir test-results
- run:
name: "JS tests"
command: |
mkdir test-results/mocha
./do t:j test-results/mocha/junit.xml
- run:
name: "PHP Unit tests"
command: |
WP_TEST_PATH="/home/circleci/mailpoet/wordpress" ./do t:u --xml
- store_test_results:
path: test-results/mocha
- store_artifacts:
path: test-results/mocha
destination: mocha
- store_test_results:
path: tests/_output
- store_artifacts:
path: tests/_output
destination: codeception
- 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:
- image: circleci/php:7.1-apache-browsers
- image: circleci/mysql:5.7
environment:
TZ: /usr/share/zoneinfo/Etc/UTC
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: source ./.circleci/setup.bash && setup php7
- run:
name: "PHP Unit tests"
command: |
WP_TEST_PATH="/home/circleci/mailpoet/wordpress" ./do t:u --xml
- store_test_results:
path: tests/_output
- store_artifacts:
path: tests/_output
destination: codeception
- store_artifacts:
path: /tmp/fake-mailer/
destination: fake-mailer
workflows:
version: 2
build_and_test:
jobs:
- qa_js_php5
- php7
- acceptance_tests

17
.circleci/fake-sendmail.php Executable file
View File

@ -0,0 +1,17 @@
#!/usr/local/bin/php
<?php
$path = "/tmp/fake-mailer";
if(!file_exists($path)) {
mkdir($path);
}
$filename = $path . '/mailpoet-' . microtime(true) . '.txt';
$file_handle = fopen($filename, "w");
$call_arguments = print_r($argv, true) . "\n";
fwrite($file_handle, $call_arguments);
while($line = fgets(STDIN)) {
fwrite($file_handle, $line);
}
fclose($file_handle);

View File

@ -0,0 +1,9 @@
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/local/bin/fake-sendmail.php
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = UTC

48
.circleci/setup.bash Normal file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env bash
function setup {
local version=$1
# install PHP dependencies for WordPress
if [[ $version == "php7" ]]; then
echo "deb http://packages.dotdeb.org jessie all" | sudo tee -a /etc/apt/sources.list.d/dotdeb.list
echo "deb-src http://packages.dotdeb.org jessie all" | sudo tee -a /etc/apt/sources.list.d/dotdeb.list
wget -qO - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install mysql-client php7.0-mysql zlib1g-dev
sudo docker-php-ext-install mysqli pdo pdo_mysql zip
else
sudo apt-get update
sudo apt-get install mysql-client php5-mysql zlib1g-dev
sudo docker-php-ext-install mysql mysqli pdo pdo_mysql zip
fi
# Add a fake sendmail mailer
sudo cp ./.circleci/fake-sendmail.php /usr/local/bin/
# configure Apache
sudo cp ./.circleci/mailpoet_php.ini /usr/local/etc/php/conf.d/
sudo cp ./.circleci/apache/mailpoet.loc.conf /etc/apache2/sites-available
sudo a2ensite mailpoet.loc
sudo a2enmod rewrite
sudo service apache2 restart
# 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
./composer.phar install
./do install
# Set up Wordpress
mysql -h 127.0.0.1 -u root -e "create database wordpress"
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
./wp-cli.phar core download --allow-root --path=wordpress
# Generate `wp-config.php` file with debugging enabled
echo "define(\"WP_DEBUG\", true);" | ./wp-cli.phar core config --allow-root --dbname=wordpress --dbuser=root --dbhost=127.0.0.1 --path=wordpress --extra-php
# Install WordPress
./wp-cli.phar core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@mailpoet.loc --url=http://mailpoet.loc:8080 --title=WordPress --path=wordpress
# Softlink plugin to plugin path
ln -s ../../.. wordpress/wp-content/plugins/mailpoet
./wp-cli.phar plugin activate mailpoet --path=wordpress
# Create .env file with correct path to WP installation
# TODO: Remove this line after PR gets merged and CircleCI env variables change
echo "WP_TEST_PATH=\"/home/circleci/mailpoet/wordpress\"" > .env
}

View File

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

View File

@ -11,9 +11,8 @@
} }
}, },
"rules": { "rules": {
"comma-dangle": ["error", "always-multiline"],
"import/no-amd": 0, "import/no-amd": 0,
"react/no-multi-comp": 0, "react/no-multi-comp": 0,
"react/sort-comp": 0, "react/sort-comp": 0,
"react/jsx-max-props-per-line": 0, "react/jsx-max-props-per-line": 0,
@ -34,40 +33,24 @@
"react/jsx-curly-spacing": 0, "react/jsx-curly-spacing": 0,
"react/no-did-mount-set-state": 0, "react/no-did-mount-set-state": 0,
"react/prefer-stateless-function": 0, "react/prefer-stateless-function": 0,
"jsx-a11y/label-has-for": 0, "jsx-a11y/label-has-for": 0,
"jsx-a11y/no-static-element-interactions": 0, "jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/alt-text": 0, "jsx-a11y/alt-text": 0,
"comma-dangle": 0,
"prefer-arrow-callback": 0,
"func-names": 0, "func-names": 0,
"space-before-function-paren": 0,
"object-shorthand": 0, "object-shorthand": 0,
"no-bitwise": 0, "no-bitwise": 0,
"arrow-body-style": 0, "arrow-body-style": 0,
"prefer-template": 0, "prefer-template": 0,
"eol-last": 0,
"no-unused-vars": 0,
"no-plusplus": 0,
"semi": 0,
"keyword-spacing": 0, "keyword-spacing": 0,
"default-case": 0, "default-case": 0,
"quote-props": 0,
"indent": 0,
"prefer-const": 0,
"arrow-parens": 0,
"array-callback-return": 0, "array-callback-return": 0,
"consistent-return": 0, "consistent-return": 0,
"no-unreachable": 0, "no-unreachable": 0,
"no-extra-semi": 0,
"import/no-unresolved": 0, "import/no-unresolved": 0,
"import/extensions": 0, "import/extensions": 0,
"import/no-extraneous-dependencies": 0, "import/no-extraneous-dependencies": 0,
"camelcase": 0, "camelcase": 0,
"template-curly-spacing": 0, "template-curly-spacing": 0,
"quotes": 0,
"radix": 0,
"eqeqeq": 0, "eqeqeq": 0,
"no-lonely-if": 0, "no-lonely-if": 0,
"space-unary-ops": 0, "space-unary-ops": 0,
@ -76,33 +59,27 @@
"no-multi-spaces": 0, "no-multi-spaces": 0,
"class-methods-use-this": 0, "class-methods-use-this": 0,
"key-spacing": 0, "key-spacing": 0,
"no-multiple-empty-lines": 0,
"space-in-parens": 0, "space-in-parens": 0,
"no-case-declarations": 0, "no-case-declarations": 0,
"array-bracket-spacing": 0, "array-bracket-spacing": 0,
"newline-per-chained-call": 0,
"no-else-return": 0, "no-else-return": 0,
"max-len": 0, "max-len": 0,
"comma-spacing": 0,
"no-useless-concat": 0, "no-useless-concat": 0,
"no-unused-expressions": 0, "no-unused-expressions": 0,
"no-sequences": 0, "no-sequences": 0,
"no-extra-boolean-cast": 0, "no-extra-boolean-cast": 0,
"dot-notation": 0, "dot-notation": 0,
"no-param-reassign": 0,
"no-shadow": 0, "no-shadow": 0,
"one-var": 0, "one-var": 0,
"no-alert": 0, "no-alert": 0,
"one-var-declaration-per-line": 0, "one-var-declaration-per-line": 0,
"no-script-url": 0, "no-script-url": 0,
"wrap-iife": 0, "wrap-iife": 0,
"no-var": 0,
"vars-on-top": 0, "vars-on-top": 0,
"space-infix-ops": 0, "space-infix-ops": 0,
"no-irregular-whitespace": 0, "no-irregular-whitespace": 0,
"padded-blocks": 0, "padded-blocks": 0,
"no-underscore-dangle": 0, "no-underscore-dangle": 0,
"object-curly-spacing": 0,
"no-undef": 0 "no-undef": 0
} }
} }

View File

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

1
.gitignore vendored
View File

@ -3,7 +3,6 @@ TODO
composer.phar composer.phar
/vendor /vendor
tests/_output/* tests/_output/*
tests/acceptance.suite.yml
tests/_support/_generated/* tests/_support/_generated/*
node_modules node_modules
.env .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. 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. 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

@ -79,7 +79,7 @@ class RoboFile extends \Robo\Tasks {
function compileJs($opts = ['env' => null]) { function compileJs($opts = ['env' => null]) {
$env = ($opts['env']) ? $env = ($opts['env']) ?
sprintf('NODE_ENV="%s"', $opts['env']) : sprintf('./node_modules/cross-env/dist/bin/cross-env.js NODE_ENV="%s"', $opts['env']) :
null; null;
return $this->_exec($env . ' ./node_modules/webpack/bin/webpack.js --bail'); return $this->_exec($env . ' ./node_modules/webpack/bin/webpack.js --bail');
} }
@ -154,9 +154,8 @@ class RoboFile extends \Robo\Tasks {
function testUnit($opts=['file' => null, 'xml' => false]) { function testUnit($opts=['file' => null, 'xml' => false]) {
$this->loadEnv(); $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']) { if($opts['xml']) {
$command .= ' --xml'; $command .= ' --xml';
@ -166,9 +165,8 @@ class RoboFile extends \Robo\Tasks {
function testCoverage($opts=['file' => null, 'xml' => false]) { function testCoverage($opts=['file' => null, 'xml' => false]) {
$this->loadEnv(); $this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$command = join(' ', array( $command = join(' ', array(
'vendor/bin/codecept run', 'vendor/bin/codecept run unit -c codeception.unit.yml ',
(($opts['file']) ? $opts['file'] : ''), (($opts['file']) ? $opts['file'] : ''),
'--coverage', '--coverage',
($opts['xml']) ? '--coverage-xml' : '--coverage-html' ($opts['xml']) ? '--coverage-xml' : '--coverage-html'
@ -199,16 +197,26 @@ class RoboFile extends \Robo\Tasks {
return $this->_exec($command); return $this->_exec($command);
} }
function testDebug() { function testDebug($opts=['file' => null, 'xml' => false]) {
$this->_exec('vendor/bin/codecept build');
$this->loadEnv(); $this->loadEnv();
return $this->_exec('vendor/bin/codecept run unit --debug'); $this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml --debug -f '.(($opts['file']) ? $opts['file'] : '');
if($opts['xml']) {
$command .= ' --xml';
}
return $this->_exec($command);
}
function testAcceptance() {
return $this->_exec('COMPOSE_HTTP_TIMEOUT=200 docker-compose run codeception --steps --debug -vvv');
} }
function testFailed() { function testFailed() {
$this->loadEnv(); $this->loadEnv();
$this->_exec('vendor/bin/codecept build'); $this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
return $this->_exec('vendor/bin/codecept run -g failed'); return $this->_exec('vendor/bin/codecept run -c codeception.unit.yml -g failed');
} }
function qa() { function qa() {
@ -235,14 +243,25 @@ class RoboFile extends \Robo\Tasks {
} else { } else {
$severityFlag = '-n'; $severityFlag = '-n';
} }
return $this->_exec( return $this->collectionBuilder()
'./vendor/bin/phpcs '. ->taskExec(
'--standard=./tasks/code_sniffer/MailPoet '. './vendor/bin/phpcs '.
'--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'. '--standard=./tasks/code_sniffer/MailPoet '.
'./lib/Util/pQuery/*,./lib/Config/PopulatorData/Templates/* '. '--runtime-set testVersion 5.3-7.0 '.
'lib/ '. '--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'.
$severityFlag './lib/Util/pQuery/*,./lib/Config/PopulatorData/Templates/* '.
); 'lib/ '.
$severityFlag
)
->taskExec(
'./vendor/bin/phpcs '.
'--standard=./tasks/code_sniffer/MailPoet '.
'--runtime-set testVersion 5.4-7.0 '.
'--ignore=./tests/unit/_bootstrap.php '.
'tests/unit/ '.
$severityFlag
)
->run();
} }
function svnCheckout() { function svnCheckout() {
@ -275,8 +294,9 @@ class RoboFile extends \Robo\Tasks {
$plugin_data = get_plugin_data('mailpoet.php', false, false); $plugin_data = get_plugin_data('mailpoet.php', false, false);
$plugin_version = $plugin_data['Version']; $plugin_version = $plugin_data['Version'];
$plugin_dist_name = sanitize_title_with_dashes($plugin_data['Name']); $plugin_dist_name = sanitize_title_with_dashes($plugin_data['Name']);
$plugin_dist_name = explode('-', $plugin_dist_name);
$plugin_dist_name = $plugin_dist_name[0];
$plugin_dist_file = $plugin_dist_name . '.zip'; $plugin_dist_file = $plugin_dist_name . '.zip';
$this->say('Publishing version: ' . $plugin_version); $this->say('Publishing version: ' . $plugin_version);
// Sanity checks // Sanity checks
@ -404,4 +424,4 @@ class RoboFile extends \Robo\Tasks {
require_once(ABSPATH . WPINC . '/plugin.php'); require_once(ABSPATH . WPINC . '/plugin.php');
require_once(ABSPATH . 'wp-admin/includes/plugin.php'); require_once(ABSPATH . 'wp-admin/includes/plugin.php');
} }
} }

View File

@ -24,5 +24,6 @@
@require 'subscribers' @require 'subscribers'
@require 'pages' @require 'pages'
@require 'pages_custom'
@require 'mp2migrator' @require 'mp2migrator'

View File

@ -21,6 +21,9 @@ a:focus
.mailpoet_spaced_block .mailpoet_spaced_block
margin: 1em 0 margin: 1em 0
.mailpoet_centered
text-align: center
// select 2 // select 2
.select2-container .select2-container
width: 25em !important width: 25em !important

View File

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

View File

@ -179,6 +179,28 @@ select.mailpoet_font-size
width: 100% width: 100%
box-sizing: border-box 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 .mailpoet_button_primary
border-color: $button-primary-border-color border-color: $button-primary-border-color
background-color: $button-primary-background-color background-color: $button-primary-background-color

View File

@ -62,3 +62,9 @@ $draggable-widget-z-index = 2
background-color: $primary-active-color background-color: $primary-active-color
box-shadow(inset 1px 2px 1px $primary-inset-shadow-color) box-shadow(inset 1px 2px 1px $primary-inset-shadow-color)
color: $white-color color: $white-color
.mailpoet_droppable_block
cursor: move
&.mailpoet_ignore_drag
cursor: auto

View File

@ -26,10 +26,6 @@ $block-text-line-height = $text-line-height
&.mailpoet_highlight > .mailpoet_block_highlight &.mailpoet_highlight > .mailpoet_block_highlight
border: 1px dashed $block-hover-highlight-color border: 1px dashed $block-hover-highlight-color
.mailpoet_block:last-child
margin-bottom: 0
.mailpoet_content .mailpoet_content
position: relative position: relative
line-height: $block-text-line-height line-height: $block-text-line-height

View File

@ -18,6 +18,7 @@
.mailpoet_settings_posts_display_options .mailpoet_settings_posts_display_options
.mailpoet_settings_posts_selection .mailpoet_settings_posts_selection
animation-slide-open-downwards() animation-slide-open-downwards()
overflow-x: hidden
.mailpoet_settings_posts_show_display_options, .mailpoet_settings_posts_show_display_options,
.mailpoet_settings_posts_show_post_selection .mailpoet_settings_posts_show_post_selection
@ -26,7 +27,12 @@
.mailpoet_post_selection_container .mailpoet_post_selection_container
margin-top: 20px margin-top: 20px
margin-bottom: 20px margin-bottom: 0
.mailpoet_post_scroll_container
overflow-y: scroll
overflow-x: hidden
max-height: 400px
.mailpoet_settings_posts_single_post .mailpoet_settings_posts_single_post
border-radius(1px) border-radius(1px)
@ -45,3 +51,6 @@
.mailpoet_select_post_checkbox .mailpoet_select_post_checkbox
margin-left: 10px margin-left: 10px
margin-right: 8px margin-right: 8px
.mailpoet_post_selection_loading
color: #999

View File

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

View File

@ -2,6 +2,7 @@
Based on /wp-admin/css/about.css of WP 4.7. Based on /wp-admin/css/about.css of WP 4.7.
This is to make MailPoet pages independent of the WordPress This is to make MailPoet pages independent of the WordPress
About page styles that may differ across WP versions. About page styles that may differ across WP versions.
Please add custom styles to pages_custom.styl
*/ */
.mailpoet-about-wrap .mailpoet-about-wrap

View File

@ -0,0 +1,35 @@
/*
Custom styles for MailPoet pages.
*/
.mailpoet-about-wrap
.videoWrapper
position: relative
padding-bottom: 56.25% /* 16:9 */
/*padding-top: 25px*/
height: 0
iframe
position: absolute
top: 0
left: 0
width: 100%
height: 100%
.mailpoet_video
border: 1px solid rgba(0, 0, 0, 0.1)
#mailpoet-changelog ul
list-style: disc
padding-left: 20px
h2.mailpoet-feature-top
margin: 50px auto
a.button.go-to-plugin
margin-top: 2em
p.top-space-triple
margin-top: 3em

View File

@ -9,15 +9,25 @@
// sending methods // sending methods
.mailpoet_sending_methods .mailpoet_sending_methods
margin 25px 0 0 0 margin 25px 0 0 0
li display flex
float left flex-direction row
position relative justify-content flex-start
padding 15px 15px 0 15px > li
flex-grow 1
flex-shrink 1
display flex
flex-direction column
flex-basis 0
margin 0 25px 25px 0 margin 0 25px 25px 0
width 300px
height 300px
border 1px solid #dedede border 1px solid #dedede
background-color #fff background-color #fff
max-width 500px
.mailpoet_sending_method_description
padding: 25px
flex-grow 1
flex-shrink 0
> li:last-child
margin-right 0
h3 h3
text-align center text-align center
height 54px height 54px
@ -25,12 +35,12 @@
.mailpoet_description .mailpoet_description
font-size 14px font-size 14px
.mailpoet_status .mailpoet_status
display flex
flex-direction row
justify-content space-between
align-items center
background-color #2f2f2f background-color #2f2f2f
color #fff color #fff
position absolute
bottom 0
left 0
right 0
text-overflow ellipsis text-overflow ellipsis
padding 15px padding 15px
span span
@ -43,23 +53,20 @@
visibility visible visibility visible
#mailpoet_mta_activate #mailpoet_mta_activate
visibility hidden visibility hidden
.mailpoet_actions
bottom 15px
color #fff
padding 0
position absolute
right 15px
.button-secondary
margin 0 -6px -4px 0
// premium key .tooltip.dashicons.dashicons-editor-help
.mailpoet_key line-height: 1.4
&_valid
&::before ul.sending-method-benefits
content ' ' list-style-type: none
&_invalid margin-bottom: 2em
&::before margin-top: 2em
content: ' '
.mailpoet_success_item::before
content ' '
.mailpoet_error_item::before
content ' '
// responsive // responsive
@media screen and (max-width: 782px) @media screen and (max-width: 782px)
@ -67,8 +74,10 @@
width auto width auto
.mailpoet_sending_methods .mailpoet_sending_methods
li flex-flow: row wrap
float none justify-content: space-around
width auto > li
margin-right 0 margin-right 0
flex-basis auto

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 814 B

View File

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

View File

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

View File

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

View File

@ -4,12 +4,14 @@ define('date',
'jquery', 'jquery',
'moment' 'moment'
], function( ], function(
MailPoet, mp,
jQuery, jQuery,
Moment Moment
) { ) {
'use strict'; 'use strict';
var MailPoet = mp;
MailPoet.Date = { MailPoet.Date = {
version: 0.1, version: 0.1,
options: {}, options: {},
@ -17,8 +19,8 @@ define('date',
offset: 0, offset: 0,
format: 'F, d Y H:i:s' format: 'F, d Y H:i:s'
}, },
init: function(options) { init: function (opts) {
options = options || {}; var options = opts || {};
// set UTC offset // set UTC offset
if ( if (
@ -39,16 +41,16 @@ define('date',
return this; return this;
}, },
format: function(date, options) { format: function(date, opts) {
options = options || {}; var options = opts || {};
this.init(options); this.init(options);
var date = Moment(date, this.convertFormat(options.parseFormat)); var momentDate = Moment(date, this.convertFormat(options.parseFormat));
if (options.offset === 0) date = date.utc(); if (options.offset === 0) momentDate = momentDate.utc();
return date.format(this.convertFormat(this.options.format)); return momentDate.format(this.convertFormat(this.options.format));
}, },
toDate: function(date, options) { toDate: function(date, opts) {
options = options || {}; var options = opts || {};
this.init(options); this.init(options);
return Moment(date, this.convertFormat(options.parseFormat)).toDate(); return Moment(date, this.convertFormat(options.parseFormat)).toDate();
@ -143,7 +145,8 @@ define('date',
var convertedFormat = []; var convertedFormat = [];
var escapeToken = false; var escapeToken = false;
for(var index = 0, token = ''; token = format.charAt(index); index++){ for(var index = 0, token = ''; format.charAt(index); index += 1){
token = format.charAt(index);
if (escapeToken === true) { if (escapeToken === true) {
convertedFormat.push('['+token+']'); convertedFormat.push('['+token+']');
escapeToken = false; escapeToken = false;

View File

@ -1,15 +1,15 @@
define([ define([
'react' 'react',
], ],
function( (
React React
) { ) => {
const FormFieldCheckbox = React.createClass({ const FormFieldCheckbox = React.createClass({
onValueChange: function(e) { onValueChange: function (e) {
e.target.value = this.refs.checkbox.checked ? '1' : '0'; e.target.value = this.refs.checkbox.checked ? '1' : '0';
return this.props.onValueChange(e); return this.props.onValueChange(e);
}, },
render: function() { render: function () {
if (this.props.field.values === undefined) { if (this.props.field.values === undefined) {
return false; return false;
} }
@ -42,8 +42,8 @@ function(
{ options } { options }
</div> </div>
); );
} },
}); });
return FormFieldCheckbox; return FormFieldCheckbox;
}); });

View File

@ -1,10 +1,10 @@
define([ define([
'react', 'react',
'moment', 'moment',
], function( ], (
React, React,
Moment Moment
) { ) => {
class FormFieldDateYear extends React.Component { class FormFieldDateYear extends React.Component {
render() { render() {
const yearsRange = 100; const yearsRange = 100;
@ -17,7 +17,7 @@ define([
} }
const currentYear = Moment().year(); const currentYear = Moment().year();
for (let i = currentYear; i >= currentYear - yearsRange; i--) { for (let i = currentYear; i >= currentYear - yearsRange; i -= 1) {
years.push(( years.push((
<option <option
key={ i } key={ i }
@ -47,7 +47,7 @@ define([
)); ));
} }
for (let i = 1; i <= 12; i++) { for (let i = 1; i <= 12; i += 1) {
months.push(( months.push((
<option <option
key={ i } key={ i }
@ -77,7 +77,7 @@ define([
)); ));
} }
for (let i = 1; i <= 31; i++) { for (let i = 1; i <= 31; i += 1) {
days.push(( days.push((
<option <option
key={ i } key={ i }
@ -104,13 +104,13 @@ define([
this.state = { this.state = {
year: '', year: '',
month: '', month: '',
day: '' day: '',
} };
} }
componentDidMount() { componentDidMount() {
this.extractDateParts(); this.extractDateParts();
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps) {
if ( if (
(this.props.item !== undefined && prevProps.item !== undefined) (this.props.item !== undefined && prevProps.item !== undefined)
&& (this.props.item.id !== prevProps.item.id) && (this.props.item.id !== prevProps.item.id)
@ -132,7 +132,7 @@ define([
this.setState({ this.setState({
year: dateTime.format('YYYY'), year: dateTime.format('YYYY'),
month: dateTime.format('M'), month: dateTime.format('M'),
day: dateTime.format('D') day: dateTime.format('D'),
}); });
} }
formatValue() { formatValue() {
@ -143,30 +143,30 @@ define([
switch(dateType) { switch(dateType) {
case 'year_month_day': case 'year_month_day':
value = { value = {
'year': this.state.year, year: this.state.year,
'month': this.state.month, month: this.state.month,
'day': this.state.day day: this.state.day,
}; };
break; break;
case 'year_month': case 'year_month':
value = { value = {
'year': this.state.year, year: this.state.year,
'month': this.state.month month: this.state.month,
}; };
break; break;
case 'month': case 'month':
value = { value = {
'month': this.state.month month: this.state.month,
}; };
break; break;
case 'year': case 'year':
value = { value = {
'year': this.state.year year: this.state.year,
}; };
break; break;
} }
return value; return value;
@ -181,16 +181,16 @@ define([
field = matches[1]; field = matches[1];
property = matches[2]; property = matches[2];
let value = ~~(e.target.value); const value = ~~(e.target.value);
this.setState({ this.setState({
[`${property}`]: value [`${property}`]: value,
}, () => { }, () => {
this.props.onValueChange({ this.props.onValueChange({
target: { target: {
name: field, name: field,
value: this.formatValue() value: this.formatValue(),
} },
}); });
}); });
} }
@ -201,7 +201,7 @@ define([
const dateType = this.props.field.params.date_type; const dateType = this.props.field.params.date_type;
const dateSelects = dateFormats[dateType][0].split('/'); const dateSelects = dateFormats[dateType][0].split('/');
const fields = dateSelects.map(type => { const fields = dateSelects.map((type) => {
switch(type) { switch(type) {
case 'YYYY': case 'YYYY':
return (<FormFieldDateYear return (<FormFieldDateYear
@ -212,7 +212,7 @@ define([
year={ this.state.year } year={ this.state.year }
placeholder={ this.props.field.year_placeholder } placeholder={ this.props.field.year_placeholder }
/>); />);
break; break;
case 'MM': case 'MM':
return (<FormFieldDateMonth return (<FormFieldDateMonth
@ -224,7 +224,7 @@ define([
monthNames={ monthNames } monthNames={ monthNames }
placeholder={ this.props.field.month_placeholder } placeholder={ this.props.field.month_placeholder }
/>); />);
break; break;
case 'DD': case 'DD':
return (<FormFieldDateDay return (<FormFieldDateDay
@ -235,9 +235,9 @@ define([
day={ this.state.day } day={ this.state.day }
placeholder={ this.props.field.day_placeholder } placeholder={ this.props.field.day_placeholder }
/>); />);
break; break;
} }
}); });
return ( return (
<div> <div>
@ -245,7 +245,7 @@ define([
</div> </div>
); );
} }
}; }
return FormFieldDate; return FormFieldDate;
}); });

View File

@ -8,7 +8,7 @@ define([
'form/fields/selection.jsx', 'form/fields/selection.jsx',
'form/fields/date.jsx', 'form/fields/date.jsx',
], ],
function( (
React, React,
FormFieldText, FormFieldText,
FormFieldTextarea, FormFieldTextarea,
@ -17,54 +17,55 @@ function(
FormFieldCheckbox, FormFieldCheckbox,
FormFieldSelection, FormFieldSelection,
FormFieldDate FormFieldDate
) { ) => {
var FormField = React.createClass({ const FormField = React.createClass({
renderField: function(data, inline = false) { renderField: function (data, inline = false) {
var description = false; let description = false;
if(data.field.description) { if(data.field.description) {
description = ( description = (
<p className="description">{ data.field.description }</p> <p className="description">{ data.field.description }</p>
); );
} }
var field = false; let field = false;
let dataField = data.field;
if(data.field['field'] !== undefined) { 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': case 'text':
field = (<FormFieldText {...data} />); field = (<FormFieldText {...data} />);
break; break;
case 'textarea': case 'textarea':
field = (<FormFieldTextarea {...data} />); field = (<FormFieldTextarea {...data} />);
break; break;
case 'select': case 'select':
field = (<FormFieldSelect {...data} />); field = (<FormFieldSelect {...data} />);
break; break;
case 'radio': case 'radio':
field = (<FormFieldRadio {...data} />); field = (<FormFieldRadio {...data} />);
break; break;
case 'checkbox': case 'checkbox':
field = (<FormFieldCheckbox {...data} />); field = (<FormFieldCheckbox {...data} />);
break; break;
case 'selection': case 'selection':
field = (<FormFieldSelection {...data} />); field = (<FormFieldSelection {...data} />);
break; break;
case 'date': case 'date':
field = (<FormFieldDate {...data} />); field = (<FormFieldDate {...data} />);
break; break;
case 'reactComponent': case 'reactComponent':
field = (<data.field.component {...data} />); field = (<data.field.component {...data} />);
break; break;
} }
if(inline === true) { if(inline === true) {
@ -83,23 +84,23 @@ function(
); );
} }
}, },
render: function() { render: function () {
var field = false; let field = false;
if(this.props.field['fields'] !== undefined) { if(this.props.field['fields'] !== undefined) {
field = this.props.field.fields.map(function(subfield, index) { field = this.props.field.fields.map((subfield, index) => {
return this.renderField({ return this.renderField({
index: index, index: index,
field: subfield, field: subfield,
item: this.props.item, item: this.props.item,
onValueChange: this.props.onValueChange || false onValueChange: this.props.onValueChange || false,
}); });
}.bind(this)); });
} else { } else {
field = this.renderField(this.props); field = this.renderField(this.props);
} }
var tip = false; let tip = false;
if(this.props.field.tip) { if(this.props.field.tip) {
tip = ( tip = (
<p className="description">{ this.props.field.tip }</p> <p className="description">{ this.props.field.tip }</p>
@ -121,7 +122,7 @@ function(
</td> </td>
</tr> </tr>
); );
} },
}); });
return FormField; return FormField;

View File

@ -1,11 +1,11 @@
define([ define([
'react' 'react',
], ],
function( (
React React
) { ) => {
const FormFieldRadio = React.createClass({ const FormFieldRadio = React.createClass({
render: function() { render: function () {
if (this.props.field.values === undefined) { if (this.props.field.values === undefined) {
return false; return false;
} }
@ -34,8 +34,8 @@ function(
{ options } { options }
</div> </div>
); );
} },
}); });
return FormFieldRadio; return FormFieldRadio;
}); });

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react';
import _ from 'underscore' import _ from 'underscore';
const FormFieldSelect = React.createClass({ const FormFieldSelect = React.createClass({
render() { render() {
@ -33,12 +33,12 @@ const FormFieldSelect = React.createClass({
_.map( _.map(
_.sortBy( _.sortBy(
_.pairs(this.props.field.values), _.pairs(this.props.field.values),
(item) => sortBy(item[0], item[1]) item => sortBy(item[0], item[1])
), ),
(item) => item[0] item => item[0]
); );
} else { } else {
keys = Object.keys(this.props.field.values) keys = Object.keys(this.props.field.values);
} }
const options = keys.map( const options = keys.map(
@ -70,7 +70,7 @@ const FormFieldSelect = React.createClass({
{options} {options}
</select> </select>
); );
} },
}); });
module.exports = FormFieldSelect; module.exports = FormFieldSelect;

View File

@ -2,35 +2,35 @@ define([
'react', 'react',
'react-dom', 'react-dom',
'jquery', 'jquery',
'select2' 'select2',
], ],
function( (
React, React,
ReactDOM, ReactDOM,
jQuery jQuery
) { ) => {
var Selection = React.createClass({ const Selection = React.createClass({
getInitialState: function() { getInitialState: function () {
return { return {
items: [], items: [],
select2: false select2: false,
}; };
}, },
componentWillMount: function() { componentWillMount: function () {
this.loadCachedItems(); this.loadCachedItems();
}, },
allowMultipleValues: function() { allowMultipleValues: function () {
return (this.props.field.multiple === true); return (this.props.field.multiple === true);
}, },
isSelect2Initialized: function() { isSelect2Initialized: function () {
return (this.state.select2 === true); return (this.state.select2 === true);
}, },
componentDidMount: function() { componentDidMount: function () {
if(this.allowMultipleValues()) { if(this.allowMultipleValues()) {
this.setupSelect2(); this.setupSelect2();
} }
}, },
componentDidUpdate: function(prevProps, prevState) { componentDidUpdate: function (prevProps) {
if( if(
(this.props.item !== undefined && prevProps.item !== undefined) (this.props.item !== undefined && prevProps.item !== undefined)
&& (this.props.item.id !== prevProps.item.id) && (this.props.item.id !== prevProps.item.id)
@ -40,24 +40,24 @@ function(
.trigger('change'); .trigger('change');
} }
}, },
componentWillUnmount: function() { componentWillUnmount: function () {
if(this.allowMultipleValues()) { if(this.allowMultipleValues()) {
this.destroySelect2(); this.destroySelect2();
} }
}, },
destroySelect2: function() { destroySelect2: function () {
if(this.isSelect2Initialized()) { if(this.isSelect2Initialized()) {
jQuery('#'+this.refs.select.id).select2('destroy'); jQuery('#'+this.refs.select.id).select2('destroy');
} }
}, },
setupSelect2: function() { setupSelect2: function () {
if(this.isSelect2Initialized()) { if(this.isSelect2Initialized()) {
return; return;
} }
var select2 = jQuery('#'+this.refs.select.id).select2({ const select2 = jQuery('#'+this.refs.select.id).select2({
width: (this.props.width || ''), width: (this.props.width || ''),
templateResult: function(item) { templateResult: function (item) {
if(item.element && item.element.selected) { if(item.element && item.element.selected) {
return null; return null;
} else { } else {
@ -67,14 +67,14 @@ function(
return item.text; return item.text;
} }
} }
} },
}); });
var hasRemoved = false; let hasRemoved = false;
select2.on('select2:unselecting', function(e) { select2.on('select2:unselecting', () => {
hasRemoved = true; hasRemoved = true;
}); });
select2.on('select2:opening', function(e) { select2.on('select2:opening', (e) => {
if(hasRemoved === true) { if(hasRemoved === true) {
hasRemoved = false; hasRemoved = false;
e.preventDefault(); e.preventDefault();
@ -85,13 +85,13 @@ function(
this.setState({ select2: true }); this.setState({ select2: true });
}, },
getSelectedValues: function() { getSelectedValues: function () {
if(this.props.field['selected'] !== undefined) { if(this.props.field['selected'] !== undefined) {
return this.props.field['selected'](this.props.item); return this.props.field['selected'](this.props.item);
} else if(this.props.item !== undefined && this.props.field.name !== undefined) { } else if(this.props.item !== undefined && this.props.field.name !== undefined) {
if (this.allowMultipleValues()) { if (this.allowMultipleValues()) {
if (Array.isArray(this.props.item[this.props.field.name])) { if (Array.isArray(this.props.item[this.props.field.name])) {
return this.props.item[this.props.field.name].map(function(item) { return this.props.item[this.props.field.name].map((item) => {
return item.id; return item.id;
}); });
} }
@ -101,9 +101,9 @@ function(
} }
return null; return null;
}, },
loadCachedItems: function() { loadCachedItems: function () {
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') { if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
var items = window['mailpoet_'+this.props.field.endpoint]; let items = window['mailpoet_'+this.props.field.endpoint];
if(this.props.field['filter'] !== undefined) { if(this.props.field['filter'] !== undefined) {
@ -111,39 +111,39 @@ function(
} }
this.setState({ this.setState({
items: items items: items,
}); });
} }
}, },
handleChange: function(e) { handleChange: function (e) {
if(this.props.onValueChange !== undefined) { if(this.props.onValueChange !== undefined) {
if(this.props.field.multiple) { if(this.props.field.multiple) {
value = jQuery('#'+this.refs.select.id).val(); value = jQuery('#'+this.refs.select.id).val();
} else { } else {
value = e.target.value; value = e.target.value;
} }
var transformedValue = this.transformChangedValue(value); const transformedValue = this.transformChangedValue(value);
this.props.onValueChange({ this.props.onValueChange({
target: { target: {
value: transformedValue, value: transformedValue,
name: this.props.field.name name: this.props.field.name,
} },
}); });
} }
}, },
getLabel: function(item) { getLabel: function (item) {
if(this.props.field['getLabel'] !== undefined) { if(this.props.field['getLabel'] !== undefined) {
return this.props.field.getLabel(item, this.props.item); return this.props.field.getLabel(item, this.props.item);
} }
return item.name; return item.name;
}, },
getSearchLabel: function(item) { getSearchLabel: function (item) {
if(this.props.field['getSearchLabel'] !== undefined) { if(this.props.field['getSearchLabel'] !== undefined) {
return this.props.field.getSearchLabel(item, this.props.item); return this.props.field.getSearchLabel(item, this.props.item);
} }
return null; return null;
}, },
getValue: function(item) { getValue: function (item) {
if(this.props.field['getValue'] !== undefined) { if(this.props.field['getValue'] !== undefined) {
return this.props.field.getValue(item, this.props.item); return this.props.field.getValue(item, this.props.item);
} }
@ -152,18 +152,18 @@ function(
// When it's impossible to represent the desired value in DOM, // When it's impossible to represent the desired value in DOM,
// this function may be used to transform the placeholder value into // this function may be used to transform the placeholder value into
// desired value. // desired value.
transformChangedValue: function(value) { transformChangedValue: function (value) {
if(typeof this.props.field['transformChangedValue'] === 'function') { if(typeof this.props.field['transformChangedValue'] === 'function') {
return this.props.field.transformChangedValue.call(this, value); return this.props.field.transformChangedValue.call(this, value);
} else { } else {
return value; return value;
} }
}, },
render: function() { render: function () {
const options = this.state.items.map((item, index) => { const options = this.state.items.map((item, index) => {
let label = this.getLabel(item); const label = this.getLabel(item);
let searchLabel = this.getSearchLabel(item); const searchLabel = this.getSearchLabel(item);
let value = this.getValue(item); const value = this.getValue(item);
return ( return (
<option <option
@ -180,13 +180,14 @@ function(
<select <select
id={ this.props.field.id || this.props.field.name } id={ this.props.field.id || this.props.field.name }
ref="select" ref="select"
disabled={this.props.field.disabled}
data-placeholder={ this.props.field.placeholder } data-placeholder={ this.props.field.placeholder }
multiple={ this.props.field.multiple } multiple={ this.props.field.multiple }
defaultValue={ this.getSelectedValues() } defaultValue={ this.getSelectedValues() }
{...this.props.field.validation} {...this.props.field.validation}
>{ options }</select> >{ options }</select>
); );
} },
}); });
return Selection; return Selection;

View File

@ -1,4 +1,4 @@
import React from 'react' import React from 'react';
const FormFieldText = React.createClass({ const FormFieldText = React.createClass({
render() { render() {
@ -29,7 +29,7 @@ const FormFieldText = React.createClass({
{...this.props.field.validation} {...this.props.field.validation}
/> />
); );
} },
}); });
module.exports = FormFieldText; module.exports = FormFieldText;

View File

@ -1,11 +1,11 @@
define([ define([
'react' 'react',
], ],
function( (
React React
) { ) => {
var FormFieldTextarea = React.createClass({ const FormFieldTextarea = React.createClass({
render: function() { render: function () {
return ( return (
<textarea <textarea
type="text" type="text"
@ -19,8 +19,8 @@ function(
{...this.props.field.validation} {...this.props.field.validation}
/> />
); );
} },
}); });
return FormFieldTextarea; return FormFieldTextarea;
}); });

View File

@ -4,54 +4,54 @@ define(
'mailpoet', 'mailpoet',
'classnames', 'classnames',
'react-router', 'react-router',
'form/fields/field.jsx' 'form/fields/field.jsx',
], ],
function( (
React, React,
MailPoet, MailPoet,
classNames, classNames,
Router, Router,
FormField FormField
) { ) => {
var Form = React.createClass({ const Form = React.createClass({
contextTypes: { contextTypes: {
router: React.PropTypes.object.isRequired router: React.PropTypes.object.isRequired,
}, },
getDefaultProps: function() { getDefaultProps: function () {
return { return {
params: {}, params: {},
}; };
}, },
getInitialState: function() { getInitialState: function () {
return { return {
loading: false, loading: false,
errors: [], errors: [],
item: {} item: {},
}; };
}, },
getValues: function() { getValues: function () {
return this.props.item ? this.props.item : this.state.item; return this.props.item ? this.props.item : this.state.item;
}, },
getErrors: function() { getErrors: function () {
return this.props.errors ? this.props.errors : this.state.errors; return this.props.errors ? this.props.errors : this.state.errors;
}, },
componentDidMount: function() { componentDidMount: function () {
if(this.isMounted()) { if(this.isMounted()) {
if(this.props.params.id !== undefined) { if(this.props.params.id !== undefined) {
this.loadItem(this.props.params.id); this.loadItem(this.props.params.id);
} else { } else {
this.setState({ this.setState({
item: jQuery('.mailpoet_form').serializeObject() item: jQuery('.mailpoet_form').serializeObject(),
}); });
} }
} }
}, },
componentWillReceiveProps: function(props) { componentWillReceiveProps: function (props) {
if(props.params.id === undefined) { if(props.params.id === undefined) {
this.setState({ this.setState({
loading: false, loading: false,
item: {} item: {},
}); });
if (props.item === undefined) { if (props.item === undefined) {
this.refs.form.reset(); this.refs.form.reset();
@ -60,7 +60,7 @@ define(
this.loadItem(props.params.id); this.loadItem(props.params.id);
} }
}, },
loadItem: function(id) { loadItem: function (id) {
this.setState({ loading: true }); this.setState({ loading: true });
MailPoet.Ajax.post({ MailPoet.Ajax.post({
@ -68,23 +68,23 @@ define(
endpoint: this.props.endpoint, endpoint: this.props.endpoint,
action: 'get', action: 'get',
data: { data: {
id: id id: id,
} },
}).done((response) => { }).done((response) => {
this.setState({ this.setState({
loading: false, loading: false,
item: response.data item: response.data,
}); });
}).fail((response) => { }).fail(() => {
this.setState({ this.setState({
loading: false, loading: false,
item: {} item: {},
}, function() { }, function () {
this.context.router.push('/new'); this.context.router.push('/new');
}); });
}); });
}, },
handleSubmit: function(e) { handleSubmit: function (e) {
e.preventDefault(); e.preventDefault();
// handle validation // handle validation
@ -97,16 +97,16 @@ define(
this.setState({ loading: true }); this.setState({ loading: true });
// only get values from displayed fields // only get values from displayed fields
var item = {}; const item = {};
this.props.fields.map(function(field) { this.props.fields.map((field) => {
if(field['fields'] !== undefined) { if(field['fields'] !== undefined) {
field.fields.map(function(subfield) { field.fields.map((subfield) => {
item[subfield.name] = this.state.item[subfield.name]; item[subfield.name] = this.state.item[subfield.name];
}.bind(this)); });
} else { } else {
item[field.name] = this.state.item[field.name]; item[field.name] = this.state.item[field.name];
} }
}.bind(this)); });
// set id if specified // set id if specified
if(this.props.params.id !== undefined) { if(this.props.params.id !== undefined) {
item.id = this.props.params.id; item.id = this.props.params.id;
@ -116,10 +116,10 @@ define(
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint, endpoint: this.props.endpoint,
action: 'save', action: 'save',
data: item data: item,
}).always(() => { }).always(() => {
this.setState({ loading: false }); this.setState({ loading: false });
}).done((response) => { }).done(() => {
if(this.props.onSuccess !== undefined) { if(this.props.onSuccess !== undefined) {
this.props.onSuccess(); this.props.onSuccess();
} else { } else {
@ -137,24 +137,25 @@ define(
} }
}); });
}, },
handleValueChange: function(e) { handleValueChange: function (e) {
if (this.props.onChange) { if (this.props.onChange) {
return this.props.onChange(e); return this.props.onChange(e);
} else { } else {
var item = this.state.item, const item = this.state.item;
field = e.target.name; const field = e.target.name;
item[field] = e.target.value; item[field] = e.target.value;
this.setState({ this.setState({
item: item item: item,
}); });
return true; return true;
} }
}, },
render: function() { render: function () {
let errors;
if(this.getErrors() !== undefined) { if(this.getErrors() !== undefined) {
var errors = this.getErrors().map(function(error, index) { errors = this.getErrors().map((error, index) => {
return ( return (
<p key={ 'error-'+index } className="mailpoet_error"> <p key={ 'error-'+index } className="mailpoet_error">
{ error.message } { error.message }
@ -163,13 +164,13 @@ define(
}); });
} }
var formClasses = classNames( const formClasses = classNames(
'mailpoet_form', 'mailpoet_form',
{ 'mailpoet_form_loading': this.state.loading || this.props.loading } { mailpoet_form_loading: this.state.loading || this.props.loading }
); );
var beforeFormContent = false; let beforeFormContent = false;
var afterFormContent = false; let afterFormContent = false;
if (this.props.beforeFormContent !== undefined) { if (this.props.beforeFormContent !== undefined) {
beforeFormContent = this.props.beforeFormContent(this.getValues()); beforeFormContent = this.props.beforeFormContent(this.getValues());
@ -179,17 +180,26 @@ define(
afterFormContent = this.props.afterFormContent(this.getValues()); afterFormContent = this.props.afterFormContent(this.getValues());
} }
var fields = this.props.fields.map(function(field, i) { const fields = this.props.fields.map((field, i) => {
// Compose an onChange handler from the default and custom one
let onValueChange = this.handleValueChange;
if (field.onBeforeChange) {
onValueChange = (e) => {
field.onBeforeChange(e);
return this.handleValueChange(e);
};
}
return ( return (
<FormField <FormField
field={ field } field={ field }
item={ this.getValues() } item={ this.getValues() }
onValueChange={ this.handleValueChange } onValueChange={ onValueChange }
key={ 'field-'+i } /> key={ 'field-'+i } />
); );
}.bind(this)); });
var actions = false; let actions = false;
if(this.props.children) { if(this.props.children) {
actions = this.props.children; actions = this.props.children;
} else { } else {
@ -228,7 +238,7 @@ define(
{ afterFormContent } { afterFormContent }
</div> </div>
); );
} },
}); });
return Form; return Form;

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
import React from 'react' import React from 'react';
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, Link, useRouterHistory } from 'react-router' import { Router, Route, IndexRoute, useRouterHistory } from 'react-router';
import { createHashHistory } from 'history' import { createHashHistory } from 'history';
import FormList from 'forms/list.jsx' import FormList from 'forms/list.jsx';
const history = useRouterHistory(createHashHistory)({ queryKey: false }); const history = useRouterHistory(createHashHistory)({ queryKey: false });
const App = React.createClass({ const App = React.createClass({
render() { render() {
return this.props.children return this.props.children;
} },
}); });
const container = document.getElementById('forms_container'); const container = document.getElementById('forms_container');
@ -23,4 +23,4 @@ if(container) {
</Route> </Route>
</Router> </Router>
), container); ), container);
} }

View File

@ -1,29 +1,27 @@
import React from 'react' import React from 'react';
import ReactDOM from 'react-dom' import Listing from 'listing/listing.jsx';
import { Router, Link } from 'react-router' import classNames from 'classnames';
import Listing from 'listing/listing.jsx' import MailPoet from 'mailpoet';
import classNames from 'classnames'
import MailPoet from 'mailpoet'
const columns = [ const columns = [
{ {
name: 'name', name: 'name',
label: MailPoet.I18n.t('formName'), label: MailPoet.I18n.t('formName'),
sortable: true sortable: true,
}, },
{ {
name: 'segments', name: 'segments',
label: MailPoet.I18n.t('segments') label: MailPoet.I18n.t('segments'),
}, },
{ {
name: 'signups', name: 'signups',
label: MailPoet.I18n.t('signups') label: MailPoet.I18n.t('signups'),
}, },
{ {
name: 'created_at', name: 'created_at',
label: MailPoet.I18n.t('createdOn'), label: MailPoet.I18n.t('createdOn'),
sortable: true sortable: true,
} },
]; ];
const messages = { const messages = {
@ -71,38 +69,38 @@ const messages = {
).replace('%$1d', count.toLocaleString()); ).replace('%$1d', count.toLocaleString());
} }
MailPoet.Notice.success(message); MailPoet.Notice.success(message);
} },
}; };
const bulk_actions = [ const bulk_actions = [
{ {
name: 'trash', name: 'trash',
label: MailPoet.I18n.t('moveToTrash'), label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash onSuccess: messages.onTrash,
} },
]; ];
const item_actions = [ const item_actions = [
{ {
name: 'edit', name: 'edit',
label: MailPoet.I18n.t('edit'), label: MailPoet.I18n.t('edit'),
link: function(item) { link: function (item) {
return ( return (
<a href={ `admin.php?page=mailpoet-form-editor&id=${item.id}` }>{MailPoet.I18n.t('edit')}</a> <a href={ `admin.php?page=mailpoet-form-editor&id=${item.id}` }>{MailPoet.I18n.t('edit')}</a>
); );
} },
}, },
{ {
name: 'duplicate', name: 'duplicate',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: function(item, refresh) { onClick: function (item, refresh) {
return MailPoet.Ajax.post({ return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
endpoint: 'forms', endpoint: 'forms',
action: 'duplicate', action: 'duplicate',
data: { data: {
id: item.id id: item.id,
} },
}).done((response) => { }).done((response) => {
MailPoet.Notice.success( MailPoet.Notice.success(
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name) (MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name)
@ -111,16 +109,16 @@ const item_actions = [
}).fail((response) => { }).fail((response) => {
if (response.errors.length > 0) { if (response.errors.length > 0) {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
} }
}); });
} },
}, },
{ {
name: 'trash' name: 'trash',
} },
]; ];
const FormList = React.createClass({ const FormList = React.createClass({
@ -128,28 +126,28 @@ const FormList = React.createClass({
MailPoet.Ajax.post({ MailPoet.Ajax.post({
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
endpoint: 'forms', endpoint: 'forms',
action: 'create' action: 'create',
}).done((response) => { }).done((response) => {
window.location = mailpoet_form_edit_url + response.data.id; window.location = mailpoet_form_edit_url + response.data.id;
}).fail((response) => { }).fail((response) => {
if (response.errors.length > 0) { if (response.errors.length > 0) {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
} }
}); });
}, },
renderItem(form, actions) { renderItem(form, actions) {
let row_classes = classNames( const row_classes = classNames(
'manage-column', 'manage-column',
'column-primary', 'column-primary',
'has-row-actions' 'has-row-actions'
); );
let segments = mailpoet_segments.filter(function(segment) { let segments = mailpoet_segments.filter((segment) => {
return (jQuery.inArray(segment.id, form.segments) !== -1); return (jQuery.inArray(segment.id, form.segments) !== -1);
}).map(function(segment) { }).map((segment) => {
return segment.name; return segment.name;
}).join(', '); }).join(', ');
@ -205,7 +203,7 @@ const FormList = React.createClass({
/> />
</div> </div>
); );
} },
}); });
module.exports = FormList; module.exports = FormList;

View File

@ -5,7 +5,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
output = ''; output = '';
for(var i = 0; i < size; i++) { for(var i = 0; i < size; i++) {
output += arguments[i]; output += arguments[i];
}; }
return output; return output;
}); });
@ -19,7 +19,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
} }
// set date format // 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 // check if we passed a timestamp
if(parseInt(timestamp, 10) == timestamp) { if(parseInt(timestamp, 10) == timestamp) {
return moment.unix(timestamp).format(f); return moment.unix(timestamp).format(f);
@ -28,7 +28,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
} }
} else { } else {
return timestamp; return timestamp;
}; }
}); });
Handlebars.registerHelper('cycle', function(value, block) { Handlebars.registerHelper('cycle', function(value, block) {
@ -67,7 +67,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
}); });
Handlebars.registerHelper('nl2br', function(value, block) { Handlebars.registerHelper('nl2br', function(value, block) {
return value.gsub("\n", "<br />"); return value.gsub('\n', '<br />');
}); });
Handlebars.registerHelper('json_encode', function(value, block) { Handlebars.registerHelper('json_encode', function(value, block) {
@ -78,7 +78,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
return JSON.parse(value); return JSON.parse(value);
}); });
Handlebars.registerHelper('url', function(value, block) { 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;
}); });
@ -99,7 +99,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
// extract all lines into an array // 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 // remove header & footer
lines.shift(); lines.shift();
@ -125,12 +125,13 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
* @return {String} The truncated string. * @return {String} The truncated string.
*/ */
Handlebars.registerHelper('ellipsis', function (str, limit, append) { Handlebars.registerHelper('ellipsis', function (str, limit, append) {
if (append === undefined) { var strAppend = append;
append = ''; if (strAppend === undefined) {
strAppend = '';
} }
var sanitized = str.replace(/(<([^>]+)>)/g, ''); var sanitized = str.replace(/(<([^>]+)>)/g, '');
if (sanitized.length > limit) { if (sanitized.length > limit) {
return sanitized.substr(0, limit - append.length) + append; return sanitized.substr(0, limit - strAppend.length) + strAppend;
} else { } else {
return sanitized; return sanitized;
} }
@ -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 '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 '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 '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 '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 '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; 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

@ -0,0 +1,32 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRedirect, useRouterHistory } from 'react-router';
import { createHashHistory } from 'history';
import KnowledgeBase from 'help/knowledge_base.jsx';
import SystemInfo from 'help/system_info.jsx';
const history = useRouterHistory(createHashHistory)({ queryKey: false });
const App = React.createClass({
render() {
return this.props.children;
},
});
const container = document.getElementById('help_container');
if(container) {
ReactDOM.render((
<Router history={ history }>
<Route path="/" component={ App }>
<IndexRedirect to="knowledgeBase" />
{/* Pages */}
<Route path="knowledgeBase(/)**" params={{ tab: 'knowledgeBase' }} component={ KnowledgeBase } />
<Route path="systemInfo(/)**" params={{ tab: 'systemInfo' }} component={ SystemInfo } />
</Route>
</Router>
), container);
}

View File

@ -0,0 +1,29 @@
import React from 'react';
import MailPoet from 'mailpoet';
import Tabs from './tabs.jsx';
function KnowledgeBase() {
return (
<div>
<Tabs tab="knowledgeBase" />
<p>{MailPoet.I18n.t('knowledgeBaseIntro')}</p>
<ul>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/116-common-problems">Common Problems</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/165-newsletters">Newsletters</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/156-migration-questions">Migration Questions</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/149-sending-methods">Sending Methods</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/139-subscription-forms">Subscription Forms</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/114-getting-started">Getting Started</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/123-newsletter-designer">Newsletter Designer</a></li>
<li><a target="_blank" href="http://beta.docs.mailpoet.com/category/121-subscribers-and-lists">Subscribers and Lists</a></li>
</ul>
<a target="_blank" href="http://beta.docs.mailpoet.com/" className="button button-primary">{MailPoet.I18n.t('knowledgeBaseButton')}</a>
</div>
);
}
module.exports = KnowledgeBase;

View File

@ -0,0 +1,47 @@
import React from 'react';
import MailPoet from 'mailpoet';
import _ from 'underscore';
import Tabs from './tabs.jsx';
function handleFocus(event) {
event.target.select();
}
function printData(data) {
if (_.isObject(data)) {
const printableData = Object.keys(data).map((key) => {
return `${key}: ${data[key]}`;
});
return (<textarea
readOnly={true}
onFocus={handleFocus}
value={printableData.join('\n')}
style={{
width: '100%',
height: '400px',
}}
/>);
} else {
return (<p>{MailPoet.I18n.t('systemInfoDataError')}</p>);
}
}
function KnowledgeBase() {
const data = window.help_scout_data;
return (
<div>
<Tabs tab="systemInfo" />
<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

@ -0,0 +1,46 @@
import React from 'react';
import { Link } from 'react-router';
import classNames from 'classnames';
import MailPoet from 'mailpoet';
const tabs = [
{
name: 'knowledgeBase',
label: MailPoet.I18n.t('tabKnowledgeBaseTitle'),
link: '/knowledgeBase',
},
{
name: 'systemInfo',
label: MailPoet.I18n.t('tabSystemInfoTitle'),
link: '/systemInfo',
},
];
function Tabs(props) {
const tabLinks = tabs.map((tab, index) => {
const tabClasses = classNames(
'nav-tab',
{ 'nav-tab-active': (props.tab === tab.name) }
);
return (
<Link
key={ 'tab-'+index }
className={ tabClasses }
to={ tab.link }
>{ tab.label }</Link>
);
});
return (
<h2 className="nav-tab-wrapper">
{ tabLinks }
</h2>
);
}
Tabs.propTypes = { tab: React.PropTypes.string };
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,10 +2,12 @@ define('i18n',
[ [
'mailpoet' 'mailpoet'
], function( ], function(
MailPoet mp
) { ) {
'use strict'; 'use strict';
var MailPoet = mp;
var translations = {}; var translations = {};
MailPoet.I18n = { MailPoet.I18n = {
@ -13,7 +15,7 @@ define('i18n',
translations[key] = value; translations[key] = value;
}, },
t: function(key) { t: function(key) {
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace("%$1s", key); return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace('%$1s', key);
}, },
all: function() { all: function() {
return translations; return translations;

View File

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

View File

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

View File

@ -1,53 +1,53 @@
define([ define([
'react', 'react',
'mailpoet' 'mailpoet',
], ],
function( (
React, React,
MailPoet MailPoet
) { ) => {
var ListingBulkActions = React.createClass({ const ListingBulkActions = React.createClass({
getInitialState: function() { getInitialState: function () {
return { return {
action: false, action: false,
extra: false extra: false,
} };
}, },
handleChangeAction: function(e) { handleChangeAction: function (e) {
this.setState({ this.setState({
action: e.target.value, action: e.target.value,
extra: false extra: false,
}, function() { }, () => {
var action = this.getSelectedAction(); const action = this.getSelectedAction();
// action on select callback // action on select callback
if(action !== null && action['onSelect'] !== undefined) { if(action !== null && action['onSelect'] !== undefined) {
this.setState({ this.setState({
extra: action.onSelect(e) extra: action.onSelect(e),
}); });
} }
}.bind(this)); });
}, },
handleApplyAction: function(e) { handleApplyAction: function (e) {
e.preventDefault(); e.preventDefault();
var action = this.getSelectedAction(); const action = this.getSelectedAction();
if(action === null) { if(action === null) {
return; return;
} }
var selected_ids = (this.props.selection !== 'all') const selected_ids = (this.props.selection !== 'all')
? this.props.selected_ids ? this.props.selected_ids
: []; : [];
var data = (action['getData'] !== undefined) const data = (action['getData'] !== undefined)
? action.getData() ? action.getData()
: {}; : {};
data.action = this.state.action; data.action = this.state.action;
var onSuccess = function() {}; let onSuccess = function () {};
if(action['onSuccess'] !== undefined) { if(action['onSuccess'] !== undefined) {
onSuccess = action.onSuccess; onSuccess = action.onSuccess;
} }
@ -56,18 +56,18 @@ function(
const promise = this.props.onBulkAction(selected_ids, data); const promise = this.props.onBulkAction(selected_ids, data);
if (promise !== false) { if (promise !== false) {
promise.then(onSuccess); promise.then(onSuccess);
}; }
} }
this.setState({ this.setState({
action: false, action: false,
extra: false extra: false,
}); });
}, },
getSelectedAction: function() { getSelectedAction: function () {
var selected_action = this.refs.action.value; const selected_action = this.refs.action.value;
if(selected_action.length > 0) { if(selected_action.length > 0) {
var action = this.props.bulk_actions.filter(function(action) { const action = this.props.bulk_actions.filter((action) => {
return (action.name === selected_action); return (action.name === selected_action);
}); });
@ -77,7 +77,7 @@ function(
} }
return null; return null;
}, },
render: function() { render: function () {
if(this.props.bulk_actions.length === 0) { if(this.props.bulk_actions.length === 0) {
return null; return null;
} }
@ -97,14 +97,14 @@ function(
onChange={this.handleChangeAction} onChange={this.handleChangeAction}
> >
<option value="">{MailPoet.I18n.t('bulkActions')}</option> <option value="">{MailPoet.I18n.t('bulkActions')}</option>
{ this.props.bulk_actions.map(function(action, index) { { this.props.bulk_actions.map((action, index) => {
return ( return (
<option <option
value={ action.name } value={ action.name }
key={ 'action-' + index } key={ 'action-' + index }
>{ action.label }</option> >{ action.label }</option>
); );
}.bind(this)) } }) }
</select> </select>
<input <input
onClick={ this.handleApplyAction } onClick={ this.handleApplyAction }
@ -115,7 +115,7 @@ function(
{ this.state.extra } { this.state.extra }
</div> </div>
); );
} },
}); });
return ListingBulkActions; return ListingBulkActions;

View File

@ -1,27 +1,30 @@
define([ define([
'react', 'react',
'jquery', 'jquery',
'mailpoet' 'mailpoet',
], ],
function( (
React, React,
jQuery, jQuery,
MailPoet MailPoet
) { ) => {
var ListingFilters = React.createClass({ const ListingFilters = React.createClass({
handleFilterAction: function() { handleFilterAction: function () {
let filters = {}; const filters = {};
this.getAvailableFilters().map((filter, i) => { this.getAvailableFilters().map((filter, i) => {
filters[this.refs['filter-'+i].name] = this.refs['filter-'+i].value filters[this.refs['filter-'+i].name] = this.refs['filter-'+i].value;
}); });
if (this.props.onBeforeSelectFilter) {
this.props.onBeforeSelectFilter(filters);
}
return this.props.onSelectFilter(filters); return this.props.onSelectFilter(filters);
}, },
handleEmptyTrash: function() { handleEmptyTrash: function () {
return this.props.onEmptyTrash(); return this.props.onEmptyTrash();
}, },
getAvailableFilters: function() { getAvailableFilters: function () {
let filters = this.props.filters; const filters = this.props.filters;
return Object.keys(filters).filter(function(filter) { return Object.keys(filters).filter((filter) => {
return !( return !(
filters[filter].length === 0 filters[filter].length === 0
|| ( || (
@ -31,39 +34,39 @@ function(
); );
}); });
}, },
componentDidUpdate: function() { componentDidUpdate: function () {
const selected_filters = this.props.filter; const selected_filters = this.props.filter;
const available_filters = this.getAvailableFilters().map( this.getAvailableFilters().map(
function(filter, i) { (filter, i) => {
if (selected_filters[filter] !== undefined && selected_filters[filter]) { if (selected_filters[filter] !== undefined && selected_filters[filter]) {
jQuery(this.refs['filter-'+i]) jQuery(this.refs['filter-'+i])
.val(selected_filters[filter]) .val(selected_filters[filter])
.trigger('change'); .trigger('change');
} }
}.bind(this) }
); );
}, },
render: function() { render: function () {
const filters = this.props.filters; const filters = this.props.filters;
const available_filters = this.getAvailableFilters() const available_filters = this.getAvailableFilters()
.map(function(filter, i) { .map((filter, i) => {
return ( return (
<select <select
ref={ `filter-${i}` } ref={ `filter-${i}` }
key={ `filter-${i}` } key={ `filter-${i}` }
name={ filter } name={ filter }
> >
{ filters[filter].map(function(option, j) { { filters[filter].map((option, j) => {
return ( return (
<option <option
value={ option.value } value={ option.value }
key={ 'filter-option-' + j } key={ 'filter-option-' + j }
>{ option.label }</option> >{ option.label }</option>
); );
}.bind(this)) } }) }
</select> </select>
); );
}.bind(this)); });
let button; let button;
@ -97,7 +100,7 @@ function(
{ empty_trash } { empty_trash }
</div> </div>
); );
} },
}); });
return ListingFilters; return ListingFilters;

View File

@ -1,20 +1,20 @@
define(['react', 'classnames'], function(React, classNames) { define(['react', 'classnames'], (React, classNames) => {
var ListingGroups = React.createClass({ const ListingGroups = React.createClass({
handleSelect: function(group) { handleSelect: function (group) {
return this.props.onSelectGroup(group); return this.props.onSelectGroup(group);
}, },
render: function() { render: function () {
var groups = this.props.groups.map(function(group, index) { const groups = this.props.groups.map((group, index) => {
if(group.name === 'trash' && group.count === 0) { if(group.name === 'trash' && group.count === 0) {
return false; return false;
} }
var classes = classNames( const classes = classNames(
{ 'current' : (group.name === this.props.group) } { current : (group.name === this.props.group) }
); );
return ( return (
<li key={index}> <li key={index}>
{(index > 0) ? ' |' : ''} {(index > 0) ? ' |' : ''}
<a <a
@ -24,17 +24,17 @@ define(['react', 'classnames'], function(React, classNames) {
{group.label} <span className="count">({ group.count.toLocaleString() })</span> {group.label} <span className="count">({ group.count.toLocaleString() })</span>
</a> </a>
</li> </li>
); );
}.bind(this)); });
return ( return (
<ul className="subsubsub"> <ul className="subsubsub">
{ groups } { groups }
</ul> </ul>
); );
} },
}); });
return ListingGroups; return ListingGroups;
} }
); );

View File

@ -1,17 +1,18 @@
import MailPoet from 'mailpoet' import MailPoet from 'mailpoet';
import React from 'react' import React from 'react';
import classNames from 'classnames' import classNames from 'classnames';
const ListingHeader = React.createClass({ const ListingHeader = React.createClass({
handleSelectItems: function() { handleSelectItems: function () {
return this.props.onSelectItems( return this.props.onSelectItems(
this.refs.toggle.checked this.refs.toggle.checked
); );
}, },
render: function() { render: function () {
const columns = this.props.columns.map(function(column, index) { const columns = this.props.columns.map((column, index) => {
column.is_primary = (index === 0); const renderColumn = column;
column.sorted = (this.props.sort_by === column.name) renderColumn.is_primary = (index === 0);
renderColumn.sorted = (this.props.sort_by === column.name)
? this.props.sort_order ? this.props.sort_order
: 'desc'; : 'desc';
return ( return (
@ -19,9 +20,9 @@ const ListingHeader = React.createClass({
onSort={this.props.onSort} onSort={this.props.onSort}
sort_by={this.props.sort_by} sort_by={this.props.sort_by}
key={ 'column-' + index } key={ 'column-' + index }
column={column} /> column={renderColumn} />
); );
}.bind(this)); });
let checkbox; let checkbox;
@ -48,22 +49,22 @@ const ListingHeader = React.createClass({
{columns} {columns}
</tr> </tr>
); );
} },
}); });
const ListingColumn = React.createClass({ const ListingColumn = React.createClass({
handleSort: function() { handleSort: function () {
const sort_by = this.props.column.name; const sort_by = this.props.column.name;
const sort_order = (this.props.column.sorted === 'asc') ? 'desc' : 'asc'; const sort_order = (this.props.column.sorted === 'asc') ? 'desc' : 'asc';
this.props.onSort(sort_by, sort_order); this.props.onSort(sort_by, sort_order);
}, },
render: function() { render: function () {
const classes = classNames( const classes = classNames(
'manage-column', 'manage-column',
{ 'column-primary': this.props.column.is_primary }, { 'column-primary': this.props.column.is_primary },
{ 'sortable': this.props.column.sortable }, { sortable: this.props.column.sortable },
this.props.column.sorted, this.props.column.sorted,
{ 'sorted': (this.props.sort_by === this.props.column.name) } { sorted: (this.props.sort_by === this.props.column.name) }
); );
let label; let label;
@ -85,7 +86,7 @@ const ListingColumn = React.createClass({
width={ this.props.column.width || null } width={ this.props.column.width || null }
>{label}</th> >{label}</th>
); );
} },
}); });
module.exports = ListingHeader; module.exports = ListingHeader;

View File

@ -1,23 +1,23 @@
import MailPoet from 'mailpoet' import MailPoet from 'mailpoet';
import jQuery from 'jquery' import jQuery from 'jquery';
import React from 'react' import React from 'react';
import _ from 'underscore' import _ from 'underscore';
import { Router, Link } from 'react-router' import { Link } from 'react-router';
import classNames from 'classnames' import classNames from 'classnames';
import ListingBulkActions from 'listing/bulk_actions.jsx' import ListingBulkActions from 'listing/bulk_actions.jsx';
import ListingHeader from 'listing/header.jsx' import ListingHeader from 'listing/header.jsx';
import ListingPages from 'listing/pages.jsx' import ListingPages from 'listing/pages.jsx';
import ListingSearch from 'listing/search.jsx' import ListingSearch from 'listing/search.jsx';
import ListingGroups from 'listing/groups.jsx' import ListingGroups from 'listing/groups.jsx';
import ListingFilters from 'listing/filters.jsx' import ListingFilters from 'listing/filters.jsx';
const ListingItem = React.createClass({ const ListingItem = React.createClass({
getInitialState: function() { getInitialState: function () {
return { return {
expanded: false expanded: false,
}; };
}, },
handleSelectItem: function(e) { handleSelectItem: function (e) {
this.props.onSelectItem( this.props.onSelectItem(
parseInt(e.target.value, 10), parseInt(e.target.value, 10),
e.target.checked e.target.checked
@ -25,20 +25,20 @@ const ListingItem = React.createClass({
return !e.target.checked; return !e.target.checked;
}, },
handleRestoreItem: function(id) { handleRestoreItem: function (id) {
this.props.onRestoreItem(id); this.props.onRestoreItem(id);
}, },
handleTrashItem: function(id) { handleTrashItem: function (id) {
this.props.onTrashItem(id); this.props.onTrashItem(id);
}, },
handleDeleteItem: function(id) { handleDeleteItem: function (id) {
this.props.onDeleteItem(id); this.props.onDeleteItem(id);
}, },
handleToggleItem: function(id) { handleToggleItem: function () {
this.setState({ expanded: !this.state.expanded }); this.setState({ expanded: !this.state.expanded });
}, },
render: function() { render: function () {
var checkbox = false; let checkbox = false;
if (this.props.is_selectable === true) { if (this.props.is_selectable === true) {
checkbox = ( checkbox = (
@ -63,7 +63,7 @@ const ListingItem = React.createClass({
if (custom_actions.length > 0) { if (custom_actions.length > 0) {
let is_first = true; let is_first = true;
item_actions = custom_actions.map(function(action, index) { item_actions = custom_actions.map((action, index) => {
if (action.display !== undefined) { if (action.display !== undefined) {
if (action.display(this.props.item) === false) { if (action.display(this.props.item) === false) {
return; return;
@ -125,7 +125,7 @@ const ListingItem = React.createClass({
} }
return custom_action; return custom_action;
}.bind(this)); });
} else { } else {
item_actions = ( item_actions = (
<span className="edit"> <span className="edit">
@ -137,7 +137,7 @@ const ListingItem = React.createClass({
let actions; let actions;
if (this.props.group === 'trash') { if (this.props.group === 'trash') {
actions = ( actions = (
<div> <div>
<div className="row-actions"> <div className="row-actions">
<span> <span>
@ -191,12 +191,12 @@ const ListingItem = React.createClass({
{ this.props.onRenderItem(this.props.item, actions) } { this.props.onRenderItem(this.props.item, actions) }
</tr> </tr>
); );
} },
}); });
const ListingItems = React.createClass({ const ListingItems = React.createClass({
render: function() { render: function () {
if (this.props.items.length === 0) { if (this.props.items.length === 0) {
let message; let message;
if (this.props.loading === true) { if (this.props.loading === true) {
@ -226,10 +226,10 @@ const ListingItems = React.createClass({
} else { } else {
const select_all_classes = classNames( const select_all_classes = classNames(
'mailpoet_select_all', 'mailpoet_select_all',
{ 'mailpoet_hidden': ( { mailpoet_hidden: (
this.props.selection === false this.props.selection === false
|| (this.props.count <= this.props.limit) || (this.props.count <= this.props.limit)
) ),
} }
); );
@ -259,9 +259,10 @@ const ListingItems = React.createClass({
</td> </td>
</tr> </tr>
{this.props.items.map(function(item, index) { {this.props.items.map((item, index) => {
item.id = parseInt(item.id, 10); const renderItem = item;
item.selected = (this.props.selected_ids.indexOf(item.id) !== -1); renderItem.id = parseInt(item.id, 10);
renderItem.selected = (this.props.selected_ids.indexOf(renderItem.id) !== -1);
return ( return (
<ListingItem <ListingItem
@ -276,21 +277,21 @@ const ListingItems = React.createClass({
is_selectable={ this.props.is_selectable } is_selectable={ this.props.is_selectable }
item_actions={ this.props.item_actions } item_actions={ this.props.item_actions }
group={ this.props.group } group={ this.props.group }
key={ `item-${item.id}-${index}` } key={ `item-${renderItem.id}-${index}` }
item={ item } /> item={ renderItem } />
); );
}.bind(this))} })}
</tbody> </tbody>
); );
} }
} },
}); });
const Listing = React.createClass({ const Listing = React.createClass({
contextTypes: { contextTypes: {
router: React.PropTypes.object.isRequired router: React.PropTypes.object.isRequired,
}, },
getInitialState: function() { getInitialState: function () {
return { return {
loading: false, loading: false,
search: '', search: '',
@ -306,31 +307,31 @@ const Listing = React.createClass({
filter: {}, filter: {},
selected_ids: [], selected_ids: [],
selection: false, selection: false,
meta: {} meta: {},
}; };
}, },
getParam: function(param) { getParam: function (param) {
const regex = /(.*)\[(.*)\]/; const regex = /(.*)\[(.*)\]/;
const matches = regex.exec(param); const matches = regex.exec(param);
return [matches[1], matches[2]]; return [matches[1], matches[2]];
}, },
initWithParams: function(params) { initWithParams: function (params) {
let state = this.getInitialState(); const state = this.getInitialState();
// check for url params // check for url params
if (params.splat) { if (params.splat) {
params.splat.split('/').map(param => { params.splat.split('/').map((param) => {
let [key, value] = this.getParam(param); const [key, value] = this.getParam(param);
switch(key) { switch(key) {
case 'filter': case 'filter':
let filters = {}; const filters = {};
value.split('&').map(function(pair) { value.split('&').map((pair) => {
let [k, v] = pair.split('=') const [k, v] = pair.split('=');
filters[k] = v filters[k] = v;
} }
); );
state.filter = filters; state.filter = filters;
break; break;
default: default:
state[key] = value; state[key] = value;
} }
@ -352,13 +353,13 @@ const Listing = React.createClass({
state.sort_order = this.props.sort_order; state.sort_order = this.props.sort_order;
} }
this.setState(state, function() { this.setState(state, () => {
this.getItems(); this.getItems();
}.bind(this)); });
}, },
getParams: function() { getParams: function () {
// get all route parameters (without the "splat") // get all route parameters (without the "splat")
let params = _.omit(this.props.params, 'splat'); const params = _.omit(this.props.params, 'splat');
// TODO: // TODO:
// find a way to set the "type" in the routes definition // find a way to set the "type" in the routes definition
// so that it appears in `this.props.params` // so that it appears in `this.props.params`
@ -367,10 +368,10 @@ const Listing = React.createClass({
} }
return params; return params;
}, },
setParams: function() { setParams: function () {
if (this.props.location) { if (this.props.location) {
let params = Object.keys(this.state) const params = Object.keys(this.state)
.filter(key => { .filter((key) => {
return ( return (
[ [
'group', 'group',
@ -378,34 +379,34 @@ const Listing = React.createClass({
'search', 'search',
'page', 'page',
'sort_by', 'sort_by',
'sort_order' 'sort_order',
].indexOf(key) !== -1 ].indexOf(key) !== -1
) );
}) })
.map(key => { .map((key) => {
let value = this.state[key]; let value = this.state[key];
if (value === Object(value)) { if (value === Object(value)) {
value = jQuery.param(value) value = jQuery.param(value);
} else if (value === Boolean(value)) { } else if (value === Boolean(value)) {
value = value.toString() value = value.toString();
} }
if (value !== '' && value !== null) { if (value !== '' && value !== null) {
return `${key}[${value}]` return `${key}[${value}]`;
} }
}) })
.filter(key => { return (key !== undefined) }) .filter((key) => { return (key !== undefined); })
.join('/'); .join('/');
// set url // set url
let url = this.getUrlWithParams(params); const url = this.getUrlWithParams(params);
if (this.props.location.pathname !== url) { if (this.props.location.pathname !== url) {
this.context.router.push(`${url}`); this.context.router.push(`${url}`);
} }
} }
}, },
getUrlWithParams: function(params) { getUrlWithParams: function (params) {
let base_url = (this.props.base_url !== undefined) let base_url = (this.props.base_url !== undefined)
? this.props.base_url ? this.props.base_url
: null; : null;
@ -417,35 +418,36 @@ const Listing = React.createClass({
return `/${ params }`; return `/${ params }`;
} }
}, },
setBaseUrlParams: function(base_url) { setBaseUrlParams: function (base_url) {
if (base_url.indexOf(':') !== -1) { let ret = base_url;
if (ret.indexOf(':') !== -1) {
const params = this.getParams(); const params = this.getParams();
Object.keys(params).map((key) => { Object.keys(params).map((key) => {
if (base_url.indexOf(':'+key) !== -1) { if (ret.indexOf(':'+key) !== -1) {
base_url = base_url.replace(':'+key, params[key]); ret = ret.replace(':'+key, params[key]);
} }
}); });
} }
return base_url; return ret;
}, },
componentDidMount: function() { componentDidMount: function () {
if (this.isMounted()) { if (this.isMounted()) {
const params = this.props.params || {}; const params = this.props.params || {};
this.initWithParams(params); this.initWithParams(params);
if (this.props.auto_refresh) { if (this.props.auto_refresh) {
jQuery(document).on('heartbeat-tick.mailpoet', function(e, data) { jQuery(document).on('heartbeat-tick.mailpoet', () => {
this.getItems(); this.getItems();
}.bind(this)); });
} }
} }
}, },
componentWillReceiveProps: function(nextProps) { componentWillReceiveProps: function (nextProps) {
const params = nextProps.params || {}; const params = nextProps.params || {};
this.initWithParams(params); this.initWithParams(params);
}, },
getItems: function() { getItems: function () {
if (this.isMounted()) { if (this.isMounted()) {
this.setState({ loading: true }); this.setState({ loading: true });
@ -463,8 +465,8 @@ const Listing = React.createClass({
filter: this.state.filter, filter: this.state.filter,
search: this.state.search, search: this.state.search,
sort_by: this.state.sort_by, sort_by: this.state.sort_by,
sort_order: this.state.sort_order sort_order: this.state.sort_order,
} },
}).always(() => { }).always(() => {
this.setState({ loading: false }); this.setState({ loading: false });
}).done((response) => { }).done((response) => {
@ -473,7 +475,7 @@ const Listing = React.createClass({
filters: response.meta.filters || {}, filters: response.meta.filters || {},
groups: response.meta.groups || [], groups: response.meta.groups || [],
count: response.meta.count || 0, count: response.meta.count || 0,
meta: _.omit(response.meta, ['filters', 'groups', 'count']) meta: _.omit(response.meta, ['filters', 'groups', 'count']),
}, () => { }, () => {
// if viewing an empty trash // if viewing an empty trash
if (this.state.group === 'trash' && response.meta.count === 0) { if (this.state.group === 'trash' && response.meta.count === 0) {
@ -487,19 +489,19 @@ const Listing = React.createClass({
} }
}); });
}).fail((response) => { }).fail((response) => {
if (response.errors.length > 0) { if(response.errors.length > 0) {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
} }
}); });
} }
}, },
handleRestoreItem: function(id) { handleRestoreItem: function (id) {
this.setState({ this.setState({
loading: true, loading: true,
page: 1 page: 1,
}); });
MailPoet.Ajax.post({ MailPoet.Ajax.post({
@ -507,8 +509,8 @@ const Listing = React.createClass({
endpoint: this.props.endpoint, endpoint: this.props.endpoint,
action: 'restore', action: 'restore',
data: { data: {
id: id id: id,
} },
}).done((response) => { }).done((response) => {
if ( if (
this.props.messages !== undefined this.props.messages !== undefined
@ -519,15 +521,15 @@ const Listing = React.createClass({
this.getItems(); this.getItems();
}).fail((response) => { }).fail((response) => {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
}); });
}, },
handleTrashItem: function(id) { handleTrashItem: function (id) {
this.setState({ this.setState({
loading: true, loading: true,
page: 1 page: 1,
}); });
MailPoet.Ajax.post({ MailPoet.Ajax.post({
@ -535,8 +537,8 @@ const Listing = React.createClass({
endpoint: this.props.endpoint, endpoint: this.props.endpoint,
action: 'trash', action: 'trash',
data: { data: {
id: id id: id,
} },
}).done((response) => { }).done((response) => {
if ( if (
this.props.messages !== undefined this.props.messages !== undefined
@ -547,15 +549,15 @@ const Listing = React.createClass({
this.getItems(); this.getItems();
}).fail((response) => { }).fail((response) => {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
}); });
}, },
handleDeleteItem: function(id) { handleDeleteItem: function (id) {
this.setState({ this.setState({
loading: true, loading: true,
page: 1 page: 1,
}); });
MailPoet.Ajax.post({ MailPoet.Ajax.post({
@ -563,8 +565,8 @@ const Listing = React.createClass({
endpoint: this.props.endpoint, endpoint: this.props.endpoint,
action: 'delete', action: 'delete',
data: { data: {
id: id id: id,
} },
}).done((response) => { }).done((response) => {
if ( if (
this.props.messages !== undefined this.props.messages !== undefined
@ -575,15 +577,15 @@ const Listing = React.createClass({
this.getItems(); this.getItems();
}).fail((response) => { }).fail((response) => {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
}); });
}, },
handleEmptyTrash: function() { handleEmptyTrash: function () {
return this.handleBulkAction('all', { return this.handleBulkAction('all', {
action: 'delete', action: 'delete',
group: 'trash' group: 'trash',
}).done((response) => { }).done((response) => {
MailPoet.Notice.success( MailPoet.Notice.success(
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response.meta.count) MailPoet.I18n.t('permanentlyDeleted').replace('%d', response.meta.count)
@ -592,12 +594,12 @@ const Listing = React.createClass({
this.handleGroup('all'); this.handleGroup('all');
}).fail((response) => { }).fail((response) => {
MailPoet.Notice.error( MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }), response.errors.map((error) => { return error.message; }),
{ scroll: true } { scroll: true }
); );
}); });
}, },
handleBulkAction: function(selected_ids, params) { handleBulkAction: function (selected_ids, params) {
if ( if (
this.state.selection === false this.state.selection === false
&& this.state.selected_ids.length === 0 && this.state.selected_ids.length === 0
@ -608,15 +610,15 @@ const Listing = React.createClass({
this.setState({ loading: true }); this.setState({ loading: true });
var data = params || {}; const data = params || {};
data.listing = { data.listing = {
params: this.getParams(), params: this.getParams(),
offset: 0, offset: 0,
limit: 0, limit: 0,
filter: this.state.filter, filter: this.state.filter,
group: this.state.group, group: this.state.group,
search: this.state.search search: this.state.search,
} };
if (selected_ids !== 'all') { if (selected_ids !== 'all') {
data.listing.selection = selected_ids; data.listing.selection = selected_ids;
} }
@ -625,32 +627,39 @@ const Listing = React.createClass({
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint, endpoint: this.props.endpoint,
action: 'bulkAction', action: 'bulkAction',
data: data data: data,
}).done(() => { }).done(() => {
this.getItems(); this.getItems();
}).fail((response) => {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
}); });
}, },
handleSearch: function(search) { handleSearch: function (search) {
this.setState({ this.setState({
search: search, search: search,
page: 1, page: 1,
selection: false, selection: false,
selected_ids: [] selected_ids: [],
}, function() { }, () => {
this.setParams(); this.setParams();
}.bind(this)); });
}, },
handleSort: function(sort_by, sort_order = 'asc') { handleSort: function (sort_by, sort_order = 'asc') {
this.setState({ this.setState({
sort_by: sort_by, sort_by: sort_by,
sort_order: (sort_order === 'asc') ? 'asc' : 'desc', sort_order: (sort_order === 'asc') ? 'asc' : 'desc',
}, function() { }, () => {
this.setParams(); this.setParams();
}.bind(this)); });
}, },
handleSelectItem: function(id, is_checked) { handleSelectItem: function (id, is_checked) {
var selected_ids = this.state.selected_ids, let selected_ids = this.state.selected_ids,
selection = false; selection = false;
if (is_checked) { if (is_checked) {
selected_ids = jQuery.merge(selected_ids, [ id ]); selected_ids = jQuery.merge(selected_ids, [ id ]);
@ -666,48 +675,48 @@ const Listing = React.createClass({
this.setState({ this.setState({
selection: selection, selection: selection,
selected_ids: selected_ids selected_ids: selected_ids,
}); });
}, },
handleSelectItems: function(is_checked) { handleSelectItems: function (is_checked) {
if (is_checked === false) { if (is_checked === false) {
this.clearSelection(); this.clearSelection();
} else { } else {
var selected_ids = this.state.items.map(function(item) { const selected_ids = this.state.items.map((item) => {
return ~~item.id; return ~~item.id;
}); });
this.setState({ this.setState({
selected_ids: selected_ids, selected_ids: selected_ids,
selection: 'page' selection: 'page',
}); });
} }
}, },
handleSelectAll: function() { handleSelectAll: function () {
if (this.state.selection === 'all') { if (this.state.selection === 'all') {
this.clearSelection(); this.clearSelection();
} else { } else {
this.setState({ this.setState({
selection: 'all', selection: 'all',
selected_ids: [] selected_ids: [],
}); });
} }
}, },
clearSelection: function() { clearSelection: function () {
this.setState({ this.setState({
selection: false, selection: false,
selected_ids: [] selected_ids: [],
}); });
}, },
handleFilter: function(filters) { handleFilter: function (filters) {
this.setState({ this.setState({
filter: filters, filter: filters,
page: 1 page: 1,
}, function() { }, () => {
this.setParams(); this.setParams();
}.bind(this)); });
}, },
handleGroup: function(group) { handleGroup: function (group) {
// reset search // reset search
jQuery('#search_input').val(''); jQuery('#search_input').val('');
@ -715,35 +724,35 @@ const Listing = React.createClass({
group: group, group: group,
filter: {}, filter: {},
search: '', search: '',
page: 1 page: 1,
}, function() { }, () => {
this.setParams(); this.setParams();
}.bind(this)); });
}, },
handleSetPage: function(page) { handleSetPage: function (page) {
this.setState({ this.setState({
page: page, page: page,
selection: false, selection: false,
selected_ids: [] selected_ids: [],
}, function() { }, () => {
this.setParams(); this.setParams();
}.bind(this)); });
}, },
handleRenderItem: function(item, actions) { handleRenderItem: function (item, actions) {
const render = this.props.onRenderItem(item, actions, this.state.meta); const render = this.props.onRenderItem(item, actions, this.state.meta);
return render.props.children; return render.props.children;
}, },
handleRefreshItems: function() { handleRefreshItems: function () {
this.getItems(); this.getItems();
}, },
render: function() { render: function () {
const items = this.state.items; const items = this.state.items;
const sort_by = this.state.sort_by; const sort_by = this.state.sort_by;
const sort_order = this.state.sort_order; const sort_order = this.state.sort_order;
// columns // columns
let columns = this.props.columns || []; let columns = this.props.columns || [];
columns = columns.filter(function(column) { columns = columns.filter((column) => {
return (column.display === undefined || !!(column.display) === true); return (column.display === undefined || !!(column.display) === true);
}); });
@ -755,13 +764,13 @@ const Listing = React.createClass({
{ {
name: 'restore', name: 'restore',
label: MailPoet.I18n.t('restore'), label: MailPoet.I18n.t('restore'),
onSuccess: this.props.messages.onRestore onSuccess: this.props.messages.onRestore,
}, },
{ {
name: 'delete', name: 'delete',
label: MailPoet.I18n.t('deletePermanently'), label: MailPoet.I18n.t('deletePermanently'),
onSuccess: this.props.messages.onDelete onSuccess: this.props.messages.onDelete,
} },
]; ];
} }
@ -774,7 +783,7 @@ const Listing = React.createClass({
'widefat', 'widefat',
'fixed', 'fixed',
'striped', 'striped',
{ 'mailpoet_listing_loading': this.state.loading } { mailpoet_listing_loading: this.state.loading }
); );
// search // search
@ -821,6 +830,7 @@ const Listing = React.createClass({
filters={ this.state.filters } filters={ this.state.filters }
filter={ this.state.filter } filter={ this.state.filter }
group={ this.state.group } group={ this.state.group }
onBeforeSelectFilter={ this.props.onBeforeSelectFilter || null }
onSelectFilter={ this.handleFilter } onSelectFilter={ this.handleFilter }
onEmptyTrash={ this.handleEmptyTrash } onEmptyTrash={ this.handleEmptyTrash }
/> />
@ -889,7 +899,7 @@ const Listing = React.createClass({
</div> </div>
</div> </div>
); );
} },
}); });
module.exports = Listing; module.exports = Listing;

View File

@ -1,76 +1,76 @@
define([ define([
'react', 'react',
'classnames', 'classnames',
'mailpoet' 'mailpoet',
], function( ], (
React, React,
classNames, classNames,
MailPoet MailPoet
) { ) => {
var ListingPages = React.createClass({ const ListingPages = React.createClass({
getInitialState: function() { getInitialState: function () {
return { return {
page: null page: null,
} };
}, },
setPage: function(page) { setPage: function (page) {
this.setState({ this.setState({
page: null page: null,
}, function () { }, () => {
this.props.onSetPage(this.constrainPage(page)); this.props.onSetPage(this.constrainPage(page));
}.bind(this)); });
}, },
setFirstPage: function() { setFirstPage: function () {
this.setPage(1); this.setPage(1);
}, },
setLastPage: function() { setLastPage: function () {
this.setPage(this.getLastPage()); this.setPage(this.getLastPage());
}, },
setPreviousPage: function() { setPreviousPage: function () {
this.setPage(this.constrainPage( this.setPage(this.constrainPage(
parseInt(this.props.page, 10) - 1) parseInt(this.props.page, 10) - 1)
); );
}, },
setNextPage: function() { setNextPage: function () {
this.setPage(this.constrainPage( this.setPage(this.constrainPage(
parseInt(this.props.page, 10) + 1) parseInt(this.props.page, 10) + 1)
); );
}, },
constrainPage: function(page) { constrainPage: function (page) {
return Math.min(Math.max(1, Math.abs(~~page)), this.getLastPage()); return Math.min(Math.max(1, Math.abs(~~page)), this.getLastPage());
}, },
handleSetManualPage: function(e) { handleSetManualPage: function (e) {
if(e.which === 13) { if(e.which === 13) {
this.setPage(this.state.page); this.setPage(this.state.page);
} }
}, },
handleChangeManualPage: function(e) { handleChangeManualPage: function (e) {
this.setState({ this.setState({
page: e.target.value page: e.target.value,
}); });
}, },
handleBlurManualPage: function(e) { handleBlurManualPage: function (e) {
this.setPage(e.target.value); this.setPage(e.target.value);
}, },
getLastPage: function() { getLastPage: function () {
return Math.ceil(this.props.count / this.props.limit); return Math.ceil(this.props.count / this.props.limit);
}, },
render: function() { render: function () {
if(this.props.count === 0) { if(this.props.count === 0) {
return false; return false;
} else { } else {
var pagination = false; let pagination = false;
var firstPage = ( let firstPage = (
<span aria-hidden="true" className="tablenav-pages-navspan">«</span> <span aria-hidden="true" className="tablenav-pages-navspan">«</span>
); );
var previousPage = ( let previousPage = (
<span aria-hidden="true" className="tablenav-pages-navspan"></span> <span aria-hidden="true" className="tablenav-pages-navspan"></span>
); );
var nextPage = ( let nextPage = (
<span aria-hidden="true" className="tablenav-pages-navspan"></span> <span aria-hidden="true" className="tablenav-pages-navspan"></span>
); );
var lastPage = ( let lastPage = (
<span aria-hidden="true" className="tablenav-pages-navspan">»</span> <span aria-hidden="true" className="tablenav-pages-navspan">»</span>
); );
@ -159,12 +159,12 @@ define([
); );
} }
var classes = classNames( const classes = classNames(
'tablenav-pages', 'tablenav-pages',
{ 'one-page': (this.props.count <= this.props.limit) } { 'one-page': (this.props.count <= this.props.limit) }
); );
var numberOfItemsLabel; let numberOfItemsLabel;
if (this.props.count == 1) { if (this.props.count == 1) {
numberOfItemsLabel = MailPoet.I18n.t('numberOfItemsSingular'); numberOfItemsLabel = MailPoet.I18n.t('numberOfItemsSingular');
} else { } else {
@ -178,7 +178,7 @@ define([
</div> </div>
); );
} }
} },
}); });
return ListingPages; return ListingPages;

View File

@ -1,22 +1,22 @@
define([ define([
'mailpoet', 'mailpoet',
'react' 'react',
], function( ], (
MailPoet, MailPoet,
React React
) { ) => {
var ListingSearch = React.createClass({ const ListingSearch = React.createClass({
handleSearch: function(e) { handleSearch: function (e) {
e.preventDefault(); e.preventDefault();
this.props.onSearch( this.props.onSearch(
this.refs.search.value this.refs.search.value
); );
}, },
componentWillReceiveProps: function(nextProps) { componentWillReceiveProps: function (nextProps) {
this.refs.search.value = nextProps.search this.refs.search.value = nextProps.search;
}, },
render: function() { render: function () {
if(this.props.search === false) { if(this.props.search === false) {
return false; return false;
} else { } else {
@ -40,7 +40,7 @@ define([
</form> </form>
); );
} }
} },
}); });
return ListingSearch; return ListingSearch;

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'; 'use strict';
var MailPoet = mp;
MailPoet.MP2Migrator = { MailPoet.MP2Migrator = {
fatal_error: '', fatal_error: '',
@ -10,7 +12,7 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
clearTimeout(MailPoet.MP2Migrator.displayLogs_timeout); clearTimeout(MailPoet.MP2Migrator.displayLogs_timeout);
clearTimeout(MailPoet.MP2Migrator.updateProgressbar_timeout); clearTimeout(MailPoet.MP2Migrator.updateProgressbar_timeout);
clearTimeout(MailPoet.MP2Migrator.update_wordpress_info_timeout); clearTimeout(MailPoet.MP2Migrator.update_wordpress_info_timeout);
setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000) setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000);
}, },
stopLogger: function () { stopLogger: function () {
@ -27,8 +29,9 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
url: mailpoet_mp2_migrator.log_file_url, url: mailpoet_mp2_migrator.log_file_url,
cache: false cache: false
}).done(function (result) { }).done(function (result) {
jQuery("#logger").html(''); jQuery('#logger').html('');
result.split("\n").forEach(function (row) { 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')) { 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 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('#import-actions').hide();
jQuery('#upgrade-completed').show(); 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 () { }).always(function () {
if(MailPoet.MP2Migrator.is_logging) { if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000); MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);
@ -61,8 +64,10 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
} }
jQuery('#progressbar').progressbar('option', 'value', progress); jQuery('#progressbar').progressbar('option', 'value', progress);
jQuery('#progresslabel').html(progress + '%'); jQuery('#progresslabel').html(progress + '%');
if(Number(result.current !== 0)) { if(Number(result.current) !== 0) {
jQuery('#skip-import').hide(); jQuery('#skip-import').hide();
jQuery('#progressbar').show();
jQuery('#logger-container').show();
} }
if(MailPoet.MP2Migrator.is_logging) { if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.updateProgressbar_timeout = setTimeout(MailPoet.MP2Migrator.updateProgressbar, 1000); MailPoet.MP2Migrator.updateProgressbar_timeout = setTimeout(MailPoet.MP2Migrator.updateProgressbar, 1000);
@ -129,6 +134,15 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
jQuery('#stop-import').removeAttr('disabled'); // Enable the button jQuery('#stop-import').removeAttr('disabled'); // Enable the button
MailPoet.MP2Migrator.reactivateImportButton(); MailPoet.MP2Migrator.reactivateImportButton();
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
}).fail(function (response) {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function (error) {
return error.message;
}),
{scroll: true}
);
}
}); });
MailPoet.MP2Migrator.stopLogger(); MailPoet.MP2Migrator.stopLogger();
return false; return false;
@ -143,6 +157,15 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
} }
}).done(function () { }).done(function () {
MailPoet.MP2Migrator.gotoWelcomePage(); MailPoet.MP2Migrator.gotoWelcomePage();
}).fail(function (response) {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function (error) {
return error.message;
}),
{scroll: true}
);
}
}); });
return false; return false;
}, },

View File

@ -6,7 +6,8 @@ define([
'underscore', 'underscore',
'handlebars', 'handlebars',
'handlebars_helpers' 'handlebars_helpers'
], function(Backbone, Marionette, Radio, jQuery, _, Handlebars) { ], function(Backbone, Marionette, BackboneRadio, jQuery, _, Handlebars) {
var Radio = BackboneRadio;
var AppView = Marionette.View.extend({ var AppView = Marionette.View.extend({
el: '#mailpoet_editor', el: '#mailpoet_editor',
@ -15,8 +16,8 @@ define([
contentRegion: '#mailpoet_editor_content', contentRegion: '#mailpoet_editor_content',
sidebarRegion: '#mailpoet_editor_sidebar', sidebarRegion: '#mailpoet_editor_sidebar',
bottomRegion: '#mailpoet_editor_bottom', bottomRegion: '#mailpoet_editor_bottom',
headingRegion: '#mailpoet_editor_heading', headingRegion: '#mailpoet_editor_heading'
}, }
}); });
var EditorApplication = Marionette.Application.extend({ var EditorApplication = Marionette.Application.extend({
@ -28,7 +29,9 @@ define([
}, },
getChannel: function(channel) { getChannel: function(channel) {
if (channel === undefined) channel = 'global'; if (channel === undefined) {
return Radio.channel('global');
}
return Radio.channel(channel); return Radio.channel(channel);
} }
}); });

View File

@ -6,8 +6,8 @@
*/ */
define([ define([
'backbone.marionette' 'backbone.marionette'
], function(Marionette) { ], function(BackboneMarionette) {
var Marionette = BackboneMarionette;
var BehaviorsLookup = {}; var BehaviorsLookup = {};
Marionette.Behaviors.behaviorsLookup = function() { Marionette.Behaviors.behaviorsLookup = function() {
return BehaviorsLookup; return BehaviorsLookup;

View File

@ -9,18 +9,19 @@ define([
'mailpoet', 'mailpoet',
'spectrum' 'spectrum'
], function(Marionette, BehaviorsLookup, MailPoet, Spectrum) { ], function(Marionette, BehaviorsLookup, MailPoet, Spectrum) {
var BL = BehaviorsLookup;
BehaviorsLookup.ColorPickerBehavior = Marionette.Behavior.extend({ BL.ColorPickerBehavior = Marionette.Behavior.extend({
onRender: function() { onRender: function() {
this.view.$('.mailpoet_color').spectrum({ this.view.$('.mailpoet_color').spectrum({
clickoutFiresChange: true, clickoutFiresChange: true,
showInput: true, showInput: true,
showInitial: true, showInitial: true,
preferredFormat: "hex6", preferredFormat: 'hex6',
allowEmpty: true, allowEmpty: true,
chooseText: MailPoet.I18n.t('selectColor'), chooseText: MailPoet.I18n.t('selectColor'),
cancelText: MailPoet.I18n.t('cancelColorSelection') cancelText: MailPoet.I18n.t('cancelColorSelection')
}); });
}, }
}); });
}); });

View File

@ -11,11 +11,12 @@ define([
'jquery', 'jquery',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'interact' 'interact'
], function(Marionette, _, jQuery, BehaviorsLookup, interact) { ], function(Marionette, _, jQuery, BL, interact) {
var BehaviorsLookup = BL;
BehaviorsLookup.ContainerDropZoneBehavior = Marionette.Behavior.extend({ BehaviorsLookup.ContainerDropZoneBehavior = Marionette.Behavior.extend({
defaults: { defaults: {
columnLimit: 3, columnLimit: 3
}, },
onRender: function() { onRender: function() {
var dragAndDropDisabled = _.isObject(this.view.options.renderOptions) && this.view.options.renderOptions.disableDragAndDrop === true; var dragAndDropDisabled = _.isObject(this.view.options.renderOptions) && this.view.options.renderOptions.disableDragAndDrop === true;
@ -195,7 +196,7 @@ define([
if (view.model.get('orientation') === 'horizontal' && droppableModel.get('type') !== 'container') { if (view.model.get('orientation') === 'horizontal' && droppableModel.get('type') !== 'container') {
// Regular blocks always need to be inserted into columns - vertical containers // Regular blocks always need to be inserted into columns - vertical containers
tempCollection = new (EditorApplication.getBlockTypeModel('container'))({ tempCollection = new (EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical', orientation: 'vertical'
}); });
tempCollection.get('blocks').add(droppableModel); tempCollection.get('blocks').add(droppableModel);
viewCollection.add(tempCollection, {at: index}); viewCollection.add(tempCollection, {at: index});
@ -210,7 +211,7 @@ define([
var tempModel = viewCollection.at(dropPosition.index); var tempModel = viewCollection.at(dropPosition.index);
tempCollection = new (EditorApplication.getBlockTypeModel('container'))({ tempCollection = new (EditorApplication.getBlockTypeModel('container'))({
orientation: (view.model.get('orientation') === 'vertical') ? 'horizontal' : 'vertical', orientation: (view.model.get('orientation') === 'vertical') ? 'horizontal' : 'vertical'
}); });
viewCollection.remove(tempModel); viewCollection.remove(tempModel);
@ -218,19 +219,19 @@ define([
if (tempCollection.get('orientation') === 'horizontal') { if (tempCollection.get('orientation') === 'horizontal') {
if (dropPosition.position === 'before') { if (dropPosition.position === 'before') {
tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({ tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical', orientation: 'vertical'
}); });
tempCollection2.get('blocks').add(droppableModel); tempCollection2.get('blocks').add(droppableModel);
tempCollection.get('blocks').add(tempCollection2); tempCollection.get('blocks').add(tempCollection2);
} }
tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({ tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical', orientation: 'vertical'
}); });
tempCollection2.get('blocks').add(tempModel); tempCollection2.get('blocks').add(tempModel);
tempCollection.get('blocks').add(tempCollection2); tempCollection.get('blocks').add(tempCollection2);
if (dropPosition.position === 'after') { if (dropPosition.position === 'after') {
tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({ tempCollection2 = new (EditorApplication.getBlockTypeModel('container'))({
orientation: 'vertical', orientation: 'vertical'
}); });
tempCollection2.get('blocks').add(droppableModel); tempCollection2.get('blocks').add(droppableModel);
tempCollection.get('blocks').add(tempCollection2); tempCollection.get('blocks').add(tempCollection2);
@ -254,11 +255,11 @@ define([
event.draggable.onDrop({ event.draggable.onDrop({
dropBehavior: that, dropBehavior: that,
droppedModel: droppableModel, droppedModel: droppableModel,
droppedView: droppedView, droppedView: droppedView
}); });
that.cleanup(); that.cleanup();
}, }
}); });
}, },
cleanup: function() { cleanup: function() {
@ -268,7 +269,7 @@ define([
// 2. Remove visual markings of drop position visualization // 2. Remove visual markings of drop position visualization
this.view.$('.mailpoet_drop_marker').remove(); 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 var SPECIAL_AREA_INSERTION_WIDTH = 0.00, // Disable special insertion. Default: 0.3
element = this.view.$el, element = this.view.$el,
@ -290,13 +291,13 @@ define([
insertionType, index, position, indexAndPosition; insertionType, index, position, indexAndPosition;
unsafe = !!unsafe; unsafe = !!is_unsafe;
if (this.getCollection().length === 0) { if (this.getCollection().length === 0) {
return { return {
insertionType: 'normal', insertionType: 'normal',
index: 0, index: 0,
position: 'inside', position: 'inside'
}; };
} }
@ -347,7 +348,7 @@ define([
return { return {
insertionType: insertionType, // 'normal'|'special' insertionType: insertionType, // 'normal'|'special'
index: index, index: index,
position: position, // 'inside'|'before'|'after' position: position // 'inside'|'before'|'after'
}; };
}, },
_computeNormalIndex: function(eventX, eventY) { _computeNormalIndex: function(eventX, eventY) {
@ -377,13 +378,13 @@ define([
// First half of the element // First half of the element
return { return {
index: index, index: index,
position: 'before', position: 'before'
}; };
} else { } else {
// Second half of the element // Second half of the element
return { return {
index: index, index: index,
position: 'after', position: 'after'
}; };
} }
}, },

View File

@ -11,8 +11,9 @@ define([
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'interact' 'interact'
], function(Marionette, _, jQuery, BehaviorsLookup, interact) { ], function(Marionette, _, jQuery, BehaviorsLookup, interact) {
var BL = BehaviorsLookup;
BehaviorsLookup.DraggableBehavior = Marionette.Behavior.extend({ BL.DraggableBehavior = Marionette.Behavior.extend({
defaults: { defaults: {
cloneOriginal: false, cloneOriginal: false,
hideOriginal: false, hideOriginal: false,
@ -28,7 +29,7 @@ define([
}, },
onDrop: function(model, view) {}, onDrop: function(model, view) {},
testAttachToInstance: function(model, view) { return true; }, testAttachToInstance: function(model, view) { return true; }
}, },
onRender: function() { onRender: function() {
var that = this, var that = this,
@ -38,7 +39,7 @@ define([
if (!this.options.testAttachToInstance(this.view.model, this.view)) return; if (!this.options.testAttachToInstance(this.view.model, this.view)) return;
interactable = interact(this.$el.get(0), { interactable = interact(this.$el.get(0), {
ignoreFrom: this.options.ignoreSelector, ignoreFrom: this.options.ignoreSelector
}).draggable({ }).draggable({
// allow dragging of multple elements at the same time // allow dragging of multple elements at the same time
max: Infinity, max: Infinity,
@ -46,7 +47,8 @@ define([
// Scroll when dragging near edges of a window // Scroll when dragging near edges of a window
autoScroll: true, autoScroll: true,
onstart: function(event) { onstart: function(startEvent) {
var event = startEvent;
if (that.options.cloneOriginal === true) { if (that.options.cloneOriginal === true) {
// Use substitution instead of a clone // Use substitution instead of a clone
@ -89,9 +91,8 @@ define([
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy; y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
// translate the element // translate the element
target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)';
target.style.transform = target.style.webkitTransform = target.style.transform;
'translate(' + x + 'px, ' + y + 'px)';
// update the posiion attributes // update the posiion attributes
target.setAttribute('data-x', x); target.setAttribute('data-x', x);
@ -99,7 +100,8 @@ define([
}, },
onend: function (event) { onend: function (event) {
var target = event.target; 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-x');
target.removeAttribute('data-y'); target.removeAttribute('data-y');
jQuery(event.interaction.element).addClass('mailpoet_droppable_active'); jQuery(event.interaction.element).addClass('mailpoet_droppable_active');
@ -111,9 +113,10 @@ define([
that.view.$el.removeClass('mailpoet_hidden'); that.view.$el.removeClass('mailpoet_hidden');
} }
} }
}, }
}) })
.preventDefault('auto') .preventDefault('auto')
.styleCursor(false)
.actionChecker(function (pointer, event, action) { .actionChecker(function (pointer, event, action) {
// Disable dragging with right click // Disable dragging with right click
if (event.button !== 0) { if (event.button !== 0) {
@ -128,7 +131,8 @@ define([
} else { } else {
interactable.getDropModel = this.view.getDropFunc(); interactable.getDropModel = this.view.getDropFunc();
} }
interactable.onDrop = function(options) { interactable.onDrop = function(opts) {
var options = opts;
if (_.isObject(options)) { if (_.isObject(options)) {
// Inject Draggable behavior if possible // Inject Draggable behavior if possible
options.dragBehavior = that; options.dragBehavior = that;
@ -136,6 +140,6 @@ define([
// Delegate to view's event handler // Delegate to view's event handler
that.options.onDrop.apply(that, [options]); that.options.onDrop.apply(that, [options]);
}; };
}, }
}); });
}); });

View File

@ -5,19 +5,20 @@
*/ */
define([ define([
'backbone.marionette', 'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, BehaviorsLookup) { ], function(Marionette, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.HighlightEditingBehavior = Marionette.Behavior.extend({ BL.HighlightEditingBehavior = Marionette.Behavior.extend({
modelEvents: { modelEvents: {
'startEditing': 'enableHighlight', startEditing: 'enableHighlight',
'stopEditing': 'disableHighlight', stopEditing: 'disableHighlight'
}, },
enableHighlight: function() { enableHighlight: function() {
this.$el.addClass('mailpoet_highlight'); this.$el.addClass('mailpoet_highlight');
}, },
disableHighlight: function() { disableHighlight: function() {
this.$el.removeClass('mailpoet_highlight'); this.$el.removeClass('mailpoet_highlight');
}, }
}); });
}); });

View File

@ -8,18 +8,19 @@ define([
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup',
'interact' 'interact'
], function(Marionette, BehaviorsLookup, interact) { ], function(Marionette, BehaviorsLookup, interact) {
var BL = BehaviorsLookup;
BehaviorsLookup.ResizableBehavior = Marionette.Behavior.extend({ BL.ResizableBehavior = Marionette.Behavior.extend({
defaults: { defaults: {
elementSelector: null, elementSelector: null,
resizeHandleSelector: true, // true will use edges of the element itself resizeHandleSelector: true, // true will use edges of the element itself
transformationFunction: function(y) { return y; }, transformationFunction: function(y) { return y; },
minLength: 0, minLength: 0,
modelField: 'styles.block.height', modelField: 'styles.block.height'
}, },
events: { events: {
"mouseenter": 'showResizeHandle', mouseenter: 'showResizeHandle',
"mouseleave": 'hideResizeHandle', mouseleave: 'hideResizeHandle'
}, },
onRender: function() { onRender: function() {
this.attachResize(); this.attachResize();
@ -37,8 +38,8 @@ define([
top: false, top: false,
left: false, left: false,
right: false, right: false,
bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector, bottom: (typeof this.options.resizeHandleSelector === 'string') ? this.view.$(this.options.resizeHandleSelector).get(0) : this.options.resizeHandleSelector
}, }
}).on('resizestart', function(event) { }).on('resizestart', function(event) {
that.isBeingResized = true; that.isBeingResized = true;
that.$el.addClass('mailpoet_resize_active'); that.$el.addClass('mailpoet_resize_active');
@ -49,7 +50,8 @@ define([
if (newLength < that.options.minLength) newLength = that.options.minLength; if (newLength < that.options.minLength) newLength = that.options.minLength;
that.view.model.set(that.options.modelField, newLength + 'px'); that.view.model.set(that.options.modelField, newLength + 'px');
}).on('resizeend', function(event) { })
.on('resizeend', function(event) {
that.isBeingResized = null; that.isBeingResized = null;
that.$el.removeClass('mailpoet_resize_active'); that.$el.removeClass('mailpoet_resize_active');
}); });
@ -63,6 +65,6 @@ define([
if (typeof this.options.resizeHandleSelector === 'string') { if (typeof this.options.resizeHandleSelector === 'string') {
this.view.$(this.options.resizeHandleSelector).addClass('mailpoet_hidden'); this.view.$(this.options.resizeHandleSelector).addClass('mailpoet_hidden');
} }
}, }
}); });
}); });

View File

@ -6,15 +6,16 @@
define([ define([
'backbone.marionette', 'backbone.marionette',
'jquery', 'jquery',
'newsletter_editor/behaviors/BehaviorsLookup', 'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, jQuery, BehaviorsLookup) { ], function(Marionette, jQuery, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.ShowSettingsBehavior = Marionette.Behavior.extend({ BL.ShowSettingsBehavior = Marionette.Behavior.extend({
defaults: { defaults: {
ignoreFrom: '', // selector ignoreFrom: '' // selector
}, },
events: { events: {
'click .mailpoet_content': 'showSettings', 'click .mailpoet_content': 'showSettings'
}, },
showSettings: function(event) { showSettings: function(event) {
if(!this.isIgnoredElement(event.target)) { if(!this.isIgnoredElement(event.target)) {
@ -25,7 +26,7 @@ define([
return this.options.ignoreFrom return this.options.ignoreFrom
&& this.options.ignoreFrom.length > 0 && this.options.ignoreFrom.length > 0
&& jQuery(element).is(this.options.ignoreFrom); && jQuery(element).is(this.options.ignoreFrom);
}, }
}); });
}); });

View File

@ -8,14 +8,15 @@ define([
'underscore', 'underscore',
'newsletter_editor/behaviors/BehaviorsLookup' 'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, _, BehaviorsLookup) { ], function(Marionette, _, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.SortableBehavior = Marionette.Behavior.extend({ BL.SortableBehavior = Marionette.Behavior.extend({
onRender: function() { onRender: function() {
var collection = this.view.collection; var collection = this.view.collection;
if (_.isFunction(this.$el.sortable)) { if (_.isFunction(this.$el.sortable)) {
this.$el.sortable({ this.$el.sortable({
cursor: "move", cursor: 'move',
start: function(event, ui) { start: function(event, ui) {
ui.item.data('previousIndex', ui.item.index()); ui.item.data('previousIndex', ui.item.index());
}, },
@ -32,7 +33,7 @@ define([
collection.remove(model); collection.remove(model);
collection.add(model, { at: newIndex }); collection.add(model, { at: newIndex });
}, },
items: this.options.items, items: this.options.items
}); });
} }
} }

View File

@ -8,17 +8,18 @@ define([
'underscore', 'underscore',
'newsletter_editor/behaviors/BehaviorsLookup' 'newsletter_editor/behaviors/BehaviorsLookup'
], function(Marionette, _, BehaviorsLookup) { ], function(Marionette, _, BehaviorsLookup) {
var BL = BehaviorsLookup;
BehaviorsLookup.TextEditorBehavior = Marionette.Behavior.extend({ BL.TextEditorBehavior = Marionette.Behavior.extend({
defaults: { defaults: {
selector: '.mailpoet_content', selector: '.mailpoet_content',
toolbar1: "bold italic link unlink forecolor mailpoet_shortcodes", toolbar1: 'bold italic link unlink forecolor mailpoet_shortcodes',
toolbar2: "", toolbar2: '',
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br", validElements: 'p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br',
invalidElements: "script", invalidElements: 'script',
blockFormats: 'Paragraph=p', blockFormats: 'Paragraph=p',
plugins: "link textcolor colorpicker mailpoet_shortcodes", plugins: 'link textcolor colorpicker mailpoet_shortcodes',
configurationFilter: function(originalConfig) { return originalConfig; }, configurationFilter: function(originalConfig) { return originalConfig; }
}, },
onDomRefresh: function() { onDomRefresh: function() {
var that = this; var that = this;
@ -33,6 +34,8 @@ define([
toolbar1: this.options.toolbar1, toolbar1: this.options.toolbar1,
toolbar2: this.options.toolbar2, toolbar2: this.options.toolbar2,
browser_spellcheck: true,
valid_elements: this.options.validElements, valid_elements: this.options.validElements,
invalid_elements: this.options.invalidElements, invalid_elements: this.options.invalidElements,
block_formats: this.options.blockFormats, block_formats: this.options.blockFormats,
@ -76,7 +79,7 @@ define([
editor.on('blur', function(e) { editor.on('blur', function(e) {
that.view.triggerMethod('text:editor:blur'); that.view.triggerMethod('text:editor:blur');
}); });
}, }
})); }));
} }
}); });

View File

@ -28,7 +28,7 @@ define([
jQuery jQuery
) { ) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock; base = BaseBlock;
@ -53,7 +53,7 @@ define([
}); });
CommunicationComponent.getBulkTransformedPosts({ CommunicationComponent.getBulkTransformedPosts({
blocks: blocks, blocks: blocks
}).then(_.partial(this.refreshBlocks, models)); }).then(_.partial(this.refreshBlocks, models));
}, },
refreshBlocks: function(models, renderedBlocks) { refreshBlocks: function(models, renderedBlocks) {
@ -65,7 +65,7 @@ define([
model.trigger('refreshPosts', contents); model.trigger('refreshPosts', contents);
} }
); );
}, }
}); });
Module.AutomatedLatestContentBlockModel = base.BlockModel.extend({ Module.AutomatedLatestContentBlockModel = base.BlockModel.extend({
@ -97,14 +97,14 @@ define([
sortBy: 'newest', // 'newest'|'oldest', sortBy: 'newest', // 'newest'|'oldest',
showDivider: true, // true|false showDivider: true, // true|false
divider: {}, divider: {},
_container: new (App.getBlockTypeModel('container'))(), _container: new (App.getBlockTypeModel('container'))()
}, App.getConfig().get('blockDefaults.automatedLatestContent')); }, App.getConfig().get('blockDefaults.automatedLatestContent'));
}, },
relations: function() { relations: function() {
return { return {
readMoreButton: App.getBlockTypeModel('button'), readMoreButton: App.getBlockTypeModel('button'),
divider: App.getBlockTypeModel('divider'), divider: App.getBlockTypeModel('divider'),
_container: App.getBlockTypeModel('container'), _container: App.getBlockTypeModel('container')
}; };
}, },
initialize: function() { initialize: function() {
@ -124,29 +124,29 @@ define([
*/ */
_scheduleFetchPosts: function() { _scheduleFetchPosts: function() {
App.getChannel().trigger('automatedLatestContentRefresh'); App.getChannel().trigger('automatedLatestContentRefresh');
}, }
}); });
Module.AutomatedLatestContentBlockView = base.BlockView.extend({ 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() { initialize: function() {
function replaceButtonStylesHandler(data) { 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 templates.automatedLatestContentBlock; },
regions: { regions: {
toolsRegion: '.mailpoet_tools', toolsRegion: '.mailpoet_tools',
postsRegion: '.mailpoet_automated_latest_content_block_posts', postsRegion: '.mailpoet_automated_latest_content_block_posts'
}, },
modelEvents: _.extend( modelEvents: _.extend(
_.omit(base.BlockView.prototype.modelEvents, 'change'), _.omit(base.BlockView.prototype.modelEvents, 'change'),
{ {
'postsChanged': 'render', postsChanged: 'render'
}), }),
events: _.extend(base.BlockView.prototype.events, { events: _.extend(base.BlockView.prototype.events, {
'click .mailpoet_automated_latest_content_block_overlay': 'showSettings', 'click .mailpoet_automated_latest_content_block_overlay': 'showSettings'
}), }),
onDragSubstituteBy: function() { return Module.AutomatedLatestContentWidgetView; }, onDragSubstituteBy: function() { return Module.AutomatedLatestContentWidgetView; },
onRender: function() { onRender: function() {
@ -154,16 +154,16 @@ define([
renderOptions = { renderOptions = {
disableTextEditor: true, disableTextEditor: true,
disableDragAndDrop: true, disableDragAndDrop: true,
emptyContainerMessage: MailPoet.I18n.t('noPostsToDisplay'), emptyContainerMessage: MailPoet.I18n.t('noPostsToDisplay')
}; };
this.toolsView = new Module.AutomatedLatestContentBlockToolsView({ model: this.model }); this.toolsView = new Module.AutomatedLatestContentBlockToolsView({ model: this.model });
this.showChildView('toolsRegion', this.toolsView); this.showChildView('toolsRegion', this.toolsView);
this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_container'), renderOptions: renderOptions })); this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_container'), renderOptions: renderOptions }));
}, }
}); });
Module.AutomatedLatestContentBlockToolsView = base.BlockToolsView.extend({ Module.AutomatedLatestContentBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.AutomatedLatestContentBlockSettingsView; }, getSettingsView: function() { return Module.AutomatedLatestContentBlockSettingsView; }
}); });
// Sidebar view container // Sidebar view container
@ -171,28 +171,28 @@ define([
getTemplate: function() { return templates.automatedLatestContentBlockSettings; }, getTemplate: function() { return templates.automatedLatestContentBlockSettings; },
events: function() { events: function() {
return { return {
"click .mailpoet_automated_latest_content_hide_display_options": 'toggleDisplayOptions', 'click .mailpoet_automated_latest_content_hide_display_options': 'toggleDisplayOptions',
"click .mailpoet_automated_latest_content_show_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_button': 'showButtonSettings',
"click .mailpoet_automated_latest_content_select_divider": 'showDividerSettings', 'click .mailpoet_automated_latest_content_select_divider': 'showDividerSettings',
"change .mailpoet_automated_latest_content_read_more_type": 'changeReadMoreType', 'change .mailpoet_automated_latest_content_read_more_type': 'changeReadMoreType',
"change .mailpoet_automated_latest_content_display_type": 'changeDisplayType', 'change .mailpoet_automated_latest_content_display_type': 'changeDisplayType',
"change .mailpoet_automated_latest_content_title_format": 'changeTitleFormat', '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_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'),
"change .mailpoet_automated_latest_content_show_divider": _.partial(this.changeBoolField, 'showDivider'), 'change .mailpoet_automated_latest_content_show_divider': _.partial(this.changeBoolField, 'showDivider'),
"input .mailpoet_automated_latest_content_show_amount": _.partial(this.changeField, "amount"), '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_content_type': _.partial(this.changeField, 'contentType'),
"change .mailpoet_automated_latest_content_include_or_exclude": _.partial(this.changeField, "inclusionType"), '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_title_alignment': _.partial(this.changeField, 'titleAlignment'),
"change .mailpoet_automated_latest_content_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"), '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_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'),
"change .mailpoet_automated_latest_content_show_author": _.partial(this.changeField, "showAuthor"), 'change .mailpoet_automated_latest_content_show_author': _.partial(this.changeField, 'showAuthor'),
"input .mailpoet_automated_latest_content_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"), 'input .mailpoet_automated_latest_content_author_preceded_by': _.partial(this.changeField, 'authorPrecededBy'),
"change .mailpoet_automated_latest_content_show_categories": _.partial(this.changeField, "showCategories"), '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_categories': _.partial(this.changeField, 'categoriesPrecededBy'),
"input .mailpoet_automated_latest_content_read_more_text": _.partial(this.changeField, "readMoreText"), 'input .mailpoet_automated_latest_content_read_more_text': _.partial(this.changeField, 'readMoreText'),
"change .mailpoet_automated_latest_content_sort_by": _.partial(this.changeField, "sortBy"), 'change .mailpoet_automated_latest_content_sort_by': _.partial(this.changeField, 'sortBy'),
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
onRender: function() { onRender: function() {
@ -247,8 +247,8 @@ define([
} }
) )
}; };
}, }
}, }
}).on({ }).on({
'select2:select': function(event) { 'select2:select': function(event) {
var terms = that.model.get('terms'); var terms = that.model.get('terms');
@ -261,7 +261,7 @@ define([
terms.remove(event.params.data); terms.remove(event.params.data);
// Reset whole model in order for change events to propagate properly // Reset whole model in order for change events to propagate properly
that.model.set('terms', terms.toJSON()); that.model.set('terms', terms.toJSON());
}, }
}).trigger( 'change' ); }).trigger( 'change' );
}, },
toggleDisplayOptions: function(event) { toggleDisplayOptions: function(event) {
@ -282,8 +282,8 @@ define([
renderOptions: { renderOptions: {
displayFormat: 'subpanel', displayFormat: 'subpanel',
hideLink: true, hideLink: true,
hideApplyToAll: true, hideApplyToAll: true
}, }
})).render(); })).render();
}, },
showDividerSettings: function(event) { showDividerSettings: function(event) {
@ -292,8 +292,8 @@ define([
model: this.model.get('divider'), model: this.model.get('divider'),
renderOptions: { renderOptions: {
displayFormat: 'subpanel', displayFormat: 'subpanel',
hideApplyToAll: true, hideApplyToAll: true
}, }
})).render(); })).render();
}, },
changeReadMoreType: function(event) { changeReadMoreType: function(event) {
@ -356,11 +356,11 @@ define([
_.each(postTypes, function(type) { _.each(postTypes, function(type) {
select.append(jQuery('<option>', { select.append(jQuery('<option>', {
value: type.name, value: type.name,
text: type.label, text: type.label
})); }));
}); });
select.val(selectedValue); select.val(selectedValue);
}, }
}); });
Module.AutomatedLatestContentWidgetView = base.WidgetView.extend({ Module.AutomatedLatestContentWidgetView = base.WidgetView.extend({
@ -373,27 +373,28 @@ define([
}, },
onDrop: function(options) { onDrop: function(options) {
options.droppedView.triggerMethod('showSettings'); options.droppedView.triggerMethod('showSettings');
}, }
} }
}, }
}); });
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('automatedLatestContent', { App.registerBlockType('automatedLatestContent', {
blockModel: Module.AutomatedLatestContentBlockModel, blockModel: Module.AutomatedLatestContentBlockModel,
blockView: Module.AutomatedLatestContentBlockView, blockView: Module.AutomatedLatestContentBlockView
}); });
App.registerWidget({ App.registerWidget({
name: 'automatedLatestContent', name: 'automatedLatestContent',
widgetView: Module.AutomatedLatestContentWidgetView, widgetView: Module.AutomatedLatestContentWidgetView,
priority: 97, priority: 97
}); });
}); });
App.on('start', function(App, options) { App.on('start', function(App, options) {
App._ALCSupervisor = new Module.ALCSupervisor(); var Application = App;
App._ALCSupervisor.refresh(); Application._ALCSupervisor = new Module.ALCSupervisor();
Application._ALCSupervisor.refresh();
}); });
return Module; return Module;

View File

@ -14,7 +14,7 @@ define([
'modal' 'modal'
], function(App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) { ], function(App, Marionette, SuperModel, _, jQuery, MailPoet, Modal) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
AugmentedView = Marionette.View.extend({}); AugmentedView = Marionette.View.extend({});
@ -42,20 +42,21 @@ define([
}, },
getChildren: function() { getChildren: function() {
return []; return [];
}, }
}); });
Module.BlockView = AugmentedView.extend({ Module.BlockView = AugmentedView.extend({
regions: { regions: {
toolsRegion: '> .mailpoet_tools', toolsRegion: '> .mailpoet_tools'
}, },
modelEvents: { modelEvents: {
'change': 'render', change: 'render',
'delete': 'deleteBlock', delete: 'deleteBlock',
duplicate: 'duplicateBlock'
}, },
events: { events: {
"mouseenter": "showTools", mouseenter: 'showTools',
"mouseleave": "hideTools", mouseleave: 'hideTools'
}, },
behaviors: { behaviors: {
DraggableBehavior: { DraggableBehavior: {
@ -78,14 +79,14 @@ define([
WidgetView.destroy(); WidgetView.destroy();
return node; return node;
} }
}, }
}, },
HighlightEditingBehavior: {}, HighlightEditingBehavior: {}
}, },
templateContext: function() { templateContext: function() {
return { return {
model: this.model.toJSON(), model: this.model.toJSON(),
viewCid: this.cid, viewCid: this.cid
}; };
}, },
constructor: function() { constructor: function() {
@ -142,6 +143,9 @@ define([
this.model.destroy(); this.model.destroy();
}.bind(this)); }.bind(this));
}, },
duplicateBlock: function() {
this.model.collection.add(this.model.toJSON(), {at: this.model.collection.findIndex(this.model)});
},
transitionIn: function() { transitionIn: function() {
return this._transition('slideDown', 'fadeIn', 'easeOut'); return this._transition('slideDown', 'fadeIn', 'easeOut');
}, },
@ -158,38 +162,40 @@ define([
easing: easing, easing: easing,
complete: function() { complete: function() {
promise.resolve(); promise.resolve();
}.bind(this), }.bind(this)
} }
).velocity( ).velocity(
fadeDirection, fadeDirection,
{ {
duration: 250, duration: 250,
easing: easing, easing: easing,
queue: false, // Do not enqueue, trigger animation in parallel queue: false // Do not enqueue, trigger animation in parallel
} }
); );
return promise; return promise;
}, }
}); });
Module.BlockToolsView = AugmentedView.extend({ Module.BlockToolsView = AugmentedView.extend({
getTemplate: function() { return templates.genericBlockTools; }, getTemplate: function() { return templates.genericBlockTools; },
events: { events: {
"click .mailpoet_edit_block": "changeSettings", 'click .mailpoet_edit_block': 'changeSettings',
"click .mailpoet_delete_block_activate": "showDeletionConfirmation", 'click .mailpoet_delete_block_activate': 'showDeletionConfirmation',
"click .mailpoet_delete_block_cancel": "hideDeletionConfirmation", 'click .mailpoet_delete_block_cancel': 'hideDeletionConfirmation',
"click .mailpoet_delete_block_confirm": "deleteBlock", 'click .mailpoet_delete_block_confirm': 'deleteBlock',
'click .mailpoet_duplicate_block': 'duplicateBlock'
}, },
// Markers of whether these particular tools will be used for this instance // Markers of whether these particular tools will be used for this instance
tools: { tools: {
settings: true, settings: true,
delete: true, delete: true,
move: true, duplicate: true,
move: true
}, },
getSettingsView: function() { return Module.BlockSettingsView; }, getSettingsView: function() { return Module.BlockSettingsView; },
initialize: function(options) { initialize: function(opts) {
options = options || {}; var options = opts || {};
if (!_.isUndefined(options.tools)) { if (!_.isUndefined(options.tools)) {
// Make a new block specific tool config object // Make a new block specific tool config object
this.tools = jQuery.extend({}, this.tools, options.tools || {}); this.tools = jQuery.extend({}, this.tools, options.tools || {});
@ -203,7 +209,7 @@ define([
return { return {
model: this.model.toJSON(), model: this.model.toJSON(),
viewCid: this.cid, viewCid: this.cid,
tools: this.tools, tools: this.tools
}; };
}, },
changeSettings: function(options) { changeSettings: function(options) {
@ -221,12 +227,17 @@ define([
this.model.trigger('delete'); this.model.trigger('delete');
return false; return false;
}, },
duplicateBlock: function(event) {
event.preventDefault();
this.model.trigger('duplicate');
return false;
}
}); });
Module.BlockSettingsView = Marionette.View.extend({ Module.BlockSettingsView = Marionette.View.extend({
className: 'mailpoet_editor_settings', className: 'mailpoet_editor_settings',
behaviors: { behaviors: {
ColorPickerBehavior: {}, ColorPickerBehavior: {}
}, },
initialize: function(params) { initialize: function(params) {
this.model.trigger('startEditing'); this.model.trigger('startEditing');
@ -237,7 +248,7 @@ define([
width: App.getConfig().get('sidepanelWidth'), width: App.getConfig().get('sidepanelWidth'),
onCancel: function() { onCancel: function() {
this.destroy(); this.destroy();
}.bind(this), }.bind(this)
}; };
this.renderOptions = params.renderOptions || {}; this.renderOptions = params.renderOptions || {};
if (this.renderOptions.displayFormat === 'subpanel') { if (this.renderOptions.displayFormat === 'subpanel') {
@ -279,7 +290,7 @@ define([
onBeforeDestroy: function() { onBeforeDestroy: function() {
MailPoet.Modal.close(); MailPoet.Modal.close();
this.model.trigger('stopEditing'); this.model.trigger('stopEditing');
}, }
}); });
Module.WidgetView = Marionette.View.extend({ Module.WidgetView = Marionette.View.extend({
@ -287,10 +298,10 @@ define([
behaviors: { behaviors: {
DraggableBehavior: { DraggableBehavior: {
drop: function() { drop: function() {
throw "Unsupported operation"; throw 'Unsupported operation';
} }
} }
}, }
}); });
return Module; return Module;

View File

@ -9,7 +9,7 @@ define([
'jquery' 'jquery'
], function(App, BaseBlock, MailPoet, _, jQuery) { ], function(App, BaseBlock, MailPoet, _, jQuery) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock; base = BaseBlock;
@ -33,19 +33,19 @@ define([
fontFamily: 'Arial', fontFamily: 'Arial',
fontSize: '16px', fontSize: '16px',
fontWeight: 'normal', // 'normal'|'bold' fontWeight: 'normal', // 'normal'|'bold'
textAlign: 'center', textAlign: 'center'
}, }
}, }
}, App.getConfig().get('blockDefaults.button')); }, App.getConfig().get('blockDefaults.button'));
}, }
}); });
Module.ButtonBlockView = base.BlockView.extend({ Module.ButtonBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_button_block mailpoet_droppable_block", className: 'mailpoet_block mailpoet_button_block mailpoet_droppable_block',
getTemplate: function() { return templates.buttonBlock; }, getTemplate: function() { return templates.buttonBlock; },
onDragSubstituteBy: function() { return Module.ButtonWidgetView; }, onDragSubstituteBy: function() { return Module.ButtonWidgetView; },
behaviors: _.extend({}, base.BlockView.prototype.behaviors, { behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ShowSettingsBehavior: {}, ShowSettingsBehavior: {}
}), }),
initialize: function() { initialize: function() {
base.BlockView.prototype.initialize.apply(this, arguments); base.BlockView.prototype.initialize.apply(this, arguments);
@ -57,51 +57,51 @@ define([
onRender: function() { onRender: function() {
this.toolsView = new Module.ButtonBlockToolsView({ model: this.model }); this.toolsView = new Module.ButtonBlockToolsView({ model: this.model });
this.showChildView('toolsRegion', this.toolsView); this.showChildView('toolsRegion', this.toolsView);
}, }
}); });
Module.ButtonBlockToolsView = base.BlockToolsView.extend({ Module.ButtonBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.ButtonBlockSettingsView; }, getSettingsView: function() { return Module.ButtonBlockSettingsView; }
}); });
Module.ButtonBlockSettingsView = base.BlockSettingsView.extend({ Module.ButtonBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.buttonBlockSettings; }, getTemplate: function() { return templates.buttonBlockSettings; },
events: function() { events: function() {
return { return {
"input .mailpoet_field_button_text": _.partial(this.changeField, "text"), 'input .mailpoet_field_button_text': _.partial(this.changeField, 'text'),
"input .mailpoet_field_button_url": _.partial(this.changeField, "url"), 'input .mailpoet_field_button_url': _.partial(this.changeField, 'url'),
"change .mailpoet_field_button_alignment": _.partial(this.changeField, "styles.block.textAlign"), '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_color': _.partial(this.changeColorField, 'styles.block.fontColor'),
"change .mailpoet_field_button_font_family": _.partial(this.changeField, "styles.block.fontFamily"), '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_font_size': _.partial(this.changeField, 'styles.block.fontSize'),
"change .mailpoet_field_button_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"), '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_border_color': _.partial(this.changeColorField, 'styles.block.borderColor'),
"change .mailpoet_field_button_font_weight": "changeFontWeight", '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)), '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)), '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_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)), '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)), '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_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)), '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)), '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_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)), '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)), '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_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_field_button_replace_all_styles': 'applyToAll',
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
templateContext: function() { templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(), availableStyles: App.getAvailableStyles().toJSON(),
renderOptions: this.renderOptions, renderOptions: this.renderOptions
}); });
}, },
applyToAll: function() { applyToAll: function() {
@ -127,21 +127,21 @@ define([
cloneOriginal: true, cloneOriginal: true,
drop: function() { drop: function() {
return new Module.ButtonBlockModel(); return new Module.ButtonBlockModel();
}, }
} }
}, }
}); });
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('button', { App.registerBlockType('button', {
blockModel: Module.ButtonBlockModel, blockModel: Module.ButtonBlockModel,
blockView: Module.ButtonBlockView, blockView: Module.ButtonBlockView
}); });
App.registerWidget({ App.registerWidget({
name: 'button', name: 'button',
widgetView: Module.ButtonWidgetView, widgetView: Module.ButtonWidgetView,
priority: 92, priority: 92
}); });
}); });

View File

@ -12,7 +12,7 @@ define([
'newsletter_editor/blocks/base' 'newsletter_editor/blocks/base'
], function(Backbone, Marionette, _, jQuery, App, BaseBlock) { ], function(Backbone, Marionette, _, jQuery, App, BaseBlock) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock, base = BaseBlock,
@ -30,12 +30,12 @@ define([
// TODO: If type has no registered model, use a backup one // TODO: If type has no registered model, use a backup one
return new Type(block, {parse: true}); return new Type(block, {parse: true});
}); });
}, }
}); });
Module.ContainerBlockModel = base.BlockModel.extend({ Module.ContainerBlockModel = base.BlockModel.extend({
relations: { relations: {
blocks: BlockCollection, blocks: BlockCollection
}, },
defaults: function() { defaults: function() {
return this._getDefaults({ return this._getDefaults({
@ -43,10 +43,10 @@ define([
orientation: 'vertical', orientation: 'vertical',
styles: { styles: {
block: { block: {
backgroundColor: 'transparent', backgroundColor: 'transparent'
}, }
}, },
blocks: new BlockCollection(), blocks: new BlockCollection()
}, App.getConfig().get('blockDefaults.container')); }, App.getConfig().get('blockDefaults.container'));
}, },
validate: function() { validate: function() {
@ -60,7 +60,7 @@ define([
// If container has any blocks - add them to a collection // If container has any blocks - add them to a collection
if (response.type === 'container' && _.has(response, 'blocks')) { if (response.type === 'container' && _.has(response, 'blocks')) {
response.blocks = new BlockCollection(response.blocks, { response.blocks = new BlockCollection(response.blocks, {
parse: true, parse: true
}); });
} }
return response; return response;
@ -71,7 +71,7 @@ define([
}); });
return _.flatten(models); return _.flatten(models);
}, }
}); });
Module.ContainerBlocksView = Marionette.CollectionView.extend({ Module.ContainerBlocksView = Marionette.CollectionView.extend({
@ -100,12 +100,12 @@ define([
blocks: { blocks: {
el: '> .mailpoet_container', el: '> .mailpoet_container',
replaceElement: true replaceElement: true
}, }
}), }),
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block', className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
getTemplate: function() { return templates.containerBlock; }, getTemplate: function() { return templates.containerBlock; },
events: _.extend({}, base.BlockView.prototype.events, { events: _.extend({}, base.BlockView.prototype.events, {
"click .mailpoet_newsletter_layer_selector": "toggleEditingLayer", 'click .mailpoet_newsletter_layer_selector': 'toggleEditingLayer'
}), }),
ui: { ui: {
tools: '> .mailpoet_tools' tools: '> .mailpoet_tools'
@ -137,8 +137,8 @@ define([
// Attach Draggable only to layout containers and disable it // Attach Draggable only to layout containers and disable it
// for root and column containers. // for root and column containers.
return view.renderOptions.depth === 1; return view.renderOptions.depth === 1;
}, }
}, }
}), }),
onDragSubstituteBy: function() { onDragSubstituteBy: function() {
// For two and three column layouts display their respective widgets, // For two and three column layouts display their respective widgets,
@ -161,9 +161,10 @@ define([
tools: { tools: {
settings: this.renderOptions.depth === 1, settings: this.renderOptions.depth === 1,
delete: this.renderOptions.depth === 1, delete: this.renderOptions.depth === 1,
duplicate: true,
move: this.renderOptions.depth === 1, move: this.renderOptions.depth === 1,
layerSelector: false, layerSelector: false
}, }
}); });
this.showChildView('toolsRegion', this.toolsView); this.showChildView('toolsRegion', this.toolsView);
this.showChildView('blocks', new Module.ContainerBlocksView({ this.showChildView('blocks', new Module.ContainerBlocksView({
@ -212,7 +213,7 @@ define([
enableContainerLayer(); enableContainerLayer();
} }
event.stopPropagation(); event.stopPropagation();
}, }
}); });
Module.ContainerBlockEmptyView = Marionette.View.extend({ Module.ContainerBlockEmptyView = Marionette.View.extend({
@ -223,45 +224,45 @@ define([
templateContext: function() { templateContext: function() {
return { return {
isRoot: this.renderOptions.depth === 0, isRoot: this.renderOptions.depth === 0,
emptyContainerMessage: this.renderOptions.emptyContainerMessage || '', emptyContainerMessage: this.renderOptions.emptyContainerMessage || ''
}; };
}, }
}); });
Module.ContainerBlockToolsView = base.BlockToolsView.extend({ Module.ContainerBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.ContainerBlockSettingsView; }, getSettingsView: function() { return Module.ContainerBlockSettingsView; }
}); });
Module.ContainerBlockSettingsView = base.BlockSettingsView.extend({ Module.ContainerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.containerBlockSettings; }, getTemplate: function() { return templates.containerBlockSettings; },
events: function() { events: function() {
return { return {
"change .mailpoet_field_container_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"), 'change .mailpoet_field_container_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
regions: { regions: {
columnsSettingsRegion: '.mailpoet_container_columns_settings', columnsSettingsRegion: '.mailpoet_container_columns_settings'
}, },
initialize: function() { initialize: function() {
base.BlockSettingsView.prototype.initialize.apply(this, arguments); base.BlockSettingsView.prototype.initialize.apply(this, arguments);
this._columnsSettingsView = new (Module.ContainerBlockColumnsSettingsView)({ this._columnsSettingsView = new (Module.ContainerBlockColumnsSettingsView)({
collection: this.model.get('blocks'), collection: this.model.get('blocks')
}); });
}, },
onRender: function() { onRender: function() {
this.showChildView('columnsSettingsRegion', this._columnsSettingsView); this.showChildView('columnsSettingsRegion', this._columnsSettingsView);
}, }
}); });
Module.ContainerBlockColumnsSettingsView = Marionette.CollectionView.extend({ Module.ContainerBlockColumnsSettingsView = Marionette.CollectionView.extend({
childView: function() { return Module.ContainerBlockColumnSettingsView; }, childView: function() { return Module.ContainerBlockColumnSettingsView; },
childViewOptions: function(model, index) { childViewOptions: function(model, index) {
return { return {
columnIndex: index, columnIndex: index
}; };
}, }
}); });
Module.ContainerBlockColumnSettingsView = Marionette.View.extend({ Module.ContainerBlockColumnSettingsView = Marionette.View.extend({
@ -272,9 +273,9 @@ define([
templateContext: function() { templateContext: function() {
return { return {
model: this.model.toJSON(), model: this.model.toJSON(),
columnNumber: this.columnNumber, columnNumber: this.columnNumber
}; };
}, }
}); });
Module.OneColumnContainerWidgetView = base.WidgetView.extend({ Module.OneColumnContainerWidgetView = base.WidgetView.extend({
@ -287,12 +288,12 @@ define([
return new Module.ContainerBlockModel({ return new Module.ContainerBlockModel({
orientation: 'horizontal', orientation: 'horizontal',
blocks: [ blocks: [
new Module.ContainerBlockModel(), new Module.ContainerBlockModel()
] ]
}); });
} }
} }
}, }
}); });
Module.TwoColumnContainerWidgetView = base.WidgetView.extend({ Module.TwoColumnContainerWidgetView = base.WidgetView.extend({
@ -306,12 +307,12 @@ define([
orientation: 'horizontal', orientation: 'horizontal',
blocks: [ blocks: [
new Module.ContainerBlockModel(), new Module.ContainerBlockModel(),
new Module.ContainerBlockModel(), new Module.ContainerBlockModel()
] ]
}); });
} }
} }
}, }
}); });
Module.ThreeColumnContainerWidgetView = base.WidgetView.extend({ Module.ThreeColumnContainerWidgetView = base.WidgetView.extend({
@ -326,36 +327,36 @@ define([
blocks: [ blocks: [
new Module.ContainerBlockModel(), new Module.ContainerBlockModel(),
new Module.ContainerBlockModel(), new Module.ContainerBlockModel(),
new Module.ContainerBlockModel(), new Module.ContainerBlockModel()
] ]
}); });
} }
} }
}, }
}); });
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('container', { App.registerBlockType('container', {
blockModel: Module.ContainerBlockModel, blockModel: Module.ContainerBlockModel,
blockView: Module.ContainerBlockView, blockView: Module.ContainerBlockView
}); });
App.registerLayoutWidget({ App.registerLayoutWidget({
name: 'oneColumnLayout', name: 'oneColumnLayout',
priority: 100, priority: 100,
widgetView: Module.OneColumnContainerWidgetView, widgetView: Module.OneColumnContainerWidgetView
}); });
App.registerLayoutWidget({ App.registerLayoutWidget({
name: 'twoColumnLayout', name: 'twoColumnLayout',
priority: 100, priority: 100,
widgetView: Module.TwoColumnContainerWidgetView, widgetView: Module.TwoColumnContainerWidgetView
}); });
App.registerLayoutWidget({ App.registerLayoutWidget({
name: 'threeColumnLayout', name: 'threeColumnLayout',
priority: 100, priority: 100,
widgetView: Module.ThreeColumnContainerWidgetView, widgetView: Module.ThreeColumnContainerWidgetView
}); });
}); });

View File

@ -9,7 +9,7 @@ define([
'mailpoet' 'mailpoet'
], function(App, BaseBlock, _, jQuery, MailPoet) { ], function(App, BaseBlock, _, jQuery, MailPoet) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock; base = BaseBlock;
@ -24,15 +24,15 @@ define([
padding: '12px', padding: '12px',
borderStyle: 'solid', borderStyle: 'solid',
borderWidth: '1px', borderWidth: '1px',
borderColor: '#000000', borderColor: '#000000'
}, }
}, }
}, App.getConfig().get('blockDefaults.divider')); }, App.getConfig().get('blockDefaults.divider'));
}, }
}); });
Module.DividerBlockView = base.BlockView.extend({ Module.DividerBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_divider_block mailpoet_droppable_block", className: 'mailpoet_block mailpoet_divider_block mailpoet_droppable_block',
getTemplate: function() { return templates.dividerBlock; }, getTemplate: function() { return templates.dividerBlock; },
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
behaviors: _.defaults({ behaviors: _.defaults({
@ -41,11 +41,11 @@ define([
resizeHandleSelector: '.mailpoet_resize_handle', resizeHandleSelector: '.mailpoet_resize_handle',
transformationFunction: function(y) { return y / 2; }, transformationFunction: function(y) { return y / 2; },
minLength: 0, // TODO: Move this number to editor configuration minLength: 0, // TODO: Move this number to editor configuration
modelField: 'styles.block.padding', modelField: 'styles.block.padding'
}, },
ShowSettingsBehavior: { ShowSettingsBehavior: {
ignoreFrom: '.mailpoet_resize_handle' ignoreFrom: '.mailpoet_resize_handle'
}, }
}, base.BlockView.prototype.behaviors), }, base.BlockView.prototype.behaviors),
onDragSubstituteBy: function() { return Module.DividerWidgetView; }, onDragSubstituteBy: function() { return Module.DividerWidgetView; },
initialize: function() { initialize: function() {
@ -61,7 +61,7 @@ define([
}, },
templateContext: function() { templateContext: function() {
return _.extend({ return _.extend({
totalHeight: parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px', totalHeight: parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px'
}, base.BlockView.prototype.templateContext.apply(this)); }, base.BlockView.prototype.templateContext.apply(this));
}, },
onRender: function() { onRender: function() {
@ -76,38 +76,38 @@ define([
this.$('.mailpoet_content').css('padding-top', this.model.get('styles.block.padding')); this.$('.mailpoet_content').css('padding-top', this.model.get('styles.block.padding'));
this.$('.mailpoet_content').css('padding-bottom', this.model.get('styles.block.padding')); this.$('.mailpoet_content').css('padding-bottom', this.model.get('styles.block.padding'));
this.$('.mailpoet_resize_handle_text').text(parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px'); this.$('.mailpoet_resize_handle_text').text(parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px');
}, }
}); });
Module.DividerBlockToolsView = base.BlockToolsView.extend({ Module.DividerBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.DividerBlockSettingsView; }, getSettingsView: function() { return Module.DividerBlockSettingsView; }
}); });
Module.DividerBlockSettingsView = base.BlockSettingsView.extend({ Module.DividerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.dividerBlockSettings; }, getTemplate: function() { return templates.dividerBlockSettings; },
events: function() { events: function() {
return { 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)), '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)), '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_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_border_color': _.partial(this.changeColorField, 'styles.block.borderColor'),
"change .mailpoet_field_divider_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"), 'change .mailpoet_field_divider_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
"click .mailpoet_button_divider_apply_to_all": "applyToAll", 'click .mailpoet_button_divider_apply_to_all': 'applyToAll',
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
modelEvents: function() { modelEvents: function() {
return { return {
'change:styles.block.borderColor': 'repaintDividerStyleOptions', 'change:styles.block.borderColor': 'repaintDividerStyleOptions'
}; };
}, },
templateContext: function() { templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(), availableStyles: App.getAvailableStyles().toJSON(),
renderOptions: this.renderOptions, renderOptions: this.renderOptions
}); });
}, },
changeStyle: function(event) { changeStyle: function(event) {
@ -125,7 +125,7 @@ define([
updateValueAndCall: function(fieldToUpdate, callable, event) { updateValueAndCall: function(fieldToUpdate, callable, event) {
this.$(fieldToUpdate).val(jQuery(event.target).val()); this.$(fieldToUpdate).val(jQuery(event.target).val());
callable(event); callable(event);
}, }
}); });
Module.DividerWidgetView = base.WidgetView.extend({ Module.DividerWidgetView = base.WidgetView.extend({
@ -135,20 +135,20 @@ define([
cloneOriginal: true, cloneOriginal: true,
drop: function() { drop: function() {
return new Module.DividerBlockModel(); return new Module.DividerBlockModel();
}, }
} }
}, }
}); });
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('divider', { App.registerBlockType('divider', {
blockModel: Module.DividerBlockModel, blockModel: Module.DividerBlockModel,
blockView: Module.DividerBlockView, blockView: Module.DividerBlockView
}); });
App.registerWidget({ App.registerWidget({
name: 'divider', name: 'divider',
widgetView: Module.DividerWidgetView, widgetView: Module.DividerWidgetView,
priority: 93, priority: 93
}); });
}); });

View File

@ -7,7 +7,7 @@ define([
'underscore' 'underscore'
], function(App, BaseBlock, _) { ], function(App, BaseBlock, _) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock; base = BaseBlock;
@ -19,38 +19,38 @@ define([
text: '<a href="[link:subscription_unsubscribe_url]">Unsubscribe</a> | <a href="[link:subscription_manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>', text: '<a href="[link:subscription_unsubscribe_url]">Unsubscribe</a> | <a href="[link:subscription_manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>',
styles: { styles: {
block: { block: {
backgroundColor: 'transparent', backgroundColor: 'transparent'
}, },
text: { text: {
fontColor: '#000000', fontColor: '#000000',
fontFamily: 'Arial', fontFamily: 'Arial',
fontSize: '12px', fontSize: '12px',
textAlign: 'center', textAlign: 'center'
}, },
link: { link: {
fontColor: '#0000ff', fontColor: '#0000ff',
textDecoration: 'none', textDecoration: 'none'
}, }
}, }
}, App.getConfig().get('blockDefaults.footer')); }, App.getConfig().get('blockDefaults.footer'));
}, }
}); });
Module.FooterBlockView = base.BlockView.extend({ Module.FooterBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_footer_block mailpoet_droppable_block", className: 'mailpoet_block mailpoet_footer_block mailpoet_droppable_block',
getTemplate: function() { return templates.footerBlock; }, getTemplate: function() { return templates.footerBlock; },
modelEvents: _.extend({ 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', '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')), }, _.omit(base.BlockView.prototype.modelEvents, 'change')),
behaviors: _.extend({}, base.BlockView.prototype.behaviors, { behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
TextEditorBehavior: { TextEditorBehavior: {
configurationFilter: function(originalSettings) { configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, { return _.extend({}, originalSettings, {
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(), mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'), mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
}); });
} }
}, }
}), }),
onDragSubstituteBy: function() { return Module.FooterWidgetView; }, onDragSubstituteBy: function() { return Module.FooterWidgetView; },
onRender: function() { onRender: function() {
@ -67,34 +67,34 @@ define([
onTextEditorBlur: function() { onTextEditorBlur: function() {
this.enableDragging(); this.enableDragging();
this.enableShowingTools(); this.enableShowingTools();
}, }
}); });
Module.FooterBlockToolsView = base.BlockToolsView.extend({ Module.FooterBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.FooterBlockSettingsView; }, getSettingsView: function() { return Module.FooterBlockSettingsView; }
}); });
Module.FooterBlockSettingsView = base.BlockSettingsView.extend({ Module.FooterBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.footerBlockSettings; }, getTemplate: function() { return templates.footerBlockSettings; },
events: function() { events: function() {
return { return {
"change .mailpoet_field_footer_text_color": _.partial(this.changeColorField, "styles.text.fontColor"), '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_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
"change .mailpoet_field_footer_text_size": _.partial(this.changeField, "styles.text.fontSize"), '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_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
"change #mailpoet_field_footer_link_underline": function(event) { 'change #mailpoet_field_footer_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none'); 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_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
"change .mailpoet_field_footer_alignment": _.partial(this.changeField, "styles.text.textAlign"), 'change .mailpoet_field_footer_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
templateContext: function() { templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(), availableStyles: App.getAvailableStyles().toJSON()
}); });
}, }
}); });
Module.FooterWidgetView = base.WidgetView.extend({ Module.FooterWidgetView = base.WidgetView.extend({
@ -104,21 +104,21 @@ define([
cloneOriginal: true, cloneOriginal: true,
drop: function() { drop: function() {
return new Module.FooterBlockModel(); return new Module.FooterBlockModel();
}, }
} }
}, }
}); });
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('footer', { App.registerBlockType('footer', {
blockModel: Module.FooterBlockModel, blockModel: Module.FooterBlockModel,
blockView: Module.FooterBlockView, blockView: Module.FooterBlockView
}); });
App.registerWidget({ App.registerWidget({
name: 'footer', name: 'footer',
widgetView: Module.FooterWidgetView, widgetView: Module.FooterWidgetView,
priority: 99, priority: 99
}); });
}); });

View File

@ -7,7 +7,7 @@ define([
'underscore' 'underscore'
], function(App, BaseBlock, _) { ], function(App, BaseBlock, _) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock; base = BaseBlock;
@ -19,38 +19,38 @@ define([
text: 'Display problems? <a href="[link:newsletter_view_in_browser_url]">View it in your browser</a>', text: 'Display problems? <a href="[link:newsletter_view_in_browser_url]">View it in your browser</a>',
styles: { styles: {
block: { block: {
backgroundColor: 'transparent', backgroundColor: 'transparent'
}, },
text: { text: {
fontColor: '#000000', fontColor: '#000000',
fontFamily: 'Arial', fontFamily: 'Arial',
fontSize: '12px', fontSize: '12px',
textAlign: 'center', textAlign: 'center'
}, },
link: { link: {
fontColor: '#0000ff', fontColor: '#0000ff',
textDecoration: 'underline', textDecoration: 'underline'
}, }
}, }
}, App.getConfig().get('blockDefaults.header')); }, App.getConfig().get('blockDefaults.header'));
}, }
}); });
Module.HeaderBlockView = base.BlockView.extend({ Module.HeaderBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_header_block mailpoet_droppable_block", className: 'mailpoet_block mailpoet_header_block mailpoet_droppable_block',
getTemplate: function() { return templates.headerBlock; }, getTemplate: function() { return templates.headerBlock; },
modelEvents: _.extend({ 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', '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')), }, _.omit(base.BlockView.prototype.modelEvents, 'change')),
behaviors: _.extend({}, base.BlockView.prototype.behaviors, { behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
TextEditorBehavior: { TextEditorBehavior: {
configurationFilter: function(originalSettings) { configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, { return _.extend({}, originalSettings, {
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(), mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'), mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
}); });
} }
}, }
}), }),
onDragSubstituteBy: function() { return Module.HeaderWidgetView; }, onDragSubstituteBy: function() { return Module.HeaderWidgetView; },
onRender: function() { onRender: function() {
@ -67,34 +67,34 @@ define([
onTextEditorBlur: function() { onTextEditorBlur: function() {
this.enableDragging(); this.enableDragging();
this.enableShowingTools(); this.enableShowingTools();
}, }
}); });
Module.HeaderBlockToolsView = base.BlockToolsView.extend({ Module.HeaderBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.HeaderBlockSettingsView; }, getSettingsView: function() { return Module.HeaderBlockSettingsView; }
}); });
Module.HeaderBlockSettingsView = base.BlockSettingsView.extend({ Module.HeaderBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.headerBlockSettings; }, getTemplate: function() { return templates.headerBlockSettings; },
events: function() { events: function() {
return { return {
"change .mailpoet_field_header_text_color": _.partial(this.changeColorField, "styles.text.fontColor"), '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_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
"change .mailpoet_field_header_text_size": _.partial(this.changeField, "styles.text.fontSize"), '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_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
"change #mailpoet_field_header_link_underline": function(event) { 'change #mailpoet_field_header_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none'); 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_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
"change .mailpoet_field_header_alignment": _.partial(this.changeField, "styles.text.textAlign"), 'change .mailpoet_field_header_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
templateContext: function() { templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(), availableStyles: App.getAvailableStyles().toJSON()
}); });
}, }
}); });
Module.HeaderWidgetView = base.WidgetView.extend({ Module.HeaderWidgetView = base.WidgetView.extend({
@ -104,21 +104,21 @@ define([
cloneOriginal: true, cloneOriginal: true,
drop: function() { drop: function() {
return new Module.HeaderBlockModel(); return new Module.HeaderBlockModel();
}, }
} }
}, }
}); });
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('header', { App.registerBlockType('header', {
blockModel: Module.HeaderBlockModel, blockModel: Module.HeaderBlockModel,
blockView: Module.HeaderBlockView, blockView: Module.HeaderBlockView
}); });
App.registerWidget({ App.registerWidget({
name: 'header', name: 'header',
widgetView: Module.HeaderWidgetView, widgetView: Module.HeaderWidgetView,
priority: 98, priority: 98
}); });
}); });

View File

@ -4,10 +4,11 @@
define([ define([
'newsletter_editor/App', 'newsletter_editor/App',
'newsletter_editor/blocks/base', 'newsletter_editor/blocks/base',
'underscore' 'underscore',
], function(App, BaseBlock, _) { 'mailpoet'
], function(App, BaseBlock, _, MailPoet) {
"use strict"; 'use strict';
var Module = {}, var Module = {},
base = BaseBlock, base = BaseBlock,
@ -25,24 +26,24 @@ define([
height: '64px', height: '64px',
styles: { styles: {
block: { block: {
textAlign: 'center', textAlign: 'center'
}, }
}, }
}, App.getConfig().get('blockDefaults.image')); }, App.getConfig().get('blockDefaults.image'));
}, }
}); });
Module.ImageBlockView = base.BlockView.extend({ Module.ImageBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_image_block mailpoet_droppable_block", className: 'mailpoet_block mailpoet_image_block mailpoet_droppable_block',
getTemplate: function() { return templates.imageBlock; }, getTemplate: function() { return templates.imageBlock; },
onDragSubstituteBy: function() { return Module.ImageWidgetView; }, onDragSubstituteBy: function() { return Module.ImageWidgetView; },
templateContext: function() { templateContext: function() {
return _.extend({ return _.extend({
imageMissingSrc: App.getConfig().get('urls.imageMissing'), imageMissingSrc: App.getConfig().get('urls.imageMissing')
}, base.BlockView.prototype.templateContext.apply(this)); }, base.BlockView.prototype.templateContext.apply(this));
}, },
behaviors: _.extend({}, base.BlockView.prototype.behaviors, { behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ShowSettingsBehavior: {}, ShowSettingsBehavior: {}
}), }),
onRender: function() { onRender: function() {
this.toolsView = new Module.ImageBlockToolsView({ model: this.model }); this.toolsView = new Module.ImageBlockToolsView({ model: this.model });
@ -53,24 +54,34 @@ define([
} else { } else {
this.$el.removeClass('mailpoet_full_image'); this.$el.removeClass('mailpoet_full_image');
} }
}, }
}); });
Module.ImageBlockToolsView = base.BlockToolsView.extend({ Module.ImageBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.ImageBlockSettingsView; }, getSettingsView: function() { return Module.ImageBlockSettingsView; }
}); });
Module.ImageBlockSettingsView = base.BlockSettingsView.extend({ Module.ImageBlockSettingsView = base.BlockSettingsView.extend({
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 templates.imageBlockSettings; }, getTemplate: function() { return templates.imageBlockSettings; },
events: function() { events: function() {
return { return {
"input .mailpoet_field_image_link": _.partial(this.changeField, "link"), 'input .mailpoet_field_image_link': _.partial(this.changeField, 'link'),
"input .mailpoet_field_image_address": 'changeAddress', 'input .mailpoet_field_image_address': 'changeAddress',
"input .mailpoet_field_image_alt_text": _.partial(this.changeField, "alt"), 'input .mailpoet_field_image_alt_text': _.partial(this.changeField, 'alt'),
"change .mailpoet_field_image_full_width": _.partial(this.changeBoolCheckboxField, "fullWidth"), 'change .mailpoet_field_image_full_width': _.partial(this.changeBoolCheckboxField, 'fullWidth'),
"change .mailpoet_field_image_alignment": _.partial(this.changeField, "styles.block.textAlign"), 'change .mailpoet_field_image_alignment': _.partial(this.changeField, 'styles.block.textAlign'),
"click .mailpoet_field_image_select_another_image": "showMediaManager", 'click .mailpoet_field_image_select_another_image': 'showMediaManager',
"click .mailpoet_done_editing": "close", 'click .mailpoet_done_editing': 'close'
}; };
}, },
initialize: function(options) { initialize: function(options) {
@ -141,7 +152,7 @@ define([
// Update user settings when users adjust the // Update user settings when users adjust the
// attachment display settings. // attachment display settings.
displayUserSettings: false displayUserSettings: false
}), })
]); ]);
if(wp.media.view.settings.post.featuredImageId) { if(wp.media.view.settings.post.featuredImageId) {
@ -166,7 +177,7 @@ define([
var handlers = { var handlers = {
content: { content: {
'embed': 'embedContent', embed: 'embedContent',
'edit-selection': 'editSelectionContent' 'edit-selection': 'editSelectionContent'
}, },
toolbar: { toolbar: {
@ -266,7 +277,8 @@ define([
}, },
mainEmbedToolbar: function(toolbar) { mainEmbedToolbar: function(toolbar) {
toolbar.view = new wp.media.view.Toolbar.Embed({ var tbar = toolbar;
tbar.view = new wp.media.view.Toolbar.Embed({
controller: this, controller: this,
text: 'Add images' text: 'Add images'
}); });
@ -274,7 +286,7 @@ define([
}); });
var theFrame = this._mediaManager = new MediaManager({ var theFrame = new MediaManager({
id: 'mailpoet-media-manager', id: 'mailpoet-media-manager',
frame: 'select', frame: 'select',
title: 'Select image', title: 'Select image',
@ -285,12 +297,13 @@ define([
}, },
displaySettings: false, displaySettings: false,
button: { button: {
text: 'Select', text: 'Select'
}, }
}), }),
that = this; that = this;
this._mediaManager = theFrame;
this._mediaManager.on('insert', function() { this._mediaManager.on('insert', function() {
// Append media manager image selections to Images tab // Append media manager image selections to Images tab
var selection = theFrame.state().get('selection'); var selection = theFrame.state().get('selection');
selection.each(function(attachment) { selection.each(function(attachment) {
@ -318,7 +331,7 @@ define([
height: mainSize.height + 'px', height: mainSize.height + 'px',
width: mainSize.width + 'px', width: mainSize.width + 'px',
src: mainSize.url, 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 // Rerender settings view due to changes from outside of settings view
that.render(); that.render();
@ -346,7 +359,7 @@ define([
if (typeof this._mediaManager === 'object') { if (typeof this._mediaManager === 'object') {
this._mediaManager.remove(); this._mediaManager.remove();
} }
}, }
}); });
ImageWidgetView = base.WidgetView.extend({ ImageWidgetView = base.WidgetView.extend({
@ -359,22 +372,22 @@ define([
}, },
onDrop: function(options) { onDrop: function(options) {
options.droppedView.triggerMethod('showSettings', { showImageManager: true }); options.droppedView.triggerMethod('showSettings', { showImageManager: true });
}, }
} }
}, }
}); });
Module.ImageWidgetView = ImageWidgetView; Module.ImageWidgetView = ImageWidgetView;
App.on('before:start', function(App, options) { App.on('before:start', function(App, options) {
App.registerBlockType('image', { App.registerBlockType('image', {
blockModel: Module.ImageBlockModel, blockModel: Module.ImageBlockModel,
blockView: Module.ImageBlockView, blockView: Module.ImageBlockView
}); });
App.registerWidget({ App.registerWidget({
name: 'image', name: 'image',
widgetView: Module.ImageWidgetView, widgetView: Module.ImageWidgetView,
priority: 91, priority: 91
}); });
}); });

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