Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / index.html
Created October 20, 2015 01:00 — forked from bhauman/index.html
Dynamic source map test
<html>
<head>
<script src="modifyme.js"></script>
</head>
<body>
<h1>Testing source map reloading.</h1>
<h3>Open Dev Tools and look in the console.</h3>
<p>Execute the <code>test_sm()</code> function and follow the source links.</p>
</body>
</html>
@paulirish
paulirish / moved.md
Last active October 1, 2015 01:38 — forked from dmethvin/gist:1676346
Breakpoint on access to a property
@paulirish
paulirish / standards.md
Created October 24, 2011 20:53 — forked from addyosmani/standards.md
jQuery Standards Team

#Announcing The jQuery Standards Team

Today we're happy to announce the creation of a new jQuery sub-team called the jQuery Standards Team to give web developers to have a voice in the standards process.

##Introduction

We all know that web standards are important. They help ensure the code we write works across different technologies, for people of different abilities and most importantly across all browsers.

That said, how often do we all feel our voices, suggestions and ideas are heard by those groups responsible for defining these standards? The reality is that whilst many of us would like to see change, due to time restrictions and lengthy formal processes we're unable to participate in standards discussions, get involved with writing specifications and contribute to meetings about the future of features. This makes it difficult for web developers to have a voice.

// feature test for position fixed.
Modernizr.addTest('positionfixed', function () {
var test = document.createElement('div'),
control = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));
}());
/*
* 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')
// Idea from http://dbaron.org/log/20100424-any
jQuery.expr[':'].any = function(el, i, match) {
return jQuery.find.matches(match[3], [el]).length > 0;
};
jQuery('body :any(div, form) p'); // Same as jQuery('body div p, body form p')
jQuery('div:any(.foo,.bar)'); // Same as jQuery('div.foo, div.bar')
// mousewheel normalization.
// taken from http://html5readiness.com/js/script.js - cheers paul!
$(document).bind('DOMMouseScroll mousewheel', function(e, delta) {
delta = delta || (e.detail && -e.detail/3) || (e.wheelDelta && e.wheelDelta/120);
});
(function (undefined) {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false,
// original (http://html5shiv.googlecode.com/svn/trunk/html5.js)
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
// kangax version (29 characters less, yay!)
/*@cc_on(function(e,i){i=e.length;while(i--)document.createElement(e[i])})("abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','))@*/
// jdalton version (was 5, now 41 characters less than kangax, yay!)
//
// Replicates .activate() from the Prototype JS library.
// http://www.prototypejs.org/api/form/element/activate
//
jQuery.fn.activate = function() {
if ('focus' in this) this.focus();
if ('select' in this && (this.tagName != 'INPUT' || !(/^(?:button|reset|submit)$/i.test(this.type)))) {
this.select();