Created
February 27, 2013 18:11
-
-
Save TechnotronicOz/5050117 to your computer and use it in GitHub Desktop.
Description
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
# loader.coffee | |
Modernizr.load [ | |
load: "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" | |
complete: -> | |
Modernizr.load "js/vendor/jquery-1.9.1.min.js" unless window.jQuery | |
, | |
load: ["//use.typekit.net/iyl5mxg.js"] | |
complete: -> | |
try | |
Typekit.load() | |
, | |
load: ["js/compiled.js", "js/main.js"] | |
complete: -> | |
#window.appView = new hawk.views.App() | |
#window.appView.render() | |
window.appRouter = new hawk.router.App() | |
Backbone.history.start() | |
window.homeGalleryItems = new hawk.collections.HomeGallery([ | |
imgSmall: "images/1.jpg" | |
imgLarge: "img/1lg.jpg" | |
url: "#1" | |
title: "Title 1" | |
description: "Description 1" | |
, | |
imgSmall: "images/2.jpg" | |
imgLarge: "img/2lg.jpg" | |
url: "#2" | |
title: "Title 2" | |
description: "Description 2" | |
, | |
imgSmall: "images/3.jpg" | |
imgLarge: "img/3lg.jpg" | |
url: "#3" | |
title: "Title 3" | |
description: "Description 3" | |
]) | |
window.homeGallery = new hawk.views.HomeGallery({ collection: homeGalleryItems }) | |
$('#grid').html(homeGallery.render().el) | |
] | |
# main.coffee | |
window.hawk = | |
views: {} | |
models: {} | |
collections: {} | |
router: {} | |
helpers: {} | |
hawk.helpers.vent = _.extend({}, Backbone.Events) | |
hawk.helpers.template = (id) -> | |
_.template( $('#' + id).html() ) | |
### ----------------------------------------- | |
Model: HomeGalleryView | |
----------------------------------------- ### | |
hawk.models.HomeGalleryView = Backbone.Model.extend | |
defaults: | |
imgSmall: '' | |
imgLarge: '' | |
url: '' | |
title: '' | |
description: '' | |
### ----------------------------------------- | |
Collection: HomeGallery | |
Related Model: HomeGalleryView | |
----------------------------------------- ### | |
hawk.collections.HomeGallery = Backbone.Collection.extend | |
model: hawk.models.HomeGalleryView | |
### ----------------------------------------- | |
View: General App View | |
----------------------------------------- ### | |
hawk.views.App = Backbone.View.extend | |
initialize: -> | |
@loadBody() | |
render: -> | |
@loadBackstretch() | |
#window.homeGallery = new hawk.views.HomeGallery() | |
#window.homeGallery.render() | |
loadBody: -> | |
$('body').addClass 'loaded' | |
loadBackstretch: -> | |
$('body').backstretch ["img/bg/bg1.jpg", "img/bg/bg2.jpg", "img/bg/bg3.jpg", "img/bg/bg4.jpg", "img/bg/bg5.jpg", "img/bg/bg6.jpg"], | |
duration: 5000 | |
fade: 750 | |
### ----------------------------------------- | |
View: Home Gallery - Home Page Images | |
----------------------------------------- ### | |
hawk.views.HomeGallery = Backbone.View.extend | |
initialize: -> | |
#load gallery images | |
console.log 'views.HomeGallery initialized' | |
@collection.on('add', @addOne, @) | |
render: -> | |
@loadGallery() | |
@loadHoverfold('#grid') | |
@collection.each(@addOne, @) | |
return @ | |
el: $('#grid') | |
events: -> | |
'click .view a' : 'openModal' | |
loadGallery: -> | |
$('#grid').fadeIn 'slow' | |
loadHoverfold: (args)-> | |
if not $(args).length then return false | |
if Modernizr.csstransforms3d and Modernizr.csstransitions then $(args).hoverfold() | |
openModal: (e) -> | |
e.preventDefault() | |
console.log 'openModal', e.currentTarget.href | |
addOne: (item) -> | |
window.itemView = new hawk.views.HomeGalleryItem({ model: item }) | |
@$el.append( itemView.render().$el ) | |
### ----------------------------------------- | |
View: Home Gallery Photo Items | |
----------------------------------------- ### | |
hawk.views.HomeGalleryItem = Backbone.View.extend | |
tagName: 'div' | |
className: 'view' | |
template: hawk.helpers.template('view-template') | |
initialize: -> | |
#@model.on('change', @render, @) | |
render: -> | |
template = @template( @model.toJSON() ) | |
@$el.html(template) | |
return @ | |
### ----------------------------------------- | |
Router | |
----------------------------------------- ### | |
hawk.router.App = Backbone.Router.extend | |
routes: | |
'': 'default' | |
'contact': 'openContact' | |
'work': 'openWork' | |
'work/:id': 'openProject' | |
'about': 'openAbout' | |
openContact: -> | |
console.log 'openContact' | |
openWork: -> | |
console.log 'openWork' | |
openProject: (id) -> | |
console.log 'openProject: ' + id | |
openAbout: -> | |
console.log 'openAbout' | |
default: -> | |
console.log 'default' | |
initialize: -> | |
window.appView = new hawk.views.App() | |
window.appView.render() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment