Free Nodelet Hack: Nodelets on the left
by ikegami (Patriarch) on Nov 07, 2006 at 02:01 UTC
|
Until (if ever) such a feature is added to PerlMonks, you can use JavaScript to manipulate the DOM objects to attain the desired effect. Add the code following to your Free Nodelet. Make sure your Free Nodelet is being displayed.
<script type="text/javascript">
// ========================================
// Move nodelets to the left side.
function move_nodelets() {
for each (var td in document.getElementsByTagName('td')) {
if (td.className != 'nodelets')
continue;
var tr = td.parentNode;
var main = tr.firstChild;
tr.insertBefore(td, main);
}
}
move_nodelets();
</script>
Tested successfully in FireFox 1.5.0.7.
Tested unsuccessfully in IE 6.0.2900.2180.xpsp_sp2_gdr.050301-1519, although I'm sure it could be made to work by someone more knowledgable.
Update: Clarified Until => Until (if ever).
Update: Title change.
Update: An updated version of this code found in Re^9: Free Nodelet Hack: Nodelets on the left. The core logic has been simplified and it has extra logic to delay execution to a safe time (allowing it to work in IE). | [reply] [Watch: Dir/Any] [d/l] |
|
var query = "//td[@class='nodelets']";
var nodesSnapshot = document.evaluate(query, document, null, XPath
+Result.ORDERED_NODE_SNAPSHOT_TYPE, null );
for ( var i=0 ; i < nodesSnapshot.snapshotLength; i++ ) {
var elt = nodesSnapshot.snapshotItem(i);
// handle elt
};
| [reply] [Watch: Dir/Any] [d/l] |
|
<script type="text/javascript">
( function() {
var td = document.getElementById( 'nodelet_container' ).parentNode
+;
var tr = td.parentNode;
tr.insertBefore( td, tr.firstChild );
} )();
</script>
Makeshifts last the longest. | [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
|
|
|
|
That's really nice! FWIW, I approve. ;-)
Those interested in scripting/styling their PerlMonks experience may also be interested in the various other Free Nodelet Hacks.
In the context of this thread, I point out (at the risk of flogging my own work) Free Nodelet Hack: Hide/Display Nodelet Bar On Demand. I've verified that it works just fine in conjunction with ikegami's code above.
We're building the house of the future together.
| [reply] [Watch: Dir/Any] |
|
Thanks!! That's really nice!!! I still hope we get a real option, but until that happens this is a great work around!
| [reply] [Watch: Dir/Any] |
|
It's not just a workaround, it's a solution.
Considering how powerful CSS styling is for configuring one's view of PerlMonks, I really don't see why pmdev should implement changes such as this. (The same could be said for Node ids by node titles, but someone went and implemented it without really giving much thought to the wider ramifications.) If anything, pmdev should probably be looking at ways of enhancing PerlMonks' stylability and scriptability.
We're building the house of the future together.
| [reply] [Watch: Dir/Any] |
|
|
|
|
Re: Nodelets on the left?
by blokhead (Monsignor) on Nov 07, 2006 at 02:10 UTC
|
I can't address your question about moving the nodelets, but I can suggest an easy compromise with your code wrapping peeves. In Display Settings, turn code wrapping off and add this to your site CSS:
.code { overflow: auto; }
This will give your code blocks a horizontal scrollbar if they are too wide. It has worked pretty well for me (in Firefox 1.5.* at least)!
| [reply] [Watch: Dir/Any] [d/l] |
|
Thanks! Looks like IE6 ignores it (which is a good compromise).
| [reply] [Watch: Dir/Any] |
Re: Nodelets on the left?
by Argel (Prior) on Jan 18, 2007 at 01:17 UTC
|
FYI, looks like it works with IE7 and Firefox 2 as well. Anyone tested this with other browsers? | [reply] [Watch: Dir/Any] |