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.js8
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/_router.js3
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js1
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js47
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js6
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js154
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/etc/push.js83
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js101
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js39
-rw-r--r--StoneIsland/platforms/android/assets/www/js/lib/products/filters/DepartmentFilter.js1
-rw-r--r--StoneIsland/platforms/android/assets/www/js/lib/products/filters/SizeFilter.js60
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js17
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/_sdk.js9
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/sdk/auth.js4
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/vendor/loader.js11
15 files changed, 316 insertions, 228 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/index.js b/StoneIsland/platforms/android/assets/www/js/index.js
index 06bfaaac..a28faabf 100755
--- a/StoneIsland/platforms/android/assets/www/js/index.js
+++ b/StoneIsland/platforms/android/assets/www/js/index.js
@@ -4,7 +4,13 @@ var app = (function(){
app.init = function(){
console.log("init")
- sdk.init({ env: "production" })
+ if (window.location.hostname === 'lvh.me' || window.location.hostname === 'stone.giraffe.life' || window.location.hostname === 'dev.stone.giraffe.life') {
+ console.log('launching in test mode')
+ sdk.init({ env: "test" })
+ }
+ else {
+ sdk.init({ env: "production" })
+ }
app.bind()
app.build()
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/_router.js b/StoneIsland/platforms/android/assets/www/js/lib/_router.js
index 9927712a..43438854 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/_router.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/_router.js
@@ -87,6 +87,9 @@ var SiteRouter = Router.extend({
else {
app.view = app[name]
}
+
+ window.FirebasePlugin && window.FirebasePlugin.setScreenName(name)
+
app.header.set_back( !! app.view.back )
app.view.show()
}.bind(this)
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js
index 9e6f1714..80738be0 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js
@@ -22,6 +22,7 @@ var AccountView = View.extend({
ccLookup: {},
listAddresses: function(opt){
+ opt = opt || {}
sdk.address.list({
success: function(data){
this.populateAddresses(data, opt.success)
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 5ee7f641..fd7b5212 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js
@@ -9,8 +9,8 @@ var BlogView = View.extend({
fetch: function(fn){
$.ajax({
method: "GET",
-// url: sdk.env == 'test' ? '/db.json' : "https://stone.sup.land/db.json",
- url: "https://stone.sup.land/db.json",
+ url: sdk.env === 'test' ? '/db.json' : sdk.cms() + '/db.json',
+ // url: "https://stone.giraffe.life/db.json",
success: function(data){
this.success(data)
fn && fn()
@@ -31,24 +31,41 @@ var BlogView = View.extend({
this.loaded = true
this.data = data = typeof data == "string" ? JSON.parse(data) : data
- switch (data.store[0].DepartmentStoreStatus) {
+ // sdk.env = 'test'
+
+ if (sdk.env === 'test') {
+ app.store = data.store[1]
+ }
+ else {
+ app.store = data.store[0]
+ }
+
+ switch (app.store.DepartmentStoreStatus) {
case "open":
app.closed.storeIsClosed = false
break
case "closed":
app.closed.storeIsClosed = true
- app.closed.storeClosedMessageOne = data.store[0].StoreClosedMessageOne
- app.closed.storeClosedMessageTwo = data.store[0].StoreClosedMessageTwo
+ app.closed.storeClosedMessageOne = app.store.StoreClosedMessageOne
+ app.closed.storeClosedMessageTwo = app.store.StoreClosedMessageTwo
break
}
-
- if (app.closed.storeIsClosed) {
- app.closed.populate(data.store[0].ClosedStoreImages)
+
+ if (app.closed.storeIsClosed && sdk.env !== 'test') {
+ app.closed.populate(app.store.ClosedStoreImages)
}
else {
- app.departments = data.store[0].Departments
- app.department_id = data.store[0].Departments[0].uri
- app.collection.setCollectionName( data.store[0].Departments[0].text )
+ app.departments = app.store.Departments
+ app.department_id = app.store.Departments[0].uri
+ $("#collections h1").toggleClass("single-dept", app.store.Departments.length == 1)
+ app.collection.setCollectionName( app.store.Departments[0].text )
+ //// demo department for shoes with weird SizeTypeId
+ // app.department_id = "NKDrtSC"
+ if (sdk.env === 'test') {
+ app.department_id = window.location.search.substr(1) || app.department_id
+ console.log('using test department id', app.department_id)
+ // app.department_id = 'TSTSZS'
+ }
app.collection.loaded = false
app.collection.fetch()
}
@@ -69,16 +86,16 @@ var BlogView = View.extend({
app[page.tag].populate(page)
})
- console.log(data.store[0].StoreStatus)
+ console.log(app.store.StoreStatus)
app.product.fitLargeCodes = {}
- if (data.store[0].FittingCodes.length) {
- data.store[0].FittingCodes.split("\n").forEach(function(code){
+ if (app.store.FittingCodes.length) {
+ app.store.FittingCodes.split("\n").forEach(function(code){
app.product.fitLargeCodes[code] = true
})
}
- if (data.store[0].BackgroundIsGray === "true") {
+ if (app.store.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 013c2b45..38a7eecf 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
@@ -140,6 +140,7 @@ var HubView = ScrollableView.extend({
var HubLoader = (function(){
var queue, view, item, loader
+ var count = 0
var HubLoader = {}
var loader
HubLoader.init = function(v){
@@ -151,6 +152,7 @@ var HubLoader = (function(){
}
HubLoader.load = function(){
item = queue.shift()
+ count++
if (! item) return
if (item.image && item.image.length) {
loader = new Loader (HubLoader.build)
@@ -159,7 +161,7 @@ var HubLoader = (function(){
}).filter(function(img){
return img.uri
})
- loader.preloadImages(images)
+ loader.preloadImages(images, true)
}
else {
HubLoader.build()
@@ -168,7 +170,7 @@ var HubLoader = (function(){
HubLoader.build = function(){
view.append(item)
view.scroller.refresh()
- setTimeout(HubLoader.load, 20)
+ setTimeout(HubLoader.load, count < 4 ? 50 : 5000)
}
return HubLoader
})()
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js b/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js
index eec5c415..dce8835a 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js
@@ -310,11 +310,11 @@ var BACKUP_DB = {
],
"hub": [
{
- "id": "ss_-016-collection-preview",
+ "id": "loading",
"date": "Tue, 12 Jan 2016 12:00:00 GMT",
- "title": "SS_'016 COLLECTION PREVIEW",
- "subtitle": "Stone Island App exclusive 1/12-1/19",
- "body": "The unrelenting research by Stone Island results in a collection full of textiles evolutions, finishing and dyeing, featuring pop colors and extraordinary visual effects.\r\n\r\n44447 NYLON METAL WATRO\r\nHooded blouson in Nylon Metal. Hood with half lining in cotton and half in nylon mesh. Slanting hand pockets with windproof entrance and zip fastening. Adjustable strap at cuffs. Drawstring in bottom hem. Zip fastening. \r\nNYLON METAL WATRO: The trilobate structure of the nylon yarn, with its grey weft and white ready to dye warp colors, is the grounds of the distinctive metallic and tonic sheen of Nylon Metal, one of the most versatile fabrics born of Stone Island’s textile research. The fabric is resin treated inside to achieve a mild wind and water resistance The finished piece undergoes an elaborate double dye procedure providing different tones, intensities and colors to the fibers and textile accessories of the garment. The addition of a special agent to the dye formula makes the piece anti-drop.\r\n\r\n10544 NYLON METAL \r\nOver shirt in Nylon Metal. Garment dyed. Hook fastening collar. On seam pocket along central placket, with snaps fastening. Snap-fastened cuffs. Hidden zip and snap fastening.\r\nNYLON METAL: The trilobate structure of the nylon yarn, with its grey weft and white ready to dye warp colors, is the grounds of the distinctive metallic and tonic sheen of Nylon Metal, one of the most versatile fabrics born of Stone Island’s textile research. The finished piece undergoes an elaborate double dye procedure providing different tones, intensities and colors to the fibers and textile accessories of the garment. The addition of a special agent to the dye formula makes the piece anti-drop.\r\n\r\n70532 POLYESTER SHANTUNG\r\nParka in an organic looking polyester. Hood with visor and chin strap adjustable with Velcro. Two bellows pockets on chest with flap closed by hidden snaps. Two welt pockets closed by a zip with a second snap opening that holds a cotton tape belt. Snap fasteners at cuffs. Zip and hidden button fastening.\r\nPOLYESTER SHANTUNG: organic looking polyester material with a shantung effect. The organic look is given by the highly technological spinning of the raw material and by its super tight weaving. The pieces are sewn and then garment dyed under pressure at 130°C with the addition of an anti-drop agent. The high pressure dye process compacts the material and induces the high absorption of the color recipe.\r\n\r\n41923 MEMBRANA 3L TC\r\nHooded jacket in a light 3 layers fabric. Garment dyed. Adjustable straps on hood with elasticated gathering on back. Patch pockets with zip fastening. Adjustable straps at cuffs. Elasticated adjustable drawstring on bottom edge. Zip fastening. \r\nMEMBRANA 3L TC: 3 layer light performance fabric made from an opaque nylon outer face laminated to a breathable, water resistant, windproof membrane, protected by an impalpable polyester base. Stone Island’s expertise in garment dyeing gives an outstanding color to the outer face while preserving the performance features of the inner membrane. The addition of a special agent to the dye formula makes the piece anti-drop.\r\n\r\n65260 T.CO+OLD\r\nHooded full zip sweatshirt in malfilé cotton, garment dyed to create the OLD effect, an exclusive dyeing treatment and subsequent fading on the finished garment to create a slightly worn and three-dimensional appearance. Hood drawstring in contrasting color. Pouch pockets. Ribbed side band, cuffs and bottom band. Zip fastening.\r\n\r\n530B0\r\nCardigan knit in plain stitching cotton nylon. Raised collar with concealed hood in Nylon Metal. Garment dyed. On seam pockets. Plain cuffs and bottom band with inner ribbing. Zip fastening.\r\nNYLON METAL: The trilobate structure of the nylon yarn, with its grey weft and white ready to dye warp colors, is the grounds of the distinctive metallic and tonic sheen of Nylon Metal, one of the most versatile fabrics born of Stone Island’s textile research. ",
+ "title": "STONE ISLAND",
+ "subtitle": "",
+ "body": "The unrelenting research by Stone Island results in a collection full of textiles evolutions, finishing and dyeing, featuring pop colors and extraordinary visual effects.",
"link": "",
"store": "true",
"image": [
@@ -322,155 +322,9 @@ var BACKUP_DB = {
"uri": "https://ltho.s3.amazonaws.com/1ee6abef-0677-41a6-91eb-029303995073.png",
"caption": ""
},
- {
- "uri": "https://ltho.s3.amazonaws.com/8cc1876a-10c7-4dc5-af66-18f5d1a30727.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/f83bf094-ddee-4d26-938e-d98eef0cb0eb.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/095b2d00-cda6-4275-a475-cf2b27965c29.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/b7b299c4-0f24-4d27-91c3-b2a0856e49f0.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/cb2378dd-2eff-4d92-a942-63da8f3afcea.png",
- "caption": ""
- }
],
"__index": 1,
"dateCreated": "Tue, 12 Jan 2016 15:55:24 GMT"
- },
- {
- "id": "nikelab-x-stone-island-windrunner",
- "date": "Wed, 09 Dec 2015 12:00:00 GMT",
- "title": "NikeLab x Stone Island Windrunner",
- "subtitle": "",
- "body": "<b>NikeLab partners with Stone Island to deliver a unique interpretation of its foremost apparel icon, to celebrate the beginning of  “The Year of Windrunner.</b>\r\n\r\n “An exciting co-lab. Stone Island loves challenges. We source our strength from challenges. It’s a great satisfaction to share our knowhow and expertise with Nike”.\r\n<i>Carlo Rivetti – Stone Island President and Creative Director</i>\r\n \r\nThe Nike Windrunner was born during a time of firsts. Created by Nike’s first apparel designer in 1978 and revolutionary for its raglan sleeves and 26-degree chevron yoke, the jacket became the first piece of Nike apparel worn by athletes at track and field trials before and after competition. Today, to commemorate this running icon, the Nike Windrunner experiences another first, the fabric innovation, the engineering and garment dyeing techniques of Stone Island.\r\n \r\nIn 2016 Nike is celebrating its foremost apparel icon: the Nike Windrunner Jacket. Designed in the late ‘70s, the silhouette has been a fixture on medal stands and city streets ever since. In the launch edition of this yearlong celebration Nike and Stone Island merge the distinctiveness of two brands to create a unique garment.\r\n \r\nThe chevron and hood of the NikeLab x Stone Island Windrunner are constructed with water and wind-resistant Mussola Gommata fabric, formed by bonding lightweight cotton muslin to an opaque polyurethane film. Nylon Metal, a proprietary Stone Island fabric with a metallic sheen, is featured on the body of the garment, which is lined with PrimaLoft®.\r\n \r\nWhile the exterior of the jacket is monochromatic, it mimics the traditional Nike Windrunner color blocking through Stone Island’s garment dyeing process. The result is a subtle distinction between the shades of the Mussola Gommata and Nylon Metal fabrics. The silver PrimaLoft® lining provides a stunning contrast to the monochromatic exterior, while the oversized trims contribute to a rugged look.\r\n \r\nThe NikeLab x Stone Island Windrunner will be available on December 17th at 10am PST from the Stone Island App and selected NikeLab retailers and on nike.com/nikelab.",
- "link": "http://www.stoneisland.com/experience/us/nikelab-x-stone-island/",
- "store": "true",
- "image": [
- {
- "uri": "https://ltho.s3.amazonaws.com/de454e51-59d6-4442-9faa-70d95203f6dd.jpg",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/faeb5522-8793-4a81-882f-3c378cef3192.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/1c7b2292-f4c9-4d4e-869a-4d4cad2a3820.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/0444066e-e3e7-484f-b932-43c855e2fa96.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/d5577c40-4e42-4738-be8b-12066f7a4301.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/540f859f-9684-412d-a012-bb1c2bd45bf6.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/a92f9dd6-09d2-48fb-8858-7c12693c302e.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/a46824b3-90ad-466d-97ab-090022363fa7.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/e234f3cb-38d8-442a-9bb9-95a90b166d20.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/607814ee-1435-42f5-b52d-fb7fe2001b6d.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/21475b14-e216-438a-8673-106d9322bf3e.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/131e1276-aed1-4790-8ab9-333393c3885a.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/e2808d55-7d9a-4c99-842d-16a0a300c93d.png",
- "caption": ""
- }
- ],
- "__index": 4,
- "dateCreated": "Tue, 12 Jan 2016 16:02:48 GMT"
- },
- {
- "id": "nikelab-x-stone-island-koth-ultra-mid-si",
- "date": "Wed, 09 Dec 2015 12:00:00 GMT",
- "title": "NikeLab x Stone Island Koth Ultra Mid SI",
- "subtitle": "",
- "body": "Inspired by the Nike Air Mowabb, the revolutionary 1991 sneaker-hiker hybrid, this all-weather Nike Koth Ultra Mid SI Shoe is made in Nike water resistant materials, real leather, and in Mussola Gommata, a fabric issued from the Stone Island research and treatment research, an exclusive panel dyed material made by bonding an extremely light cotton muslin to an opaque polyurethane film. The shoe features aggressive traction and flexible ankle support. Unitsole foam midsole for cushioning and durable support. Waffle rubber lugs for rugged traction and durability. Flex grooves allow for natural range of motion. Heel loop for easier on and off. Heel overlay for enhanced support. The shoe dust bag is made in 2 Stone Island fabrics, Nylon Metal, nylon canvas with a distinctive metallic and iridescent sheen, 50 Fili, a cotton/nylon canvas, both panel dyed.\r\n\r\nThe NikeLab x Stone Island Koth Ultra Mid SI will be available on December 17th at 10am PST from the Stone Island App and selected NikeLab retailers and on nike.com/nikelab.\r\n",
- "link": "http://www.stoneisland.com/experience/us/nikelab-x-stone-island/",
- "store": "true",
- "image": [
- {
- "uri": "https://ltho.s3.amazonaws.com/dd5f611f-3800-49ed-a6b1-9f6dd06cc103.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/34185ef2-1658-4472-bc3a-4d3f0c23ba2f.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/4767f114-1e8e-4ed3-856c-74f6c4342f0f.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/ed510070-9f60-45a6-aebf-2e7684b67cb3.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/c32af490-4ae5-4040-9327-02ce8808ee71.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/b913fc7d-d5d8-4047-b252-c2f404d9cb3e.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/3bea1cd4-2529-4a06-99ec-ec55c5a9f8d5.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/e29264fd-4236-4d16-938f-7dbe264c9b88.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/9c445717-dc18-4e0f-95f4-f695b13547a2.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/63cb328c-2624-4ed1-9d1e-113649be7f26.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/8ef50cce-c89d-4642-98b9-3be6ff798727.png",
- "caption": ""
- },
- {
- "uri": "https://ltho.s3.amazonaws.com/46f320b1-b908-42b5-9cad-20689c4d0d23.png",
- "caption": ""
- }
- ],
- "__index": 5,
- "dateCreated": "Tue, 12 Jan 2016 16:03:00 GMT"
}
],
"page": [
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 da63fdd1..082692ec 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/push.js
@@ -2,28 +2,38 @@ var push = (function(){
var push = { settings: {}, disabled: false }
var pushPlugin
push.init = function(){
- if (device.platform !== "ios") {
+ if (! ('device' in window) || (device.platform || "").toLowerCase() !== "ios") {
+ console.log("push disabled")
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)
+ window.FirebasePlugin.hasPermission(function(data){
+ push.did_initialize()
+ })
+
+ window.FirebasePlugin.getToken(function(token) {
+ push.got_registration(token);
+ }, function(error) {
+ console.error(error);
+ });
+
+ window.FirebasePlugin.onTokenRefresh(function(token) {
+ // save this server-side and use it to push notifications to this device
+ push.got_registration(token);
+ }, function(error) {
+ console.error(error);
+ });
+
+ // PushNotification.hasPermission(push.did_initialize)
}
push.did_initialize = function(data) {
+ console.log(data)
if (! data.isEnabled) {
+ console.log("push did not initialize")
+ window.FirebasePlugin.grantPermission()
return
}
console.log("push did initialize")
@@ -41,8 +51,8 @@ var push = (function(){
push.subscribe("store")
}
}
- push.got_registration = function(data){
- var registrationId = data.registrationId
+ push.got_registration = function(token){
+ var registrationId = token
var oldRegistrationId = localStorage.getItem("yoox.registrationId")
console.log(registrationId, oldRegistrationId)
@@ -62,12 +72,12 @@ var push = (function(){
channel: channel,
platform: device.platform,
}
- pushPlugin.subscribe(channel, function(){
+ window.FirebasePlugin.subscribe(channel, function(){
console.log("subscribed to", channel)
})
$.ajax({
method: "POST",
- url: "https://stone.sup.land/_services/push/add",
+ url: push.url('add'),
data: data,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
success: function(){
@@ -88,40 +98,55 @@ var push = (function(){
}
$.ajax({
method: "POST",
- url: "https://stone.sup.land/_services/push/remove",
+ url: push.url('remove'),
data: data,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
success: function(){
+ window.FirebasePlugin.unsubscribe(channel)
console.log("unsubscribed from", channel)
cb && cb()
},
error: push.error,
})
}
+ push.url = function(key){
+ return sdk.cms() + '/_services/push/' + key
+ }
push.got_push_notification = function(push_obj) {
- // alert('We received this push notification: ' + JSON.stringify(push_obj));
+ // console.log('We received this push notification: ' + JSON.stringify(push_obj));
+
app.blog.refresh()
+
+ push_obj.additionalData = push_obj.additionalData || {}
+
+ var is_hub = true
try {
- var is_hub = JSON.stringify(push_obj || {}).match(/hub/i)
- if (is_hub) {
- app.intro.$alert.show().html("[ HUB UPDATED ]")
- }
- else {
- auth.clear_cart()
- app.intro.$alert.show().html("[ STORE UPDATED ]")
- }
+ is_hub = JSON.stringify(push_obj || {}).match(/hub/i)
}
catch (e) {
+ }
+
+ if (is_hub) {
app.intro.$alert.show().html("[ HUB UPDATED ]")
}
+ else if (! push_obj.additionalData.url) {
+ auth.clear_cart()
+ app.intro.$alert.show().html("[ STORE UPDATED ]")
+ }
if (push_obj.additionalData.foreground === false) {
// TODO: route the user to the uri in push_obj
- pushPlugin.finish(function(){}, function(){})
+ // pushPlugin.finish(function(){}, function(){})
+ if (push_obj.additionalData.url) {
+ app.router.go(push_obj.additionalData.url)
+ }
+ }
+ else if (is_hub) {
+ app.router.go("hub")
}
else {
- app.route("intro")
+ app.router.go("intro")
}
}
push.error = function(e){
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js
index 671d36b3..7c73d66f 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/CollectionView.js
@@ -5,6 +5,7 @@ var CollectionView = ScrollableView.extend({
template: $("#collection .template").html(),
loaded: false,
data: null,
+ filtered_items: null,
items: {},
events: {
@@ -22,7 +23,8 @@ var CollectionView = ScrollableView.extend({
this.$content = this.$(".content")
this.$loader = this.$(".loader")
this.scroller = new IScroll('#collection', app.iscroll_options)
- this.filterView = new DepartmentFilter ({ parent: this })
+ this.departmentFilterView = new DepartmentFilter ({ parent: this })
+ this.sizeFilterView = new SizeFilter ({ parent: this })
},
show: function(){
@@ -34,11 +36,24 @@ var CollectionView = ScrollableView.extend({
if (sdk.env !== "test" && app.closed.storeIsClosed) {
return app.closed.show()
}
+
+// if (sdk.env === 'test' && this.data.SearchResponseFull.Results.Items.length < 4) {
+// var items = this.data.SearchResponseFull.Results.Items
+// items = items.concat(items).concat(items).concat(items)
+// items = items.concat(items).concat(items).concat(items)
+// this.data.SearchResponseFull.Results.Items = items
+// }
+
if (this.data && this.data.SearchResponseFull.Results.Items.length < 4) {
app.footer.hide()
}
- else {
- app.footer.show("FILTER")
+ if (app.store.FilterBy !== "none") {
+ if (app.store.FilterBy === "category") {
+ app.footer.show("FILTER")
+ }
+ else {
+ app.footer.show("FILTER BY " + app.store.FilterBy.toUpperCase())
+ }
}
document.body.className = "collection"
if (this.loaded) {
@@ -50,8 +65,16 @@ var CollectionView = ScrollableView.extend({
}
},
+ // called when footer is tapped - filter by (x)
save: function(){
- this.filterView.filter()
+ switch (app.store.FilterBy) {
+ case 'none':
+ this.departmentFilterView.filter()
+ break
+ case 'size':
+ this.sizeFilterView.filter()
+ break
+ }
},
fetch: function(){
@@ -82,7 +105,7 @@ var CollectionView = ScrollableView.extend({
console.log("populate 2")
this.data = data
this.loaded = false
- console.log(data)
+ // console.log(data)
}
console.log(">>>>>>>> YES ")
if (! this.loaded) {
@@ -112,26 +135,75 @@ var CollectionView = ScrollableView.extend({
// }
console.log( data.SearchResponseFull.Results.Items.length )
- data.SearchResponseFull.Results.Items.forEach(function(item){
- console.log(">>> ITEM")
- this.append(item, is_single_product)
- }.bind(this))
- this.deferScrollToTop()
+
+ var items = this.filtered_items || data.SearchResponseFull.Results.Items
+ if (app.store.GroupBy === 'size') {
+ this.groupBySize( items, is_single_product )
+ }
+ else {
+ this.appendItems( items, is_single_product )
+ }
+ // this.restoreScroll()
+ // this.deferScrollToTop()
}
this.afterFetchCallback && this.afterFetchCallback()
- app.collection.deferRefresh()
+ this.deferRefresh()
+ this.restoreScroll()
+ },
+
+ groupBySize: function(items, is_single_product){
+ var groups = {}
+ items.forEach(function(item){
+ if (! item.Sizes.length) return
+ var size = item.Sizes[0]
+ var id = size['Text']
+ if ( ! (id in groups) ) {
+ groups[id] = {
+ label: SIZE_LOOKUP[ id ],
+ items: [],
+ }
+ }
+ groups[id].items.push( item )
+ }.bind(this))
+
+ Object.keys(groups).sort(function(a,b){
+ var ao = SIZE_ORDER.indexOf( a )
+ var bo = SIZE_ORDER.indexOf( b )
+ return ao - bo
+ }).forEach(function(id){
+ var size = groups[id]
+ var $el = $("<div>")
+ $el.addClass("product-group")
+ $el.html( size.label )
+ this.$content.append($el)
+ this.appendItems( size.items, is_single_product )
+ }.bind(this))
+ },
+
+ appendItems: function(items, is_single_product){
+ items.forEach(function(item){
+ this.append(item, is_single_product)
+ }.bind(this))
},
append: function(item, is_single_product){
this.items[ item['Code8'] ] = item
var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], is_single_product ? '13_f' : '11_f'))
.replace(/{{code8}}/, item['Code8'])
- this.$content.append(t)
+ var $t = $(t)
+ if (app.store.ShowProductNameOnCollectionPage) {
+ var $title = $("<span>")
+ $title.addClass("product-title")
+ $title.html( item['ModelNames'] )
+ $t.append($title)
+ }
+ this.$content.append($t)
},
pick: function(e){
var code = $(e.currentTarget).data("code")
var data = this.items[code]
+ this.saveScroll()
app.product.load(code, data)
},
@@ -141,8 +213,11 @@ var CollectionView = ScrollableView.extend({
this.$title.html(this.collectionName)
},
+ // filter by department
showDepartmentSelector: function(){
- this.filterView.filter()
+ if (this.$("h1").hasClass("single-dept")) {
+ this.departmentFilterView.filter()
+ }
},
firstTouch: { x: 0, y: 0, id: "" },
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 81ad536d..2743946a 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js
@@ -16,7 +16,7 @@ var ProductView = ScrollableView.extend({
this.gallery = new GalleryView ()
this.scroller = new IScroll('#product', app.iscroll_options)
- this.$num = this.$(".num")
+ this.$productHeader = this.$(".product-header")
this.$title = this.$(".title")
this.$type = this.$(".type")
this.$price = this.$(".price")
@@ -113,12 +113,12 @@ var ProductView = ScrollableView.extend({
var descriptions = this.get_descriptions(details)
- var name_partz = data['ModelNames'].split(' ')
- var num = name_partz.shift()
- var title = name_partz.join(' ')
+ var title = data['ModelNames']
var type = title_case( data['MicroCategory'] )
var price = "$" + data['DiscountedPrice'] + ".00"
- var body = descriptions['Details'] + " " + descriptions['EditorialDescription']
+ var details_description = descriptions['Details'] || ""
+ var editorial = descriptions['EditorialDescription'] || ""
+ var body = details_description + " " + editorial
// body = body.replace(/<br>/g, "<br><br>").replace(/(<br>)+$/, "")
var default_color_id = this.populate_selectors(data, details)
@@ -162,11 +162,14 @@ var ProductView = ScrollableView.extend({
console.log( data['DefaultCode10'] )
- this.$num.html(num)
this.$title.html(title)
this.$type.html(type)
this.$price.html(price)
this.$body.html(body)
+
+ window.FirebasePlugin && window.FirebasePlugin.setScreenName('product:' + code)
+
+ this.$productHeader.toggleClass("wide", title.length > 48)
var fits_large = !! this.fitLargeCodes[this.code]
app.product.$fit.toggle( fits_large )
@@ -196,8 +199,11 @@ var ProductView = ScrollableView.extend({
populate_selectors: function(data, details){
var sizes = {}, colors = {}, size_lookup = {}, default_color
- console.log(details['Item']['ModelColors'].length)
- if (! details['Item']['ModelColors'].length) {
+
+ var modelColors = details['Item']['ModelColors'] || []
+ console.log('colors:', modelColors.length || "none")
+
+ if (! modelColors.length) {
this.not_available = true
return
}
@@ -205,7 +211,7 @@ var ProductView = ScrollableView.extend({
this.not_available = false
}
- details['Item']['ModelColors'].forEach(function(color, index){
+ modelColors.forEach(function(color, index){
if (! default_color || color['Code10'] == data['DefaultCode10']) {
default_color = color['ColorId']
}
@@ -218,10 +224,21 @@ var ProductView = ScrollableView.extend({
})
details['Item']['ModelSizes'].forEach(function(size){
- var label = SIZE_LOOKUP[ size['Default']['Text'] ]
- if (! label && ! size['Default']['Labeled']) {
+ var label = ""
+ if (details['Item']['SizeTypeId'] == 412) { // shoes
label = size['Default']['Text'] + " " + size['Default']['ClassFamily']
+ console.log("shoes?", label)
}
+ else { // everything else
+ label = SIZE_LOOKUP[ size['Default']['Text'] ]
+ }
+ if (! label) {
+ label = size['Default']['Text']
+ if (size['Default']['Labeled']) {
+ label += " " + size['Default']['ClassFamily']
+ }
+ }
+ console.log(size)
size_lookup[ label ] = size['SizeId']
console.log( label )
sizes[ size['SizeId'] ] = {
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/filters/DepartmentFilter.js b/StoneIsland/platforms/android/assets/www/js/lib/products/filters/DepartmentFilter.js
index cc0d925e..7d5ccf3d 100644
--- a/StoneIsland/platforms/android/assets/www/js/lib/products/filters/DepartmentFilter.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/filters/DepartmentFilter.js
@@ -6,7 +6,6 @@ var DepartmentFilter = View.extend({
filter: function(){
var deps = app.departments.map(function(dep){
- console.log(dep)
return {
id: dep.uri,
label: dep.text,
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/filters/SizeFilter.js b/StoneIsland/platforms/android/assets/www/js/lib/products/filters/SizeFilter.js
new file mode 100644
index 00000000..d0231021
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/products/filters/SizeFilter.js
@@ -0,0 +1,60 @@
+var SizeFilter = View.extend({
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ },
+
+ filter: function(){
+ var seen_sizes = {}
+ var sizes = []
+ this.parent.data.SearchResponseFull.Results.Items.forEach(function(item){
+ item.Sizes.forEach(function(size){
+ if (size.Id in seen_sizes) {
+ return
+ }
+ seen_sizes[size.Id] = true
+ sizes.push(size)
+ })
+ })
+ sizes.sort(function(a,b){
+ return a.Id - b.Id
+ })
+
+ var cats = sizes.map(function(cat){
+ return {
+ id: cat.Id,
+ label: cat.Text,
+ }
+ })
+ if (this.last_choice) {
+ cats.push({
+ id: "__remove_filter",
+ label: "REMOVE FILTER",
+ })
+ }
+ app.selector.select("wide", cats, this.pick.bind(this))
+ },
+
+ last_choice: null,
+
+ pick: function(choice){
+ this.parent.$content.empty()
+ if (choice.id == "__remove_filter") {
+ this.last_choice = null
+ this.parent.filtered_items = null
+ this.parent.data.SearchResponseFull.Results.Items.forEach(this.parent.append.bind(this.parent))
+ }
+ else {
+ this.last_choice = choice
+ console.log("filtering for size", choice.id)
+ var items = this.parent.data.SearchResponseFull.Results.Items.filter(function(item){
+ console.log(item.Sizes.map(function(s){ return s }))
+ return item.Sizes.some(function(size){ return size.Id == choice.id })
+ })
+ this.parent.filtered_items = items
+ items.forEach(this.parent.append.bind(this.parent))
+ }
+ this.parent.deferScrollToTop()
+ },
+
+})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
index 0baff845..7f90929a 100755
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
@@ -5,9 +5,26 @@ var ScrollableView = View.extend({
},
deferScrollToTop: function(){
+ this.scrollPosition = 0
setTimeout(this.scrollToTop.bind(this), 0)
},
+ scrollPosition: 0,
+
+ resetScroll: function(){
+ this.scrollPosition = 0
+ },
+
+ saveScroll: function(){
+ this.scrollPosition = this.scroller.y
+ },
+
+ restoreScroll: function(){
+ setTimeout(function(){
+ this.scroller.scrollTo(0, this.scrollPosition)
+ }.bind(this), 0)
+ },
+
refreshScroller: function(){
this.scroller.refresh()
clearTimeout( this.scrollerRefreshTimeout )
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js b/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js
index 017df015..c251e364 100755
--- a/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js
@@ -9,7 +9,7 @@ var sdk = (function(){
sdk.init = function(opt){
switch (sdk.env = opt.env || "development") {
case 'test':
- endpoint = "http://lvh.me:9090/"
+ endpoint = window.location.origin + "/"
break
default:
case 'development':
@@ -26,7 +26,12 @@ var sdk = (function(){
}
sdk.image = function(code, size){
- return "http://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_" + size + ".jpg"
+ return "https://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_" + size + ".jpg"
+ }
+
+ sdk.cms = function(){
+ return "http://staging.stone.giraffe.life"
+ // return "https://stone.giraffe.life"
}
$.ajaxSetup({
diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/auth.js b/StoneIsland/platforms/android/assets/www/js/sdk/auth.js
index fa8dd71c..bcfb2d3a 100755
--- a/StoneIsland/platforms/android/assets/www/js/sdk/auth.js
+++ b/StoneIsland/platforms/android/assets/www/js/sdk/auth.js
@@ -51,6 +51,9 @@ var auth = sdk.auth = (function(){
localStorage.setItem("yoox.access_token", access_token)
localStorage.setItem("yoox.user_id", user_id)
+
+ window.FirebasePlugin && window.FirebasePlugin.setUserId(user_id)
+
cb && cb()
}
auth.get_user = function(cb){
@@ -63,6 +66,7 @@ var auth = sdk.auth = (function(){
auth.user_id = -1
localStorage.removeItem("yoox.access_token")
localStorage.removeItem("yoox.user_id")
+
cb && cb()
}
diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/loader.js b/StoneIsland/platforms/android/assets/www/js/vendor/loader.js
index cc9644f8..ccfcdc9e 100755
--- a/StoneIsland/platforms/android/assets/www/js/vendor/loader.js
+++ b/StoneIsland/platforms/android/assets/www/js/vendor/loader.js
@@ -62,25 +62,28 @@ var Loader = Loader || (function(){
}
// Preload the images in config.images
- Loader.prototype.preloadImages = function(images){
+ Loader.prototype.preloadImages = function(images, register){
this.register("preload");
for (var i = 0; i < images.length; i++) {
- this.preloadImage(images[i]);
+ this.preloadImage(images[i], register);
}
this.ready("preload");
}
Loader.prototype.preloadImage = function(src, register, cb){
if (! src || src == "none") return;
var _this = this;
- if (! cb && typeof register !== "string") {
+ if (! cb && typeof register !== "boolean") {
cb = register
register = null
}
if (register) {
this.register(src);
}
- var img = new Image();
+ var img = new Image()
+ var loaded = false
img.onload = function(){
+ if (loaded) return
+ loaded = true
if (cb) {
cb(img);
}