Created
May 16, 2013 06:29
-
-
Save datapimp/5589768 to your computer and use it in GitHub Desktop.
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
var color = function(e){ | |
var $target = $(e.target); | |
$target.css({ | |
'background-color': '#9FC4E7', | |
opacity: .5 | |
}) | |
$target.children().each(function(i,el){ | |
$(el).css({ | |
'background-color': '#C2DDB6', | |
opacity: .5 | |
}) | |
}) | |
}; | |
var uncolor = function(e){ | |
var $target = $(e.target); | |
$target.attr('style', ''); | |
$target.children().each(function(i,el){ $(el).attr('style', ''); }); | |
}; | |
var makeEditable = function(editable){ | |
return function(e){ | |
e.preventDefault(); | |
var $target = $(e.target); | |
$target.attr('contenteditable', editable); | |
}; | |
}; | |
$('*') | |
.on('mouseover.inspekt', color) | |
.on('mouseout.inspekt', uncolor) | |
.on('click.inspekt', makeEditable(true)) | |
.on('blur.inspekt', makeEditable(false)) | |
// $('*').off('.inspekt') to turn off |
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
(function($){ | |
$.fn.overlay = function() { | |
this.each(function() { | |
$el = $(this); | |
$overlay = $("<div class='overlay'></div>"); | |
$overlay.width( $el.outerWidth() ); | |
$overlay.height( $el.outerHeight() ); | |
var style = $el.offset(); | |
if ($el.css('position') == 'static') { | |
var position = 'fixed'; | |
style.top-= $(document).scrollTop() | |
} else { | |
var position = 'absolute'; | |
} | |
var style = $.extend(style, { | |
'background-color': 'black', | |
opacity: 0.5, | |
position: position, | |
'z-index': 5000 | |
}) | |
$overlay.css(style); | |
$overlay.appendTo('body'); | |
}) | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment