index: fix url controller

This commit is contained in:
rolux 2012-07-05 23:08:19 +02:00
parent 52f1a7f627
commit a11cb68301

View file

@ -437,8 +437,7 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test(
app.url.push({page: 'examples', item: data.id}); app.url.push({page: 'examples', item: data.id});
}, },
select: function(data) { select: function(data) {
app.user.item.doc = data.id; app.url.push({item: data.id});
app.url.push();
} }
}) })
.bindEventOnce({ .bindEventOnce({
@ -470,14 +469,11 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test(
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
app.url.push({ app.url.push({
page: 'examples',
item: app.user.item.examples,
mode: data.value == 'live' ? 'live' : '' mode: data.value == 'live' ? 'live' : ''
}); });
}, },
select: function(data) { select: function(data) {
app.user.item.examples = data.id; app.url.push({item: data.id});
app.url.push();
} }
}); });
}, },
@ -542,8 +538,7 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test(
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
if (app.state.loaded) { if (app.state.loaded) {
app.user.page = data.selected; app.url.push({page: data.selected});
app.url.push();
} }
} }
}); });
@ -629,8 +624,7 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test(
); );
}); });
}); });
app.user.item.readme = id; app.url.push({item: id});
app.url.push();
} }
return $panel; return $panel;
}, },
@ -681,14 +675,9 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test(
if (!app.user.page || !app.user.previousPage) { if (!app.user.page || !app.user.previousPage) {
app.animate(); app.animate();
} }
Ox.print('URL CHANGE', JSON.stringify(data));
}, },
format: function(data) { format: function(data) {
var hash = ''; var hash = '';
data = data || {
page: app.user.page,
item: app.user.item[app.user.page] || ''
};
if (data.page) { if (data.page) {
hash = '#' + data.page; hash = '#' + data.page;
if (data.item && data.page in app.user.item) { 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; return hash;
}, },
parse: function(hash) { parse: function(hash) {
@ -710,13 +698,14 @@ Ox.load(/^https?:\/\/(www\.)?oxjs\.org\//.test(
? split[1] : ''; ? split[1] : '';
data.mode = data.page == 'examples' && split[2] == 'live' data.mode = data.page == 'examples' && split[2] == 'live'
? 'live' : ''; ? 'live' : '';
Ox.print('URL PARSE', hash, JSON.stringify(data))
formattedHash = app.url.format(data); formattedHash = app.url.format(data);
hash != formattedHash && app.url.replace(formattedHash); hash != formattedHash && app.url.replace(formattedHash);
return data; return data;
}, },
push: function(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); window.location.hash = app.url.format(data);
return app; return app;
}, },