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.js1
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js14
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js4
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js4
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js2
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/push.js118
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js1
11 files changed, 110 insertions, 42 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/index.js b/StoneIsland/platforms/android/assets/www/js/index.js
index 76a8af05..06bfaaac 100755
--- a/StoneIsland/platforms/android/assets/www/js/index.js
+++ b/StoneIsland/platforms/android/assets/www/js/index.js
@@ -71,6 +71,7 @@ var app = (function(){
document.addEventListener('online', app.online, false)
document.addEventListener('offline', app.offline, false)
cordova.plugins.Keyboard.disableScroll(true)
+ cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false)
geo.fetch()
var image = new Image
image.src = "./img/compass-logo.png"
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js
index f773c05b..796ea188 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js
@@ -25,7 +25,7 @@ var PaymentView = FormView.extend({
},
initialize: function(){
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.address = new AddressView ({ parent: this, checkPhone: false })
this.cc = new CreditCardView ({ parent: this })
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js
index df6bc865..52ef8056 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js
@@ -3,12 +3,13 @@ var ProfileView = FormView.extend({
el: "#profile",
events: {
+ "click .privacy-msg": "privacy_link",
},
action: sdk.account.update,
initialize: function(){
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.scroller = new IScroll('#profile', app.iscroll_options)
},
@@ -90,6 +91,17 @@ var ProfileView = FormView.extend({
return submissible_data
},
+ privacy_link: function(){
+ // rewrite app.privacy instance temporarily
+ app.privacy.back = function(){
+ app.router.go("account/profile")
+ }
+ app.privacy.hide = function(){
+ app.privacy.back = app.privacy.hide = null
+ }
+ app.router.go("page/privacy")
+ },
+
success: function(data){
},
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 f6eae13c..90ace549 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js
@@ -8,7 +8,7 @@ var SettingsView = FormView.extend({
},
initialize: function(){
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.$store = this.$("[name=store]")
this.$hub = this.$("[name=hub]")
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js
index 71cd9eef..67a1cfec 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js
@@ -24,7 +24,7 @@ var ShippingView = FormView.extend({
},
initialize: function(){
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.address = new AddressView ({ parent: this })
this.scroller = new IScroll('#shipping', app.iscroll_options)
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js
index d7968c22..aeb15d1d 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/LoginView.js
@@ -11,7 +11,7 @@ var LoginView = FormView.extend({
},
initialize: function(){
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.scroller = new IScroll('#login', app.iscroll_options)
},
@@ -23,7 +23,7 @@ var LoginView = FormView.extend({
}
var msg = "* Your personal and payment<br>information will always remain private"
app.footer.show("SUBMIT")
- this.$form.get(0).reset()
+ this.$("input").val("")
this.$msg.html(msg)
document.body.className = "login"
},
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js
index fd0c1887..220026c0 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js
@@ -24,7 +24,7 @@ var SignupView = FormView.extend({
},
initialize: function(){
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.scroller = new IScroll('#signup', app.iscroll_options)
},
@@ -36,7 +36,7 @@ var SignupView = FormView.extend({
}
var msg = "* Your personal and payment<br>information will always remain private"
app.footer.show("SUBMIT")
- this.$form.get(0).reset()
+ this.$("input").val("")
this.$msg.html(msg)
document.body.className = "signup"
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js
index a19e69a5..31c371a5 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js
@@ -19,7 +19,7 @@ var CartPayment = FormView.extend({
initialize: function(opt){
this.parent = opt.parent
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$msg = this.$(".msg")
this.$same_as_shipping = this.$("[name=SameAsShipping]")
this.$billing_address_rapper = this.$(".billing_address_rapper")
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js
index fd227324..536b5161 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js
@@ -15,7 +15,7 @@ var CartShipping = FormView.extend({
initialize: function(opt){
this.parent = opt.parent
- this.$form = this.$("form")
+ this.$form = this.$(".form")
this.$dropdown_wrapper = this.$(".dropdown-wrapper")
this.$address_list = this.$(".address_list")
this.$address_form = this.$(".address")
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 634ffe6d..da63fdd1 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
@@ -1,50 +1,103 @@
var push = (function(){
- var appId = "GS82ZxpN8Mecpc53rsyu6aLLGK0W4CKi42J25DLB"
- var clientKey = "hQRtQfsgimYnX5PMivtcdXCG9eZhESeyTr0Rd8Sv"
- var push = { settings: {} }
- var parsePlugin
+ var push = { settings: {}, disabled: false }
+ var pushPlugin
push.init = function(){
- parsePlugin = window.parsePlugin || { initialize: function(){} }
- parsePlugin.initialize(appId, clientKey, push.did_initialize, push.error)
+ if (device.platform !== "ios") {
+ push.disabled = true
+ return
+ }
+
+ pushPlugin = PushNotification.init({
+ ios: {
+ alert: true,
+ badge: true,
+ sound: false,
+ clearBadge: true,
+ },
+ })
+
+ console.log("push init")
+
+ PushNotification.hasPermission(push.did_initialize)
+ pushPlugin.on('registration', push.got_registration)
+ pushPlugin.on('notification', push.got_push_notification)
}
- push.did_initialize = function() {
- parsePlugin.registerCallback('onNotification', function(){
- window.onNotification = push.got_push_notification
- }, push.error)
+ push.did_initialize = function(data) {
+ if (! data.isEnabled) {
+ return
+ }
+ console.log("push did initialize")
+ var hub_status = localStorage.getItem("yoox.push_hub")
+ var store_status = localStorage.getItem("yoox.push_store")
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"
+ push.settings.hub = hub_status == "true"
+ push.settings.store = store_status == "true"
+
+ if (! hub_status || hub_status == "true") {
+ push.subscribe("hub")
+ }
+ if (! store_status || store_status == "true") {
+ push.subscribe("store")
+ }
+ }
+ push.got_registration = function(data){
+ var registrationId = data.registrationId
+ var oldRegistrationId = localStorage.getItem("yoox.registrationId")
+ console.log(registrationId, oldRegistrationId)
- if ( ! push.settings.requested ) {
- localStorage.setItem("yoox.push_requested", "true")
+ if (registrationId !== oldRegistrationId || ! push.settings.requested) {
+ localStorage.setItem("yoox.registrationId", registrationId)
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")
+ if (push.disabled) return
+ push.settings[channel] = true
+ localStorage.setItem("yoox.push_" + channel, "true")
+ var data = {
+ registrationId: localStorage.getItem("yoox.registrationId"),
+ channel: channel,
+ platform: device.platform,
+ }
+ pushPlugin.subscribe(channel, function(){
console.log("subscribed to", channel)
- cb && cb()
- }, push.error)
+ })
+ $.ajax({
+ method: "POST",
+ url: "https://stone.sup.land/_services/push/add",
+ data: data,
+ contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
+ success: function(){
+ console.log("subscribed to", channel)
+ cb && cb()
+ },
+ error: 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)
+ if (push.disabled) return
+ push.settings[channel] = false
+ localStorage.setItem("yoox.push_" + channel, "false")
+ var data = {
+ registrationId: localStorage.getItem("yoox.registrationId"),
+ channel: channel,
+ platform: device.platform,
+ }
+ $.ajax({
+ method: "POST",
+ url: "https://stone.sup.land/_services/push/remove",
+ data: data,
+ contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
+ success: function(){
+ console.log("unsubscribed from", channel)
+ cb && cb()
+ },
+ error: 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()
@@ -63,8 +116,9 @@ var push = (function(){
app.intro.$alert.show().html("[ HUB UPDATED ]")
}
- if (push_obj.receivedInForeground === false) {
+ if (push_obj.additionalData.foreground === false) {
// TODO: route the user to the uri in push_obj
+ pushPlugin.finish(function(){}, function(){})
}
else {
app.route("intro")
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
index 8d25daf4..fa4eba02 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
@@ -128,6 +128,7 @@ var SerializableView = View.extend({
}
else {
this.hide_errors()
+ cordova.plugins.Keyboard.close()
}
var finalized_data = this.finalize(valid.data)