Skip to content

Instantly share code, notes, and snippets.

View scottjehl's full-sized avatar

Scott Jehl scottjehl

View GitHub Profile
//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']
});
//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){
//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'),
//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 = {},
/* 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(),
/*
* 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
*/
/*
* 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')
//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() {
/*!
* 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
/*
* 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