ManifestReader
by Shaun Ellis
HTML
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<body>
<h1 class="selected"></h1>
<div id="container"></div>
<script type="text/template" id="thumbs-template">
<div class="col-xs-6 col-md-3">
<a href="#" class="thumbnail">
<img data-src="holder.js/150x180" alt="...">
<div class="caption">
<h3><%= label %></h3>
</div>
</a>
</div>
</script>
</body>
JavaScript
// Models
var Collection = Backbone.Model.extend({
initialize : function(){
console.log('Collection has been initialized.');
setID(this);
logObj(this);
this.on('change', function(){
logChange(this);
});
},
defaults: {
id: null,
within: [],
label: 'Untitled',
type: 'collection',
description: '',
attribution: 'Unattributed',
collections: {}, // CollectionCollection
manifests: {} // ManifestCollection
}
});
var Manifest = Backbone.Model.extend({
initialize : function(){
console.log('Manifest has been initialized.');
setID(this);
logObj(this);
this.on('change', function(){
logChange(this);
});
},
defaults: {
label: 'Untitled',
type: 'manifest',
within: [],
viewingDirection: 'left-to-right',
viewingHint: 'paged',
sequences: {} // SequenceCollection; Note: first sequence is the default
}
});
var Sequence = Backbone.Model.extend({
initialize : function(){
console.log('Sequence has been initialized.');
setID(this);
logObj(this);
this.on('change', function(){
logChange(this);
});
this.on("invalid", function(model, error){
console.log(error);
});
},
defaults: {
label: 'Untitled',
type: 'sequence',
startCanvas: null,
canvases: {} // CanvasCollection
},
validate: function(attributes){
if(attributes.canvases){
if(attributes.canvases.length < 1){
return "Your sequence must have at least one canvas in it.";
}
}else{
return "Your sequence must have at least one canvas in it.";
}
},
addCanvas: function(canvas){
/*
var c = _.clone(this.get("canvases")); // we need to clone to...