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/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 + 4 files changed, 16 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/js') 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