Compare commits

...

255 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
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
563ca3e605 Switch ID fields from mediumint to int in DB [MAILPOET-1022] 2017-07-25 13:11:56 +03:00
5572a7f1e5 Prevent to override sending group
[MAILPOET-1024]
2017-07-25 08:32:10 +02:00
375 changed files with 9603 additions and 5743 deletions

View File

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

View File

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

View File

@ -11,9 +11,8 @@
}
},
"rules": {
"comma-dangle": ["error", "always-multiline"],
"import/no-amd": 0,
"react/no-multi-comp": 0,
"react/sort-comp": 0,
"react/jsx-max-props-per-line": 0,
@ -34,12 +33,9 @@
"react/jsx-curly-spacing": 0,
"react/no-did-mount-set-state": 0,
"react/prefer-stateless-function": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/alt-text": 0,
"comma-dangle": 0,
"func-names": 0,
"object-shorthand": 0,
"no-bitwise": 0,
@ -47,17 +43,14 @@
"prefer-template": 0,
"keyword-spacing": 0,
"default-case": 0,
"quote-props": 0,
"array-callback-return": 0,
"consistent-return": 0,
"no-unreachable": 0,
"no-extra-semi": 0,
"import/no-unresolved": 0,
"import/extensions": 0,
"import/no-extraneous-dependencies": 0,
"camelcase": 0,
"template-curly-spacing": 0,
"quotes": 0,
"eqeqeq": 0,
"no-lonely-if": 0,
"space-unary-ops": 0,
@ -66,20 +59,16 @@
"no-multi-spaces": 0,
"class-methods-use-this": 0,
"key-spacing": 0,
"no-multiple-empty-lines": 0,
"space-in-parens": 0,
"no-case-declarations": 0,
"array-bracket-spacing": 0,
"newline-per-chained-call": 0,
"no-else-return": 0,
"max-len": 0,
"comma-spacing": 0,
"no-useless-concat": 0,
"no-unused-expressions": 0,
"no-sequences": 0,
"no-extra-boolean-cast": 0,
"dot-notation": 0,
"no-param-reassign": 0,
"no-shadow": 0,
"one-var": 0,
"no-alert": 0,

View File

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

1
.gitignore vendored
View File

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

39
Dockerfile Normal file
View File

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

View File

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

View File

@ -154,9 +154,8 @@ class RoboFile extends \Robo\Tasks {
function testUnit($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$command = 'vendor/bin/codecept run unit -f '.(($opts['file']) ? $opts['file'] : '');
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml -f '.(($opts['file']) ? $opts['file'] : '');
if($opts['xml']) {
$command .= ' --xml';
@ -166,9 +165,8 @@ class RoboFile extends \Robo\Tasks {
function testCoverage($opts=['file' => null, 'xml' => false]) {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$command = join(' ', array(
'vendor/bin/codecept run',
'vendor/bin/codecept run unit -c codeception.unit.yml ',
(($opts['file']) ? $opts['file'] : ''),
'--coverage',
($opts['xml']) ? '--coverage-xml' : '--coverage-html'
@ -199,16 +197,26 @@ class RoboFile extends \Robo\Tasks {
return $this->_exec($command);
}
function testDebug() {
$this->_exec('vendor/bin/codecept build');
function testDebug($opts=['file' => null, 'xml' => false]) {
$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() {
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
return $this->_exec('vendor/bin/codecept run -g failed');
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
return $this->_exec('vendor/bin/codecept run -c codeception.unit.yml -g failed');
}
function qa() {
@ -239,6 +247,7 @@ class RoboFile extends \Robo\Tasks {
->taskExec(
'./vendor/bin/phpcs '.
'--standard=./tasks/code_sniffer/MailPoet '.
'--runtime-set testVersion 5.3-7.0 '.
'--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'.
'./lib/Util/pQuery/*,./lib/Config/PopulatorData/Templates/* '.
'lib/ '.
@ -246,7 +255,8 @@ class RoboFile extends \Robo\Tasks {
)
->taskExec(
'./vendor/bin/phpcs '.
'--standard=./tasks/code_sniffer/MailPoetTests '.
'--standard=./tasks/code_sniffer/MailPoet '.
'--runtime-set testVersion 5.4-7.0 '.
'--ignore=./tests/unit/_bootstrap.php '.
'tests/unit/ '.
$severityFlag
@ -284,8 +294,9 @@ class RoboFile extends \Robo\Tasks {
$plugin_data = get_plugin_data('mailpoet.php', false, false);
$plugin_version = $plugin_data['Version'];
$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';
$this->say('Publishing version: ' . $plugin_version);
// Sanity checks
@ -413,4 +424,4 @@ class RoboFile extends \Robo\Tasks {
require_once(ABSPATH . WPINC . '/plugin.php');
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 814 B

View File

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

View File

@ -2,7 +2,7 @@ function requestFailed(errorMessage, xhr) {
if (xhr.responseJSON) {
return xhr.responseJSON;
}
var message = errorMessage.replace("%d", xhr.status);
var message = errorMessage.replace('%d', xhr.status);
return {
errors: [
{
@ -12,7 +12,8 @@ function requestFailed(errorMessage, xhr) {
};
}
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(mp, jQuery, _) {
var MailPoet = mp;
MailPoet.Ajax = {
version: 0.5,

View File

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

View File

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

View File

@ -1,5 +1,5 @@
define([
'react'
'react',
],
(
React
@ -42,7 +42,7 @@ define([
{ options }
</div>
);
}
},
});
return FormFieldCheckbox;

View File

@ -104,7 +104,7 @@ define([
this.state = {
year: '',
month: '',
day: ''
day: '',
};
}
componentDidMount() {
@ -132,7 +132,7 @@ define([
this.setState({
year: dateTime.format('YYYY'),
month: dateTime.format('M'),
day: dateTime.format('D')
day: dateTime.format('D'),
});
}
formatValue() {
@ -143,28 +143,28 @@ define([
switch(dateType) {
case 'year_month_day':
value = {
'year': this.state.year,
'month': this.state.month,
'day': this.state.day
year: this.state.year,
month: this.state.month,
day: this.state.day,
};
break;
case 'year_month':
value = {
'year': this.state.year,
'month': this.state.month
year: this.state.year,
month: this.state.month,
};
break;
case 'month':
value = {
'month': this.state.month
month: this.state.month,
};
break;
case 'year':
value = {
'year': this.state.year
year: this.state.year,
};
break;
}
@ -184,13 +184,13 @@ define([
const value = ~~(e.target.value);
this.setState({
[`${property}`]: value
[`${property}`]: value,
}, () => {
this.props.onValueChange({
target: {
name: field,
value: this.formatValue()
}
value: this.formatValue(),
},
});
});
}
@ -245,7 +245,7 @@ define([
</div>
);
}
};
}
return FormFieldDate;
});

View File

@ -28,12 +28,13 @@ define([
}
let field = false;
let dataField = data.field;
if(data.field['field'] !== undefined) {
data.field = jQuery.merge(data.field, data.field.field);
dataField = jQuery.merge(dataField, data.field.field);
}
switch(data.field.type) {
switch(dataField.type) {
case 'text':
field = (<FormFieldText {...data} />);
break;
@ -92,7 +93,7 @@ define([
index: index,
field: subfield,
item: this.props.item,
onValueChange: this.props.onValueChange || false
onValueChange: this.props.onValueChange || false,
});
});
} else {
@ -121,7 +122,7 @@ define([
</td>
</tr>
);
}
},
});
return FormField;

View File

@ -1,5 +1,5 @@
define([
'react'
'react',
],
(
React
@ -34,7 +34,7 @@ define([
{ options }
</div>
);
}
},
});
return FormFieldRadio;

View File

@ -70,7 +70,7 @@ const FormFieldSelect = React.createClass({
{options}
</select>
);
}
},
});
module.exports = FormFieldSelect;

View File

@ -2,7 +2,7 @@ define([
'react',
'react-dom',
'jquery',
'select2'
'select2',
],
(
React,
@ -13,7 +13,7 @@ define([
getInitialState: function () {
return {
items: [],
select2: false
select2: false,
};
},
componentWillMount: function () {
@ -67,7 +67,7 @@ define([
return item.text;
}
}
}
},
});
let hasRemoved = false;
@ -111,7 +111,7 @@ define([
}
this.setState({
items: items
items: items,
});
}
},
@ -126,8 +126,8 @@ define([
this.props.onValueChange({
target: {
value: transformedValue,
name: this.props.field.name
}
name: this.props.field.name,
},
});
}
},
@ -180,13 +180,14 @@ define([
<select
id={ this.props.field.id || this.props.field.name }
ref="select"
disabled={this.props.field.disabled}
data-placeholder={ this.props.field.placeholder }
multiple={ this.props.field.multiple }
defaultValue={ this.getSelectedValues() }
{...this.props.field.validation}
>{ options }</select>
);
}
},
});
return Selection;

View File

@ -29,7 +29,7 @@ const FormFieldText = React.createClass({
{...this.props.field.validation}
/>
);
}
},
});
module.exports = FormFieldText;

View File

@ -1,5 +1,5 @@
define([
'react'
'react',
],
(
React
@ -19,7 +19,7 @@ define([
{...this.props.field.validation}
/>
);
}
},
});
return FormFieldTextarea;

View File

@ -4,7 +4,7 @@ define(
'mailpoet',
'classnames',
'react-router',
'form/fields/field.jsx'
'form/fields/field.jsx',
],
(
React,
@ -16,7 +16,7 @@ define(
const Form = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: React.PropTypes.object.isRequired,
},
getDefaultProps: function () {
return {
@ -27,7 +27,7 @@ define(
return {
loading: false,
errors: [],
item: {}
item: {},
};
},
getValues: function () {
@ -42,7 +42,7 @@ define(
this.loadItem(this.props.params.id);
} else {
this.setState({
item: jQuery('.mailpoet_form').serializeObject()
item: jQuery('.mailpoet_form').serializeObject(),
});
}
}
@ -51,7 +51,7 @@ define(
if(props.params.id === undefined) {
this.setState({
loading: false,
item: {}
item: {},
});
if (props.item === undefined) {
this.refs.form.reset();
@ -68,17 +68,17 @@ define(
endpoint: this.props.endpoint,
action: 'get',
data: {
id: id
}
id: id,
},
}).done((response) => {
this.setState({
loading: false,
item: response.data
item: response.data,
});
}).fail(() => {
this.setState({
loading: false,
item: {}
item: {},
}, function () {
this.context.router.push('/new');
});
@ -116,7 +116,7 @@ define(
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'save',
data: item
data: item,
}).always(() => {
this.setState({ loading: false });
}).done(() => {
@ -147,7 +147,7 @@ define(
item[field] = e.target.value;
this.setState({
item: item
item: item,
});
return true;
}
@ -166,7 +166,7 @@ define(
const formClasses = classNames(
'mailpoet_form',
{ 'mailpoet_form_loading': this.state.loading || this.props.loading }
{ mailpoet_form_loading: this.state.loading || this.props.loading }
);
let beforeFormContent = false;
@ -238,7 +238,7 @@ define(
{ afterFormContent }
</div>
);
}
},
});
return Form;

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ const history = useRouterHistory(createHashHistory)({ queryKey: false });
const App = React.createClass({
render() {
return this.props.children;
}
},
});
const container = document.getElementById('forms_container');

View File

@ -7,21 +7,21 @@ const columns = [
{
name: 'name',
label: MailPoet.I18n.t('formName'),
sortable: true
sortable: true,
},
{
name: 'segments',
label: MailPoet.I18n.t('segments')
label: MailPoet.I18n.t('segments'),
},
{
name: 'signups',
label: MailPoet.I18n.t('signups')
label: MailPoet.I18n.t('signups'),
},
{
name: 'created_at',
label: MailPoet.I18n.t('createdOn'),
sortable: true
}
sortable: true,
},
];
const messages = {
@ -69,15 +69,15 @@ const messages = {
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
},
};
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
onSuccess: messages.onTrash,
},
];
const item_actions = [
@ -88,7 +88,7 @@ const item_actions = [
return (
<a href={ `admin.php?page=mailpoet-form-editor&id=${item.id}` }>{MailPoet.I18n.t('edit')}</a>
);
}
},
},
{
name: 'duplicate',
@ -99,8 +99,8 @@ const item_actions = [
endpoint: 'forms',
action: 'duplicate',
data: {
id: item.id
}
id: item.id,
},
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name)
@ -114,11 +114,11 @@ const item_actions = [
);
}
});
}
},
},
{
name: 'trash'
}
name: 'trash',
},
];
const FormList = React.createClass({
@ -126,7 +126,7 @@ const FormList = React.createClass({
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',
action: 'create'
action: 'create',
}).done((response) => {
window.location = mailpoet_form_edit_url + response.data.id;
}).fail((response) => {
@ -203,7 +203,7 @@ const FormList = React.createClass({
/>
</div>
);
}
},
});
module.exports = FormList;

View File

@ -5,7 +5,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
output = '';
for(var i = 0; i < size; i++) {
output += arguments[i];
};
}
return output;
});
@ -19,7 +19,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
}
// set date format
var f = block.hash.format || "MMM Do, YYYY";
var f = block.hash.format || 'MMM Do, YYYY';
// check if we passed a timestamp
if(parseInt(timestamp, 10) == timestamp) {
return moment.unix(timestamp).format(f);
@ -28,7 +28,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
}
} else {
return timestamp;
};
}
});
Handlebars.registerHelper('cycle', function(value, block) {
@ -67,7 +67,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
});
Handlebars.registerHelper('nl2br', function(value, block) {
return value.gsub("\n", "<br />");
return value.gsub('\n', '<br />');
});
Handlebars.registerHelper('json_encode', function(value, block) {
@ -78,7 +78,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
return JSON.parse(value);
});
Handlebars.registerHelper('url', function(value, block) {
var url = window.location.protocol + "//" + window.location.host + window.location.pathname;
var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
return url + value;
});
@ -99,7 +99,7 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
// extract all lines into an array
if(value === undefined) return '';
var lines = value.trim().split("\n");
var lines = value.trim().split('\n');
// remove header & footer
lines.shift();
@ -125,12 +125,13 @@ define('handlebars_helpers', ['handlebars'], function(Handlebars) {
* @return {String} The truncated string.
*/
Handlebars.registerHelper('ellipsis', function (str, limit, append) {
if (append === undefined) {
append = '';
var strAppend = append;
if (strAppend === undefined) {
strAppend = '';
}
var sanitized = str.replace(/(<([^>]+)>)/g, '');
if (sanitized.length > limit) {
return sanitized.substr(0, limit - append.length) + append;
return sanitized.substr(0, limit - strAppend.length) + strAppend;
} else {
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 'Georgia': return new Handlebars.SafeString("Georgia, Times, 'Times New Roman', serif");
case 'Lucida': return new Handlebars.SafeString("'Lucida Sans Unicode', 'Lucida Grande', sans-serif");
case 'Tahoma': return new Handlebars.SafeString("Tahoma, Verdana, Segoe, sans-serif");
case 'Tahoma': return new Handlebars.SafeString('Tahoma, Verdana, Segoe, sans-serif');
case 'Times New Roman': return new Handlebars.SafeString("'Times New Roman', Times, Baskerville, Georgia, serif");
case 'Trebuchet MS': return new Handlebars.SafeString("'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif");
case 'Verdana': return new Handlebars.SafeString("Verdana, Geneva, sans-serif");
case 'Verdana': return new Handlebars.SafeString('Verdana, Geneva, sans-serif');
default: return font;
}
});

View File

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

View File

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

View File

@ -11,7 +11,7 @@ const history = useRouterHistory(createHashHistory)({ queryKey: false });
const App = React.createClass({
render() {
return this.props.children;
}
},
});
const container = document.getElementById('help_container');

View File

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

View File

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

View File

@ -7,12 +7,12 @@ const tabs = [
{
name: 'knowledgeBase',
label: MailPoet.I18n.t('tabKnowledgeBaseTitle'),
link: '/knowledgeBase'
link: '/knowledgeBase',
},
{
name: 'systemInfo',
label: MailPoet.I18n.t('tabSystemInfoTitle'),
link: '/systemInfo'
link: '/systemInfo',
},
];
@ -38,9 +38,9 @@ function Tabs(props) {
{ tabLinks }
</h2>
);
};
}
Tabs.propTypes = { tab: React.PropTypes.string };
Tabs.defaultProps = { tab: "knowledgeBase" };
Tabs.defaultProps = { tab: 'knowledgeBase' };
module.exports = Tabs;

