activity_notification 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +33 -0
  3. data/.rubocop.yml +1157 -0
  4. data/.yardopts +3 -0
  5. data/CHANGELOG.md +25 -0
  6. data/Gemfile.lock +15 -17
  7. data/README.md +154 -27
  8. data/activity_notification.gemspec +1 -1
  9. data/app/controllers/activity_notification/notifications_controller.rb +30 -104
  10. data/app/controllers/activity_notification/notifications_with_devise_controller.rb +1 -33
  11. data/app/controllers/activity_notification/subscriptions_controller.rb +184 -0
  12. data/app/controllers/activity_notification/subscriptions_with_devise_controller.rb +6 -0
  13. data/app/mailers/activity_notification/mailer.rb +3 -3
  14. data/app/views/activity_notification/notifications/default/_index.html.erb +3 -0
  15. data/app/views/activity_notification/notifications/default/index.html.erb +8 -10
  16. data/app/views/activity_notification/notifications/default/show.html.erb +24 -2
  17. data/app/views/activity_notification/subscriptions/default/_form.html.erb +52 -0
  18. data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +89 -0
  19. data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +73 -0
  20. data/app/views/activity_notification/subscriptions/default/_subscriptions.html.erb +13 -0
  21. data/app/views/activity_notification/subscriptions/default/create.js.erb +5 -0
  22. data/app/views/activity_notification/subscriptions/default/destroy.js.erb +5 -0
  23. data/app/views/activity_notification/subscriptions/default/index.html.erb +197 -0
  24. data/app/views/activity_notification/subscriptions/default/show.html.erb +177 -0
  25. data/app/views/activity_notification/subscriptions/default/subscribe.js.erb +8 -0
  26. data/app/views/activity_notification/subscriptions/default/subscribe_to_email.js.erb +6 -0
  27. data/app/views/activity_notification/subscriptions/default/unsubscribe.js.erb +8 -0
  28. data/app/views/activity_notification/subscriptions/default/unsubscribe_to_email.js.erb +6 -0
  29. data/gemfiles/Gemfile.rails-4.2.lock +18 -20
  30. data/gemfiles/Gemfile.rails-5.0.lock +18 -20
  31. data/lib/activity_notification.rb +7 -3
  32. data/lib/activity_notification/apis/notification_api.rb +95 -61
  33. data/lib/activity_notification/apis/subscription_api.rb +51 -0
  34. data/lib/activity_notification/common.rb +1 -1
  35. data/lib/activity_notification/config.rb +65 -17
  36. data/lib/activity_notification/controllers/common_controller.rb +118 -0
  37. data/lib/activity_notification/controllers/devise_authentication_controller.rb +41 -0
  38. data/lib/activity_notification/helpers/view_helpers.rb +131 -3
  39. data/lib/activity_notification/mailers/helpers.rb +6 -8
  40. data/lib/activity_notification/models/concerns/notifiable.rb +45 -27
  41. data/lib/activity_notification/models/concerns/subscriber.rb +149 -0
  42. data/lib/activity_notification/models/concerns/target.rb +100 -66
  43. data/lib/activity_notification/models/notification.rb +7 -5
  44. data/lib/activity_notification/models/subscription.rb +93 -0
  45. data/lib/activity_notification/rails/routes.rb +148 -33
  46. data/lib/activity_notification/renderable.rb +3 -4
  47. data/lib/activity_notification/roles/acts_as_notifiable.rb +14 -1
  48. data/lib/activity_notification/roles/acts_as_target.rb +11 -8
  49. data/lib/activity_notification/version.rb +1 -1
  50. data/lib/generators/activity_notification/controllers_generator.rb +2 -2
  51. data/lib/generators/activity_notification/install_generator.rb +0 -1
  52. data/lib/generators/activity_notification/migration/migration_generator.rb +8 -2
  53. data/lib/generators/activity_notification/models_generator.rb +53 -0
  54. data/lib/generators/activity_notification/views_generator.rb +7 -7
  55. data/lib/generators/templates/activity_notification.rb +17 -3
  56. data/lib/generators/templates/controllers/notifications_controller.rb +18 -17
  57. data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +18 -17
  58. data/lib/generators/templates/controllers/subscriptions_controller.rb +79 -0
  59. data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +87 -0
  60. data/lib/generators/templates/migrations/migration.rb +57 -0
  61. data/lib/generators/templates/models/README +10 -0
  62. data/lib/generators/templates/{notification → models}/notification.rb +1 -3
  63. data/lib/generators/templates/models/subscription.rb +4 -0
  64. data/spec/concerns/apis/notification_api_spec.rb +48 -11
  65. data/spec/concerns/apis/subscription_api_spec.rb +167 -0
  66. data/spec/concerns/models/notifiable_spec.rb +60 -0
  67. data/spec/concerns/models/subscriber_spec.rb +525 -0
  68. data/spec/concerns/models/target_spec.rb +271 -42
  69. data/spec/controllers/common_controller_spec.rb +25 -0
  70. data/spec/controllers/dummy_common_controller.rb +5 -0
  71. data/spec/controllers/notifications_controller_shared_examples.rb +2 -6
  72. data/spec/controllers/subscriptions_controller_shared_examples.rb +735 -0
  73. data/spec/controllers/subscriptions_controller_spec.rb +12 -0
  74. data/spec/controllers/subscriptions_with_devise_controller_spec.rb +91 -0
  75. data/spec/factories/dummy/dummy_subscriber.rb +4 -0
  76. data/spec/factories/subscriptions.rb +8 -0
  77. data/spec/generators/controllers_generator_spec.rb +25 -2
  78. data/spec/generators/migration/migration_generator_spec.rb +3 -3
  79. data/spec/generators/models_generator_spec.rb +96 -0
  80. data/spec/generators/views_generator_spec.rb +84 -0
  81. data/spec/helpers/view_helpers_spec.rb +143 -0
  82. data/spec/mailers/mailer_spec.rb +5 -4
  83. data/spec/models/dummy/dummy_subscriber_spec.rb +5 -0
  84. data/spec/models/notification_spec.rb +7 -7
  85. data/spec/models/subscription_spec.rb +158 -0
  86. data/spec/rails_app/app/controllers/users/notifications_controller.rb +67 -0
  87. data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +75 -0
  88. data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +79 -0
  89. data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +87 -0
  90. data/spec/rails_app/app/models/admin.rb +1 -0
  91. data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +4 -0
  92. data/spec/rails_app/app/models/user.rb +2 -1
  93. data/spec/rails_app/app/views/activity_notification/mailer/dummy_subscribers/test_key.text.erb +1 -0
  94. data/spec/rails_app/app/views/articles/index.html.erb +6 -0
  95. data/spec/rails_app/config/initializers/activity_notification.rb +17 -3
  96. data/spec/rails_app/config/routes.rb +2 -2
  97. data/spec/rails_app/db/migrate/20160715050420_create_activity_notification_tables.rb +33 -0
  98. data/spec/rails_app/db/schema.rb +18 -0
  99. data/spec/roles/acts_as_notifiable_spec.rb +1 -1
  100. data/spec/roles/acts_as_target_spec.rb +1 -1
  101. metadata +70 -11
  102. data/lib/generators/activity_notification/notification/notification_generator.rb +0 -20
  103. data/lib/generators/templates/active_record/migration.rb +0 -18
  104. data/spec/generators/notification/notification_generator_spec.rb +0 -41
  105. data/spec/rails_app/db/migrate/20160715050420_create_notifications.rb +0 -18
