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});
},
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;
},