This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from amarshall/tabs
Tabs & more
- Loading branch information
Showing
13 changed files
with
178 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
<!DOCTYPE html> | ||
!!! 5 | ||
%html | ||
%head | ||
%title== Pivot Pong - #{location} | ||
%title Pivot Pong #{location} — #{yield :title} | ||
= stylesheet_link_tag 'reset', 'pong', 'jquery.autocomplete' | ||
= javascript_include_tag :defaults | ||
= javascript_include_tag 'jquery.autocomplete' | ||
= javascript_include_tag 'jquery.autocomplete', 'jquery.tabs' | ||
= javascript_include_tag "http://use.typekit.com/rol0dzy.js" | ||
= javascript_tag "try{Typekit.load();}catch(e){}" | ||
= favicon_link_tag | ||
= csrf_meta_tag | ||
|
||
%body | ||
#page | ||
#content | ||
%h1== pivot pong #{location.downcase} | ||
= render 'shared/flash_messages' | ||
= yield | ||
= link_to "source code", "https://github.com/seanmoon/pivot-pong", class: "source" | ||
%header | ||
%h1 pivot pong #{location.downcase} | ||
%nav | ||
= link_to_with_current "Rankings", root_path | ||
= link_to_with_current "Matches", matches_path | ||
|
||
= render 'shared/flash_messages' | ||
= yield | ||
%footer | ||
= link_to "source code", "https://github.com/seanmoon/pivot-pong" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
%h2 Rankings | ||
- content_for :title, "Rankings" | ||
|
||
%nav | ||
= link_to "Matches", matches_path | ||
.tabs | ||
%ul.tab-bar | ||
%li= link_to "All time", "#all-time" | ||
%li= link_to "Last 30 days", "#30-days" | ||
%li= link_to "Last 90 days", "#90-days" | ||
|
||
%h1 All time | ||
%ol.rankings | ||
- @rankings.each do |player| | ||
%li{class: cycle("even", "odd")}= player.display_name | ||
%ol#all-time.rankings | ||
- @rankings.each do |player| | ||
%li{class: cycle("even", "odd")}= player.display_name | ||
|
||
%h1 Last 30 days | ||
%ol.rankings | ||
- @last_30_days_rankings.each do |player| | ||
%li{class: cycle("even", "odd")}= player | ||
- reset_cycle | ||
|
||
%h1 Last 90 days | ||
%ol.rankings | ||
- @last_90_days_rankings.each do |player| | ||
%li{class: cycle("even", "odd")}= player | ||
%ol#30-days.rankings | ||
- @last_30_days_rankings.each do |player| | ||
%li{class: cycle("even", "odd")}= player | ||
|
||
%nav | ||
= link_to "Matches", matches_path | ||
- reset_cycle | ||
|
||
%ol#90-days.rankings | ||
- @last_90_days_rankings.each do |player| | ||
%li{class: cycle("even", "odd")}= player |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
- if notice || alert | ||
.flash | ||
- if notice | ||
.notice | ||
= notice | ||
.notice= notice | ||
- if alert | ||
.alert | ||
= alert | ||
.alert= alert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
$(document).ready( function(){ | ||
$('#new_match input[type=text]').autocomplete('/matches/players'); | ||
}); | ||
$('.tab-bar').tabs(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(function($) { | ||
$.fn.tabs = function() { | ||
var $this = $(this); | ||
var tabs = []; | ||
$this.data("currentTab", $("<p></p>")); | ||
|
||
var switchToTab = function(elem) { | ||
console.log(elem); | ||
$elem = $(elem); | ||
current = $this.data("currentTab"); | ||
$(current).hide(); | ||
$("a[href='" + current + "']").removeClass("current"); | ||
$elem.show(); | ||
$("a[href='" + elem + "']").addClass("current"); | ||
$this.data("currentTab", elem); | ||
} | ||
|
||
$this.children().each(function() { | ||
var link = $(this).find("a").first(); | ||
var id = link.attr("href"); | ||
tabs.push(id); | ||
$(id).hide(); | ||
link.click(function(e) { | ||
e.preventDefault(); | ||
switchToTab(id); | ||
}); | ||
}); | ||
|
||
switchToTab(tabs[0]); | ||
|
||
return this; | ||
} | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
require 'spec_helper' | ||
|
||
describe ApplicationHelper do | ||
describe "#link_to_with_current" do | ||
let(:name) { "My Link" } | ||
let(:url) { "/the/url" } | ||
subject { helper.link_to_with_current(name, url) } | ||
|
||
context "when the URL is the current page" do | ||
before { view.stub(:current_page?) { true } } | ||
|
||
it { should include('class="current"') } | ||
end | ||
|
||
context "when the URL is not the current page" do | ||
before { view.stub(:current_page?) { false } } | ||
|
||
it { should_not include('class="current"') } | ||
end | ||
end | ||
|
||
describe "#location" do | ||
subject { helper.location } | ||
|
||
context "when no location is configured" do | ||
it "returns nyc" do | ||
helper.location.should == "NYC" | ||
end | ||
it { should == "NYC" } | ||
end | ||
|
||
context "when a location is configured" do | ||
before do | ||
ENV["PIVOT_PONG_LOCATION"] = "Starbase Alpha" | ||
end | ||
|
||
it "returns that location" do | ||
helper.location.should == "Starbase Alpha" | ||
end | ||
|
||
it { should == "Starbase Alpha" } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.