Skip to content

Commit

Permalink
Merge pull request #419 from addyosmani/master
Browse files Browse the repository at this point in the history
Pulling in feature-detection tests from modernizr-plugins
  • Loading branch information
paulirish committed Dec 4, 2011
2 parents 1e1af83 + 5efe030 commit 75afc46
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 1 deletion.
24 changes: 24 additions & 0 deletions feature-detects/apng.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Animated PNG
// http://en.wikipedia.org/wiki/APNG
// By Addy Osmani
(function () {

var image = new Image(),
canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');


image.onload = function () {
Modernizr.addTest('apng', function () {
if (typeof canvas.getContext == 'undefined') {
return false;
} else {
ctx.drawImage(image, 0, 0);
return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
}
});
};

image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==";

}());
4 changes: 4 additions & 0 deletions feature-detects/audiodata-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Mozilla Audio Data API
// https://wiki.mozilla.org/Audio_Data_API
// by Addy Osmani
Modernizr.addTest('audiodata', !!(window.Audio));
4 changes: 4 additions & 0 deletions feature-detects/classlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// classList
// https://developer.mozilla.org/en/DOM/element.classList
// By Addy Osmani
Modernizr.addTest('classlist', !!('classList' in document.createElement('a')));
4 changes: 4 additions & 0 deletions feature-detects/contenteditable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// contentEditable
// http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable
// by Addy Osmani
Modernizr.addTest('contenteditable', !!('isContentEditable' in document.createElement('span')));
4 changes: 3 additions & 1 deletion feature-detects/contextmenu.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// http://www.w3.org/TR/html5/interactive-elements.html#context-menus
// Demo at http://thewebrocks.com/demos/context-menu/
Modernizr.addTest(
'contextmenu',
('contextMenu' in document.body && 'HTMLMenuItemElement' in window)
);

// Demo at http://thewebrocks.com/demos/context-menu/




4 changes: 4 additions & 0 deletions feature-detects/dataview-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// DataView
// https://developer.mozilla.org/en/JavaScript_typed_arrays/DataView
// By Addy Osmani
Modernizr.addTest('dataview', (typeof DataView !== 'undefined' && 'getFloat64' in DataView.prototype));
4 changes: 4 additions & 0 deletions feature-detects/eventsource.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// EventSource
// http://dev.w3.org/html5/eventsource/
// By Addy Osmani
Modernizr.addTest('eventsource', !!('EventSource' in window));
6 changes: 6 additions & 0 deletions feature-detects/gamepad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// GamePad API
// https://wiki.mozilla.org/GamepadAPI
// Note: this feature detection test has been confirmed with the developers
// of the GamePad API implementation in FF
// By Addy Osmani
Modernizr.addTest('gamepad', !!('gamepads' in navigator));
4 changes: 4 additions & 0 deletions feature-detects/getusermedia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// getUserMedia
// http://www.whatwg.org/specs/web-apps/current-work/multipage/video-conferencing-and-peer-to-peer-communication.html
// By Addy Osmani
Modernizr.addTest('getusermedia', !!('getUserMedia' in navigator));
4 changes: 4 additions & 0 deletions feature-detects/microdata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Microdata support
// http://www.w3.org/TR/html5/microdata.html
// By Addy Osmani
Modernizr.addTest('microdata', !!(document['getItems']));
4 changes: 4 additions & 0 deletions feature-detects/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <output>
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-output-element
// by Addy Osmani
Modernizr.addTest('output', !!('value' in document.createElement('output')));
3 changes: 3 additions & 0 deletions feature-detects/progress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// HTML5 <progress> tag
// By Addy Osmani
Modernizr.addTest('progress', !!('position' in document.createElement('progress')));
4 changes: 4 additions & 0 deletions feature-detects/time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <time> element
// http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#the-time-element-0
// by Addy Osmani
Modernizr.addTest('time', !!('valueAsDate' in document.createElement('time')));
4 changes: 4 additions & 0 deletions feature-detects/track.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Track element
// http://www.w3.org/TR/html5/video.html#the-track-element
// By Addy Osmani
Modernizr.addTest('track', (typeof (document.createElement('video').addTextTrack) === 'function'));
4 changes: 4 additions & 0 deletions feature-detects/webaudio-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Web Audio API
// https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
// By Addy Osmani
Modernizr.addTest('webaudio', !!(window.webkitAudioContext || window.AudioContext));

0 comments on commit 75afc46

Please sign in to comment.