Skip to content

Commit 1fa2058

Browse files
author
Jacques Crocker
committedDec 28, 2015
add ability to close subscribe form
1 parent 47b410b commit 1fa2058

File tree

7 files changed

+32
-1
lines changed

7 files changed

+32
-1
lines changed
 

‎app-css/components/list-subscriber-form.css.sass

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
color: #fff
1616
text-shadow: 0 0 3px rgba(#000, 0.5)
1717

18+
.close-subscribe-form
19+
position: absolute
20+
right: 10px
21+
top: 18px
22+
cursor: pointer
23+
z-index: 100
24+
opacity: 0.3
25+
i
26+
font-size: 20px
27+
1828
label, .form-control
1929
display: inline-block
2030
margin-top: 3px
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(() => {
2+
3+
$(document).on("click", ".close-subscribe-form", (e) => {
4+
e.preventDefault();
5+
Cookies.set('hide_subscribe', true, { expires: 90 });
6+
$(e.target).closest(".list-subscriber-form").slideUp("fast")
7+
});
8+
9+
})();

‎app-js/vendor/js.cookie-2.0.4.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/assets/javascripts/dependencies.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
//= require lodash
1717
//= require vendor/lodash-inflection
1818
//= require bootstrap
19+
//= require vendor/js.cookie-2.0.4.min

‎app/helpers/application_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,8 @@ def content_nav_link(title, action)
136136
link_to title, url_for(controller: "pages", action: action)
137137
end
138138
end
139+
140+
def show_subcribe_form?
141+
current_subscriber.blank? and !cookies[:hide_subscribe]
142+
end
139143
end

‎app/views/list_subscribers/_subscribe_form.html.erb

+4
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
</span>
1212
<% end %>
1313
</div>
14+
15+
<span class="close-subscribe-form">
16+
<i class="fa fa-times"></i>
17+
</span>
1418
</div>

‎app/views/projects/index.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
= auto_discovery_link_tag(:atom, format: :atom, controller: :projects, action: :recent)
88

99

10-
- unless current_subscriber.present?
10+
- if show_subcribe_form?
1111
- content_for :after_header do
1212
= render "list_subscribers/subscribe_form"
1313

0 commit comments

Comments
 (0)
Please sign in to comment.