View File

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

View File

@ -2,10 +2,12 @@ define('i18n',
[
'mailpoet'
], function(
MailPoet
mp
) {
'use strict';
var MailPoet = mp;
var translations = {};
MailPoet.I18n = {
@ -13,7 +15,7 @@ define('i18n',
translations[key] = value;
},
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() {
return translations;

View File

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

View File

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

View File

@ -1,6 +1,6 @@
define([
'react',
'mailpoet'
'mailpoet',
],
(
React,
@ -10,20 +10,20 @@ define([
getInitialState: function () {
return {
action: false,
extra: false
extra: false,
};
},
handleChangeAction: function (e) {
this.setState({
action: e.target.value,
extra: false
extra: false,
}, () => {
const action = this.getSelectedAction();
// action on select callback
if(action !== null && action['onSelect'] !== undefined) {
this.setState({
extra: action.onSelect(e)
extra: action.onSelect(e),
});
}
});
@ -56,12 +56,12 @@ define([
const promise = this.props.onBulkAction(selected_ids, data);
if (promise !== false) {
promise.then(onSuccess);
};
}
}
this.setState({
action: false,
extra: false
extra: false,
});
},
getSelectedAction: function () {
@ -115,7 +115,7 @@ define([
{ this.state.extra }
</div>
);
}
},
});
return ListingBulkActions;

View File

@ -1,7 +1,7 @@
define([
'react',
'jquery',
'mailpoet'
'mailpoet',
],
(
React,
@ -100,7 +100,7 @@ define([
{ empty_trash }
</div>
);
}
},
});
return ListingFilters;

View File

@ -11,7 +11,7 @@ define(['react', 'classnames'], (React, classNames) => {
}
const classes = classNames(
{ 'current' : (group.name === this.props.group) }
{ current : (group.name === this.props.group) }
);
return (
@ -32,7 +32,7 @@ define(['react', 'classnames'], (React, classNames) => {
{ groups }
</ul>
);
}
},
});
return ListingGroups;

View File

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

View File

@ -14,7 +14,7 @@ import ListingFilters from 'listing/filters.jsx';
const ListingItem = React.createClass({
getInitialState: function () {
return {
expanded: false
expanded: false,
};
},
handleSelectItem: function (e) {
@ -191,7 +191,7 @@ const ListingItem = React.createClass({
{ this.props.onRenderItem(this.props.item, actions) }
</tr>
);
}
},
});
@ -226,10 +226,10 @@ const ListingItems = React.createClass({
} else {
const select_all_classes = classNames(
'mailpoet_select_all',
{ 'mailpoet_hidden': (
{ mailpoet_hidden: (
this.props.selection === false
|| (this.props.count <= this.props.limit)
)
),
}
);
@ -260,8 +260,9 @@ const ListingItems = React.createClass({
</tr>
{this.props.items.map((item, index) => {
item.id = parseInt(item.id, 10);
item.selected = (this.props.selected_ids.indexOf(item.id) !== -1);
const renderItem = item;
renderItem.id = parseInt(item.id, 10);
renderItem.selected = (this.props.selected_ids.indexOf(renderItem.id) !== -1);
return (
<ListingItem
@ -276,19 +277,19 @@ const ListingItems = React.createClass({
is_selectable={ this.props.is_selectable }
item_actions={ this.props.item_actions }
group={ this.props.group }
key={ `item-${item.id}-${index}` }
item={ item } />
key={ `item-${renderItem.id}-${index}` }
item={ renderItem } />
);
})}
</tbody>
);
}
}
},
});
const Listing = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: React.PropTypes.object.isRequired,
},
getInitialState: function () {
return {
@ -306,7 +307,7 @@ const Listing = React.createClass({
filter: {},
selected_ids: [],
selection: false,
meta: {}
meta: {},
};
},
getParam: function (param) {
@ -378,7 +379,7 @@ const Listing = React.createClass({
'search',
'page',
'sort_by',
'sort_order'
'sort_order',
].indexOf(key) !== -1
);
})
@ -418,16 +419,17 @@ const Listing = React.createClass({
}
},
setBaseUrlParams: function (base_url) {
if (base_url.indexOf(':') !== -1) {
let ret = base_url;
if (ret.indexOf(':') !== -1) {
const params = this.getParams();
Object.keys(params).map((key) => {
if (base_url.indexOf(':'+key) !== -1) {
base_url = base_url.replace(':'+key, params[key]);
if (ret.indexOf(':'+key) !== -1) {
ret = ret.replace(':'+key, params[key]);
}
});
}
return base_url;
return ret;
},
componentDidMount: function () {
if (this.isMounted()) {
@ -463,8 +465,8 @@ const Listing = React.createClass({
filter: this.state.filter,
search: this.state.search,
sort_by: this.state.sort_by,
sort_order: this.state.sort_order
}
sort_order: this.state.sort_order,
},
}).always(() => {
this.setState({ loading: false });
}).done((response) => {
@ -473,7 +475,7 @@ const Listing = React.createClass({
filters: response.meta.filters || {},
groups: response.meta.groups || [],
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 (this.state.group === 'trash' && response.meta.count === 0) {
@ -499,7 +501,7 @@ const Listing = React.createClass({
handleRestoreItem: function (id) {
this.setState({
loading: true,
page: 1
page: 1,
});
MailPoet.Ajax.post({
@ -507,8 +509,8 @@ const Listing = React.createClass({
endpoint: this.props.endpoint,
action: 'restore',
data: {
id: id
}
id: id,
},
}).done((response) => {
if (
this.props.messages !== undefined
@ -527,7 +529,7 @@ const Listing = React.createClass({
handleTrashItem: function (id) {
this.setState({
loading: true,
page: 1
page: 1,
});
MailPoet.Ajax.post({
@ -535,8 +537,8 @@ const Listing = React.createClass({
endpoint: this.props.endpoint,
action: 'trash',
data: {
id: id
}
id: id,
},
}).done((response) => {
if (
this.props.messages !== undefined
@ -555,7 +557,7 @@ const Listing = React.createClass({
handleDeleteItem: function (id) {
this.setState({
loading: true,
page: 1
page: 1,
});
MailPoet.Ajax.post({
@ -563,8 +565,8 @@ const Listing = React.createClass({
endpoint: this.props.endpoint,
action: 'delete',
data: {
id: id
}
id: id,
},
}).done((response) => {
if (
this.props.messages !== undefined
@ -583,7 +585,7 @@ const Listing = React.createClass({
handleEmptyTrash: function () {
return this.handleBulkAction('all', {
action: 'delete',
group: 'trash'
group: 'trash',
}).done((response) => {
MailPoet.Notice.success(
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response.meta.count)
@ -615,7 +617,7 @@ const Listing = React.createClass({
limit: 0,
filter: this.state.filter,
group: this.state.group,
search: this.state.search
search: this.state.search,
};
if (selected_ids !== 'all') {
data.listing.selection = selected_ids;
@ -625,7 +627,7 @@ const Listing = React.createClass({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'bulkAction',
data: data
data: data,
}).done(() => {
this.getItems();
}).fail((response) => {
@ -642,7 +644,7 @@ const Listing = React.createClass({
search: search,
page: 1,
selection: false,
selected_ids: []
selected_ids: [],
}, () => {
this.setParams();
});
@ -673,7 +675,7 @@ const Listing = React.createClass({
this.setState({
selection: selection,
selected_ids: selected_ids
selected_ids: selected_ids,
});
},
handleSelectItems: function (is_checked) {
@ -686,7 +688,7 @@ const Listing = React.createClass({
this.setState({
selected_ids: selected_ids,
selection: 'page'
selection: 'page',
});
}
},
@ -696,20 +698,20 @@ const Listing = React.createClass({
} else {
this.setState({
selection: 'all',
selected_ids: []
selected_ids: [],
});
}
},
clearSelection: function () {
this.setState({
selection: false,
selected_ids: []
selected_ids: [],
});
},
handleFilter: function (filters) {
this.setState({
filter: filters,
page: 1
page: 1,
}, () => {
this.setParams();
});
@ -722,7 +724,7 @@ const Listing = React.createClass({
group: group,
filter: {},
search: '',
page: 1
page: 1,
}, () => {
this.setParams();
});
@ -731,7 +733,7 @@ const Listing = React.createClass({
this.setState({
page: page,
selection: false,
selected_ids: []
selected_ids: [],
}, () => {
this.setParams();
});
@ -762,13 +764,13 @@ const Listing = React.createClass({
{
name: 'restore',
label: MailPoet.I18n.t('restore'),
onSuccess: this.props.messages.onRestore
onSuccess: this.props.messages.onRestore,
},
{
name: 'delete',
label: MailPoet.I18n.t('deletePermanently'),
onSuccess: this.props.messages.onDelete
}
onSuccess: this.props.messages.onDelete,
},
];
}
@ -781,7 +783,7 @@ const Listing = React.createClass({
'widefat',
'fixed',
'striped',
{ 'mailpoet_listing_loading': this.state.loading }
{ mailpoet_listing_loading: this.state.loading }
);
// search
@ -897,7 +899,7 @@ const Listing = React.createClass({
</div>
</div>
);
}
},
});
module.exports = Listing;

View File

@ -1,7 +1,7 @@
define([
'react',
'classnames',
'mailpoet'
'mailpoet',
], (
React,
classNames,
@ -11,12 +11,12 @@ define([
const ListingPages = React.createClass({
getInitialState: function () {
return {
page: null
page: null,
};
},
setPage: function (page) {
this.setState({
page: null
page: null,
}, () => {
this.props.onSetPage(this.constrainPage(page));
});
@ -47,7 +47,7 @@ define([
},
handleChangeManualPage: function (e) {
this.setState({
page: e.target.value
page: e.target.value,
});
},
handleBlurManualPage: function (e) {
@ -178,7 +178,7 @@ define([
</div>
);
}
}
},
});
return ListingPages;

View File

@ -1,6 +1,6 @@
define([
'mailpoet',
'react'
'react',
], (
MailPoet,
React
@ -40,7 +40,7 @@ define([
</form>
);
}
}
},
});
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';
var MailPoet = mp;
MailPoet.MP2Migrator = {
fatal_error: '',
@ -10,7 +12,7 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
clearTimeout(MailPoet.MP2Migrator.displayLogs_timeout);
clearTimeout(MailPoet.MP2Migrator.updateProgressbar_timeout);
clearTimeout(MailPoet.MP2Migrator.update_wordpress_info_timeout);
setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000)
setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000);
},
stopLogger: function () {
@ -27,8 +29,9 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
url: mailpoet_mp2_migrator.log_file_url,
cache: false
}).done(function (result) {
jQuery("#logger").html('');
result.split("\n").forEach(function (row) {
jQuery('#logger').html('');
result.split('\n').forEach(function (resultRow) {
var row = resultRow;
if(row.substr(0, 7) === '[ERROR]' || row.substr(0, 9) === '[WARNING]' || row === MailPoet.I18n.t('import_stopped_by_user')) {
row = '<span class="error_msg">' + row + '</span>'; // Mark the errors in red
}
@ -37,10 +40,10 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
jQuery('#import-actions').hide();
jQuery('#upgrade-completed').show();
}
jQuery("#logger").append(row + "<br />\n");
jQuery('#logger').append(row + '<br />\n');
});
jQuery("#logger").append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + "<br />\n");
jQuery('#logger').append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + '<br />\n');
}).always(function () {
if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
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>',
styles: {
block: {
backgroundColor: 'transparent',
backgroundColor: 'transparent'
},
text: {
fontColor: '#000000',
fontFamily: 'Arial',
fontSize: '12px',
textAlign: 'center',
textAlign: 'center'
},
link: {
fontColor: '#0000ff',
textDecoration: 'none',
},
},
textDecoration: 'none'
}
}
}, App.getConfig().get('blockDefaults.footer'));
},
}
});
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; },
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')),
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
TextEditorBehavior: {
configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, {
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; },
onRender: function() {
@ -67,34 +67,34 @@ define([
onTextEditorBlur: function() {
this.enableDragging();
this.enableShowingTools();
},
}
});
Module.FooterBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.FooterBlockSettingsView; },
getSettingsView: function() { return Module.FooterBlockSettingsView; }
});
Module.FooterBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.footerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_footer_text_color": _.partial(this.changeColorField, "styles.text.fontColor"),
"change .mailpoet_field_footer_text_font_family": _.partial(this.changeField, "styles.text.fontFamily"),
"change .mailpoet_field_footer_text_size": _.partial(this.changeField, "styles.text.fontSize"),
"change #mailpoet_field_footer_link_color": _.partial(this.changeColorField, "styles.link.fontColor"),
"change #mailpoet_field_footer_link_underline": function(event) {
'change .mailpoet_field_footer_text_color': _.partial(this.changeColorField, 'styles.text.fontColor'),
'change .mailpoet_field_footer_text_font_family': _.partial(this.changeField, 'styles.text.fontFamily'),
'change .mailpoet_field_footer_text_size': _.partial(this.changeField, 'styles.text.fontSize'),
'change #mailpoet_field_footer_link_color': _.partial(this.changeColorField, 'styles.link.fontColor'),
'change #mailpoet_field_footer_link_underline': function(event) {
this.model.set('styles.link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change .mailpoet_field_footer_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"change .mailpoet_field_footer_alignment": _.partial(this.changeField, "styles.text.textAlign"),
"click .mailpoet_done_editing": "close",
'change .mailpoet_field_footer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'change .mailpoet_field_footer_alignment': _.partial(this.changeField, 'styles.text.textAlign'),
'click .mailpoet_done_editing': 'close'
};
},
templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(),
availableStyles: App.getAvailableStyles().toJSON()
});
},
}
});
Module.FooterWidgetView = base.WidgetView.extend({
@ -104,21 +104,21 @@ define([
cloneOriginal: true,
drop: function() {
return new Module.FooterBlockModel();
},
}
}
},
}
});
App.on('before:start', function(App, options) {
App.registerBlockType('footer', {
blockModel: Module.FooterBlockModel,
blockView: Module.FooterBlockView,
blockView: Module.FooterBlockView
});
App.registerWidget({
name: 'footer',
widgetView: Module.FooterWidgetView,
priority: 99,
priority: 99
});
});

View File

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

View File

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

View File

@ -37,7 +37,7 @@ define([
DividerBlock
) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -76,7 +76,7 @@ define([
divider: {},
_selectedPosts: [],
_availablePosts: [],
_transformedPosts: new (App.getBlockTypeModel('container'))(),
_transformedPosts: new (App.getBlockTypeModel('container'))()
}, App.getConfig().get('blockDefaults.posts'));
},
relations: function() {
@ -85,7 +85,7 @@ define([
divider: App.getBlockTypeModel('divider'),
_selectedPosts: Backbone.Collection,
_availablePosts: Backbone.Collection,
_transformedPosts: App.getBlockTypeModel('container'),
_transformedPosts: App.getBlockTypeModel('container')
};
},
initialize: function() {
@ -172,15 +172,15 @@ define([
}).fail(function() {
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
});
},
}
});
Module.PostsBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_posts_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_posts_block mailpoet_droppable_block',
getTemplate: function() { return templates.postsBlock; },
modelEvents: {}, // Forcefully disable all events
regions: _.extend({
postsRegion: '.mailpoet_posts_block_posts',
postsRegion: '.mailpoet_posts_block_posts'
}, base.BlockView.prototype.regions),
onDragSubstituteBy: function() { return Module.PostsWidgetView; },
initialize: function() {
@ -199,7 +199,7 @@ define([
renderOptions = {
disableTextEditor: true,
disableDragAndDrop: true,
emptyContainerMessage: MailPoet.I18n.t('noPostsToDisplay'),
emptyContainerMessage: MailPoet.I18n.t('noPostsToDisplay')
};
this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_transformedPosts'), renderOptions: renderOptions }));
},
@ -208,27 +208,27 @@ define([
},
onBeforeDestroy: function() {
this.model.stopReplying('blockView', this.notifyAboutSelf, this);
},
}
});
Module.PostsBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.PostsBlockSettingsView; },
getSettingsView: function() { return Module.PostsBlockSettingsView; }
});
Module.PostsBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.postsBlockSettings; },
regions: {
selectionRegion: '.mailpoet_settings_posts_selection',
displayOptionsRegion: '.mailpoet_settings_posts_display_options',
displayOptionsRegion: '.mailpoet_settings_posts_display_options'
},
events: {
'click .mailpoet_settings_posts_show_display_options': 'switchToDisplayOptions',
'click .mailpoet_settings_posts_show_post_selection': 'switchToPostSelection',
'click .mailpoet_settings_posts_insert_selected': 'insertPosts',
'click .mailpoet_settings_posts_insert_selected': 'insertPosts'
},
templateContext: function() {
return {
model: this.model.toJSON(),
model: this.model.toJSON()
};
},
initialize: function() {
@ -251,7 +251,7 @@ define([
onCancel: function() {
// Self destroy the block if the user closes settings modal
that.model.destroy();
},
}
});
// Inform child views that they have been attached to document
@ -280,7 +280,7 @@ define([
this.model.trigger('insertSelectedPosts');
this.model.destroy();
this.close();
},
}
});
var PostsSelectionCollectionView = Marionette.CollectionView.extend({
@ -289,14 +289,14 @@ define([
emptyView: function() { return EmptyPostSelectionSettingsView; },
childViewOptions: function() {
return {
blockModel: this.blockModel,
blockModel: this.blockModel
};
},
initialize: function(options) {
this.blockModel = options.blockModel;
},
events: {
'scroll': 'onPostsScroll',
scroll: 'onPostsScroll'
},
onPostsScroll: function(event) {
var $postsBox = jQuery(event.target);
@ -304,19 +304,19 @@ define([
// Load more posts if scrolled to bottom
this.blockModel.trigger('loadMorePosts');
}
},
}
});
var PostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.postSelectionPostsBlockSettings; },
regions: {
posts: '.mailpoet_post_selection_container',
posts: '.mailpoet_post_selection_container'
},
events: function() {
return {
'change .mailpoet_settings_posts_content_type': _.partial(this.changeField, 'contentType'),
'change .mailpoet_posts_post_status': _.partial(this.changeField, 'postStatus'),
'input .mailpoet_posts_search_term': _.partial(this.changeField, 'search'),
'input .mailpoet_posts_search_term': _.partial(this.changeField, 'search')
};
},
modelEvents: {
@ -326,10 +326,10 @@ define([
this.$('.mailpoet_post_scroll_container').scrollTop(0);
}
},
'loadingMorePosts': function() {
loadingMorePosts: function() {
this.$('.mailpoet_post_selection_loading').css('visibility', 'visible');
},
'morePostsLoaded': function() {
morePostsLoaded: function() {
this.$('.mailpoet_post_selection_loading').css('visibility', 'hidden');
}
},
@ -392,8 +392,8 @@ define([
}
)
};
},
},
}
}
}).on({
'select2:select': function(event) {
var terms = that.model.get('terms');
@ -406,7 +406,7 @@ define([
terms.remove(event.params.data);
// Reset whole model in order for change events to propagate properly
that.model.set('terms', terms.toJSON());
},
}
}).trigger( 'change' );
},
changeField: function(field, event) {
@ -420,28 +420,28 @@ define([
_.each(postTypes, function(type) {
select.append(jQuery('<option>', {
value: type.name,
text: type.label,
text: type.label
}));
});
select.val(selectedValue);
},
}
});
var EmptyPostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.emptyPostPostsBlockSettings; },
getTemplate: function() { return templates.emptyPostPostsBlockSettings; }
});
var SinglePostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.singlePostPostsBlockSettings; },
events: function() {
return {
'change .mailpoet_select_post_checkbox': 'postSelectionChange',
'change .mailpoet_select_post_checkbox': 'postSelectionChange'
};
},
templateContext: function() {
return {
model: this.model.toJSON(),
index: this._index,
index: this._index
};
},
initialize: function(options) {
@ -455,37 +455,37 @@ define([
} else {
selectedPostsCollection.remove(this.model);
}
},
}
});
var PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.displayOptionsPostsBlockSettings; },
events: function() {
return {
"click .mailpoet_posts_select_button": 'showButtonSettings',
"click .mailpoet_posts_select_divider": 'showDividerSettings',
"change .mailpoet_posts_read_more_type": 'changeReadMoreType',
"change .mailpoet_posts_display_type": 'changeDisplayType',
"change .mailpoet_posts_title_format": 'changeTitleFormat',
"change .mailpoet_posts_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
"change .mailpoet_posts_show_divider": _.partial(this.changeBoolField, 'showDivider'),
"input .mailpoet_posts_show_amount": _.partial(this.changeField, "amount"),
"change .mailpoet_posts_content_type": _.partial(this.changeField, "contentType"),
"change .mailpoet_posts_include_or_exclude": _.partial(this.changeField, "inclusionType"),
"change .mailpoet_posts_title_alignment": _.partial(this.changeField, "titleAlignment"),
"change .mailpoet_posts_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
"change .mailpoet_posts_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
"change .mailpoet_posts_show_author": _.partial(this.changeField, "showAuthor"),
"input .mailpoet_posts_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
"change .mailpoet_posts_show_categories": _.partial(this.changeField, "showCategories"),
"input .mailpoet_posts_categories": _.partial(this.changeField, "categoriesPrecededBy"),
"input .mailpoet_posts_read_more_text": _.partial(this.changeField, "readMoreText"),
"change .mailpoet_posts_sort_by": _.partial(this.changeField, "sortBy"),
'click .mailpoet_posts_select_button': 'showButtonSettings',
'click .mailpoet_posts_select_divider': 'showDividerSettings',
'change .mailpoet_posts_read_more_type': 'changeReadMoreType',
'change .mailpoet_posts_display_type': 'changeDisplayType',
'change .mailpoet_posts_title_format': 'changeTitleFormat',
'change .mailpoet_posts_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'),
'change .mailpoet_posts_show_divider': _.partial(this.changeBoolField, 'showDivider'),
'input .mailpoet_posts_show_amount': _.partial(this.changeField, 'amount'),
'change .mailpoet_posts_content_type': _.partial(this.changeField, 'contentType'),
'change .mailpoet_posts_include_or_exclude': _.partial(this.changeField, 'inclusionType'),
'change .mailpoet_posts_title_alignment': _.partial(this.changeField, 'titleAlignment'),
'change .mailpoet_posts_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'),
'change .mailpoet_posts_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'),
'change .mailpoet_posts_show_author': _.partial(this.changeField, 'showAuthor'),
'input .mailpoet_posts_author_preceded_by': _.partial(this.changeField, 'authorPrecededBy'),
'change .mailpoet_posts_show_categories': _.partial(this.changeField, 'showCategories'),
'input .mailpoet_posts_categories': _.partial(this.changeField, 'categoriesPrecededBy'),
'input .mailpoet_posts_read_more_text': _.partial(this.changeField, 'readMoreText'),
'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy')
};
},
templateContext: function() {
return {
model: this.model.toJSON(),
model: this.model.toJSON()
};
},
showButtonSettings: function(event) {
@ -495,8 +495,8 @@ define([
renderOptions: {
displayFormat: 'subpanel',
hideLink: true,
hideApplyToAll: true,
},
hideApplyToAll: true
}
})).render();
},
showDividerSettings: function(event) {
@ -505,8 +505,8 @@ define([
model: this.model.get('divider'),
renderOptions: {
displayFormat: 'subpanel',
hideApplyToAll: true,
},
hideApplyToAll: true
}
})).render();
},
changeReadMoreType: function(event) {
@ -560,7 +560,7 @@ define([
this.$('.mailpoet_posts_title_as_link').removeClass('mailpoet_hidden');
}
this.changeField('titleFormat', event);
},
}
});
Module.PostsWidgetView = base.WidgetView.extend({
@ -572,19 +572,19 @@ define([
return new Module.PostsBlockModel({}, { parse: true });
}
}
},
}
});
App.on('before:start', function(App, options) {
App.registerBlockType('posts', {
blockModel: Module.PostsBlockModel,
blockView: Module.PostsBlockView,
blockView: Module.PostsBlockView
});
App.registerWidget({
name: 'posts',
widgetView: Module.PostsWidgetView,
priority: 96,
priority: 96
});
});

