Skip to content

Instantly share code, notes, and snippets.

View adrianengine's full-sized avatar

Λdrian Q adrianengine

View GitHub Profile
@adrianengine
adrianengine / new_gist_file
Created August 19, 2013 22:09
Event Tracking - Web Tracking (analytics.js), In this example, the addEventListener function is a utility to add event listeners across browsers. This function is used to add an event listener to the PDF download link to listen for the click event. When a click event occurs, the event is sent to Google Analytics. Source (https://developers.googl…
var downloadLink = document.getElementById('button');
addListener(downloadLink, 'click', function() {
ga('send', 'event', 'button', 'click', 'nav-buttons');
});
/**
* Utility to wrap the different behaviors between W3C-compliant browsers
* and IE when adding event handlers.
*
@adrianengine
adrianengine / new_gist_file
Created August 19, 2013 21:09
A CSS snippet for media queries, using ems.
/* MEDIA QUERIES
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
/* Viewport ----------- */
@-webkit-viewport { width: device-width; }
@-moz-viewport { width: device-width; }
@-o-viewport { width: device-width; }
@-ms-viewport { width: device-width; }
@viewport { width: device-width; }
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
// these are labels for the days of the week
cal_days_labels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
// these are human-readable month name labels, in order
cal_months_labels = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December'];
// these are the days of the week for each month, in order
cal_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@adrianengine
adrianengine / gist:4453598
Created January 4, 2013 15:48
A simple snippet to detect placeholder support with jQuery on form inputs and fallback accordingly.
//Find if user browser supports placeholder
jQuery(function() {
jQuery.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) jQuery.support.placeholder = true;
});
if(!$.support.placeholder) {
// If placeholder is not supported
var inputPlaceholder= function () {