id summary reporter owner description type status priority component severity resolution keywords cc release
3162 The code sucks; rewrite suggested Kyle Alan Hale Pavel "I just think the code sucks. Why not do it like this?
{{{
#!js
$(document).ready(function () {
var breadcrumb = document.createElement('div');
breadcrumb.setAttribute('id', 'pathnav');
breadcrumb.setAttribute('class', 'nav');
var links = document.location.pathname.split(""/"");
var editing = !!document.location.toString().match(/action=edit/);
var first, last;
var url = """";
var crumbs = '
';
breadcrumb.innerHTML = crumbs;
var main = document.getElementById('main');
main.insertBefore(breadcrumb, main.firstChild);
});
}}}
The CSS would look like this:
{{{
#!css
#pathnav {
float: left;
margin-left: -40px;
}
#content {
padding-top: 2em;
}
}}}
These changes effect the following:
* Waits until the page is loaded before appending the new element.
* Uses a DOM insertion rather than '''document.write'''
* The breadcrumb is placed on the same level as the other wiki historical links (Index, History, etc.), and pushes down the content a bit to make room
* Makes the final item in the breadcrumb (the current page) bold instead of a link. It also looks for the 'edit' parameter in the query string and appends a crumb if present.
* Uses the ""first"" and ""last"" CSS classes to better the styling
My probs with my approach:
* It does use a mixture of DOM functions and innerHTML, which I'm usually against, but it seemed easiest in this case. At least, it was faster to code. Someone who knows dojo better could perhaps clean it up.
* Unfortunately, previews are done via `POST`, so the '''(editing)''' flag goes away after a preview.
Anyway, this is how I'm using it, and it's fantastic.
Thought others might like this change, even if you don't incorporate it." enhancement closed normal BreadcrumbTrailsScript normal wontfix 0.10