Skip to content

Commit

Permalink
Merge branch 'grunt' of https://github.com/sindresorhus/Modernizr int…
Browse files Browse the repository at this point in the history
…o sindresorhus-grunt

* 'grunt' of https://github.com/sindresorhus/Modernizr:
  Close GH-1: Match Modernizr's current style as close as possible!.
  Forgot to remove the old build script
  Add grunt

Conflicts:
	modernizr.js
  • Loading branch information
ryanseddon committed Jun 25, 2012
2 parents 928edb7 + b389d0b commit a16c9f7
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 89 deletions.
15 changes: 0 additions & 15 deletions compress.sh

This file was deleted.

2 changes: 1 addition & 1 deletion feature-detects/canvas-todataurl-type.js
Expand Up @@ -24,5 +24,5 @@
});
};

image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=='
image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==';
}());
2 changes: 1 addition & 1 deletion feature-detects/cors.js
@@ -1,3 +1,3 @@
// cors
// By Theodoor van Donge
Modernizr.addTest('cors', 'withCredentials' in new XMLHttpRequest);
Modernizr.addTest('cors', 'withCredentials' in new XMLHttpRequest());
2 changes: 1 addition & 1 deletion feature-detects/css-calc.js
Expand Up @@ -5,6 +5,6 @@ Modernizr.addTest('csscalc', function(el, prop, value) {
prop = 'width:';
value = 'calc(10px);';
el = document.createElement('div');
el.style.cssText = prop + Modernizr._prefixes.join(value + prop)
el.style.cssText = prop + Modernizr._prefixes.join(value + prop);
return !!el.style.length;
});
2 changes: 1 addition & 1 deletion feature-detects/css-cubicbezierrange.js
Expand Up @@ -2,7 +2,7 @@
// By @calvein

