Skip to content

Instantly share code, notes, and snippets.

@ericraio
Created May 26, 2013 18:14
Show Gist options
  • Save ericraio/5653568 to your computer and use it in GitHub Desktop.
Save ericraio/5653568 to your computer and use it in GitHub Desktop.
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require turbolinks
//= require bootstrap
//= require_self
//= require_tree .
//
$(function () {
$(window).scroll(function() {
if ($(".navbar").offset().top>30) {
$(".navbar-inner").addClass("sticky");
}
else {
$(".navbar-inner").removeClass("sticky");
}
});
// Flex
if ($(".flexslider").length) {
$('.flexslider').flexslider();
}
servicesCircle.initialize();
staticHeader.initialize();
portfolioItem.initialize();
postsLive.initialize();
});
var portfolioItem = {
initialize: function () {
var $container = $("#portfolio_tem .left_box");
var $bigPics = $container.find(".big img");
var $thumbs = $container.find(".thumbs .thumb");
$bigPics.hide().eq(0).show();
$thumbs.click(function (e) {
e.preventDefault();
var index = $thumbs.index(this);
$bigPics.fadeOut();
$bigPics.eq(index).fadeIn();
});
}
}
var staticHeader = {
initialize: function () {
if ($(".navbar-static-top").length) {
$("body").css("padding-top", 0);
}
}
}
var servicesCircle = {
initialize: function () {
var $container = $(".services_circles");
var $texts = $container.find(".description .text");
var $circles = $container.find(".areas .circle");
$circles.click(function () {
var index = $circles.index(this);
$texts.fadeOut();
$texts.eq(index).fadeIn();
$circles.removeClass("active");
$(this).addClass("active");
});
}
}
var postsLive = {
initialize: function () {
source = new EventSource('/posts/events')
source.addEventListener('messages.create', function(e) {
message = $.parseJSON(e.data)
$('#activity-feed').prepend('<a href="/posts/' + message.slug + '"><h2>' + message.headline + '</h2></a>')
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment