summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/index.js16
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js22
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js1
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js49
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js9
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/push.js77
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js3
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js4
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js20
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js6
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/View.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/util.js2
13 files changed, 176 insertions, 37 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/index.js b/StoneIsland/platforms/android/assets/www/js/index.js
index 468c0d7e..73af443a 100755
--- a/StoneIsland/platforms/android/assets/www/js/index.js
+++ b/StoneIsland/platforms/android/assets/www/js/index.js
@@ -64,6 +64,8 @@ var app = (function(){
app.ready = function(){
if (window.cordova) {
+ document.addEventListener('pause', app.paused, false)
+ document.addEventListener('resume', app.resumed, false)
cordova.plugins.Keyboard.disableScroll(true)
geo.fetch()
}
@@ -74,12 +76,24 @@ var app = (function(){
// app.router.launch()
// }
// else {
- app.account.connect( app.router.launch.bind(app.router) )
+ push.init()
+ app.account.connect( app.router.launch.bind(app.router) )
// }
$("body").removeClass("loading")
}
+ var refresh_time = +Date.now()
+ app.paused = function(){}
+ app.resumed = function(){
+ geo.fetch()
+ var now = +Date.now()
+ if (now - refresh_time > 60 * 60 * 1000) {
+ refresh_time = now
+ app.blog.refresh()
+ }
+ }
+
return app
})()
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
index 0de80048..0d6fa807 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
@@ -3,22 +3,38 @@ var SettingsView = FormView.extend({
el: "#settings",
events: {
+ "change [name=store]": "changeStore",
+ "change [name=hub]": "changeHub",
},
initialize: function(){
this.$form = this.$("form")
this.$msg = this.$(".msg")
+ this.$store = this.$("[name=store]")
+ this.$hub = this.$("[name=hub]")
this.scroller = new IScroll('#settings', app.iscroll_options)
},
show: function(){
if (! auth.logged_in()) { return app.router.go("intro") }
- app.footer.show("SAVE")
document.body.className = "settings"
this.deferScrollToTop()
+
+ this.$store.prop("checked", !! push.settings.store)
+ this.$hub.prop("checked", !! push.settings.hub)
+ // push.subscribe("store")
+ // push.subscribe("hub")
},
-
- save: function(){
+
+ changeStore: function(){
+ var state = app.settings.$store.prop("checked")
+ if (state) { push.subscribe("store") }
+ else { push.unsubscribe('store') }
+ },
+ changeHub: function(){
+ var state = app.settings.$hub.prop("checked")
+ if (state) { push.subscribe("hub") }
+ else { push.unsubscribe('hub') }
},
}) \ No newline at end of file
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 254df6d1..a1863b67 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/ArchiveView.js
@@ -78,6 +78,7 @@ var ArchiveView = ScrollableView.extend({
count = count || row.images.length
row.images.forEach(function(cell, i){
+ if (count && i > count) { return }
var $t = $("<div>")
$t.addClass("row").addClass("loading")
var t = this.row_template.replace(/{{image}}/, cell.uri)
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 9b49abbd..02491b32 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js
@@ -17,6 +17,11 @@ var BlogView = View.extend({
})
},
+ refresh: function(){
+ this.loaded = false
+ this.fetch()
+ },
+
success: function(data){
if (this.loaded) return
@@ -24,20 +29,6 @@ var BlogView = View.extend({
this.loaded = true
this.data = data = typeof data == "string" ? JSON.parse(data) : data
- app.archive.populate(data.archive)
- this.loader.preloadImage(data.hub[0].image[0].uri, function(img){
- app.hub.populate(data.hub)
- })
- this.loader.preloadImage(data.story[0].image.uri, function(img){
- app.story.populate(data.story)
- })
- data.page.forEach(function(page){
- app[page.tag].populate(page)
-
- })
- app.collection.setCollectionName( data.store[0].collection )
-
- app.closed.populate(data.store[0].ClosedStoreImages)
switch (data.store[0].StoreStatus) {
case "open":
app.closed.storeIsClosed = false
@@ -51,6 +42,32 @@ var BlogView = View.extend({
app.closed.storeOpenDate = moment(data.store[0].OpensOn)
break
}
+
+ if (app.closed.storeIsClosed) {
+ app.closed.populate(data.store[0].ClosedStoreImages)
+ }
+ else {
+ app.gallery_id = data.store[0].CollectionId
+ app.collection.setCollectionName( data.store[0].collection )
+ app.collection.fetch()
+ }
+
+ app.archive.populate(data.archive)
+ this.loader.preloadImage(data.hub[0].image[0].uri, function(img){
+ app.hub.populate(data.hub)
+ }.bind(this))
+ this.loader.preloadImage(data.story[0].image.uri, function(img){
+ app.story.populate(data.story)
+ setTimeout(function(){
+ this.loader.preloadImage(data.story[1].image.uri)
+ this.loader.preloadImage(data.story[2].image.uri)
+ }.bind(this), 2000)
+ }.bind(this))
+
+ data.page.forEach(function(page){
+ app[page.tag].populate(page)
+ })
+
console.log(data.store[0].StoreStatus)
var fits_large = (data.store[0].FitsLarge === "true")
@@ -61,10 +78,6 @@ var BlogView = View.extend({
app.collection.$el.addClass("gray")
app.product.gallery.$el.addClass("gray")
}
-
- app.gallery_id = data.store[0].CollectionId
-
- app.collection.fetch()
},
}) \ No newline at end of file
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 49c05ff6..a6c4384b 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
@@ -107,7 +107,7 @@ var HubView = ScrollableView.extend({
},
share: function(){
- window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/")
+ window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/" )
},
}) \ No newline at end of file
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 a10c8351..c2a9f4b4 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/StoryView.js
@@ -15,6 +15,7 @@ var StoryView = ScrollableView.extend({
this.$content = this.$(".content")
this.$links = this.$(".links")
this.$loader = this.$(".loader")
+ this.loader = new Loader ()
this.scroller = new IScroll('#story', app.iscroll_options)
},
@@ -25,7 +26,7 @@ var StoryView = ScrollableView.extend({
},
populate: function(data){
- if (this.loaded) { console.warn("populate called twice"); return }
+ if (this.loaded) {}
this.loaded = true
this.data = data
this.$loader.hide()
@@ -58,10 +59,10 @@ var StoryView = ScrollableView.extend({
this.$content.find("[data-id=" + id + "]").addClass("active")
var section = this.sections[id]
- var replace = this.$img
- // optional image transition.. ?
+ var $replace = this.$img
+
this.$img.fadeTo(110,0.65, function() {
- replace.attr("src", section.image.uri)
+ $replace.attr("src", section.image.uri)
}).fadeTo(130,1)
this.deferScrollToTop()
},
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js b/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
index ab0c0141..4e771b62 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
@@ -1 +1,76 @@
-// \ No newline at end of file
+var push = (function(){
+ var appId = "GS82ZxpN8Mecpc53rsyu6aLLGK0W4CKi42J25DLB"
+ var clientKey = "hQRtQfsgimYnX5PMivtcdXCG9eZhESeyTr0Rd8Sv"
+ var push = { settings: {} }
+ var parsePlugin
+ push.init = function(){
+ parsePlugin = window.parsePlugin || { initialize: function(){} }
+ parsePlugin.initialize(appId, clientKey, push.did_initialize, push.error)
+ }
+ push.did_initialize = function() {
+ parsePlugin.registerCallback('onNotification', function(){
+ window.onNotification = push.got_push_notification
+ }, push.error)
+
+ push.settings.requested = localStorage.getItem("yoox.push_requested") == "true"
+ push.settings.hub = localStorage.getItem("yoox.push_hub") == "true"
+ push.settings.store = localStorage.getItem("yoox.push_store") == "true"
+
+ if ( ! push.settings.requested ) {
+ localStorage.setItem("yoox.push_" + channel, "true")
+ push.subscribe("hub", function(){
+ push.subscribe("store")
+ })
+ }
+ }
+ push.subscribe = function(channel, cb){
+ parsePlugin.subscribe(channel, function(){
+ push.settings[channel] = true
+ localStorage.setItem("yoox.push_" + channel, "true")
+ console.log("subscribed to", channel)
+ cb && cb()
+ }, push.error)
+ }
+ push.unsubscribe = function(channel, cb){
+ parsePlugin.unsubscribe(channel, function(){
+ push.settings[channel] = false
+ localStorage.setItem("yoox.push_" + channel, "false")
+ console.log("unsubscribed from", channel)
+ cb && cb()
+ }, push.error)
+ }
+ // parsePlugin.getInstallationId(function(id) {
+ // var install_data = {
+ // installation_id: id,
+ // channels: ['SampleChannel']
+ // }
+ // }, push.error)
+ push.got_push_notification = function(push_obj) {
+ // alert('We received this push notification: ' + JSON.stringify(push_obj));
+ app.blog.refresh()
+
+ try {
+ var is_hub = JSON.stringify(push_obj || {}).match(/hub/i)
+ if (is_hub) {
+ app.intro.$alert.show().html("[ HUB UPDATED ]")
+ }
+ else {
+ app.intro.$alert.show().html("[ STORE UPDATED ]")
+ }
+ }
+ catch (e) {
+ app.intro.$alert.show().html("[ HUB UPDATED ]")
+ }
+
+ if (push_obj.receivedInForeground === false) {
+ // TODO: route the user to the uri in push_obj
+ }
+ else {
+ app.route("intro")
+ }
+ }
+ push.error = function(e){
+ console.log("push error")
+ }
+ return push
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js
index 2d8dca43..8797241f 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/IntroView.js
@@ -10,8 +10,10 @@ var IntroView = View.extend({
},
initialize: function(){
+ this.$alert = this.$(".alert")
this.compass = this.$("#compass").get(0)
this.orient = this.deviceorientation.bind(this)
+ this.$alert.hide()
},
show: function(){
@@ -24,6 +26,7 @@ var IntroView = View.extend({
hide: function(){
window.removeEventListener("deviceorientation", this.orient)
+ this.$alert.hide()
},
deviceorientation: function(e){
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js
index 704aaa34..71314559 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js
@@ -34,6 +34,7 @@ var NavView = View.extend({
"click .fb": "fb",
"click .insta": "insta",
"click .tw": "tw",
+ "click .yt": "yt",
},
initialize: function(){
@@ -153,5 +154,8 @@ var NavView = View.extend({
tw: function(){
window.open("https://twitter.com/stoneisland", '_system')
},
+ yt: function(){
+ window.open("https://www.youtube.com/user/StoneIslandOfficial", '_system')
+ },
})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js
index 5f8c1e84..6f7b8486 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/ClosedStoreView.js
@@ -12,6 +12,7 @@ var ClosedStoreView = View.extend({
timeout: -1,
images: null,
+ images_loaded: {},
initialize: function(){
this.loader = new Loader ()
@@ -21,7 +22,6 @@ var ClosedStoreView = View.extend({
document.body.className = "closed"
this.animate()
app.footer.hide()
- console.log(this)
if (this.storeOpenDate) {
var date = moment(this.storeOpenDate).format("MM/DD")
console.log(date)
@@ -38,15 +38,27 @@ var ClosedStoreView = View.extend({
animate: function(){
this.timeout = setTimeout(this.animate.bind(this), this.delay)
+ this.next()
+ },
+
+ next: function(){
if (! this.images) return
var url = choice(this.images)
- this.loader.preloadImage(url, function(img){
- this.el.style.backgroundImage = 'url(' + img.src + ')'
- }.bind(this))
+
+ if (this.images_loaded[url]) {
+ this.el.style.backgroundImage = 'url(' + url + ')'
+ }
+ else {
+ this.loader.preloadImage(url, function(img){
+ this.el.style.backgroundImage = 'url(' + url + ')'
+ this.images_loaded[url] = true
+ }.bind(this))
+ }
},
populate: function(data){
this.images = data.map(function(img){ return img.uri })
+ this.next()
},
website_link: function(){
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
index 285e551d..484cd442 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
@@ -56,7 +56,7 @@ var ProductView = ScrollableView.extend({
cache: {},
- gallery_prev: function(){
+ gallery_left: function(){
app.product.gallery.gallery.previous()
},
gallery_right: function(){
@@ -250,8 +250,8 @@ var ProductView = ScrollableView.extend({
app.selector.select("style", colors, function(color){
this.code = color.code
this.$color.html(color.label)
-
- // UPDATE GALLERY
+ this.gallery.populate( color.code, this.details['ImageTypes'] )
+ this.gallery_right()
}.bind(this))
},
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/View.js b/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
index fe145221..2401df0d 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
@@ -59,7 +59,6 @@ var View = (function($, _){
var match = key.match(delegateEventSplitter);
var eventName = match[1], selector = match[2];
method = _.bind(method, this);
- eventName += '.delegateEvents' + this._id;
if (is_mobile) {
if (eventName === 'mouseenter' || eventName === 'mouseleave') {
continue
@@ -68,6 +67,7 @@ var View = (function($, _){
eventName = 'touchstart'
}
}
+ eventName += '.delegateEvents' + this._id;
if (selector === '') {
this.$el.on(eventName, method);
} else {
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/util.js b/StoneIsland/platforms/android/assets/www/js/vendor/util.js
index 23f55d4c..e09b6ada 100755
--- a/StoneIsland/platforms/android/assets/www/js/vendor/util.js
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/util.js
@@ -143,7 +143,7 @@ if (!Function.prototype.bind) {
}());
// Identify browser based on useragent string
-(function( ua ) {
+var browser = (function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||