Add JS for dismissing announcements
This commit is contained in:
parent
80c6a4272a
commit
4889071f95
|
@ -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/
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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/
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue