Permalink
Browse files

add cookie check on non-widget voting page

  • Loading branch information...
1 parent 6e6fd83 commit 5a5a5b967e48b982bf3e78f2d3248fcc5ba0cdd7 @lukebaker lukebaker committed Aug 12, 2013
Showing with 46 additions and 1 deletion.
  1. +25 −0 app/views/earls/show.html.haml
  2. +20 −0 public/stylesheets/sass/styles.scss
  3. +1 −1 public/stylesheets/styles.css
View
25 app/views/earls/show.html.haml
@@ -9,6 +9,13 @@
- bg_color = ab_test("bg_color_aa_#{@earl.name}", ['#F2F2F2', '#F2F2F1'], :conversion => 'voted')
.tab-content.question-vote.row-fluid{:style => "background-color: #{bg_color}"}
+ #cookies-failed{:style => "display: none;"}
+ %div
+ %h2 Cookies Blocked
+ %p
+ = link_to("Cookies are required", 'http://blog.allourideas.org/post/54515392435/cookies')
+ for voting, and it looks like cookies may be disabled in your browser.
+ In order to vote, you should enable cookies in your browser.
-if !session[:has_voted] && session[:welcome_msg]
.row-fluid
.span10.offset1.welcome-message
@@ -92,6 +99,24 @@
-content_for :view_javascript do
+ :plain
+ // Test if we can set and read cookies.
+ // If we can't, then the browser probably has 3rd party cookies disabled
+ // unless the user has first navigated to the domain serving the iframe source.
+ var cookieValue = "cookieTest" + new Date().getTime();
+ document.cookie = "cookieTest="+cookieValue;
+ if (document.cookie.indexOf("cookieTest="+cookieValue) === -1) {
+ var cookies_failed = document.getElementById('cookies-failed');
+ if (cookies_failed) {
+ cookies_failed.style.display = 'block';
+ var img = new Image();
+ img.src = '/cookies_blocked.gif?question_id=#{@earl.question_id}&session_id=#{@user_session.session_id}&referrer=' + encodeURIComponent(document.referrer);
+ }
+ }
+ else {
+ // cleanup test cookie
+ document.cookie = 'cookieTest=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
+ }
$('.rounded').corner('5px');
-unless session[:has_voted]
:plain
View
20 public/stylesheets/sass/styles.scss
@@ -112,6 +112,26 @@ form#new_question_form{
border-radius: 7px;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
+ position: relative;
+}
+#cookies-failed {
+ position: absolute;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0,0,0, 0.8);
+ border-radius: 7px;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+
+ >div {
+ margin: 4em 4em;
+ padding: 1em;
+ background-color: #ffffff;
+ border-radius: 7px;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+ }
}
.interior-content {
background-color: white;
View
2 public/stylesheets/styles.css
@@ -11,4 +11,4 @@
*
*/.container-fluid{max-width:1200px;margin-right:auto;margin-left:auto}/*
* AOI CSS
- */html{-webkit-overflow-scrolling:touch}body.modal-open{overflow:hidden}.logo{margin-top:1em}@media (max-width: 767px){h2{font-size:21px;line-height:30px}}@media (max-width: 767px){.pagination ul li.current{display:none}}.navbar-static-top{width:auto;min-width:100%}form#new_question_form fieldset legend{padding-top:1em}.vote-tabs{margin-bottom:0;border-bottom:none;padding-right:2em}.vote-tabs>li.active>a,.vote-tabs>li.active a:hover{background-color:#F2F2F2}.tab-content{background-color:#F2F2F2;padding:2em 0;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px}.interior-content{background-color:white;margin:0 2em;padding:0 2em;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px}@media (max-width: 767px){.welcome-message .alert{margin-left:5%;margin-right:5%}}.vote-question{text-align:center}@media (max-width: 480px){.vote-question{font-size:18px;line-height:24px}}@media (max-width: 767px){.vote-question{margin:0 5%}}@media (max-width: 767px){.answers{margin:0;padding:0 5%;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.answers li{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-left:auto;margin-right:auto;margin-bottom:1em}}.vote_stats{text-align:center;color:#666666;font-size:12px;clear:both}.btn-vote{display:table-cell;vertical-align:middle;min-height:8em;width:100%}@media (max-width: 480px){.btn-vote{font-size:16px}}.cant_decide{text-align:center}@media (max-width: 767px){#cant_decide_btn{width:intrinsic;min-width:50%;display:block;margin-left:auto;margin-right:auto}}#cant_decide_options button.btn-primary,#cant_decide_options button.btn-vote{width:100%;min-height:3.6em}@media (min-width: 1200px){#cant_decide_options{width:600px}}@media (max-width: 979px) and (min-width: 768px){#cant_decide_options{width:500px}#cant_decide_options .span6{width:100%;margin-left:0}}@media (max-width: 767px){#cant_decide_options{position:fixed;top:10px;bottom:10px;left:10px;right:10px;width:auto}#cant_decide_options h2{font-size:14px;line-height:21px}#cant_decide_options button.btn-primary,#cant_decide_options button.btn-vote{min-height:auto}#cant_decide_options .modal-body{bottom:0px;top:60px;position:absolute;max-height:100%;height:auto;-webkit-overflow-scrolling:touch}#cant_decide_options .close{font-size:40px;line-height:30px}}#the_add_box h3{color:#367bbe}#the_add_box #new_idea_field{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;min-height:4em}.choice-progress .progress{width:85%;float:left;margin-right:1em}@media (max-width: 767px){#data-vis{display:none;visibility:hidden}}@media (max-width: 767px){body .row-fluid .offset1{margin-left:0}body .row-fluid .offset1:first-child{margin-left:0}body .row-fluid .offset2{margin-left:0}body .row-fluid .offset2:first-child{margin-left:0}body .row-fluid .offset3{margin-left:0}body .row-fluid .offset3:first-child{margin-left:0}body .row-fluid .offset4{margin-left:0}body .row-fluid .offset4:first-child{margin-left:0}body .row-fluid .offset5{margin-left:0}body .row-fluid .offset5:first-child{margin-left:0}body .row-fluid .offset6{margin-left:0}body .row-fluid .offset6:first-child{margin-left:0}body .row-fluid .offset7{margin-left:0}body .row-fluid .offset7:first-child{margin-left:0}body .row-fluid .offset8{margin-left:0}body .row-fluid .offset8:first-child{margin-left:0}body .row-fluid .offset9{margin-left:0}body .row-fluid .offset9:first-child{margin-left:0}body .row-fluid .offset10{margin-left:0}body .row-fluid .offset10:first-child{margin-left:0}body .row-fluid .offset11{margin-left:0}body .row-fluid .offset11:first-child{margin-left:0}body .row-fluid .offset12{margin-left:0}body .row-fluid .offset12:first-child{margin-left:0}body.container-fluid{padding-left:1em;padding-right:1em}}ul.footer-social-icons{list-style:none;margin-left:0;overflow:hidden;width:128px}ul.footer-social-icons li a{display:block;text-indent:-9999px;background:url(/images/social_icons.png) no-repeat;float:left;width:32px;height:32px;white-space:nowrap}ul.footer-social-icons li.fb a:hover{background-position:0 -32px}ul.footer-social-icons li.twitter a{background-position:-40px 0}ul.footer-social-icons li.twitter a:hover{background-position:-40px -32px}ul.footer-social-icons li.github a{background-position:-80px 0}ul.footer-social-icons li.github a:hover{background-position:-80px -32px}ul.footer-social-icons li.blog a{background-position:-120px 0}ul.footer-social-icons li.blog a:hover{background-position:-120px -32px}.navbar .brand{padding-top:1px;padding-bottom:1px}.powered-by{text-indent:-9999px;display:block;width:139px;height:29px;background:url(/images/powered-by-aoi.gif) no-repeat;font-size:0}.powered-by:hover{background-position:0 -29px}@media (max-width: 767px){.footer{margin-left:-20px;margin-right:-20px;text-align:center}.footer .powered-by{margin:0 auto}.footer .footer-right{float:none}.footer .footer-social-icons{margin:0 auto}.footer .generous-grantees{margin-bottom:40px}}.tooltip{font-size:14px}
+ */html{-webkit-overflow-scrolling:touch}body.modal-open{overflow:hidden}.logo{margin-top:1em}@media (max-width: 767px){h2{font-size:21px;line-height:30px}}@media (max-width: 767px){.pagination ul li.current{display:none}}.navbar-static-top{width:auto;min-width:100%}form#new_question_form fieldset legend{padding-top:1em}.vote-tabs{margin-bottom:0;border-bottom:none;padding-right:2em}.vote-tabs>li.active>a,.vote-tabs>li.active a:hover{background-color:#F2F2F2}.tab-content{background-color:#F2F2F2;padding:2em 0;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;position:relative}#cookies-failed{position:absolute;top:0;width:100%;height:100%;background-color:rgba(0,0,0,0.8);border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px}#cookies-failed>div{margin:4em 4em;padding:1em;background-color:#ffffff;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px}.interior-content{background-color:white;margin:0 2em;padding:0 2em;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px}@media (max-width: 767px){.welcome-message .alert{margin-left:5%;margin-right:5%}}.vote-question{text-align:center}@media (max-width: 480px){.vote-question{font-size:18px;line-height:24px}}@media (max-width: 767px){.vote-question{margin:0 5%}}@media (max-width: 767px){.answers{margin:0;padding:0 5%;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.answers li{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-left:auto;margin-right:auto;margin-bottom:1em}}.vote_stats{text-align:center;color:#666666;font-size:12px;clear:both}.btn-vote{display:table-cell;vertical-align:middle;min-height:8em;width:100%}@media (max-width: 480px){.btn-vote{font-size:16px}}.cant_decide{text-align:center}@media (max-width: 767px){#cant_decide_btn{width:intrinsic;min-width:50%;display:block;margin-left:auto;margin-right:auto}}#cant_decide_options button.btn-primary,#cant_decide_options button.btn-vote{width:100%;min-height:3.6em}@media (min-width: 1200px){#cant_decide_options{width:600px}}@media (max-width: 979px) and (min-width: 768px){#cant_decide_options{width:500px}#cant_decide_options .span6{width:100%;margin-left:0}}@media (max-width: 767px){#cant_decide_options{position:fixed;top:10px;bottom:10px;left:10px;right:10px;width:auto}#cant_decide_options h2{font-size:14px;line-height:21px}#cant_decide_options button.btn-primary,#cant_decide_options button.btn-vote{min-height:auto}#cant_decide_options .modal-body{bottom:0px;top:60px;position:absolute;max-height:100%;height:auto;-webkit-overflow-scrolling:touch}#cant_decide_options .close{font-size:40px;line-height:30px}}#the_add_box h3{color:#367bbe}#the_add_box #new_idea_field{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;min-height:4em}.choice-progress .progress{width:85%;float:left;margin-right:1em}@media (max-width: 767px){#data-vis{display:none;visibility:hidden}}@media (max-width: 767px){body .row-fluid .offset1{margin-left:0}body .row-fluid .offset1:first-child{margin-left:0}body .row-fluid .offset2{margin-left:0}body .row-fluid .offset2:first-child{margin-left:0}body .row-fluid .offset3{margin-left:0}body .row-fluid .offset3:first-child{margin-left:0}body .row-fluid .offset4{margin-left:0}body .row-fluid .offset4:first-child{margin-left:0}body .row-fluid .offset5{margin-left:0}body .row-fluid .offset5:first-child{margin-left:0}body .row-fluid .offset6{margin-left:0}body .row-fluid .offset6:first-child{margin-left:0}body .row-fluid .offset7{margin-left:0}body .row-fluid .offset7:first-child{margin-left:0}body .row-fluid .offset8{margin-left:0}body .row-fluid .offset8:first-child{margin-left:0}body .row-fluid .offset9{margin-left:0}body .row-fluid .offset9:first-child{margin-left:0}body .row-fluid .offset10{margin-left:0}body .row-fluid .offset10:first-child{margin-left:0}body .row-fluid .offset11{margin-left:0}body .row-fluid .offset11:first-child{margin-left:0}body .row-fluid .offset12{margin-left:0}body .row-fluid .offset12:first-child{margin-left:0}body.container-fluid{padding-left:1em;padding-right:1em}}ul.footer-social-icons{list-style:none;margin-left:0;overflow:hidden;width:128px}ul.footer-social-icons li a{display:block;text-indent:-9999px;background:url(/images/social_icons.png) no-repeat;float:left;width:32px;height:32px;white-space:nowrap}ul.footer-social-icons li.fb a:hover{background-position:0 -32px}ul.footer-social-icons li.twitter a{background-position:-40px 0}ul.footer-social-icons li.twitter a:hover{background-position:-40px -32px}ul.footer-social-icons li.github a{background-position:-80px 0}ul.footer-social-icons li.github a:hover{background-position:-80px -32px}ul.footer-social-icons li.blog a{background-position:-120px 0}ul.footer-social-icons li.blog a:hover{background-position:-120px -32px}.navbar .brand{padding-top:1px;padding-bottom:1px}.powered-by{text-indent:-9999px;display:block;width:139px;height:29px;background:url(/images/powered-by-aoi.gif) no-repeat;font-size:0}.powered-by:hover{background-position:0 -29px}@media (max-width: 767px){.footer{margin-left:-20px;margin-right:-20px;text-align:center}.footer .powered-by{margin:0 auto}.footer .footer-right{float:none}.footer .footer-social-icons{margin:0 auto}.footer .generous-grantees{margin-bottom:40px}}.tooltip{font-size:14px}

0 comments on commit 5a5a5b9

Please sign in to comment.