-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client side JavaScript for documentation pages
Build dependencies with Ender. Handle minification in script.
- Loading branch information
Showing
6 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
resources/docs.js | ||
shared/ender* | ||
test-browser/tests.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
src/ | ||
node_modules/ | ||
test/ | ||
test-browser/ | ||
examples/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Scans your stylesheet for pseudo classes and adds a class with the same name. | ||
// Thanks to Knyle Style Sheets for the idea. | ||
$.domReady(function() { | ||
addPseudoClasses(); | ||
}); | ||
|
||
var _ = require('underscore'); | ||
|
||
var add = function(a, b) { return a + b; }; | ||
|
||
var addPseudoClasses = function() { | ||
// Compile regular expression. | ||
var pseudos = ['link', 'visited', 'hover', 'active', 'focus', 'target', 'enabled', 'disabled', 'checked']; | ||
var pseudoRe = new RegExp(":((" + pseudos.join(")|(") + "))", "gi"); | ||
var processedPseudoClasses = _.toArray(document.styleSheets).filter(function(ss) { | ||
return !(ss.href != null); | ||
}).map(function(ss) { | ||
return _.toArray(ss.cssRules).filter(function(rule) { | ||
// Keep only rules with pseudo classes. | ||
return rule.selectorText && rule.selectorText.match(pseudoRe); | ||
}).map(function(rule) { | ||
// Replace : with . and encoded : | ||
return rule.cssText.replace(pseudoRe, ".\\3A $1"); | ||
}).reduce(add); | ||
}).reduce(add, ''); | ||
if (processedPseudoClasses.length) { | ||
// Add a new style element with the processed pseudo class styles. | ||
return $('head').append($('<style />').text(processedPseudoClasses)); | ||
} | ||
}; |