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/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/entry'], function (_, $, allsettings, resource, event, entry) {
modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
var settings = _.extend({
enabled: false
@ -26,11 +26,11 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
$html
.addClass(entry.isFolder() ? 'folder' : 'file')
.data('item', entry)
.data('status', entry.status);
$a
.attr('href', entry.absHref)
.find('span').text(entry.label).end();
location.setLink($a, entry);
$a.find('span').text(entry.label).end();
if (entry.isDomain()) {
$html.addClass('domain');
@ -69,25 +69,49 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
}
},
// creates the complete crumb from entry down to the root
init = function (entry) {
onLocationChanged = function (item) {
var crumb = item.getCrumb(),
$ul = $('#navbar'),
found = false;
$ul.find('.crumb').each(function () {
var $html = $(this);
if ($html.data('item') === item) {
found = true;
$html.addClass('current');
} else {
$html.removeClass('current');
}
});
if (!found) {
$ul.find('.crumb').remove();
_.each(crumb, function (e) {
$ul.append(update(e));
});
}
},
init = function () {
if (!settings.enabled) {
return;
}
var crumb = entry.getCrumb(),
$ul = $('#navbar');
_.each(crumb, function (e) {
$ul.append(update(e));
});
// event.sub('entry.created', onContentChanged);
// event.sub('entry.removed', onContentChanged);
event.sub('entry.changed', onContentChanged);
event.sub('location.changed', function () {
onLocationChanged(location.getItem());
});
onLocationChanged(location.getItem());
};
init(entry);
init();
});

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();

View file

@ -1,5 +1,5 @@
modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings'], function (_, $, allsettings) {
modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
var settings = _.extend({
enabled: false
@ -29,13 +29,22 @@ modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings'], function (
selectLinks(href).removeClass('hover');
},
onLocationChanged = function () {
$('.hover').removeClass('hover');
},
init = function () {
if (settings.enabled) {
$('body')
.on('mouseenter', selector, onMouseEnter)
.on('mouseleave', selector, onMouseLeave);
if (!settings.enabled) {
return;
}
$('body')
.on('mouseenter', selector, onMouseEnter)
.on('mouseleave', selector, onMouseLeave);
event.sub('location.changed', onLocationChanged);
};
init();