diff --git a/docs/source/javascripts/modernizr.selectors.js b/docs/source/javascripts/modernizr.selectors.js new file mode 100644 index 00000000..65e9b285 --- /dev/null +++ b/docs/source/javascripts/modernizr.selectors.js @@ -0,0 +1,55 @@ +// selectorSupported lovingly lifted from the mad italian genius, diego perini +// http://javascript.nwbox.com/CSSSupport/ +function selectorSupported(selector){ + + var support, link, sheet, doc = document, + root = doc.documentElement, + head = root.getElementsByTagName('head')[0], + + impl = doc.implementation || { + hasFeature: function() { + return false; + } + }, + + link = doc.createElement("style"); + link.type = 'text/css'; + + (head || root).insertBefore(link, (head || root).firstChild); + + sheet = link.sheet || link.styleSheet; + + if (!(sheet && selector)) return false; + + support = impl.hasFeature('CSS2', '') ? + + function(selector) { + try { + sheet.insertRule(selector + '{ }', 0); + sheet.deleteRule(sheet.cssRules.length - 1); + } catch (e) { + return false; + } + return true; + + } : function(selector) { + + sheet.cssText = selector + ' { }'; + return sheet.cssText.length !== 0 && !(/unknown/i).test(sheet.cssText) && sheet.cssText.indexOf(selector) === 0; + }; + + return support(selector); + +}; + +Modernizr.addTest('target',function(){ + return selectorSupported(':target'); +}).addTest('not',function(){ + return selectorSupported(':not(p)'); +}).addTest('last-child',function(){ + return selectorSupported(':last-child'); +}).addTest('nth-child',function(){ + return selectorSupported(':nth-child(2)'); +}).addTest('nth-of-type',function(){ + return selectorSupported(':nth-of-type(2)'); +}) diff --git a/docs/source/partials/_head.haml b/docs/source/partials/_head.haml index 2e87c710..ddcfc517 100644 --- a/docs/source/partials/_head.haml +++ b/docs/source/partials/_head.haml @@ -8,4 +8,5 @@ %meta{:content => "width=device-width", :name => "viewport"} = stylesheet_link_tag "site.css" - = javascript_include_tag "modernizr-2.5.3.min.js" \ No newline at end of file + = javascript_include_tag "modernizr-2.5.3.min.js" + = javascript_include_tag "modernizr.selectors.js" diff --git a/docs/source/stylesheets/_modules/_toggle.scss b/docs/source/stylesheets/_modules/_toggle.scss index 2894cef5..0e88fd1c 100644 --- a/docs/source/stylesheets/_modules/_toggle.scss +++ b/docs/source/stylesheets/_modules/_toggle.scss @@ -2,10 +2,11 @@ // Grid Toggle .grid-toggle { - // display: none; + display: none; position: absolute; top: .5em; right: .5em; + .target & { display: block; } } .on, .off {