diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-11-08 12:37:03 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-11-08 12:37:03 -0500 |
| commit | ef4f212fc1482136dba1e690ec589b315b4a377f (patch) | |
| tree | 0b7e16d72567fafcfd3e08d7c5c591ad07a63458 /StoneIsland/platforms/android/assets/www/js/lib/blogs | |
| parent | 5fa81da81260d65113f57a293b6256d334fe8e2d (diff) | |
build 0.7.0
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/blogs')
4 files changed, 143 insertions, 78 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js index e7211036..12aaf7de 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js @@ -44,6 +44,9 @@ var ArchiveView = ScrollableView.extend({ app.footer.hide() this.back() document.body.className = "archive" + if (! this.populated) { + this.populate( BACKUP_DB.archive ) + } }, populate: function(data){ @@ -109,6 +112,9 @@ var ArchiveView = ScrollableView.extend({ }.bind(this)) this.deferRefresh() + setTimeout(function(){ + this.deferScrollToTop() + }.bind(this), 100) }, // ['transformProp'] = "translateZ(0) translateX(-50%) translateY(-50%) "; diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js index 02491b32..b7c80520 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js @@ -4,15 +4,17 @@ var BlogView = View.extend({ loaded: false, initialize: function(){ this.loader = new Loader () - this.fetch() }, - fetch: function(){ + fetch: function(fn){ $.ajax({ method: "GET", -// url: sdk.env == 'test' ? '/db.json' : "http://stone.sup.land/db.json", - url: "http://stone.sup.land/db.json", - success: this.success.bind(this), +// url: sdk.env == 'test' ? '/db.json' : "https://stone.sup.land/db.json", + url: "https://stone.sup.land/db.json", + success: function(data){ + this.success(data) + fn && fn() + }.bind(this), cache: true, }) }, @@ -35,11 +37,8 @@ var BlogView = View.extend({ break case "closed": app.closed.storeIsClosed = true - app.closed.storeOpenDate = null - break - case "openson": - app.closed.storeIsClosed = true - app.closed.storeOpenDate = moment(data.store[0].OpensOn) + app.closed.storeClosedMessageOne = data.store[0].StoreClosedMessageOne + app.closed.storeClosedMessageTwo = data.store[0].StoreClosedMessageTwo break } @@ -48,7 +47,9 @@ var BlogView = View.extend({ } else { app.gallery_id = data.store[0].CollectionId + app.department_id = data.store[0].DepartmentId app.collection.setCollectionName( data.store[0].collection ) + app.collection.loaded = false app.collection.fetch() } @@ -70,10 +71,13 @@ var BlogView = View.extend({ console.log(data.store[0].StoreStatus) - var fits_large = (data.store[0].FitsLarge === "true") - app.product.$fit.toggle( fits_large ) - app.product.$sizing.toggle( fits_large ) - + app.product.fitLargeCodes = {} + if (data.store[0].FittingCodes.length) { + data.store[0].FittingCodes.split("\n").forEach(function(code){ + app.product.fitLargeCodes[code] = true + }) + } + if (data.store[0].BackgroundIsGray === "true") { app.collection.$el.addClass("gray") app.product.gallery.$el.addClass("gray") diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js index 4ed05bb8..1657d295 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js @@ -15,87 +15,102 @@ var HubView = ScrollableView.extend({ this.$content = this.$(".content") this.$loader = this.$(".loader") this.scroller = new IScroll('#hub', app.iscroll_options) + HubLoader.init(this) }, show: function(){ this.deferScrollToTop() app.footer.hide() document.body.className = "hub" + if (! this.populated) { + this.populate( BACKUP_DB.hub ) + } }, galleries: {}, + populated: false, populate: function(data){ // sort posts by date, reversed + this.populated = true this.data = data.map(function(s){ return [ +moment(s.date), s ] }).sort(function(a,b){ return a[0] > b[0] ? -1 : a[0] == b[0] ? 0 : 1 }).map(function(pair){ - console.log(pair[1]) + // console.log(pair[1]) return pair[1] }) this.$loader.hide() this.$content.empty() this.galleries = {} + HubLoader.add(this.data) + + this.deferScrollToTop() + }, + + append: function(row){ // id date subtitle body link store image[uri caption] - this.data.forEach(function(row){ - // console.log(row) - console.log(moment(row.date)) - var t = this.template.replace(/{{id}}/g, row.id) - .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) - .replace(/{{title}}/, row.title) - .replace(/{{subtitle}}/, row.subtitle) - .replace(/{{link}}/, row.link) - .replace(/{{body}}/, row.body.replace(/\n/g, "<br>")) - var $t = $(t) - if (row.store != "true") { - $t.find(".store").remove() - } - this.$content.append($t) - - if (row.image.length > 1) { - // image gallery - var $gallery = $(".gallery-" + row.id) - row.image.forEach(function(img){ - var el = document.createElement("div") - el.style.backgroundImage = "url(" + img.uri + ")" - el.className = "item" - $gallery.append(el) - }) - this.galleries[row.id] = new Flickity( ".gallery-" + row.id, { - selector: '.item', - cellAlign: 'center', - autoPlay: false, - freeScroll: false, - wrapAround: true, - imagesLoaded: true, - prevNextButtons: false, - pageDots: false, - contain: true, - draggable: true, - }) - } - else { - // single image + // console.log(row) + // console.log(moment(row.date)) + var t = this.template.replace(/{{id}}/g, row.id) + .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) + .replace(/{{title}}/, row.title) + .replace(/{{subtitle}}/, row.subtitle) + .replace(/{{link}}/, row.link) + .replace(/{{body}}/, row.body.replace(/\n/g, "<br>")) + var $t = $(t) + if (row.store != "true") { + $t.find(".store").remove() + } + this.$content.append($t) + + if (row.image && row.image.length > 1) { + // image gallery + var $gallery = $(".gallery-" + row.id) + row.image.forEach(function(img){ var el = document.createElement("div") - el.style.backgroundImage = "url(" + row.image[0].uri + ")" + el.style.backgroundImage = "url(" + img.uri + ")" el.className = "item" - $(".gallery-" + row.id).append(el) - $(".gallery-" + row.id).data("row", row) - - // video, append play button - if (row.link.match(/youtube|youtu.be|vimeo/)) { - var play = document.createElement("div") - play.className = "play" - $(".gallery-" + row.id).append(play) - } - $t.find(".gallery-left").remove() - $t.find(".gallery-right").remove() + $gallery.append(el) + }) + this.galleries[row.id] = new Flickity( ".gallery-" + row.id, { + selector: '.item', + cellAlign: 'center', + autoPlay: false, + freeScroll: false, + wrapAround: true, + imagesLoaded: true, + prevNextButtons: false, + pageDots: false, + contain: true, + draggable: true, + }) + } + else { + // single image + var el = document.createElement("div") + if (row.image && row.image.length) { + el.style.backgroundImage = "url(" + row.image[0].uri + ")" } + el.className = "item" + $(".gallery-" + row.id).append(el) + $(".gallery-" + row.id).data("row", row) - }.bind(this)) - - this.deferScrollToTop() + // video, append play button + if (row.link.match(/youtube|youtu.be|vimeo/)) { + var play = document.createElement("div") + play.className = "play" + $(".gallery-" + row.id).append(play) + $(".gallery-" + row.id).addClass("gallery-video-post") + if (! row.image) { + var url = row.link + var ytid = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; + e.style.backgroundImage = "url(https://i.ytimg.com/vi/" + ytid + "/maxresdefault.jpg" + } + } + $t.find(".gallery-left").remove() + $t.find(".gallery-right").remove() + } }, store_link: function(){ @@ -118,7 +133,41 @@ var HubView = ScrollableView.extend({ share: function(e){ var title = $(e.currentTarget).parent().find(".title").text() console.log("share", title) - window.plugins.socialsharing.share(title, null, null, "http://stoneisland.com/" ) + window.plugins.socialsharing.share(title, null, null, "http://deeplink.me/www.stoneisland.com/hub" ) }, -})
\ No newline at end of file +}) + +var HubLoader = (function(){ + var queue, view, item, loader + var HubLoader = {} + var loader + HubLoader.init = function(v){ + view = v + } + HubLoader.add = function(items){ + queue = items + this.load() + } + HubLoader.load = function(){ + item = queue.shift() + if (! item) return + if (item.image && item.image.length) { + loader = new Loader (HubLoader.build) + images = item.image.map(function(img){ + return img.uri.replace("http:","https:") + }).filter(function(img){ + return img.uri + }) + loader.preloadImages(images) + } + else { + HubLoader.build() + } + } + HubLoader.build = function(){ + view.append(item) + setTimeout(HubLoader.load, 20) + } + return HubLoader +})() diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js index 73b7b83b..5a7a56d1 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js @@ -23,6 +23,9 @@ var StoryView = ScrollableView.extend({ this.deferScrollToTop() app.footer.hide() document.body.className = "story" + if (! this.loaded) { + this.populate( BACKUP_DB.story ) + } }, populate: function(data){ @@ -52,18 +55,21 @@ var StoryView = ScrollableView.extend({ }, set_active: function(id){ - this.$links.find(".active").removeClass("active") - this.$links.find("[data-id=" + id + "]").addClass("active") + this.$(".active").removeClass("active") - this.$content.find(".active").removeClass("active") + this.$links.find("[data-id=" + id + "]").addClass("active") this.$content.find("[data-id=" + id + "]").addClass("active") var section = this.sections[id] - var $replace = this.$img - this.$img.fadeTo(110,0.65, function() { - $replace.attr("src", section.image.uri) - }).fadeTo(130,1) + if (navigator.onLine) { + var $replace = this.$img + + this.$img.stop().fadeTo(110,0.65, function() { + $replace.attr("src", section.image.uri) + }).fadeTo(130,1) + } + this.deferScrollToTop() }, |