Modernizr.addTest('cubicbezierrange', function() {
el = document.createElement('div');
var el = document.createElement('div');
el.style.cssText = Modernizr._prefixes.join('transition-timing-function' + ':cubic-bezier(1,0,0,1.1); ');
return !!el.style.length;
});
36 changes: 18 additions & 18 deletions feature-detects/css-hyphens.js
@@ -1,15 +1,15 @@
/* see http://davidnewton.ca/the-current-state-of-hyphenation-on-the-web
http://davidnewton.ca/demos/hyphenation/test.html
/* see http://davidnewton.ca/the-current-state-of-hyphenation-on-the-web
http://davidnewton.ca/demos/hyphenation/test.html
There are three tests:
1. csshyphens - tests hyphens:auto actually adds hyphens to text
2. softhyphens - tests that ­ does its job
3. softhyphensfind - tests that in-browser Find functionality still works correctly with ­
1. csshyphens - tests hyphens:auto actually adds hyphens to text
2. softhyphens - tests that ­ does its job
3. softhyphensfind - tests that in-browser Find functionality still works correctly with ­
These tests currently require document.body to be present
These tests currently require document.body to be present
Hyphenation is language specific, sometimes.
Hyphenation is language specific, sometimes.
See for more details: http://code.google.com/p/hyphenator/source/diff?spec=svn975&r=975&format=side&path=/trunk/Hyphenator.js#sc_svn975_313
If loading Hyphenator.js via Modernizr.load, be cautious of issue 158: http://code.google.com/p/hyphenator/issues/detail?id=158
Expand All @@ -21,7 +21,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
(function() {

if (!document.body){
window.console && console.warn('document.body doesn\'t exist. Modernizr hyphens test needs it.')
window.console && console.warn('document.body doesn\'t exist. Modernizr hyphens test needs it.');
return;
}

Expand All @@ -37,21 +37,21 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
spanWidth = 0,
result = false,
firstChild = document.body.firstElementChild || document.body.firstChild;

div.appendChild(span);
span.innerHTML = 'Bacon ipsum dolor sit amet jerky velit in culpa hamburger et. Laborum dolor proident, enim dolore duis commodo et strip steak. Salami anim et, veniam consectetur dolore qui tenderloin jowl velit sirloin. Et ad culpa, fatback cillum jowl ball tip ham hock nulla short ribs pariatur aute. Pig pancetta ham bresaola, ut boudin nostrud commodo flank esse cow tongue culpa. Pork belly bresaola enim pig, ea consectetur nisi. Fugiat officia turkey, ea cow jowl pariatur ullamco proident do laborum velit sausage. Magna biltong sint tri-tip commodo sed bacon, esse proident aliquip. Ullamco ham sint fugiat, velit in enim sed mollit nulla cow ut adipisicing nostrud consectetur. Proident dolore beef ribs, laborum nostrud meatball ea laboris rump cupidatat labore culpa. Shankle minim beef, velit sint cupidatat fugiat tenderloin pig et ball tip. Ut cow fatback salami, bacon ball tip et in shank strip steak bresaola. In ut pork belly sed mollit tri-tip magna culpa veniam, short ribs qui in andouille ham consequat. Dolore bacon t-bone, velit short ribs enim strip steak nulla. Voluptate labore ut, biltong swine irure jerky. Cupidatat excepteur aliquip salami dolore. Ball tip strip steak in pork dolor. Ad in esse biltong. Dolore tenderloin exercitation ad pork loin t-bone, dolore in chicken ball tip qui pig. Ut culpa tongue, sint ribeye dolore ex shank voluptate hamburger. Jowl et tempor, boudin pork chop labore ham hock drumstick consectetur tri-tip elit swine meatball chicken ground round. Proident shankle mollit dolore. Shoulder ut duis t-bone quis reprehenderit. Meatloaf dolore minim strip steak, laboris ea aute bacon beef ribs elit shank in veniam drumstick qui. Ex laboris meatball cow tongue pork belly. Ea ball tip reprehenderit pig, sed fatback boudin dolore flank aliquip laboris eu quis. Beef ribs duis beef, cow corned beef adipisicing commodo nisi deserunt exercitation. Cillum dolor t-bone spare ribs, ham hock est sirloin. Brisket irure meatloaf in, boudin pork belly sirloin ball tip. Sirloin sint irure nisi nostrud aliqua. Nostrud nulla aute, enim officia culpa ham hock. Aliqua reprehenderit dolore sunt nostrud sausage, ea boudin pork loin ut t-bone ham tempor. Tri-tip et pancetta drumstick laborum. Ham hock magna do nostrud in proident. Ex ground round fatback, venison non ribeye in.';

document.body.insertBefore(div, firstChild);

/* get size of unhyphenated text */
divStyle.cssText = 'position:absolute;top:0;left:0;width:5em;text-align:justify;text-justification:newspaper;';
spanHeight = span.offsetHeight;
spanWidth = span.offsetWidth;

/* compare size with hyphenated text */
divStyle.cssText = 'position:absolute;top:0;left:0;width:5em;text-align:justify;'+
'text-justification:newspaper;'
+ Modernizr._prefixes.join('hyphens:auto; ');
'text-justification:newspaper;'+
Modernizr._prefixes.join('hyphens:auto; ');

result = (span.offsetHeight != spanHeight || span.offsetWidth != spanWidth);

Expand Down Expand Up @@ -82,8 +82,8 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
divStyle.cssText = 'position:absolute;top:0;left:0;overflow:visible;width:1.25em;';
div.appendChild(span);
document.body.insertBefore(div, firstChild);


/* get height of unwrapped text */
span.innerHTML = 'mm';
spanSize = span.offsetHeight;
Expand All @@ -110,7 +110,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
if (result1 === true && result2 === true) { result = true; }
document.body.removeChild(div);
div.removeChild(span);

