Modernizr definitions added

This commit is contained in:
Boris Yankov
2012-10-05 19:49:38 +03:00
parent 647369a322
commit a976315cac
2 changed files with 128 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
// Type definitions for Modernizr 2.6.2
// https://github.com/borisyankov/DefinitelyTyped
interface AudioBool {
ogg: bool;
mp3: bool;
wav: bool;
m4a: bool;
}
interface VideoBool {
ogg: bool;
h264: bool;
webm: bool;
}
interface ModernizrStatic {
fontface: bool;
backgroundsize: bool;
borderimage: bool;
borderradius: bool;
boxshadow: bool;
flexbox: bool;
hsla: bool;
multiplebgs: bool;
opacity: bool;
rgba: bool;
textshadow: bool;
cssanimations: bool;
csscolumns: bool;
generatedcontent: bool;
cssgradients: bool;
cssreflections: bool;
csstransforms: bool;
csstransforms3d: bool;
csstransitions: bool;
applicationcache: bool;
canvas: bool;
canvastext: bool;
draganddrop: bool;
hashchange: bool;
history: bool;
audio: AudioBool;
video: VideoBool;
indexeddb: bool;
localstorage: bool;
postmessage: bool;
sessionstorage: bool;
websockets: bool;
websqldatabase: bool;
webworkers: bool;
geolocation: bool;
inlinesvg: bool;
smil: bool;
svg: bool;
svgclippaths: bool;
touch: bool;
webgl: bool;
prefixed(): bool;
prefixed(property: string): bool;
prefixed(property: string, obj: any, element?: any): bool;
mq(mediaQuery: string): bool;
addTest(feature: string, test: () => any);
addTest(feature: string, test: bool);
addTest(feature: any);
testStyles(rule: string, callback: (element, rule) => bool, nodes?: number, testnames?: string[]): bool;
testProp(property: string): bool;
testAllProps(property: string, prefix?: string): bool;
testAllProps(property: string, obj: any, element: any): bool;
hasEvent(eventName: string, element?: any): bool;
}
declare var Modernizr: ModernizrStatic;
+50
View File
@@ -0,0 +1,50 @@
/// <reference path="../Definitions/modernizr.d.ts" />
declare var $: any;
function alert(thing: any) {
$('#content').append('<div>' + thing + '</div>');
}
$(function () {
var audio = new Audio();
audio.src = Modernizr.audio.ogg ? 'background.ogg' :
Modernizr.audio.mp3 ? 'background.mp3' :
'background.m4a';
if (Modernizr.webgl) {
// loadAllWebGLScripts();
} else {
var msg = 'With a different browser youll get to see the WebGL experience here: get.webgl.org.';
document.getElementById('#notice').innerHTML = msg;
}
Modernizr.prefixed('boxSizing');
Modernizr.prefixed('requestAnimationFrame', window);
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, document.body);
Modernizr.prefixed('requestAnimationFrame', window, false);
Modernizr.mq('only all and (max-width: 400px)');
Modernizr.mq('(min-width: 0px)');
Modernizr.mq('only screen and (max-width: 768px)');
Modernizr.addTest('track', () => {
var video = document.createElement('video');
// return typeof video.addTextTrack === 'function'
});
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => {
Modernizr.addTest('width', elem.offsetWidth == 9);
});
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => {
Modernizr.addTest('width', elem.offsetWidth == 9);
}, 2, ["video", "image"]);
Modernizr.testProp('pointerEvents');
Modernizr.testAllProps('boxSizing');
var elem;
Modernizr.hasEvent('gesturestart', elem);
});