2012-03-09 05:02:49 +00:00
|
|
|
$(function() {
|
2012-06-04 19:10:35 +00:00
|
|
|
// start the icon carousel
|
|
|
|
$('#iconCarousel').carousel({
|
|
|
|
interval: 5000
|
|
|
|
});
|
|
|
|
|
|
|
|
// make code pretty
|
|
|
|
window.prettyPrint && prettyPrint();
|
|
|
|
|
|
|
|
// inject twitter & github counts
|
|
|
|
$.ajax({
|
|
|
|
url: 'http://api.twitter.com/1/users/show.json',
|
|
|
|
data: {screen_name: 'fortaweso_me'},
|
|
|
|
dataType: 'jsonp',
|
|
|
|
success: function(data) {
|
|
|
|
$('#followers').html(data.followers_count);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.ajax({
|
2012-06-14 20:59:29 +00:00
|
|
|
url: 'https://api.github.com/repos/fortawesome/Font-Awesome',
|
2012-06-04 19:10:35 +00:00
|
|
|
dataType: 'jsonp',
|
|
|
|
success: function(data) {
|
2012-06-14 20:59:29 +00:00
|
|
|
$('#watchers').html(data.data.watchers);
|
|
|
|
$('#forks').html(data.data.forks);
|
2012-06-04 19:10:35 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
var firstInHistory = true;
|
2012-03-09 05:02:49 +00:00
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
var MainView = Backbone.View.extend({
|
|
|
|
el: $("div.container"),
|
2012-03-09 05:02:49 +00:00
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
modalTemplate: _.template($("#modal-template").html()),
|
2012-03-09 05:02:49 +00:00
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
events:{
|
|
|
|
"click ul.the-icons > li": "iconClicked"
|
|
|
|
},
|
2012-03-09 05:02:49 +00:00
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
iconClicked: function(event) {
|
|
|
|
event.preventDefault();
|
2012-03-09 05:02:49 +00:00
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
var $item = $(event.currentTarget);
|
|
|
|
var $iconName = $item.find("i").attr("class");
|
2012-06-14 20:59:29 +00:00
|
|
|
_gaq.push(['_trackEvent', 'iconClick', $iconName]);
|
2012-06-04 04:20:05 +00:00
|
|
|
|
|
|
|
mainRouter.navigate("icon/" + $iconName, {trigger: true});
|
|
|
|
firstInHistory = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var MainRouter = Backbone.Router.extend({
|
|
|
|
routes: {
|
2012-06-04 16:05:38 +00:00
|
|
|
"": "checkModal",
|
2012-06-04 04:20:05 +00:00
|
|
|
"icon/:iconName": "showIcon"
|
|
|
|
},
|
|
|
|
|
2012-06-04 16:05:38 +00:00
|
|
|
checkModal: function() {
|
|
|
|
var $modal = $("div.modal");
|
|
|
|
|
|
|
|
if ($modal.length > 0) {
|
|
|
|
$modal.modal("hide");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
showIcon: function(iconName) {
|
|
|
|
var $modal = $(mainView.modalTemplate({"iconName": iconName}));
|
|
|
|
|
|
|
|
$modal.modal("show");
|
|
|
|
$modal.on('hidden', function () {
|
|
|
|
$modal.remove();
|
|
|
|
if (firstInHistory) {
|
|
|
|
mainRouter.navigate("/", {trigger: false});
|
|
|
|
firstInHistory = false;
|
|
|
|
} else {
|
|
|
|
window.history.back();
|
2012-03-09 05:02:49 +00:00
|
|
|
}
|
2012-06-04 04:20:05 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
2012-03-09 05:02:49 +00:00
|
|
|
|
2012-06-04 04:20:05 +00:00
|
|
|
var mainView = new MainView();
|
|
|
|
var mainRouter = new MainRouter();
|
|
|
|
Backbone.history.start({pushState : false});
|
2012-03-09 05:02:49 +00:00
|
|
|
});
|