View File

@ -11,7 +11,7 @@ define([
'jquery'
], function(App, BaseBlock, Backbone, Marionette, SuperModel, _, jQuery) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock,
@ -30,7 +30,7 @@ define([
image: App.getAvailableStyles().get('socialIconSets.default.custom'),
height: '32px',
width: '32px',
text: defaultValues.get('title'),
text: defaultValues.get('title')
};
},
initialize: function(options) {
@ -42,11 +42,11 @@ define([
this.set({
link: defaultValues.get('defaultLink'),
image: iconSet.get(that.get('iconType')),
text: defaultValues.get('title'),
text: defaultValues.get('title')
});
}, this);
this.on('change', function() { App.getChannel().trigger('autoSave'); });
},
}
});
Module.SocialIconCollectionModel = Backbone.Collection.extend({
@ -59,11 +59,11 @@ define([
return this._getDefaults({
type: 'social',
iconSet: 'default',
icons: new Module.SocialIconCollectionModel(),
icons: new Module.SocialIconCollectionModel()
}, App.getConfig().get('blockDefaults.social'));
},
relations: {
icons: Module.SocialIconCollectionModel,
icons: Module.SocialIconCollectionModel
},
initialize: function() {
this.get('icons').on('add remove change', this._iconsChanged, this);
@ -80,27 +80,27 @@ define([
},
_iconsChanged: function() {
App.getChannel().trigger('autoSave');
},
}
});
var SocialIconView = Marionette.View.extend({
tagName: 'span',
getTemplate: function() { return templates.socialIconBlock; },
modelEvents: {
'change': 'render',
change: 'render'
},
templateContext: function() {
var allIconSets = App.getAvailableStyles().get('socialIconSets');
return {
model: this.model.toJSON(),
allIconSets: allIconSets.toJSON(),
imageMissingSrc: App.getConfig().get('urls.imageMissing'),
imageMissingSrc: App.getConfig().get('urls.imageMissing')
};
},
}
});
Module.SocialIconCollectionView = Marionette.CollectionView.extend({
childView: SocialIconView,
childView: SocialIconView
});
Module.SocialBlockView = base.BlockView.extend({
@ -113,7 +113,7 @@ define([
tools: '> .mailpoet_tools'
},
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ShowSettingsBehavior: {},
ShowSettingsBehavior: {}
}),
onDragSubstituteBy: function() { return Module.SocialWidgetView; },
onRender: function() {
@ -121,12 +121,12 @@ define([
this.showChildView('toolsRegion', this.toolsView);
this.showChildView('icons', new Module.SocialIconCollectionView({
collection: this.model.get('icons')
}))
},
}));
}
});
Module.SocialBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.SocialBlockSettingsView; },
getSettingsView: function() { return Module.SocialBlockSettingsView; }
});
// Sidebar view container
@ -134,11 +134,11 @@ define([
getTemplate: function() { return templates.socialBlockSettings; },
regions: {
iconRegion: '#mailpoet_social_icons_selection',
stylesRegion: '#mailpoet_social_icons_styles',
stylesRegion: '#mailpoet_social_icons_styles'
},
events: function() {
return {
"click .mailpoet_done_editing": "close",
'click .mailpoet_done_editing': 'close'
};
},
initialize: function() {
@ -158,11 +158,11 @@ define([
getTemplate: function() { return templates.socialSettingsIcon; },
events: function() {
return {
"click .mailpoet_delete_block": "deleteIcon",
"change .mailpoet_social_icon_field_type": _.partial(this.changeField, "iconType"),
"input .mailpoet_social_icon_field_image": _.partial(this.changeField, "image"),
"input .mailpoet_social_icon_field_link": this.changeLink,
"input .mailpoet_social_icon_field_text": _.partial(this.changeField, "text"),
'click .mailpoet_delete_block': 'deleteIcon',
'change .mailpoet_social_icon_field_type': _.partial(this.changeField, 'iconType'),
'input .mailpoet_social_icon_field_image': _.partial(this.changeField, 'image'),
'input .mailpoet_social_icon_field_link': this.changeLink,
'input .mailpoet_social_icon_field_text': _.partial(this.changeField, 'text')
};
},
modelEvents: {
@ -172,7 +172,7 @@ define([
},
'change:text': function() {
this.$('.mailpoet_social_icon_image').attr('alt', this.model.get('text'));
},
}
},
templateContext: function() {
var icons = App.getConfig().get('socialIcons'),
@ -182,7 +182,7 @@ define([
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
iconTypes: availableIconTypes,
currentType: icons.get(this.model.get('iconType')).toJSON(),
allIconSets: allIconSets.toJSON(),
allIconSets: allIconSets.toJSON()
});
},
deleteIcon: function() {
@ -197,30 +197,30 @@ define([
},
changeField: function(field, event) {
this.model.set(field, jQuery(event.target).val());
},
}
});
SocialBlockSettingsIconCollectionView = Marionette.CollectionView.extend({
behaviors: {
SortableBehavior: {
items: '> div',
},
items: '> div'
}
},
childViewContainer: '#mailpoet_social_icon_selector_contents',
childView: SocialBlockSettingsIconView,
childView: SocialBlockSettingsIconView
});
// Select icons section container view
SocialBlockSettingsIconSelectorView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsIconSelector; },
regions: {
'icons': '#mailpoet_social_icon_selector_contents'
icons: '#mailpoet_social_icon_selector_contents'
},
events: {
'click .mailpoet_add_social_icon': 'addSocialIcon',
'click .mailpoet_add_social_icon': 'addSocialIcon'
},
modelEvents: {
'change:iconSet': 'render',
'change:iconSet': 'render'
},
addSocialIcon: function() {
// Add a social icon with default values
@ -237,10 +237,10 @@ define([
SocialBlockSettingsStylesView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsStyles; },
modelEvents: {
'change': 'render',
change: 'render'
},
events: {
'click .mailpoet_social_icon_set': 'changeSocialIconSet',
'click .mailpoet_social_icon_set': 'changeSocialIconSet'
},
initialize: function() {
this.listenTo(this.model.get('icons'), 'add remove change', this.render);
@ -251,7 +251,7 @@ define([
activeSet: this.model.get('iconSet'),
socialIconSets: allIconSets.toJSON(),
availableSets: _.keys(allIconSets.toJSON()),
availableSocialIcons: this.model.get('icons').pluck('iconType'),
availableSocialIcons: this.model.get('icons').pluck('iconType')
};
},
changeSocialIconSet: function(event) {
@ -259,7 +259,7 @@ define([
},
onBeforeDestroy: function() {
this.model.get('icons').off('add remove', this.render, this);
},
}
});
Module.SocialWidgetView = base.WidgetView.extend({
@ -279,7 +279,7 @@ define([
image: App.getAvailableStyles().get('socialIconSets.default.facebook'),
height: '32px',
width: '32px',
text: 'Facebook',
text: 'Facebook'
},
{
type: 'socialIcon',
@ -288,25 +288,25 @@ define([
image: App.getAvailableStyles().get('socialIconSets.default.twitter'),
height: '32px',
width: '32px',
text: 'Twitter',
},
],
text: 'Twitter'
}
]
}, { parse: true });
}
}
},
}
});
App.on('before:start', function(App, options) {
App.registerBlockType('social', {
blockModel: Module.SocialBlockModel,
blockView: Module.SocialBlockView,
blockView: Module.SocialBlockView
});
App.registerWidget({
name: 'social',
widgetView: Module.SocialWidgetView,
priority: 95,
priority: 95
});
});

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -19,26 +19,26 @@ define([
styles: {
block: {
backgroundColor: 'transparent',
height: '40px',
},
},
height: '40px'
}
}
}, App.getConfig().get('blockDefaults.spacer'));
},
}
});
Module.SpacerBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_spacer_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_spacer_block mailpoet_droppable_block',
getTemplate: function() { return templates.spacerBlock; },
behaviors: _.defaults({
ResizableBehavior: {
elementSelector: '.mailpoet_spacer',
resizeHandleSelector: '.mailpoet_resize_handle',
minLength: 20, // TODO: Move this number to editor configuration
modelField: 'styles.block.height',
modelField: 'styles.block.height'
},
ShowSettingsBehavior: {
ignoreFrom: '.mailpoet_resize_handle'
},
}
}, base.BlockView.prototype.behaviors),
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
onDragSubstituteBy: function() { return Module.SpacerWidgetView; },
@ -58,21 +58,21 @@ define([
},
onBeforeDestroy: function() {
this.stopListening(this.model);
},
}
});
Module.SpacerBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.SpacerBlockSettingsView; },
getSettingsView: function() { return Module.SpacerBlockSettingsView; }
});
Module.SpacerBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.spacerBlockSettings; },
events: function() {
return {
"change .mailpoet_field_spacer_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
"click .mailpoet_done_editing": "close",
'change .mailpoet_field_spacer_background_color': _.partial(this.changeColorField, 'styles.block.backgroundColor'),
'click .mailpoet_done_editing': 'close'
};
},
}
});
Module.SpacerWidgetView = base.WidgetView.extend({
@ -82,21 +82,21 @@ define([
cloneOriginal: true,
drop: function() {
return new Module.SpacerBlockModel();
},
}
}
},
}
});
App.on('before:start', function(App, options) {
App.registerBlockType('spacer', {
blockModel: Module.SpacerBlockModel,
blockView: Module.SpacerBlockView,
blockView: Module.SpacerBlockView
});
App.registerWidget({
name: 'spacer',
widgetView: Module.SpacerWidgetView,
priority: 94,
priority: 94
});
});

