Skip to content

Instantly share code, notes, and snippets.

View tjFogarty's full-sized avatar
🇮🇪

T.J. Fogarty tjFogarty

🇮🇪
View GitHub Profile
@tjFogarty
tjFogarty / utils.js
Created July 26, 2015 20:00
Little utility object
/**
* Utilities
* see http://youmightnotneedjquery.com/
* @type {Object}
*/
var U = {
/**
* Call a function when DOM is ready
* @param {Function} fn Function to call when DOM is ready
*/
@tjFogarty
tjFogarty / picture.twig
Created February 24, 2015 20:40
Picture element + Twig
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="{{ slide.image_desktop | tojpg | resize(1200) }}" media="(min-width: 1000px)">
<source srcset="{{ slide.image_tablet | tojpg | resize(800) }}" media="(min-width: 767px)">
<source srcset="{{ slide.image | tojpg | resize(480) }}, {{ slide.image | tojpg | resize(766) }} 2x" media="(max-width: 766px)">
<!--[if IE 9]></video><![endif]-->
<img class="slider__image" srcset="{{ slide.image_tablet | tojpg | resize(800) }}" alt="{{ slide.title }}">
@tjFogarty
tjFogarty / SassMeister-input-HTML.html
Created February 25, 2016 16:18
Generated by SassMeister.com.
<h1>This should be a responsive heading title right here</h1>
@tjFogarty
tjFogarty / environment.php
Created October 6, 2013 12:45
Manage assets based on current environment
/**
* Environment
* Lets us manage assets based on current environment
*/
class Environment {
/**
* @param $localEnvironment (default value is 'localhost' if nothing is passed)
* @return boolean
*/
@tjFogarty
tjFogarty / js-enabled.js
Created August 26, 2013 11:31
Assuming the HTML element has a class of 'no-js', this will swap it for 'js'. Should be placed in the header.
var el = document.getElementsByTagName('html')[0];
el.className = el.className.replace('no-js', 'js');
@tjFogarty
tjFogarty / mobile-nav.js
Created July 9, 2013 15:57
Build mobile navigation from existing list of links
var MobileNav = {
navContainer: $( '.main-nav, .ancillary-nav' ),
navItems: null,
select: null,
navHTML: "<select class=mobile-nav></select>",
optionHTML: null,
init: function() {
// Build navigation then attach event handlers
MobileNav.buildNav();
@tjFogarty
tjFogarty / youtube-event-tracking.js
Created April 30, 2013 14:38
Tracking for any number of YouTube iframes. Uses a data-title attribute for grabbing a title.
// Any iframes with a class of .yt will be collected for event tracking
var Youtube = {
$players: $( '.yt' ),
playerArray: [],
numPlayers: $( '.yt' ).length - 1,
init: function() {
Youtube.assignID();
Youtube.bindEvents();
},
@tjFogarty
tjFogarty / config.php
Created March 19, 2013 15:38
Quick and simple database connection
<?php
include('db.class.php');
$database = new Database();
$database->dbUrl = 'localhost'; //URL of database
$database->dbUser = 'root'; // Username
$database->dbPass = ''; // Password
$database->dbName = 'test_db'; // Name of database you wish to connect to
@tjFogarty
tjFogarty / slider-demo.html
Last active December 14, 2015 18:19
A CodePen by T.J. Fogarty. Touch/keyboard content slider - I wanted to build a simple, reusable content slider just to understand how it works. There's definitely improvements to be made, but it works :) Supports keyboard navigation, and swiping on touch-based devices.
<div class="container">
<div id="slider-container">
<ul class="slider-images clearfix">
<li><img class="scale" src="http://dummyimage.com/500x200/000/fff.gif&text=Slide+1" alt=""></li>
<li><img class="scale" src="http://dummyimage.com/500x200/fff/000.gif&text=Slide+2" alt=""></li>
<li><img class="scale" src="http://dummyimage.com/500x200/000/fff.gif&text=Slide+3" alt=""></li>
<li><img class="scale" src="http://dummyimage.com/500x200/fff/000.gif&text=Slide+4" alt=""></li>
</ul>
</div>
@tjFogarty
tjFogarty / notifications-demo.html
Last active December 14, 2015 10:10
A CodePen by T.J. Fogarty. Notify - A simple little notification system that will let you define a success or an error, so you can hook in with CSS and style accordingly.
<a href="#" class='notify'>Success!</a>
<a href="#" class='notify error'>Error :(</a>