diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-17 08:12:18 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-17 08:12:18 -0400 |
| commit | 18eecb2faa34cbdfe558e3941c9ec0f5019a3ff9 (patch) | |
| tree | c476e5ab9ccb2d799df19b21c70d6f9d15382f87 /StoneIsland/www/js/lib/blogs | |
| parent | 7eb327b13bd9ee241f47f22ba1c3db3c90e8e942 (diff) | |
fetch blogviews from cms database and populate based on presumed schema
Diffstat (limited to 'StoneIsland/www/js/lib/blogs')
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/ArchiveView.js | 14 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/BlogView.js | 34 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/HubView.js | 17 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/StoryView.js | 15 |
4 files changed, 76 insertions, 4 deletions
diff --git a/StoneIsland/www/js/lib/blogs/ArchiveView.js b/StoneIsland/www/js/lib/blogs/ArchiveView.js index 742ee0f2..79139054 100644 --- a/StoneIsland/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/www/js/lib/blogs/ArchiveView.js @@ -8,13 +8,25 @@ var ArchiveView = View.extend({ initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") }, show: function(){ document.body.className = "archive" }, - populate: function(){ + populate: function(data){ + this.data = data + this.$loader.hide() + this.$content.empty() + this.data.forEach(function(row){ + var t = this.template.replace({{image}}, row.image.url) + .replace({{code}}, row.code) + .replace({{title}}, row.title) + .replace({{body}}, row.body) + this.$content.append(t) + }.bind(this)) }, + })
\ No newline at end of file diff --git a/StoneIsland/www/js/lib/blogs/BlogView.js b/StoneIsland/www/js/lib/blogs/BlogView.js new file mode 100644 index 00000000..bd43c6aa --- /dev/null +++ b/StoneIsland/www/js/lib/blogs/BlogView.js @@ -0,0 +1,34 @@ +var BlogView = View.extend({ + + data: null, + loaded: false, + initialize: function(){ + this.loader = new Loader () + this.fetch() + }, + + fetch: function(){ + $.ajax({ + method: "GET", + url: "http://stone.sup.land/db.json", + success: this.success.bind(this), + cache: true, + }) + }, + + success: function(data){ + this.loaded = true + this.data = data + // preload images + this.loader.preloadImage(data.archive[0].image.url, function(img){ + app.archive.populate(data.archive) + }) + this.loader.preloadImage(data.hub[0].image.url, function(img){ + app.hub.populate(data.hub) + }) + this.loader.preloadImage(data.story[0].image.url, function(img){ + app.story.populate(data.story) + }) + }, + +})
\ No newline at end of file diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js index 430464b1..ce035c7d 100644 --- a/StoneIsland/www/js/lib/blogs/HubView.js +++ b/StoneIsland/www/js/lib/blogs/HubView.js @@ -8,13 +8,28 @@ var HubView = View.extend({ initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") }, show: function(){ document.body.className = "hub" }, - populate: function(){ + populate: function(data){ + this.data = data + this.$loader.hide() + this.$content.empty() + this.data.forEach(function(row){ + var t = this.template.replace({{image}}, row.image.url) + .replace({{date}}, row.date) + .replace({{code}}, row.code) + .replace({{title}}, row.title) + .replace({{subtitle}}, row.subtitle) + .replace({{link}}, row.link) + .replace({{body}}, row.body) + this.$content.append(t) + }.bind(this)) }, + })
\ No newline at end of file diff --git a/StoneIsland/www/js/lib/blogs/StoryView.js b/StoneIsland/www/js/lib/blogs/StoryView.js index ed46af31..4a825c8a 100644 --- a/StoneIsland/www/js/lib/blogs/StoryView.js +++ b/StoneIsland/www/js/lib/blogs/StoryView.js @@ -8,13 +8,24 @@ var StoryView = View.extend({ initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") }, show: function(){ document.body.className = "story" }, - - populate: function(){ + + populate: function(data){ + this.data = data + this.$loader.hide() + this.$content.empty() + this.data.forEach(function(row){ + var t = this.template.replace({{image}}, row.image.url) + .replace({{date}}, row.date) + .replace({{title}}, row.title) + .replace({{body}}, row.body) + this.$content.append(t) + }.bind(this)) }, })
\ No newline at end of file |
