mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Merge branch '1.5.0-wip' of https://github.com/gitaarik/less.js into 1.5.0-wip
Conflicts: lib/less/browser.js
This commit is contained in:
@@ -12,6 +12,13 @@ less.env = less.env || (location.hostname == '127.0.0.1' ||
|
||||
isFileProtocol ? 'development'
|
||||
: 'production');
|
||||
|
||||
// The amount of logging in the javascript console.
|
||||
// 2 - Information and errors
|
||||
// 1 - Errors
|
||||
// 0 - None
|
||||
// Defaults to 2
|
||||
less.log_level = typeof(less.log_level) != 'undefined' ? less.log_level : 2;
|
||||
|
||||
// Load styles asynchronously (default: false)
|
||||
//
|
||||
// This is set to `false` by default, so that the body
|
||||
@@ -118,14 +125,14 @@ less.refresh = function (reload, newVars) {
|
||||
return error(e, sheet.href);
|
||||
}
|
||||
if (env.local) {
|
||||
log("loading " + sheet.href + " from cache.");
|
||||
log("loading " + sheet.href + " from cache.", 2);
|
||||
} else {
|
||||
log("parsed " + sheet.href + " successfully.");
|
||||
log("parsed " + sheet.href + " successfully.", 2);
|
||||
createCSS(root.toCSS(less), sheet, env.lastModified);
|
||||
}
|
||||
log("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
|
||||
log("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms', 2);
|
||||
if (env.remaining === 0) {
|
||||
log("css generated in " + (new Date() - startTime) + 'ms');
|
||||
log("css generated in " + (new Date() - startTime) + 'ms', 2);
|
||||
}
|
||||
endTime = new Date();
|
||||
}, reload, newVars);
|
||||
@@ -424,13 +431,13 @@ function createCSS(styles, sheet, lastModified) {
|
||||
|
||||
// Don't update the local store if the file wasn't modified
|
||||
if (lastModified && cache) {
|
||||
log('saving ' + href + ' to cache.');
|
||||
log('saving ' + href + ' to cache.', 2);
|
||||
try {
|
||||
cache.setItem(href, styles);
|
||||
cache.setItem(href + ':timestamp', lastModified);
|
||||
} catch(e) {
|
||||
//TODO - could do with adding more robust error handling
|
||||
log('failed to save');
|
||||
log('failed to save', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,7 +449,7 @@ function doXHR(url, type, callback, errback) {
|
||||
if (typeof(xhr.overrideMimeType) === 'function') {
|
||||
xhr.overrideMimeType('text/css');
|
||||
}
|
||||
log("XHR: Getting '" + url + "'");
|
||||
log("XHR: Getting '" + url + "'", 2);
|
||||
xhr.open('GET', url, async);
|
||||
xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
|
||||
xhr.send(null);
|
||||
@@ -481,14 +488,16 @@ function getXMLHttpRequest() {
|
||||
/*global ActiveXObject */
|
||||
return new ActiveXObject("MSXML2.XMLHTTP.3.0");
|
||||
} catch (e) {
|
||||
log("browser doesn't support AJAX.");
|
||||
log("browser doesn't support AJAX.", 1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function log(str) {
|
||||
if (less.env == 'development' && typeof(console) !== "undefined") { console.log('less: ' + str); }
|
||||
function log(str, level) {
|
||||
if (less.env == 'development' && typeof(console) !== 'undefined' && less.log_level >= level) {
|
||||
console.log('less: ' + str);
|
||||
}
|
||||
}
|
||||
|
||||
function error(e, rootHref) {
|
||||
|
||||
Reference in New Issue
Block a user