http://www.perlmonks.org?node_id=547277


in reply to Free Nodelet freed

I like to have my Nodelet bar (column? table?) nice and wide, most of the time, partly because it makes the nodelets shorter, and thus I have to scroll less to read them. (I keep the most dynamic ones at the top.) The downside is that the main body of the node is squeezed. This not only makes it taller, but often causes ugly line wrapping, especially in embedded HTML tables. So, sometimes I really want to get my Nodelet column out of the way, and just view the main node body in its full glory. So I thought:

How can I hide (toggle off) the Nodelet bar as needed?

The following code does just that. Simply plunk it into your Free Nodelet Settings. It makes two checkboxes near the top right corner of your page, labeled 'Hide Main Body' and 'Hide Nodelets'. When one or the other part of the page is hidden, the remaining visible part expands to fill the entire width of the window.

// add toggles to hide/show nodelets and main_content { var tbl = document.getElementById('titlebar-bottom'); var cel = document.createElement('td'); tbl.rows[0].appendChild(cel); cel.width = "20%"; cel.align = "right"; // add toggle to hide/show main_content txt = document.createTextNode( 'Hide Main Body' ); cel.appendChild(txt); chk = document.createElement('input'); cel.appendChild(chk); chk.type = 'checkbox'; chk.name = 'hide_mainbody'; chk.id = 'hide_mainbody'; chk.onclick = function(){ var chk = document.getElementById('hide_mainbody'); var state = chk.checked ? 'none' : 'table-cell'; element_of_tag_and_class('td','main_content').style.display = +state; } // add toggle to hide/show nodelets var txt = document.createTextNode( 'Hide Nodelets' ); cel.appendChild(txt); var chk = document.createElement('input'); cel.appendChild(chk); chk.type = 'checkbox'; chk.name = 'hide_nodelets'; chk.id = 'hide_nodelets'; chk.onclick = function(){ var chk = document.getElementById('hide_nodelets'); var state = chk.checked ? 'none' : 'table-cell'; element_of_tag_and_class('td','nodelets').style.display = stat +e; } } // presumes only one. returns first found. function element_of_tag_and_class(tagname,classname) { var elems = document.getElementsByTagName(tagname); var i; for ( i = 0; i < elems.length; i++ ) { if ( elems[i].className == classname ) { return( elems[i] ); } } }
We're building the house of the future together.