SlideShare a Scribd company logo
1 of 56
modernizr-1.5.js
/*!
* Modernizr JavaScript library 1.5
* http://www.modernizr.com/
*
* Copyright (c) 2009-2010 Faruk Ates - http://farukat.es/
* Dual-licensed under the BSD and MIT licenses.
* http://www.modernizr.com/license/
*
* Featuring major contributions by
* Paul Irish - http://paulirish.com
*/
/*
* LicenseModernizr is available under the MIT and BSD
licenses:
* MIT License
* Copyright (c) 2009–2010 Faruk Ate?
* Permission is hereby granted, free of charge, to any person
obtaining a copy
* of this software and associated documentation files (the
"Software"), to deal
* in the Software without restriction, including without
limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell
* copies of the Software, and to permit persons to whom the
Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall
be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* BSD License
* Copyright (c) 2010, Faruk Ate?
* All rights reserved.
* Redistribution and use in source and binary forms, with or
without
* modification, are permitted provided that the following
conditions are met:
* * Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
copyright
* notice, this list of conditions and the following disclaimer in
the
* documentation and/or other materials provided with the
distribution.
* * Neither the name of the Organization nor the
* names of its contributors may be used to endorse or promote
products
* derived from this software without specific prior written
permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT
HOLDER BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
/*
* Modernizr is a script that will detect native CSS3 and
HTML5 features
* available in the current UA and provide an object containing
all
* features with a true/false value, depending on whether the
UA has
* native support for it or not.
*
* In addition to that, Modernizr will add classes to the <html>
* element of the page, one for each cutting-edge feature. If the
UA
* supports it, a class like "cssgradients" will be added. If not,
* the class name will be "no-cssgradients". This allows for
simple
* if-conditionals in CSS styling, making it easily to have fine
* control over the look and feel of your website.
*
* @author Faruk Ates
* @copyright (c) 2009-2010 Faruk Ates.
*
* @contributor Paul Irish
* @contributor Ben Alman
*/
window.Modernizr = (function(window,doc,undefined){
var version = '1.5',
ret = {},
/**
* enableHTML5 is a private property for advanced use only.
If enabled,
* it will make Modernizr.init() run through a brief while()
loop in
* which it will create all HTML5 elements in the DOM to
allow for
* styling them in Internet Explorer, which does not
recognize any
* non-HTML4 elements unless created in the DOM this way.
*
* enableHTML5 is ON by default.
*/
enableHTML5 = true,
/**
* fontfaceCheckDelay is the ms delay before the @font-face
test is
* checked a second time. This is neccessary because both
Gecko and
* WebKit do not load data: URI font data synchronously.
* https://bugzilla.mozilla.org/show_bug.cgi?id=512566
* The check will be done again at fontfaceCheckDelay*2 and
then
* a fourth time at window's load event.
* If you need to query for @font-face support, send a
callback to:
* Modernizr._fontfaceready(fn);
* The callback is passed the boolean value of
Modernizr.fontface
*/
fontfaceCheckDelay = 75,
docElement = doc.documentElement,
/**
* Create our "modernizr" element that we do most feature
tests on.
*/
mod = 'modernizr',
m = doc.createElement( mod ),
m_style = m.style,
/**
* Create the input element for various Web Forms feature
tests.
*/
f = doc.createElement( 'input' ),
// Reused strings, stored here to allow better minification
canvas = 'canvas',
canvastext = 'canvastext',
rgba = 'rgba',
hsla = 'hsla',
multiplebgs = 'multiplebgs',
backgroundsize = 'backgroundsize',
borderimage = 'borderimage',
borderradius = 'borderradius',
boxshadow = 'boxshadow',
opacity = 'opacity',
cssanimations = 'cssanimations',
csscolumns = 'csscolumns',
cssgradients = 'cssgradients',
cssreflections = 'cssreflections',
csstransforms = 'csstransforms',
csstransforms3d = 'csstransforms3d',
csstransitions = 'csstransitions',
fontface = 'fontface',
geolocation = 'geolocation',
video = 'video',
audio = 'audio',
input = 'input',
inputtypes = input + 'types',
// inputtypes is an object of its own containing individual
tests for
// various new input types, such as search, range, datetime,
etc.
svg = 'svg',
smil = 'smil',
svgclippaths = svg+'clippaths',
background = 'background',
backgroundColor = background + 'Color',
canPlayType = 'canPlayType',
// FF gets really angry if you name local variables as these,
but camelCased.
localstorage = 'localStorage',
sessionstorage = 'sessionStorage',
applicationcache = 'applicationCache',
webWorkers = 'webworkers',
hashchange = 'hashchange',
crosswindowmessaging = 'crosswindowmessaging',
historymanagement = 'historymanagement',
draganddrop = 'draganddrop',
websqldatabase = 'websqldatabase',
indexedDB = 'indexedDB',
websockets = 'websockets',
smile = ':)',
// IE7 gets mad if you name a local variable `toString`
tostring = Object.prototype.toString,
// list of property values to set for css tests. see ticket #21
prefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
tests = {},
inputs = {},
attrs = {},
classes = [],
/**
* isEventSupported determines if a given element supports
the given event
* function from
http://yura.thinkweb2.com/isEventSupported/
*/
isEventSupported = (function(){
var TAGNAMES = {
'select':'input','change':'input',
'submit':'form','reset':'form',
'error':'img','load':'img','abort':'img'
},
cache = { };
function isEventSupported(eventName, element) {
var canCache = (arguments.length == 1);
// only return cached result when no element is given
if (canCache && cache[eventName]) {
return cache[eventName];
}
element = element ||
document.createElement(TAGNAMES[eventName] || 'div');
eventName = 'on' + eventName;
// When using `setAttribute`, IE skips "unload", WebKit
skips "unload" and "resize"
// `in` "catches" those
var isSupported = (eventName in element);
if (!isSupported && element.setAttribute) {
element.setAttribute(eventName, 'return;');
isSupported = typeof element[eventName] ==
'function';
}
element = null;
return canCache ? (cache[eventName] = isSupported) :
isSupported;
}
return isEventSupported;
})();
var _hasOwnProperty = ({}).hasOwnProperty,
hasOwnProperty;
if (typeof _hasOwnProperty !== 'undefined' && typeof
_hasOwnProperty.call !== 'undefined') {
hasOwnProperty = function (object, property) {
return _hasOwnProperty.call(object, property);
};
}
else {
hasOwnProperty = function (object, property) { /* yes, this
can give false positives/negatives, but most of the time we don't
care about those */
return ((property in object) && typeof
object.constructor.prototype[property] === 'undefined');
};
}
/**
* set_css applies given styles to the Modernizr DOM node.
*/
function set_css( str ) {
m_style.cssText = str;
}
/**
* set_css_all extrapolates all vendor-specific css strings.
*/
function set_css_all( str1, str2 ) {
return set_css(prefixes.join(str1 + ';') + ( str2 || '' ));
}
/**
* contains returns a boolean for if substr is found within str.
*/
function contains( str, substr ) {
return (''+str).indexOf( substr ) !== -1;
}
/**
* test_props is a generic CSS / DOM property test; if a
browser supports
* a certain property, it won't return undefined for it.
* A supported CSS property returns empty string when its
not yet set.
*/
function test_props( props, callback ) {
for ( var i in props ) {
if ( m_style[ props[i] ] !== undefined && ( !callback ||
callback( props[i], m ) ) ) {
return true;
}
}
}
/**
* test_props_all tests a list of DOM properties we want to
check against.
* We specify literally ALL possible (known and/or likely)
properties on
* the element including the non-vendor prefixed one, for
forward-
* compatibility.
*/
function test_props_all( prop, callback ) {
var uc_prop = prop.charAt(0).toUpperCase() +
prop.substr(1),
// following spec is to expose vendor-specific style
properties as:
// elem.style.WebkitBorderRadius
// and the following would be incorrect:
// elem.style.webkitBorderRadius
// Webkit and Mozilla are nice enough to ghost their
properties in the lowercase
// version but Opera does not.
// see more here:
http://github.com/Modernizr/Modernizr/issues/issue/21
props = [
prop,
'Webkit' + uc_prop,
'Moz' + uc_prop,
'O' + uc_prop,
'ms' + uc_prop,
'Khtml' + uc_prop
];
return !!test_props( props, callback );
}
/**
* Tests
*/
tests[canvas] = function() {
return !!doc.createElement( canvas ).getContext;
};
tests[canvastext] = function() {
return !!(tests[canvas]() && typeof doc.createElement(
canvas ).getContext('2d').fillText == 'function');
};
/**
* The Modernizr.touch test only indicates if the browser
supports
* touch events, which does not necessarily reflect a
touchscreen
* device, as evidenced by tablets running Windows 7 or,
alas,
* the Palm Pre / WebOS (touch) phones.
* Additionally, chrome used to lie about its support on this,
but that
* has since been recitifed: http://crbug.com/36415
* Because there is no way to reliably detect Chrome's false
positive
* without UA sniffing we have removed this test from
Modernizr. We
* hope to add it in after Chrome 5 has been sunsetted.
* See also
http://github.com/Modernizr/Modernizr/issues#issue/84
tests[touch] = function() {
return !!('ontouchstart' in window);
};
*/
/**
* geolocation tests for the new Geolocation API
specification.
* This test is a standards compliant-only test; for more
complete
* testing, including a Google Gears fallback, please see:
* http://code.google.com/p/geo-location-javascript/
* or view a fallback solution using google's geo API:
* http://gist.github.com/366184
*/
tests[geolocation] = function() {
return !!navigator.geolocation;
};
tests[crosswindowmessaging] = function() {
return !!window.postMessage;
};
tests[websqldatabase] = function() {
var result = !!window.openDatabase;
if (result){
try {
result = !!openDatabase("testdb", "1.0", "html5 test db",
200000);
} catch(err) {
result = false;
}
}
return result;
};
tests[indexedDB] = function(){
return !!window[indexedDB];
};
// documentMode logic from YUI to filter out IE8 Compat
Mode
// which false positives.
tests[hashchange] = function() {
return isEventSupported(hashchange, window) && (
document.documentMode === undefined ||
document.documentMode > 7 );
};
tests[historymanagement] = function() {
return !!(window.history && history.pushState);
};
tests[draganddrop] = function() {
return isEventSupported('drag')
&& isEventSupported('dragstart')
&& isEventSupported('dragenter')
&& isEventSupported('dragover')
&& isEventSupported('dragleave')
&& isEventSupported('dragend')
&& isEventSupported('drop');
};
tests[websockets] = function(){
return ('WebSocket' in window);
};
// http://css-tricks.com/rgba-browser-support/
tests[rgba] = function() {
// Set an rgba() color and check the returned value
set_css( background + '-color:rgba(150,255,150,.5)' );
return contains( m_style[backgroundColor], rgba );
};
tests[hsla] = function() {
// Same as rgba(), in fact, browsers re-map hsla() to rgba()
internally
set_css( background + '-color:hsla(120,40%,100%,.5)' );
return contains( m_style[backgroundColor], rgba );
};
tests[multiplebgs] = function() {
// Setting multiple images AND a color on the background
shorthand property
// and then querying the style.background property value
for the number of
// occurrences of "url(" is a reliable method for detecting
ACTUAL support for this!
set_css( background + ':url(//:),url(//:),red url(//:)' );
// If the UA supports multiple backgrounds, there should
be three occurrences
// of the string "url(" in the return value for
elem_style.background
return new
RegExp("(urls*(.*?){3}").test(m_style[background]);
};
// In testing support for a given CSS property, it's legit to
test:
// elem.style[styleName] !== undefined
// If the property is supported it will return an empty string,
// if unsupported it will return undefined.
// We'll take advantage of this quick test and skip setting a
style
// on our modernizr element, but instead just testing
undefined vs
// empty string.
// The legacy set_css_all calls will remain in the source
// (however, commented) in for clarity, yet functionally they
are
// no longer needed.
tests[backgroundsize] = function() {
return test_props_all( background + 'Size' );
};
tests[borderimage] = function() {
// set_css_all( 'border-image:url(m.png) 1 1 stretch' );
return test_props_all( 'borderImage' );
};
// super comprehensive table about all the unique
implementations of
// border-radius: http://muddledramblings.com/table-of-css3-
border-radius-compliance
tests[borderradius] = function() {
// set_css_all( 'border-radius:10px' );
return test_props_all( 'borderRadius', '', function( prop ) {
return contains( prop, 'orderRadius' );
});
};
tests[boxshadow] = function() {
// set_css_all( 'box-shadow:#000 1px 1px 3px' );
return test_props_all( 'boxShadow' );
};
tests[opacity] = function() {
// Browsers that actually have CSS Opacity implemented
have done so
// according to spec, which means their return values are
within the
// range of [0.0,1.0] - including the leading zero.
set_css_all( 'opacity:.5' );
return contains( m_style[opacity], '0.5' );
};
tests[cssanimations] = function() {
// set_css_all( 'animation:"animate" 2s ease 2',
'position:relative' );
return test_props_all( 'animationName' );
};
tests[csscolumns] = function() {
// set_css_all( 'column-count:3' );
return test_props_all( 'columnCount' );
};
tests[cssgradients] = function() {
/**
* For CSS Gradients syntax, please see:
* http://webkit.org/blog/175/introducing-css-gradients/
* https://developer.mozilla.org/en/CSS/-moz-linear-
gradient
* https://developer.mozilla.org/en/CSS/-moz-radial-
gradient
* http://dev.w3.org/csswg/css3-images/#gradients-
*/
var str1 = background + '-image:',
str2 = 'gradient(linear,left top,right
bottom,from(#9f9),to(white));',
str3 = 'linear-gradient(left top,#9f9, white);';
set_css(
(str1 + prefixes.join(str2 + str1) + prefixes.join(str3 +
str1)).slice(0,-str1.length)
);
return contains( m_style.backgroundImage, 'gradient' );
};
tests[cssreflections] = function() {
// set_css_all( 'box-reflect:right 1px' );
return test_props_all( 'boxReflect' );
};
tests[csstransforms] = function() {
// set_css_all( 'transform:rotate(3deg)' );
return !!test_props([ 'transformProperty',
'WebkitTransform', 'MozTransform', 'OTransform',
'msTransform' ]);
};
tests[csstransforms3d] = function() {
// set_css_all( 'perspective:500' );
var ret = !!test_props([ 'perspectiveProperty',
'WebkitPerspective', 'MozPerspective', 'OPerspective',
'msPerspective' ]);
// webkit has 3d transforms disabled for chrome, though
// it works fine in safari on leopard and snow leopard
// as a result, it 'recognizes' the syntax and throws a false
positive
// thus we must do a more thorough check:
if (ret){
var st = document.createElement('style'),
div = doc.createElement('div');
// webkit allows this media query to succeed only if the
feature is enabled.
// "@media (transform-3d),(-o-transform-3d),(-moz-
transform-3d),(-ms-transform-3d),(-webkit-transform-
3d),(modernizr){#modernizr{height:3px}}"
st.textContent = '@media ('+prefixes.join('transform-
3d),(')+'modernizr){#modernizr{height:3px}}';
doc.getElementsByTagName('head')[0].appendChild(st);
div.id = 'modernizr';
docElement.appendChild(div);
ret = div.offsetHeight === 3;
st.parentNode.removeChild(st);
div.parentNode.removeChild(div);
}
return ret;
};
tests[csstransitions] = function() {
// set_css_all( 'transition:all .5s linear' );
return test_props_all( 'transitionProperty' );
};
// @font-face detection routine created by Paul Irish -
paulirish.com
// Merged into Modernizr with approval. Read more about
Paul's work here:
// http://paulirish.com/2009/font-face-feature-detection/
tests[fontface] = function(){
var fontret;
if
(/*@[email protected](@_jscript_version>=5)[email protected]
@*/0) fontret = true;
else {
// Create variables for dedicated @font-face test
var st = doc.createElement('style'),
spn = doc.createElement('span'),
size, isFakeBody = false, body = doc.body,
callback, isCallbackCalled;
// The following is a font-face + glyph definition for the .
character:
st.textContent = "@font-face{font-
family:testfont;src:url('data:font/ttf;base64,AAEAAAAMAIAA
AwBAT1MvMliohmwAAADMAAAAVmNtYXCp5qrBAAABJA
AAANhjdnQgACICiAAAAfwAAAAEZ2FzcP//AAMAAAIAAA
AACGdseWYv5OZoAAACCAAAANxoZWFk69bnvwAAAuQA
AAA2aGhlYQUJAt8AAAMcAAAAJGhtdHgGDgC4AAADQAA
AABRsb2NhAIQAwgAAA1QAAAAMbWF4cABVANgAAANg
AAAAIG5hbWUgXduAAAADgAAABPVwb3N03NkzmgAACH
gAAAA4AAECBAEsAAUAAAKZAswAAACPApkCzAAAAesA
MwEJAAACAAMDAAAAAAAAgAACbwAAAAoAAAAAAAA
AAFBmRWQAAAAgqS8DM/8zAFwDMwDNAAAABQAAAAA
AAAAAAAMAAAADAAAAHAABAAAAAABGAAMAAQAA
AK4ABAAqAAAABgAEAAEAAgAuqQD//wAAAC6pAP///9ZX
AwAAAAAAAAACAAAABgBoAAAAAAAvAAEAAAAAAAA
AAAAAAAAAAAABAAIAAAAAAAAAAgAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
AAEACoAAAAGAAQAAQACAC6pAP//AAAALqkA////1lcDA
AAAAAAAAAIAAAAiAogAAAAB//8AAgACACIAAAEyAqoA
AwAHAC6xAQAvPLIHBADtMrEGBdw8sgMCAO0yALEDAC8
8sgUEAO0ysgcGAfw8sgECAO0yMxEhESczESMiARDuzMwCq
v1WIgJmAAACAFUAAAIRAc0ADwAfAAATFRQWOwEyNj0
BNCYrASIGARQGKwEiJj0BNDY7ATIWFX8aIvAiGhoi8CIaA
ZIoN/43KCg3/jcoAWD0JB4eJPQkHh7++EY2NkbVRjY2RgAA
AAABAEH/+QCdAEEACQAANjQ2MzIWFAYjIkEeEA8fHw8Q
DxwWFhwWAAAAAQAAAAIAAIuYbWpfDzz1AAsEAAAAA
ADFn9IuAAAAAMWf0i797/8zA4gDMwAAAAgAAgAAAAAA
AAABAAADM/8zAFwDx/3v/98DiAABAAAAAAAAAAAAAA
AAAAAABQF2ACIAAAAAAVUAAAJmAFUA3QBBAAAAKg
AqACoAWgBuAAEAAAAFAFAABwBUAAQAAgAAAAEAAQ
AAAEAALgADAAMAAAAQAMYAAQAAAAAAAACLAAAA
AQAAAAAAAQAhAIsAAQAAAAAAAgAFAKwAAQAAAAA
AAwBDALEAAQAAAAAABAAnAPQAAQAAAAAABQAKAR
sAAQAAAAAABgAmASUAAQAAAAAADgAaAUsAAwABBA
kAAAEWAWUAAwABBAkAAQBCAnsAAwABBAkAAgAKAr
0AAwABBAkAAwCGAscAAwABBAkABABOA00AAwABBAk
ABQAUA5sAAwABBAkABgBMA68AAwABBAkADgA0A/tDb
3B5cmlnaHQgMjAwOSBieSBEYW5pZWwgSm9obnNvbi4gIFJl
bGVhc2VkIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgT3BlbiBG
b250IExpY2Vuc2UuIEtheWFoIExpIGdseXBocyBhcmUgcmVsZ
WFzZWQgdW5kZXIgdGhlIEdQTCB2ZXJzaW9uIDMuYmFlYzJ
hOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhTGlnaHRiYW
VjMmE5MmJmZmU1MDMyIC0gc3Vic2V0IG9mIEZvbnRGb3Jn
ZSAyLjAgOiBKdXJhIExpZ2h0IDogMjMtMS0yMDA5YmFlYzJ
hOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhIExpZ2h0Vm
Vyc2lvbiAyIGJhZWMyYTkyYmZmZTUwMzIgLSBzdWJzZXQg
b2YgSnVyYUxpZ2h0aHR0cDovL3NjcmlwdHMuc2lsLm9yZy9P
RkwAQwBvAHAAeQByAGkAZwBoAHQAIAAyADAAMAA5A
CAAYgB5ACAARABhAG4AaQBlAGwAIABKAG8AaABuAH
MAbwBuAC4AIAAgAFIAZQBsAGUAYQBzAGUAZAAgAHU
AbgBkAGUAcgAgAHQAaABlACAAdABlAHIAbQBzACAAbw
BmACAAdABoAGUAIABPAHAAZQBuACAARgBvAG4AdAA
gAEwAaQBjAGUAbgBzAGUALgAgAEsAYQB5AGEAaAAgAE
wAaQAgAGcAbAB5AHAAaABzACAAYQByAGUAIAByAGU
AbABlAGEAcwBlAGQAIAB1AG4AZABlAHIAIAB0AGgAZQ
AgAEcAUABMACAAdgBlAHIAcwBpAG8AbgAgADMALgBiA
GEAZQBjADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyAC
AALQAgAHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHI
AYQBMAGkAZwBoAHQAYgBhAGUAYwAyAGEAOQAyAGI
AZgBmAGUANQAwADMAMgAgAC0AIABzAHUAYgBzAGU
AdAAgAG8AZgAgAEYAbwBuAHQARgBvAHIAZwBlACAAM
gAuADAAIAA6ACAASgB1AHIAYQAgAEwAaQBnAGgAdAA
gADoAIAAyADMALQAxAC0AMgAwADAAOQBiAGEAZQBj
ADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyACAALQAg
AHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHIAYQAgA
EwAaQBnAGgAdABWAGUAcgBzAGkAbwBuACAAMgAgAGI
AYQBlAGMAMgBhADkAMgBiAGYAZgBlADUAMAAzADIAI
AAtACAAcwB1AGIAcwBlAHQAIABvAGYAIABKAHUAcgBh
AEwAaQBnAGgAdABoAHQAdABwADoALwAvAHMAYwByA
GkAcAB0AHMALgBzAGkAbAAuAG8AcgBnAC8ATwBGAEw
AAAAAAgAAAAAAAP+BADMAAAAAAAAAAAAAAAAAA
AAAAAAAAAAFAAAAAQACAQIAEQt6ZXJva2F5YWhsaQ==
')}";
doc.getElementsByTagName('head')[0].appendChild(st);
// we don't use `serif` and we don't use `monospace`
//
http://github.com/Modernizr/Modernizr/issues/closed#issue/39
//
http://neugierig.org/software/chromium/notes/2009/09/monospa
ce-fonts-workaround.html
spn.setAttribute('style','font:99px
_,arial,helvetica;position:absolute;visibility:hidden');
if (!body){
body =
docElement.appendChild(doc.createElement(fontface));
isFakeBody = true;
}
// the data-uri'd font only has the . glyph; which is 3
pixels wide.
spn.innerHTML = '........';
spn.id = 'fonttest';
body.appendChild(spn);
size = spn.offsetWidth*spn.offsetHeight;
spn.style.font = '99px testfont,_,arial,helvetica';
// needed for the CSSFontFaceRule false positives (ff3,
chrome, op9)
fontret = size !== spn.offsetWidth*spn.offsetHeight;
function delayedCheck(){
if (!body.parentNode) return;
fontret = ret[fontface] = size !==
spn.offsetWidth*spn.offsetHeight;
docElement.className =
docElement.className.replace(/(no-)?fontfaceb/,'') + (fontret ?
' ' : ' no-') + fontface;
}
setTimeout(delayedCheck,fontfaceCheckDelay);
setTimeout(delayedCheck,fontfaceCheckDelay*2);
addEventListener('load',function(){
delayedCheck();
(isCallbackCalled = true) && callback &&
callback(fontret);
setTimeout(function(){
if (!isFakeBody) body = spn;
body.parentNode.removeChild(body);
st.parentNode.removeChild(st);
}, 50);
},false);
}
// allow for a callback
ret._fontfaceready = function(fn){
(isCallbackCalled || fontret) ? fn(fontret) : (callback =
fn);
}
return fontret || size !== spn.offsetWidth;
};
// These tests evaluate support of the video/audio elements,
as well as
// testing what types of content they support.
//
// we're using the Boolean constructor here, so that we can
extend the value
// e.g. Modernizr.video // true
// Modernizr.video.ogg // 'probably'
//
// codec values from :
http://github.com/NielsLeenheer/html5test/blob/9106a8/index.ht
ml#L845
// thx to NielsLeenheer and zcorpan
tests[video] = function() {
var elem = doc.createElement(video),
bool = !!elem[canPlayType];
if (bool){
bool = new Boolean(bool);
bool.ogg = elem[canPlayType]('video/ogg;
codecs="theora"');
bool.h264 = elem[canPlayType]('video/mp4;
codecs="avc1.42E01E"');
bool.webm = elem[canPlayType]('video/webm;
codecs="vp8, vorbis"');
}
return bool;
};
tests[audio] = function() {
var elem = doc.createElement(audio),
bool = !!elem[canPlayType];
if (bool){
bool = new Boolean(bool);
bool.ogg = elem[canPlayType]('audio/ogg;
codecs="vorbis"');
bool.mp3 = elem[canPlayType]('audio/mpeg;');
// mimetypes accepted:
//
https://developer.mozilla.org/En/Media_formats_supported_by_
the_audio_and_video_elements
// http://bit.ly/iphoneoscodecs
bool.wav = elem[canPlayType]('audio/wav;
codecs="1"');
bool.m4a = elem[canPlayType]('audio/x-m4a;') ||
elem[canPlayType]('audio/aac;');
}
return bool;
};
// both localStorage and sessionStorage are
// tested in this method because otherwise Firefox will
// throw an error:
https://bugzilla.mozilla.org/show_bug.cgi?id=365772
// if cookies are disabled
// FWIW miller device resolves to [object Storage] in all
supporting browsers
// except for IE who does [object Object]
// IE8 Compat mode supports these features completely:
// http://www.quirksmode.org/dom/html5.html
tests[localstorage] = function() {
return ('localStorage' in window) &&
window[localstorage] !== null;
};
tests[sessionstorage] = function() {
// try/catch required for pissy FF behavior
try {
return ('sessionStorage' in window) &&
window[sessionstorage] !== null;
} catch(e){
return false;
}
};
tests[webWorkers] = function () {
return !!window.Worker;
};
tests[applicationcache] = function() {
var cache = window[applicationcache];
return !!(cache && (typeof cache.status != 'undefined')
&& (typeof cache.update == 'function') && (typeof
cache.swapCache == 'function'));
};
// thanks to Erik Dahlstrom
tests[svg] = function(){
return !!doc.createElementNS && !!doc.createElementNS(
"http://www.w3.org/2000/svg", "svg").createSVGRect;
};
// thanks to F1lt3r and lucideer
// http://github.com/Modernizr/Modernizr/issues#issue/35
tests[smil] = function(){
return !!doc.createElementNS &&
/SVG/.test(tostring.call(doc.createElementNS('http://www.w3.or
g/2000/svg','animate')));
};
tests[svgclippaths] = function(){
// returns a false positive in saf 3.2?
return !!doc.createElementNS &&
/SVG/.test(tostring.call(doc.createElementNS('http://www.w3.or
g/2000/svg','clipPath')));
};
// input features and input types go directly onto the ret
object, bypassing the tests loop.
// hold this guy to execute in a moment.
function webforms(){
// Run through HTML5's new input attributes to see if the
UA understands any.
// We're using f which is the <input> element created early
on
// Mike Taylr has created a comprehensive resource for
testing these attributes
// when applied to all input types:
// http://miketaylr.com/code/input-type-attr.html
// spec: http://www.whatwg.org/specs/web-apps/current-
work/multipage/the-input-element.html#input-type-attr-
summary
ret[input] = (function(props) {
for (var i = 0,len=props.length;i<len;i++) {
attrs[ props[i] ] = !!(props[i] in f);
}
return attrs;
})('autocomplete autofocus list placeholder max min
multiple pattern required step'.split(' '));
// Run through HTML5's new input types to see if the UA
understands any.
// This is put behind the tests runloop because it doesn't
return a
// true/false like all the other tests; instead, it returns an
object
// containing each input type with its corresponding
true/false value
// Big thx to @miketaylr for the html5 forms expertise.
http://miketaylr.com/
ret[inputtypes] = (function(props) {
for (var i = 0,bool,len=props.length;i<len;i++) {
f.setAttribute('type', props[i]);
bool = f.type !== 'text';
// chrome likes to falsely purport support, so we feed
it a textual value
// if that doesnt succeed then we know there's a
custom UI
if (bool){
f.value = smile;
/* Safari 4 is allowing the smiley as a value, and
incorrecty failing..
the test fixes for webkit only, but breaks Opera..
if (/range/.test(f.type)){
bool =
test_props_all('appearance',function(prop,m){ return
m_style[prop] !== 'textfield' })
}
*/
if (/tel|search/.test(f.type)){
// spec doesnt define any special parsing or
detectable UI
// behaviors so we pass these through as true
} else if (/url|email/.test(f.type)) {
// real url and email support comes with prebaked
validation.
bool = f.checkValidity && f.checkValidity() ===
false;
} else {
bool = f.value != smile;
}
}
inputs[ props[i] ] = !!bool;
}
return inputs;
})('search tel url email datetime date month week time
datetime-local number range color'.split(' '));
}
// end of test definitions
// Run through all tests and detect their support in the current
UA.
// todo: hypothetically we could be doing an array of tests
and use a basic loop here.
for ( var feature in tests ) {
if ( hasOwnProperty( tests, feature ) ) {
// run the test, throw the return value into the
Modernizr,
// then based on that boolean, define an appropriate
className
// and push it into an array of classes we'll join later.
classes.push( ( ( ret[ feature.toLowerCase() ] = tests[
feature ]() ) ? '' : 'no-' ) + feature.toLowerCase() );
}
}
// input tests need to run.
if (!ret[input]) webforms();
/**
* Addtest allows the user to define their own feature tests
* the result will be added onto the Modernizr object,
* as well as an appropriate className set on the html
element
*
* @param feature - String naming the feature
* @param test - Function returning true if feature is
supported, false if not
*/
ret.addTest = function (feature, test) {
feature = feature.toLowerCase();
if (ret[ feature ]) {
return; // quit if you're trying to overwrite an existing test
}
test = !!(test());
docElement.className += ' ' + (test ? '' : 'no-') + feature;
ret[ feature ] = test;
return ret; // allow chaining.
};
/**
* Reset m.style.cssText to nothing to reduce memory
footprint.
*/
set_css( '' );
m = f = null;
// Enable HTML 5 elements for styling in IE.
// fyi: jscript version does not reflect trident version
// therefore ie9 in ie7 mode will still have a jScript v.9
if ( enableHTML5 && (function(){ var elem =
doc.createElement("div");
elem.innerHTML = "<elem></elem>";
return elem.childNodes.length !== 1;
})()) {
// iepp v1.5.1 MIT @jon_neal
http://code.google.com/p/ie-print-protector/
(function(p,e){function
q(a,b){if(g[a])g[a].styleSheet.cssText+=b;else{var
c=r[l],d=e[j]("style");d.media=a;c.insertBefore(d,c[l]);g[a]=d;q(
a,b)}}function s(a,b){for(var c=new
RegExp("b("+m+")b(?!.*[;}])","gi"),d=function(k){return".ie
pp_"+k},h=-
1;++h<a.length;){b=a[h].media||b;s(a[h].imports,b);q(b,a[h].css
Text.replace(c,d))}}function t(){for(var
a,b=e.getElementsByTagName("*"),c,d,h=new
RegExp("^"+m+"$","i"),k=-
1;++k<b.length;)if((a=b[k])&&(d=a.nodeName.match(h))){c=ne
w
RegExp("^s*<"+d+"(.*)/"+d+">s*$","i");i.innerHTML=a.o
uterHTML.replace(/r|n/g,"
").replace(c,a.currentStyle.display=="block"?"<div$1/div>":"<s
pan$1/span>");c=i.childNodes[0];c.className+="
iepp_"+d;c=f[f.length]=[a,c];a.parentNode.replaceChild(c[1],c[
0])}s(e.styleSheets,"all")}function u(){for(var a=-
1,b;++a<f.length;)f[a][1].parentNode.replaceChild(f[a][0],f[a][1
]);for(b in g)r[l].removeChild(g[b]);g={};f=[]}for(var
r=e.documentElement,i=e.createDocumentFragment(),g={},m="
abbr|article|aside|audio|canvas|command|datalist|details|figure|fi
gcaption|footer|header|hgroup|keygen|mark|meter|nav|output|pro
gress|section|source|summary|time|video",n=m.split("|"),f=[],o=
-
1,l="firstChild",j="createElement";++o<n.length;){e[j](n[o]);i[j
](n[o])}i=i.appendChild(e[j]("div"));p.attachEvent("onbeforepri
nt",t);p.attachEvent("onafterprint",u)})(this,doc);
}
// Assign private properties to the return object with prefix
ret._enableHTML5 = enableHTML5;
ret._version = version;
// Remove "no-js" class from <html> element, if it exists:
docElement.className=docElement.className.replace(/bno-
jsb/,'') + ' js';
// Add the new classes to the <html> element.
docElement.className += ' ' + classes.join( ' ' );
return ret;
})(this,this.document);

More Related Content

Similar to modernizr-1.5.js! Modernizr JavaScript library 1.5 .docx

BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
mwbrooks
 
Third party attributions-click-to-call
Third party attributions-click-to-callThird party attributions-click-to-call
Third party attributions-click-to-call
Rositadianamanullang
 
follow theses instructions and work on the page Chapter07pr.pdf
follow theses instructions and work on the page Chapter07pr.pdffollow theses instructions and work on the page Chapter07pr.pdf
follow theses instructions and work on the page Chapter07pr.pdf
rchopra4
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
Jan Rybák Benetka
 
Couch db 浅漫游.
Couch db 浅漫游.Couch db 浅漫游.
Couch db 浅漫游.
shyboyzk
 
RegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docx
RegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docxRegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docx
RegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docx
sodhi3
 

Similar to modernizr-1.5.js! Modernizr JavaScript library 1.5 .docx (20)

Hello worldswing.java
Hello worldswing.javaHello worldswing.java
Hello worldswing.java
 
Introduction to Aspect Oriented Software Development
Introduction to Aspect Oriented Software DevelopmentIntroduction to Aspect Oriented Software Development
Introduction to Aspect Oriented Software Development
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Readme
ReadmeReadme
Readme
 
Third party attributions-click-to-call
Third party attributions-click-to-callThird party attributions-click-to-call
Third party attributions-click-to-call
 
CSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdfCSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdf
 
C# and Borland StarTeam Connectivity
C# and Borland StarTeam ConnectivityC# and Borland StarTeam Connectivity
C# and Borland StarTeam Connectivity
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
 
How do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and ClientHow do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and Client
 
follow theses instructions and work on the page Chapter07pr.pdf
follow theses instructions and work on the page Chapter07pr.pdffollow theses instructions and work on the page Chapter07pr.pdf
follow theses instructions and work on the page Chapter07pr.pdf
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
 
IIIF without an image server? No problem!
IIIF without an image server? No problem!IIIF without an image server? No problem!
IIIF without an image server? No problem!
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
 
SlideShare API ''Get Slideshow Information'' method example with Groovy
SlideShare API ''Get Slideshow Information'' method example with GroovySlideShare API ''Get Slideshow Information'' method example with Groovy
SlideShare API ''Get Slideshow Information'' method example with Groovy
 
Couch db 浅漫游.
Couch db 浅漫游.Couch db 浅漫游.
Couch db 浅漫游.
 
Treatment, Architecture and Threads
Treatment, Architecture and ThreadsTreatment, Architecture and Threads
Treatment, Architecture and Threads
 
Web automation with #d8rules (European Drupal Days 2015)
Web automation with #d8rules (European Drupal Days 2015)Web automation with #d8rules (European Drupal Days 2015)
Web automation with #d8rules (European Drupal Days 2015)
 
Rm09a fin
Rm09a finRm09a fin
Rm09a fin
 
RegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docx
RegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docxRegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docx
RegistrationForm.DS_Store__MACOSXRegistrationForm._.DS_St.docx
 

More from raju957290

(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx
(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx
(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx
raju957290
 
(Links to an external site.) (Links to an external site.) (Links.docx
(Links to an external site.) (Links to an external site.) (Links.docx(Links to an external site.) (Links to an external site.) (Links.docx
(Links to an external site.) (Links to an external site.) (Links.docx
raju957290
 
(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx
(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx
(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx
raju957290
 
(Sample) Safety and Health Training Plan 1.0 Intro.docx
(Sample)  Safety and Health Training Plan  1.0 Intro.docx(Sample)  Safety and Health Training Plan  1.0 Intro.docx
(Sample) Safety and Health Training Plan 1.0 Intro.docx
raju957290
 
(SLIDES)Rohingya People Living Conditions---(Housing) and .docx
(SLIDES)Rohingya People  Living Conditions---(Housing) and .docx(SLIDES)Rohingya People  Living Conditions---(Housing) and .docx
(SLIDES)Rohingya People Living Conditions---(Housing) and .docx
raju957290
 
(Need in 8 hours 100 plagiarism free) Read the following es.docx
(Need in 8 hours 100 plagiarism free) Read the following es.docx(Need in 8 hours 100 plagiarism free) Read the following es.docx
(Need in 8 hours 100 plagiarism free) Read the following es.docx
raju957290
 
(please scroll all the way to bottom to see info covered in u3-4.docx
(please scroll all the way to bottom to see info covered in u3-4.docx(please scroll all the way to bottom to see info covered in u3-4.docx
(please scroll all the way to bottom to see info covered in u3-4.docx
raju957290
 
(Insert Student Name) (Insert Student Number) - PPMP20011 Portfo.docx
(Insert Student Name)  (Insert Student Number) - PPMP20011 Portfo.docx(Insert Student Name)  (Insert Student Number) - PPMP20011 Portfo.docx
(Insert Student Name) (Insert Student Number) - PPMP20011 Portfo.docx
raju957290
 
(Just I need APA format and simple Paragraph for each question a.docx
(Just I need APA format and simple Paragraph for each question a.docx(Just I need APA format and simple Paragraph for each question a.docx
(Just I need APA format and simple Paragraph for each question a.docx
raju957290
 

More from raju957290 (20)

(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx
(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx
(Need in 2 hours) 100 plagiarism freeIn our society as we deal .docx
 
(Minimum of 250 words with  peer review reference ) I am a nurse.docx
(Minimum of 250 words with  peer review reference ) I am a nurse.docx(Minimum of 250 words with  peer review reference ) I am a nurse.docx
(Minimum of 250 words with  peer review reference ) I am a nurse.docx
 
(minimum of 250 words with peer review reference)  Topic 8 DQ 1.docx
(minimum of 250 words with peer review reference)  Topic 8 DQ 1.docx(minimum of 250 words with peer review reference)  Topic 8 DQ 1.docx
(minimum of 250 words with peer review reference)  Topic 8 DQ 1.docx
 
(Links to an external site.) (Links to an external site.) (Links.docx
(Links to an external site.) (Links to an external site.) (Links.docx(Links to an external site.) (Links to an external site.) (Links.docx
(Links to an external site.) (Links to an external site.) (Links.docx
 
(Need in 5 hours no essay short answer 100 plagiarism free)De.docx
(Need in 5 hours no essay short answer 100 plagiarism free)De.docx(Need in 5 hours no essay short answer 100 plagiarism free)De.docx
(Need in 5 hours no essay short answer 100 plagiarism free)De.docx
 
(minimum of 250 words with peer review reference) What t.docx
(minimum of 250 words with peer review reference) What t.docx(minimum of 250 words with peer review reference) What t.docx
(minimum of 250 words with peer review reference) What t.docx
 
(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx
(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx
(Page 132) G. Prewriting Using the Toulmin Model to Get Ideas for.docx
 
(Normal Curves, 2013)In the video, Normal Curves,  there is .docx
(Normal Curves, 2013)In the video, Normal Curves,  there is .docx(Normal Curves, 2013)In the video, Normal Curves,  there is .docx
(Normal Curves, 2013)In the video, Normal Curves,  there is .docx
 
(minimum of 250 words with peer review reference) Review HIPAA.docx
(minimum of 250 words with peer review reference) Review HIPAA.docx(minimum of 250 words with peer review reference) Review HIPAA.docx
(minimum of 250 words with peer review reference) Review HIPAA.docx
 
(minimum of 250 words with peer review reference)Topic 8 DQ .docx
(minimum of 250 words with peer review reference)Topic 8 DQ .docx(minimum of 250 words with peer review reference)Topic 8 DQ .docx
(minimum of 250 words with peer review reference)Topic 8 DQ .docx
 
(minimum of 250 words with peer review reference)Topic 7 D.docx
(minimum of 250 words with peer review reference)Topic 7 D.docx(minimum of 250 words with peer review reference)Topic 7 D.docx
(minimum of 250 words with peer review reference)Topic 7 D.docx
 
(Sample) Safety and Health Training Plan 1.0 Intro.docx
(Sample)  Safety and Health Training Plan  1.0 Intro.docx(Sample)  Safety and Health Training Plan  1.0 Intro.docx
(Sample) Safety and Health Training Plan 1.0 Intro.docx
 
(SLIDES)Rohingya People Living Conditions---(Housing) and .docx
(SLIDES)Rohingya People  Living Conditions---(Housing) and .docx(SLIDES)Rohingya People  Living Conditions---(Housing) and .docx
(SLIDES)Rohingya People Living Conditions---(Housing) and .docx
 
(Need in 8 hours 100 plagiarism free) Read the following es.docx
(Need in 8 hours 100 plagiarism free) Read the following es.docx(Need in 8 hours 100 plagiarism free) Read the following es.docx
(Need in 8 hours 100 plagiarism free) Read the following es.docx
 
(note  I am a nurse working in a hospital) Develop a synopsis.docx
(note  I am a nurse working in a hospital) Develop a synopsis.docx(note  I am a nurse working in a hospital) Develop a synopsis.docx
(note  I am a nurse working in a hospital) Develop a synopsis.docx
 
(minimum of 250 words with peer review reference) Topic 8 DQ 2.docx
(minimum of 250 words with peer review reference) Topic 8 DQ 2.docx(minimum of 250 words with peer review reference) Topic 8 DQ 2.docx
(minimum of 250 words with peer review reference) Topic 8 DQ 2.docx
 
(See detail instruction in the attachment)This is a music pape.docx
(See detail instruction in the attachment)This is a music pape.docx(See detail instruction in the attachment)This is a music pape.docx
(See detail instruction in the attachment)This is a music pape.docx
 
(please scroll all the way to bottom to see info covered in u3-4.docx
(please scroll all the way to bottom to see info covered in u3-4.docx(please scroll all the way to bottom to see info covered in u3-4.docx
(please scroll all the way to bottom to see info covered in u3-4.docx
 
(Insert Student Name) (Insert Student Number) - PPMP20011 Portfo.docx
(Insert Student Name)  (Insert Student Number) - PPMP20011 Portfo.docx(Insert Student Name)  (Insert Student Number) - PPMP20011 Portfo.docx
(Insert Student Name) (Insert Student Number) - PPMP20011 Portfo.docx
 
(Just I need APA format and simple Paragraph for each question a.docx
(Just I need APA format and simple Paragraph for each question a.docx(Just I need APA format and simple Paragraph for each question a.docx
(Just I need APA format and simple Paragraph for each question a.docx
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 

modernizr-1.5.js! Modernizr JavaScript library 1.5 .docx

  • 1. modernizr-1.5.js /*! * Modernizr JavaScript library 1.5 * http://www.modernizr.com/ * * Copyright (c) 2009-2010 Faruk Ates - http://farukat.es/ * Dual-licensed under the BSD and MIT licenses. * http://www.modernizr.com/license/ * * Featuring major contributions by * Paul Irish - http://paulirish.com */ /* * LicenseModernizr is available under the MIT and BSD licenses: * MIT License
  • 2. * Copyright (c) 2009–2010 Faruk Ate? * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND
  • 3. NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * BSD License * Copyright (c) 2010, Faruk Ate? * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright
  • 4. * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Organization nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  • 5. INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Modernizr is a script that will detect native CSS3 and HTML5 features * available in the current UA and provide an object containing all * features with a true/false value, depending on whether the UA has * native support for it or not. * * In addition to that, Modernizr will add classes to the <html> * element of the page, one for each cutting-edge feature. If the UA * supports it, a class like "cssgradients" will be added. If not,
  • 6. * the class name will be "no-cssgradients". This allows for simple * if-conditionals in CSS styling, making it easily to have fine * control over the look and feel of your website. * * @author Faruk Ates * @copyright (c) 2009-2010 Faruk Ates. * * @contributor Paul Irish * @contributor Ben Alman */ window.Modernizr = (function(window,doc,undefined){ var version = '1.5', ret = {},
  • 7. /** * enableHTML5 is a private property for advanced use only. If enabled, * it will make Modernizr.init() run through a brief while() loop in * which it will create all HTML5 elements in the DOM to allow for * styling them in Internet Explorer, which does not recognize any * non-HTML4 elements unless created in the DOM this way. * * enableHTML5 is ON by default. */ enableHTML5 = true, /** * fontfaceCheckDelay is the ms delay before the @font-face test is * checked a second time. This is neccessary because both Gecko and
  • 8. * WebKit do not load data: URI font data synchronously. * https://bugzilla.mozilla.org/show_bug.cgi?id=512566 * The check will be done again at fontfaceCheckDelay*2 and then * a fourth time at window's load event. * If you need to query for @font-face support, send a callback to: * Modernizr._fontfaceready(fn); * The callback is passed the boolean value of Modernizr.fontface */ fontfaceCheckDelay = 75, docElement = doc.documentElement, /** * Create our "modernizr" element that we do most feature tests on. */
  • 9. mod = 'modernizr', m = doc.createElement( mod ), m_style = m.style, /** * Create the input element for various Web Forms feature tests. */ f = doc.createElement( 'input' ), // Reused strings, stored here to allow better minification canvas = 'canvas', canvastext = 'canvastext', rgba = 'rgba', hsla = 'hsla', multiplebgs = 'multiplebgs', backgroundsize = 'backgroundsize', borderimage = 'borderimage',
  • 10. borderradius = 'borderradius', boxshadow = 'boxshadow', opacity = 'opacity', cssanimations = 'cssanimations', csscolumns = 'csscolumns', cssgradients = 'cssgradients', cssreflections = 'cssreflections', csstransforms = 'csstransforms', csstransforms3d = 'csstransforms3d', csstransitions = 'csstransitions', fontface = 'fontface', geolocation = 'geolocation', video = 'video', audio = 'audio', input = 'input', inputtypes = input + 'types', // inputtypes is an object of its own containing individual tests for
  • 11. // various new input types, such as search, range, datetime, etc. svg = 'svg', smil = 'smil', svgclippaths = svg+'clippaths', background = 'background', backgroundColor = background + 'Color', canPlayType = 'canPlayType', // FF gets really angry if you name local variables as these, but camelCased. localstorage = 'localStorage', sessionstorage = 'sessionStorage', applicationcache = 'applicationCache', webWorkers = 'webworkers', hashchange = 'hashchange',
  • 12. crosswindowmessaging = 'crosswindowmessaging', historymanagement = 'historymanagement', draganddrop = 'draganddrop', websqldatabase = 'websqldatabase', indexedDB = 'indexedDB', websockets = 'websockets', smile = ':)', // IE7 gets mad if you name a local variable `toString` tostring = Object.prototype.toString, // list of property values to set for css tests. see ticket #21 prefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '), tests = {}, inputs = {}, attrs = {},
  • 13. classes = [], /** * isEventSupported determines if a given element supports the given event * function from http://yura.thinkweb2.com/isEventSupported/ */ isEventSupported = (function(){ var TAGNAMES = { 'select':'input','change':'input', 'submit':'form','reset':'form', 'error':'img','load':'img','abort':'img' }, cache = { }; function isEventSupported(eventName, element) { var canCache = (arguments.length == 1);
  • 14. // only return cached result when no element is given if (canCache && cache[eventName]) { return cache[eventName]; } element = element || document.createElement(TAGNAMES[eventName] || 'div'); eventName = 'on' + eventName; // When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize" // `in` "catches" those var isSupported = (eventName in element); if (!isSupported && element.setAttribute) { element.setAttribute(eventName, 'return;'); isSupported = typeof element[eventName] == 'function'; }
  • 15. element = null; return canCache ? (cache[eventName] = isSupported) : isSupported; } return isEventSupported; })(); var _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty; if (typeof _hasOwnProperty !== 'undefined' && typeof _hasOwnProperty.call !== 'undefined') { hasOwnProperty = function (object, property) { return _hasOwnProperty.call(object, property); }; } else {
  • 16. hasOwnProperty = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */ return ((property in object) && typeof object.constructor.prototype[property] === 'undefined'); }; } /** * set_css applies given styles to the Modernizr DOM node. */ function set_css( str ) { m_style.cssText = str; } /** * set_css_all extrapolates all vendor-specific css strings. */ function set_css_all( str1, str2 ) { return set_css(prefixes.join(str1 + ';') + ( str2 || '' ));
  • 17. } /** * contains returns a boolean for if substr is found within str. */ function contains( str, substr ) { return (''+str).indexOf( substr ) !== -1; } /** * test_props is a generic CSS / DOM property test; if a browser supports * a certain property, it won't return undefined for it. * A supported CSS property returns empty string when its not yet set. */ function test_props( props, callback ) { for ( var i in props ) { if ( m_style[ props[i] ] !== undefined && ( !callback ||
  • 18. callback( props[i], m ) ) ) { return true; } } } /** * test_props_all tests a list of DOM properties we want to check against. * We specify literally ALL possible (known and/or likely) properties on * the element including the non-vendor prefixed one, for forward- * compatibility. */ function test_props_all( prop, callback ) { var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1), // following spec is to expose vendor-specific style properties as:
  • 19. // elem.style.WebkitBorderRadius // and the following would be incorrect: // elem.style.webkitBorderRadius // Webkit and Mozilla are nice enough to ghost their properties in the lowercase // version but Opera does not. // see more here: http://github.com/Modernizr/Modernizr/issues/issue/21 props = [ prop, 'Webkit' + uc_prop, 'Moz' + uc_prop, 'O' + uc_prop, 'ms' + uc_prop, 'Khtml' + uc_prop ]; return !!test_props( props, callback );
  • 20. } /** * Tests */ tests[canvas] = function() { return !!doc.createElement( canvas ).getContext; }; tests[canvastext] = function() { return !!(tests[canvas]() && typeof doc.createElement( canvas ).getContext('2d').fillText == 'function'); }; /** * The Modernizr.touch test only indicates if the browser supports
  • 21. * touch events, which does not necessarily reflect a touchscreen * device, as evidenced by tablets running Windows 7 or, alas, * the Palm Pre / WebOS (touch) phones. * Additionally, chrome used to lie about its support on this, but that * has since been recitifed: http://crbug.com/36415 * Because there is no way to reliably detect Chrome's false positive * without UA sniffing we have removed this test from Modernizr. We * hope to add it in after Chrome 5 has been sunsetted. * See also http://github.com/Modernizr/Modernizr/issues#issue/84 tests[touch] = function() { return !!('ontouchstart' in window); };
  • 22. */ /** * geolocation tests for the new Geolocation API specification. * This test is a standards compliant-only test; for more complete * testing, including a Google Gears fallback, please see: * http://code.google.com/p/geo-location-javascript/ * or view a fallback solution using google's geo API: * http://gist.github.com/366184 */ tests[geolocation] = function() { return !!navigator.geolocation; }; tests[crosswindowmessaging] = function() { return !!window.postMessage; };
  • 23. tests[websqldatabase] = function() { var result = !!window.openDatabase; if (result){ try { result = !!openDatabase("testdb", "1.0", "html5 test db", 200000); } catch(err) { result = false; } } return result; }; tests[indexedDB] = function(){ return !!window[indexedDB]; };
  • 24. // documentMode logic from YUI to filter out IE8 Compat Mode // which false positives. tests[hashchange] = function() { return isEventSupported(hashchange, window) && ( document.documentMode === undefined || document.documentMode > 7 ); }; tests[historymanagement] = function() { return !!(window.history && history.pushState); }; tests[draganddrop] = function() { return isEventSupported('drag') && isEventSupported('dragstart') && isEventSupported('dragenter') && isEventSupported('dragover') && isEventSupported('dragleave') && isEventSupported('dragend')
  • 25. && isEventSupported('drop'); }; tests[websockets] = function(){ return ('WebSocket' in window); }; // http://css-tricks.com/rgba-browser-support/ tests[rgba] = function() { // Set an rgba() color and check the returned value set_css( background + '-color:rgba(150,255,150,.5)' ); return contains( m_style[backgroundColor], rgba ); };
  • 26. tests[hsla] = function() { // Same as rgba(), in fact, browsers re-map hsla() to rgba() internally set_css( background + '-color:hsla(120,40%,100%,.5)' ); return contains( m_style[backgroundColor], rgba ); }; tests[multiplebgs] = function() { // Setting multiple images AND a color on the background shorthand property // and then querying the style.background property value for the number of // occurrences of "url(" is a reliable method for detecting ACTUAL support for this! set_css( background + ':url(//:),url(//:),red url(//:)' ); // If the UA supports multiple backgrounds, there should
  • 27. be three occurrences // of the string "url(" in the return value for elem_style.background return new RegExp("(urls*(.*?){3}").test(m_style[background]); }; // In testing support for a given CSS property, it's legit to test: // elem.style[styleName] !== undefined // If the property is supported it will return an empty string, // if unsupported it will return undefined. // We'll take advantage of this quick test and skip setting a style // on our modernizr element, but instead just testing undefined vs // empty string. // The legacy set_css_all calls will remain in the source // (however, commented) in for clarity, yet functionally they
  • 28. are // no longer needed. tests[backgroundsize] = function() { return test_props_all( background + 'Size' ); }; tests[borderimage] = function() { // set_css_all( 'border-image:url(m.png) 1 1 stretch' ); return test_props_all( 'borderImage' ); }; // super comprehensive table about all the unique implementations of // border-radius: http://muddledramblings.com/table-of-css3- border-radius-compliance
  • 29. tests[borderradius] = function() { // set_css_all( 'border-radius:10px' ); return test_props_all( 'borderRadius', '', function( prop ) { return contains( prop, 'orderRadius' ); }); }; tests[boxshadow] = function() { // set_css_all( 'box-shadow:#000 1px 1px 3px' ); return test_props_all( 'boxShadow' ); }; tests[opacity] = function() { // Browsers that actually have CSS Opacity implemented have done so // according to spec, which means their return values are within the
  • 30. // range of [0.0,1.0] - including the leading zero. set_css_all( 'opacity:.5' ); return contains( m_style[opacity], '0.5' ); }; tests[cssanimations] = function() { // set_css_all( 'animation:"animate" 2s ease 2', 'position:relative' ); return test_props_all( 'animationName' ); }; tests[csscolumns] = function() { // set_css_all( 'column-count:3' ); return test_props_all( 'columnCount' ); };
  • 31. tests[cssgradients] = function() { /** * For CSS Gradients syntax, please see: * http://webkit.org/blog/175/introducing-css-gradients/ * https://developer.mozilla.org/en/CSS/-moz-linear- gradient * https://developer.mozilla.org/en/CSS/-moz-radial- gradient * http://dev.w3.org/csswg/css3-images/#gradients- */ var str1 = background + '-image:', str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));', str3 = 'linear-gradient(left top,#9f9, white);'; set_css(
  • 32. (str1 + prefixes.join(str2 + str1) + prefixes.join(str3 + str1)).slice(0,-str1.length) ); return contains( m_style.backgroundImage, 'gradient' ); }; tests[cssreflections] = function() { // set_css_all( 'box-reflect:right 1px' ); return test_props_all( 'boxReflect' ); }; tests[csstransforms] = function() { // set_css_all( 'transform:rotate(3deg)' ); return !!test_props([ 'transformProperty', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform' ]); };
  • 33. tests[csstransforms3d] = function() { // set_css_all( 'perspective:500' ); var ret = !!test_props([ 'perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective' ]); // webkit has 3d transforms disabled for chrome, though // it works fine in safari on leopard and snow leopard // as a result, it 'recognizes' the syntax and throws a false positive // thus we must do a more thorough check: if (ret){ var st = document.createElement('style'), div = doc.createElement('div'); // webkit allows this media query to succeed only if the feature is enabled.
  • 34. // "@media (transform-3d),(-o-transform-3d),(-moz- transform-3d),(-ms-transform-3d),(-webkit-transform- 3d),(modernizr){#modernizr{height:3px}}" st.textContent = '@media ('+prefixes.join('transform- 3d),(')+'modernizr){#modernizr{height:3px}}'; doc.getElementsByTagName('head')[0].appendChild(st); div.id = 'modernizr'; docElement.appendChild(div); ret = div.offsetHeight === 3; st.parentNode.removeChild(st); div.parentNode.removeChild(div); } return ret; }; tests[csstransitions] = function() {
  • 35. // set_css_all( 'transition:all .5s linear' ); return test_props_all( 'transitionProperty' ); }; // @font-face detection routine created by Paul Irish - paulirish.com // Merged into Modernizr with approval. Read more about Paul's work here: // http://paulirish.com/2009/font-face-feature-detection/ tests[fontface] = function(){ var fontret; if (/*@[email protected](@_jscript_version>=5)[email protected] @*/0) fontret = true; else { // Create variables for dedicated @font-face test
  • 36. var st = doc.createElement('style'), spn = doc.createElement('span'), size, isFakeBody = false, body = doc.body, callback, isCallbackCalled; // The following is a font-face + glyph definition for the . character: st.textContent = "@font-face{font- family:testfont;src:url('data:font/ttf;base64,AAEAAAAMAIAA AwBAT1MvMliohmwAAADMAAAAVmNtYXCp5qrBAAABJA AAANhjdnQgACICiAAAAfwAAAAEZ2FzcP//AAMAAAIAAA AACGdseWYv5OZoAAACCAAAANxoZWFk69bnvwAAAuQA AAA2aGhlYQUJAt8AAAMcAAAAJGhtdHgGDgC4AAADQAA AABRsb2NhAIQAwgAAA1QAAAAMbWF4cABVANgAAANg AAAAIG5hbWUgXduAAAADgAAABPVwb3N03NkzmgAACH gAAAA4AAECBAEsAAUAAAKZAswAAACPApkCzAAAAesA MwEJAAACAAMDAAAAAAAAgAACbwAAAAoAAAAAAAA AAFBmRWQAAAAgqS8DM/8zAFwDMwDNAAAABQAAAAA AAAAAAAMAAAADAAAAHAABAAAAAABGAAMAAQAA AK4ABAAqAAAABgAEAAEAAgAuqQD//wAAAC6pAP///9ZX AwAAAAAAAAACAAAABgBoAAAAAAAvAAEAAAAAAAA AAAAAAAAAAAABAAIAAAAAAAAAAgAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB AAEACoAAAAGAAQAAQACAC6pAP//AAAALqkA////1lcDA AAAAAAAAAIAAAAiAogAAAAB//8AAgACACIAAAEyAqoA AwAHAC6xAQAvPLIHBADtMrEGBdw8sgMCAO0yALEDAC8 8sgUEAO0ysgcGAfw8sgECAO0yMxEhESczESMiARDuzMwCq v1WIgJmAAACAFUAAAIRAc0ADwAfAAATFRQWOwEyNj0 BNCYrASIGARQGKwEiJj0BNDY7ATIWFX8aIvAiGhoi8CIaA
  • 37. ZIoN/43KCg3/jcoAWD0JB4eJPQkHh7++EY2NkbVRjY2RgAA AAABAEH/+QCdAEEACQAANjQ2MzIWFAYjIkEeEA8fHw8Q DxwWFhwWAAAAAQAAAAIAAIuYbWpfDzz1AAsEAAAAA ADFn9IuAAAAAMWf0i797/8zA4gDMwAAAAgAAgAAAAAA AAABAAADM/8zAFwDx/3v/98DiAABAAAAAAAAAAAAAA AAAAAABQF2ACIAAAAAAVUAAAJmAFUA3QBBAAAAKg AqACoAWgBuAAEAAAAFAFAABwBUAAQAAgAAAAEAAQ AAAEAALgADAAMAAAAQAMYAAQAAAAAAAACLAAAA AQAAAAAAAQAhAIsAAQAAAAAAAgAFAKwAAQAAAAA AAwBDALEAAQAAAAAABAAnAPQAAQAAAAAABQAKAR sAAQAAAAAABgAmASUAAQAAAAAADgAaAUsAAwABBA kAAAEWAWUAAwABBAkAAQBCAnsAAwABBAkAAgAKAr 0AAwABBAkAAwCGAscAAwABBAkABABOA00AAwABBAk ABQAUA5sAAwABBAkABgBMA68AAwABBAkADgA0A/tDb 3B5cmlnaHQgMjAwOSBieSBEYW5pZWwgSm9obnNvbi4gIFJl bGVhc2VkIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgT3BlbiBG b250IExpY2Vuc2UuIEtheWFoIExpIGdseXBocyBhcmUgcmVsZ WFzZWQgdW5kZXIgdGhlIEdQTCB2ZXJzaW9uIDMuYmFlYzJ hOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhTGlnaHRiYW VjMmE5MmJmZmU1MDMyIC0gc3Vic2V0IG9mIEZvbnRGb3Jn ZSAyLjAgOiBKdXJhIExpZ2h0IDogMjMtMS0yMDA5YmFlYzJ hOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhIExpZ2h0Vm Vyc2lvbiAyIGJhZWMyYTkyYmZmZTUwMzIgLSBzdWJzZXQg b2YgSnVyYUxpZ2h0aHR0cDovL3NjcmlwdHMuc2lsLm9yZy9P RkwAQwBvAHAAeQByAGkAZwBoAHQAIAAyADAAMAA5A CAAYgB5ACAARABhAG4AaQBlAGwAIABKAG8AaABuAH MAbwBuAC4AIAAgAFIAZQBsAGUAYQBzAGUAZAAgAHU AbgBkAGUAcgAgAHQAaABlACAAdABlAHIAbQBzACAAbw BmACAAdABoAGUAIABPAHAAZQBuACAARgBvAG4AdAA gAEwAaQBjAGUAbgBzAGUALgAgAEsAYQB5AGEAaAAgAE wAaQAgAGcAbAB5AHAAaABzACAAYQByAGUAIAByAGU AbABlAGEAcwBlAGQAIAB1AG4AZABlAHIAIAB0AGgAZQ AgAEcAUABMACAAdgBlAHIAcwBpAG8AbgAgADMALgBiA GEAZQBjADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyAC AALQAgAHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHI AYQBMAGkAZwBoAHQAYgBhAGUAYwAyAGEAOQAyAGI
  • 38. AZgBmAGUANQAwADMAMgAgAC0AIABzAHUAYgBzAGU AdAAgAG8AZgAgAEYAbwBuAHQARgBvAHIAZwBlACAAM gAuADAAIAA6ACAASgB1AHIAYQAgAEwAaQBnAGgAdAA gADoAIAAyADMALQAxAC0AMgAwADAAOQBiAGEAZQBj ADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyACAALQAg AHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHIAYQAgA EwAaQBnAGgAdABWAGUAcgBzAGkAbwBuACAAMgAgAGI AYQBlAGMAMgBhADkAMgBiAGYAZgBlADUAMAAzADIAI AAtACAAcwB1AGIAcwBlAHQAIABvAGYAIABKAHUAcgBh AEwAaQBnAGgAdABoAHQAdABwADoALwAvAHMAYwByA GkAcAB0AHMALgBzAGkAbAAuAG8AcgBnAC8ATwBGAEw AAAAAAgAAAAAAAP+BADMAAAAAAAAAAAAAAAAAA AAAAAAAAAAFAAAAAQACAQIAEQt6ZXJva2F5YWhsaQ== ')}"; doc.getElementsByTagName('head')[0].appendChild(st); // we don't use `serif` and we don't use `monospace` // http://github.com/Modernizr/Modernizr/issues/closed#issue/39 // http://neugierig.org/software/chromium/notes/2009/09/monospa ce-fonts-workaround.html spn.setAttribute('style','font:99px _,arial,helvetica;position:absolute;visibility:hidden'); if (!body){ body =
  • 39. docElement.appendChild(doc.createElement(fontface)); isFakeBody = true; } // the data-uri'd font only has the . glyph; which is 3 pixels wide. spn.innerHTML = '........'; spn.id = 'fonttest'; body.appendChild(spn); size = spn.offsetWidth*spn.offsetHeight; spn.style.font = '99px testfont,_,arial,helvetica'; // needed for the CSSFontFaceRule false positives (ff3, chrome, op9) fontret = size !== spn.offsetWidth*spn.offsetHeight; function delayedCheck(){ if (!body.parentNode) return;
  • 40. fontret = ret[fontface] = size !== spn.offsetWidth*spn.offsetHeight; docElement.className = docElement.className.replace(/(no-)?fontfaceb/,'') + (fontret ? ' ' : ' no-') + fontface; } setTimeout(delayedCheck,fontfaceCheckDelay); setTimeout(delayedCheck,fontfaceCheckDelay*2); addEventListener('load',function(){ delayedCheck(); (isCallbackCalled = true) && callback && callback(fontret); setTimeout(function(){ if (!isFakeBody) body = spn; body.parentNode.removeChild(body); st.parentNode.removeChild(st); }, 50); },false); }
  • 41. // allow for a callback ret._fontfaceready = function(fn){ (isCallbackCalled || fontret) ? fn(fontret) : (callback = fn); } return fontret || size !== spn.offsetWidth; }; // These tests evaluate support of the video/audio elements, as well as // testing what types of content they support. // // we're using the Boolean constructor here, so that we can extend the value // e.g. Modernizr.video // true // Modernizr.video.ogg // 'probably'
  • 42. // // codec values from : http://github.com/NielsLeenheer/html5test/blob/9106a8/index.ht ml#L845 // thx to NielsLeenheer and zcorpan tests[video] = function() { var elem = doc.createElement(video), bool = !!elem[canPlayType]; if (bool){ bool = new Boolean(bool); bool.ogg = elem[canPlayType]('video/ogg; codecs="theora"'); bool.h264 = elem[canPlayType]('video/mp4; codecs="avc1.42E01E"'); bool.webm = elem[canPlayType]('video/webm; codecs="vp8, vorbis"'); } return bool;
  • 43. }; tests[audio] = function() { var elem = doc.createElement(audio), bool = !!elem[canPlayType]; if (bool){ bool = new Boolean(bool); bool.ogg = elem[canPlayType]('audio/ogg; codecs="vorbis"'); bool.mp3 = elem[canPlayType]('audio/mpeg;'); // mimetypes accepted: // https://developer.mozilla.org/En/Media_formats_supported_by_ the_audio_and_video_elements // http://bit.ly/iphoneoscodecs bool.wav = elem[canPlayType]('audio/wav; codecs="1"'); bool.m4a = elem[canPlayType]('audio/x-m4a;') || elem[canPlayType]('audio/aac;');
  • 44. } return bool; }; // both localStorage and sessionStorage are // tested in this method because otherwise Firefox will // throw an error: https://bugzilla.mozilla.org/show_bug.cgi?id=365772 // if cookies are disabled // FWIW miller device resolves to [object Storage] in all supporting browsers // except for IE who does [object Object] // IE8 Compat mode supports these features completely: // http://www.quirksmode.org/dom/html5.html tests[localstorage] = function() {
  • 45. return ('localStorage' in window) && window[localstorage] !== null; }; tests[sessionstorage] = function() { // try/catch required for pissy FF behavior try { return ('sessionStorage' in window) && window[sessionstorage] !== null; } catch(e){ return false; } }; tests[webWorkers] = function () { return !!window.Worker; };
  • 46. tests[applicationcache] = function() { var cache = window[applicationcache]; return !!(cache && (typeof cache.status != 'undefined') && (typeof cache.update == 'function') && (typeof cache.swapCache == 'function')); }; // thanks to Erik Dahlstrom tests[svg] = function(){ return !!doc.createElementNS && !!doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect; }; // thanks to F1lt3r and lucideer // http://github.com/Modernizr/Modernizr/issues#issue/35 tests[smil] = function(){ return !!doc.createElementNS && /SVG/.test(tostring.call(doc.createElementNS('http://www.w3.or
  • 47. g/2000/svg','animate'))); }; tests[svgclippaths] = function(){ // returns a false positive in saf 3.2? return !!doc.createElementNS && /SVG/.test(tostring.call(doc.createElementNS('http://www.w3.or g/2000/svg','clipPath'))); }; // input features and input types go directly onto the ret object, bypassing the tests loop. // hold this guy to execute in a moment. function webforms(){ // Run through HTML5's new input attributes to see if the UA understands any. // We're using f which is the <input> element created early on // Mike Taylr has created a comprehensive resource for
  • 48. testing these attributes // when applied to all input types: // http://miketaylr.com/code/input-type-attr.html // spec: http://www.whatwg.org/specs/web-apps/current- work/multipage/the-input-element.html#input-type-attr- summary ret[input] = (function(props) { for (var i = 0,len=props.length;i<len;i++) { attrs[ props[i] ] = !!(props[i] in f); } return attrs; })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' ')); // Run through HTML5's new input types to see if the UA understands any. // This is put behind the tests runloop because it doesn't return a // true/false like all the other tests; instead, it returns an object // containing each input type with its corresponding true/false value
  • 49. // Big thx to @miketaylr for the html5 forms expertise. http://miketaylr.com/ ret[inputtypes] = (function(props) { for (var i = 0,bool,len=props.length;i<len;i++) { f.setAttribute('type', props[i]); bool = f.type !== 'text'; // chrome likes to falsely purport support, so we feed it a textual value // if that doesnt succeed then we know there's a custom UI if (bool){ f.value = smile; /* Safari 4 is allowing the smiley as a value, and incorrecty failing.. the test fixes for webkit only, but breaks Opera.. if (/range/.test(f.type)){
  • 50. bool = test_props_all('appearance',function(prop,m){ return m_style[prop] !== 'textfield' }) } */ if (/tel|search/.test(f.type)){ // spec doesnt define any special parsing or detectable UI // behaviors so we pass these through as true } else if (/url|email/.test(f.type)) { // real url and email support comes with prebaked validation. bool = f.checkValidity && f.checkValidity() === false; } else { bool = f.value != smile; }
  • 51. } inputs[ props[i] ] = !!bool; } return inputs; })('search tel url email datetime date month week time datetime-local number range color'.split(' ')); } // end of test definitions // Run through all tests and detect their support in the current UA. // todo: hypothetically we could be doing an array of tests and use a basic loop here. for ( var feature in tests ) {
  • 52. if ( hasOwnProperty( tests, feature ) ) { // run the test, throw the return value into the Modernizr, // then based on that boolean, define an appropriate className // and push it into an array of classes we'll join later. classes.push( ( ( ret[ feature.toLowerCase() ] = tests[ feature ]() ) ? '' : 'no-' ) + feature.toLowerCase() ); } } // input tests need to run. if (!ret[input]) webforms();
  • 53. /** * Addtest allows the user to define their own feature tests * the result will be added onto the Modernizr object, * as well as an appropriate className set on the html element * * @param feature - String naming the feature * @param test - Function returning true if feature is supported, false if not */ ret.addTest = function (feature, test) { feature = feature.toLowerCase(); if (ret[ feature ]) { return; // quit if you're trying to overwrite an existing test } test = !!(test()); docElement.className += ' ' + (test ? '' : 'no-') + feature; ret[ feature ] = test;
  • 54. return ret; // allow chaining. }; /** * Reset m.style.cssText to nothing to reduce memory footprint. */ set_css( '' ); m = f = null; // Enable HTML 5 elements for styling in IE. // fyi: jscript version does not reflect trident version // therefore ie9 in ie7 mode will still have a jScript v.9 if ( enableHTML5 && (function(){ var elem = doc.createElement("div"); elem.innerHTML = "<elem></elem>"; return elem.childNodes.length !== 1; })()) { // iepp v1.5.1 MIT @jon_neal http://code.google.com/p/ie-print-protector/
  • 55. (function(p,e){function q(a,b){if(g[a])g[a].styleSheet.cssText+=b;else{var c=r[l],d=e[j]("style");d.media=a;c.insertBefore(d,c[l]);g[a]=d;q( a,b)}}function s(a,b){for(var c=new RegExp("b("+m+")b(?!.*[;}])","gi"),d=function(k){return".ie pp_"+k},h=- 1;++h<a.length;){b=a[h].media||b;s(a[h].imports,b);q(b,a[h].css Text.replace(c,d))}}function t(){for(var a,b=e.getElementsByTagName("*"),c,d,h=new RegExp("^"+m+"$","i"),k=- 1;++k<b.length;)if((a=b[k])&&(d=a.nodeName.match(h))){c=ne w RegExp("^s*<"+d+"(.*)/"+d+">s*$","i");i.innerHTML=a.o uterHTML.replace(/r|n/g," ").replace(c,a.currentStyle.display=="block"?"<div$1/div>":"<s pan$1/span>");c=i.childNodes[0];c.className+=" iepp_"+d;c=f[f.length]=[a,c];a.parentNode.replaceChild(c[1],c[ 0])}s(e.styleSheets,"all")}function u(){for(var a=- 1,b;++a<f.length;)f[a][1].parentNode.replaceChild(f[a][0],f[a][1 ]);for(b in g)r[l].removeChild(g[b]);g={};f=[]}for(var r=e.documentElement,i=e.createDocumentFragment(),g={},m=" abbr|article|aside|audio|canvas|command|datalist|details|figure|fi gcaption|footer|header|hgroup|keygen|mark|meter|nav|output|pro gress|section|source|summary|time|video",n=m.split("|"),f=[],o= - 1,l="firstChild",j="createElement";++o<n.length;){e[j](n[o]);i[j ](n[o])}i=i.appendChild(e[j]("div"));p.attachEvent("onbeforepri nt",t);p.attachEvent("onafterprint",u)})(this,doc); } // Assign private properties to the return object with prefix ret._enableHTML5 = enableHTML5;
  • 56. ret._version = version; // Remove "no-js" class from <html> element, if it exists: docElement.className=docElement.className.replace(/bno- jsb/,'') + ' js'; // Add the new classes to the <html> element. docElement.className += ' ' + classes.join( ' ' ); return ret; })(this,this.document);