Skip to content

Instantly share code, notes, and snippets.

View sindre's full-sized avatar

Sindre Wimberger sindre

View GitHub Profile
@balupton
balupton / bind.trigger.prototype.js
Created January 26, 2011 15:42
Bind and Trigger Custom and Native Events in Prototype
/**
* Bind and Trigger custom and native events in Prototype
* @author Juriy Zaytsev (kangax)
* @author Benjamin Lupton (balupton)
* @copyright MIT license
**/
(function(){
var eventMatchers = {
'HTMLEvents': /^(?:load|unload|abort|error|select|hashchange|popstate|change|submit|reset|focus|blur|resize|scroll)$/,
/*
* 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
$("#foo").click(function(e){
if (e.clientX) {
// native mouse click
}
else {
// triggered mouse click
}
});
@paulirish
paulirish / gist:576335
Created September 12, 2010 19:05
Things to do when IE9 Beta comes out

Things to do when IE9 Beta comes out

Note significant features added since IE9 PP4

  • Implemented but not announced: box-shadow, hsla
  • Expecting: 2d transforms, css animation, css transitions, flexible box model
  • Maybe: gradients, columns, reflections, svg filters, uncrippling @font-face, 3d transforms
  • Maybe version auto-update functionality

Test Modernizr against it

  • Does it still throw an error checking elem.msTransform?
anonymous
anonymous / ipadlabels
Created August 20, 2010 19:43
var iPadLabels = function () {
function fix() {
var labels = document.getElementsByTagName('label'),
target_id,
el;
for (var i = 0; labels[i]; i++) {
if (labels[i].getAttribute('for')) {
labels[i].onclick = labelClick;
}
@kaelig
kaelig / gist:458477
Created June 30, 2010 10:04
Make Outlook 2007+ behave with line-heights
// Make Outlook 2007+ behave with line-heights
element {
mso-line-height-rule:exactly;
-mso-line-height-rule:exactly;
}
@paulirish
paulirish / gist:366184
Created April 14, 2010 18:59
html5 geolocation with fallback.
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
// doublecheck the ClientLocation results because it may returning null results
;(function(geolocation){
if (geolocation) return;
@remy
remy / gist:330318
Created March 12, 2010 13:59
autofocus and placeholder support
/**
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
*/
(function () {
function each(list, fn) {
var l = list.length;
@jensgro
jensgro / af-toggle.js
Created March 11, 2010 23:30
Klappfunktion mit jQuery und WAI-ARIA accessible machen.
/*
* Klappfunktion mit jQuery accessible machen mit WAI-ARIA. Skript von Alexander Farkas.
* Original: http://gist.github.com/329709
* Fork: http://gist.github.com/329832
* Ausgangsartikel mit Diskussion dazu:
http://grochtdreis.de/weblog/2010/03/11/anreicherung-meiner-webseite-mit-wai-aria/
*/
(function($){
/* a11y-helper */
/* Use this to cause a function to fire no more than once every 'ms' milliseconds.
For example, an expensive mousemove handler:
$('body').mouseover(ratelimit(function(ev) {
// ...
}, 250));
*/
function ratelimit(fn, ms) {
var last = (new Date()).getTime();