@@ -0,0 +1,6 @@
1
+ module ActivityNotification
2
+ # Controller to manage subscriptions with Devise authentication.
3
+ class SubscriptionsWithDeviseController < SubscriptionsController
4
+ include DeviceAuthenticationController
5
+ end
6
+ end
@@ -21,16 +21,16 @@ if defined?(ActionMailer)
21
21
  #
22
22
  # @param [Object] target Target of batch notification email
23
23
  # @param [Array<Notification>] notifications Target notifications to send batch notification email
24
+ # @param [String] batch_key Key of the batch notification email
24
25
  # @param [Hash] options Options for notification email
25
26
  # @option options [String, Symbol] :fallback (:batch_default) Fallback template to use when MissingTemplate is raised
26
- # @option options [String] :batch_key (nil) Key of the batch notification email, a key of the first notification will be used if not specified
27
27
  # @return [Mail::Message|ActionMailer::DeliveryJob] Email message or its delivery job
28
- def send_batch_notification_email(target, notifications, options = {})
28
+ def send_batch_notification_email(target, notifications, batch_key, options = {})
29
29
  options[:fallback] ||= :batch_default
30
30
  if options[:fallback] == :none
31
31
  options.delete(:fallback)
32
32
  end
33
- batch_notification_mail(target, notifications, options)
33
+ batch_notification_mail(target, notifications, batch_key, options)
34
34
  end
