Initial switch to smart browsing.

This commit is contained in:
Lars Jung 2012-10-18 21:27:09 +02:00
parent ecc05d3a8b
commit 499013f4fb
12 changed files with 244 additions and 97 deletions

View file

@ -1,5 +1,5 @@
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server'], function (_, $, allsettings, server) {
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/event'], function (_, $, allsettings, server, event) {
var settings = _.extend({
enabled: false,
@ -7,23 +7,35 @@ modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server'], functi
footer: '_h5ai.footer.html'
}, allsettings.custom),
onLocationChanged = function () {
$('#content-header, #content-footer').stop(true, true).slideUp(200);
server.request({action: 'get', custom: true}, function (response) {
if (response) {
if (response.custom.header) {
$('#content-header').html(response.custom.header).stop(true, true).slideDown(400);
}
if (response.custom.footer) {
$('#content-footer').html(response.custom.footer).stop(true, true).slideDown(400);
}
}
});
},
init = function () {
if (!settings.enabled) {
return;
}
server.request({action: 'get', custom: true}, function (response) {
$('<div id="content-header"/>').hide().prependTo('#content');
$('<div id="content-footer"/>').hide().appendTo('#content');
if (response) {
if (response.custom.header) {
$('<div id="content-header">' + response.custom.header + '</div>').prependTo('#content');
}
if (response.custom.footer) {
$('<div id="content-footer">' + response.custom.footer + '</div>').appendTo('#content');
}
}
});
event.sub('location.changed', onLocationChanged);
onLocationChanged();
};
init();