Skip to content

Instantly share code, notes, and snippets.

View murtaugh's full-sized avatar
👋

Tim Murtaugh murtaugh

👋
View GitHub Profile
@murtaugh
murtaugh / parallax.js
Created March 5, 2014 16:06
Finally a simple parallax script I like
$(window).scroll(function(e){
parallax();
});
function parallax() {
var scrolled = $(window).scrollTop();
//81% is the original top position of the element,
@murtaugh
murtaugh / codepen-sample.html
Created February 12, 2014 23:24
CodePen on ALA
<figure class="text full-width">
<p data-height="388" data-theme-id="0" data-slug-hash="BJrpg" data-default-tab="result" class='codepen'>See the demo: <a href='http://alistapart.com/d/390/ui-animation-and-ux-a-not-so-secret-friendship/demo-show-hide'>Show/hide example</a></p>
<script async src="//codepen.io/assets/embed/ei.js"></script>
<figcaption>Select items on the main nav to reveal the submenus.</figcaption>
</figure>
@murtaugh
murtaugh / menu-items.md
Last active May 17, 2020 13:22
How would you mark up an item on a restaurant menu?

I was thinking about restaurant menus, and started wondering how best to mark up individual items on the menu. Assuming you're going to put the each item in an li one approach could be:

<li>
	<h2>Home-Style Burger</h2>
	<p>half-pound burger with grilled onions</p>
	<p class="price">$7.25</p>
</li>	
@murtaugh
murtaugh / wait.js
Created November 20, 2013 22:56
a function that does what I always expect .delay() to do
$.wait = function( callback, seconds){
return window.setTimeout( callback, seconds * 1000 );
}
// usage
$.wait( function(){ $("#message").slideUp() }, 5);
@murtaugh
murtaugh / auto-footnote.js
Last active January 4, 2021 19:45
Sniff out superscripts that should be footnote links
$('sup[data-footnote]').each(function(index) {
noteCount = $(this).html();
$(this).html('<a id="ref' + noteCount + '" href="#note' + noteCount + '">' + noteCount + '</a>');
$('#footnotes li').eq(noteCount - 1).attr('id', 'note' + noteCount).prepend('<a href="#ref' + noteCount + '">' + noteCount + '.</a> ');
});
@murtaugh
murtaugh / placeholder-polyfill.js
Created September 20, 2013 15:21
In my experience, `placeholder` polyfills try way too hard, and the results are mixed. Here's mine.
if (!Modernizr.input.placeholder) {
$('*[placeholder]').each(function() {
placeholder = $(this).attr('placeholder');
$(this).attr('value', placeholder).addClass('fakePlaceholder');
});
@murtaugh
murtaugh / columns.css
Created September 16, 2013 19:48
CSS Columns
.columns {
display: block;
list-style-type: none;
margin-bottom: 24px;
-moz-column-count: 2;
-moz-column-gap: 24px;
-webkit-column-count: 2;
-webkit-column-gap: 24px;
column-count: 2;
column-gap: 24px;
<figure class="code">
<pre><code class=“language-markup”>&lt;meta charset="utf-8"/></code></pre>
<figcaption>A UTF-8 encoding declaration should appear at the beginning of every &lt;head&gt; element.</figcaption>
</figure>
@murtaugh
murtaugh / In-Page Nav Functions.js
Last active December 20, 2015 04:39
In-page nav, with smooth scrolling, update on scroll, and proper location.hash updating
$(document).ready(function() {
$("#in-page-nav-1 a").click(function(e){
e.preventDefault();
var dest = 0;
if ($(this.hash).offset().top > $(document).height()-$(window).height()){
@murtaugh
murtaugh / autogrow.js
Last active December 19, 2015 07:59 — forked from jlong/jquery.autogrow.js
I un-plugin-ified this for my own purposes.
(function($){
$(document).ready(function (){
$('textarea[data-autoresize]').on('input propertychange', function() {
autoResize($(this));
});