diff --git a/app/assets/javascripts/announcements.js.coffee b/app/assets/javascripts/announcements.js.coffee new file mode 100644 --- /dev/null +++ b/app/assets/javascripts/announcements.js.coffee @@ -0,0 +1,15 @@ +#js for announcement +$ -> + $('.ajax-toggle').on 'click', (event) -> + console.log event.target.id + target = $(event.target) + target.removeClass 'btn-default' + target.removeClass 'btn-success' + target.addClass 'btn-warning' + target.text '...' + return + + $(document).ajaxError (event, jqxhr, settings, exception) -> + if jqxhr.status + alert 'We\'re sorry, but something went wrong (' + jqxhr.status + ')' + return diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -85,17 +85,17 @@ border-bottom: 1px solid #eeeeee -a - color: #6666cc - text-decoration: none - - &:link, &:visited - color: #6666cc - text-decoration: none - - &:hover, &:focus - color: #111166 - text-decoration: none +//#a +// color: #6666cc +// text-decoration: none +// +// &:link, &:visited +// color: #6666cc +// text-decoration: none +// +// &:hover, &:focus +// color: #111166 +// text-decoration: none div diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -81,7 +81,7 @@ def toggle @announcement = Announcement.find(params[:id]) - @announcement.update_attributes( published: params[:published] == 1) + @announcement.update_attributes( published: !@announcement.published? ) respond_to do |format| format.js {} end diff --git a/app/views/announcements/index.html.erb b/app/views/announcements/index.html.erb deleted file mode 100644 --- a/app/views/announcements/index.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -
Updated | -Announcement | -Author | -Published | -- | - | - |
---|---|---|---|---|---|---|
<%= time_ago_in_words announcement.updated_at %> | -
- <% if !announcement.title.blank? %>
- Title: <%=h announcement.title %> - <% end %> - <% if !announcement.notes.blank? %> - Notes: <%=h announcement.notes %> - <% end %> - <%=h announcement.body %> - |
- <%=h announcement.author %> | -<%= check_box_tag :published, 1, announcement.published, { class: 'bootstrap-toggle', id: "published-#{announcement.id}", data: {remote: true, method: 'PUT', url: url_for(controller: :announcements, action: :toggle, id: announcement), size: 'small', toggle: 'toggle' } } %> | - -<%= link_to 'Show', announcement %> | -<%= link_to 'Edit', edit_announcement_path(announcement) %> | -<%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %> | -