Merge pull request #7178 from leonyu/modernizr3

Modernizr 3.2.0
This commit is contained in:
Horiuchi_H
2015-12-16 17:26:55 +09:00
3 changed files with 470 additions and 118 deletions
+96 -6
View File
@@ -19,9 +19,9 @@ $(function () {
document.getElementById('#notice').innerHTML = msg;
}
Modernizr.prefixed('boxSizing');
Modernizr.prefixed('boxSizing');
Modernizr.prefixed('requestAnimationFrame', window);
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, document.body);
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, true);
Modernizr.prefixed('requestAnimationFrame', window, false);
Modernizr.mq('only all and (max-width: 400px)');
@@ -30,7 +30,7 @@ $(function () {
Modernizr.addTest('track', () => {
var video = document.createElement('video');
// return typeof video.addTextTrack === 'function'
return typeof video.addTextTrack === 'function'
});
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => {
@@ -45,10 +45,100 @@ $(function () {
Modernizr.testAllProps('boxSizing');
var elem;
var elem: Element;
Modernizr.hasEvent('gesturestart', elem);
if (!Modernizr.autofocus) {
if (!Modernizr.input.autofocus) {
$("[autofocus]").focus();
}
});
Modernizr.on('flash', function( result ) {
if (result) {
// the browser has flash
} else {
// the browser does not have flash
}
});
Modernizr.addTest('itsTuesday', function() {
var d = new Date();
return d.getDay() === 2;
});
Modernizr.addTest('hasJquery', 'jQuery' in window);
var detects = {
'hasjquery': 'jQuery' in window,
'itstuesday': function() {
var d = new Date();
return d.getDay() === 2;
}
}
Modernizr.addTest(detects);
var keyframes = Modernizr.atRule('@keyframes');
if (keyframes) {
// keyframes are supported
// could be `@-webkit-keyframes` or `@keyframes`
} else {
// keyframes === `false`
}
Modernizr._domPrefixes === [ "Moz", "O", "ms", "Webkit" ];
Modernizr.hasEvent('blur') // true;
Modernizr.hasEvent('devicelight', window) // true;
var query = Modernizr.mq('(min-width: 900px)');
if (query) {
// the browser window is larger than 900px
}
Modernizr.prefixed('boxSizing')
var raf = Modernizr.prefixed('requestAnimationFrame', window);
raf(function() {
});
var rAFProp = Modernizr.prefixed('requestAnimationFrame', window, false);
rAFProp === 'WebkitRequestAnimationFrame' // in older webkit
Modernizr.prefixedCSS('transition') // '-moz-transition' in old Firefox
Modernizr.prefixedCSSValue('background', 'linear-gradient(left, red, red)')
var rule = Modernizr._prefixes.join('transform: rotate(20deg); ');
rule === 'transform: rotate(20deg); webkit-transform: rotate(20deg); moz-transform: rotate(20deg); o-transform: rotate(20deg); ms-transform: rotate(20deg);'
rule = 'display:' + Modernizr._prefixes.join('flex; display:') + 'flex';
rule === 'display:flex; display:-webkit-flex; display:-moz-flex; display:-o-flex; display:-ms-flex; display:flex'
Modernizr.testAllProps('boxSizing') // true
Modernizr.testAllProps('display', 'block') // true
Modernizr.testAllProps('display', 'penguin') // false
Modernizr.testAllProps('shapeOutside', 'content-box', true);
Modernizr.testProp('pointerEvents') // true
Modernizr.testProp('pointerEvents', 'none') // true
Modernizr.testProp('pointerEvents', 'penguin') // false
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', function(elem, rule) {
// elem is the first DOM node in the page (by default #modernizr)
// rule is the first argument you supplied - the CSS rule in string form
Modernizr.addTest('widthworks', elem.style.width === '9px')
});
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
document.getElementById('modernizr').style.width === '1px'; // true
document.getElementById('modernizr2').style.width === '2px'; // true
elem.firstChild === document.getElementById('modernizr2'); // true
}, 1);
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
document.getElementById('modernizr').style.width === '1px'; // true
document.getElementById('modernizr2').style.width === '2px'; // true
elem.firstChild === document.getElementById('modernizr2'); // true
}, 1);
-1
View File
@@ -1 +0,0 @@
+374 -111
View File
@@ -1,116 +1,379 @@
// Type definitions for Modernizr 2.6.2
// Type definitions for Modernizr 3.2.0
// Project: http://modernizr.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb/>, Leon Yu <https://github.com/leonyu/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace __Modernizr {
interface AudioBoolean {
ogg: boolean;
mp3: boolean;
wav: boolean;
m4a: boolean;
}
interface Audioboolean {
ogg: boolean;
mp3: boolean;
wav: boolean;
m4a: boolean;
interface VideoBoolean {
ogg: boolean;
h264: boolean;
webm: boolean;
}
interface InputBoolean {
autocomplete: boolean;
autofocus: boolean;
list: boolean;
placeholder: boolean;
max: boolean;
min: boolean;
multiple: boolean;
pattern: boolean;
required: boolean;
step: boolean;
}
interface InputTypesBoolean {
color: boolean;
date: boolean;
datetime: boolean;
"datetime-local": boolean;
email: boolean;
month: boolean;
number: boolean;
range: boolean;
search: boolean;
tel: boolean;
time: boolean;
url: boolean;
week: boolean;
}
interface FeatureDetects {
// Documented
ambientlight: boolean;
applicationcache: boolean;
audio: AudioBoolean;
batteryapi: boolean;
blobconstructor: boolean;
canvas: boolean;
canvastext: boolean;
contenteditable: boolean;
contextmenu: boolean;
cookies: boolean;
cors: boolean;
cryptography: boolean;
customprotocolhandler: boolean;
customevent: boolean;
dart: boolean;
dataview: boolean;
emoji: boolean;
eventlistener: boolean;
exiforientation: boolean;
flash: boolean;
forcetouch: boolean;
fullscreen: boolean;
gamepads: boolean;
geolocation: boolean;
hashchange: boolean;
hiddenscroll: boolean;
history: boolean;
htmlimports: boolean;
ie8compat: boolean;
indexeddb: boolean;
indexeddbblob: boolean;
input: InputBoolean;
search: boolean;
inputtypes: InputTypesBoolean;
intl: boolean;
json: boolean;
ligatures: boolean;
olreversed: boolean;
mathml: boolean;
notification: boolean;
pagevisibility: boolean;
performance: boolean;
pointerevents: boolean;
pointerlock: boolean;
postmessage: boolean;
proximity: boolean;
queryselector: boolean;
quotamanagement: boolean;
requestanimationframe: boolean;
serviceworker: boolean;
svg: boolean;
templatestrings: boolean;
touchevents: boolean;
typedarrays: boolean;
unicoderange: boolean;
unicode: boolean;
userdata: boolean;
vibrate: boolean;
video: VideoBoolean;
vml: boolean;
webintents: boolean;
animation: boolean;
webgl: boolean;
websockets: boolean;
xdomainrequest: boolean;
adownload: boolean;
audioloop: boolean;
audiopreload: boolean;
webaudio: boolean;
lowbattery: boolean;
canvasblending: boolean;
todataurljpeg: boolean;
todataurlpng: boolean;
todataurlwebp: boolean;
canvaswinding: boolean;
getrandomvalues: boolean;
cssall: boolean;
cssanimations: boolean;
appearance: boolean;
backdropfilter: boolean;
backgroundblendmode: boolean;
backgroundcliptext: boolean;
bgpositionshorthand: boolean;
bgpositionxy: boolean;
bgrepeatspace: boolean;
bgrepeatround: boolean;
backgroundsize: boolean;
bgsizecover: boolean;
borderimage: boolean;
borderradius: boolean;
boxshadow: boolean;
boxsizing: boolean;
csscalc: boolean;
checked: boolean;
csschunit: boolean;
csscolumns: boolean;
cubicbezierrange: boolean;
"display-runin": boolean;
displaytable: boolean;
ellipsis: boolean;
cssescape: boolean;
cssexunit: boolean;
cssfilters: boolean;
flexbox: boolean;
flexboxlegacy: boolean;
flexboxtweener: boolean;
flexwrap: boolean;
fontface: boolean;
generatedcontent: boolean;
cssgradients: boolean;
csshairline: boolean;
hsla: boolean;
csshyphens: boolean;
softhyphens: boolean;
softhyphensfind: boolean;
cssinvalid: boolean;
lastchild: boolean;
cssmask: boolean;
mediaqueries: boolean;
multiplebgs: boolean;
nthchild: boolean;
objectfit: boolean;
opacity: boolean;
overflowscrolling: boolean;
csspointerevents: boolean;
csspositionsticky: boolean;
csspseudoanimations: boolean;
csspseudotransitions: boolean;
cssreflections: boolean;
regions: boolean;
cssremunit: boolean;
cssresize: boolean;
rgba: boolean;
cssscrollbar: boolean;
scrollsnappoints: boolean;
shapes: boolean;
siblinggeneral: boolean;
subpixelfont: boolean;
supports: boolean;
target: boolean;
textalignlast: boolean;
textshadow: boolean;
csstransforms: boolean;
csstransforms3d: boolean;
preserve3d: boolean;
csstransitions: boolean;
userselect: boolean;
cssvalid: boolean;
cssvhunit: boolean;
cssvmaxunit: boolean;
cssvminunit: boolean;
cssvwunit: boolean;
willchange: boolean;
wrapflow: boolean;
classlist: boolean;
createelementattrs: boolean;
"createelement-attrs": boolean;
dataset: boolean;
documentfragment: boolean;
hidden: boolean;
microdata: boolean;
mutationobserver: boolean;
bdi: boolean;
datalistelem: boolean;
details: boolean;
outputelem: boolean;
picture: boolean;
progressbar: boolean;
meter: boolean;
ruby: boolean;
template: boolean;
time: boolean;
texttrackapi: boolean;
track: boolean;
unknownelements: boolean;
es5array: boolean;
es5date: boolean;
es5function: boolean;
es5object: boolean;
es5: boolean;
strictmode: boolean;
es5string: boolean;
es5syntax: boolean;
es5undefined: boolean;
es6array: boolean;
es6collections: boolean;
contains: boolean;
generators: boolean;
es6math: boolean;
es6number: boolean;
es6object: boolean;
promises: boolean;
es6string: boolean;
devicemotion: boolean;
deviceorientation: boolean;
oninput: boolean;
filereader: boolean;
filesystem: boolean;
capture: boolean;
fileinput: boolean;
directory: boolean;
formattribute: boolean;
localizednumber: boolean;
placeholder: boolean;
requestautocomplete: boolean;
formvalidation: boolean;
sandbox: boolean;
seamless: boolean;
srcdoc: boolean;
apng: boolean;
imgcrossorigin: boolean;
jpeg2000: boolean;
jpegxr: boolean;
sizes: boolean;
srcset: boolean;
webpalpha: boolean;
webpanimation: boolean;
webplossless: boolean;
"webp-lossless": boolean;
webp: boolean;
inputformaction: boolean;
inputformenctype: boolean;
inputformmethod: boolean;
inputformtarget: boolean;
beacon: boolean;
lowbandwidth: boolean;
eventsource: boolean;
fetch: boolean;
xhrresponsetypearraybuffer: boolean;
xhrresponsetypeblob: boolean;
xhrresponsetypedocument: boolean;
xhrresponsetypejson: boolean;
xhrresponsetypetext: boolean;
xhrresponsetype: boolean;
xhr2: boolean;
scriptasync: boolean;
scriptdefer: boolean;
speechrecognition: boolean;
speechsynthesis: boolean;
localstorage: boolean;
sessionstorage: boolean;
websqldatabase: boolean;
stylescoped: boolean;
svgasimg: boolean;
svgclippaths: boolean;
svgfilters: boolean;
svgforeignobject: boolean;
inlinesvg: boolean;
smil: boolean;
textareamaxlength: boolean;
bloburls: boolean;
datauri: boolean;
urlparser: boolean;
videoautoplay: boolean;
videoloop: boolean;
videopreload: boolean;
webglextensions: boolean;
datachannel: boolean;
getusermedia: boolean;
peerconnection: boolean;
websocketsbinary: boolean;
atobbtoa: boolean;
framed: boolean;
matchmedia: boolean;
blobworkers: boolean;
dataworkers: boolean;
sharedworkers: boolean;
transferables: boolean;
webworkers: boolean;
// Undocumented - usually aliases or new features
"atob-btoa": boolean;
"battery-api": boolean;
"blob-constructor": boolean;
"display-table": boolean;
"input-formaction": boolean;
"input-formenctype": boolean;
"input-formtarget": boolean;
"object-fit": boolean;
crypto: boolean;
displayrunin: boolean;
fileinputdirectory: boolean;
hairline: boolean;
inputsearchevent: boolean;
raf: boolean;
webanimations: boolean;
}
interface Dictionary<T> {
[key: string]: T;
}
interface ModernizrAPI {
on(feature: string, cb: (result: boolean) => any): void;
addTest(feature: string, test: () => boolean): void;
addTest(feature: string, test: boolean): void;
addTest(feature: Dictionary<any>): void;
atRule(prop: string): boolean;
_domPrefixes: string[];
hasEvent(eventName: string, element?: EventTarget): boolean;
mq(mq: string): boolean;
prefixed(prop: string): string;
prefixed(prop: string, obj: EventTarget, element?: boolean): any;
prefixedCSS(prop: string): string;
prefixedCSSValue(prop: string, value: string): string;
_prefixes: string[];
testAllProps(prop: string, value?: string, skipValueTest?: boolean): boolean;
testProp(prop: string, value?: string, useValue?: boolean): boolean;
testStyles(rule: string, callback: (elem: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean;
}
export interface ModernizrStatic extends ModernizrAPI, FeatureDetects { }
}
interface Videoboolean {
ogg: boolean;
h264: boolean;
webm: boolean;
}
interface Inputboolean {
autocomplete: boolean;
autofocus: boolean;
list: boolean;
placeholder: boolean;
max: boolean;
min: boolean;
multiple: boolean;
pattern: boolean;
required: boolean;
step: boolean;
}
interface InputTypesboolean {
search: boolean;
tel: boolean;
url: boolean;
email: boolean;
datetime: boolean;
date: boolean;
month: boolean;
week: boolean;
time: boolean;
datetimelocal: boolean;
number: boolean;
range: boolean;
color: boolean;
}
interface ModernizrStatic {
autofocus: boolean;
fontface: boolean;
backgroundsize: boolean;
borderimage: boolean;
borderradius: boolean;
boxshadow: boolean;
flexbox: boolean;
hsla: boolean;
multiplebgs: boolean;
opacity: boolean;
rgba: boolean;
textshadow: boolean;
cssanimations: boolean;
csscolumns: boolean;
generatedcontent: boolean;
cssgradients: boolean;
cssreflections: boolean;
csstransforms: boolean;
csstransforms3d: boolean;
csstransitions: boolean;
applicationcache: boolean;
canvas: boolean;
canvastext: boolean;
draganddrop: boolean;
hashchange: boolean;
history: boolean;
audio: Audioboolean;
video: Videoboolean;
indexeddb: boolean;
input: Inputboolean;
inputtypes: InputTypesboolean;
localstorage: boolean;
postmessage: boolean;
sessionstorage: boolean;
websockets: boolean;
websqldatabase: boolean;
webworkers: boolean;
geolocation: boolean;
inlinesvg: boolean;
smil: boolean;
svg: boolean;
svgclippaths: boolean;
touch: boolean;
webgl: boolean;
load(resources: any[]): void;
load(resourceObject: any): void;
load(resourceString: string): void;
prefixed(property: string): any;
prefixed(property: string, obj: any, element?: any): any;
mq(mediaQuery: string): boolean;
addTest(feature: string, test: () => any): void;
addTest(feature: string, test: boolean): void;
addTest(feature: any): void;
testStyles(rule: string, callback: (element: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean;
testProp(property: string): boolean;
testAllProps(property: string, prefix?: string): boolean;
testAllProps(property: string, obj: any, element: any): boolean;
hasEvent(eventName: string, element?: any): boolean;
}
declare var Modernizr: ModernizrStatic;
declare var Modernizr: __Modernizr.ModernizrStatic;