return result;
} catch(e) {
return false;
Expand All @@ -136,7 +136,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
document.body.insertBefore(div, firstChild);
document.body.insertBefore(dummy, div);


/* reset the selection to the dummy input element, i.e. BEFORE the div container
* stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area */
if (dummy.setSelectionRange) {
Expand All @@ -155,7 +155,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
result = window.find(testword + testword);
} else {
try {
textrange = self.document.body.createTextRange();
textrange = window.self.document.body.createTextRange();
result = textrange.findText(testword + testword);
} catch(e) {
result = false;
Expand Down Expand Up @@ -188,7 +188,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
Modernizr.addTest("softhyphens", function() {
try {
// use numeric entity instead of ­ in case it's XHTML
return test_hyphens('­', true) && test_hyphens('​', false);
return test_hyphens('­', true) && test_hyphens('​', false);
} catch(e) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions feature-detects/css-remunit.js
@@ -1,7 +1,7 @@

// test by github.com/nsfmc

// "The 'rem' unit ('root em') is relative to the computed
// "The 'rem' unit ('root em') is relative to the computed
// value of the 'font-size' value of the root element."
// http://www.w3.org/TR/css3-values/#relative0
// you can test by checking if the prop was ditched
Expand All @@ -14,6 +14,6 @@ Modernizr.addTest('cssremunit', function(){
try {
div.style.fontSize = '3rem';
} catch(er){}
return /rem/.test(div.style.fontSize)
return (/rem/).test(div.style.fontSize);

});
12 changes: 6 additions & 6 deletions feature-detects/css-scrollbars.js
@@ -1,19 +1,19 @@
// Stylable scrollbars detection
Modernizr.addTest('cssscrollbar', function() {

var bool,
styles = "#modernizr{overflow: scroll; width: 40px }#" +
Modernizr._prefixes

styles = "#modernizr{overflow: scroll; width: 40px }#" +
Modernizr._prefixes
.join("scrollbar{width:0px}"+' #modernizr::')
.split('#')
.slice(1)
.join('#') + "scrollbar{width:0px}";

Modernizr.testStyles(styles, function(node) {
bool = 'scrollWidth' in node && node.scrollWidth == 40;
});

return bool;

});
4 changes: 2 additions & 2 deletions feature-detects/elem-progress-meter.js
Expand Up @@ -2,10 +2,10 @@

//tests for progressbar-support. All browsers that don't support progressbar returns undefined =)
Modernizr.addTest("progressbar",function(){
return document.createElement('progress').max != undefined;
return document.createElement('progress').max !== undefined;
});

//tests for meter-support. All browsers that don't support meters returns undefined =)
Modernizr.addTest("meter",function(){
return document.createElement('meter').max != undefined;
return document.createElement('meter').max !== undefined;
});
6 changes: 3 additions & 3 deletions feature-detects/elem-ruby.js
Expand Up @@ -17,10 +17,10 @@ Modernizr.addTest('ruby', function () {
docElement.appendChild(ruby);

// browsers that support <ruby> hide the <rp> via "display:none"
if ( getStyle(rp, displayStyleProperty) == 'none' // for non-IE browsers
if ( getStyle(rp, displayStyleProperty) == 'none' || // for non-IE browsers
// but in IE browsers <rp> has "display:inline" so, the test needs other conditions:
|| getStyle(ruby, displayStyleProperty) == 'ruby' && getStyle(rt, displayStyleProperty) == 'ruby-text' // for IE8 & IE9
|| getStyle(rp, fontSizeStyleProperty) == '6pt' && getStyle(rt, fontSizeStyleProperty) == '6pt' ) { // for IE6 & IE7
getStyle(ruby, displayStyleProperty) == 'ruby' && getStyle(rt, displayStyleProperty) == 'ruby-text' || // for IE8 & IE9
getStyle(rp, fontSizeStyleProperty) == '6pt' && getStyle(rt, fontSizeStyleProperty) == '6pt' ) { // for IE6 & IE7

cleanUp();
return true;
Expand Down
2 changes: 1 addition & 1 deletion feature-detects/emoji.js
Expand Up @@ -7,5 +7,5 @@ Modernizr.addTest('emoji', function() {
ctx.textBaseline = 'top';
ctx.font = '32px Arial';
ctx.fillText('\ud83d\ude03', 0, 0); // "smiling face with open mouth" emoji
return ctx.getImageData(16, 16, 1, 1).data[0] != 0;
return ctx.getImageData(16, 16, 1, 1).data[0] !== 0;
});
4 changes: 2 additions & 2 deletions feature-detects/event-deviceorientation-motion.js
@@ -1,5 +1,5 @@
//By Shi Chuan
//Part of Device Access aspect of HTML5, same category as geolocation
//By Shi Chuan
//Part of Device Access aspect of HTML5, same category as geolocation
//W3C Editor's Draft at http://dev.w3.org/geo/api/spec-source-orientation.html
//Implementation by iOS Safari at http://goo.gl/fhce3 and http://goo.gl/rLKz8

Expand Down
8 changes: 4 additions & 4 deletions feature-detects/network-connection.js
Expand Up @@ -13,10 +13,10 @@
// for more rigorous network testing, consider boomerang.js: github.com/bluesmoon/boomerang/

Modernizr.addTest('lowbandwidth', function() {

var connection = navigator.connection || { type: 0 }; // polyfill

return connection.type == 3 // connection.CELL_2G
|| connection.type == 4 // connection.CELL_3G
|| /^[23]g$/.test(connection.type); // string value in new spec
return connection.type == 3 || // connection.CELL_2G
connection.type == 4 || // connection.CELL_3G
/^[23]g$/.test(connection.type); // string value in new spec
});
14 changes: 7 additions & 7 deletions feature-detects/webgl-extensions.js
Expand Up @@ -12,8 +12,8 @@

var canvas, ctx, exts;

try {
canvas = document.createElement('canvas'),
try {
canvas = document.createElement('canvas');
ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
exts = ctx.getSupportedExtensions();
}
Expand All @@ -22,21 +22,21 @@
}

if (ctx === undefined) {
Modernizr.webgl = new Boolean(false);
Modernizr.webgl = new Boolean(false);
}
else {
Modernizr.webgl = new Boolean(true);
Modernizr.webgl = new Boolean(true);
}


for (var i = -1, len = exts.length; ++i < len; ){
Modernizr.webgl[exts[i]] = true;
Modernizr.webgl[exts[i]] = true;
}

// hack for addressing modernizr testsuite failures. sorry.
if (window.TEST && TEST.audvid){
TEST.audvid.push('webgl');
}

canvas = undefined;;
canvas = undefined;
})();
4 changes: 2 additions & 2 deletions feature-detects/workers-blobworkers.js
Expand Up @@ -9,7 +9,7 @@
try {

// we're avoiding using Modernizr._domPrefixes as the prefix capitalization on
// these guys are notoriously peculiar.
// these guys are notoriously peculiar.
var BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.MSBlobBuilder || window.OBlobBuilder || window.BlobBuilder,
URL = window.MozURL || window.webkitURL || window.MSURL || window.OURL || window.URL;

Expand All @@ -18,7 +18,7 @@

bb.append('this.onmessage=function(e){postMessage(e.data)}');

var url = URL.createObjectURL(bb.getBlob());
var url = URL.createObjectURL(bb.getBlob()),
worker = new Worker(url);

bb = null;
Expand Down
62 changes: 62 additions & 0 deletions grunt.js
@@ -0,0 +1,62 @@
/*global module */
module.exports = function( grunt ) {
'use strict';

grunt.initConfig({
meta: {
version: '2.5.3',
banner: '/*!\n' +
' * Modernizr v<%= meta.version %>\n' +
' * www.modernizr.com\n *\n' +
' * Copyright (c) Faruk Ates, Paul Irish, Alex Sexton\n' +
' * Available under the BSD and MIT licenses: www.modernizr.com/license/\n */'
},
lint: {
files: [
'grunt.js',
'modernizr.js',
'feature-detects/*.js'
]
},
min: {
dist: {
src: [
'<banner:meta.banner>',
'modernizr.js'
],
dest: 'modernizr.min.js'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
jshint: {
options: {
boss: true,
browser: true,
curly: false,
devel: true,
eqeqeq: false,
eqnull: true,
expr: true,
evil: true,
immed: false,
laxcomma: true,
newcap: false,
noarg: true,
smarttabs: true,
sub: true,
undef: true
},
globals: {
Modernizr: true,
DocumentTouch: true,
TEST: true
}
}
});

grunt.registerTask('default', 'min');

};

0 comments on commit a16c9f7

Please sign in to comment.