modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings', 'view/topbar'], function (_, $, event, location, resource, allsettings, topbar) {
var settings = _.extend({
enabled: false
}, allsettings.crumb);
var crumbTemplate =
'' +
'' +
'' +
'';
var pageHintTemplate = '
';
var $crumbbar;
function createHtml(item) {
var $html = $(crumbTemplate).data('item', item);
item.$crumb = $html;
location.setLink($html, item);
$html.find('.label').text(item.label);
if (item.isDomain() || item.isRoot()) {
$html.find('.sep').width(0);
}
if (item.isCurrentFolder()) {
$html.addClass('active');
}
if (!item.isManaged) {
$html.append($(pageHintTemplate));
}
return $html;
}
function onLocationChanged(item) {
var $crumb = item.$crumb;
if ($crumb && $crumb.parent()[0] === $crumbbar[0]) {
$crumbbar.children().removeClass('active');
$crumb.addClass('active');
} else {
$crumbbar.empty();
_.each(item.getCrumb(), function (item) {
$crumbbar.append(createHtml(item));
});
}
}
function init() {
if (!settings.enabled) {
return;
}
$crumbbar = $('