diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-17 21:26:52 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-17 21:26:52 -0400 |
| commit | 5d68db92b37545fb03332a46b01d0f1aad8ce64b (patch) | |
| tree | 28aea3c304ab5adc01236f60b719dbaff834c375 /StoneIsland/platforms/ios/www/js/lib/blogs | |
| parent | 58bf27362c0b3d1d41e135aa8bdbd38297a4d0f9 (diff) | |
populate selector
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/blogs')
4 files changed, 78 insertions, 4 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js index 742ee0f2..31dfd743 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js @@ -8,13 +8,26 @@ var ArchiveView = View.extend({ initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") + this.scroller = new IScroll('#archive .scroll') }, 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/platforms/ios/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js new file mode 100644 index 00000000..70fc910a --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js @@ -0,0 +1,33 @@ +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 + 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/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js index 430464b1..88ae6f1f 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js @@ -8,13 +8,29 @@ var HubView = View.extend({ initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") + this.scroller = new IScroll('#hub .scroll') }, 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/platforms/ios/www/js/lib/blogs/StoryView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js index ed46af31..0f03a518 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js @@ -8,13 +8,25 @@ var StoryView = View.extend({ initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") + this.scroller = new IScroll('#story .scroll') }, 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 |
