mirror of
https://github.com/less/less.js.git
synced 2026-02-04 03:55:10 -05:00
Merge remote branch 'cloudhead/master'
This commit is contained in:
3
Makefile
3
Makefile
@@ -38,8 +38,7 @@ less:
|
||||
min: less
|
||||
@@echo minifying...
|
||||
@@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST_MIN}
|
||||
@@java -jar build/compiler.jar\
|
||||
--js ${DIST} >> ${DIST_MIN}
|
||||
@@uglifyjs ${DIST} >> ${DIST_MIN}
|
||||
|
||||
clean:
|
||||
git rm dist/*
|
||||
|
||||
17
bin/lessc
17
bin/lessc
@@ -11,13 +11,14 @@ var args = process.argv.slice(1);
|
||||
var options = {
|
||||
compress: false,
|
||||
optimization: 1,
|
||||
silent: false
|
||||
silent: false,
|
||||
paths: []
|
||||
};
|
||||
|
||||
args = args.filter(function (arg) {
|
||||
var match;
|
||||
|
||||
if (match = arg.match(/^--?([a-z][0-9a-z-]*)$/i)) { arg = match[1] }
|
||||
if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=([^\s]+))?$/i)) { arg = match[1] }
|
||||
else { return arg }
|
||||
|
||||
switch (arg) {
|
||||
@@ -40,6 +41,16 @@ args = args.filter(function (arg) {
|
||||
case 'compress':
|
||||
options.compress = true;
|
||||
break;
|
||||
case 'include-path':
|
||||
options.paths = match[2].split(':')
|
||||
.map(function(p) {
|
||||
if (p && p[0] == '/') {
|
||||
return path.join(path.dirname(input), p);
|
||||
} else if (p) {
|
||||
return path.join(process.cwd(), p);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'O0': options.optimization = 0; break;
|
||||
case 'O1': options.optimization = 1; break;
|
||||
case 'O2': options.optimization = 2; break;
|
||||
@@ -69,7 +80,7 @@ fs.readFile(input, 'utf-8', function (e, data) {
|
||||
}
|
||||
|
||||
new(less.Parser)({
|
||||
paths: [path.dirname(input)],
|
||||
paths: [path.dirname(input)].concat(options.paths),
|
||||
optimization: options.optimization,
|
||||
filename: input
|
||||
}).parse(data, function (err, tree) {
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
// LESS - Leaner CSS v@VERSION
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2010, Alexis Sellier
|
||||
// Copyright (c) 2009-2011, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
|
||||
69
dist/less-1.0.41.min.js
vendored
69
dist/less-1.0.41.min.js
vendored
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// LESS - Leaner CSS v1.0.41
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2010, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
(function(z){function s(d){return z.less[d.split("/")[1]]}function U(){for(var d=document.getElementsByTagName("style"),b=0;b<d.length;b++)if(d[b].type.match(V))(new o.Parser).parse(d[b].innerHTML||"",function(a,g){d[b].type="text/css";d[b].innerHTML=g.toCSS()})}function W(d,b){for(var a=0;a<o.sheets.length;a++)X(o.sheets[a],d,b,o.sheets.length-(a+1))}function X(d,b,a,g){var e=z.location.href.replace(/[#?].*$/,""),h=d.href.replace(/\?.*$/,""),i=B&&B.getItem(h),k=B&&B.getItem(h+":timestamp"),n={css:i,
|
||||
timestamp:k};/^(https?|file):/.test(h)||(h=e.slice(0,e.lastIndexOf("/")+1)+h);Z(d.href,d.type,function(r,p){if(!a&&n&&p&&(new Date(p)).valueOf()===(new Date(n.timestamp)).valueOf()){N(n.css,d);b(null,d,{local:true,remaining:g})}else try{(new o.Parser({optimization:o.optimization,paths:[h.replace(/[\w\.-]+$/,"")],mime:d.type})).parse(r,function(K,O){if(K)return Q(K,h);try{b(O,d,{local:false,lastModified:p,remaining:g});var F=document.getElementById("less-error-message:"+R(h));F&&F.parentNode.removeChild(F)}catch(f){Q(f,
|
||||
h)}})}catch(t){Q(t,h)}},function(r,p){throw Error("Couldn't load "+p+" ("+r+")");})}function R(d){return d.replace(/^[a-z]+:\/\/?[^\/]+/,"").replace(/^\//,"").replace(/\?.*$/,"").replace(/\.[^\.\/]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function N(d,b,a){var g,e=b.href?b.href.replace(/\?.*$/,""):"",h="less:"+(b.title||R(e));if((g=document.getElementById(h))===null){g=document.createElement("style");g.type="text/css";g.media=b.media||"screen";g.id=h;document.getElementsByTagName("head")[0].appendChild(g)}if(g.styleSheet)try{g.styleSheet.cssText=
|
||||
d}catch(i){throw Error("Couldn't reassign styleSheet.cssText.");}else(function(k){if(g.childNodes.length>0)g.firstChild.nodeValue!==k.nodeValue&&g.replaceChild(k,g.firstChild);else g.appendChild(k)})(document.createTextNode(d));if(a&&B){H("saving "+e+" to cache.");B.setItem(e,d);B.setItem(e+":timestamp",a)}}function Z(d,b,a,g){function e(k,n,r){if(k.status>=200&&k.status<300)n(k.responseText,k.getResponseHeader("Last-Modified"));else typeof r==="function"&&r(k.status,d)}var h=$(),i=P?false:o.async;
|
||||
typeof h.overrideMimeType==="function"&&h.overrideMimeType("text/css");h.open("GET",d,i);h.setRequestHeader("Accept",b||"text/x-less, text/css; q=0.9, */*; q=0.5");h.send(null);if(P)h.status===0?a(h.responseText):g(h.status,d);else if(i)h.onreadystatechange=function(){h.readyState==4&&e(h,a,g)};else e(h,a,g)}function $(){if(z.XMLHttpRequest)return new XMLHttpRequest;else try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(d){H("browser doesn't support AJAX.");return null}}function H(d){o.env==
|
||||
"development"&&typeof console!=="undefined"&&console.log("less: "+d)}function Q(d,b){var a="less-error-message:"+R(b),g=document.createElement("div"),e,h;g.id=a;g.className="less-error-message";h="<h3>"+(d.message||"There is an error in your .less file")+'</h3><p><a href="'+b+'">'+b+"</a> ";if(d.extract)h+="on line "+d.line+", column "+(d.column+1)+":</p>"+'<ul>\n<li><label>[-1]</label><pre class="ctx">{0}</pre></li>\n<li><label>[0]</label><pre>{current}</pre></li>\n<li><label>[1]</label><pre class="ctx">{2}</pre></li>\n</ul>'.replace(/\[(-?\d)\]/g,
|
||||
function(i,k){return parseInt(d.line)+parseInt(k)||""}).replace(/\{(\d)\}/g,function(i,k){return d.extract[parseInt(k)]||""}).replace(/\{current\}/,d.extract[1].slice(0,d.column)+'<span class="error">'+d.extract[1].slice(d.column)+"</span>");g.innerHTML=h;N(".less-error-message ul, .less-error-message li {\nlist-style-type: none;\nmargin-right: 15px;\npadding: 4px 0;\nmargin: 0;\n}\n.less-error-message label {\nfont-size: 12px;\nmargin-right: 15px;\npadding: 4px 0;\ncolor: #cc7777;\n}\n.less-error-message pre {\ncolor: #ee4444;\npadding: 4px 0;\nmargin: 0;\ndisplay: inline-block;\n}\n.less-error-message pre.ctx {\ncolor: #dd4444;\n}\n.less-error-message h3 {\nfont-size: 20px;\nfont-weight: bold;\npadding: 15px 0 5px 0;\nmargin: 0;\n}\n.less-error-message a {\ncolor: #10a\n}\n.less-error-message .error {\ncolor: red;\nfont-weight: bold;\npadding-bottom: 2px;\nborder-bottom: 1px dashed red;\n}",
|
||||
{title:"error-message"});g.style.cssText="font-family: Arial, sans-serif;border: 1px solid #e00;background-color: #eee;border-radius: 5px;-webkit-border-radius: 5px;-moz-border-radius: 5px;color: #e00;padding: 15px;margin-bottom: 15px";if(o.env=="development")e=setInterval(function(){if(document.body){document.getElementById(a)?document.body.replaceChild(g,document.getElementById(a)):document.body.insertBefore(g,document.body.firstChild);clearInterval(e)}},10)}if(!Array.isArray)Array.isArray=function(d){return Object.prototype.toString.call(d)===
|
||||
"[object Array]"||d instanceof Array};if(!Array.prototype.forEach)Array.prototype.forEach=function(d,b){for(var a=this.length>>>0,g=0;g<a;g++)g in this&&d.call(b,this[g],g,this)};if(!Array.prototype.map)Array.prototype.map=function(d,b){for(var a=this.length>>>0,g=Array(a),e=0;e<a;e++)if(e in this)g[e]=d.call(b,this[e],e,this);return g};if(!Array.prototype.filter)Array.prototype.filter=function(d,b){for(var a=[],g=0;g<this.length;g++)d.call(b,this[g])&&a.push(this[g]);return a};if(!Array.prototype.reduce)Array.prototype.reduce=
|
||||
function(d){var b=this.length>>>0,a=0;if(b===0&&arguments.length===1)throw new TypeError;if(arguments.length>=2)var g=arguments[1];else{do{if(a in this){g=this[a++];break}if(++a>=b)throw new TypeError;}while(1)}for(;a<b;a++)if(a in this)g=d.call(null,g,this[a],a,this);return g};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(d,b){var a=this.length,g=b||0;if(!a)return-1;if(g>=a)return-1;if(g<0)g+=a;for(;g<a;g++)if(Object.prototype.hasOwnProperty.call(this,g))if(d===this[g])return g;return-1};
|
||||
if(!Object.keys)Object.keys=function(d){var b=[],a;for(a in d)Object.prototype.hasOwnProperty.call(d,a)&&b.push(a);return b};if(!String.prototype.trim)String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")};var o,m;if(typeof z==="undefined"){o=exports;m=s("less/tree")}else{if(typeof z.less==="undefined")z.less={};o=z.less;m=z.less.tree={}}o.Parser=function(d){function b(){if(h>t){p[i]=p[i].slice(h-t);t=h}}function a(f){var j,l,q;if(f instanceof Function)return f.call(K.parsers);
|
||||
else if(typeof f==="string"){f=e.charAt(h)===f?f:null;j=1;b()}else{b();if(f=f.exec(p[i]))j=f[0].length;else return null}if(f){mem=h+=j;for(q=h+p[i].length-j;h<q;){l=e.charCodeAt(h);if(!(l===32||l===10||l===9))break;h++}p[i]=p[i].slice(j+(h-mem));t=h;p[i].length===0&&i<p.length-1&&i++;return typeof f==="string"?f:f.length===1?f[0]:f}}function g(f){return typeof f==="string"?e.charAt(h)===f:f.test(p[i])?true:false}var e,h,i,k,n,r,p,t,K,O=function(){},F=this.imports={paths:d&&d.paths||[],queue:[],files:{},
|
||||
mime:d&&d.mime,push:function(f,j){var l=this;this.queue.push(f);o.Parser.importer(f,this.paths,function(q){l.queue.splice(l.queue.indexOf(f),1);l.files[f]=q;j(q);l.queue.length===0&&O()},d)}};this.env=d=d||{};this.optimization="optimization"in this.env?this.env.optimization:1;this.env.filename=this.env.filename||null;return K={imports:F,parse:function(f,j){var l,q,I,S=null;h=i=t=r=0;p=[];e=f.replace(/\r\n/g,"\n");p=function(L){for(var D=0,E=/[^"'`\{\}\/]+/g,G=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
|
||||
A=0,w,x=L[0],y,u=0,v;u<e.length;u++){E.lastIndex=u;if(w=E.exec(e))if(w.index===u){u+=w[0].length;x.push(w[0])}v=e.charAt(u);G.lastIndex=u;if(!y&&v==="/"){w=e.charAt(u+1);if(w==="/"||w==="*")if(w=G.exec(e))if(w.index===u){u+=w[0].length;x.push(w[0]);v=e.charAt(u)}}if(v==="{"&&!y){A++;x.push(v)}else if(v==="}"&&!y){A--;x.push(v);L[++D]=x=[]}else{if(v==='"'||v==="'"||v==="`")y=y?y===v?false:y:v;x.push(v)}}if(A>0)throw{type:"Syntax",message:"Missing closing `}`",filename:d.filename};return L.map(function(C){return C.join("")})}([[]]);
|
||||
l=new m.Ruleset([],a(this.parsers.primary));l.root=true;l.toCSS=function(L){var D,E;return function(G,A){function w(v){return v?(e.slice(0,v).match(/\n/g)||"").length:null}var x=[];G=G||{};if(typeof A==="object"&&!Array.isArray(A)){A=Object.keys(A).map(function(v){var C=A[v];if(!(C instanceof m.Value)){C instanceof m.Expression||(C=new m.Expression([C]));C=new m.Value([C])}return new m.Rule("@"+v,C,false,0)});x=[new m.Ruleset(null,A)]}try{var y=L.call(this,{frames:x}).toCSS([],{compress:G.compress||
|
||||
false})}catch(u){E=e.split("\n");D=w(u.index);x=u.index;for(y=-1;x>=0&&e.charAt(x)!=="\n";x--)y++;throw{type:u.type,message:u.message,filename:d.filename,index:u.index,line:typeof D==="number"?D+1:null,callLine:u.call&&w(u.call)+1,callExtract:E[w(u.call)],stack:u.stack,column:y,extract:[E[D-1],E[D],E[D+1]]};}return G.compress?y.replace(/(\s)+/g,"$1"):y}}(l.eval);if(h<e.length-1){h=r;I=e.split("\n");q=(e.slice(0,h).match(/\n/g)||"").length+1;for(var T=h,Y=-1;T>=0&&e.charAt(T)!=="\n";T--)Y++;S={name:"ParseError",
|
||||
message:"Syntax Error on line "+q,filename:d.filename,line:q,column:Y,extract:[I[q-2],I[q-1],I[q]]}}if(this.imports.queue.length>0)O=function(){j(S,l)};else j(S,l)},parsers:{primary:function(){for(var f,j=[];(f=a(this.mixin.definition)||a(this.rule)||a(this.ruleset)||a(this.mixin.call)||a(this.comment)||a(this.directive))||a(/^[\s\n]+/);)f&&j.push(f);return j},comment:function(){var f;if(e.charAt(h)==="/")if(e.charAt(h+1)==="/")return new m.Comment(a(/^\/\/.*/),true);else if(f=a(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new m.Comment(f)},
|
||||
entities:{quoted:function(){var f;if(!(e.charAt(h)!=='"'&&e.charAt(h)!=="'"))if(f=a(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new m.Quoted(f[0],f[1]||f[2])},keyword:function(){var f;if(f=a(/^[A-Za-z-]+/))return new m.Keyword(f)},call:function(){var f,j;if(f=/^([\w-]+|%)\(/.exec(p[i])){f=f[1].toLowerCase();if(f==="url")return null;else h+=f.length+1;if(f==="alpha")return a(this.alpha);j=a(this.entities.arguments);if(a(")"))if(f)return new m.Call(f,j)}},arguments:function(){for(var f=
|
||||
[],j;j=a(this.expression);){f.push(j);if(!a(","))break}return f},literal:function(){return a(this.entities.dimension)||a(this.entities.color)||a(this.entities.quoted)},url:function(){var f;if(!(e.charAt(h)!=="u"||!a(/^url\(/))){f=a(this.entities.quoted)||a(this.entities.variable)||a(this.entities.dataURI)||a(/^[-\w%@$\/.&=:;#+?]+/)||"";if(!a(")"))throw Error("missing closing ) for url()");return new m.URL(f.value||f.data||f instanceof m.Variable?f:new m.Anonymous(f),F.paths)}},dataURI:function(){var f;
|
||||
if(a(/^data:/)){f={};f.mime=a(/^[^\/]+\/[^,;)]+/)||"";f.charset=a(/^;\s*charset=[^,;)]+/)||"";f.base64=a(/^;\s*base64/)||"";f.data=a(/^,\s*[^)]+/);if(f.data)return f}},variable:function(){var f,j=h;if(e.charAt(h)==="@"&&(f=a(/^@[\w-]+/)))return new m.Variable(f,j)},color:function(){var f;if(e.charAt(h)==="#"&&(f=a(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new m.Color(f[1])},dimension:function(){var f;f=e.charCodeAt(h);if(!(f>57||f<45||f===47))if(f=a(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/))return new m.Dimension(f[1],
|
||||
f[2])},javascript:function(){var f;if(e.charAt(h)==="`")if(f=a(/^`([^`]*)`/))return new m.JavaScript(f[1],h)}},variable:function(){var f;if(e.charAt(h)==="@"&&(f=a(/^(@[\w-]+)\s*:/)))return f[1]},shorthand:function(){var f,j;if(g(/^[@\w.%-]+\/[@\w.-]+/))if((f=a(this.entity))&&a("/")&&(j=a(this.entity)))return new m.Shorthand(f,j)},mixin:{call:function(){var f=[],j,l,q,I=h;j=e.charAt(h);if(!(j!=="."&&j!=="#")){for(;j=a(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/);){f.push(new m.Element(l,
|
||||
j));l=a(">")}a("(")&&(q=a(this.entities.arguments))&&a(")");if(f.length>0&&(a(";")||g("}")))return new m.mixin.Call(f,q,I)}},definition:function(){var f,j=[],l,q;if(!(e.charAt(h)!=="."&&e.charAt(h)!=="#"||g(/^[^{]*(;|})/)))if(f=a(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)){for(f=f[1];l=a(this.entities.variable)||a(this.entities.literal)||a(this.entities.keyword);){if(l instanceof m.Variable)if(a(":"))if(q=a(this.expression))j.push({name:l.name,value:q});else throw Error("Expected value");
|
||||
else j.push({name:l.name});else j.push({value:l});if(!a(","))break}if(!a(")"))throw Error("Expected )");if(l=a(this.block))return new m.mixin.Definition(f,j,l)}}},entity:function(){return a(this.entities.literal)||a(this.entities.variable)||a(this.entities.url)||a(this.entities.call)||a(this.entities.keyword)||a(this.entities.javascript)},end:function(){return a(";")||g("}")},alpha:function(){var f;if(a(/^opacity=/i))if(f=a(/^\d+/)||a(this.entities.variable)){if(!a(")"))throw Error("missing closing ) for alpha()");
|
||||
return new m.Alpha(f)}},element:function(){var f;c=a(this.combinator);if(f=a(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)||a("*")||a(this.attribute)||a(/^\([^)@]+\)/))return new m.Element(c,f)},combinator:function(){var f=e.charAt(h);if(f===">"||f==="&"||f==="+"||f==="~"){for(h++;e.charAt(h)===" ";)h++;return new m.Combinator(f)}else if(f===":"&&e.charAt(h+1)===":"){for(h+=2;e.charAt(h)===" ";)h++;return new m.Combinator("::")}else return e.charAt(h-1)===" "?new m.Combinator(" "):
|
||||
new m.Combinator(null)},selector:function(){for(var f,j=[],l;f=a(this.element);){l=e.charAt(h);j.push(f);if(l==="{"||l==="}"||l===";"||l===",")break}if(j.length>0)return new m.Selector(j)},tag:function(){return a(/^[a-zA-Z][a-zA-Z-]*[0-9]?/)||a("*")},attribute:function(){var f="",j,l,q;if(a("[")){if(j=a(/^[a-zA-Z-]+/)||a(this.entities.quoted))f=(q=a(/^[|~*$^]?=/))&&(l=a(this.entities.quoted)||a(/^[\w-]+/))?[j,q,l.toCSS?l.toCSS():l].join(""):j;if(a("]"))if(f)return"["+f+"]"}},block:function(){var f;
|
||||
if(a("{")&&(f=a(this.primary))&&a("}"))return f},ruleset:function(){var f=[],j,l;k=p[i];t=n=h;if(j=/^([.#: \w-]+)[\s\n]*\{/.exec(p[i])){h+=j[0].length-1;f=[new m.Selector([new m.Element(null,j[1])])]}else{for(;j=a(this.selector);){f.push(j);if(!a(","))break}j&&a(this.comment)}if(f.length>0&&(l=a(this.block)))return new m.Ruleset(f,l);else{r=h;p[i]=k;t=h=n}},rule:function(){var f,j;f=e.charAt(h);var l;k=p[i];t=n=h;if(!(f==="."||f==="#"||f==="&"))if(f=a(this.variable)||a(this.property)){if(f.charAt(0)!=
|
||||
"@"&&(match=/^([^@+\/'"*`(;{}-]*);/.exec(p[i]))){h+=match[0].length-1;j=new m.Anonymous(match[1])}else j=f==="font"?a(this.font):a(this.value);l=a(this.important);if(j&&a(this.end))return new m.Rule(f,j,l,n);else{r=h;p[i]=k;t=h=n}}},"import":function(){var f;if(a(/^@import\s+/)&&(f=a(this.entities.quoted)||a(this.entities.url))&&a(";"))return new m.Import(f,F)},directive:function(){var f,j,l;if(e.charAt(h)==="@")if(j=a(this["import"]))return j;else if(f=a(/^@media|@page/)){l=(a(/^[^{]+/)||"").trim();
|
||||
if(j=a(this.block))return new m.Directive(f+" "+l,j)}else if(f=a(/^@[-a-z]+/))if(f==="@font-face"){if(j=a(this.block))return new m.Directive(f,j)}else if((j=a(this.entity))&&a(";"))return new m.Directive(f,j)},font:function(){for(var f=[],j=[],l;l=a(this.shorthand)||a(this.entity);)j.push(l);f.push(new m.Expression(j));if(a(","))for(;l=a(this.expression);){f.push(l);if(!a(","))break}return new m.Value(f)},value:function(){for(var f,j=[];f=a(this.expression);){j.push(f);if(!a(","))break}if(j.length>
|
||||
0)return new m.Value(j)},important:function(){if(e.charAt(h)==="!")return a(/^! *important/)},sub:function(){var f;if(a("(")&&(f=a(this.expression))&&a(")"))return f},multiplication:function(){var f,j,l,q;if(f=a(this.operand)){for(;(l=a("/")||a("*"))&&(j=a(this.operand));)q=new m.Operation(l,[q||f,j]);return q||f}},addition:function(){var f,j,l,q;if(f=a(this.multiplication)){for(;(l=a(/^[-+]\s+/)||e.charAt(h-1)!=" "&&(a("+")||a("-")))&&(j=a(this.multiplication));)q=new m.Operation(l,[q||f,j]);return q||
|
||||
f}},operand:function(){return a(this.sub)||a(this.entities.dimension)||a(this.entities.color)||a(this.entities.variable)||a(this.entities.call)},expression:function(){for(var f,j=[];f=a(this.addition)||a(this.entity);)j.push(f);if(j.length>0)return new m.Expression(j)},property:function(){var f;if(f=a(/^(\*?-?[-a-z_0-9]+)\s*:/))return f[1]}}}};if(typeof z!=="undefined")o.Parser.importer=function(d,b,a,g){if(d.charAt(0)!=="/"&&b.length>0)d=b[0]+d;X({href:d,title:d,type:g.mime},a,true)};(function(d){function b(e){return d.functions.hsla(e.h,
|
||||
e.s,e.l,e.a)}function a(e){if(e instanceof d.Dimension)return parseFloat(e.unit=="%"?e.value/100:e.value);else if(typeof e==="number")return e;else throw{error:"RuntimeError",message:"color functions take numbers as parameters"};}function g(e){return Math.min(1,Math.max(0,e))}d.functions={rgb:function(e,h,i){return this.rgba(e,h,i,1)},rgba:function(e,h,i,k){e=[e,h,i].map(function(n){return a(n)});k=a(k);return new d.Color(e,k)},hsl:function(e,h,i){return this.hsla(e,h,i,1)},hsla:function(e,h,i,k){function n(t){t=
|
||||
t<0?t+1:t>1?t-1:t;return t*6<1?p+(r-p)*t*6:t*2<1?r:t*3<2?p+(r-p)*(2/3-t)*6:p}e=a(e)%360/360;h=a(h);i=a(i);k=a(k);var r=i<=0.5?i*(h+1):i+h-i*h,p=i*2-r;return this.rgba(n(e+1/3)*255,n(e)*255,n(e-1/3)*255,k)},hue:function(e){return new d.Dimension(Math.round(e.toHSL().h))},saturation:function(e){return new d.Dimension(Math.round(e.toHSL().s*100),"%")},lightness:function(e){return new d.Dimension(Math.round(e.toHSL().l*100),"%")},alpha:function(e){return new d.Dimension(e.toHSL().a)},saturate:function(e,
|
||||
h){var i=e.toHSL();i.s+=h.value/100;i.s=g(i.s);return b(i)},desaturate:function(e,h){var i=e.toHSL();i.s-=h.value/100;i.s=g(i.s);return b(i)},lighten:function(e,h){var i=e.toHSL();i.l+=h.value/100;i.l=g(i.l);return b(i)},darken:function(e,h){var i=e.toHSL();i.l-=h.value/100;i.l=g(i.l);return b(i)},fadein:function(e,h){var i=e.toHSL();i.a+=h.value/100;i.a=g(i.a);return b(i)},fadeout:function(e,h){var i=e.toHSL();i.a-=h.value/100;i.a=g(i.a);return b(i)},spin:function(e,h){var i=e.toHSL(),k=(i.h+h.value)%
|
||||
360;i.h=k<0?360+k:k;return b(i)},mix:function(e,h,i){i=i.value/100;var k=i*2-1,n=e.toHSL().a-h.toHSL().a;k=((k*n==-1?k:(k+n)/(1+k*n))+1)/2;n=1-k;return new d.Color([e.rgb[0]*k+h.rgb[0]*n,e.rgb[1]*k+h.rgb[1]*n,e.rgb[2]*k+h.rgb[2]*n],e.alpha*i+h.alpha*(1-i))},greyscale:function(e){return this.desaturate(e,new d.Dimension(100))},e:function(e){return new d.Anonymous(e instanceof d.JavaScript?e.evaluated:e)},"%":function(e){for(var h=Array.prototype.slice.call(arguments,1),i=e.value,k=0;k<h.length;k++)i=
|
||||
i.replace(/%s/,h[k].value).replace(/%[da]/,h[k].toCSS());i=i.replace(/%%/g,"%");return new d.Quoted('"'+i+'"',i)}}})(s("less/tree"));(function(d){d.Alpha=function(b){this.value=b};d.Alpha.prototype={toCSS:function(){return"alpha(opacity="+(this.value.toCSS?this.value.toCSS():this.value)+")"},eval:function(){return this}}})(s("less/tree"));(function(d){d.Anonymous=function(b){this.value=b.value||b};d.Anonymous.prototype={toCSS:function(){return this.value},eval:function(){return this}}})(s("less/tree"));
|
||||
(function(d){d.Call=function(b,a){this.name=b;this.args=a};d.Call.prototype={eval:function(b){var a=this.args.map(function(g){return g.eval(b)});return this.name in d.functions?d.functions[this.name].apply(d.functions,a):new d.Anonymous(this.name+"("+a.map(function(g){return g.toCSS()}).join(", ")+")")},toCSS:function(b){return this.eval(b).toCSS()}}})(s("less/tree"));(function(d){d.Color=function(b,a){this.rgb=Array.isArray(b)?b:b.length==6?b.match(/.{2}/g).map(function(g){return parseInt(g,16)}):
|
||||
b.split("").map(function(g){return parseInt(g+g,16)});this.alpha=typeof a==="number"?a:1};d.Color.prototype={eval:function(){return this},toCSS:function(){return this.alpha<1?"rgba("+this.rgb.map(function(b){return Math.round(b)}).concat(this.alpha).join(", ")+")":"#"+this.rgb.map(function(b){b=Math.round(b);b=(b>255?255:b<0?0:b).toString(16);return b.length===1?"0"+b:b}).join("")},operate:function(b,a){var g=[];a instanceof d.Color||(a=a.toColor());for(var e=0;e<3;e++)g[e]=d.operate(b,this.rgb[e],
|
||||
a.rgb[e]);return new d.Color(g)},toHSL:function(){var b=this.rgb[0]/255,a=this.rgb[1]/255,g=this.rgb[2]/255,e=this.alpha,h=Math.max(b,a,g),i=Math.min(b,a,g),k,n=(h+i)/2,r=h-i;if(h===i)k=i=0;else{i=n>0.5?r/(2-h-i):r/(h+i);switch(h){case b:k=(a-g)/r+(a<g?6:0);break;case a:k=(g-b)/r+2;break;case g:k=(b-a)/r+4}k/=6}return{h:k*360,s:i,l:n,a:e}}}})(s("less/tree"));(function(d){d.Comment=function(b,a){this.value=b;this.silent=!!a};d.Comment.prototype={toCSS:function(b){return b.compress?"":this.value},eval:function(){return this}}})(s("less/tree"));
|
||||
(function(d){d.Dimension=function(b,a){this.value=parseFloat(b);this.unit=a||null};d.Dimension.prototype={eval:function(){return this},toColor:function(){return new d.Color([this.value,this.value,this.value])},toCSS:function(){return this.value+this.unit},operate:function(b,a){return new d.Dimension(d.operate(b,this.value,a.value),this.unit||a.unit)}}})(s("less/tree"));(function(d){d.Directive=function(b,a){this.name=b;if(Array.isArray(a))this.ruleset=new d.Ruleset([],a);else this.value=a};d.Directive.prototype=
|
||||
{toCSS:function(b,a){if(this.ruleset){this.ruleset.root=true;return this.name+(a.compress?"{":" {\n ")+this.ruleset.toCSS(b,a).trim().replace(/\n/g,"\n ")+(a.compress?"}":"\n}\n")}else return this.name+" "+this.value.toCSS()+";\n"},eval:function(b){b.frames.unshift(this);this.ruleset=this.ruleset&&this.ruleset.eval(b);b.frames.shift();return this},variable:function(b){return d.Ruleset.prototype.variable.call(this.ruleset,b)},find:function(){return d.Ruleset.prototype.find.apply(this.ruleset,arguments)},
|
||||
rulesets:function(){return d.Ruleset.prototype.rulesets.apply(this.ruleset)}}})(s("less/tree"));(function(d){d.Element=function(b,a){this.combinator=b instanceof d.Combinator?b:new d.Combinator(b);this.value=a.trim()};d.Element.prototype.toCSS=function(b){return this.combinator.toCSS(b||{})+this.value};d.Combinator=function(b){this.value=b===" "?" ":b?b.trim():""};d.Combinator.prototype.toCSS=function(b){return{"":""," ":" ","&":"",":":" :","::":"::","+":b.compress?"+":" + ","~":b.compress?"~":" ~ ",
|
||||
">":b.compress?">":" > "}[this.value]}})(s("less/tree"));(function(d){d.Expression=function(b){this.value=b};d.Expression.prototype={eval:function(b){return this.value.length>1?new d.Expression(this.value.map(function(a){return a.eval(b)})):this.value[0].eval(b)},toCSS:function(b){return this.value.map(function(a){return a.toCSS(b)}).join(" ")}}})(s("less/tree"));(function(d){d.Import=function(b,a){var g=this;this._path=b;this.path=b instanceof d.Quoted?/\.(le?|c)ss$/.test(b.value)?b.value:b.value+
|
||||
".less":b.value.value||b.value;(this.css=/css$/.test(this.path))||a.push(this.path,function(e){if(!e)throw Error("Error parsing "+g.path);g.root=e})};d.Import.prototype={toCSS:function(){return this.css?"@import "+this._path.toCSS()+";\n":""},eval:function(b){var a;if(this.css)return this;else{a=new d.Ruleset(null,this.root.rules.slice(0));for(var g=0;g<a.rules.length;g++)a.rules[g]instanceof d.Import&&Array.prototype.splice.apply(a.rules,[g,1].concat(a.rules[g].eval(b)));return a.rules}}}})(s("less/tree"));
|
||||
(function(d){d.JavaScript=function(b,a){this.expression=b;this.index=a};d.JavaScript.prototype={toCSS:function(){return JSON.stringify(this.evaluated)},eval:function(b){var a=new Function("return ("+this.expression+")"),g={},e;for(e in b.frames[0].variables())g[e.slice(1)]={value:b.frames[0].variables()[e].value,toJS:function(){return this.value.eval(b).toCSS()}};try{this.evaluated=a.call(g)}catch(h){throw{message:"JavaScript evaluation error: '"+h.name+": "+h.message+"'",index:this.index};}return this}}})(s("less/tree"));
|
||||
(function(d){d.Keyword=function(b){this.value=b};d.Keyword.prototype={eval:function(){return this},toCSS:function(){return this.value}}})(s("less/tree"));(function(d){d.mixin={};d.mixin.Call=function(b,a,g){this.selector=new d.Selector(b);this.arguments=a;this.index=g};d.mixin.Call.prototype={eval:function(b){for(var a,g=[],e=false,h=0;h<b.frames.length;h++)if((a=b.frames[h].find(this.selector)).length>0){for(h=0;h<a.length;h++)if(a[h].match(this.arguments,b))try{Array.prototype.push.apply(g,a[h].eval(b,
|
||||
this.arguments).rules);e=true}catch(i){throw{message:i.message,index:i.index,stack:i.stack,call:this.index};}if(e)return g;else throw{message:"No matching definition was found for `"+this.selector.toCSS().trim()+"("+this.arguments.map(function(k){return k.toCSS()}).join(", ")+")`",index:this.index};}throw{message:this.selector.toCSS().trim()+" is undefined",index:this.index};}};d.mixin.Definition=function(b,a,g){this.name=b;this.selectors=[new d.Selector([new d.Element(null,b)])];this.params=a;this.arity=
|
||||
a.length;this.rules=g;this._lookups={};this.required=a.reduce(function(e,h){return!h.name||h.name&&!h.value?e+1:e},0);this.parent=d.Ruleset.prototype;this.frames=[]};d.mixin.Definition.prototype={toCSS:function(){return""},variable:function(b){return this.parent.variable.call(this,b)},variables:function(){return this.parent.variables.call(this)},find:function(){return this.parent.find.apply(this,arguments)},rulesets:function(){return this.parent.rulesets.apply(this)},eval:function(b,a){for(var g=
|
||||
new d.Ruleset(null,[]),e=0,h;e<this.params.length;e++)if(this.params[e].name)if(h=a&&a[e]||this.params[e].value)g.rules.unshift(new d.Rule(this.params[e].name,h.eval(b)));else throw{message:"wrong number of arguments for "+this.name+" ("+a.length+" for "+this.arity+")"};return(new d.Ruleset(null,this.rules.slice(0))).eval({frames:[this,g].concat(this.frames,b.frames)})},match:function(b,a){var g=b&&b.length||0;if(g<this.required)return false;if(this.required>0&&g>this.params.length)return false;g=
|
||||
Math.min(g,this.arity);for(var e=0;e<g;e++)if(!this.params[e].name)if(b[e].eval(a).toCSS()!=this.params[e].value.eval(a).toCSS())return false;return true}}})(s("less/tree"));(function(d){d.Operation=function(b,a){this.op=b.trim();this.operands=a};d.Operation.prototype.eval=function(b){var a=this.operands[0].eval(b);b=this.operands[1].eval(b);var g;if(a instanceof d.Dimension&&b instanceof d.Color)if(this.op==="*"||this.op==="+"){g=b;b=a;a=g}else throw{name:"OperationError",message:"Can't substract or divide a color from a number"};
|
||||
return a.operate(this.op,b)};d.operate=function(b,a,g){switch(b){case "+":return a+g;case "-":return a-g;case "*":return a*g;case "/":return a/g}}})(s("less/tree"));(function(d){d.Quoted=function(b,a){this.value=a||"";this.quote=b.charAt(0)};d.Quoted.prototype={toCSS:function(){return this.quote+this.value+this.quote},eval:function(){return this}}})(s("less/tree"));(function(d){d.Rule=function(b,a,g,e){this.name=b;this.value=a instanceof d.Value?a:new d.Value([a]);this.important=g?" "+g.trim():"";
|
||||
this.index=e;this.variable=b.charAt(0)==="@"?true:false};d.Rule.prototype.toCSS=function(b){return this.variable?"":this.name+(b.compress?":":": ")+this.value.toCSS(b)+this.important+";"};d.Rule.prototype.eval=function(b){return new d.Rule(this.name,this.value.eval(b),this.important,this.index)};d.Shorthand=function(b,a){this.a=b;this.b=a};d.Shorthand.prototype={toCSS:function(b){return this.a.toCSS(b)+"/"+this.b.toCSS(b)},eval:function(){return this}}})(s("less/tree"));(function(d){d.Ruleset=function(b,
|
||||
a){this.selectors=b;this.rules=a;this._lookups={}};d.Ruleset.prototype={eval:function(b){var a=new d.Ruleset(this.selectors,this.rules.slice(0));a.root=this.root;b.frames.unshift(a);if(a.root)for(var g=0;g<a.rules.length;g++)a.rules[g]instanceof d.Import&&Array.prototype.splice.apply(a.rules,[g,1].concat(a.rules[g].eval(b)));for(g=0;g<a.rules.length;g++)if(a.rules[g]instanceof d.mixin.Definition)a.rules[g].frames=b.frames.slice(0);for(g=0;g<a.rules.length;g++)a.rules[g]instanceof d.mixin.Call&&Array.prototype.splice.apply(a.rules,
|
||||
[g,1].concat(a.rules[g].eval(b)));g=0;for(var e;g<a.rules.length;g++){e=a.rules[g];e instanceof d.mixin.Definition||(a.rules[g]=e.eval?e.eval(b):e)}b.frames.shift();return a},match:function(b){return!b||b.length===0},variables:function(){return this._variables?this._variables:this._variables=this.rules.reduce(function(b,a){if(a instanceof d.Rule&&a.variable===true)b[a.name]=a;return b},{})},variable:function(b){return this.variables()[b]},rulesets:function(){return this._rulesets?this._rulesets:this._rulesets=
|
||||
this.rules.filter(function(b){return b instanceof d.Ruleset||b instanceof d.mixin.Definition})},find:function(b,a){a=a||this;var g=[],e=b.toCSS();if(e in this._lookups)return this._lookups[e];this.rulesets().forEach(function(h){if(h!==a)for(var i=0;i<h.selectors.length;i++)if(b.match(h.selectors[i])){b.elements.length>1?Array.prototype.push.apply(g,h.find(new d.Selector(b.elements.slice(1)),a)):g.push(h);break}});return this._lookups[e]=g},toCSS:function(b,a){var g=[],e=[],h=[],i=[],k;if(!this.root)if(b.length===
|
||||
0)i=this.selectors.map(function(r){return[r]});else for(k=0;k<this.selectors.length;k++)for(var n=0;n<b.length;n++)i.push(b[n].concat([this.selectors[k]]));for(n=0;n<this.rules.length;n++){k=this.rules[n];if(k.rules||k instanceof d.Directive)h.push(k.toCSS(i,a));else if(k instanceof d.Comment)k.silent||(this.root?h.push(k.toCSS(a)):e.push(k.toCSS(a)));else if(k.toCSS&&!k.variable)e.push(k.toCSS(a));else k.value&&!k.variable&&e.push(k.value.toString())}h=h.join("");if(this.root)g.push(e.join(a.compress?
|
||||
"":"\n"));else if(e.length>0){i=i.map(function(r){return r.map(function(p){return p.toCSS(a)}).join("").trim()}).join(a.compress?",":i.length>3?",\n":", ");g.push(i,(a.compress?"{":" {\n ")+e.join(a.compress?"":"\n ")+(a.compress?"}":"\n}\n"))}g.push(h);return g.join("")+(a.compress?"\n":"")}}})(s("less/tree"));(function(d){d.Selector=function(b){this.elements=b;if(this.elements[0].combinator.value==="")this.elements[0].combinator.value=" "};d.Selector.prototype.match=function(b){return this.elements[0].value===
|
||||
b.elements[0].value?true:false};d.Selector.prototype.toCSS=function(b){if(this._css)return this._css;return this._css=this.elements.map(function(a){return typeof a==="string"?" "+a.trim():a.toCSS(b)}).join("")}})(s("less/tree"));(function(d){d.URL=function(b,a){if(b.data)this.attrs=b;else{if(!/^(?:https?:\/|file:\/)?\//.test(b.value)&&a.length>0&&typeof z!=="undefined")b.value=a[0]+(b.value.charAt(0)==="/"?b.value.slice(1):b.value);this.value=b;this.paths=a}};d.URL.prototype={toCSS:function(){return"url("+
|
||||
(this.attrs?"data:"+this.attrs.mime+this.attrs.charset+this.attrs.base64+this.attrs.data:this.value.toCSS())+")"},eval:function(b){return this.attrs?this:new d.URL(this.value.eval(b),this.paths)}}})(s("less/tree"));(function(d){d.Value=function(b){this.value=b;this.is="value"};d.Value.prototype={eval:function(b){return this.value.length===1?this.value[0].eval(b):new d.Value(this.value.map(function(a){return a.eval(b)}))},toCSS:function(b){return this.value.map(function(a){return a.toCSS(b)}).join(b.compress?
|
||||
",":", ")}}})(s("less/tree"));(function(d){d.Variable=function(b,a){this.name=b;this.index=a};d.Variable.prototype={eval:function(b){var a,g,e=this.name;if(a=d.find(b.frames,function(h){if(g=h.variable(e))return g.value.eval(b)}))return a;else throw{message:"variable "+this.name+" is undefined",index:this.index};}}})(s("less/tree"));s("less/tree").find=function(d,b){for(var a=0,g;a<d.length;a++)if(g=b.call(d,d[a]))return g;return null};var P=location.protocol==="file:"||location.protocol==="chrome:"||
|
||||
location.protocol==="resource:";o.env=o.env||(location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.port.length>0||P?"development":"production");o.async=false;o.poll=o.poll||(P?1E3:1500);o.watch=function(){return this.watchMode=true};o.unwatch=function(){return this.watchMode=false};if(o.env==="development"){o.optimization=0;/!watch/.test(location.hash)&&o.watch();o.watchTimer=setInterval(function(){o.watchMode&&W(function(d,b,a){d&&N(d.toCSS(),b,a.lastModified)})},
|
||||
o.poll)}else o.optimization=3;var B;try{B=typeof z.localStorage==="undefined"?null:z.localStorage}catch(aa){B=null}var M=document.getElementsByTagName("link"),V=/^text\/(x-)?less$/;o.sheets=[];for(var J=0;J<M.length;J++)if(M[J].rel==="stylesheet/less"||M[J].rel.match(/stylesheet/)&&M[J].type.match(V))o.sheets.push(M[J]);o.refresh=function(d){var b=endTime=new Date;W(function(a,g,e){if(e.local)H("loading "+g.href+" from cache.");else{H("parsed "+g.href+" successfully.");N(a.toCSS(),g,e.lastModified)}H("css for "+
|
||||
g.href+" generated in "+(new Date-endTime)+"ms");e.remaining===0&&H("css generated in "+(new Date-b)+"ms");endTime=new Date},d);U()};o.refreshStyles=U;o.refresh(o.env==="development")})(window);
|
||||
39
dist/less-1.0.43.js → dist/less-1.0.44.js
vendored
39
dist/less-1.0.43.js → dist/less-1.0.44.js
vendored
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// LESS - Leaner CSS v1.0.43
|
||||
// LESS - Leaner CSS v1.0.44
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2010, Alexis Sellier
|
||||
@@ -1171,9 +1171,14 @@ less.Parser = function Parser(env) {
|
||||
// such as a Color, or a Variable
|
||||
//
|
||||
operand: function () {
|
||||
return $(this.sub) || $(this.entities.dimension) ||
|
||||
$(this.entities.color) || $(this.entities.variable) ||
|
||||
$(this.entities.call);
|
||||
var negate, p = input.charAt(i + 1);
|
||||
|
||||
if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
|
||||
var o = $(this.sub) || $(this.entities.dimension) ||
|
||||
$(this.entities.color) || $(this.entities.variable) ||
|
||||
$(this.entities.call);
|
||||
return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
|
||||
: o;
|
||||
},
|
||||
|
||||
//
|
||||
@@ -1341,16 +1346,33 @@ tree.functions = {
|
||||
e: function (str) {
|
||||
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
|
||||
},
|
||||
escape: function (str) {
|
||||
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
||||
},
|
||||
'%': function (quoted /* arg, arg, ...*/) {
|
||||
var args = Array.prototype.slice.call(arguments, 1),
|
||||
str = quoted.value;
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
str = str.replace(/%s/, args[i].value)
|
||||
.replace(/%[da]/, args[i].toCSS());
|
||||
str = str.replace(/%[sda]/i, function(token) {
|
||||
var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
|
||||
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
||||
});
|
||||
}
|
||||
str = str.replace(/%%/g, '%');
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
},
|
||||
round: function (n) {
|
||||
if (n instanceof tree.Dimension) {
|
||||
return new(tree.Dimension)(Math.round(number(n)), n.unit);
|
||||
} else if (typeof(n) === 'number') {
|
||||
return Math.round(n);
|
||||
} else {
|
||||
throw {
|
||||
error: "RuntimeError",
|
||||
message: "math functions take numbers as parameters"
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1459,6 +1481,11 @@ tree.Color = function (rgb, a) {
|
||||
this.rgb = rgb.match(/.{2}/g).map(function (c) {
|
||||
return parseInt(c, 16);
|
||||
});
|
||||
} else if (rgb.length == 8) {
|
||||
this.alpha = parseInt(rgb.substring(0,2), 16) / 255.0;
|
||||
this.rgb = rgb.substr(2).match(/.{2}/g).map(function (c) {
|
||||
return parseInt(c, 16);
|
||||
});
|
||||
} else {
|
||||
this.rgb = rgb.split('').map(function (c) {
|
||||
return parseInt(c + c, 16);
|
||||
158
dist/less-1.0.41.js → dist/less-1.1.0.js
vendored
158
dist/less-1.0.41.js → dist/less-1.1.0.js
vendored
@@ -1,8 +1,8 @@
|
||||
//
|
||||
// LESS - Leaner CSS v1.0.41
|
||||
// LESS - Leaner CSS v1.1.0
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2010, Alexis Sellier
|
||||
// Copyright (c) 2009-2011, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
(function (window, undefined) {
|
||||
@@ -229,7 +229,7 @@ less.Parser = function Parser(env) {
|
||||
// Parse from a token, regexp or string, and move forward if match
|
||||
//
|
||||
function $(tok) {
|
||||
var match, args, length, c, index, endIndex, k;
|
||||
var match, args, length, c, index, endIndex, k, mem;
|
||||
|
||||
//
|
||||
// Non-terminal
|
||||
@@ -327,11 +327,12 @@ less.Parser = function Parser(env) {
|
||||
// Split the input into chunks.
|
||||
chunks = (function (chunks) {
|
||||
var j = 0,
|
||||
skip = /[^"'`\{\}\/]+/g,
|
||||
skip = /[^"'`\{\}\/\(\)]+/g,
|
||||
comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
|
||||
level = 0,
|
||||
match,
|
||||
chunk = chunks[0],
|
||||
inParam,
|
||||
inString;
|
||||
|
||||
for (var i = 0, c, cc; i < input.length; i++) {
|
||||
@@ -345,7 +346,7 @@ less.Parser = function Parser(env) {
|
||||
c = input.charAt(i);
|
||||
comment.lastIndex = i;
|
||||
|
||||
if (!inString && c === '/') {
|
||||
if (!inString && !inParam && c === '/') {
|
||||
cc = input.charAt(i + 1);
|
||||
if (cc === '/' || cc === '*') {
|
||||
if (match = comment.exec(input)) {
|
||||
@@ -358,11 +359,17 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
}
|
||||
|
||||
if (c === '{' && !inString) { level ++;
|
||||
if (c === '{' && !inString && !inParam) { level ++;
|
||||
chunk.push(c);
|
||||
} else if (c === '}' && !inString) { level --;
|
||||
} else if (c === '}' && !inString && !inParam) { level --;
|
||||
chunk.push(c);
|
||||
chunks[++j] = chunk = [];
|
||||
} else if (c === '(' && !inString && !inParam) {
|
||||
chunk.push(c);
|
||||
inParam = true;
|
||||
} else if (c === ')' && !inString && inParam) {
|
||||
chunk.push(c);
|
||||
inParam = false;
|
||||
} else {
|
||||
if (c === '"' || c === "'" || c === '`') {
|
||||
if (! inString) {
|
||||
@@ -485,6 +492,7 @@ less.Parser = function Parser(env) {
|
||||
error = {
|
||||
name: "ParseError",
|
||||
message: "Syntax Error on line " + line,
|
||||
index: i,
|
||||
filename: env.filename,
|
||||
line: line,
|
||||
column: column,
|
||||
@@ -584,11 +592,15 @@ less.Parser = function Parser(env) {
|
||||
// "milky way" 'he\'s the one!'
|
||||
//
|
||||
quoted: function () {
|
||||
var str;
|
||||
if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return;
|
||||
var str, j = i, e;
|
||||
|
||||
if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
|
||||
if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return;
|
||||
|
||||
e && $('~');
|
||||
|
||||
if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
|
||||
return new(tree.Quoted)(str[0], str[1] || str[2]);
|
||||
return new(tree.Quoted)(str[0], str[1] || str[2], e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -620,10 +632,12 @@ less.Parser = function Parser(env) {
|
||||
name = name[1].toLowerCase();
|
||||
|
||||
if (name === 'url') { return null }
|
||||
else { i += name.length + 1 }
|
||||
else { i += name.length }
|
||||
|
||||
if (name === 'alpha') { return $(this.alpha) }
|
||||
|
||||
$('('); // Parse the '(' and consume whitespace.
|
||||
|
||||
args = $(this.entities.arguments);
|
||||
|
||||
if (! $(')')) return;
|
||||
@@ -657,7 +671,7 @@ less.Parser = function Parser(env) {
|
||||
|
||||
if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
|
||||
value = $(this.entities.quoted) || $(this.entities.variable) ||
|
||||
$(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?]+/) || "";
|
||||
$(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || "";
|
||||
if (! $(')')) throw new(Error)("missing closing ) for url()");
|
||||
|
||||
return new(tree.URL)((value.value || value.data || value instanceof tree.Variable)
|
||||
@@ -689,7 +703,7 @@ less.Parser = function Parser(env) {
|
||||
variable: function () {
|
||||
var name, index = i;
|
||||
|
||||
if (input.charAt(i) === '@' && (name = $(/^@[\w-]+/))) {
|
||||
if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) {
|
||||
return new(tree.Variable)(name, index);
|
||||
}
|
||||
},
|
||||
@@ -729,12 +743,15 @@ less.Parser = function Parser(env) {
|
||||
// `window.location.href`
|
||||
//
|
||||
javascript: function () {
|
||||
var str;
|
||||
var str, j = i, e;
|
||||
|
||||
if (input.charAt(i) !== '`') { return }
|
||||
if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
|
||||
if (input.charAt(j) !== '`') { return }
|
||||
|
||||
e && $('~');
|
||||
|
||||
if (str = $(/^`([^`]*)`/)) {
|
||||
return new(tree.JavaScript)(str[1], i);
|
||||
return new(tree.JavaScript)(str[1], i, e);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -861,7 +878,8 @@ less.Parser = function Parser(env) {
|
||||
//
|
||||
entity: function () {
|
||||
return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
|
||||
$(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript);
|
||||
$(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) ||
|
||||
$(this.comment);
|
||||
},
|
||||
|
||||
//
|
||||
@@ -901,7 +919,7 @@ less.Parser = function Parser(env) {
|
||||
// and an element name, such as a tag a class, or `*`.
|
||||
//
|
||||
element: function () {
|
||||
var e, t;
|
||||
var e, t, c;
|
||||
|
||||
c = $(this.combinator);
|
||||
e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/);
|
||||
@@ -1000,9 +1018,10 @@ less.Parser = function Parser(env) {
|
||||
} else {
|
||||
while (s = $(this.selector)) {
|
||||
selectors.push(s);
|
||||
$(this.comment);
|
||||
if (! $(',')) { break }
|
||||
$(this.comment);
|
||||
}
|
||||
if (s) $(this.comment);
|
||||
}
|
||||
|
||||
if (selectors.length > 0 && (rules = $(this.block))) {
|
||||
@@ -1014,7 +1033,7 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
},
|
||||
rule: function () {
|
||||
var name, value, c = input.charAt(i), important;
|
||||
var name, value, c = input.charAt(i), important, match;
|
||||
save();
|
||||
|
||||
if (c === '.' || c === '#' || c === '&') { return }
|
||||
@@ -1070,7 +1089,7 @@ less.Parser = function Parser(env) {
|
||||
|
||||
if (value = $(this['import'])) {
|
||||
return value;
|
||||
} else if (name = $(/^@media|@page/)) {
|
||||
} else if (name = $(/^@media|@page|@-[-a-z]+/)) {
|
||||
types = ($(/^[^{]+/) || '').trim();
|
||||
if (rules = $(this.block)) {
|
||||
return new(tree.Directive)(name + " " + types, rules);
|
||||
@@ -1159,9 +1178,14 @@ less.Parser = function Parser(env) {
|
||||
// such as a Color, or a Variable
|
||||
//
|
||||
operand: function () {
|
||||
return $(this.sub) || $(this.entities.dimension) ||
|
||||
$(this.entities.color) || $(this.entities.variable) ||
|
||||
$(this.entities.call);
|
||||
var negate, p = input.charAt(i + 1);
|
||||
|
||||
if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
|
||||
var o = $(this.sub) || $(this.entities.dimension) ||
|
||||
$(this.entities.color) || $(this.entities.variable) ||
|
||||
$(this.entities.call);
|
||||
return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
|
||||
: o;
|
||||
},
|
||||
|
||||
//
|
||||
@@ -1329,16 +1353,33 @@ tree.functions = {
|
||||
e: function (str) {
|
||||
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
|
||||
},
|
||||
escape: function (str) {
|
||||
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
||||
},
|
||||
'%': function (quoted /* arg, arg, ...*/) {
|
||||
var args = Array.prototype.slice.call(arguments, 1),
|
||||
str = quoted.value;
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
str = str.replace(/%s/, args[i].value)
|
||||
.replace(/%[da]/, args[i].toCSS());
|
||||
str = str.replace(/%[sda]/i, function(token) {
|
||||
var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
|
||||
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
||||
});
|
||||
}
|
||||
str = str.replace(/%%/g, '%');
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
},
|
||||
round: function (n) {
|
||||
if (n instanceof tree.Dimension) {
|
||||
return new(tree.Dimension)(Math.round(number(n)), n.unit);
|
||||
} else if (typeof(n) === 'number') {
|
||||
return Math.round(n);
|
||||
} else {
|
||||
throw {
|
||||
error: "RuntimeError",
|
||||
message: "math functions take numbers as parameters"
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1447,6 +1488,11 @@ tree.Color = function (rgb, a) {
|
||||
this.rgb = rgb.match(/.{2}/g).map(function (c) {
|
||||
return parseInt(c, 16);
|
||||
});
|
||||
} else if (rgb.length == 8) {
|
||||
this.alpha = parseInt(rgb.substring(0,2), 16) / 255.0;
|
||||
this.rgb = rgb.substr(2).match(/.{2}/g).map(function (c) {
|
||||
return parseInt(c, 16);
|
||||
});
|
||||
} else {
|
||||
this.rgb = rgb.split('').map(function (c) {
|
||||
return parseInt(c + c, 16);
|
||||
@@ -1493,7 +1539,7 @@ tree.Color.prototype = {
|
||||
for (var c = 0; c < 3; c++) {
|
||||
result[c] = tree.operate(op, this.rgb[c], other.rgb[c]);
|
||||
}
|
||||
return new(tree.Color)(result);
|
||||
return new(tree.Color)(result, this.alpha + other.alpha);
|
||||
},
|
||||
|
||||
toHSL: function () {
|
||||
@@ -1736,19 +1782,29 @@ tree.Import.prototype = {
|
||||
})(require('less/tree'));
|
||||
(function (tree) {
|
||||
|
||||
tree.JavaScript = function (string, index) {
|
||||
tree.JavaScript = function (string, index, escaped) {
|
||||
this.escaped = escaped;
|
||||
this.expression = string;
|
||||
this.index = index;
|
||||
};
|
||||
tree.JavaScript.prototype = {
|
||||
toCSS: function () {
|
||||
return JSON.stringify(this.evaluated);
|
||||
if (this.escaped) {
|
||||
return this.evaluated;
|
||||
} else {
|
||||
return JSON.stringify(this.evaluated);
|
||||
}
|
||||
},
|
||||
eval: function (env) {
|
||||
var result,
|
||||
expression = new(Function)('return (' + this.expression + ')'),
|
||||
context = {};
|
||||
|
||||
var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
|
||||
return new(tree.Variable)('@' + name).eval(env).value;
|
||||
});
|
||||
|
||||
expression = new(Function)('return (' + expression + ')');
|
||||
|
||||
for (var k in env.frames[0].variables()) {
|
||||
context[k.slice(1)] = {
|
||||
value: env.frames[0].variables()[k].value,
|
||||
@@ -1843,7 +1899,7 @@ tree.mixin.Definition.prototype = {
|
||||
rulesets: function () { return this.parent.rulesets.apply(this) },
|
||||
|
||||
eval: function (env, args) {
|
||||
var frame = new(tree.Ruleset)(null, []), context;
|
||||
var frame = new(tree.Ruleset)(null, []), context, _arguments = [];
|
||||
|
||||
for (var i = 0, val; i < this.params.length; i++) {
|
||||
if (this.params[i].name) {
|
||||
@@ -1855,6 +1911,11 @@ tree.mixin.Definition.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) {
|
||||
_arguments.push(args[i] || this.params[i].value);
|
||||
}
|
||||
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments)));
|
||||
|
||||
return new(tree.Ruleset)(null, this.rules.slice(0)).eval({
|
||||
frames: [this, frame].concat(this.frames, env.frames)
|
||||
});
|
||||
@@ -1913,15 +1974,26 @@ tree.operate = function (op, a, b) {
|
||||
})(require('less/tree'));
|
||||
(function (tree) {
|
||||
|
||||
tree.Quoted = function (str, content) {
|
||||
tree.Quoted = function (str, content, escaped, i) {
|
||||
this.escaped = escaped;
|
||||
this.value = content || '';
|
||||
this.quote = str.charAt(0);
|
||||
this.index = i;
|
||||
};
|
||||
tree.Quoted.prototype = {
|
||||
toCSS: function () {
|
||||
return this.quote + this.value + this.quote;
|
||||
if (this.escaped) {
|
||||
return this.value;
|
||||
} else {
|
||||
return this.quote + this.value + this.quote;
|
||||
}
|
||||
},
|
||||
eval: function () {
|
||||
eval: function (env) {
|
||||
this.value = this.value.replace(/@\{([\w-]+)\}/g, function (_, name) {
|
||||
return new(tree.Variable)('@' + name).eval(env).value;
|
||||
}).replace(/`([^`]+)`/g, function (_, exp) {
|
||||
return new(tree.JavaScript)(exp, this.index, true).eval(env).toCSS();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
};
|
||||
@@ -2179,7 +2251,7 @@ tree.URL = function (val, paths) {
|
||||
this.attrs = val;
|
||||
} else {
|
||||
// Add the base path if the URL is relative and we are in the browser
|
||||
if (!/^(?:https?:\/|file:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
|
||||
if (!/^(?:https?:\/|file:\/|data:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
|
||||
val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
|
||||
}
|
||||
this.value = val;
|
||||
@@ -2228,13 +2300,17 @@ tree.Variable.prototype = {
|
||||
eval: function (env) {
|
||||
var variable, v, name = this.name;
|
||||
|
||||
if (name.indexOf('@@') == 0) {
|
||||
name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
|
||||
}
|
||||
|
||||
if (variable = tree.find(env.frames, function (frame) {
|
||||
if (v = frame.variable(name)) {
|
||||
return v.value.eval(env);
|
||||
}
|
||||
})) { return variable }
|
||||
else {
|
||||
throw { message: "variable " + this.name + " is undefined",
|
||||
throw { message: "variable " + name + " is undefined",
|
||||
index: this.index };
|
||||
}
|
||||
}
|
||||
@@ -2253,6 +2329,7 @@ require('less/tree').find = function (obj, fun) {
|
||||
|
||||
var isFileProtocol = (location.protocol === 'file:' ||
|
||||
location.protocol === 'chrome:' ||
|
||||
location.protocol === 'chrome-extension:' ||
|
||||
location.protocol === 'resource:');
|
||||
|
||||
less.env = less.env || (location.hostname == '127.0.0.1' ||
|
||||
@@ -2323,7 +2400,8 @@ for (var i = 0; i < links.length; i++) {
|
||||
|
||||
|
||||
less.refresh = function (reload) {
|
||||
var startTime = endTime = new(Date);
|
||||
var startTime, endTime;
|
||||
startTime = endTime = new(Date);
|
||||
|
||||
loadStyleSheets(function (root, sheet, env) {
|
||||
if (env.local) {
|
||||
@@ -2370,7 +2448,11 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
|
||||
// Stylesheets in IE don't always return the full path
|
||||
if (! /^(https?|file):/.test(href)) {
|
||||
href = url.slice(0, url.lastIndexOf('/') + 1) + href;
|
||||
if (href.charAt(0) == "/") {
|
||||
href = window.location.protocol + "//" + window.location.host + href;
|
||||
} else {
|
||||
href = url.slice(0, url.lastIndexOf('/') + 1) + href;
|
||||
}
|
||||
}
|
||||
|
||||
xhr(sheet.href, sheet.type, function (data, lastModified) {
|
||||
16
dist/less-1.1.0.min.js
vendored
Normal file
16
dist/less-1.1.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2710
dist/less-1.1.1.js
vendored
Normal file
2710
dist/less-1.1.1.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
dist/less-1.1.1.min.js
vendored
Normal file
16
dist/less-1.1.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2712
dist/less-1.1.2.js
vendored
Normal file
2712
dist/less-1.1.2.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
dist/less-1.1.2.min.js
vendored
Normal file
16
dist/less-1.1.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2721
dist/less-1.1.3.js
vendored
Normal file
2721
dist/less-1.1.3.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
dist/less-1.1.3.min.js
vendored
Normal file
16
dist/less-1.1.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -4,6 +4,7 @@
|
||||
|
||||
var isFileProtocol = (location.protocol === 'file:' ||
|
||||
location.protocol === 'chrome:' ||
|
||||
location.protocol === 'chrome-extension:' ||
|
||||
location.protocol === 'resource:');
|
||||
|
||||
less.env = less.env || (location.hostname == '127.0.0.1' ||
|
||||
@@ -122,7 +123,11 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
|
||||
// Stylesheets in IE don't always return the full path
|
||||
if (! /^(https?|file):/.test(href)) {
|
||||
href = url.slice(0, url.lastIndexOf('/') + 1) + href;
|
||||
if (href.charAt(0) == "/") {
|
||||
href = window.location.protocol + "//" + window.location.host + href;
|
||||
} else {
|
||||
href = url.slice(0, url.lastIndexOf('/') + 1) + href;
|
||||
}
|
||||
}
|
||||
|
||||
xhr(sheet.href, sheet.type, function (data, lastModified) {
|
||||
|
||||
@@ -120,16 +120,33 @@ tree.functions = {
|
||||
e: function (str) {
|
||||
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
|
||||
},
|
||||
escape: function (str) {
|
||||
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
||||
},
|
||||
'%': function (quoted /* arg, arg, ...*/) {
|
||||
var args = Array.prototype.slice.call(arguments, 1),
|
||||
str = quoted.value;
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
str = str.replace(/%s/, args[i].value)
|
||||
.replace(/%[da]/, args[i].toCSS());
|
||||
str = str.replace(/%[sda]/i, function(token) {
|
||||
var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
|
||||
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
||||
});
|
||||
}
|
||||
str = str.replace(/%%/g, '%');
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
},
|
||||
round: function (n) {
|
||||
if (n instanceof tree.Dimension) {
|
||||
return new(tree.Dimension)(Math.round(number(n)), n.unit);
|
||||
} else if (typeof(n) === 'number') {
|
||||
return Math.round(n);
|
||||
} else {
|
||||
throw {
|
||||
error: "RuntimeError",
|
||||
message: "math functions take numbers as parameters"
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ var path = require('path'),
|
||||
require.paths.unshift(path.join(__dirname, '..'));
|
||||
|
||||
var less = {
|
||||
version: [1, 0, 43],
|
||||
version: [1, 1, 3],
|
||||
Parser: require('less/parser').Parser,
|
||||
importer: require('less/parser').importer,
|
||||
tree: require('less/tree'),
|
||||
|
||||
@@ -457,11 +457,15 @@ less.Parser = function Parser(env) {
|
||||
// "milky way" 'he\'s the one!'
|
||||
//
|
||||
quoted: function () {
|
||||
var str;
|
||||
if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return;
|
||||
var str, j = i, e;
|
||||
|
||||
if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
|
||||
if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return;
|
||||
|
||||
e && $('~');
|
||||
|
||||
if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
|
||||
return new(tree.Quoted)(str[0], str[1] || str[2]);
|
||||
return new(tree.Quoted)(str[0], str[1] || str[2], e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -486,7 +490,7 @@ less.Parser = function Parser(env) {
|
||||
// The arguments are parsed with the `entities.arguments` parser.
|
||||
//
|
||||
call: function () {
|
||||
var name, args;
|
||||
var name, args, index = i;
|
||||
|
||||
if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
|
||||
|
||||
@@ -503,7 +507,7 @@ less.Parser = function Parser(env) {
|
||||
|
||||
if (! $(')')) return;
|
||||
|
||||
if (name) { return new(tree.Call)(name, args) }
|
||||
if (name) { return new(tree.Call)(name, args, index) }
|
||||
},
|
||||
arguments: function () {
|
||||
var args = [], arg;
|
||||
@@ -532,7 +536,7 @@ less.Parser = function Parser(env) {
|
||||
|
||||
if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
|
||||
value = $(this.entities.quoted) || $(this.entities.variable) ||
|
||||
$(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?]+/) || "";
|
||||
$(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || "";
|
||||
if (! $(')')) throw new(Error)("missing closing ) for url()");
|
||||
|
||||
return new(tree.URL)((value.value || value.data || value instanceof tree.Variable)
|
||||
@@ -564,7 +568,7 @@ less.Parser = function Parser(env) {
|
||||
variable: function () {
|
||||
var name, index = i;
|
||||
|
||||
if (input.charAt(i) === '@' && (name = $(/^@[\w-]+/))) {
|
||||
if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) {
|
||||
return new(tree.Variable)(name, index);
|
||||
}
|
||||
},
|
||||
@@ -604,12 +608,15 @@ less.Parser = function Parser(env) {
|
||||
// `window.location.href`
|
||||
//
|
||||
javascript: function () {
|
||||
var str;
|
||||
var str, j = i, e;
|
||||
|
||||
if (input.charAt(i) !== '`') { return }
|
||||
if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
|
||||
if (input.charAt(j) !== '`') { return }
|
||||
|
||||
e && $('~');
|
||||
|
||||
if (str = $(/^`([^`]*)`/)) {
|
||||
return new(tree.JavaScript)(str[1], i);
|
||||
return new(tree.JavaScript)(str[1], i, e);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -757,7 +764,7 @@ less.Parser = function Parser(env) {
|
||||
alpha: function () {
|
||||
var value;
|
||||
|
||||
if (! $(/^opacity=/i)) return;
|
||||
if (! $(/^\(opacity=/i)) return;
|
||||
if (value = $(/^\d+/) || $(this.entities.variable)) {
|
||||
if (! $(')')) throw new(Error)("missing closing ) for alpha()");
|
||||
return new(tree.Alpha)(value);
|
||||
@@ -1036,9 +1043,14 @@ less.Parser = function Parser(env) {
|
||||
// such as a Color, or a Variable
|
||||
//
|
||||
operand: function () {
|
||||
return $(this.sub) || $(this.entities.dimension) ||
|
||||
$(this.entities.color) || $(this.entities.variable) ||
|
||||
$(this.entities.call);
|
||||
var negate, p = input.charAt(i + 1);
|
||||
|
||||
if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
|
||||
var o = $(this.sub) || $(this.entities.dimension) ||
|
||||
$(this.entities.color) || $(this.entities.variable) ||
|
||||
$(this.entities.call);
|
||||
return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
|
||||
: o;
|
||||
},
|
||||
|
||||
//
|
||||
|
||||
@@ -4,3 +4,10 @@ require('less/tree').find = function (obj, fun) {
|
||||
}
|
||||
return null;
|
||||
};
|
||||
require('less/tree').jsify = function (obj) {
|
||||
if (Array.isArray(obj.value) && (obj.value.length > 1)) {
|
||||
return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']';
|
||||
} else {
|
||||
return obj.toCSS(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,10 @@ tree.Alpha.prototype = {
|
||||
return "alpha(opacity=" +
|
||||
(this.value.toCSS ? this.value.toCSS() : this.value) + ")";
|
||||
},
|
||||
eval: function () { return this }
|
||||
eval: function (env) {
|
||||
if (this.value.eval) { this.value = this.value.eval(env) }
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
})(require('less/tree'));
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
//
|
||||
// A function call node.
|
||||
//
|
||||
tree.Call = function (name, args) {
|
||||
tree.Call = function (name, args, index) {
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
this.index = index;
|
||||
};
|
||||
tree.Call.prototype = {
|
||||
//
|
||||
@@ -24,7 +25,12 @@ tree.Call.prototype = {
|
||||
var args = this.args.map(function (a) { return a.eval(env) });
|
||||
|
||||
if (this.name in tree.functions) { // 1.
|
||||
return tree.functions[this.name].apply(tree.functions, args);
|
||||
try {
|
||||
return tree.functions[this.name].apply(tree.functions, args);
|
||||
} catch (e) {
|
||||
throw { message: "error evaluating function `" + this.name + "`",
|
||||
index: this.index };
|
||||
}
|
||||
} else { // 2.
|
||||
return new(tree.Anonymous)(this.name +
|
||||
"(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
|
||||
|
||||
@@ -7,8 +7,10 @@ tree.Expression.prototype = {
|
||||
return new(tree.Expression)(this.value.map(function (e) {
|
||||
return e.eval(env);
|
||||
}));
|
||||
} else {
|
||||
} else if (this.value.length === 1) {
|
||||
return this.value[0].eval(env);
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
},
|
||||
toCSS: function (env) {
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.JavaScript = function (string, index) {
|
||||
tree.JavaScript = function (string, index, escaped) {
|
||||
this.escaped = escaped;
|
||||
this.expression = string;
|
||||
this.index = index;
|
||||
};
|
||||
tree.JavaScript.prototype = {
|
||||
toCSS: function () {
|
||||
return JSON.stringify(this.evaluated);
|
||||
},
|
||||
eval: function (env) {
|
||||
var result,
|
||||
expression = new(Function)('return (' + this.expression + ')'),
|
||||
that = this,
|
||||
context = {};
|
||||
|
||||
var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
|
||||
return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env));
|
||||
});
|
||||
|
||||
try {
|
||||
expression = new(Function)('return (' + expression + ')');
|
||||
} catch (e) {
|
||||
throw { message: "JavaScript evaluation error: `" + expression + "`" ,
|
||||
index: this.index };
|
||||
}
|
||||
|
||||
for (var k in env.frames[0].variables()) {
|
||||
context[k.slice(1)] = {
|
||||
value: env.frames[0].variables()[k].value,
|
||||
@@ -23,12 +32,18 @@ tree.JavaScript.prototype = {
|
||||
}
|
||||
|
||||
try {
|
||||
this.evaluated = expression.call(context);
|
||||
result = expression.call(context);
|
||||
} catch (e) {
|
||||
throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
|
||||
index: this.index };
|
||||
}
|
||||
return this;
|
||||
if (typeof(result) === 'string') {
|
||||
return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index);
|
||||
} else if (Array.isArray(result)) {
|
||||
return new(tree.Anonymous)(result.join(', '));
|
||||
} else {
|
||||
return new(tree.Anonymous)(result);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@ tree.mixin.Call = function (elements, args, index) {
|
||||
};
|
||||
tree.mixin.Call.prototype = {
|
||||
eval: function (env) {
|
||||
var mixins, rules = [], match = false;
|
||||
var mixins, args, rules = [], match = false;
|
||||
|
||||
for (var i = 0; i < env.frames.length; i++) {
|
||||
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
|
||||
args = this.arguments && this.arguments.map(function (a) { return a.eval(env) });
|
||||
for (var m = 0; m < mixins.length; m++) {
|
||||
if (mixins[m].match(this.arguments, env)) {
|
||||
if (mixins[m].match(args, env)) {
|
||||
try {
|
||||
Array.prototype.push.apply(
|
||||
rules, mixins[m].eval(env, this.arguments).rules);
|
||||
@@ -62,7 +63,7 @@ tree.mixin.Definition.prototype = {
|
||||
rulesets: function () { return this.parent.rulesets.apply(this) },
|
||||
|
||||
eval: function (env, args) {
|
||||
var frame = new(tree.Ruleset)(null, []), context;
|
||||
var frame = new(tree.Ruleset)(null, []), context, _arguments = [];
|
||||
|
||||
for (var i = 0, val; i < this.params.length; i++) {
|
||||
if (this.params[i].name) {
|
||||
@@ -74,7 +75,10 @@ tree.mixin.Definition.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(args)));
|
||||
for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) {
|
||||
_arguments.push(args[i] || this.params[i].value);
|
||||
}
|
||||
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
|
||||
|
||||
return new(tree.Ruleset)(null, this.rules.slice(0)).eval({
|
||||
frames: [this, frame].concat(this.frames, env.frames)
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Quoted = function (str, content) {
|
||||
tree.Quoted = function (str, content, escaped, i) {
|
||||
this.escaped = escaped;
|
||||
this.value = content || '';
|
||||
this.quote = str.charAt(0);
|
||||
this.index = i;
|
||||
};
|
||||
tree.Quoted.prototype = {
|
||||
toCSS: function () {
|
||||
return this.quote + this.value + this.quote;
|
||||
if (this.escaped) {
|
||||
return this.value;
|
||||
} else {
|
||||
return this.quote + this.value + this.quote;
|
||||
}
|
||||
},
|
||||
eval: function () {
|
||||
return this;
|
||||
eval: function (env) {
|
||||
var that = this;
|
||||
var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
|
||||
return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
|
||||
}).replace(/@\{([\w-]+)\}/g, function (_, name) {
|
||||
var v = new(tree.Variable)('@' + name, that.index).eval(env);
|
||||
return v.value || v.toCSS();
|
||||
});
|
||||
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ tree.URL = function (val, paths) {
|
||||
this.attrs = val;
|
||||
} else {
|
||||
// Add the base path if the URL is relative and we are in the browser
|
||||
if (!/^(?:https?:\/|file:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
|
||||
if (!/^(?:https?:\/|file:\/|data:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
|
||||
val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
|
||||
}
|
||||
this.value = val;
|
||||
|
||||
@@ -5,13 +5,17 @@ tree.Variable.prototype = {
|
||||
eval: function (env) {
|
||||
var variable, v, name = this.name;
|
||||
|
||||
if (name.indexOf('@@') == 0) {
|
||||
name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
|
||||
}
|
||||
|
||||
if (variable = tree.find(env.frames, function (frame) {
|
||||
if (v = frame.variable(name)) {
|
||||
return v.value.eval(env);
|
||||
}
|
||||
})) { return variable }
|
||||
else {
|
||||
throw { message: "variable " + this.name + " is undefined",
|
||||
throw { message: "variable " + name + " is undefined",
|
||||
index: this.index };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"keywords" : ["css", "parser", "lesscss", "browser"],
|
||||
"author" : "Alexis Sellier <self@cloudhead.net>",
|
||||
"contributors" : [],
|
||||
"version" : "1.0.43",
|
||||
"version" : "1.1.3",
|
||||
"bin" : { "lessc": "./bin/lessc" },
|
||||
"main" : "./lib/less/index",
|
||||
"directories" : { "test": "./test" },
|
||||
|
||||
@@ -66,6 +66,7 @@ p + h1 {
|
||||
background-image: url(images/image.jpg);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(red), to(blue));
|
||||
margin: ;
|
||||
filter: alpha(opacity=100);
|
||||
}
|
||||
#important {
|
||||
color: red !important;
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
spin-n: #bf4055;
|
||||
format: "rgb(32, 128, 64)";
|
||||
format-string: "hello world";
|
||||
format-multiple: "hello earth 2";
|
||||
format-url-encode: "red is %23ff0000";
|
||||
eformat: rgb(32, 128, 64);
|
||||
hue: 98;
|
||||
saturation: 12%;
|
||||
lightness: 95%;
|
||||
rounded: 11;
|
||||
roundedpx: 3px;
|
||||
}
|
||||
#alpha {
|
||||
alpha: rgba(153, 94, 51, 0.6);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
js: 42;
|
||||
js: 2;
|
||||
js: "hello world";
|
||||
sigkill: 9;
|
||||
js: 1, 2, 3;
|
||||
title: "node";
|
||||
ternary: true;
|
||||
}
|
||||
.scope {
|
||||
@@ -12,3 +13,10 @@
|
||||
.vars {
|
||||
width: 8;
|
||||
}
|
||||
.escape-interpol {
|
||||
width: hello world;
|
||||
}
|
||||
.arrays {
|
||||
ary: "1, 2, 3";
|
||||
ary: "1, 2, 3";
|
||||
}
|
||||
|
||||
@@ -56,3 +56,6 @@ body {
|
||||
.arguments {
|
||||
border: 1px solid black;
|
||||
}
|
||||
.arguments2 {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
@@ -35,3 +35,12 @@
|
||||
color: #222222;
|
||||
border-color: #222222;
|
||||
}
|
||||
.negations {
|
||||
variable: -4px;
|
||||
variable1: 0px;
|
||||
variable2: 0px;
|
||||
variable3: 8px;
|
||||
variable4: 0px;
|
||||
paren: -4px;
|
||||
paren2: 16px;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,25 @@
|
||||
empty: '';
|
||||
semi-colon: ';';
|
||||
}
|
||||
#escaped {
|
||||
filter: DX.Transform.MS.BS.filter(opacity=50);
|
||||
}
|
||||
#one-line {
|
||||
image: url(http://tooks.com);
|
||||
}
|
||||
#crazy {
|
||||
image: url(http://), "}", url("http://}");
|
||||
}
|
||||
#interpolation {
|
||||
url: "http://lesscss.org/dev/image.jpg";
|
||||
url2: "http://lesscss.org/image-256.jpg";
|
||||
url3: "http://lesscss.org#445566";
|
||||
url4: "http://lesscss.org/hello";
|
||||
url5: "http://lesscss.org/54.4";
|
||||
}
|
||||
.mix-mul-class {
|
||||
color: blue;
|
||||
color: red;
|
||||
color: blue;
|
||||
color: orange;
|
||||
}
|
||||
|
||||
@@ -16,3 +16,9 @@
|
||||
url: url('Trebuchet');
|
||||
multi: something 'A', B, C, 'Trebuchet';
|
||||
}
|
||||
.variable-names {
|
||||
name: 'hello';
|
||||
}
|
||||
.alpha {
|
||||
filter: alpha(opacity=42);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ p + h1 {
|
||||
background-image: url(images/image.jpg);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(red), to(blue));
|
||||
margin: ;
|
||||
filter: alpha(opacity=100);
|
||||
}
|
||||
|
||||
#important {
|
||||
|
||||
@@ -19,11 +19,15 @@
|
||||
spin-n: spin(hsl(30, 50%, 50%), -40);
|
||||
format: %("rgb(%d, %d, %d)", @r, 128, 64);
|
||||
format-string: %("hello %s", "world");
|
||||
format-multiple: %("hello %s %d", "earth", 2);
|
||||
format-url-encode: %('red is %A', #ff0000);
|
||||
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));
|
||||
|
||||
hue: hue(hsl(98, 12%, 95%));
|
||||
saturation: saturation(hsl(98, 12%, 95%));
|
||||
lightness: lightness(hsl(98, 12%, 95%));
|
||||
rounded: round(@r/3);
|
||||
roundedpx: round(10px / 3);
|
||||
}
|
||||
|
||||
#alpha {
|
||||
|
||||
@@ -2,15 +2,26 @@
|
||||
js: `42`;
|
||||
js: `1 + 1`;
|
||||
js: `"hello world"`;
|
||||
sigkill: `process.SIGKILL`;
|
||||
js: `[1, 2, 3]`;
|
||||
title: `process.title`;
|
||||
ternary: `(1 + 1 == 2 ? true : false)`;
|
||||
}
|
||||
.scope {
|
||||
@foo: 42;
|
||||
var: `this.foo.toJS()`;
|
||||
escaped: e(`2 + 5 + 'px'`);
|
||||
escaped: ~`2 + 5 + 'px'`;
|
||||
}
|
||||
.vars {
|
||||
@var: `4 + 4`;
|
||||
width: @var;
|
||||
}
|
||||
.escape-interpol {
|
||||
@world: "world";
|
||||
width: ~`"hello" + " " + @{world}`;
|
||||
}
|
||||
.arrays {
|
||||
@ary: 1, 2, 3;
|
||||
@ary2: 1 2 3;
|
||||
ary: `@{ary}.join(', ')`;
|
||||
ary: `@{ary2}.join(', ')`;
|
||||
}
|
||||
|
||||
@@ -106,10 +106,13 @@ body {
|
||||
#id-mixin;
|
||||
}
|
||||
|
||||
.mixin-arguments () {
|
||||
border: @arguments;
|
||||
.mixin-arguments (@width: 0px) {
|
||||
border: @arguments;
|
||||
}
|
||||
|
||||
.arguments {
|
||||
.mixin-arguments(1px, solid, black);
|
||||
.mixin-arguments(1px, solid, black);
|
||||
}
|
||||
.arguments2 {
|
||||
.mixin-arguments();
|
||||
}
|
||||
|
||||
@@ -45,3 +45,14 @@
|
||||
border-color: #333333 / 3 + #111; // #222222
|
||||
}
|
||||
}
|
||||
|
||||
.negations {
|
||||
@var: 4px;
|
||||
variable: -@var; // 4
|
||||
variable1: -@var + @var; // 0
|
||||
variable2: @var + -@var; // 0
|
||||
variable3: @var - -@var; // 8
|
||||
variable4: -@var - -@var; // 0
|
||||
paren: -(@var); // -4px
|
||||
paren2: -(2 + 2) * -@var; // 16
|
||||
}
|
||||
|
||||
@@ -14,5 +14,36 @@
|
||||
empty: '';
|
||||
semi-colon: ';';
|
||||
}
|
||||
#escaped {
|
||||
filter: ~"DX.Transform.MS.BS.filter(opacity=50)";
|
||||
}
|
||||
#one-line { image: url(http://tooks.com) }
|
||||
#crazy { image: url(http://), "}", url("http://}") }
|
||||
#interpolation {
|
||||
@var: '/dev';
|
||||
url: "http://lesscss.org@{var}/image.jpg";
|
||||
|
||||
@var2: 256;
|
||||
url2: "http://lesscss.org/image-@{var2}.jpg";
|
||||
|
||||
@var3: #456;
|
||||
url3: "http://lesscss.org@{var3}";
|
||||
|
||||
@var4: hello;
|
||||
url4: "http://lesscss.org/@{var4}";
|
||||
|
||||
@var5: 54.4px;
|
||||
url5: "http://lesscss.org/@{var5}";
|
||||
}
|
||||
|
||||
// multiple calls with string interpolation
|
||||
|
||||
.mix-mul (@a: green) {
|
||||
color: ~"@{a}";
|
||||
}
|
||||
.mix-mul-class {
|
||||
.mix-mul(blue);
|
||||
.mix-mul(red);
|
||||
.mix-mul(blue);
|
||||
.mix-mul(orange);
|
||||
}
|
||||
|
||||
@@ -38,3 +38,13 @@
|
||||
url: url(@a);
|
||||
multi: something @multi, @a;
|
||||
}
|
||||
|
||||
.variable-names {
|
||||
@var: 'hello';
|
||||
@name: 'var';
|
||||
name: @@name;
|
||||
}
|
||||
.alpha {
|
||||
@var: 42;
|
||||
filter: alpha(opacity=@var);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user