diff options
Diffstat (limited to 'StoneIsland/www/js/lib')
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/ArchiveView.js | 79 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/BlogView.js | 11 |
2 files changed, 77 insertions, 13 deletions
diff --git a/StoneIsland/www/js/lib/blogs/ArchiveView.js b/StoneIsland/www/js/lib/blogs/ArchiveView.js index f0a796bf..c156aed0 100644 --- a/StoneIsland/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/www/js/lib/blogs/ArchiveView.js @@ -6,6 +6,12 @@ var ArchiveView = ScrollableView.extend({ events: { "click .item": "pick", + "mousedown .row": "mousedown", + "touchstart .row": "touchstart", + "mousemove .row": "mousemove", + "touchmove .row": "touchmove", + "mouseup .row": "mouseup", + "touchend .row": "touchend", }, initialize: function(){ @@ -20,9 +26,11 @@ var ArchiveView = ScrollableView.extend({ app.header.set_back(false) }, - pick: function(){ + pick: function(e){ this.$el.removeClass("menu") - app.header.set_back(true) + app.header.set_back(true) + var index = $(e.currentTarget).data("index") + this.populateDecade(index) }, show: function(){ @@ -41,11 +49,6 @@ var ArchiveView = ScrollableView.extend({ // id title images[ uri label code caption ] this.data.forEach(function(row, index){ - var t = this.row_template.replace(/{{image}}/, row.images[0].uri) - .replace(/{{label}}/, row.images[0].label) - .replace(/{{code}}/, row.images[0].code) - .replace(/{{caption}}/, row.images[0].caption) - this.$content.append(t) var t = this.menu_template.replace(/{{title}}/, row.title) var $t = $(t) @@ -56,6 +59,68 @@ var ArchiveView = ScrollableView.extend({ this.back() this.deferScrollToTop() + + this.populateDecade(0, 3) + }, + + populateDecade: function(index, count){ + this.$content.empty() + + var loader = new Loader() + + var row = this.data[index] + + row.images.forEach(function(cell, i){ + if (i > count) return + var $t = $("<div>") + $t.addClass("row").addClass("loading") + var t = this.row_template.replace(/{{image}}/, cell.uri) + .replace(/{{label}}/, cell.label) + .replace(/{{code}}/, cell.code) + .replace(/{{caption}}/, cell.caption) + $t.html(t) + this.$content.append($t) + + loader.preloadImage(cell.uri, function(){ + $t.removeClass('loading') + }.bind(this)) + }.bind(this)) + }, + +// ['transformProp'] = "translateZ(0) translateX(-50%) translateY(-50%) "; +// .image, .text + + touchstart: function(e){ + this.$row = e.currentTarget + this.mousedown(e.touches[0]) + }, + touchmove: function(e){ + this.mousemove(e.touches[0]) + }, + touchend: function(e){ + this.mouseup() + }, + mouse: { x: 0, y: 0 }, + $row: null, + + mousedown: function(e){ + this.$row = this.$row || e.currentTarget + this.mouse.x = e.pageX + this.mouse.y = e.pageY + }, + mousemove: function(e){ + var dx = ( this.mouse.x - e.pageX ) / window.innerWidth + var dy = ( this.mouse.y - e.pageY ) / window.innerWidth + this.$row.style['transformProp'] = [ + "translateZ(0)", + "translateX(-50%)", + "translateY(-50%)", + "rotateY(" + dx + "deg)", + ].join(" ") + }, + mouseup: function(e){ + this.mouse.x = this.mouse.y = 0 + this.$row = null }, })
\ No newline at end of file diff --git a/StoneIsland/www/js/lib/blogs/BlogView.js b/StoneIsland/www/js/lib/blogs/BlogView.js index 3ea35418..ddfff9e6 100644 --- a/StoneIsland/www/js/lib/blogs/BlogView.js +++ b/StoneIsland/www/js/lib/blogs/BlogView.js @@ -10,7 +10,7 @@ var BlogView = View.extend({ fetch: function(){ $.ajax({ method: "GET", - url: "http://stone.sup.land/db.json", + url: sdk.env == 'test' ? '/db.json' : "http://stone.sup.land/db.json", success: this.success.bind(this), cache: true, }) @@ -21,11 +21,10 @@ var BlogView = View.extend({ if (this.loaded) return this.loaded = true - this.data = data + this.data = data = typeof data == "string" ? JSON.parse(data) : data + + app.archive.populate(data.archive) - this.loader.preloadImage(data.archive[0].images[0].uri, function(img){ - app.archive.populate(data.archive) - }) this.loader.preloadImage(data.hub[0].image[0].uri, function(img){ app.hub.populate(data.hub) }) @@ -54,7 +53,7 @@ var BlogView = View.extend({ app.gallery_id = data.store[0].CollectionId - app.collection.fetch() + // app.collection.fetch() }, })
\ No newline at end of file |
