Skip to content

Instantly share code, notes, and snippets.

Scott Jehl scottjehl

Block or report user

Report or block scottjehl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View EnhanceJS: Resolution-based layout toggle.js
//EnhanceJS (enhancejs.googlecode.com)
//Quick idea for loading CSS depending on Screen resolution with EnhanceJS.
//Smart phones that pass capabilities tests would get mobile.css
//enhance page based on capabilities and serve different CSS based on screen resolution
enhance({
loadStyles: screen.availWidth < 500 ? ['css/mobile.css'] : ['css/screen.css']
});
View detect IE and version number through injected conditional comments.js
//EnhanceJS isIE test idea
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
function isIE(version, comparison) {
var cc = 'IE';
if(version){
View detect IE and version number through injected conditional comments.js
//EnhanceJS isIE test idea
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
function isIE(version, comparison) {
var cc = 'IE',
b = document.createElement('B'),
View detect IE and version number through injected conditional comments.js
//detect Internet Explorer and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
var isIE = (function(undefined){
var doc = document,
doc_elem = doc.documentElement,
cache = {},
View gist:364802
/* coordinate-based click event
- jsbin http://jsbin.com/ivaxu3/edit
*/
$.fn.clickxy = function(xy, callback){
var inzone = false,
tolerance = 10;
return $(this)
.bind('mousemove',function(e){
var offset = $(this).offset(),
View media query check
/*
* mediaquery function - test whether a CSS media type or query applies
* author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* Developed as a feature of the EnhanceJS Framework (enhancejs.googlecode.com)
* thx to:
- phpied.com/dynamic-script-and-style-elements-in-ie for inner css text trick
- @paul_irish for fakeBody trick
*/
View media query check - media.matchMedium.js
/*
* media.matchMedium()- test whether a CSS media type or media query applies
* primary author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* adapted by Paul Irish to use the matchMedium API
* http://www.w3.org/TR/cssom-view/#media
* Doesn't implement media.type as there's no way for crossbrowser property
* getters. instead of media.type == 'tv' just use media.matchMedium('tv')
View Let IE7+ Into jQuery Mobile
//run this script after jQuery loads, but before jQuery Mobile loads
//customize jQuery Mobile to let IE7+ in (Mobile IE)
$(document).bind("mobileinit", function(){
$.extend( $.mobile , {
//extend gradeA qualifier to include IE7+
gradeA: function(){
//IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
var ie = (function() {
View quick custom build for test...
/*!
* jQuery Mobile v1.0a3pre
* http://jquerymobile.com/
*
* Copyright 2010, jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function(a,f){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var e=0,d;(d=b[e])!=null;e++)a(d).triggerHandler("remove");c(b)}}else{var g=a.fn.remove;a.fn.remove=function(b,e){return this.each(function(){if(!e)if(!b||a.filter(b,[this]).length)a("*",this).add([this]).each(function(){a(this).triggerHandler("remove")});return g.call(a(this),b,e)})}}a.widget=function(b,e,d){var i=b.split(".")[0],k;b=b.split(".")[1];k=i+"-"+b;if(!d){d=e;e=a.Widget}a.expr[":"][k]=function(l){return!!a.data(l,
b)};a[i]=a[i]||{};a[i][b]=function(l,h){arguments.length&&this._createWidget(l,h)};e=new e;e.options=a.extend(true,{},e.options);a[i][b].prototype=a.extend(true,e,{namespace:i,widgetName:b,widgetEventPrefix:a[i][b].prototype.widgetEventPrefix||b,widgetBaseClass:k},d);a.widget.bridge(b,a[i][b])};a.widget.bridge=function(b,e){a.fn
View matchMedia.js
/*
* matchMedia() polyfill - test whether a CSS media type or media query applies
* primary author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* adapted by Paul Irish to use the matchMedia API
* http://dev.w3.org/csswg/cssom-view/#dom-window-matchmedia
* which webkit now supports: http://trac.webkit.org/changeset/72552
*
* Doesn't implement media.type as there's no way for crossbrowser property
You can’t perform that action at this time.