summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js')
-rwxr-xr-xStoneIsland/www/js/lib/account/SettingsView.js22
-rwxr-xr-xStoneIsland/www/js/lib/blogs/BlogView.js6
-rwxr-xr-xStoneIsland/www/js/lib/etc/push.js57
-rwxr-xr-xStoneIsland/www/js/lib/products/CollectionView.js2
4 files changed, 74 insertions, 13 deletions
diff --git a/StoneIsland/www/js/lib/account/SettingsView.js b/StoneIsland/www/js/lib/account/SettingsView.js
index 0de80048..0d6fa807 100755
--- a/StoneIsland/www/js/lib/account/SettingsView.js
+++ b/StoneIsland/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/www/js/lib/blogs/BlogView.js b/StoneIsland/www/js/lib/blogs/BlogView.js
index 59c0a192..51881aa5 100755
--- a/StoneIsland/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/www/js/lib/blogs/BlogView.js
@@ -27,14 +27,14 @@ var BlogView = View.extend({
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)
- }, 2000)
- })
+ }.bind(this), 2000)
+ }.bind(this))
data.page.forEach(function(page){
app[page.tag].populate(page)
diff --git a/StoneIsland/www/js/lib/etc/push.js b/StoneIsland/www/js/lib/etc/push.js
index 0db5c1a2..eb0dd4c3 100755
--- a/StoneIsland/www/js/lib/etc/push.js
+++ b/StoneIsland/www/js/lib/etc/push.js
@@ -1,12 +1,39 @@
var push = (function(){
var appId
var clientKey
- var push = {}
+ var push = { settings: {} }
push.init = function(){
- parsePlugin.initialize(appId, clientKey, push.subscribe, push.error)
+ parsePlugin.initialize(appId, clientKey, push.did_initialize, push.error)
}
- push.subscribe = function() {
- parsePlugin.subscribe('SampleChannel', push.did_subscribe, 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")
+ cb && cb()
+ }, push.error)
+ }
+ push.unsubscribe = function(channel, cb){
+ parsePlugin.unsubscribe(channel, function(){
+ push.settings[channel] = false
+ localStorage.setItem("yoox.push_" + channel, "false")
+ cb && cb()
+ }, push.error)
}
push.did_subscribe = function(){
// parsePlugin.getInstallationId(function(id) {
@@ -16,9 +43,27 @@ var push = (function(){
// }
// }, push.error)
}
+ push.did_unsubscribe = function(){
+ // parsePlugin.getInstallationId(function(id) {
+ // var install_data = {
+ // installation_id: id,
+ // channels: ['SampleChannel']
+ // }
+ // }, push.error)
+ }
+ push.got_push_notification = function(pnObj) {
+ alert('We received this push notification: ' + JSON.stringify(pnObj));
+ app.collection.loaded = false
+ app.hub.loaded = false
+ if (pnObj.receivedInForeground === false) {
+ // TODO: route the user to the uri in pnObj
+ }
+ else {
+ app.route("intro")
+ }
+ }
push.error = function(e){
console.log("push error")
- }
-
+ }
return push
})() \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js
index d290e4b4..7a020798 100755
--- a/StoneIsland/www/js/lib/products/CollectionView.js
+++ b/StoneIsland/www/js/lib/products/CollectionView.js
@@ -49,7 +49,7 @@ var CollectionView = ScrollableView.extend({
return
}
this.$loader.show()
- sdk.collection.all({
+ sdk.product.collection({
gallery_id: app.gallery_id,
success: this.populate.bind(this)
})