-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamic styles with .less! + modal resizing improvements
- Added the possibility of customizing styles via parameters - Fixed .less for IE 11, see: less/less.js#3321 - Improved resizing for opening modals
- Loading branch information
1 parent
fa5fb28
commit 11568df
Showing
14 changed files
with
6,354 additions
and
77 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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// This file is used to dynamically generate styles for library & homePage pages. | ||
// https://stackoverflow.com/questions/3922139/add-css-to-head-with-javascript | ||
function addCssToDocument(css){ | ||
var head = document.getElementsByTagName('head')[0]; | ||
var s = document.createElement('style'); | ||
s.setAttribute('type', 'text/css'); | ||
if (s.styleSheet) { // IE | ||
s.styleSheet.cssText = css; | ||
} else { // the world | ||
s.appendChild(document.createTextNode(css)); | ||
} | ||
head.appendChild(s); | ||
} | ||
|
||
// Generate colors for less. | ||
var primary = getParamValue('primary'); | ||
var links = getParamValue('links'); | ||
var linksHover = getParamValue('linksHover'); | ||
var linksExternal = getParamValue('linksExternal'); | ||
|
||
if(primary === undefined){ | ||
primary = "#026FCF"; | ||
} | ||
else { | ||
primary = "#" + primary; | ||
} | ||
|
||
if(links === undefined){ | ||
links = "#0b62c1"; | ||
} | ||
else { | ||
links = "#" + links; | ||
} | ||
|
||
if(linksHover === undefined){ | ||
linksHover = "#0050a8"; | ||
} | ||
else { | ||
linksHover = "#" + linksHover; | ||
} | ||
|
||
if(linksExternal === undefined){ | ||
linksExternal = "#026FCF"; | ||
} | ||
else { | ||
linksExternal = "#" + linksExternal; | ||
} | ||
|
||
// Generate lessVariables. | ||
primary = "@primary: " + primary + "; "; | ||
links = "@links: " + links + "; "; | ||
linksHover = "@linksHover: " + linksHover + "; "; | ||
linksExternal = "@linksExternal: " + linksExternal + "; "; | ||
var lessVariables = primary + links + linksHover + linksExternal; | ||
|
||
var styleCssXml = new XMLHttpRequest(); | ||
styleCssXml.open('GET', '../style/style.less'); | ||
styleCssXml.onreadystatechange = function() { | ||
//console.log(styleCssXml.responseText); | ||
less.render(lessVariables + styleCssXml.responseText) | ||
.then(function(output) { | ||
//console.log(output.css) | ||
//console.log(output.css); | ||
addCssToDocument(output.css); | ||
}); | ||
}; | ||
styleCssXml.send(); | ||
|
||
var libraryCssXml = new XMLHttpRequest(); | ||
libraryCssXml.open('GET', '../style/library.less'); | ||
libraryCssXml.onreadystatechange = function() { | ||
//console.log(libraryCssXml.responseText); | ||
less.render(lessVariables + libraryCssXml.responseText) | ||
.then(function(output) { | ||
//console.log(output.css) | ||
addCssToDocument(output.css); | ||
}); | ||
}; | ||
libraryCssXml.send(); | ||
|
||
if(homePage) { | ||
var homePageCssXml = new XMLHttpRequest(); | ||
homePageCssXml.open('GET', '../style/homepage.less'); | ||
homePageCssXml.onreadystatechange = function() { | ||
//console.log(homePageCssXml.responseText); | ||
less.render(lessVariables + homePageCssXml.responseText) | ||
.then(function(output) { | ||
//console.log(output.css) | ||
addCssToDocument(output.css); | ||
}); | ||
}; | ||
homePageCssXml.send(); | ||
} |
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
Oops, something went wrong.