35
35
 
36
36
  end
@@ -13,6 +13,9 @@
13
13
  </p>
14
14
  <p class="notification_header_menu">
15
15
  <%= link_to "Open all", open_all_notifications_path_for(@target, parameters), method: :post, remote: true %>
16
+ <% if @target.class.subscription_enabled? %>
17
+ <%= link_to "Subscriptions", subscriptions_path_for(@target) %>
18
+ <% end %>
16
19
  </p>
17
20
  </div>
18
21
  <div class="notifications">
@@ -2,16 +2,14 @@
2
2
  <div class="notification_header">
3
3
  <h1>Notifications to <%= @target.printable_target_name %> <%= link_to open_all_notifications_path_for(@target, @index_options), method: :post, remote: true do %><span class="notification_count"><span class="<%= 'unopened' if @target.has_unopened_notifications?(@index_options) %>"><%= @target.unopened_notification_count(@index_options) %></span></span><% end %></h1>
4
4
  </div>
5
- <ul>
6
- <div class="notifications">
7
- <% if @index_options[:with_group_members] %>
8
- <%= render_notification @notifications, fallback: :default_without_grouping, with_group_members: true %>
9
- <% else %>
10
- <%= render_notification @notifications, fallback: :default %>
11
- <%#= render_notification @notifications, fallback: :text %>
12
- <% end %>
13
- </div>
14
- </ul>
5
+ <div class="notifications">
6
+ <% if @index_options[:with_group_members] %>
7
+ <%= render_notification @notifications, fallback: :default_without_grouping, with_group_members: true %>
8
+ <% else %>
9
+ <%= render_notification @notifications, fallback: :default %>
10
+ <%#= render_notification @notifications, fallback: :text %>
11
+ <% end %>
12
+ </div>
15
13
  </div>
16
14
 
17
15
  <%#= render_notifications_of @target, fallback: :default, index_content: :with_attributes %>
