Skip to content

Instantly share code, notes, and snippets.

View megantaylor's full-sized avatar

Megan Taylor megantaylor

View GitHub Profile
@megantaylor
megantaylor / fadeHover
Created July 18, 2014 21:31
Fade in/fade out on hover. The code below set opacity to 100% on hover, and to 60% on hover.
$(document).ready(function(){
$(".thumbs img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads
$(".thumbs img").hover(function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
},function(){
$(this).fadeTo("slow", 0.6); // This should set the opacity back to 60% on mouseout
});
});
@megantaylor
megantaylor / scrollAnchor
Created July 18, 2014 21:30
The following snippet will create a smooth sliding effect when a link with the topLink class is clicked.
$(document).ready(function() {
$("a.topLink").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
}, {
duration: 500,
easing: "swing"
});
return false;
});
@megantaylor
megantaylor / blankLinks
Created July 18, 2014 21:29
The following snippet will open all links with the rel="external" attribute in a new tab/window. The code can be easily customized to only open links with a specific class.
@megantaylor
megantaylor / imagePreload.js
Created July 18, 2014 21:28
Preloading images is useful: Instead of loading an image when the user request it, we preload them in the background so they are ready to be displayed.
(function($) {
var cache = [];
// Arguments are image paths relative to the current page.
$.preLoadImages = function() {
var args_len = arguments.length;
for (var i = args_len; i--;) {
var cacheImage = document.createElement('img');
cacheImage.src = arguments[i];
cache.push(cacheImage);
}
@megantaylor
megantaylor / list bullets color
Created August 23, 2013 14:41
Defining the color of bullets in a list without using an image or span tag
ul {
list-style: none;
padding:0;
margin:0;
}
li {
padding-left: 1em;
text-indent: -.7em;
}
@megantaylor
megantaylor / meetupgroups.html
Last active December 16, 2015 15:08
Get Meetup Groups by Member ID
<!DOCTYPE html>
<html>
<head>
<title>Meetup Groups by Member ID</title>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.getJSON("https://api.meetup.com/2/groups?callback=?&sign=true&member_id=MEMBER_ID&page=50&api&key=API_KEY&only=name,link",
function (data) {
var htmlString = "";
<div class="container">
<p>
<a href="#" class="btn">This is a button</a>
<a href="#" class="btn btn-blue">This is a button</a>
</p>
<p>
<a href="#" class="btn btn-red">This is a button</a>
</p>
</div>
@megantaylor
megantaylor / pdfviewer.php
Created April 22, 2013 22:11
PDF viewer shortcode for WordPress
The first step is to paste the following code into your functions.php file:
function pdflink($attr, $content) {
return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
}
add_shortcode('pdf', 'pdflink');
Once you saved the file, you'll be able to use the shortcode on your posts and page. Here is the syntax:
[pdf href="http://yoursite.com/linktoyour/file.pdf"]View PDF[/pdf]
@megantaylor
megantaylor / fontstacks.css
Created April 22, 2013 20:44
Font Stacks
/* Times New Roman-based stack */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
/* Modern Georgia-based serif stack */
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
/* Traditional Garamond-based serif stack */
font-family: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif;
/* Helvetica/Arial-based sans serif stack */
@megantaylor
megantaylor / mailto.html
Created April 22, 2013 19:23
Mailto Links
Open default mail program, create new message with the TO field already filled out.
<a href="mailto:someone@yoursite.com">Email Us</a>
Adding a subject
Open default mail program, create new message with the TO and SUBJECT field already filled out. Essentially we are adding the parameter subject to the href value.
Spaces in the subject will probably work OK, but to be super-extra sure, you can replace spaces with "%20".
<a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a>