carto/lib/less/tree/rule.js

38 lines
995 B
JavaScript
Raw Normal View History

(function (tree) {
2010-02-24 02:39:05 +08:00
2010-06-28 04:40:12 +08:00
tree.Rule = function (name, value, important, index) {
2010-02-24 02:39:05 +08:00
this.name = name;
this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
2010-06-28 04:40:12 +08:00
this.important = important ? ' ' + important.trim() : '';
this.index = index;
2010-02-24 02:39:05 +08:00
if (name.charAt(0) === '@') {
this.variable = true;
} else { this.variable = false }
};
2010-06-12 09:45:51 +08:00
tree.Rule.prototype.toCSS = function (env) {
2010-02-26 06:56:21 +08:00
if (this.variable) { return "" }
else {
2010-12-02 04:33:17 +08:00
return '<CssParameter name="' + this.name + '">' +
this.value.toCSS(env) + '</CssParameter>';
2010-02-26 06:56:21 +08:00
}
2010-02-24 02:39:05 +08:00
};
tree.Rule.prototype.eval = function (context) {
2010-06-28 04:40:12 +08:00
return new(tree.Rule)(this.name, this.value.eval(context), this.important, this.index);
};
2010-06-19 13:51:26 +08:00
tree.Shorthand = function (a, b) {
this.a = a;
this.b = b;
};
tree.Shorthand.prototype = {
toCSS: function (env) {
return this.a.toCSS(env) + "/" + this.b.toCSS(env);
},
eval: function () { return this }
};
})(require('less/tree'));