Skip to content

Instantly share code, notes, and snippets.

View gpassarelli's full-sized avatar

Gabriel Passarelli gpassarelli

View GitHub Profile
@gpassarelli
gpassarelli / gist:2134950
Created March 20, 2012 12:48
jQuery: Highlight Related Label when Input in Focus
$("form :input").focus(function() {
$("label[for='" + this.id + "']").addClass("labelfocus");
}).blur(function() {
$("label").removeClass("labelfocus");
});
@gpassarelli
gpassarelli / gist:2134944
Created March 20, 2012 12:48
jQuery: jQuery JSON getting with error catching
$.get('/path/to/url', function (data) {
if( !data || data === ""){
// error
return;
}
var json;
try {
json = jQuery.parseJSON(data);
} catch (e) {
// error
@gpassarelli
gpassarelli / gist:2134936
Created March 20, 2012 12:47
jQuery: Highlight All Links To Current Page
$(function(){
$("a").each(function(){
if ($(this).attr("href") == window.location.pathname){
$(this).addClass("selected");
}
});
});
@gpassarelli
gpassarelli / gist:2134931
Created March 20, 2012 12:47
jQuery: Open External Links In New Window
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
@gpassarelli
gpassarelli / gist:2134927
Created March 20, 2012 12:46
jQuery: Make Entire Div Clickable
$(".myBox").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
@gpassarelli
gpassarelli / gist:2134886
Created March 20, 2012 12:44
CSS: CSS Tooltips
a:hover {
background:#ffffff;
text-decoration:none;} /*BG color is a must for IE6*/
a.tooltip span {
display:none;
padding:2px 3px;
margin-left:8px;
width:130px;
@gpassarelli
gpassarelli / gist:2134882
Created March 20, 2012 12:43
CSS: Set color of selected text
::selection {
background: #ffb7b7; /* Safari */
}
::-moz-selection {
background: #ffb7b7; /* Firefox */
}
@gpassarelli
gpassarelli / gist:2134873
Created March 20, 2012 12:43
CSS: Print URL After Links
@media print{
a:after{content:" (" attr(href) ") ";font-size:0.8em;font-weight:normal;}
}
@gpassarelli
gpassarelli / gist:2134863
Created March 20, 2012 12:43
CSS: Remove Dotted Link Borders
a,a:active {
outline: none;
}
@gpassarelli
gpassarelli / gist:2134856
Created March 20, 2012 12:42
CSS: Min-Height
selector {
min-height:500px;
height:auto !important;
height:500px;
}