Created
October 11, 2009 18:14
-
-
Save mfilej/207775 to your computer and use it in GitHub Desktop.
toggle the visibility of a grid to aid setting the vertical rhythm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// depends on prototype and http://mislav.uniqpath.com/js/c-is-for-cookie/ | |
document.observe('dom:loaded', function() { | |
var gridOverlay = $('grid-overlay') | |
if (!gridOverlay) return | |
if (Cookie.get('gridOverlay') == "true") gridOverlay.show() | |
var toggleGrid = function() { | |
var visible = this.toggle().visible() | |
Cookie.set('gridOverlay', visible, { path: '/' }) | |
} | |
var toggle = new Element('div', { id: 'grid-overlay-toggle' }).update('grid') | |
toggle.observe('click', toggleGrid.bindAsEventListener(gridOverlay)) | |
gridOverlay.insert({ after: toggle }) | |
// toggle the grid by pressing "G" | |
document.observe('keyup', function(ev) { | |
if (ev.keyCode == 71) toggleGrid.bind(gridOverlay)() | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="grid-overlay" style="display: none;"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#grid-overlay | |
:position absolute | |
:top 0 | |
:left 0 | |
:width 100% | |
:height 100% | |
:background url('/images/h21.gif') 0 14px | |
#grid-overlay-toggle | |
:position absolute | |
:bottom 4px | |
:right 14px | |
:font-size 8px | |
:cursor pointer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment