summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/blogs/HubView.js
blob: 62e8d10fa3215adc1097b29674866e625c89c0b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var HubView = View.extend({
  
  el: "#hub",
  template: $("#hub .template").html(),

  events: {
  },
  
  initialize: function(){
    this.$content = this.$(".content")
    this.$loader = this.$(".loader")
    this.scroller = new IScroll('#hub', app.iscroll_options)
  },

  show: function(){
    document.body.className = "hub"
  },

  populate: function(data){
    this.data = data
    this.$loader.hide()
    this.$content.empty()
    // id date subtitle body link image[uri caption]
    this.data.forEach(function(row){
      var t = this.template.replace(/{{image}}/, row.images[0].uri)
                           .replace(/{{date}}/, row.date)
                           .replace(/{{code}}/, row.code)
                           .replace(/{{title}}/, row.title)
                           .replace(/{{subtitle}}/, row.subtitle)
                           .replace(/{{link}}/, row.link)
                           .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
      this.$content.append(t)
    }.bind(this))
  },


})