View File

@ -7,7 +7,7 @@ define([
'underscore'
], function(App, BaseBlock, _) {
"use strict";
'use strict';
var Module = {},
base = BaseBlock;
@ -16,36 +16,36 @@ define([
defaults: function() {
return this._getDefaults({
type: 'text',
text: 'Edit this to insert text',
text: 'Edit this to insert text'
}, App.getConfig().get('blockDefaults.text'));
},
}
});
Module.TextBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_text_block mailpoet_droppable_block",
className: 'mailpoet_block mailpoet_text_block mailpoet_droppable_block',
getTemplate: function() { return templates.textBlock; },
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'), // Prevent rerendering on model change due to text editor redrawing
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
TextEditorBehavior: {
toolbar1: "formatselect bold italic forecolor | link unlink",
toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes",
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
invalidElements: "script",
toolbar1: 'formatselect bold italic forecolor | link unlink',
toolbar2: 'alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes',
validElements: 'p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]',
invalidElements: 'script',
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
plugins: "link lists code textcolor colorpicker mailpoet_shortcodes paste",
plugins: 'link lists code textcolor colorpicker mailpoet_shortcodes paste',
configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, {
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle')
});
}
},
}
}),
initialize: function(options) {
base.BlockView.prototype.initialize.apply(this, arguments);
this.renderOptions = _.defaults(options.renderOptions || {}, {
disableTextEditor: false,
disableTextEditor: false
});
this.disableTextEditor = this.renderOptions.disableTextEditor;
@ -55,8 +55,8 @@ define([
this.toolsView = new Module.TextBlockToolsView({
model: this.model,
tools: {
settings: false,
},
settings: false
}
});
this.showChildView('toolsRegion', this.toolsView);
},
@ -70,15 +70,15 @@ define([
onTextEditorBlur: function() {
this.enableDragging();
this.enableShowingTools();
},
}
});
Module.TextBlockToolsView = base.BlockToolsView.extend({
getSettingsView: function() { return Module.TextBlockSettingsView; },
getSettingsView: function() { return Module.TextBlockSettingsView; }
});
Module.TextBlockSettingsView = base.BlockSettingsView.extend({
getTemplate: function() { return templates.textBlockSettings; },
getTemplate: function() { return templates.textBlockSettings; }
});
Module.TextWidgetView = base.WidgetView.extend({
@ -88,21 +88,21 @@ define([
cloneOriginal: true,
drop: function() {
return new Module.TextBlockModel();
},
}
}
},
}
});
App.on('before:start', function(App, options) {
App.registerBlockType('text', {
blockModel: Module.TextBlockModel,
blockView: Module.TextBlockView,
blockView: Module.TextBlockView
});
App.registerWidget({
name: 'text',
widgetView: Module.TextWidgetView,
priority: 90,
priority: 90
});
});

View File

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

View File

