-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Blair Anderson
committed
Mar 16, 2015
1 parent
6d3224b
commit f63e2f0
Showing
27 changed files
with
1,344 additions
and
127 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
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,42 +1,57 @@ | ||
var ready = function() { | ||
$('#reset-and-load-from-hn').click(function(e) { | ||
function fetchStory(id, callback) { | ||
$.getJSON('https://hacker-news.firebaseio.com/v0/item/' + id + '.json?print=pretty', function(story, status, jqxhr) { | ||
if (status === "error") { | ||
return callback(status) | ||
} else { | ||
if (story.text) { | ||
story.content = story.text; | ||
} | ||
|
||
callback(null, { | ||
item: story, | ||
status: status | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
|
||
ready(function() { | ||
$(document).on('click', '#reset-and-load-from-hn', function(e) { | ||
var apiRoot = $(this).data('api'); | ||
|
||
// use API to fetch all items. | ||
// use api to destroy all items? | ||
|
||
debugger | ||
|
||
//https://github.com/HackerNews/API | ||
// use api to fetch the top hackernews stories. | ||
$.getJSON("https://hacker-news.firebaseio.com/v0/topstories.json", function(stories, status, jqxhr){ | ||
debugger | ||
stories.forEach(function(story) { | ||
var data = { | ||
title: story.title | ||
}; | ||
|
||
if (story.url){ | ||
data.url = story.url; | ||
} | ||
if (story.content){ | ||
data.content = story.content; | ||
} | ||
|
||
$.ajax({ | ||
type: "POST", | ||
url: apiRoot+"/items", | ||
data: data, | ||
success: function(e){ | ||
$.getJSON("https://hacker-news.firebaseio.com/v0/topstories.json", function(stories, status, jqxhr) { | ||
|
||
stories.forEach(function(story_id) { | ||
fetchStory(story_id, function(error, result) { | ||
if (error || !result.item ) { | ||
console.log('rawr', error, result); | ||
return | ||
} | ||
|
||
$.ajax({ | ||
type: "POST", | ||
url: apiRoot + "/items", | ||
data: result, | ||
dataType: "JSON", | ||
headers: { | ||
"Authorization": "Token token="+window.current_user.token | ||
} | ||
}).success(function(e) { | ||
debugger | ||
|
||
}).error(function(e) { | ||
debugger | ||
}, | ||
dataType: "JSON" | ||
}); | ||
|
||
}); | ||
}) | ||
}); | ||
// use api to add all the hackernews stories | ||
}) | ||
}; | ||
|
||
$(document).ready(ready); | ||
$(document).on('page:load', ready); | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function ready(callback) { | ||
$(document).ready(callback); | ||
$(document).on('page:load', callback); | ||
} | ||
|
||
window.ready = ready; |
3 changes: 3 additions & 0 deletions
3
app/assets/javascripts/vendor/bootstrap_material_design_config.js
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,3 @@ | ||
ready(function() { | ||
$.material.init() | ||
}) |
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,77 @@ | ||
ready(function() { | ||
var $container = $('.portfolio'), | ||
$items = $container.find('.portfolio-item'), | ||
portfolioLayout = 'fitRows'; | ||
|
||
if ($container.hasClass('portfolio-centered')) { | ||
portfolioLayout = 'masonry'; | ||
} | ||
|
||
$container.isotope({ | ||
filter: '*', | ||
animationEngine: 'best-available', | ||
layoutMode: portfolioLayout, | ||
animationOptions: { | ||
duration: 750, | ||
easing: 'linear', | ||
queue: false | ||
}, | ||
masonry: {} | ||
}, refreshWaypoints()); | ||
|
||
function refreshWaypoints() { | ||
setTimeout(function() { | ||
}, 1000); | ||
} | ||
|
||
$('nav.portfolio-filter ul a').on('click', function() { | ||
var selector = $(this).attr('data-filter'); | ||
$container.isotope({filter: selector}, refreshWaypoints()); | ||
$('nav.portfolio-filter ul a').removeClass('active'); | ||
$(this).addClass('active'); | ||
return false; | ||
}); | ||
|
||
function getColumnNumber() { | ||
var winWidth = $(window).width(), | ||
columnNumber = 1; | ||
|
||
if (winWidth > 1200) { | ||
columnNumber = 5; | ||
} else if (winWidth > 950) { | ||
columnNumber = 4; | ||
} else if (winWidth > 600) { | ||
columnNumber = 3; | ||
} else if (winWidth > 400) { | ||
columnNumber = 2; | ||
} else if (winWidth > 250) { | ||
columnNumber = 1; | ||
} | ||
return columnNumber; | ||
} | ||
|
||
function setColumns() { | ||
var winWidth = $(window).width(), | ||
columnNumber = getColumnNumber(), | ||
itemWidth = Math.floor(winWidth / columnNumber); | ||
|
||
$container.find('.portfolio-item').each(function() { | ||
$(this).css({ | ||
width: itemWidth + 'px' | ||
}); | ||
}); | ||
} | ||
|
||
function setPortfolio() { | ||
setColumns(); | ||
$container.isotope('reLayout'); | ||
} | ||
|
||
$container.imagesLoaded(function() { | ||
setPortfolio(); | ||
}); | ||
|
||
$(window).on('resize', function() { | ||
setPortfolio(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; |
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,15 +0,0 @@ | ||
@mixin clearfix() { | ||
&:before, | ||
&:after { | ||
content: " "; // 1 | ||
display: table; // 2 | ||
} | ||
&:after { | ||
clear: both; | ||
} | ||
} | ||
|
||
|
||
.row { | ||
@include clearfix(); | ||
} | ||
Oops, something went wrong.