Skip to content

Commit

Permalink
fixed js and template stuff, front-end pieces still fritzing
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityrail committed Mar 11, 2011
1 parent aa3006a commit 3c359d4
Show file tree
Hide file tree
Showing 21 changed files with 457 additions and 31 deletions.
15 changes: 0 additions & 15 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ class ApplicationController < ActionController::Base

protect_from_forgery

rescue_from(Exception) do |e|
#TODO: Flash something?
flash[:alert] = e.message
logger.error "Error: '#{e.message}'"

respond_to do |format|
format.html { redirect_to :back }
format.js {
render :update do |page|
page.redirect_to(:back)
end
}
end
end

protected

SHOW_LIMIT = 10
Expand Down
22 changes: 21 additions & 1 deletion app/controllers/issues_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
class IssuesController < ApplicationController

#custom exception handler puts errors in the pop-down flash area
rescue_from(VoteException) do |e|
#TODO: Flash something?

flash[:alert] = e.inspect
logger.error "Error: '#{e.message}'"
e.backtrace

respond_to do |format|
format.html { redirect_to :back }
format.js {
render :update do |page|
page.redirect_to(:back)
end
}
end
end

def show
@issue = Issue.find(params[:id])
Expand Down Expand Up @@ -47,10 +64,13 @@ def vote
return
end

#@issue.add_vote_for_user(current_user)

begin
@issue.add_vote_for_user(current_user)
rescue Exception => e
flash[:alert] = e.message

flash[:alert] = e.inspect
puts e.backtrace
logger.warn(flash[:alert])

Expand Down
2 changes: 1 addition & 1 deletion app/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.find_similar(report)
def add_vote_for_user(user)

unless(user.votes_remaining > 0)
throw 'Not enough votes. Please return in a few hours to vote on more issues.'
throw VoteException.new('Not enough votes. Please return in a few hours to vote on more issues.')
end

@vote = votes.create({:user => user})
Expand Down
3 changes: 3 additions & 0 deletions app/models/kajoo_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class KajooException < Exception

end
2 changes: 1 addition & 1 deletion app/models/solution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Solution < ActiveRecord::Base

def add_vote_for_user(user)
unless(user.votes_remaining > 0)
throw Exception.new('Not enough votes')
throw VoteException.new('Not enough votes')
end

@vote = votes.create({:user => current_user})
Expand Down
3 changes: 3 additions & 0 deletions app/models/vote_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class VoteException < KajooException

end
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
<body>

<div id="wrapper" class="container_24">
<% if notice %><div class="grid_24"><div class="flash_message" id="flash_notice"><%= notice %></div></div><% end %>
<% if alert %><div class="grid_24"><div class="flash_message" id="flash_alert"><%= alert %></div></div><% end %>
<div id="notices">
<div class="grid_24"><% if notice %><div class="flash_message" id="flash_notice"><%= notice %></div><% end %></div>
<div class="grid_24"><% if alert %><div class="flash_message" id="flash_alert"><%= alert %></div><% end %></div>
</div>
<div id="header" class="container_24"><!--Header starts-->
<%= render :partial => 'shared/navigation' %>
</div><!--closes header--><div class="clear"></div>
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions app/views/reports/new.js.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
$("#flash_notice").html("<%= escape_javascript(flash[:notice])%>").show();
$("#alert_notice").html("<%= escape_javascript(flash[:alert])%>").show();

$('#flash_notice').delay(2000).slideUp(1000);
$('#alert_notice').delay(2000).slideUp(1000);
$('#notices').show().delay(2000).slideUp(1000);

$('#feature').slideUp(1000).html("<%= escape_javascript(render :partial => 'form')%>").slideDown(1000);
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions config/initializers/dragonfly

This file was deleted.

2 changes: 2 additions & 0 deletions config/initializers/dragonfly.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'dragonfly/rails/images'

2 changes: 1 addition & 1 deletion config/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ development: &default
state_name: 'Texas'
country_name: 'United States'
site_name: 'SXSW Civic Hackathon'
daily_vote_limit: 5
daily_vote_limit: 100

test: &test
<<: *default
Expand Down
26 changes: 23 additions & 3 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,34 @@ $(document).ready(function(){

//fade out alerts

$('#flash_notice').delay(2000).slideUp(1000);
$('#flash_alert').delay(2000).slideUp(1000);
$('#notices').delay(2000).slideUp(1000);
// $('#flash_alert').delay(2000).slideUp(1000);

//fixed positioning for iPhone
//$(window).bind( "scroll", maybeShowNavBar );
});

$.fn.animateHighlight = function(highlightColor, duration) {
var highlightBg = highlightColor || "#FFFF9C";
var animateMs = duration || 1500;
var originalBg = this.css("backgroundColor");
this.stop().css("background-color", highlightBg).animate({backgroundColor: originalBg}, animateMs);
};
};

function showNavBar() {
var win_y = $(window).height();
var scroll_y = $(window).scrollTop();
$("footer").css({ top: ((win_y - 36) + scroll_y) + "px" });
$("header").css({ top: scroll_y + "px" });
}

var showTimer = false;

function maybeShowNavBar(evt) {
if ( showTimer ) {
clearTimeout( showTimer );
}
showTimer = setTimeout( showNavBar, 175 );
}


Loading

0 comments on commit 3c359d4

Please sign in to comment.