@ -12,8 +12,8 @@ define([
blockDefaults: {},
sidepanelWidth: '331px',
validation: {},
urls: {},
},
urls: {}
}
});
// Global and available styles for access in blocks and their settings
@ -25,11 +25,12 @@ define([
};
App.on('before:start', function(App, options) {
var Application = App;
// Expose config methods globally
App.getConfig = Module.getConfig;
App.setConfig = Module.setConfig;
Application.getConfig = Module.getConfig;
Application.setConfig = Module.setConfig;
App.setConfig(options.config);
Application.setConfig(options.config);
});
return Module;

View File

@ -4,7 +4,7 @@ define([
'underscore',
'mailpoet'
], function(App, SuperModel, _, MailPoet) {
"use strict";
'use strict';
var Module = {};
@ -22,7 +22,7 @@ define([
// Use only whitelisted properties to ensure properties editor
// doesn't control don't change.
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
},
}
});
// Content block view and model handlers for different content types
@ -34,27 +34,27 @@ define([
if (type in Module._blockTypes) {
return Module._blockTypes[type].blockModel;
} else {
throw "Block type not supported: " + type;
throw 'Block type not supported: ' + type;
}
};
Module.getBlockTypeView = function(type) {
if (type in Module._blockTypes) {
return Module._blockTypes[type].blockView;
} else {
throw "Block type not supported: " + type;
throw 'Block type not supported: ' + type;
}
};
Module.getBody = function() {
return {
content: App._contentContainer.toJSON(),
globalStyles: App.getGlobalStyles().toJSON(),
globalStyles: App.getGlobalStyles().toJSON()
};
};
Module.toJSON = function() {
return _.extend({
body: Module.getBody(),
body: Module.getBody()
}, App.getNewsletter().toJSON());
};
@ -67,7 +67,8 @@ define([
return _.filter(blocks, predicate);
};
App.on('before:start', function(App, options) {
App.on('before:start', function(Application, options) {
var App = Application;
// Expose block methods globally
App.registerBlockType = Module.registerBlockType;
App.getBlockTypeModel = Module.getBlockTypeModel;
@ -80,7 +81,8 @@ define([
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
});
App.on('start', function(App, options) {
App.on('start', function(Application, options) {
var App = Application;
var body = options.newsletter.body;
var content = (_.has(body, 'content')) ? body.content : {};
@ -94,7 +96,7 @@ define([
App._contentContainer = new (App.getBlockTypeModel('container'))(content, {parse: true});
App._contentContainerView = new (App.getBlockTypeView('container'))({
model: App._contentContainer,
renderOptions: { depth: 0 },
renderOptions: { depth: 0 }
});
App._appView.showChildView('contentRegion', App._contentContainerView);

View File

@ -6,7 +6,7 @@ define([
'jquery'
], function(App, Backbone, Marionette, _, jQuery) {
"use strict";
'use strict';
var Module = {};
@ -14,22 +14,31 @@ define([
getTemplate: function() { return templates.heading; },
templateContext: function() {
return {
model: this.model.toJSON(),
model: this.model.toJSON()
};
},
events: function() {
return {
'keyup .mailpoet_input_title': _.partial(this.changeField, "subject"),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, "preheader"),
'keyup .mailpoet_input_title': _.partial(this.changeField, 'subject'),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, 'preheader')
};
},
changeField: function(field, event) {
this.model.set(field, jQuery(event.target).val());
},
}
});
App.on('start', function(App, options) {
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-subject-line'), {
tooltipId: 'tooltip-designer-subject-line-ti',
tooltip: MailPoet.I18n.t('helpTooltipDesignerSubjectLine'),
place: 'right'
});
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-preheader'), {
tooltipId: 'tooltip-designer-preheader-ti',
tooltip: MailPoet.I18n.t('helpTooltipDesignerPreheader')
});
});
return Module;

View File

@ -22,7 +22,7 @@ define([
html2canvas
) {
"use strict";
'use strict';
var Module = {},
saveTimeout;
@ -49,7 +49,7 @@ define([
MailPoet.Notice.error(
MailPoet.I18n.t('templateSaveFailed'),
{
scroll: true,
scroll: true
}
);
} else {
@ -65,14 +65,6 @@ define([
});
};
// For getting a promise after triggering save event
Module.saveAndProvidePromise = function(saveResult) {
var promise = Module.save();
if (saveResult !== undefined) {
saveResult.promise = promise;
}
};
Module.getThumbnail = function(element, options) {
var promise = html2canvas(element, options || {});
@ -81,8 +73,8 @@ define([
// Removes 1px left transparent border from resulting canvas.
var oldContext = oldCanvas.getContext('2d'),
newCanvas = document.createElement("canvas"),
newContext = newCanvas.getContext("2d"),
newCanvas = document.createElement('canvas'),
newContext = newCanvas.getContext('2d'),
leftBorderWidth = 1;
newCanvas.width = oldCanvas.width;
@ -105,7 +97,7 @@ define([
promise.then(function(thumbnail) {
var data = _.extend(options || {}, {
thumbnail: thumbnail.toDataURL('image/jpeg'),
body: JSON.stringify(App.getBody()),
body: JSON.stringify(App.getBody())
});
return MailPoet.Ajax.post({
@ -132,7 +124,7 @@ define([
).then(function(thumbnail) {
var data = _.extend(options || {}, {
thumbnail: thumbnail.toDataURL('image/jpeg'),
body: App.getBody(),
body: App.getBody()
});
var blob = new Blob(
[JSON.stringify(data)],
@ -140,6 +132,9 @@ define([
);
FileSaver.saveAs(blob, 'template.json');
MailPoet.trackEvent('Editor > Template exported', {
'MailPoet Free version': window.mailpoet_version
});
});
};
@ -154,7 +149,7 @@ define([
'click .mailpoet_save_as_template': 'saveAsTemplate',
/* Export template */
'click .mailpoet_save_export': 'toggleExportTemplate',
'click .mailpoet_export_template': 'exportTemplate',
'click .mailpoet_export_template': 'exportTemplate'
},
initialize: function(options) {
App.getChannel().on('beforeEditorSave', this.beforeSave, this);
@ -165,7 +160,7 @@ define([
},
save: function() {
this.hideOptionContents();
App.getChannel().trigger('save');
App.getChannel().request('save');
},
beforeSave: function() {
// TODO: Add a loading animation instead
@ -202,7 +197,7 @@ define([
MailPoet.I18n.t('templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
scroll: true
}
);
} else if (templateDescription === '') {
@ -210,27 +205,30 @@ define([
MailPoet.I18n.t('templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
scroll: true
}
);
} else {
Module.saveTemplate({
name: templateName,
description: templateDescription,
description: templateDescription
}).done(function() {
MailPoet.Notice.success(
MailPoet.I18n.t('templateSaved'),
{
positionAfter: that.$el,
scroll: true,
scroll: true
}
);
MailPoet.trackEvent('Editor > Template saved', {
'MailPoet Free version': window.mailpoet_version
});
}).fail(function() {
MailPoet.Notice.error(
MailPoet.I18n.t('templateSaveFailed'),
{
positionAfter: that.$el,
scroll: true,
scroll: true
}
);
});
@ -255,7 +253,7 @@ define([
MailPoet.I18n.t('templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
scroll: true
}
);
} else if (templateDescription === '') {
@ -263,13 +261,13 @@ define([
MailPoet.I18n.t('templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
scroll: true
}
);
} else {
Module.exportTemplate({
name: templateName,
description: templateDescription,
description: templateDescription
});
this.hideExportTemplate();
}
@ -282,7 +280,10 @@ define([
next: function() {
this.hideOptionContents();
if(!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
window.location.href = App.getConfig().get('urls.send');
Module._cancelAutosave();
Module.save().done(function(response) {
window.location.href = App.getConfig().get('urls.send');
});
}
},
validateNewsletter: function(jsonObject) {
@ -293,8 +294,8 @@ define([
var contents = JSON.stringify(jsonObject);
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
contents.indexOf("[link:subscription_unsubscribe_url]") < 0 &&
contents.indexOf("[link:subscription_unsubscribe]") < 0) {
contents.indexOf('[link:subscription_unsubscribe_url]') < 0 &&
contents.indexOf('[link:subscription_unsubscribe]') < 0) {
this.showValidationError(MailPoet.I18n.t('unsubscribeLinkMissing'));
return;
}
@ -311,7 +312,7 @@ define([
hideValidationError: function() {
this.$('.mailpoet_save_error').addClass('mailpoet_hidden');
this.$('.mailpoet_save_next').removeClass('button-disabled');
},
}
});
Module.autoSave = function() {
@ -319,22 +320,28 @@ define([
// may be requested
var AUTOSAVE_DELAY_DURATION = 1000;
// Cancel save timer if another change happens before it completes
if (saveTimeout) clearTimeout(saveTimeout);
Module._cancelAutosave();
saveTimeout = setTimeout(function() {
App.getChannel().trigger('save');
clearTimeout(saveTimeout);
saveTimeout = undefined;
App.getChannel().request('save').always(function() {
Module._cancelAutosave();
});
}, AUTOSAVE_DELAY_DURATION);
};
Module._cancelAutosave = function() {
if (!saveTimeout) return;
clearTimeout(saveTimeout);
saveTimeout = undefined;
};
Module.beforeExitWithUnsavedChanges = function(e) {
if (saveTimeout) {
var message = MailPoet.I18n.t('unsavedChangesWillBeLost');
e = e || window.event;
var event = e || window.event;
if (e) {
e.returnValue = message;
if (event) {
event.returnValue = message;
}
return message;
@ -342,12 +349,13 @@ define([
};
App.on('before:start', function(App, options) {
App.save = Module.saveAndProvidePromise;
App.getChannel().on('autoSave', Module.autoSave);
var Application = App;
Application.save = Module.save;
Application.getChannel().on('autoSave', Module.autoSave);
window.onbeforeunload = Module.beforeExitWithUnsavedChanges;
App.getChannel().on('save', function(saveResult) { App.save(saveResult); });
Application.getChannel().reply('save', Application.save);
});
App.on('start', function(App, options) {

View File

@ -20,7 +20,7 @@ define([
StickyKit
) {
"use strict";
'use strict';
var Module = {};
@ -30,10 +30,10 @@ define([
defaults: {
name: '',
priority: 100,
widgetView: undefined,
},
widgetView: undefined
}
}),
comparator: 'priority',
comparator: 'priority'
}))();
Module.registerWidget = function(widget) { return Module._contentWidgets.add(widget); };
Module.getWidgets = function() { return Module._contentWidgets; };
@ -44,10 +44,10 @@ define([
defaults: {
name: '',
priority: 100,
widgetView: undefined,
},
widgetView: undefined
}
}),
comparator: 'priority',
comparator: 'priority'
}))();
Module.registerLayoutWidget = function(widget) { return Module._layoutWidgets.add(widget); };
Module.getLayoutWidgets = function() { return Module._layoutWidgets; };
@ -58,7 +58,7 @@ define([
contentRegion: '.mailpoet_content_region',
layoutRegion: '.mailpoet_layout_region',
stylesRegion: '.mailpoet_styles_region',
previewRegion: '.mailpoet_preview_region',
previewRegion: '.mailpoet_preview_region'
},
events: {
'click .mailpoet_sidebar_region h3, .mailpoet_sidebar_region .handlediv': function(event) {
@ -69,7 +69,7 @@ define([
'slideUp',
{
duration: 250,
easing: "easeOut",
easing: 'easeOut',
complete: function() {
$openRegion.addClass('closed');
}.bind(this)
@ -81,14 +81,14 @@ define([
'slideDown',
{
duration: 250,
easing: "easeIn",
easing: 'easeIn',
complete: function() {
$targetRegion.removeClass('closed');
},
}
}
);
}
},
}
},
initialize: function(options) {
jQuery(window)
@ -104,7 +104,7 @@ define([
));
this.showChildView('stylesRegion', new Module.SidebarStylesView({
model: App.getGlobalStyles(),
availableStyles: App.getAvailableStyles(),
availableStyles: App.getAvailableStyles()
}));
this.showChildView('previewRegion', new Module.SidebarPreviewView());
},
@ -127,13 +127,13 @@ define([
},
onDomRefresh: function() {
this.$el.parent().stick_in_parent({
offset_top: 32,
offset_top: 32
});
this.$el.parent().on('sticky_kit:stick', this.updateHorizontalScroll.bind(this));
this.$el.parent().on('sticky_kit:unstick', this.updateHorizontalScroll.bind(this));
this.$el.parent().on('sticky_kit:bottom', this.updateHorizontalScroll.bind(this));
this.$el.parent().on('sticky_kit:unbottom', this.updateHorizontalScroll.bind(this));
},
}
});
/**
@ -167,7 +167,7 @@ define([
* Responsible for rendering draggable layout widgets
*/
Module.SidebarLayoutWidgetsView = Module.SidebarWidgetsView.extend({
getTemplate: function() { return templates.sidebarLayout; },
getTemplate: function() { return templates.sidebarLayout; }
});
/**
@ -176,50 +176,50 @@ define([
Module.SidebarStylesView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarStyles; },
behaviors: {
ColorPickerBehavior: {},
ColorPickerBehavior: {}
},
events: function() {
return {
"change #mailpoet_text_font_color": _.partial(this.changeColorField, 'text.fontColor'),
"change #mailpoet_text_font_family": function(event) {
'change #mailpoet_text_font_color': _.partial(this.changeColorField, 'text.fontColor'),
'change #mailpoet_text_font_family': function(event) {
this.model.set('text.fontFamily', event.target.value);
},
"change #mailpoet_text_font_size": function(event) {
'change #mailpoet_text_font_size': function(event) {
this.model.set('text.fontSize', event.target.value);
},
"change #mailpoet_h1_font_color": _.partial(this.changeColorField, 'h1.fontColor'),
"change #mailpoet_h1_font_family": function(event) {
'change #mailpoet_h1_font_color': _.partial(this.changeColorField, 'h1.fontColor'),
'change #mailpoet_h1_font_family': function(event) {
this.model.set('h1.fontFamily', event.target.value);
},
"change #mailpoet_h1_font_size": function(event) {
'change #mailpoet_h1_font_size': function(event) {
this.model.set('h1.fontSize', event.target.value);
},
"change #mailpoet_h2_font_color": _.partial(this.changeColorField, 'h2.fontColor'),
"change #mailpoet_h2_font_family": function(event) {
'change #mailpoet_h2_font_color': _.partial(this.changeColorField, 'h2.fontColor'),
'change #mailpoet_h2_font_family': function(event) {
this.model.set('h2.fontFamily', event.target.value);
},
"change #mailpoet_h2_font_size": function(event) {
'change #mailpoet_h2_font_size': function(event) {
this.model.set('h2.fontSize', event.target.value);
},
"change #mailpoet_h3_font_color": _.partial(this.changeColorField, 'h3.fontColor'),
"change #mailpoet_h3_font_family": function(event) {
'change #mailpoet_h3_font_color': _.partial(this.changeColorField, 'h3.fontColor'),
'change #mailpoet_h3_font_family': function(event) {
this.model.set('h3.fontFamily', event.target.value);
},
"change #mailpoet_h3_font_size": function(event) {
'change #mailpoet_h3_font_size': function(event) {
this.model.set('h3.fontSize', event.target.value);
},
"change #mailpoet_a_font_color": _.partial(this.changeColorField, 'link.fontColor'),
"change #mailpoet_a_font_underline": function(event) {
'change #mailpoet_a_font_color': _.partial(this.changeColorField, 'link.fontColor'),
'change #mailpoet_a_font_underline': function(event) {
this.model.set('link.textDecoration', (event.target.checked) ? event.target.value : 'none');
},
"change #mailpoet_newsletter_background_color": _.partial(this.changeColorField, 'wrapper.backgroundColor'),
"change #mailpoet_background_color": _.partial(this.changeColorField, 'body.backgroundColor'),
'change #mailpoet_newsletter_background_color': _.partial(this.changeColorField, 'wrapper.backgroundColor'),
'change #mailpoet_background_color': _.partial(this.changeColorField, 'body.backgroundColor')
};
},
templateContext: function() {
return {
model: this.model.toJSON(),
availableStyles: this.availableStyles.toJSON(),
availableStyles: this.availableStyles.toJSON()
};
},
initialize: function(options) {
@ -234,14 +234,14 @@ define([
value = 'transparent';
}
this.model.set(field, value);
},
}
});
Module.SidebarPreviewView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarPreview; },
events: {
'click .mailpoet_show_preview': 'showPreview',
'click #mailpoet_send_preview': 'sendPreview',
'click #mailpoet_send_preview': 'sendPreview'
},
onBeforeDestroy: function() {
if (this.previewView) {
@ -263,7 +263,7 @@ define([
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'showPreview',
data: json,
data: json
}).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
@ -272,16 +272,23 @@ define([
});
var view = this.previewView.render();
this.previewView.$el.css('height', '100%');
MailPoet.Modal.popup({
template: '',
element: this.previewView.$el,
width: '95%',
height: '94%',
title: MailPoet.I18n.t('newsletterPreview'),
onCancel: function() {
this.previewView.destroy();
this.previewView = null;
}.bind(this)
});
MailPoet.trackEvent('Editor > Browser Preview', {
'MailPoet Free version': window.mailpoet_version
});
}.bind(this)).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
@ -296,7 +303,7 @@ define([
var $emailField = this.$('#mailpoet_preview_to_email');
var data = {
subscriber: $emailField.val(),
id: App.getNewsletter().get('id'),
id: App.getNewsletter().get('id')
};
if (data.subscriber.length <= 0) {
@ -304,7 +311,7 @@ define([
MailPoet.I18n.t('newsletterPreviewEmailMissing'),
{
positionAfter: $emailField,
scroll: true,
scroll: true
}
);
return false;
@ -314,16 +321,18 @@ define([
MailPoet.Modal.loading(true);
// save before sending
var saveResult = {promise: null};
App.getChannel().trigger('save', saveResult);
saveResult.promise.always(function() {
App.getChannel().request('save').always(function() {
CommunicationComponent.previewNewsletter(data).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterPreviewSent'),
{ scroll: true });
{ scroll: true }
);
MailPoet.trackEvent('Editor > Preview sent', {
'MailPoet Free version': window.mailpoet_version,
'Domain name': data.subscriber.substring(data.subscriber.indexOf('@') + 1)
});
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
@ -333,30 +342,33 @@ define([
}
});
});
},
}
});
Module.NewsletterPreviewView = Marionette.View.extend({
getTemplate: function() { return templates.newsletterPreview; },
initialize: function(options) {
this.previewUrl = options.previewUrl;
this.width = App.getConfig().get('newsletterPreview.width');
this.height = App.getConfig().get('newsletterPreview.height')
this.width = '100%';
this.height = '100%';
// this.width = App.getConfig().get('newsletterPreview.width');
// this.height = App.getConfig().get('newsletterPreview.height')
},
templateContext: function() {
return {
previewUrl: this.previewUrl,
width: this.width,
height: this.height,
height: this.height
};
}
});
App.on('before:start', function(App, options) {
App.registerWidget = Module.registerWidget;
App.getWidgets = Module.getWidgets;
App.registerLayoutWidget = Module.registerLayoutWidget;
App.getLayoutWidgets = Module.getLayoutWidgets;
var Application = App;
Application.registerWidget = Module.registerWidget;
Application.getWidgets = Module.getWidgets;
Application.registerLayoutWidget = Module.registerLayoutWidget;
Application.getLayoutWidgets = Module.getLayoutWidgets;
});
App.on('start', function(App, options) {
@ -364,6 +376,16 @@ define([
sidebarView = new SidebarView();
App._appView.showChildView('sidebarRegion', sidebarView);
MailPoet.helpTooltip.show(document.getElementById('tooltip-send-preview'), {
tooltipId: 'tooltip-editor-send-preview',
tooltip: MailPoet.I18n.t('helpTooltipSendPreview')
});
MailPoet.helpTooltip.show(document.getElementById('tooltip-designer-styles'), {
tooltipId: 'tooltip-editor-designer-styles',
tooltip: MailPoet.I18n.t('helpTooltipDesignerStyles')
});
});
return Module;

View File

@ -4,7 +4,7 @@ define([
'backbone.supermodel'
], function(App, Marionette, SuperModel) {
"use strict";
'use strict';
var Module = {};
@ -13,7 +13,7 @@ define([
text: {
fontColor: '#000000',
fontFamily: 'Arial',
fontSize: '16px',
fontSize: '16px'
},
h1: {
fontColor: '#111111',
@ -23,33 +23,33 @@ define([
h2: {
fontColor: '#222222',
fontFamily: 'Tahoma',
fontSize: '32px',
fontSize: '32px'
},
h3: {
fontColor: '#333333',
fontFamily: 'Verdana',
fontSize: '24px',
fontSize: '24px'
},
link: {
fontColor: '#21759B',
textDecoration: 'underline',
textDecoration: 'underline'
},
wrapper: {
backgroundColor: '#ffffff',
backgroundColor: '#ffffff'
},
body: {
backgroundColor: '#cccccc',
},
backgroundColor: '#cccccc'
}
},
initialize: function() {
this.on('change', function() { App.getChannel().trigger('autoSave'); });
},
}
});
Module.StylesView = Marionette.View.extend({
getTemplate: function() { return templates.styles; },
modelEvents: {
'change': 'render',
change: 'render'
},
serializeData: function() {
return this.model.toJSON();
@ -69,10 +69,11 @@ define([
};
App.on('before:start', function(App, options) {
var Application = App;
// Expose style methods to global application
App.getGlobalStyles = Module.getGlobalStyles;
App.setGlobalStyles = Module.setGlobalStyles;
App.getAvailableStyles = Module.getAvailableStyles;
Application.getGlobalStyles = Module.getGlobalStyles;
Application.setGlobalStyles = Module.setGlobalStyles;
Application.getAvailableStyles = Module.getAvailableStyles;
var body = options.newsletter.body;
var globalStyles = (_.has(body, 'globalStyles')) ? body.globalStyles : {};

View File

@ -31,7 +31,7 @@ tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
if (configShortcodes.hasOwnProperty(segment)) {
shortcodes.push({
type: 'label',
text: segment,
text: segment
});
for (var i = 0; i < configShortcodes[segment].length; i += 1) {
@ -46,13 +46,13 @@ tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
// Open window
editor.windowManager.open({
height: parseInt(editor.getParam("plugin_mailpoet_shortcodes_height", 400)),
width: parseInt(editor.getParam("plugin_mailpoet_shortcodes_width", 450)),
height: parseInt(editor.getParam('plugin_mailpoet_shortcodes_height', 400)),
width: parseInt(editor.getParam('plugin_mailpoet_shortcodes_width', 450)),
autoScroll: true,
title: editor.settings.mailpoet_shortcodes_window_title,
body: shortcodes,
buttons: [],
buttons: []
});
},
}
});
});

View File

@ -13,15 +13,15 @@ ImageAndTextTemplateWidgetView = EditorApplication.module('blocks.base').WidgetV
orientation: 'horizontal',
blocks: [
{
type: 'image',
type: 'image'
},
{
type: 'text',
text: 'Some random text',
},
],
text: 'Some random text'
}
]
}, {parse: true});
},
}
}
},
}
});

View File

@ -6,16 +6,16 @@ import Badge from './badge.jsx';
const badges = {
excellent: {
name: MailPoet.I18n.t('excellentBadgeName'),
tooltipTitle: MailPoet.I18n.t('excellentBadgeTooltip')
tooltipTitle: MailPoet.I18n.t('excellentBadgeTooltip'),
},
good: {
name: MailPoet.I18n.t('goodBadgeName'),
tooltipTitle: MailPoet.I18n.t('goodBadgeTooltip')
tooltipTitle: MailPoet.I18n.t('goodBadgeTooltip'),
},
bad: {
name: MailPoet.I18n.t('badBadgeName'),
tooltipTitle: MailPoet.I18n.t('badBadgeTooltip')
}
tooltipTitle: MailPoet.I18n.t('badBadgeTooltip'),
},
};
const stats = {
@ -24,7 +24,7 @@ const stats = {
badgeTypes: [
'excellent',
'good',
'bad'
'bad',
],
tooltipText: MailPoet.I18n.t('openedStatTooltip'),
},
@ -33,18 +33,18 @@ const stats = {
badgeTypes: [
'excellent',
'good',
'bad'
'bad',
],
tooltipText: MailPoet.I18n.t('clickedStatTooltip')
tooltipText: MailPoet.I18n.t('clickedStatTooltip'),
},
unsubscribed: {
badgeRanges: [3, 1, 0],
badgeTypes: [
'bad',
'good',
'excellent'
'excellent',
],
tooltipText: MailPoet.I18n.t('unsubscribedStatTooltip')
tooltipText: MailPoet.I18n.t('unsubscribedStatTooltip'),
},
};

View File

@ -3,7 +3,7 @@ define(
'react',
'react-router',
'classnames',
'mailpoet'
'mailpoet',
],
(
React,
@ -21,27 +21,27 @@ define(
{
name: 'type',
label: MailPoet.I18n.t('selectType'),
link: '/new'
link: '/new',
},
{
name: 'template',
label: MailPoet.I18n.t('template')
label: MailPoet.I18n.t('template'),
},
{
name: 'editor',
label: MailPoet.I18n.t('designer')
label: MailPoet.I18n.t('designer'),
},
{
name: 'send',
label: MailPoet.I18n.t('send')
}
]
label: MailPoet.I18n.t('send'),
},
],
};
},
render: function () {
const steps = this.state.steps.map((step, index) => {
const stepClasses = classNames(
{ 'mailpoet_current': (this.props.step === step.name) }
{ mailpoet_current: (this.props.step === step.name) }
);
let label = step.label;
@ -67,7 +67,7 @@ define(
{ steps }
</p>
);
}
},
});
return Breadcrumb;

View File

@ -16,8 +16,8 @@ const _QueueMixin = {
endpoint: 'sendingQueue',
action: 'pause',
data: {
newsletter_id: newsletter.id
}
newsletter_id: newsletter.id,
},
}).done(() => {
jQuery('#resume_'+newsletter.id).show();
jQuery('#pause_'+newsletter.id).hide();
@ -36,8 +36,8 @@ const _QueueMixin = {
endpoint: 'sendingQueue',
action: 'resume',
data: {
newsletter_id: newsletter.id
}
newsletter_id: newsletter.id,
},
}).done(() => {
jQuery('#pause_'+newsletter.id).show();
jQuery('#resume_'+newsletter.id).hide();
@ -69,7 +69,7 @@ const _QueueMixin = {
}
const progressClasses = classNames(
'mailpoet_progress',
{ 'mailpoet_progress_complete': newsletter.queue.status === 'completed' }
{ mailpoet_progress_complete: newsletter.queue.status === 'completed' }
);
// calculate percentage done
@ -84,8 +84,8 @@ const _QueueMixin = {
<span>
{
MailPoet.I18n.t('newsletterQueueCompleted')
.replace("%$1d",newsletter.queue.count_processed)
.replace("%$2d", newsletter.queue.count_total)
.replace('%$1d', newsletter.queue.count_processed)
.replace('%$2d', newsletter.queue.count_total)
}
</span>
);
@ -120,7 +120,7 @@ const _QueueMixin = {
percentage = MailPoet.I18n.t('noSubscribers');
} else {
progress_bar_width = percentage;
percentage += "%";
percentage += '%';
}
return (
@ -128,7 +128,7 @@ const _QueueMixin = {
<div className={ progressClasses }>
<span
className="mailpoet_progress_bar"
style={ { width: progress_bar_width + "%" } }
style={ { width: progress_bar_width + '%' } }
></span>
<span className="mailpoet_progress_label">
{ percentage }
@ -145,13 +145,14 @@ const _QueueMixin = {
const _StatisticsMixin = {
renderStatistics: function (newsletter, is_sent, current_time) {
if (is_sent === undefined) {
let sent = is_sent;
if (sent === undefined) {
// condition for standard and post notification listings
is_sent = newsletter.statistics
sent = newsletter.statistics
&& newsletter.queue
&& newsletter.queue.status !== 'scheduled';
}
if (!is_sent) {
if (!sent) {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
);
@ -238,7 +239,7 @@ const _StatisticsMixin = {
<div>
<span className="mailpoet_stats_text">
{ percentage_opened_display }%,
{ " " }
{ ' ' }
{ percentage_clicked_display }%
<span className="mailpoet_stat_hidden">
, { percentage_unsubscribed_display }%
@ -301,7 +302,7 @@ const _StatisticsMixin = {
{after_content}
</div>
);
}
},
};
const _MailerMixin = {
@ -326,7 +327,7 @@ const _MailerMixin = {
MailPoet.I18n.t('mailerCheckSettingsNotice'),
/\[link\](.*?)\[\/link\]/g,
match => (
<a href={`?page=mailpoet-settings#mta`}>{ match }</a>
<a href={'?page=mailpoet-settings#mta'} key="check-sending">{ match }</a>
)
);
if (state.meta.mta_log.error.operation === 'send') {
@ -356,7 +357,7 @@ const _MailerMixin = {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'mailer',
action: 'resumeSending'
action: 'resumeSending',
}).done(() => {
MailPoet.Notice.hide('mailpoet_mailer_error');
MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice'));
@ -369,12 +370,10 @@ const _MailerMixin = {
);
}
});
}
},
};
export { _QueueMixin as QueueMixin };
export { _StatisticsMixin as StatisticsMixin };
export { _MailerMixin as MailerMixin };

View File

@ -13,7 +13,7 @@ import {
timeOfDayValues,
weekDayValues,
monthDayValues,
nthWeekDayValues
nthWeekDayValues,
} from 'newsletters/scheduling/common.jsx';
const messages = {
@ -61,42 +61,42 @@ const messages = {
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
},
};
const columns = [
{
name: 'subject',
label: MailPoet.I18n.t('subject'),
sortable: true
sortable: true,
},
{
name: 'status',
label: MailPoet.I18n.t('status'),
width: 100
width: 100,
},
{
name: 'settings',
label: MailPoet.I18n.t('settings')
label: MailPoet.I18n.t('settings'),
},
{
name: 'history',
label: MailPoet.I18n.t('history'),
width: 100
width: 100,
},
{
name: 'updated_at',
label: MailPoet.I18n.t('lastModifiedOn'),
sortable: true
}
sortable: true,
},
];
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
onSuccess: messages.onTrash,
},
];
const newsletter_actions = [
@ -108,7 +108,7 @@ const newsletter_actions = [
{MailPoet.I18n.t('preview')}
</a>
);
}
},
},
{
name: 'edit',
@ -118,7 +118,7 @@ const newsletter_actions = [
{MailPoet.I18n.t('edit')}
</a>
);
}
},
},
{
name: 'duplicate',
@ -129,8 +129,8 @@ const newsletter_actions = [
endpoint: 'newsletters',
action: 'duplicate',
data: {
id: newsletter.id
}
id: newsletter.id,
},
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
@ -146,11 +146,11 @@ const newsletter_actions = [
);
}
});
}
},
},
{
name: 'trash'
}
name: 'trash',
},
];
const NewsletterListNotification = React.createClass({
@ -166,8 +166,8 @@ const NewsletterListNotification = React.createClass({
action: 'setStatus',
data: {
id: ~~(e.target.getAttribute('data-id')),
status: e.target.value
}
status: e.target.value,
},
}).done((response) => {
if (response.data.status === 'active') {
MailPoet.Notice.success(MailPoet.I18n.t('postNotificationActivated'));
@ -335,7 +335,7 @@ const NewsletterListNotification = React.createClass({
/>
</div>
);
}
},
});
module.exports = NewsletterListNotification;

View File

@ -10,7 +10,7 @@ import ListingTabs from 'newsletters/listings/tabs.jsx';
import {
QueueMixin,
StatisticsMixin,
MailerMixin
MailerMixin,
} from 'newsletters/listings/mixins.jsx';
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
@ -22,21 +22,21 @@ const columns = [
},
{
name: 'status',
label: MailPoet.I18n.t('status')
label: MailPoet.I18n.t('status'),
},
{
name: 'segments',
label: MailPoet.I18n.t('lists')
label: MailPoet.I18n.t('lists'),
},
{
name: 'statistics',
label: MailPoet.I18n.t('statistics'),
display: mailpoet_tracking_enabled
display: mailpoet_tracking_enabled,
},
{
name: 'sent_at',
label: MailPoet.I18n.t('sentOn'),
}
},
];
let newsletter_actions = [
@ -48,8 +48,8 @@ let newsletter_actions = [
{MailPoet.I18n.t('preview')}
</a>
);
}
}
},
},
];
newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_notification_history_actions', newsletter_actions);
@ -126,7 +126,7 @@ const NewsletterListNotificationHistory = React.createClass({
/>
</div>
);
}
},
});
module.exports = NewsletterListNotificationHistory;

View File

@ -10,7 +10,7 @@ import ListingTabs from 'newsletters/listings/tabs.jsx';
import {
QueueMixin,
StatisticsMixin,
MailerMixin
MailerMixin,
} from 'newsletters/listings/mixins.jsx';
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
@ -60,43 +60,54 @@ const messages = {
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
},
};
const columns = [
{
name: 'subject',
label: MailPoet.I18n.t('subject'),
sortable: true
sortable: true,
},
{
name: 'status',
label: MailPoet.I18n.t('status')
label: MailPoet.I18n.t('status'),
},
{
name: 'segments',
label: MailPoet.I18n.t('lists')
label: MailPoet.I18n.t('lists'),
},
{
name: 'statistics',
label: MailPoet.I18n.t('statistics'),
display: mailpoet_tracking_enabled
display: mailpoet_tracking_enabled,
},
{
name: 'sent_at',
label: MailPoet.I18n.t('sentOn'),
sortable: true
}
sortable: true,
},
];
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
onSuccess: messages.onTrash,
},
];
const confirmEdit = (newsletter) => {
if(
!newsletter.queue
|| newsletter.status != 'sending'
|| newsletter.queue.status !== null
|| window.confirm(MailPoet.I18n.t('confirmEdit'))
) {
window.location.href = `?page=mailpoet-newsletter-editor&id=${ newsletter.id }`;
}
};
let newsletter_actions = [
{
name: 'view',
@ -106,17 +117,12 @@ let newsletter_actions = [
{MailPoet.I18n.t('preview')}
</a>
);
}
},
},
{
name: 'edit',
link: function (newsletter) {
return (
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
{MailPoet.I18n.t('edit')}
</a>
);
}
label: MailPoet.I18n.t('edit'),
onClick: confirmEdit,
},
{
name: 'duplicate',
@ -127,8 +133,8 @@ let newsletter_actions = [
endpoint: 'newsletters',
action: 'duplicate',
data: {
id: newsletter.id
}
id: newsletter.id,
},
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
@ -144,11 +150,11 @@ let newsletter_actions = [
);
}
});
}
},
},
{
name: 'trash'
}
name: 'trash',
},
];
newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_standard_actions', newsletter_actions);
@ -172,7 +178,8 @@ const NewsletterListStandard = React.createClass({
<strong>
<a
className="row-title"
href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }
href="javascript:;"
onClick={() => confirmEdit(newsletter)}
>{ newsletter.queue.newsletter_rendered_subject || newsletter.subject }</a>
</strong>
{ actions }
@ -198,7 +205,14 @@ const NewsletterListStandard = React.createClass({
return (
<div>
<h1 className="title">
{MailPoet.I18n.t('pageTitle')} <Link className="page-title-action" to="/new">{MailPoet.I18n.t('new')}</Link>
{MailPoet.I18n.t('pageTitle')}
<Link className="page-title-action" to="/new"
onClick={() => MailPoet.trackEvent('Emails > Add New',
{ 'MailPoet Free version': window.mailpoet_version }
)}
>
{MailPoet.I18n.t('new')}
</Link>
</h1>
<ListingTabs tab="standard" />
@ -222,7 +236,7 @@ const NewsletterListStandard = React.createClass({
/>
</div>
);
}
},
});
module.exports = NewsletterListStandard;

View File

@ -11,19 +11,19 @@ const ListingTabs = React.createClass({
{
name: 'standard',
label: MailPoet.I18n.t('tabStandardTitle'),
link: '/standard'
link: '/standard',
},
{
name: 'welcome',
label: MailPoet.I18n.t('tabWelcomeTitle'),
link: '/welcome'
link: '/welcome',
},
{
name: 'notification',
label: MailPoet.I18n.t('tabNotificationTitle'),
link: '/notification'
}
]
link: '/notification',
},
],
};
},
render() {
@ -38,6 +38,9 @@ const ListingTabs = React.createClass({
key={ 'tab-'+index }
className={ tabClasses }
to={ tab.link }
onClick={() => MailPoet.trackEvent(`Tab Emails > ${tab.name} clicked`,
{ 'MailPoet Free version': window.mailpoet_version }
)}
>{ tab.label }</Link>
);
});
@ -47,7 +50,7 @@ const ListingTabs = React.createClass({
{ tabs }
</h2>
);
}
},
});
module.exports = ListingTabs;

View File

@ -60,42 +60,42 @@ const messages = {
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
}
},
};
const columns = [
{
name: 'subject',
label: MailPoet.I18n.t('subject'),
sortable: true
sortable: true,
},
{
name: 'status',
label: MailPoet.I18n.t('status'),
width: 145
width: 145,
},
{
name: 'settings',
label: MailPoet.I18n.t('settings')
label: MailPoet.I18n.t('settings'),
},
{
name: 'statistics',
label: MailPoet.I18n.t('statistics'),
display: mailpoet_tracking_enabled
display: mailpoet_tracking_enabled,
},
{
name: 'updated_at',
label: MailPoet.I18n.t('lastModifiedOn'),
sortable: true
}
sortable: true,
},
];
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
onSuccess: messages.onTrash,
},
];
let newsletter_actions = [
@ -107,7 +107,7 @@ let newsletter_actions = [
{MailPoet.I18n.t('preview')}
</a>
);
}
},
},
{
name: 'edit',
@ -117,11 +117,11 @@ let newsletter_actions = [
{MailPoet.I18n.t('edit')}
</a>
);
}
},
},
{
name: 'trash'
}
name: 'trash',
},
];
newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_welcome_notification_actions', newsletter_actions);
@ -139,8 +139,8 @@ const NewsletterListWelcome = React.createClass({
action: 'setStatus',
data: {
id: ~~(e.target.getAttribute('data-id')),
status: e.target.value
}
status: e.target.value,
},
}).done((response) => {
if (response.data.status === 'active') {
MailPoet.Notice.success(MailPoet.I18n.t('welcomeEmailActivated'));
@ -313,7 +313,7 @@ const NewsletterListWelcome = React.createClass({
/>
</div>
);
}
},
});
module.exports = NewsletterListWelcome;

View File

@ -21,7 +21,7 @@ const history = useRouterHistory(createHashHistory)({ queryKey: false });
const App = React.createClass({
render() {
return this.props.children;
}
},
});
const container = document.getElementById('newsletters_container');

View File

@ -5,18 +5,18 @@ const timeFormat = window.mailpoet_time_format || 'H:i';
// welcome emails
const _timeDelayValues = {
'immediate': MailPoet.I18n.t('delayImmediately'),
'hours': MailPoet.I18n.t('delayHoursAfter'),
'days': MailPoet.I18n.t('delayDaysAfter'),
'weeks': MailPoet.I18n.t('delayWeeksAfter')
immediate: MailPoet.I18n.t('delayImmediately'),
hours: MailPoet.I18n.t('delayHoursAfter'),
days: MailPoet.I18n.t('delayDaysAfter'),
weeks: MailPoet.I18n.t('delayWeeksAfter'),
};
const _intervalValues = {
'daily': MailPoet.I18n.t('daily'),
'weekly': MailPoet.I18n.t('weekly'),
'monthly': MailPoet.I18n.t('monthly'),
'nthWeekDay': MailPoet.I18n.t('monthlyEvery'),
'immediately': MailPoet.I18n.t('immediately')
daily: MailPoet.I18n.t('daily'),
weekly: MailPoet.I18n.t('weekly'),
monthly: MailPoet.I18n.t('monthly'),
nthWeekDay: MailPoet.I18n.t('monthlyEvery'),
immediately: MailPoet.I18n.t('immediately'),
};
// notification emails
@ -25,7 +25,7 @@ const TIME_STEP_SECONDS = 3600;
const numberOfTimeSteps = SECONDS_IN_DAY / TIME_STEP_SECONDS;
const _timeOfDayValues = _.object(_.map(
_.times(numberOfTimeSteps,(step) => {
_.times(numberOfTimeSteps, (step) => {
return step * TIME_STEP_SECONDS;
}), (seconds) => {
const date = new Date(null);
@ -42,7 +42,7 @@ const _weekDayValues = {
3: MailPoet.I18n.t('wednesday'),
4: MailPoet.I18n.t('thursday'),
5: MailPoet.I18n.t('friday'),
6: MailPoet.I18n.t('saturday')
6: MailPoet.I18n.t('saturday'),
};
const NUMBER_OF_DAYS_IN_MONTH = 28;
@ -54,13 +54,13 @@ const _monthDayValues = _.object(
const labels = {
0: MailPoet.I18n.t('first'),
1: MailPoet.I18n.t('second'),
2: MailPoet.I18n.t('third')
2: MailPoet.I18n.t('third'),
};
let label;
if (labels[day] !== undefined) {
label = labels[day];
} else {
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
label = MailPoet.I18n.t('nth').replace('%$1d', day + 1);
}
return [day + 1, label];
}
@ -68,10 +68,10 @@ const _monthDayValues = _.object(
);
const _nthWeekDayValues = {
'1': MailPoet.I18n.t('first'),
'2': MailPoet.I18n.t('second'),
'3': MailPoet.I18n.t('third'),
'L': MailPoet.I18n.t('last')
1: MailPoet.I18n.t('first'),
2: MailPoet.I18n.t('second'),
3: MailPoet.I18n.t('third'),
L: MailPoet.I18n.t('last'),
};
export { _timeDelayValues as timeDelayValues };

View File

@ -8,7 +8,8 @@ define(
'newsletters/send/standard.jsx',
'newsletters/send/notification.jsx',
'newsletters/send/welcome.jsx',
'newsletters/breadcrumb.jsx'
'newsletters/breadcrumb.jsx',
'help-tooltip.jsx',
],
(
React,
@ -19,12 +20,13 @@ define(
StandardNewsletterFields,
NotificationNewsletterFields,
WelcomeNewsletterFields,
Breadcrumb
Breadcrumb,
HelpTooltip
) => {
const NewsletterSend = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: React.PropTypes.object.isRequired,
},
getInitialState: function () {
return {
@ -68,18 +70,18 @@ define(
endpoint: 'newsletters',
action: 'get',
data: {
id: id
}
id: id,
},
}).done((response) => {
this.setState({
loading: false,
item: response.data,
fields: this.getFieldsByNewsletter(response.data)
fields: this.getFieldsByNewsletter(response.data),
});
}).fail(() => {
this.setState({
loading: false,
item: {}
item: {},
}, () => {
this.context.router.push('/new');
});
@ -103,21 +105,30 @@ define(
action: 'setStatus',
data: {
id: this.props.params.id,
status: 'active'
}
status: 'active',
},
}).done((response) => {
// redirect to listing based on newsletter type
this.context.router.push(`/${ this.state.item.type || '' }`);
const opts = this.state.item.options;
// display success message depending on newsletter type
if (response.data.type === 'welcome') {
MailPoet.Notice.success(
MailPoet.I18n.t('welcomeEmailActivated')
);
MailPoet.trackEvent('Emails > Welcome email activated', {
'MailPoet Free version': window.mailpoet_version,
'List type': opts.event,
Delay: opts.afterTimeNumber + ' ' + opts.afterTimeType,
});
} else if (response.data.type === 'notification') {
MailPoet.Notice.success(
MailPoet.I18n.t('postNotificationActivated')
);
MailPoet.trackEvent('Emails > Post notifications activated', {
'MailPoet Free version': window.mailpoet_version,
Frequency: opts.intervalType,
});
}
}).fail(this._showError);
default:
@ -126,8 +137,8 @@ define(
endpoint: 'sendingQueue',
action: 'add',
data: {
newsletter_id: this.props.params.id
}
newsletter_id: this.props.params.id,
},
}).done((response) => {
// redirect to listing based on newsletter type
this.context.router.push(`/${ this.state.item.type || '' }`);
@ -136,14 +147,60 @@ define(
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterHasBeenScheduled')
);
MailPoet.trackEvent('Emails > Newsletter sent', {
scheduled: true,
'MailPoet Free version': window.mailpoet_version,
});
} else {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterBeingSent')
);
MailPoet.trackEvent('Emails > Newsletter sent', {
scheduled: false,
'MailPoet Free version': window.mailpoet_version,
});
}
}).fail(this._showError);
}
}).fail(this._showError).always(() => {
})
.fail(this._showError)
.always(() => {
this.setState({ loading: false });
});
}
return false;
},
handleResume: function (e) {
e.preventDefault();
if(!this.isValid()) {
jQuery('#mailpoet_newsletter').parsley().validate();
} else {
this._save(e).done(() => {
this.setState({ loading: true });
}).done(() => {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
action: 'resume',
data: {
newsletter_id: this.state.item.id,
},
}).done(() => {
this.context.router.push(`/${ this.state.item.type || '' }`);
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterSendingHasBeenResumed')
);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
})
.fail(this._showError)
.always(() => {
this.setState({ loading: false });
});
}
@ -174,12 +231,13 @@ define(
},
_save: function () {
const data = this.state.item;
data.queue = undefined;
this.setState({ loading: true });
// Store only properties that can be changed on this page
const IGNORED_NEWSLETTER_PROPERTIES = [
'preheader', 'body', 'created_at', 'deleted_at', 'hash',
'status', 'updated_at', 'type'
'status', 'updated_at', 'type',
];
const newsletterData = _.omit(
data,
@ -210,11 +268,21 @@ define(
item[field] = e.target.value;
this.setState({
item: item
item: item,
});
return true;
},
render: function () {
const isPaused = this.state.item.status == 'sending'
&& this.state.item.queue
&& this.state.item.queue.status == 'paused';
const fields = this.state.fields.map((field) => {
const newField = field;
if (field.name == 'segments' || field.name == 'options') {
newField.disabled = isPaused;
}
return newField;
});
return (
<div>
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>
@ -223,20 +291,29 @@ define(
<Form
id="mailpoet_newsletter"
fields={ this.state.fields }
fields={ fields }
item={ this.state.item }
loading={ this.state.loading }
onChange={this.handleFormChange}
onSubmit={this.handleSave}
>
<p className="submit">
<input
{
isPaused ?
<input
className="button button-primary"
type="button"
onClick={ this.handleResume }
value={MailPoet.I18n.t('resume')} />
:
<input
className="button button-primary"
type="button"
onClick={ this.handleSend }
value={MailPoet.I18n.t('send')}
{...this.getSendButtonOptions()}
/>
}
&nbsp;
<input
className="button button-secondary"
@ -251,10 +328,14 @@ define(
{MailPoet.I18n.t('goBackToDesign')}
</a>.
</p>
<HelpTooltip
tooltip={MailPoet.I18n.t('helpTooltipSendEmail')}
tooltipId="helpTooltipSendEmail"
/>
</Form>
</div>
);
}
},
});
return NewsletterSend;

View File

@ -3,7 +3,7 @@ define(
'mailpoet',
'wp-js-hooks',
'newsletters/types/notification/scheduling.jsx',
'underscore'
'underscore',
],
(
MailPoet,
@ -20,8 +20,8 @@ define(
type: 'text',
validation: {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError')
}
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError'),
},
},
{
name: 'options',
@ -55,8 +55,8 @@ define(
},
validation: {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('noSegmentsSelectedError')
}
'data-parsley-required-message': MailPoet.I18n.t('noSegmentsSelectedError'),
},
},
{
name: 'sender',
@ -68,8 +68,8 @@ define(
type: 'text',
placeholder: MailPoet.I18n.t('senderNamePlaceholder'),
validation: {
'data-parsley-required': true
}
'data-parsley-required': true,
},
},
{
name: 'sender_address',
@ -77,10 +77,10 @@ define(
placeholder: MailPoet.I18n.t('senderAddressPlaceholder'),
validation: {
'data-parsley-required': true,
'data-parsley-type': 'email'
}
}
]
'data-parsley-type': 'email',
},
},
],
},
{
name: 'reply-to',
@ -91,15 +91,15 @@ define(
{
name: 'reply_to_name',
type: 'text',
placeholder: MailPoet.I18n.t('replyToNamePlaceholder')
placeholder: MailPoet.I18n.t('replyToNamePlaceholder'),
},
{
name: 'reply_to_address',
type: 'text',
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder')
}
]
}
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder'),
},
],
},
];
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
@ -110,7 +110,7 @@ define(
},
getSendButtonOptions: function () {
return {
value: MailPoet.I18n.t('activate')
value: MailPoet.I18n.t('activate'),
};
},
};

View File

@ -8,12 +8,14 @@ define(
],
(
React,
jQuery,
jq,
_,
MailPoet,
Hooks
) => {
const jQuery = jq;
const currentTime = window.mailpoet_current_time || '00:00';
const defaultDateTime = window.mailpoet_current_date + ' ' + '00:00:00';
const timeOfDayItems = window.mailpoet_schedule_time_of_day;
@ -37,7 +39,7 @@ define(
MailPoet.I18n.t('september'),
MailPoet.I18n.t('october'),
MailPoet.I18n.t('november'),
MailPoet.I18n.t('december')
MailPoet.I18n.t('december'),
],
monthNamesShort: [
MailPoet.I18n.t('januaryShort'),
@ -51,7 +53,7 @@ define(
MailPoet.I18n.t('septemberShort'),
MailPoet.I18n.t('octoberShort'),
MailPoet.I18n.t('novemberShort'),
MailPoet.I18n.t('decemberShort')
MailPoet.I18n.t('decemberShort'),
],
dayNames: [
MailPoet.I18n.t('sunday'),
@ -60,7 +62,7 @@ define(
MailPoet.I18n.t('wednesday'),
MailPoet.I18n.t('thursday'),
MailPoet.I18n.t('friday'),
MailPoet.I18n.t('saturday')
MailPoet.I18n.t('saturday'),
],
dayNamesShort: [
MailPoet.I18n.t('sundayShort'),
@ -69,7 +71,7 @@ define(
MailPoet.I18n.t('wednesdayShort'),
MailPoet.I18n.t('thursdayShort'),
MailPoet.I18n.t('fridayShort'),
MailPoet.I18n.t('saturdayShort')
MailPoet.I18n.t('saturdayShort'),
],
dayNamesMin: [
MailPoet.I18n.t('sundayMin'),
@ -78,18 +80,19 @@ define(
MailPoet.I18n.t('wednesdayMin'),
MailPoet.I18n.t('thursdayMin'),
MailPoet.I18n.t('fridayMin'),
MailPoet.I18n.t('saturdayMin')
MailPoet.I18n.t('saturdayMin'),
],
};
const DateText = React.createClass({
onChange: function (event) {
const changeEvent = event;
// Swap display format to storage format
const displayDate = event.target.value;
const displayDate = changeEvent.target.value;
const storageDate = this.getStorageDate(displayDate);
event.target.value = storageDate;
this.props.onChange(event);
changeEvent.target.value = storageDate;
this.props.onChange(changeEvent);
},
componentDidMount: function () {
const $element = jQuery(this.refs.dateInput);
@ -100,13 +103,13 @@ define(
// Transform string format to Date object
return MailPoet.Date.toDate(value, {
parseFormat: dateDisplayFormat,
format: format
format: format,
});
};
jQuery.datepicker.formatDate = function (format, value) {
// Transform Date object to string format
const newValue = MailPoet.Date.format(value, {
format: format
format: format,
});
return newValue;
};
@ -138,13 +141,13 @@ define(
getDisplayDate: function (date) {
return MailPoet.Date.format(date, {
parseFormat: this.props.storageFormat,
format: this.props.displayFormat
format: this.props.displayFormat,
});
},
getStorageDate: function (date) {
return MailPoet.Date.format(date, {
parseFormat: this.props.displayFormat,
format: this.props.storageFormat
format: this.props.storageFormat,
});
},
render: function () {
@ -155,6 +158,7 @@ define(
name={this.getFieldName()}
value={this.getDisplayDate(this.props.value)}
readOnly={ true }
disabled={this.props.disabled}
onChange={this.onChange}
ref="dateInput"
{...this.props.validation} />
@ -180,17 +184,18 @@ define(
<select
name={this.props.name || 'time'}
value={this.props.value}
disabled={this.props.disabled}
onChange={this.props.onChange}
{...this.props.validation}
>
{options}
</select>
);
}
},
});
const DateTime = React.createClass({
_DATE_TIME_SEPARATOR: " ",
_DATE_TIME_SEPARATOR: ' ',
getInitialState: function () {
return this._buildStateFromProps(this.props);
},
@ -219,7 +224,7 @@ define(
target: {
name: this.props.name || '',
value: this.getDateTime(),
}
},
});
}
},
@ -235,15 +240,17 @@ define(
onChange={this.handleChange}
displayFormat={dateDisplayFormat}
storageFormat={dateStorageFormat}
disabled={this.props.disabled}
validation={this.props.dateValidation}/>
<TimeSelect
name="time"
value={this.state.time}
onChange={this.handleChange}
disabled={this.props.disabled}
validation={this.props.timeValidation} />
</span>
);
}
},
});
const StandardScheduling = React.createClass({
@ -252,7 +259,7 @@ define(
this.props.item[this.props.field.name] || {},
{
isScheduled: '0',
scheduledAt: defaultDateTime
scheduledAt: defaultDateTime,
}
);
},
@ -264,13 +271,14 @@ define(
return this.props.onValueChange({
target: {
name: this.props.field.name,
value: _.extend({}, oldValue, newValue)
}
value: _.extend({}, oldValue, newValue),
},
});
},
handleCheckboxChange: function (event) {
event.target.value = this.refs.isScheduled.checked ? '1' : '0';
return this.handleValueChange(event);
const changeEvent = event;
changeEvent.target.value = this.refs.isScheduled.checked ? '1' : '0';
return this.handleValueChange(changeEvent);
},
isScheduled: function () {
return this._getCurrentValue().isScheduled === '1';
@ -292,6 +300,7 @@ define(
name="scheduledAt"
value={this._getCurrentValue().scheduledAt}
onChange={this.handleValueChange}
disabled={this.props.field.disabled}
dateValidation={this.getDateValidation()} />
&nbsp;
<span>
@ -300,7 +309,6 @@ define(
</span>
);
}
return (
<div>
<input
@ -308,6 +316,7 @@ define(
type="checkbox"
value="1"
checked={this.isScheduled()}
disabled={this.props.field.disabled}
name="isScheduled"
onChange={this.handleCheckboxChange} />
@ -325,8 +334,8 @@ define(
type: 'text',
validation: {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError')
}
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError'),
},
},
{
name: 'segments',
@ -354,8 +363,8 @@ define(
},
validation: {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('noSegmentsSelectedError')
}
'data-parsley-required-message': MailPoet.I18n.t('noSegmentsSelectedError'),
},
},
{
name: 'sender',
@ -367,8 +376,8 @@ define(
type: 'text',
placeholder: MailPoet.I18n.t('senderNamePlaceholder'),
validation: {
'data-parsley-required': true
}
'data-parsley-required': true,
},
},
{
name: 'sender_address',
@ -376,10 +385,10 @@ define(
placeholder: MailPoet.I18n.t('senderAddressPlaceholder'),
validation: {
'data-parsley-required': true,
'data-parsley-type': 'email'
}
}
]
'data-parsley-type': 'email',
},
},
],
},
{
name: 'reply-to',
@ -390,21 +399,21 @@ define(
{
name: 'reply_to_name',
type: 'text',
placeholder: MailPoet.I18n.t('replyToNamePlaceholder')
placeholder: MailPoet.I18n.t('replyToNamePlaceholder'),
},
{
name: 'reply_to_address',
type: 'text',
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder')
}
]
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder'),
},
],
},
{
name: 'options',
label: MailPoet.I18n.t('scheduleIt'),
type: 'reactComponent',
component: StandardScheduling,
}
},
];
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
@ -414,20 +423,20 @@ define(
return fields;
},
getSendButtonOptions: function (newsletter) {
newsletter = newsletter || {};
const newsletterOptions = newsletter || {};
const isScheduled = (
typeof newsletter.options === 'object'
&& newsletter.options.isScheduled === '1'
typeof newsletterOptions.options === 'object'
&& newsletterOptions.options.isScheduled === '1'
);
const options = {
value: (isScheduled
? MailPoet.I18n.t('schedule')
: MailPoet.I18n.t('send'))
: MailPoet.I18n.t('send')),
};
if (newsletter.status === 'sent'
|| newsletter.status === 'sending') {
if (newsletterOptions.status === 'sent'
|| newsletterOptions.status === 'sending') {
options['disabled'] = 'disabled';
}

View File

@ -2,7 +2,7 @@ define(
[
'mailpoet',
'wp-js-hooks',
'newsletters/types/welcome/scheduling.jsx'
'newsletters/types/welcome/scheduling.jsx',
],
(
MailPoet,
@ -19,8 +19,8 @@ define(
type: 'text',
validation: {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError')
}
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError'),
},
},
{
name: 'options',
@ -38,8 +38,8 @@ define(
type: 'text',
placeholder: MailPoet.I18n.t('senderNamePlaceholder'),
validation: {
'data-parsley-required': true
}
'data-parsley-required': true,
},
},
{
name: 'sender_address',
@ -47,10 +47,10 @@ define(
placeholder: MailPoet.I18n.t('senderAddressPlaceholder'),
validation: {
'data-parsley-required': true,
'data-parsley-type': 'email'
}
}
]
'data-parsley-type': 'email',
},
},
],
},
{
name: 'reply-to',
@ -61,15 +61,15 @@ define(
{
name: 'reply_to_name',
type: 'text',
placeholder: MailPoet.I18n.t('replyToNamePlaceholder')
placeholder: MailPoet.I18n.t('replyToNamePlaceholder'),
},
{
name: 'reply_to_address',
type: 'text',
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder')
}
]
}
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder'),
},
],
},
];
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
@ -80,7 +80,7 @@ define(
},
getSendButtonOptions: function () {
return {
value: MailPoet.I18n.t('activate')
value: MailPoet.I18n.t('activate'),
};
},
};

View File

@ -5,7 +5,8 @@ define(
'mailpoet',
'react-router',
'classnames',
'newsletters/breadcrumb.jsx'
'newsletters/breadcrumb.jsx',
'help-tooltip.jsx',
],
(
React,
@ -13,11 +14,13 @@ define(
MailPoet,
Router,
classNames,
Breadcrumb
Breadcrumb,
HelpTooltip
) => {
const ImportTemplate = React.createClass({
saveTemplate: function (template) {
saveTemplate: function (saveTemplate) {
const template = saveTemplate;
// Stringify to enable transmission of primitive non-string value types
if (!_.isUndefined(template.body)) {
@ -30,7 +33,7 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'save',
data: template
data: template,
}).always(() => {
MailPoet.Modal.loading(false);
}).done((response) => {
@ -49,6 +52,7 @@ define(
if (_.size(this.refs.templateFile.files) <= 0) return false;
const file = _.first(this.refs.templateFile.files);
const reader = new FileReader();
const saveTemplate = this.saveTemplate;
@ -56,6 +60,9 @@ define(
reader.onload = (e) => {
try {
saveTemplate(JSON.parse(e.target.result));
MailPoet.trackEvent('Emails > Template imported', {
'MailPoet Free version': window.mailpoet_version,
});
} catch (err) {
MailPoet.Notice.error(MailPoet.I18n.t('templateFileMalformedError'));
}
@ -66,10 +73,13 @@ define(
render: function () {
return (
<div>
<h2>{MailPoet.I18n.t('importTemplateTitle')}</h2>
<h2>{MailPoet.I18n.t('importTemplateTitle')} <HelpTooltip
tooltip={MailPoet.I18n.t('helpTooltipTemplateUpload')}
place="right"
className="tooltip-help-import-template"
/></h2>
<form onSubmit={this.handleSubmit}>
<input type="file" placeholder={MailPoet.I18n.t('selectJsonFileToUpload')} ref="templateFile" />
<p className="submit">
<input
className="button button-primary"
@ -86,7 +96,7 @@ define(
getInitialState: function () {
return {
loading: false,
templates: []
templates: [],
};
},
componentDidMount: function () {
@ -112,13 +122,13 @@ define(
MailPoet.I18n.t('mailpoetGuideTemplateTitle'),
description:
MailPoet.I18n.t('mailpoetGuideTemplateDescription'),
readonly: "1"
}
readonly: '1',
},
];
}
this.setState({
templates: response.data,
loading: false
loading: false,
});
}
}).fail((response) => {
@ -138,14 +148,19 @@ define(
body = JSON.stringify(body);
}
MailPoet.trackEvent('Emails > Template selected', {
'MailPoet Free version': window.mailpoet_version,
'Email name': template.name,
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'save',
data: {
id: this.props.params.id,
body: body
}
body: body,
},
}).done((response) => {
// TODO: Move this URL elsewhere
window.location = 'admin.php?page=mailpoet-newsletter-editor&id=' + response.data.id;
@ -164,7 +179,7 @@ define(
window.confirm(
(
MailPoet.I18n.t('confirmTemplateDeletion')
).replace("%$1s", template.name)
).replace('%$1s', template.name)
)
) {
MailPoet.Ajax.post({
@ -172,8 +187,8 @@ define(
endpoint: 'newsletterTemplates',
action: 'delete',
data: {
id: template.id
}
id: template.id,
},
}).done(() => {
this.getTemplates();
}).fail((response) => {
@ -192,7 +207,7 @@ define(
MailPoet.Modal.popup({
title: template.name,
template: '<div class="mailpoet_boxes_preview" style="background-color: {{ body.globalStyles.body.backgroundColor }}"><img src="{{ thumbnail }}" /></div>',
data: template
data: template,
});
},
handleTemplateImport: function () {
@ -248,7 +263,7 @@ define(
{MailPoet.I18n.t('select')}
</a>
</div>
{ (template.readonly === "1") ? false : deleteLink }
{ (template.readonly === '1') ? false : deleteLink }
</li>
);
});
@ -256,7 +271,7 @@ define(
const boxClasses = classNames(
'mailpoet_boxes',
'clearfix',
{ 'mailpoet_boxes_loading': this.state.loading }
{ mailpoet_boxes_loading: this.state.loading }
);
return (
@ -272,7 +287,7 @@ define(
<ImportTemplate onImport={this.handleTemplateImport} />
</div>
);
}
},
});
return NewsletterTemplates;

View File

@ -4,7 +4,7 @@ define(
'mailpoet',
'wp-js-hooks',
'react-router',
'newsletters/breadcrumb.jsx'
'newsletters/breadcrumb.jsx',
],
(
React,
@ -15,14 +15,22 @@ define(
) => {
const NewsletterTypes = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: React.PropTypes.object.isRequired,
},
setupNewsletter: function (type) {
if(type !== undefined) {
this.context.router.push(`/new/${type}`);
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,
'Email type': type,
});
}
},
createNewsletter: function (type) {
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,
'Email type': type,
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -30,7 +38,7 @@ define(
data: {
type: type,
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}
},
}).done((response) => {
this.context.router.push(`/template/${response.data.id}`);
}).fail((response) => {
@ -45,22 +53,22 @@ define(
render: function () {
let types = [
{
'id': 'standard',
'title': MailPoet.I18n.t('regularNewsletterTypeTitle'),
'description': MailPoet.I18n.t('regularNewsletterTypeDescription'),
'action': function () {
id: 'standard',
title: MailPoet.I18n.t('regularNewsletterTypeTitle'),
description: MailPoet.I18n.t('regularNewsletterTypeDescription'),
action: function () {
return (
<a className="button button-primary" onClick={ this.createNewsletter.bind(null, 'standard') }>
{MailPoet.I18n.t('create')}
</a>
);
}.bind(this)()
}.bind(this)(),
},
{
'id': 'welcome',
'title': MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
'description': MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
'action': function () {
id: 'welcome',
title: MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
description: MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
action: function () {
return (
<div>
<a href="?page=mailpoet-premium" target="_blank">
@ -68,20 +76,20 @@ define(
</a>
</div>
);
}()
}(),
},
{
'id': 'notification',
'title': MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
'description': MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
'action': function () {
id: 'notification',
title: MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
description: MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
action: function () {
return (
<a className="button button-primary" onClick={ this.setupNewsletter.bind(null, 'notification') }>
{MailPoet.I18n.t('setUp')}
</a>
);
}.bind(this)()
}
}.bind(this)(),
},
];
types = Hooks.applyFilters('mailpoet_newsletters_types', types, this);
@ -114,7 +122,7 @@ define(
</ul>
</div>
);
}
},
});
return NewsletterTypes;

View File

@ -5,7 +5,7 @@ define(
'react-router',
'mailpoet',
'newsletters/types/notification/scheduling.jsx',
'newsletters/breadcrumb.jsx'
'newsletters/breadcrumb.jsx',
],
(
_,
@ -24,7 +24,7 @@ define(
const NewsletterNotification = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: React.PropTypes.object.isRequired,
},
getInitialState: function () {
return {
@ -34,7 +34,7 @@ define(
weekDay: 1,
monthDay: 0,
nthWeekDay: 1,
}
},
};
},
handleValueChange: function (event) {

View File

@ -6,32 +6,32 @@ import {
timeOfDayValues,
weekDayValues,
monthDayValues,
nthWeekDayValues
nthWeekDayValues,
} from 'newsletters/scheduling/common.jsx';
const intervalField = {
name: 'intervalType',
values: intervalValues
values: intervalValues,
};
const timeOfDayField = {
name: 'timeOfDay',
values: timeOfDayValues
values: timeOfDayValues,
};
const weekDayField = {
name: 'weekDay',
values: weekDayValues
values: weekDayValues,
};
const monthDayField = {
name: 'monthDay',
values: monthDayValues
values: monthDayValues,
};
const nthWeekDayField = {
name: 'nthWeekDay',
values: nthWeekDayValues
values: nthWeekDayValues,
};
const NotificationScheduling = React.createClass({
@ -47,8 +47,8 @@ const NotificationScheduling = React.createClass({
return this.props.onValueChange({
target: {
name: this.props.field.name,
value: _.extend({}, oldValue, newValue)
}
value: _.extend({}, oldValue, newValue),
},
});
},
handleIntervalChange: function (event) {
@ -137,7 +137,7 @@ const NotificationScheduling = React.createClass({
{timeOfDaySelection}
</div>
);
}
},
});
module.exports = NotificationScheduling;

View File

@ -3,7 +3,7 @@ define(
'react',
'react-router',
'mailpoet',
'newsletters/breadcrumb.jsx'
'newsletters/breadcrumb.jsx',
],
(
React,
@ -14,7 +14,7 @@ define(
const NewsletterStandard = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
router: React.PropTypes.object.isRequired,
},
showTemplateSelection: function (newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
@ -26,8 +26,8 @@ define(
endpoint: 'newsletters',
action: 'create',
data: {
type: 'standard'
}
type: 'standard',
},
}).done((response) => {
this.showTemplateSelection(response.data.id);
}).fail((response) => {

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