Created
August 3, 2009 11:18
-
-
Save chrislloyd/160497 to your computer and use it in GitHub Desktop.
This file contains 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
(function($){ | |
$.fn.grid = function() { | |
return this.each(function(){ | |
var self = $(this), | |
hGrid = $('<div></div>'), | |
vGrid = $('<div></div>'); | |
self.css('position','relative'); | |
$.each([hGrid, vGrid], function(){ | |
this.css({ | |
position: 'absolute', | |
top: 0, | |
right: 0, | |
bottom: 0, | |
left: 0, | |
opacity: 0.5, | |
zIndex: 100 | |
}); | |
this.hide(); | |
self.prepend(this); | |
}) | |
hGrid.css('backgroundImage','url(/images/h_grid.gif)'); | |
vGrid.css('backgroundImage','url(/images/v_grid.gif)') | |
$(document).keydown(function(e){ | |
var hKey = 72, vKey = 86; | |
if (e.shiftKey) switch(e.keyCode) { | |
case hKey: hGrid.toggle(); break; | |
case vKey: vGrid.toggle(); break; | |
} | |
}); | |
}); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment