From b2f133ffe639ecd7d6fb8158341208e2b24d7fb5 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 22:46:52 -0500 Subject: geo --- StoneIsland/www/css/blogs.css | 4 ++++ StoneIsland/www/index.html | 2 ++ StoneIsland/www/js/index.js | 1 + StoneIsland/www/js/lib/etc/geo.js | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 StoneIsland/www/js/lib/etc/geo.js (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/css/blogs.css b/StoneIsland/www/css/blogs.css index 19e3f8fd..455b76d5 100644 --- a/StoneIsland/www/css/blogs.css +++ b/StoneIsland/www/css/blogs.css @@ -226,6 +226,10 @@ ul.links { transform: translateZ(0) translateX(-50%) translateY(-50%); } +#archive .menu .items { + border-top: 1px solid transparent; +} + #archive.menu .menu { opacity: 1; pointer-events: auto; diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index 5bab617f..7bd73c84 100644 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -1063,6 +1063,8 @@ + + diff --git a/StoneIsland/www/js/index.js b/StoneIsland/www/js/index.js index 208eab21..1f2de128 100644 --- a/StoneIsland/www/js/index.js +++ b/StoneIsland/www/js/index.js @@ -64,6 +64,7 @@ var app = (function(){ app.ready = function(){ if (window.cordova) { cordova.plugins.Keyboard.disableScroll(true) + geo.fetch() } app.view = null diff --git a/StoneIsland/www/js/lib/etc/geo.js b/StoneIsland/www/js/lib/etc/geo.js new file mode 100644 index 00000000..0270d681 --- /dev/null +++ b/StoneIsland/www/js/lib/etc/geo.js @@ -0,0 +1,33 @@ +var geo = (function(){ + var geo = {} + + geo.fetch = function(){ + navigator.geolocation.getCurrentPosition(geo.success, geo.error, {timeout: 15000}) + } + + geo.success = function(position){ + var lat_str = as_degrees( position.coords.latitude ) + var lng_str = as_degrees( position.coords.longitude ) + } + + geo.error = function(error){ + $(".latlng").html( "+40° 58' 90\" -74° 04' 46\"" ) + } + + function as_degrees (n) { + var s = "" + if (n >= 0) s += "+" + s += Math.floor(n) + "° " + + n %= 1 + n *= 60 + s += Math.floor(n) + "'" + + n %= 1 + n *= 60 + + s += Math.floor(n) + '"' + } + + return geo +})() \ No newline at end of file -- cgit v1.2.3-70-g09d2 From ef14c875d7056f90be606ebf1f389c112b947f81 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 23:07:12 -0500 Subject: canadian country code --- .../ios/StoneIsland/StoneIsland-Info.plist | 9 + StoneIsland/platforms/ios/www/cordova_plugins.js | 10 +- .../www/ios/LaunchMyApp.js | 11 + .../LaunchMyApp-PhoneGap-Plugin.iws | 1242 ++++++++++++++++++++ .../cordova-plugin-customurlscheme/README.md | 201 ++++ .../atlassian-ide-plugin.xml | 5 + .../cordova-plugin-customurlscheme/package.json | 43 + .../cordova-plugin-customurlscheme/plugin.xml | 107 ++ .../android/nl/xservices/plugins/LaunchMyApp.java | 136 +++ .../www/android/LaunchMyApp.js | 24 + .../www/ios/LaunchMyApp.js | 9 + .../www/windows/LaunchMyApp.js | 10 + StoneIsland/plugins/fetch.json | 10 + StoneIsland/plugins/ios.json | 10 + StoneIsland/www/js/lib/cart/CartShipping.js | 2 +- 15 files changed, 1827 insertions(+), 2 deletions(-) create mode 100644 StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/package.json create mode 100755 StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js (limited to 'StoneIsland/www') diff --git a/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist b/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist index 160c02b8..cc7d9214 100644 --- a/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist +++ b/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist @@ -182,5 +182,14 @@ remote-notification + CFBundleURLTypes + + + CFBundleURLSchemes + + stoneisland + + + \ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/cordova_plugins.js b/StoneIsland/platforms/ios/www/cordova_plugins.js index fbdc76c9..99a9e96f 100644 --- a/StoneIsland/platforms/ios/www/cordova_plugins.js +++ b/StoneIsland/platforms/ios/www/cordova_plugins.js @@ -91,6 +91,13 @@ module.exports = [ "clobbers": [ "PushNotification" ] + }, + { + "file": "plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js", + "id": "cordova-plugin-customurlscheme.LaunchMyApp", + "clobbers": [ + "window.plugins.launchmyapp" + ] } ]; module.exports.metadata = @@ -104,7 +111,8 @@ module.exports.metadata = "cordova-plugin-geolocation": "1.0.1", "cordova-plugin-network-information": "1.0.1", "cordova-plugin-splashscreen": "2.1.0", - "phonegap-plugin-push": "1.4.4" + "phonegap-plugin-push": "1.4.4", + "cordova-plugin-customurlscheme": "4.0.0" } // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js new file mode 100644 index 00000000..3568c73f --- /dev/null +++ b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js @@ -0,0 +1,11 @@ +cordova.define("cordova-plugin-customurlscheme.LaunchMyApp", function(require, exports, module) { "use strict"; + +/* + Q: Why an empty file? + A: iOS doesn't need plumbing to get the plugin to work, so.. + - Including no file would mean the import in index.html would differ per platform. + - Also, using one version and adding a userAgent check for Android feels wrong. + - And if you're not using PhoneGap Build, you could paste your handleOpenUrl JS function here. +*/ + +}); diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws b/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws new file mode 100644 index 00000000..9879f7f4 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws @@ -0,0 +1,1242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + 1380298653954 + + + 1380299229689 + + + 1380302935690 + + + 1380305538088 + + + 1380305862564 + + + 1380306489891 + + + 1380307532008 + + + 1380307669209 + + + 1380311306948 + + + 1380311921427 + + + 1380317008739 + + + 1380317829887 + + + 1380353871771 + + + 1380358237732 + + + 1380358605885 + + + 1380376149014 + + + 1380378153190 + + + 1380383948466 + + + 1380393159906 + + + 1380393508799 + + + 1380393757355 + + + 1380393772924 + + + 1380402190419 + + + 1380402398063 + + + 1380402815702 + + + 1380488689110 + + + 1380488797067 + + + 1380488875151 + + + 1380489049263 + + + 1380489820453 + + + 1380567506465 + + + 1380567576964 + + + 1380567665822 + + + 1383169425770 + + + 1383172326587 + + + 1383174045796 + + + 1390857761557 + + + 1390857936690 + + + 1391028041914 + + + 1402048017666 + + + 1417632494865 + + + 1417703047123 + + + 1417706007258 + + + 1434477311221 + + + 1434530307503 + + + 1434577022103 + + + 1435161053225 + + + 1440664137793 + + + 1440664585797 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md b/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md new file mode 100644 index 00000000..2de829c2 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md @@ -0,0 +1,201 @@ +# Custom URL scheme PhoneGap Plugin +#### launch your app by a link like this: `mycoolapp://` +for iOS and Android, by [Eddy Verbruggen](http://www.x-services.nl) +- This repo is for PhoneGap 3.0.0 and up +- For PhoneGap 2.9.0 and lower, [switch to the phonegap-2.9.0-and-lower branch](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin/tree/phonegap-2.9.0-and-lower) + +1. [Description](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#1-description) +2. [Installation](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#2-installation) + 2. [Automatically (CLI / Plugman)](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#automatically-cli--plugman) + 2. [Manually](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#manually) + 2. [PhoneGap Build](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#phonegap-build) +3. [Usage](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#3-usage) +4. [URL Scheme hints](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#4-url-scheme-hints) +5. [License](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#5-license) + + +### BEWARE: [This Apache Cordova issue](https://issues.apache.org/jira/browse/CB-7606) causes problems with Cordova-iOS 3.7.0: the `handleOpenURL` function is not invoked upon cold start. Use a higher or lower version than 3.7.0. + +## 1. Description + +This plugin allows you to start your app by calling it with a URL like `mycoolapp://path?foo=bar` + +* Compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman) +* Submitted and waiting for approval at PhoneGap Build ([more information](https://build.phonegap.com/plugins)) + +### iOS specifics +* Forget about [using config.xml to define a URL scheme](https://build.phonegap.com/docs/config-xml#url_schemes). This plugin adds 2 essential enhancements: + - Uniform URL scheme with Android (for which there is no option to define a URL scheme via PhoneGap configuration at all). + - You still need to wire up the Javascript to handle incoming events. This plugin assists you with that. +* Tested on iOS 5.1, 6 and 7. + +### Android specifics +* Unlike iOS, there is no way to use config.xml to define a scheme for your app. Now there is. +* Tested on Android 4.3, will most likely work with 2.2 and up. + + +## 2. Installation + +### Automatically (CLI / Plugman) +LaunchMyApp is compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman). +Replace `mycoolapp` by a nice scheme you want to have your app listen to: + +Latest release on npm: +``` +$ cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp +``` + +Bleeding edge master version from Github: +``` +$ cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=mycoolapp +``` +(Note that the Phonegap CLI didn't support `--variable` before version 3.6.3, so please use the Cordova CLI as shown above in case you're on an older version) + +The LaunchMyApp.js file is brought in automatically. + +Note for iOS: there was a bug in CLI which caused an error in your `*-Info.plist`. +Please manually remove the blank line and whitespace (if any) from `NSMainNibFile` and `NSMainNibFile~ipad` (or your app won't start at all). + + +### Manually +Don't shoot yourself in the foot - use the CLI! That being said, here goes: + +#### iOS +1\. `Copy www/ios/LaunchMyApp.js` to `www/js/plugins/LaunchMyApp.js` and reference it in your `index.html`: +```html + +``` + +2\. Add this to your `*-Info.plist` (replace `URL_SCHEME` by a nice scheme you want to have your app listen to, like `mycoolapp`): +```xml +CFBundleURLTypes + + + CFBundleURLSchemes + + URL_SCHEME + + + +``` + +#### Android +1\. Copy www/android/LaunchMyApp.js to www/js/plugins/LaunchMyApp.js and reference it in your `index.html`: +```html + +``` + +2\. Add the following xml to your `config.xml` to always use the latest version of this plugin: +```xml + +``` + +3\. Copy `LaunchMyApp.java` to `platforms/android/src/nl/xservices/plugins` (create the folders) + +4\. Add the following to your `AndroidManifest.xml` inside the `/manifest/application/activity` node (replace `URL_SCHEME` by a nice scheme you want to have your app listen to, like `mycoolapp`): +```xml + + + + + + +``` + +5\. In `AndroidManifest.xml` set the launchMode to singleTask to avoid issues like [#24]. ` + + +``` + +The LaunchMyApp.js file is brought in automatically. + +NOTE: When Hydration is enabled at PGB, this plugin may not work. + +### Restoring cordova plugin settings on plugin add or update +In order to be able to restore the plugin settings on `cordova plugin add`, one need to add the following feature into config.xml. Note that if you added the plugin with the `--save` param you will find this in your `config.xml` already, except for the `variable` tag which is likely a `param` tag. [Change that.](https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/76) +```xml + + + + + +``` + +Please notice that URL_SCHEME is saved as `variable`, not as `prop`. However if you do `cordova plugin add` with a --save option, cordova will write the URL_SCHEME as a `prop`, you need to change the tag name from `param` to `variable` in this case. + +These plugin restore instructions are tested on: +cordova-cli 4.3.+ and cordova-android 3.7.1+ + + +## 3. Usage + +1a\. Your app can be launced by linking to it like this from a website or an email for example (all of these will work): +```html +Open my app +Open my app +Open my app +Open my app +``` + +`mycoolapp` is the value of URL_SCHEME you used while installing this plugin. + +1b\. If you're trying to open your app from another PhoneGap app, use the InAppBrowser plugin and launch the receiving app like this, to avoid a 'protocol not supported' error: +```html + +``` + +2\. When your app is launched by a URL, you probably want to do something based on the path and parameters in the URL. For that, you could implement the (optional) `handleOpenURL(url)` method, which receives the URL that was used to launch your app. +```javascript +function handleOpenURL(url) { + console.log("received url: " + url); +} +``` + +If you want to alert the URL for testing the plugin, at least on iOS you need to wrap it in a timeout like this: +```javascript +function handleOpenURL(url) { + setTimeout(function() { + alert("received url: " + url); + }, 0); +} +``` +A more useful implementation would mean parsing the URL, saving any params to sessionStorage and redirecting the app to the correct page inside your app. +All this happens before the first page is loaded. + +## 4. URL Scheme hints +Please choose a URL_SCHEME which which complies to these restrictions: +- Don't use an already registered scheme (like `fb`, `twitter`, `comgooglemaps`, etc). +- Use only lowercase characters. +- Don't use a dash `-` because on Android it will become underscore `_`. +- Use only 1 word (no spaces). + +TIP: test your scheme by installing the app on a device or simulator and typing yourscheme:// in the browser URL bar, or create a test HTML page with a link to your app to impress your buddies. + + +## 5. License + +[The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml b/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml new file mode 100644 index 00000000..858eed55 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json b/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json new file mode 100644 index 00000000..de90c8e2 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json @@ -0,0 +1,43 @@ +{ + "name": "cordova-plugin-customurlscheme", + "version": "4.0.0", + "description": "Launch your app by using this URL: mycoolapp://, you can add a path and even pass params like this: mycoolerapp://somepath?foo=bar", + "cordova": { + "id": "cordova-plugin-customurlscheme", + "platforms": [ + "ios", + "android", + "windows8", + "windows" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/EddyVerbruggen/Custom-URL-scheme.git" + }, + "keywords": [ + "Custom URL Scheme", + "URLscheme", + "URL scheme", + "Custom URL", + "Launch My App", + "Launch App", + "ecosystem:cordova", + "cordova-ios", + "cordova-android", + "cordova-windows", + "cordova-windows8" + ], + "engines": [ + { + "name": "cordova", + "version": ">=3.0.0" + } + ], + "author": "Eddy Verbruggen (https://github.com/EddyVerbruggen)", + "license": "MIT", + "bugs": { + "url": "https://github.com/EddyVerbruggen/Custom-URL-scheme/issues" + }, + "homepage": "https://github.com/EddyVerbruggen/Custom-URL-scheme#readme" +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml b/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml new file mode 100755 index 00000000..1e43e724 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml @@ -0,0 +1,107 @@ + + + + Custom URL scheme + + + Launch your app by using this URL: mycoolapp:// + You can add a path and even pass params like this: mycoolerapp://somepath?foo=bar + + + Eddy Verbruggen + + MIT + + Custom URL Scheme, URLscheme, URL scheme, Custom URL, Launch My App, Launch App + + https://github.com/EddyVerbruggen/Custom-URL-scheme.git + + https://github.com/EddyVerbruggen/Custom-URL-scheme/issues + + + + + + + + + + + + + + + + + CFBundleURLSchemes + + $URL_SCHEME + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java new file mode 100644 index 00000000..9d3f3d63 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java @@ -0,0 +1,136 @@ +package nl.xservices.plugins; + +import android.content.Intent; +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaActivity; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PluginResult; +import org.json.JSONArray; +import org.json.JSONException; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Locale; + +public class LaunchMyApp extends CordovaPlugin { + + private static final String ACTION_CHECKINTENT = "checkIntent"; + + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + if (ACTION_CHECKINTENT.equalsIgnoreCase(action)) { + final Intent intent = ((CordovaActivity) this.webView.getContext()).getIntent(); + final String intentString = intent.getDataString(); + if (intentString != null && intentString.contains("://") && intent.getScheme() != null) { + callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, intent.getDataString())); + intent.setData(null); + } else { + callbackContext.error("App was not started via the launchmyapp URL scheme. Ignoring this errorcallback is the best approach."); + } + return true; + } else { + callbackContext.error("This plugin only responds to the " + ACTION_CHECKINTENT + " action."); + return false; + } + } + + @Override + public void onNewIntent(Intent intent) { + final String intentString = intent.getDataString(); + if (intentString != null && intentString.contains("://") && intent.getScheme() != null) { + intent.setData(null); + try { + StringWriter writer = new StringWriter(intentString.length() * 2); + escapeJavaStyleString(writer, intentString, true, false); + webView.loadUrl("javascript:handleOpenURL('" + writer.toString() + "');"); + } catch (IOException ignore) { + } + } + } + + // Taken from commons StringEscapeUtils + private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote, + boolean escapeForwardSlash) throws IOException { + if (out == null) { + throw new IllegalArgumentException("The Writer must not be null"); + } + if (str == null) { + return; + } + int sz; + sz = str.length(); + for (int i = 0; i < sz; i++) { + char ch = str.charAt(i); + + // handle unicode + if (ch > 0xfff) { + out.write("\\u" + hex(ch)); + } else if (ch > 0xff) { + out.write("\\u0" + hex(ch)); + } else if (ch > 0x7f) { + out.write("\\u00" + hex(ch)); + } else if (ch < 32) { + switch (ch) { + case '\b': + out.write('\\'); + out.write('b'); + break; + case '\n': + out.write('\\'); + out.write('n'); + break; + case '\t': + out.write('\\'); + out.write('t'); + break; + case '\f': + out.write('\\'); + out.write('f'); + break; + case '\r': + out.write('\\'); + out.write('r'); + break; + default: + if (ch > 0xf) { + out.write("\\u00" + hex(ch)); + } else { + out.write("\\u000" + hex(ch)); + } + break; + } + } else { + switch (ch) { + case '\'': + if (escapeSingleQuote) { + out.write('\\'); + } + out.write('\''); + break; + case '"': + out.write('\\'); + out.write('"'); + break; + case '\\': + out.write('\\'); + out.write('\\'); + break; + case '/': + if (escapeForwardSlash) { + out.write('\\'); + } + out.write('/'); + break; + default: + out.write(ch); + break; + } + } + } + } + + private static String hex(char ch) { + return Integer.toHexString(ch).toUpperCase(Locale.ENGLISH); + } +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js new file mode 100644 index 00000000..19dbdc0b --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js @@ -0,0 +1,24 @@ +(function () { + "use strict"; + + var remainingAttempts = 10; + + function waitForAndCallHandlerFunction(url) { + if (typeof window.handleOpenURL == "function") { + window.handleOpenURL(url); + } else if (remainingAttempts-- > 0) { + setTimeout(function(){waitForAndCallHandlerFunction(url)}, 500); + } + } + + function triggerOpenURL() { + cordova.exec( + waitForAndCallHandlerFunction, + null, + "LaunchMyApp", + "checkIntent", + []); + } + + document.addEventListener("deviceready", triggerOpenURL, false); +}()); diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js new file mode 100644 index 00000000..a1d60818 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js @@ -0,0 +1,9 @@ +"use strict"; + +/* + Q: Why an empty file? + A: iOS doesn't need plumbing to get the plugin to work, so.. + - Including no file would mean the import in index.html would differ per platform. + - Also, using one version and adding a userAgent check for Android feels wrong. + - And if you're not using PhoneGap Build, you could paste your handleOpenUrl JS function here. +*/ diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js new file mode 100644 index 00000000..a70d5e94 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js @@ -0,0 +1,10 @@ +(function () { + function activatedHandler(e) { + if (typeof handleOpenURL == 'function' && e.uri) { + handleOpenURL(e.uri.rawUri); + } + }; + + var wui = Windows.UI.WebUI.WebUIApplication; + wui.addEventListener("activated", activatedHandler, false); +}()); diff --git a/StoneIsland/plugins/fetch.json b/StoneIsland/plugins/fetch.json index b57114f3..59ddd3e7 100644 --- a/StoneIsland/plugins/fetch.json +++ b/StoneIsland/plugins/fetch.json @@ -70,5 +70,15 @@ }, "is_top_level": true, "variables": {} + }, + "cordova-plugin-customurlscheme": { + "source": { + "type": "registry", + "id": "cordova-plugin-customurlscheme" + }, + "is_top_level": true, + "variables": { + "URL_SCHEME": "stoneisland" + } } } \ No newline at end of file diff --git a/StoneIsland/plugins/ios.json b/StoneIsland/plugins/ios.json index 337f2532..2a7a09ab 100644 --- a/StoneIsland/plugins/ios.json +++ b/StoneIsland/plugins/ios.json @@ -84,6 +84,12 @@ "xml": "remote-notification", "count": 1 } + ], + "CFBundleURLTypes": [ + { + "xml": "CFBundleURLSchemesstoneisland", + "count": 1 + } ] } } @@ -116,6 +122,10 @@ }, "phonegap-plugin-push": { "PACKAGE_NAME": "io.cordova.hellocordova" + }, + "cordova-plugin-customurlscheme": { + "URL_SCHEME": "stoneisland", + "PACKAGE_NAME": "io.cordova.hellocordova" } }, "dependent_plugins": {} diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js index 1a9653e1..9b8205c1 100644 --- a/StoneIsland/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/www/js/lib/cart/CartShipping.js @@ -101,7 +101,7 @@ var CartShipping = FormView.extend({ shipping_info.City = address_data.City shipping_info.Province = address_data.Province shipping_info.Region = address_data.Province - shipping_info.CountryCode = "US" + shipping_info.CountryCode = CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US" return shipping_info }, -- cgit v1.2.3-70-g09d2 From 83a884197ff0226631a46e4894f22b8468b15598 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 23:11:28 -0500 Subject: add deep linking lib --- StoneIsland/www/index.html | 2 ++ StoneIsland/www/js/index.js | 2 +- StoneIsland/www/js/lib/_router.js | 11 +++++++++++ StoneIsland/www/js/lib/etc/deeplink.js | 3 +++ StoneIsland/www/js/lib/etc/push.js | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 StoneIsland/www/js/lib/etc/deeplink.js create mode 100644 StoneIsland/www/js/lib/etc/push.js (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index 7bd73c84..03d4a958 100644 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -1063,6 +1063,8 @@ + + diff --git a/StoneIsland/www/js/index.js b/StoneIsland/www/js/index.js index 1f2de128..e6bdf49f 100644 --- a/StoneIsland/www/js/index.js +++ b/StoneIsland/www/js/index.js @@ -69,7 +69,7 @@ var app = (function(){ app.view = null app.router = new SiteRouter () - app.account.connect( app.router.route.bind(app.router) ) + app.account.connect( app.router.launch.bind(app.router) ) $("body").removeClass("loading") } diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js index b70d9be8..23daf4c7 100644 --- a/StoneIsland/www/js/lib/_router.js +++ b/StoneIsland/www/js/lib/_router.js @@ -47,6 +47,17 @@ var SiteRouter = Router.extend({ } } }, + + initial_route: null, + launch: function(){ + if (this.initial_route) { + this.parseRoute( this.initial_route ) + } + else { + this.route() + } + this.initial_route = null + }, go: function(url){ if (app.view && app.view.hide) { diff --git a/StoneIsland/www/js/lib/etc/deeplink.js b/StoneIsland/www/js/lib/etc/deeplink.js new file mode 100644 index 00000000..648dd167 --- /dev/null +++ b/StoneIsland/www/js/lib/etc/deeplink.js @@ -0,0 +1,3 @@ +function handleOpenURL (url) { + app.router.initial_route = url +} \ No newline at end of file diff --git a/StoneIsland/www/js/lib/etc/push.js b/StoneIsland/www/js/lib/etc/push.js new file mode 100644 index 00000000..ab0c0141 --- /dev/null +++ b/StoneIsland/www/js/lib/etc/push.js @@ -0,0 +1 @@ +// \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 2c063f920983c2b8b4584a21471c70521a391009 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 23:25:05 -0500 Subject: share links --- StoneIsland/www/js/lib/blogs/HubView.js | 5 +++++ StoneIsland/www/js/lib/products/ProductView.js | 1 + 2 files changed, 6 insertions(+) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js index a6ae958e..001b8161 100644 --- a/StoneIsland/www/js/lib/blogs/HubView.js +++ b/StoneIsland/www/js/lib/blogs/HubView.js @@ -4,6 +4,7 @@ var HubView = ScrollableView.extend({ template: $("#hub .template").html(), events: { + "click .share": "content-share", "click .store": "store_link", "click .gallery-left": "gallery_left", "click .gallery-right": "gallery_right", @@ -95,4 +96,8 @@ var HubView = ScrollableView.extend({ $(e.currentTarget).closest("hub_item").flickity('next') }, + share: function(){ + window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/") + }, + }) \ No newline at end of file diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index 92a0e0f7..d35f6385 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -263,6 +263,7 @@ var ProductView = ScrollableView.extend({ }, share: function(){ + window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/") }, }) -- cgit v1.2.3-70-g09d2 From 848730bdbc1e1b2c81274385d85fd385422323d8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 23:51:15 -0500 Subject: use_stored_credit_card --- StoneIsland/www/js/lib/auth/SignupView.js | 6 ++-- StoneIsland/www/js/lib/cart/CartPayment.js | 56 ++++++++++++++++++++--------- StoneIsland/www/js/lib/cart/CartShipping.js | 5 ++- 3 files changed, 47 insertions(+), 20 deletions(-) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/js/lib/auth/SignupView.js b/StoneIsland/www/js/lib/auth/SignupView.js index 22b310de..a78af233 100644 --- a/StoneIsland/www/js/lib/auth/SignupView.js +++ b/StoneIsland/www/js/lib/auth/SignupView.js @@ -4,7 +4,8 @@ var SignupView = FormView.extend({ action: sdk.account.signup, last_data: null, - + +/* test_data: { "Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com", "Password": "TestPassword", @@ -16,7 +17,8 @@ var SignupView = FormView.extend({ "DataProfiling": true, "DataProfiling2": true, }, - +*/ + events: { "click .privacy-msg": "privacy_link", "submit form": "save", diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js index fec5e1d1..222e2ac9 100644 --- a/StoneIsland/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/www/js/lib/cart/CartPayment.js @@ -9,6 +9,7 @@ var CartPayment = FormView.extend({ address_list_mode: false, cc_list_mode: false, + data: {}, events: { "change [name=SameAsShipping]": "toggle_shipping", @@ -28,6 +29,7 @@ var CartPayment = FormView.extend({ this.$cc_list = this.$(".cc_list") this.$cc_form = this.$(".cc") this.$cc_dropdown = this.$(".cc_dropdown") + this.$cc_confirm = this.$(".cc_confirm") this.address = new AddressView ({ parent: this, checkPhone: false }) this.cc = new CreditCardView ({ parent: this }) @@ -75,6 +77,7 @@ var CartPayment = FormView.extend({ this.cc.disabled = this.cc_list_mode this.$cc_form.toggle(! this.cc_list_mode) this.$cc_list.toggle(this.cc_list_mode) + this.$cc_confirm.toggle(this.cc_list_mode) }, populate: function(){ @@ -107,37 +110,56 @@ var CartPayment = FormView.extend({ }, finalize: function(data){ - var shipping_info = {}, address_data, address_id, cc_info = {}, cc_data, cc_id + var shipping_info = {}, address_data, address_id, cc_info = {}, cc_data, cc_id var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val() - if (this.list_mode) { - address_id = $("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() + if (this.address_list_mode) { + address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() address_data = app.account.addressLookup[ address_id ] } else { address_data = data } + if (this.cc_list_mode) { - cc_id = $("[name=CCId]").filter(function(){ return $(this).prop("checked") }).val() + cc_id = this.$("[name=CCId]").filter(function(){ return $(this).prop("checked") }).val() cc_data = app.account.ccLookup[ cc_id ] + + var card_on_file = { + "guid": cc_data.Guid, + "cvv": this.$("[name=CvvConfirm]"), + } + app.curtain.show("loading") + promise(sdk.cart.use_stored_credit_card, { data: card_on_file }).then(function(data){ + app.curtain.hide("loading") + this.success() + }.bind(this)).error(function(data){ + app.curtain.hide("loading") + }.bind(this)) + + return } else { cc_data = data } - shipping_info.Name = address_data.Name - shipping_info.Surname = address_data.Surname - shipping_info.Email = auth.user.Email - shipping_info.Phone = address_data.Phone - shipping_info.Mobile = address_data.Phone - shipping_info.StreetWithNumber = address_data.Address - shipping_info.PostalCode = address_data.ZipCode - shipping_info.City = address_data.City - shipping_info.Province = address_data.Province - shipping_info.Region = address_data.Province - shipping_info.CountryCode = "US" - - return shipping_info + var credit_info = { + "HolderName": address_data.Name, + "HolderSurname": address_data.Surname, + "HolderAddress": address_data.Adress, + "HolderCity": address_data.City, + "HolderProvince": address_data.Province, + "HolderZip": address_data.ZipCode, + "HolderISOCountry": CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US", + "HolderEmail": auth.user.Email, + "CardNumber": "", + "Type": cc_data.Type, + "ExpirationMonth": cc_data.ExpirationMonth, + "ExpirationYear": cc_data.ExpirationYear, + "Cvv": cc_data.Cvv, + } + + return credit_info }, success: function(){ diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js index 9b8205c1..ec9394da 100644 --- a/StoneIsland/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/www/js/lib/cart/CartShipping.js @@ -5,6 +5,7 @@ var CartShipping = FormView.extend({ action: sdk.cart.set_shipping_address, list_mode: true, + data: {}, template: $("#cart_shipping .template").html(), @@ -84,7 +85,7 @@ var CartShipping = FormView.extend({ }) if (this.list_mode) { - address_id = $("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() + address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() address_data = app.account.addressLookup[ address_id ] } else { @@ -103,6 +104,8 @@ var CartShipping = FormView.extend({ shipping_info.Region = address_data.Province shipping_info.CountryCode = CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US" + this.data = shipping_info + return shipping_info }, -- cgit v1.2.3-70-g09d2 From 881c5de5b7709d06e88fdf554a021b8f1eddb9ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 23:58:19 -0500 Subject: more cart --- StoneIsland/www/css/nav.css | 5 +++++ StoneIsland/www/js/lib/cart/CartPayment.js | 9 ++++++++- StoneIsland/www/js/lib/cart/CartSummary.js | 2 +- StoneIsland/www/js/lib/nav/CreditCardView.js | 1 + StoneIsland/www/js/lib/view/Serializable.js | 8 +++++--- 5 files changed, 20 insertions(+), 5 deletions(-) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/css/nav.css b/StoneIsland/www/css/nav.css index 61834f8b..814a8c3f 100644 --- a/StoneIsland/www/css/nav.css +++ b/StoneIsland/www/css/nav.css @@ -334,3 +334,8 @@ h1 { letter-spacing: 1px; font-weight: bold; } + +.msg { + padding: 20px; + display: inline-block; +} diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js index 222e2ac9..e65c7e8e 100644 --- a/StoneIsland/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/www/js/lib/cart/CartPayment.js @@ -52,6 +52,7 @@ var CartPayment = FormView.extend({ setTimeout(function(){ var state = this.$same_as_shipping.prop("checked") this.$billing_address_rapper.toggle( ! state ) + this.address.disabled = state }.bind(this)) }, @@ -113,7 +114,10 @@ var CartPayment = FormView.extend({ var shipping_info = {}, address_data, address_id, cc_info = {}, cc_data, cc_id var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val() - if (this.address_list_mode) { + if (this.$same_as_shipping.prop("checked")) { + address_data = app.cart.shipping.data + } + else if (this.address_list_mode) { address_id = this.$("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val() address_data = app.account.addressLookup[ address_id ] } @@ -129,6 +133,9 @@ var CartPayment = FormView.extend({ "guid": cc_data.Guid, "cvv": this.$("[name=CvvConfirm]"), } + + console.log("got card on file") + app.curtain.show("loading") promise(sdk.cart.use_stored_credit_card, { data: card_on_file }).then(function(data){ app.curtain.hide("loading") diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js index 72c44405..cfd34bd7 100644 --- a/StoneIsland/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/www/js/lib/cart/CartSummary.js @@ -133,7 +133,7 @@ var CartSummary = ScrollableView.extend({ updateTotals: function(){ var subtotal = this.data.Cart.Totals.TotalWithoutPromotions var shipping_cost = this.data.Cart.DeliveryMethod.Selected.Amount.Total - var tax = 0 + var tax = this.data.Cart.Totals.TotalSalesTax var total = this.data.Cart.Totals.TotalToPay this.$subtotal.html( as_cash(subtotal) ) diff --git a/StoneIsland/www/js/lib/nav/CreditCardView.js b/StoneIsland/www/js/lib/nav/CreditCardView.js index ba3ac54a..63784618 100644 --- a/StoneIsland/www/js/lib/nav/CreditCardView.js +++ b/StoneIsland/www/js/lib/nav/CreditCardView.js @@ -40,6 +40,7 @@ var CreditCardView = SerializableView.extend({ }, validate_fields: function(data, errors){ + if (this.disabled) { return } var card = this.$number.validateCreditCard(this.cardOptions) if (! card.valid) { errors.push([ "Number", "Your card number is invalid." ]) } if (! data.ExpirationMonth || data.ExpirationMonth == "NONE") { errors.push([ "ExpirationMonth", "Please enter the expiration month." ]) } diff --git a/StoneIsland/www/js/lib/view/Serializable.js b/StoneIsland/www/js/lib/view/Serializable.js index b1e095d3..6ef8eda3 100644 --- a/StoneIsland/www/js/lib/view/Serializable.js +++ b/StoneIsland/www/js/lib/view/Serializable.js @@ -68,9 +68,11 @@ var SerializableView = View.extend({ var data = data || this.serialize() var errors = errors || [] var presence_msgs = this.validate_presence || {} - Object.keys(presence_msgs).forEach(function(k){ - if (! data[k]) errors.push( [ k, presence_msgs[k] ] ) - }) + if (! this.disabled) { + Object.keys(presence_msgs).forEach(function(k){ + if (! data[k]) errors.push( [ k, presence_msgs[k] ] ) + }) + } this.validate_fields && this.validate_fields(data, errors) this.cc && this.cc.validate(data, errors) this.address && this.address.validate(data, errors) -- cgit v1.2.3-70-g09d2 From bc3d47e6f7f93640e6f183ab2664235c00057e6c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 1 Dec 2015 00:10:02 -0500 Subject: show curtain when adding to cart.. --- StoneIsland/www/js/lib/products/ProductView.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index d35f6385..5b7ee6d2 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -240,14 +240,18 @@ var ProductView = ScrollableView.extend({ app.last_view = app.cart } else if ( ! auth.has_cart() ) { + app.curtain.show("loading") auth.create_cart(function(){ auth.add_deferred_product_to_cart(function(){ + app.curtain.hide("loading") app.router.go("cart") }) }) } else { + app.curtain.show("loading") auth.add_deferred_product_to_cart(function(){ + app.curtain.hide("loading") if (opt.route) { app.router.go("cart") } -- cgit v1.2.3-70-g09d2 From 7b14d7a87af7d0bb9563672b5880c2a4042509d2 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 1 Dec 2015 00:35:28 -0500 Subject: load cart shipping from api --- StoneIsland/www/js/lib/cart/CartConfirm.js | 4 ++++ StoneIsland/www/js/lib/cart/CartPayment.js | 4 +--- StoneIsland/www/js/lib/cart/CartShipping.js | 15 +++++++++++++++ StoneIsland/www/js/lib/cart/CartSummary.js | 4 ++++ 4 files changed, 24 insertions(+), 3 deletions(-) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js index aa6ec9e4..8a6b3c0e 100644 --- a/StoneIsland/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/www/js/lib/cart/CartConfirm.js @@ -16,9 +16,13 @@ var CartConfirm = FormView.extend({ app.footer.show("PLACE ORDER", "CANCEL") window.location.hash = "#/cart/confirm" this.deferScrollToTop() + + app.curtain.show("loading") + promise(sdk.cart.get_status).then( this.populate.bind(this) ) }, populate: function(){ + app.curtain.hide("loading") }, save: function(){ diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js index e65c7e8e..749594bc 100644 --- a/StoneIsland/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/www/js/lib/cart/CartPayment.js @@ -134,8 +134,6 @@ var CartPayment = FormView.extend({ "cvv": this.$("[name=CvvConfirm]"), } - console.log("got card on file") - app.curtain.show("loading") promise(sdk.cart.use_stored_credit_card, { data: card_on_file }).then(function(data){ app.curtain.hide("loading") @@ -159,7 +157,7 @@ var CartPayment = FormView.extend({ "HolderZip": address_data.ZipCode, "HolderISOCountry": CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US", "HolderEmail": auth.user.Email, - "CardNumber": "", + "CardNumber": cc_data['Number'], "Type": cc_data.Type, "ExpirationMonth": cc_data.ExpirationMonth, "ExpirationYear": cc_data.ExpirationYear, diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js index ec9394da..dfc5cb3a 100644 --- a/StoneIsland/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/www/js/lib/cart/CartShipping.js @@ -54,6 +54,21 @@ var CartShipping = FormView.extend({ }.bind(this)) }, + load_form: function(cart_data){ + var data = cart_data.Cart.Receiver + var addy = data.StreetWithNumber.split("\n") + data.Address1 = addy[0] || "" + data.Address2 = addy[1] || "" + data.ZipCode = data.PostalCode + data.Province = data.Region + this.load_data(data) + + if (cart_data.DeliveryMethod.Selected && cart_data.DeliveryMethod.Type) { + $("#standard-shipping").prop("checked", cart_data.DeliveryMethod.Type == 1) + $("#express-shipping").prop("checked", cart_data.DeliveryMethod.Type == 2) + } + }, + toggle_dropdown: function(state){ if (! app.account.addresses.length) { state = false diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js index cfd34bd7..0ad57020 100644 --- a/StoneIsland/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/www/js/lib/cart/CartSummary.js @@ -119,6 +119,10 @@ var CartSummary = ScrollableView.extend({ }.bind(this)) }.bind(this)) + if (data.Cart.Receiver && data.Cart.Receiver.City) { + app.cart.shipping.load_form( data ) + } + this.updateTotals() this.el.className = "full" -- cgit v1.2.3-70-g09d2 From 3078a4c252135f7e8e15389522b0d5c79fc3bd8e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 1 Dec 2015 00:41:20 -0500 Subject: advance to confirm page --- StoneIsland/www/js/lib/cart/CartPayment.js | 8 +++++--- StoneIsland/www/js/lib/cart/CartShipping.js | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js index 749594bc..11d6cddf 100644 --- a/StoneIsland/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/www/js/lib/cart/CartPayment.js @@ -151,18 +151,20 @@ var CartPayment = FormView.extend({ var credit_info = { "HolderName": address_data.Name, "HolderSurname": address_data.Surname, - "HolderAddress": address_data.Adress, + "HolderAddress": address_data.Address || address_data.StreetWithNumber, "HolderCity": address_data.City, "HolderProvince": address_data.Province, - "HolderZip": address_data.ZipCode, + "HolderZip": address_data.PostalCode || address_data.ZipCode, "HolderISOCountry": CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US", "HolderEmail": auth.user.Email, "CardNumber": cc_data['Number'], "Type": cc_data.Type, "ExpirationMonth": cc_data.ExpirationMonth, - "ExpirationYear": cc_data.ExpirationYear, + "ExpirationYear": cc_data.ExpirationYear.substr(2,3), "Cvv": cc_data.Cvv, } + + console.log( credit_info ) return credit_info }, diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js index dfc5cb3a..ef906804 100644 --- a/StoneIsland/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/www/js/lib/cart/CartShipping.js @@ -63,9 +63,10 @@ var CartShipping = FormView.extend({ data.Province = data.Region this.load_data(data) - if (cart_data.DeliveryMethod.Selected && cart_data.DeliveryMethod.Type) { - $("#standard-shipping").prop("checked", cart_data.DeliveryMethod.Type == 1) - $("#express-shipping").prop("checked", cart_data.DeliveryMethod.Type == 2) + this.data = data + if (cart_data.Cart.DeliveryMethod && cart_data.Cart.DeliveryMethod.Selected && cart_data.Cart.DeliveryMethod.Type) { + $("#standard-shipping").prop("checked", cart_data.Cart.DeliveryMethod.Type == 1) + $("#express-shipping").prop("checked", cart_data.Cart.DeliveryMethod.Type == 2) } }, -- cgit v1.2.3-70-g09d2 From 9497b50fa02f3cfa9cb263ce3a96fa725282d60d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 1 Dec 2015 01:06:58 -0500 Subject: populate cartconfirm page --- StoneIsland/www/index.html | 1 - StoneIsland/www/js/lib/cart/CartConfirm.js | 103 ++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 2 deletions(-) (limited to 'StoneIsland/www') diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index 03d4a958..45a04bdf 100644 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -861,7 +861,6 @@
-
diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js index 8a6b3c0e..171f41a1 100644 --- a/StoneIsland/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/www/js/lib/cart/CartConfirm.js @@ -2,11 +2,26 @@ var CartConfirm = FormView.extend({ el: "#cart_confirm", + template: $("#cart_confirm .template").html(), + events: { }, initialize: function(opt){ this.parent = opt.parent + this.$rows = this.$(".rows") + this.$subtotal = this.$(".subtotal") + this.$shipping = this.$(".shipping") + this.$tax = this.$(".tax") + this.$total = this.$(".total") + + this.$shipping_address = this.$(".shipping_address") + this.$shipping_method = this.$(".shipping_method") + + this.$payment_name = this.$(".payment_name") + this.$payment_method = this.$(".payment_method") + this.$payment_address = this.$(".payment_address") + this.scroller = new IScroll('#cart_confirm', app.iscroll_options) }, @@ -21,7 +36,93 @@ var CartConfirm = FormView.extend({ promise(sdk.cart.get_status).then( this.populate.bind(this) ) }, - populate: function(){ + populate: function(data){ + console.log(data) + + data = data.Cart + + this.$rows.empty() + + data.Items.forEach(function(item){ + var $el = $("
") + this.$rows.append($el) + var code_ten = item.Code10 + var size_id = item.Size + + var code = code_ten.substr(0, 8) + app.product.find(code, function(data, details){ + var descriptions = app.product.get_descriptions( details ) + + var name_partz = descriptions['ModelNames'].split(' ') + var num = name_partz.shift() + var title = name_partz.join(' ') + var type = title_case( descriptions['MicroCategory'] ) + + var color_name, size_name + + details.Item.ModelColors.some(function(color){ + if (color['Code10'] == code_ten) { + color_name = color['ColorDescription'] + return true + } + return false + }) + + details.Item.ModelSizes.some(function(size){ + if (size['SizeId'] == size_id) { + // console.log(size) + size_name = size['Default']['Text'] + size_name = SIZE_LOOKUP[ size_name ] || size_name + if (! size_name && ! size['Default']['Labeled']) { + size_name = size['Default']['Text'] + " " + size['Default']['ClassFamily'] + } + + return true + } + return false + }) + +// size_name = item.DefaultSize + " " + item.DefaultSizeClassFamily + + var t = this.template + .replace(/{{image}}/, sdk.image(item['Code10'], '11_f')) + .replace(/{{sku}}/, num) + .replace(/{{title}}/, title) + .replace(/{{type}}/, type) + .replace(/{{size}}/, size_name || "DEFAULT") + .replace(/{{color}}/, color_name || "DEFAULT") + .replace(/{{quantity}}/, 1) + .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice)) + $el.data("price", details.Item.Price.DiscountedPrice) + $el.html(t) + this.refreshScroller() + }.bind(this)) + }.bind(this)) + + var subtotal = data.Totals.TotalWithoutPromotions + var shipping_cost = data.DeliveryMethod.Selected.Amount.Total + var tax = data.Totals.TotalSalesTax + var total = data.Totals.TotalToPay + + this.$subtotal.html( as_cash(subtotal) ) + this.$shipping.html( as_cash(shipping_cost) ) + this.$tax.html( as_cash(tax) ) + this.$total.html( as_cash(total) ) + + var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") + var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "
" + street + ", " + address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode + + this.$shipping_address.html(address) + this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + + var cc = data.Payment.CreditCard + var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") + var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + + this.$payment_name.html( cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() ) + this.$payment_method.html( cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 ) + app.curtain.hide("loading") }, -- cgit v1.2.3-70-g09d2