Created
June 21, 2014 22:18
-
-
Save gingerrific/ec0fe1433820a3d6b724 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
"use strict"; | |
var App = { | |
Models: { | |
Photo:{} | |
}, | |
Collections: { | |
PhotoCollection: {} | |
}, | |
Views: { | |
SiteView: {}, | |
ThumbView: {} | |
}, | |
Routers: {}, | |
models: {}, | |
collecitons: {}, | |
views: {}, | |
routers: {}, | |
}; | |
This file contains hidden or 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
<!doctype html> | |
<html class="no-js"> | |
<head> | |
<meta charset="utf-8"> | |
<title>dueSouthExperience</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width"> | |
<link rel="shortcut icon" href="/favicon.ico"> | |
<!-- Place favicon.ico and apple-touch-icon.png in the root directory --> | |
<!-- build:css styles/vendor.css --> | |
<!-- bower:css --> | |
<!-- endbower --> | |
<!-- endbuild --> | |
<!-- build:css(.tmp) styles/main.css --> | |
<link rel="stylesheet" href="styles/main.css"> | |
<!-- endbuild --> | |
<!-- build:js scripts/vendor/modernizr.js --> | |
<script src="../bower_components/modernizr/modernizr.js"></script> | |
<!-- endbuild --> | |
</head> | |
<body> | |
<!--[if lt IE 10]> | |
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> | |
<![endif]--> | |
<div class="image-upload-container"> | |
Photo name: | |
<input type='text' class="name-input"> | |
URL: | |
<input type='text' class="url-input"> | |
Caption: | |
<input type='text' class="caption-input"> | |
<button class="add-button">Add Image</button> | |
</div> | |
<div class="container"> | |
</div> | |
<script type="text/template" class="thumb-view-template"> | |
<img src="<%=url%>"> | |
<h3><%=photoName%></h3> | |
<p><%=caption%></p> | |
</script> | |
<!-- build:js scripts/vendor.js --> | |
<!-- bower:js --> | |
<script src="../bower_components/jquery/dist/jquery.js"></script> | |
<script src="../bower_components/underscore/underscore.js"></script> | |
<script src="../bower_components/backbone/backbone.js"></script> | |
<!-- endbower --> | |
<!-- endbuild --> | |
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. --> | |
<script> | |
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]= | |
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date; | |
e=o.createElement(i);r=o.getElementsByTagName(i)[0]; | |
e.src='//www.google-analytics.com/analytics.js'; | |
r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); | |
ga('create','UA-XXXXX-X');ga('send','pageview'); | |
</script> | |
<!-- build:js({app,.tmp}) scripts/main.js --> | |
<script src="scripts/app.js"></script> | |
<script src="scripts/models.js"></script> | |
<script src="scripts/views.js"></script> | |
<script src="scripts/main.js"></script> | |
<!-- endbuild --> | |
</body> | |
</html> |
This file contains hidden or 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
"use strict"; | |
$('.add-button').click(function () { | |
var userURL = $('.url-input').val(); | |
var userProvideName = $('.name-input').val(); | |
var userCaption = $('.caption-input').val(); | |
var photo = new App.Models.Photo(); | |
photo.set({ | |
url: userURL, | |
photoName: userProvideName, | |
caption: userCaption | |
}); | |
mySite.collection.add(photo); | |
photo.save(); | |
}) | |
var mySite = new App.Views.SiteView(); |
This file contains hidden or 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
// bower:scss | |
// endbower | |
body { | |
background: #fafafa; | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
color: #333; | |
} | |
input { | |
width: 21.875em; | |
} | |
/////////////////////////////////////////// | |
// Container ////////////////////////////// | |
.container { | |
width: 95%; | |
min-height: 25em; | |
margin: 1em auto; | |
border: 1px solid black; | |
padding: 1em; | |
} |
This file contains hidden or 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
"use strict"; | |
//Model constructor | |
App.Models.Photo = Backbone.Model.extend({ | |
idAttribute: '_id', | |
defaults: { | |
url: "", | |
photoName: "", | |
caption: "" | |
} | |
}); | |
//Collection Constructor | |
App.Collections.PhotoCollection = Backbone.Collection.extend({ | |
model: App.Models.Photo, | |
url: 'http://tiny-pizza-server.herokuapp.com/collections/dueSouthPhotos' | |
}); |
This file contains hidden or 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
"use strict"; | |
// Individual Thumbnail View - many many instances | |
App.Views.ThumbView = Backbone.View.extend({ | |
template: _.template($(".thumb-view-template").text()), | |
className: "thumb-container", | |
initialize: function () { | |
$(".container").append(this.el); | |
this.render(); | |
}, | |
render: function () { | |
var renderedTemplate = this.template(this.model.attributes); | |
this.$el.html(renderedTemplate); | |
} | |
}); | |
// Full App View // only 1 instance | |
App.Views.SiteView = Backbone.View.extend({ | |
initialize: function () { | |
this.collection = new App.Collections.PhotoCollection() | |
this.collection.fetch() | |
this.listenTo(this.collection, "add", function (photo) { | |
new App.Views.ThumbView({model: photo}); | |
}); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment