1
0
Fork 0
mirror of https://github.com/lrsjng/h5ai synced 2025-12-20 15:53:38 +01:00
h5ai/src/_h5ai/client/js/inc/ext/title.js
2015-04-12 23:23:05 +02:00

29 lines
643 B
JavaScript

modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_, allsettings, event) {
var settings = _.extend({
enabled: false
}, allsettings.title);
function onLocationChanged(item) {
var labels = _.pluck(item.getCrumb(), 'label');
var title = labels.join(' > ');
if (labels.length > 1) {
title = labels[labels.length - 1] + ' - ' + title;
}
document.title = title;
}
function init() {
if (!settings.enabled) {
return;
}
event.sub('location.changed', onLocationChanged);
}
init();
});