From a11cb68301335ed1ef064b65c5cd4e170588549b Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 5 Jul 2012 23:08:19 +0200 Subject: [PATCH] index: fix url controller --- index.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index d8f18684..721f7e0b 100644 --- a/index.js +++ b/index.js @@ -437,8 +437,7 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( app.url.push({page: 'examples', item: data.id}); }, select: function(data) { - app.user.item.doc = data.id; - app.url.push(); + app.url.push({item: data.id}); } }) .bindEventOnce({ @@ -470,14 +469,11 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( .bindEvent({ change: function(data) { app.url.push({ - page: 'examples', - item: app.user.item.examples, mode: data.value == 'live' ? 'live' : '' }); }, select: function(data) { - app.user.item.examples = data.id; - app.url.push(); + app.url.push({item: data.id}); } }); }, @@ -542,8 +538,7 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( .bindEvent({ change: function(data) { if (app.state.loaded) { - app.user.page = data.selected; - app.url.push(); + app.url.push({page: data.selected}); } } }); @@ -629,8 +624,7 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( ); }); }); - app.user.item.readme = id; - app.url.push(); + app.url.push({item: id}); } return $panel; }, @@ -681,14 +675,9 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( if (!app.user.page || !app.user.previousPage) { app.animate(); } - Ox.print('URL CHANGE', JSON.stringify(data)); }, format: function(data) { var hash = ''; - data = data || { - page: app.user.page, - item: app.user.item[app.user.page] || '' - }; if (data.page) { hash = '#' + data.page; if (data.item && data.page in app.user.item) { @@ -698,7 +687,6 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( } } } - Ox.print('URL FORMAT', JSON.stringify(data), hash); return hash; }, parse: function(hash) { @@ -710,13 +698,14 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test( ? split[1] : ''; data.mode = data.page == 'examples' && split[2] == 'live' ? 'live' : ''; - Ox.print('URL PARSE', hash, JSON.stringify(data)) formattedHash = app.url.format(data); hash != formattedHash && app.url.replace(formattedHash); return data; }, push: function(data) { - Ox.print('PUSH', JSON.stringify(data)) + data = data || {}; + data.page = 'page' in data ? data.page : app.user.page; + data.item = 'item' in data ? data.item : app.user.item[data.page] || ''; window.location.hash = app.url.format(data); return app; },