@@ -1,2 +1,24 @@
1
- <h1>Notification for <%= "#{@target.class.to_s.underscore} (#{@target.id})" %></h1>
2
- <%= render_notification(@notification, fallback: :default) %>
1
+ <div class="notification_wrapper">
2
+ <div class="notification_header">
3
+ <h1>Notification to <%= @target.printable_target_name %></h1>
4
+ </div>
5
+ <ul>
6
+ <div class="notifications">
7
+ <%= render_notification(@notification, fallback: :default) %>
8
+ <%#= render_notification @notification, fallback: :text %>
9
+ </div>
10
+ </ul>
11
+ </div>
12
+
13
+ <style>
14
+ .notification_wrapper .notification_header h1 span span{
15
+ color: #fff;
16
+ background-color: #e5e5e5;
17
+ border-radius: 4px;
18
+ font-size: 12px;
19
+ padding: 4px 8px;
20
+ }
21
+ .notification_wrapper .notification_header h1 span span.unopened{
22
+ background-color: #f87880;
23
+ }
24
+ </style>
@@ -0,0 +1,52 @@
1
+ <div class="fields_area">
2
+ <div class="fields_wrapper">
3
+ <%= form_for(ActivityNotification::Subscription.new, as: :subscription, url: subscriptions_url_for(target, option_params), data: { remote: true }) do |f| %>
4
+ <div class="field_wrapper">
5
+ <div class="field_label">
6
+ <%= f.label :key, "Notification key" %>
7
+ </div>
8
+ <div class="field">
9
+ <div class="ui text_field">
10
+ <%= f.text_field :key, placeholder: "Notification key" %>
11
+ </div>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="field_wrapper subscribing">
16
+ <div class="field_label">
17
+ <label>
18
+ Notification
19
+ </label>
20
+ </div>
21
+ <div class="field">
22
+ <div class="ui checkbox">
23
+ <label>
24
+ <%= f.check_box :subscribing, { checked: ActivityNotification.config.subscribe_as_default }, 'true', 'false' %>
25
+ <div class="slider"></div>
26
+ </label>
27
+ </div>
28
+ </div>
29
+ </div>
30
+
31
+ <div class="field_wrapper subscribing_to_email <%= 'hidden' unless ActivityNotification.config.subscribe_as_default %>">
32
+ <div class="field_label">
33
+ <label>
34
+ Email notification
35
+ </label>
36
+ </div>
37
+ <div class="field">
38
+ <div class="ui checkbox">
39
+ <label>
40
+ <%= f.check_box :subscribing_to_email, { checked: ActivityNotification.config.subscribe_as_default }, 'true', 'false' %>
41
+ <div class="slider"></div>
42
+ </label>
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+ <div class="ui button">
48
+ <button type="submit">Create subscription</button>
49
+ </div>
50
+ <% end %>
51
+ </div>
52
+ </div>
@@ -0,0 +1,89 @@
1
+ <% if notification_keys.present? %>
2
+ <div class="fields_area">
3
+ <% notification_keys.each do |key| %>
4
+ <div class="fields_wrapper">
5
+ <%= form_for(ActivityNotification::Subscription.new, as: :subscription, url: subscriptions_url_for(target, option_params), data: { remote: true }) do |f| %>
6
+ <%= f.hidden_field :key, value: key %>
7
+ <div class="fields_title_wrapper">
8
+ <h3 class="fields_title">
9
+ <%= key %>
10
+ </h3>
11
+ <p>
12
+ <%= link_to "Notifications", notifications_path_for(target, filtered_by_key: key) %>
13
+ </p>
14
+ </div>
15
+ <div class="field_wrapper subscribing">
16
+ <div class="field_label">
17
+ <label>
18
+ Notification
19
+ </label>
20
+ </div>
21
+
22
+ <div class="field">
23
+ <div class="ui checkbox">
24
+ <label>
25
+ <%= f.check_box :subscribing, { checked: ActivityNotification.config.subscribe_as_default }, 'true', 'false' %>
26
+ <div class="slider"></div>
27
+ </label>
28
+ </div>
29
+ </div>
30
+ </div>
31
+
32
+ <div class="field_wrapper subscribing_to_email <%= 'hidden' unless ActivityNotification.config.subscribe_as_default %>">
33
+ <div class="field_label">
34
+ <label>
35
+ Email notification
36
+ </label>
37
+ </div>
38
+ <div class="field">
39
+ <div class="ui checkbox">
40
+ <label>
41
+ <%= f.check_box :subscribing_to_email, { checked: ActivityNotification.config.subscribe_as_default }, 'true', 'false' %>
42
+ <div class="slider"></div>
43
+ </label>
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <div class="ui button">
49
+ <button type="submit">Configure subscription</button>
50
+ </div>
51
+ <% end %>
52
+ </div>
53
+ <% end %>
54
+ </div>
55
+ <% else %>
56
+ <div class="fields_area">
57
+ <div class="fields_wrapper">
58
+ No notification keys are available.
59
+ </div>
60
+ </div>
61
+ <% end %>
62
+
63
+ <!--
64
+ <%# if notification_keys.present? %>
65
+ <%# notification_keys.each do |key| %>
66
+ Key: <%#= key %>
67
+ <%#= form_for(ActivityNotification::Subscription.new, as: :subscription, url: subscriptions_url_for(target, option_params), data: {remote: true}) do |f| %>
68
+ <%#= f.hidden_field :key, value: key %>
69
+ <div class="field">
70
+ <%#= f.label :subscribing, "Subscribe to this notification?" %>
71
+ <%#= f.check_box :subscribing, {checked: true}, 'true', 'false' %>
72
+ </div>
73
+ <div class="field">
74
+ <%#= f.label :subscribing_to_email, "Subscribe to this notification email?" %>
75
+ <%#= f.check_box :subscribing_to_email, {checked: true}, 'true', 'false' %>
76
+ </div>
77
+ <div class="actions">
78
+ <%#= f.submit "Save" %>
79
+ </div>
80
+ <%# end %>
81
+ <%#= link_to "See notifications", notifications_path_for(target, filtered_by_key: key) %>
82
+ <br/><br/>
83
+ <%# end %>
84
+ <%# else %>
85
+ No notification keys are available.
86
+ <%# end %>
87
+ <br/><br/>
88
+ -->
89
+
@@ -0,0 +1,73 @@
1
+ <div class="fields_wrapper configured">
2
+ <div class="fields_title_wrapper">
3
+ <h3 class="fields_title">
4
+ <%= subscription.key %>
5
+ </h3>
6
+
7
+ <p>
8
+ <%= link_to "Notifications", notifications_path_for(subscription.target, filtered_by_key: subscription.key) %>
9
+ </p>
10
+ </div>
11
+
12
+ <div class="field_wrapper subscribing">
13
+ <div class="field_label">
14
+ <label>
15
+ Notification
16
+ </label>
17
+ </div>
18
+ <div class="field">
19
+ <div class="ui checkbox">
20
+ <% if subscription.subscribing? %>
21
+ <%= link_to unsubscribe_path_for(subscription, option_params), onclick: '$(this).find("input").prop("checked", false);$(this).parent().parent().parent().next().slideUp();', method: :post, remote: true do %>
22
+ <%= check_box :subscribing, "", { checked: true }, 'true', 'false' %>
23
+ <div class="slider"></div>
24
+ <% end %>
25
+ <% else %>
26
+ <% if ActivityNotification.config.subscribe_as_default %>
27
+ <%= link_to subscribe_path_for(subscription, option_params), onclick: '$(this).find("input").prop("checked", true);$(this).parent().parent().parent().next().slideDown();$(this).parent().parent().parent().next().find("input").prop("checked", true);', method: :post, remote: true do %>
28
+ <%= check_box :subscribing, "", { checked: false }, 'true', 'false' %>
29
+ <div class="slider"></div>
30
+ <% end %>
31
+ <% else %>
32
+ <%= link_to subscribe_path_for(subscription, option_params.merge(with_email_subscription: false)), onclick: '$(this).find("input").prop("checked", true);$(this).parent().parent().parent().next().slideDown();', method: :post, remote: true do %>
33
+ <%= check_box :subscribing, "", { checked: false }, 'true', 'false' %>
34
+ <div class="slider"></div>
35
+ <% end %>
36
+ <% end %>
37
+ <% end %>
38
+ </div>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="field_wrapper subscribing_to_email <%= 'hidden' unless subscription.subscribing? %>">
43
+ <div class="field_label">
44
+ <label>
45
+ Email notification
46
+ </label>
47
+ </div>
48
+ <div class="field">
49
+ <div class="ui checkbox">
50
+ <% if subscription.subscribing_to_email? %>
51
+ <%= link_to unsubscribe_to_email_url_for(subscription, option_params), onclick: '$(this).find("input").prop("checked", false)', method: :post, remote: true do %>
52
+ <label>
53
+ <%= check_box :subscribing_to_email, "", { checked: true }, 'true', 'false' %>
54
+ <div class="slider"></div>
55
+ </label>
56
+ <% end %>
57
+ <% else %>
58
+ <%= link_to subscribe_to_email_url_for(subscription, option_params), onclick: '$(this).find("input").prop("checked", true)', method: :post, remote: true do %>
59
+ <label>
60
+ <%= check_box :subscribing_to_email, "", { checked: false }, 'true', 'false' %>
61
+ <div class="slider"></div>
62
+ </label>
63
+ <% end %>
64
+ <% end %>
65
+ </div>
66
+ </div>
67
+ </div>
68
+
69
+ <div class="ui button">
70
+ <%#= link_to "Show", subscription_path_for(subscription, option_params), class: "button" %>
71
+ <%= link_to "Destroy", subscription_path_for(subscription, option_params), method: :delete, remote: true, data: { confirm: 'Are you sure?' }, class: "button" %>
72
+ </div>
73
+ </div>
@@ -0,0 +1,13 @@
1
+ <% if subscriptions.present? %>
2
+ <div class="fields_area">
3
+ <% subscriptions.each do |subscription| %>
4
+ <%= render 'subscription', subscription: subscription, option_params: option_params %>
5
+ <% end %>
6
+ </div>
7
+ <% else %>
8
+ <div class="fields_area">
9
+ <div class="fields_wrapper">
10
+ No subscriptions are available.
11
+ </div>
12
+ </div>
13
+ <% end %>
@@ -0,0 +1,5 @@
1
+ $("#subscriptions").html("<%= escape_javascript( render 'subscriptions', subscriptions: @subscriptions, option_params: @index_options ) %>");
2
+ $("#notification_keys").html("<%= escape_javascript( render 'notification_keys', target: @target, notification_keys: @notification_keys, option_params: @index_options ) %>");
3
+ $("#subscription_form").html("<%= escape_javascript( render 'form', target: @target, option_params: @index_options ) %>");
4
+
5
+ loadSubscription();
@@ -0,0 +1,5 @@
1
+ $("#subscriptions").html("<%= escape_javascript( render 'subscriptions', subscriptions: @subscriptions, option_params: @index_options ) %>");
2
+ $("#notification_keys").html("<%= escape_javascript( render 'notification_keys', target: @target, notification_keys: @notification_keys, option_params: @index_options ) %>");
3
+ $("#subscription_form").html("<%= escape_javascript( render 'form', target: @target, option_params: @index_options ) %>");
4
+
5
+ loadSubscription();
@@ -0,0 +1,197 @@
1
+ <div class="subscription_wrapper">
2
+ <% unless @subscriptions.nil? %>
3
+ <div class="subscription_header">
4
+ <h1>Configured subscriptions</h1>
5
+ </div>
6
+ <div class="subscriptions" id="subscriptions">
7
+ <%= render 'subscriptions', subscriptions: @subscriptions, option_params: @index_options %>
8
+ </div>
9
+ <% end %>
10
+
11
+ <% unless @notification_keys.nil? %>
12
+ <div class="subscription_header">
13
+ <h1>Unconfigured notification keys</h1>
14
+ </div>
15
+ <div class="notification_keys" id="notification_keys">
16
+ <%= render 'notification_keys', target: @target, notification_keys: @notification_keys, option_params: @index_options %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <div class="subscription_header">
21
+ <h1>Create a new subscription</h1>
22
+ </div>
23
+ <div class="subscription_form" id="subscription_form">
24
+ <%= render 'form', target: @target, option_params: @index_options %>
25
+ </div>
26
+ </div>
27
+
28
+ <style>
29
+ .fields_area {
30
+ border: 1px solid #e5e5e5;
31
+ width: 600px;
32
+ box-sizing: border-box;
33
+ margin-bottom: 30px;
34
+ }
35
+
36
+ .fields_area .fields_wrapper {
37
+ position: relative;
38
+ background-color: #fff;
39
+ padding: 20px;
40
+ box-sizing: border-box;
41
+ border-bottom: 1px solid #e5e5e5;
42
+ }
43
+ .fields_area .fields_wrapper.configured {
44
+ background-color: #f8f9fb;
45
+ }
46
+
47
+ .fields_area .fields_wrapper:last-child {
48
+ border-bottom: none;
49
+ }
50
+
51
+ .fields_area .fields_wrapper .fields_title_wrapper {
52
+ margin-bottom: 16px;
53
+ border-bottom: none;
54
+ }
55
+
56
+ .fields_area .fields_wrapper .fields_title_wrapper .fields_title {
57
+ font-size: 16px;
58
+ font-weight: bold;
59
+ }
60
+
61
+ .fields_area .fields_wrapper .fields_title_wrapper p {
62
+ position: absolute;
63
+ top: 15px;
64
+ right: 15px;
65
+ }
66
+
67
+ .fields_area .fields_wrapper .field_wrapper {
68
+ margin-bottom: 16px;
69
+ }
70
+
71
+ .fields_area .fields_wrapper .field_wrapper:last-child {
72
+ margin-bottom: 0;
73
+ }
74
+
75
+ .fields_area .fields_wrapper .field_wrapper.hidden {
76
+ display: none;
77
+ }
78
+
79
+ .fields_area .fields_wrapper .field_wrapper .field_label {
80
+ margin-bottom: 8px;
81
+ }
82
+
83
+ .fields_area .fields_wrapper .field_wrapper .field_label label {
84
+ font-size: 14px;
85
+ }
86
+
87
+ .ui label {
88
+ font-size: 14px;
89
+ }
90
+
91
+ /* button */
92
+ .ui.button button,
93
+ .ui.button .button {
94
+ cursor: pointer;
95
+ color: #4f4f4f;
96
+ font-weight: bold;
97
+ font-size: 12px;
98
+ padding: 10px 14px;
99
+ margin-left: 10px;
100
+ border: 1px solid #e5e5e5;
101
+ background-color: #fafafa;
102
+ }
103
+
104
+ .ui.button button:first-child,
105
+ .ui.button .button:first-child {
106
+ margin-left: 0;
107
+ }
108
+
109
+ .ui.text_field input {
110
+ margin: 0;
111
+ outline: 0;
112
+ padding: 10px;
113
+ font-size: 14px;
114
+ border: 1px solid #e5e5e5;
115
+ border-radius: 3px;
116
+ box-shadow: 0 0 0 0 transparent inset;
117
+ }
118
+
119
+ /* checkbox */
120
+ .ui.checkbox {
121
+ position: relative;
122
+ left: 300px;
123
+ margin-top: -26px;
124
+ width: 40px;
125
+ }
126
+
127
+ .ui.checkbox input {
128
+ position: absolute;
129
+ margin-left: -9999px;
130
+ visibility: hidden;
131
+ }
132
+
133
+ .ui.checkbox .slider {
134
+ display: block;
135
+ position: relative;
136
+ cursor: pointer;
137
+ outline: none;
138
+ user-select: none;
139
+
140
+ padding: 2px;
141
+ width: 36px;
142
+ height: 20px;
143
+ background-color: #dddddd;
144
+ border-radius: 20px;
145
+ }
146
+
147
+ .ui.checkbox .slider:before,
148
+ .ui.checkbox .slider:after {
149
+ display: block;
150
+ position: absolute;
151
+ top: 1px;
152
+ left: 1px;
153
+ bottom: 1px;
154
+ content: "";
155
+ }
156
+
157
+ .ui.checkbox .slider:before {
158
+ right: 1px;
159
+ background-color: #f1f1f1;
160
+ border-radius: 20px;
161
+ transition: background 0.4s;
162
+ }
163
+
164
+ .ui.checkbox .slider:after {
165
+ width: 20px;
166
+ background-color: #fff;
167
+ border-radius: 100%;
168
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
169
+ transition: margin 0.4s;
170
+ }
171
+
172
+ .ui.checkbox input:checked + .slider:before {
173
+ background-color: #8ce196;
174
+ }
175
+
176
+ .ui.checkbox input:checked + .slider:after {
177
+ margin-left: 18px;
178
+ }
179
+ </style>
180
+
181
+ <script>
182
+ loadSubscription();
183
+ function loadSubscription() {
184
+ $(".field_wrapper.subscribing").find("input[type='checkbox']").change(function () {
185
+ $thisFieldWrapper = $(this).parent().parent().parent().parent();
186
+ if ($(this).prop('checked')) {
187
+ $thisFieldWrapper.next().slideDown();
188
+ $thisFieldWrapper.next().find("input[type='checkbox']").prop("checked", <%= ActivityNotification.config.subscribe_as_default %>);
189
+ } else {
190
+ $thisFieldWrapper.next().slideUp();
191
+ setTimeout(function () {
192
+ $thisFieldWrapper.next().find("input[type='checkbox']").prop("checked", false);
193
+ }, 400);
194
+ }
195
+ })
196
+ }
197
+ </script>