Skip to content

Instantly share code, notes, and snippets.

@stevenleeg
Created June 16, 2012 19:45
Show Gist options
  • Save stevenleeg/2942343 to your computer and use it in GitHub Desktop.
Save stevenleeg/2942343 to your computer and use it in GitHub Desktop.
Compiled source of app.js
// Generated by CoffeeScript 1.3.3
(function() {
var get_template,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
window.App = {};
get_template = function(el, tpl, callback, context) {
if (context == null) {
context = {};
}
return $.get("/static/tpl/" + tpl + ".html", function(tpl) {
$(el).html(_.template(tpl, context));
return callback();
});
};
App.IndexView = (function(_super) {
__extends(IndexView, _super);
function IndexView() {
return IndexView.__super__.constructor.apply(this, arguments);
}
IndexView.prototype.template = "index";
IndexView.prototype.el = $("#container");
IndexView.prototype.initialize = function() {
return this.render();
};
IndexView.prototype.render = function() {
return get_template(this.el, this.template, this.domEvents);
};
IndexView.prototype.domEvents = function() {
return $("#searchInput").on("change keydown", function() {
if ($(this).val().length >= 0) {
return $("#placeholder").css("display", "none");
} else {
return $("#placeholder").css("display", "inline-block");
}
});
};
return IndexView;
})(Backbone.View);
$.ajaxSetup({
cache: false
});
window.App.Router = (function(_super) {
__extends(Router, _super);
function Router() {
return Router.__super__.constructor.apply(this, arguments);
}
Router.prototype.initialize = function() {
Backbone.history.start({
pushState: true
});
return $(document).on("click", "a:not([data-bypass])", function(evt) {
var href, protocol;
href = $(this).attr("href");
protocol = this.protocol + "//";
if (href.slice(protocol.length) !== protocol) {
evt.preventDefault();
return App.navigate(href, true);
}
});
};
Router.prototype.routes = {
"": "index",
"artist/:id": "artist",
"albums/:id": "album"
};
Router.prototype.index = Router.view = new App.IndexView();
return Router;
})(Backbone.Router);
$(document).ready(function() {
return App.runtime = new App.Router();
});
}).call(this);
window.App = {}
get_template = (el, tpl, callback, context = {}) ->
$(el).html(_.template("hello", context));
callback();
class App.IndexView extends Backbone.View
template: "index"
el: $("#container")
initialize: ->
@render()
render: ->
get_template(@el, @template, @domEvents)
domEvents: ->
$("#searchInput").on "change keydown", ->
# TODO: James fix me!!!
if $(this).val().length >= 0
$("#placeholder").css("display", "none")
else
$("#placeholder").css("display", "inline-block")
$.ajaxSetup { cache: false }
class window.App.Router extends Backbone.Router
initialize: ->
Backbone.history.start({pushState: true})
$(document).on "click", "a:not([data-bypass])", (evt) ->
href = $(this).attr "href"
protocol = this.protocol + "//"
if href.slice(protocol.length) != protocol
evt.preventDefault()
App.navigate(href, true)
routes: {
"": "index",
"artist/:id": "artist",
"albums/:id": "album"
}
index:
@view = new App.IndexView()
$(document).ready ->
App.runtime = new App.Router()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment