-
Notifications
You must be signed in to change notification settings - Fork 4
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 #34 from GingerBear/layout-update
mobile layout update
- Loading branch information
Showing
17 changed files
with
333 additions
and
320 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
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,60 @@ | ||
(function() { | ||
|
||
var isMobile = /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile/.test(window.navigator.userAgent); | ||
|
||
$.ajax('/standings').done(showStandings); | ||
|
||
function showStandings(json) { | ||
var template = Handlebars.compile($('[data-template-name="standings"]').html()); | ||
var html = template(json); | ||
$('.standings .content').html(html); | ||
} | ||
|
||
|
||
if (isMobile) { | ||
$('.standing-toggle').click(function(e) { | ||
e.preventDefault(); | ||
$('.standings .content').toggleClass('show'); | ||
}); | ||
} | ||
|
||
if (isMobile) { | ||
initScrollPreload(); | ||
} | ||
|
||
function initVideo($link) { | ||
var img = $link.find('img'); | ||
var href = $link.attr('href'); | ||
$link.addClass('preloading'); | ||
$.get(href).done(function(data) { | ||
if (data.video) { | ||
$link.replaceWith('<video class="video-player" controls poster="' + data.thumbnailUrl + '" src="' + data.video + '"></video>'); | ||
} | ||
}); | ||
} | ||
|
||
function getVideosByScroll(y) { | ||
return $('li.video').filter(function() { | ||
return $(this).offset().top > y | ||
}).slice(0, 5); | ||
} | ||
|
||
function initScrollPreload() { | ||
var timer; | ||
tryPreload(); | ||
|
||
function tryPreload() { | ||
var videos = getVideosByScroll(window.scrollY); | ||
videos.each(function() { | ||
var videoLink = $(this).find('[data-preload="true"]:not(.preloading)'); | ||
initVideo(videoLink); | ||
}); | ||
} | ||
|
||
window.onscroll = function() { | ||
clearTimeout(timer); | ||
timer = setTimeout(tryPreload, 100); | ||
}; | ||
} | ||
|
||
})(); |
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,17 @@ | ||
// Custom handlebar helpers | ||
|
||
module.exports = function(app) { | ||
|
||
var hbs = app.hbs; | ||
|
||
// css helper for getting paths to compiled assets | ||
hbs.registerHelper('css', function(file, options) { | ||
return css(file); | ||
}); | ||
|
||
// js helper for getting paths to compiled assets | ||
hbs.registerHelper('js', function(file, options) { | ||
return js(file); | ||
}); | ||
|
||
}; |
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.