Skip to content

Instantly share code, notes, and snippets.

@clayb
clayb / smooth-scroll-to-anchor.js
Last active October 23, 2018 14:17
Smooth Scroll Anchor jQuery
// Better way
function scrollToTarget(target, shift = 0, timing = 500) {
$('html, body').animate({
scrollTop: $(target).offset().top + shift
}, timing);
}
// Same as above but with IE friendly default parameters
function scrollToTarget(target, shift, timing) {
if (typeof shift == 'undefined') {shift = 0}
[[E130:"[[S8]]" "https://secure2.edf.org/site/" "" replaceall "http://support.edf.org/site/" "" replaceall "/" "-" replaceall ".html" "" replaceall "SPageServer?" "" replaceall "PageServer?" "" replaceall "SPageNavigator?" "" replaceall "PageNavigator?" "" replaceall "Donation2?" "" replaceall "Advocacy?" "" replaceall "SSurvey?" "" replaceall "Survey?" "" replaceall "MessageViewer?" "" replaceall "?" "-" replaceall "&" "_" replaceall]]
@clayb
clayb / gist:bd51fcdc74bd857db655
Created October 30, 2014 15:51 — forked from equijada001/gist:4204524
Convio strip out $ from gift amount
[[E130:"[[S120:dc:giftAmount]]" "$" "" replaceall]]
<script type="application/ld+json">// <![CDATA[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"publisher": {
"@type": "Organization",
"name": "African Wildlife Foundation",
"url": "http://www.awf.org",
"url/googlePlus": "https://plus.google.com/+AfricanWildlifeFoundation"
},
@clayb
clayb / scroll-next-prev.js
Last active April 28, 2016 21:08
Scroll to Next or Previous <article> element
/**document ready**/
$(document).ready(function () {
/** scroll to element function **/
function scrollToElement(selector, time, verticalOffset) {
time = typeof (time) != 'undefined' ? time : 500;
verticalOffset = typeof (verticalOffset) != 'undefined' ? verticalOffset : 0;
element = $(selector);
offset = element.offset();
offsetTop = offset.top + verticalOffset;
@clayb
clayb / main.scss
Created July 23, 2014 20:58 — forked from rattlion/main.scss
Compass sprite for loop example
@import "compass";
@import "compass/reset";
@import "icon/*.png";
@include all-icon-sprites;
@import "logo/*.png";
@include all-logo-sprites;
@import "pencil/*.png";
@include all-pencil-sprites;
$('a').each(function() {
if (location.search.substr(1) !== '') {
query = location.search.substr(1);
symbol = $(this).attr('href').indexOf("?") == -1 ? '?' : '&';
$(this).attr('href', $(this).attr('href') + symbol + query);
}
});
@clayb
clayb / nav-dropdown-on-scroll.js
Last active April 28, 2016 21:10
Navigation dropdown on page scroll
openDropdownNav = function() {
return $('header').addClass('dropdown-nav').slideDown();
};
closeDropdownNav = function() {
return $('header.dropdown-nav').slideUp(function() {
return $('header').removeClass('dropdown-nav').stop().removeAttr('style');
});
};
getDocHeight = function() {
var D;
@clayb
clayb / placeholder.js
Last active April 8, 2016 15:55
placeholder js script
if (!Modernizr.input.placeholder) {
$('[placeholder]').focus(function() {
var input;
input = $(this);
if (input.val() === input.attr('placeholder')) {
input.val('');
return input.removeClass('placeholder');
}
}).blur(function() {
var input;
@clayb
clayb / placeholder.js.coffee
Last active April 28, 2016 21:07
Form placeholder coffeescript
# placeholder for inputs in IE
unless Modernizr.input.placeholder
$('[placeholder]')
.focus ->
input = $(@)
if input.val() == input.attr('placeholder')
input.val('')
input.removeClass('placeholder')
.blur ->
input = $(@)