Skip to content

Instantly share code, notes, and snippets.

View jlittlejohn's full-sized avatar

Josh Littlejohn jlittlejohn

View GitHub Profile
@jlittlejohn
jlittlejohn / gist:4084309
Created November 16, 2012 05:09
SCSS: Horizontal Gradient (Mixin)
@mixin gradient-horizontal($startColor: #555, $endColor: #333) {
background-color: $endColor;
background-image: -moz-linear-gradient(left, $startColor, $endColor); // FF 3.6+
background-image: -webkit-gradient(linear, 0 0, 100% 0, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(to right, $startColor, $endColor); // Standard, IE10
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($startColor)}', endColorstr='#{ie-hex-str($endColor)}', GradientType=1); // IE9 and down
}
@jlittlejohn
jlittlejohn / gist:4084310
Created November 16, 2012 05:10
SCSS: Vertical Gradient (Mixin)
@mixin gradient-vertical($startColor: #555, $endColor: #333) {
background-color: mix($startColor, $endColor, 60%);
background-image: -moz-linear-gradient(top, $startColor, $endColor); // FF 3.6+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(top, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(top, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(to bottom, $startColor, $endColor); // Standard, IE10
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($startColor)}', endColorstr='#{ie-hex-str($endColor)}', GradientType=0); // IE9 and down
}
@jlittlejohn
jlittlejohn / gist:4084315
Created November 16, 2012 05:12
SCSS: Radial Gradient (Mixin)
@mixin gradient-radial($innerColor: #555, $outerColor: #333) {
background-color: $outerColor;
background-image: -webkit-gradient(radial, center center, 0, center center, 460, from($innerColor), to($outerColor));
background-image: -webkit-radial-gradient(circle, $innerColor, $outerColor);
background-image: -moz-radial-gradient(circle, $innerColor, $outerColor);
background-image: -o-radial-gradient(circle, $innerColor, $outerColor);
background-repeat: no-repeat;
}
@jlittlejohn
jlittlejohn / gist:4084544
Created November 16, 2012 05:50
SCSS: Text Overflow (Mixin)
@mixin text-overflow() {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
@jlittlejohn
jlittlejohn / gist:4279911
Created December 13, 2012 21:09
JS: Hover On/Off
$("a").hover(
function () {
// code on hover over
},
function () {
// code on away from hover
}
);
@jlittlejohn
jlittlejohn / gist:4279922
Created December 13, 2012 21:10
JS: Prevent Anchor Links from Loading
$("a").on("click", function(e){
e.preventDefault();
});
@jlittlejohn
jlittlejohn / gist:4279941
Created December 13, 2012 21:12
JS: Scroll to Top
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
@jlittlejohn
jlittlejohn / gist:4279973
Created December 13, 2012 21:15
JS: Ajax Template
$.ajax({
type: 'POST',
url: 'backend.php',
data: "q="+myform.serialize(),
success: function(data){
// on success use return data here
},
error: function(xhr, type, exception) {
// if ajax fails display error alert
alert("ajax error response type "+type);
@jlittlejohn
jlittlejohn / gist:4280007
Created December 13, 2012 21:20
JS: Animate Template
$('p').animate({
left: '+=90px',
top: '+=150px',
opacity: 0.25
},
900,
'linear',
function() {
// function code on animation complete
});
@jlittlejohn
jlittlejohn / gist:4280020
Created December 13, 2012 21:21
JS: Toggle CSS Classes
$('nav a').toggleClass('selected');