From ce9b3cab187ed5c20390d6fe334a99fad477ad24 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 7 Jun 2012 13:09:46 -0500 Subject: [PATCH] Improved internal Modernizr testing function --- .../classic/source/javascripts/octopress.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.themes/classic/source/javascripts/octopress.js b/.themes/classic/source/javascripts/octopress.js index 42e23de..08928e7 100644 --- a/.themes/classic/source/javascripts/octopress.js +++ b/.themes/classic/source/javascripts/octopress.js @@ -54,12 +54,23 @@ var octopress = (function(){ }); } - , testFeatures: function () { - if (Modernizr.testAllProps('maskImage')) { - $('html').addClass('maskimage') - } else { - $('html').addClass('no-maskimage') + , testFeature: function (features) { + getTestClasses = function (tests) { + classes = ''; + if (typeof(tests.join) == 'function') { + for (var i=0; i < features.length; i++) + classes += getClass(features[i]) + ' '; + } else { + classes = getClass(tests); + } + return classes; } + + getClass = function (test) { + return ((Modernizr.testAllProps(test) ? test : "no-"+features[i]).toLowerCase()) + } + + $('html').addClass(getTestClasses(features)); } , flashVideoFallback: function (){ @@ -244,7 +255,7 @@ var octopress = (function(){ $(document).ready(function() { octopress.wrapFlashVideos(); - octopress.testFeatures(); + octopress.testFeature(['maskImage', 'transform']); octopress.flashVideoFallback(); octopress.addCodeLineNumbers(); octopress.addMobileNav();