Permalink
Browse files

modernizr class toggling added.

  • Loading branch information...
1 parent 1f22c66 commit bf77500c2ef1a74ddb08e175b6e3771cd5817534 @paulirish paulirish committed Aug 28, 2011
Showing with 36 additions and 5 deletions.
  1. +19 −0 deCSS3.js
  2. +13 −5 example.html
  3. +4 −0 modernizr.custom.17939.js
View
@@ -21,6 +21,7 @@ var deCSS3 = {
elem.parentNode.removeChild( elem );
});
}
+ this.toggleModernizr();
},
@@ -141,6 +142,24 @@ var deCSS3 = {
stylesheet.disabled = true;
}
});
+ },
+
+ toggleModernizr: function(){
+ if (!window.Modernizr) return;
+
+ var newclasses = document.documentElement.className,
+ bool, regex, match
+
+ for (var feat in Modernizr){
+ bool = Modernizr[feat];
+ regex = RegExp('(?:^|\\s)(no-)?' + feat + '(?:\\s|$)');
+ match = newclasses.match(regex);
+
+ if (match){
+ newclasses = newclasses.replace(regex, (((match[1] == 'no-') ? ' ' : ' no-') + feat) + ' ')
+ }
+ }
+ document.documentElement.className = newclasses;
}
}
// Auto-init
View
@@ -128,6 +128,7 @@
}
</style>
+ <script src="modernizr.custom.17939.js"></script>
</head>
<body>
<header class="multiple_backgrounds">
@@ -143,14 +144,21 @@
</section>
<script>
- var trigger = document.getElementsByTagName('a');
- trigger[0].onclick = function(e){
+ document.getElementsByTagName('a')[0].addEventListener('click', function(e){
+
e.preventDefault();
- s=document.createElement('script');
+
+ if (window.deCSS3){
+ deCSS3.init( document.querySelectorAll( '.deCSS3-Style' ) );
+ return;
+ }
+
+ var s = document.createElement('script');
s.type='text/javascript';
- s.src='deCSS3.js?v='+parseInt(Math.random()*99999999);
+ s.src='deCSS3.js?v=' + parseInt(Math.random() * 99999999);
document.body.appendChild(s);
- };
+
+ }, false);;
</script>
</body>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit bf77500

Please sign in to comment.