Permalink
Browse files

Bring in another announcement helper for signed out users, use jquery…

… for javascript instead and cookie setters.
  • Loading branch information...
1 parent e7e5fcf commit 772d52efb3ca7ac3685b2974217ce00d0b73ba4f @qrush qrush committed Oct 13, 2010
@@ -7,5 +7,3 @@ def current_announcement
@current_announcement ||= Announcement.current
end
end
-
-
@@ -0,0 +1,9 @@
+<% if current_announcement.exists? and not announcement_hidden?(current_announcement) %>
+ <div id="announcement">
+ <%= current_announcement.body %>
+ <div class="hide">
+ <%= link_to_function "hide", "hideAnnouncement('announcement_#{current_announcement.created_at}');" %>
+ </div>
+ </div>
+<% end %>
+
@@ -1,6 +1,15 @@
-
function hideAnnouncement(announcement_created_at) {
- setCookie(announcement_created_at, 'hidden');
- $("announcement").fade();
+ createCookie(announcement_created_at, 'hidden', 1);
+ $("#announcement").slideUp();
}
+// http://www.quirksmode.org/js/cookies.html
+function createCookie(name,value,days) {
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime()+(days*24*60*60*1000));
+ var expires = "; expires="+date.toGMTString();
+ }
+ else var expires = "";
+ document.cookie = name+"="+value+expires+"; path=/";
+}

0 comments on commit 772d52e

Please sign in to comment.