Skip to content

Instantly share code, notes, and snippets.

View tedw's full-sized avatar

Ted Whitehead tedw

  • Threespot
  • Washington, DC
View GitHub Profile
@tedw
tedw / ie-form-polyfills.js
Created November 13, 2012 21:00
IE Form Polyfills
$('input:text, input[type="text"]').addClass('input-text');
$('input[type="email"]').addClass('input-email');
$('input:checkbox, input:radio').addClass('input-check');
$('input[type="submit"]').addClass( 'input-submit' );
$('input[type="button"]').addClass( 'btn-submit' );
$('input[type="search"]').addClass('input-search');
$('input[type="email"]').addClass('input-email');
@tedw
tedw / iOS-polyfill.js
Created November 13, 2012 21:03
iOS Polyfills
/* Toggle Zoom on iPhone */
var DisableZoom = function( disable ) {
// Check for meta tag
var hasMeta = $('head meta[name=viewport]').length,
opts = ( disable ? 'minimum-scale=1.0, maximum-scale=1.0' : 'maximum-scale=10');
// Check if meta viewport tag exsits
if ( hasMeta ) {
// Remove current meta viewport tag
$('head meta[name=viewport]').remove();
@tedw
tedw / has-flash.js
Created November 13, 2012 21:05
Check if Flash supported
/* Check if Flash is installed - http://bit.ly/QnBX8L */
var hasFlash = false;
try {
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if(fo) {
hasFlash = true;
}
}
catch(e) {
if( typeof navigator.mimeTypes ["application/x-shockwave-flash"] !== 'undefined' ) {
@tedw
tedw / ie-test.js
Created November 13, 2012 21:09
Check if IE
/* Check if IE - http://msdn.microsoft.com/en-us/library/ms537509(v=vs.85).aspx */
var getIEVersion = function() {
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp(/MSIE ([0-9]{1,}[\.0-9]{0,})/);
if (re.exec(ua) !== null)
rv = parseFloat( RegExp.$1 );
@tedw
tedw / insert-css.js
Created November 13, 2012 21:10
Dynamically Insert a CSS File
/* Dynamically insert a CSS file */
/* Inspired by http://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript */
var insertCSS = function(cssId, path, width) {
var $ = document;
if( !$.getElementById(cssId) ) {
var head = $.getElementsByTagName('head')[0],
link = $.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
@tedw
tedw / set-hash.js
Created November 13, 2012 21:15
Set URL Hash
/* Set hash */
var hashSet = function( value ) {
value = value || '';
// If no value and no hash, don't bother updating
if ( value || location.hash ) {
// Use pushState if possible to prevent page jump
if ( Modernizr.history ) {
// console.log('Push: ' + ( value ? '#' + value : '/' ) );
history.pushState(null, null, ( value ? '#' + value : '/' ) );
}
@tedw
tedw / popup-window.js
Created November 13, 2012 21:17
Popup Window
/* Popup Window */
var openPopup = function( url, h, w ) {
if ( url ) {
if ( h && w ) {
window.open(url, '_blank', 'menubar=no,status=no,titlebar=no,toolbar=no,height=' + h + ',width=' + w);
}
else {
window.open(url, '_blank');
}
}
@tedw
tedw / media-object.css
Created November 13, 2012 21:55
Media Object
/* Media List Styles (image next to text) */
/* Based on article by Nicole Sullivan http://goo.gl/5GrKJ */
.media-list {
list-style: none;
margin: 0;
padding: 0;
}
.media-list li {
background-image: none;
@tedw
tedw / list-classes.css
Created November 13, 2012 22:05
List Classes
/* List with items floated to the left */
.list-row {
list-style: none;
padding-left: 0;
}
.list-row > li {
float: left;
margin-left: 10px;
}
@font-face {
font-family: 'Ultramagnetic';
src: url('/assets/ywft-ultramagnetic.eot');
src: url('/assets/ywft-ultramagnetic.eot?#iefix') format('embedded-opentype'),
url('/assets/ywft-ultramagnetic.woff') format('woff'),
url('/assets/ywft-ultramagnetic.ttf') format('truetype'),
url('/assets/ywft-ultramagnetic.svg#ultramagnetic') format('svg');
font-weight: normal;
font-style: normal;
}