eriiicam avatar eriiicam committed 626f88a

modernizr selectors extension

Comments (0)

Files changed (2)

static/js/modernizr.selectors.js

+// 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('targetselector',function(){
+  return selectorSupported(':target');
+})

templates/base.html

   <!-- Modernizr -->
   {% compress js %}
   <script src="{{ STATIC_URL }}js/modernizr.js"></script>  
+  <script src="{{ STATIC_URL }}js/modernizr.selectors.js"></script>  
   {% endcompress %}
   
   <!-- Page-Specific Head -->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.