Permalink
Browse files

messy way of hiding proposals already rated or not rated

  • Loading branch information...
1 parent ed8748b commit cf018a05fbc30f662ee482f9f680569f5d23153d @paulanthonywilson paulanthonywilson committed Mar 19, 2012
View
4 app/assets/stylesheets/application.css
@@ -235,6 +235,10 @@ em {
font-weight: bolder
}
+.hideshow {
+ margin: 10px;
+}
+
/* forms */
#rating form{margin: 20px 0; border-top: 1px dotted #ccc; padding-top: 10px;}
#rating form .row{margin: 0 0 5px 0;}
View
4 app/helpers/application_helper.rb
@@ -1,9 +1,9 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def logoff_link
- link_to 'logoff', reviewer_session_path(session[:reviewer]), {:method=>:delete, :id => 'logout'} if session[:reviewer]
+ button_to 'logoff', reviewer_session_path(session[:reviewer]), :method=>:delete, :id => 'logout' if session[:reviewer]
end
-
+
def admin?
session[:reviewer] && session[:reviewer].admin
end
View
5 app/helpers/proposals_helper.rb
@@ -22,6 +22,11 @@ def in_paragraphs(text)
Kramdown::Document.new(text).to_html.html_safe
end
+ def proposals_class(proposal)
+ rating_class = rating(proposal) ? "rated" : "unrated"
+ "proposal #{rating_class}"
+ end
+
def sort_proposals_by(text,param)
css_class = (params[:sort] == param) ? ' active' : ''
link_to text, proposals_path(:sort => param), :class => "sortable#{css_class}"
View
75 app/views/proposals/index.html.erb
@@ -1,19 +1,64 @@
<h1>Proposals</h1>
-
+<div class="hideshow">
+ Hide rated: <input id="hide-rated" type="checkbox">
+ Hide unrated: <input id="hide-unrated" type="checkbox">
+</div>
<table id="summary">
-<th></th>
-<th>Proposal</th>
-<th>Speakers</th>
-<th>Description</th>
-<th>Score</th>
-<% @proposals.each_with_index do |proposal, i| %>
-<tr class="proposal">
- <td><%= i + 1 %>.</td>
- <td class="title"><%= link_to proposal.title, proposal %></td>
- <td class="presenters"> <%= proposal.presenter.name %> </td>
- <td class="description"> <%= short(proposal.description, 200)%></td>
- <td class="score"><%= rating(proposal)%></td>
-</tr>
-<% end %>
+ <th></th>
+ <th>Proposal</th>
+ <th>Speakers</th>
+ <th>Description</th>
+ <th>Score</th>
+ <% @proposals.each_with_index do |proposal, i| %>
+ <tr class="<%= proposals_class proposal%>">
+ <td><%= i + 1 %>.</td>
+ <td class="title"><%= link_to proposal.title, proposal %></td>
+ <td class="presenters"> <%= proposal.presenter.name %> </td>
+ <td class="description"> <%= short(proposal.description, 200)%></td>
+ <td class="score"><%= rating(proposal)%></td>
+ </tr>
+ <% end %>
</table>
+
+<script>
+ $(
+ function(){
+ var hideShow = function(name){
+ if($.cookie(name) === 'true'){
+ $('#' + name).attr('checked', 'true');
+ } else {
+ $('#' + name).removeAttr('checked');
+ }};
+
+ var changeFunction = function(name){
+ return function(el){
+ if($(el.target).attr('checked')){
+ $.cookie(name, 'true');
+ } else {
+ $.cookie(name, 'false');
+ }
+ hideUnhide();
+ };
+ };
+
+ hideShow("hide-rated");
+ hideShow("hide-unrated");
+
+ $('#hide-rated').change(changeFunction('hide-rated'));
+ $('#hide-unrated').change(changeFunction('hide-unrated'));
+
+ var hideUnhide = function(){
+ if($.cookie('hide-rated') === 'true'){
+ $('.rated').hide();
+ } else {
+ $('.rated').show();
+ }
+ if($.cookie('hide-unrated') === 'true'){
+ $('.unrated').hide();
+ } else {
+ $('.unrated').show();
+ }
+ };
+ })
+</script>

0 comments on commit cf018a0

Please sign in to comment.