diff --git a/app/assets/javascripts/announcement.coffee b/app/assets/javascripts/announcement.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/announcement.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/application.js.erb.coffee b/app/assets/javascripts/application.js.erb.coffee index b135cf66..73e9ef73 100644 --- a/app/assets/javascripts/application.js.erb.coffee +++ b/app/assets/javascripts/application.js.erb.coffee @@ -74,6 +74,16 @@ _ready = -> lineColor: bodyColor density: 23000 + $(".alert-announcement").each -> + aId = $(this)[0].dataset.announcementId + unless (window.localStorage.getItem("announcement#{aId}")) + $(this).toggleClass("hidden") + + $(document).on "click", ".alert-announcement button.close", (evt) -> + announcement = event.target.closest(".alert-announcement") + aId = announcement.dataset.announcementId + window.localStorage.setItem("announcement#{aId}", true) + $('.arctic_scroll').arctic_scroll speed: 500 diff --git a/app/assets/stylesheets/announcement.scss b/app/assets/stylesheets/announcement.scss deleted file mode 100644 index e922d541..00000000 --- a/app/assets/stylesheets/announcement.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the announcement controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/views/layouts/_profile.html.haml b/app/views/layouts/_profile.html.haml index d01c7293..519195db 100644 --- a/app/views/layouts/_profile.html.haml +++ b/app/views/layouts/_profile.html.haml @@ -28,6 +28,10 @@ %a{href: pghero_path} %i.fa.fa-fw.fa-database Database Monitor + %li + %a{href: announcement_index_path} + %i.fa.fa-fw.fa-info + Announcements %li.divider - if current_user.mod? %li diff --git a/app/views/shared/_announcements.haml b/app/views/shared/_announcements.haml index 6885694d..99fa74d6 100644 --- a/app/views/shared/_announcements.haml +++ b/app/views/shared/_announcements.haml @@ -1,6 +1,8 @@ .container.announcements - @active_announcements.each do |announcement| - .alert.alert-announcement + .alert.alert-announcement.alert-info.alert-dismissable.hidden{ data: { 'announcement-id': announcement.id } } + %button.close{ type: "button", "data-dismiss" => "alert" } + %span{ "aria-hidden" => "true" } × %p= announcement.content - if announcement.link_present? %a.alert-link{ href: announcement.link_href }= announcement.link_text