var StoryView = ScrollableView.extend({
loaded: false,
el: "#story",
template: $("#story .template").html(),
events: {
"click .links li": "pick",
},
initialize: function(){
this.sections = {}
this.$img = this.$("img")
this.$content = this.$(".content")
this.$links = this.$(".links")
this.$loader = this.$(".loader")
this.loader = new Loader ()
this.scroller = ScrollFactory('#story', app.iscroll_options)
},
show: function(){
this.deferScrollToTop()
app.footer.hide()
document.body.className = "story"
if (! this.loaded) {
this.populate( BACKUP_DB.story )
}
},
populate: function(data){
if (this.loaded) { return }
this.loaded = true
this.data = data
this.$loader.hide()
this.$content.empty()
// id title image[uri caption] body
this.data.forEach(function(row){
var t = this.template.replace(/{{id}}/, row.id)
.replace(/{{body}}/, row.body.replace(/\n/g, "
"))
var li = document.createElement("li")
li.dataset.id = row.id
li.innerHTML = "