(new) less.refreshStyles, and reload styles on refresh()

This commit is contained in:
cloudhead 2010-07-04 19:21:43 +02:00
parent dd87c3bae9
commit b8e6455d55

View File

@ -72,17 +72,6 @@ for (var i = 0; i < links.length; i++) {
}
}
var styles = document.getElementsByTagName('style');
for (var i = 0; i < styles.length; i++) {
if (styles[i].type.match(typePattern)) {
new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) {
styles[i].type = 'text/css';
styles[i].innerHTML = tree.toCSS();
});
}
}
var startTime = endTime = new(Date);
less.refresh = function (reload) {
@ -97,10 +86,25 @@ less.refresh = function (reload) {
(env.remaining === 0) && log("css generated in " + (new(Date) - startTime) + 'ms');
endTime = new(Date);
}, reload);
loadStyles();
};
less.refreshStyles = loadStyles;
less.refresh(less.env === 'development');
function loadStyles() {
var styles = document.getElementsByTagName('style');
for (var i = 0; i < styles.length; i++) {
if (styles[i].type.match(typePattern)) {
new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) {
styles[i].type = 'text/css';
styles[i].innerHTML = tree.toCSS();
});
}
}
}
function loadStyleSheets(callback, reload) {
for (var i = 0; i < less.sheets.length; i++) {
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1));