Revert "Export"
[framework/web/web-ui-fw.git] / build-tools / lib / less / tree / dimension.js
1 (function (tree) {
2
3 //
4 // A number with a unit
5 //
6 tree.Dimension = function (value, unit) {
7     this.value = parseFloat(value);
8     this.unit = unit || null;
9 };
10
11 tree.Dimension.prototype = {
12     eval: function () { return this },
13     toColor: function () {
14         return new(tree.Color)([this.value, this.value, this.value]);
15     },
16     toCSS: function () {
17         var css = this.value + this.unit;
18         return css;
19     },
20
21     // In an operation between two Dimensions,
22     // we default to the first Dimension's unit,
23     // so `1px + 2em` will yield `3px`.
24     // In the future, we could implement some unit
25     // conversions such that `100cm + 10mm` would yield
26     // `101cm`.
27     operate: function (op, other) {
28         return new(tree.Dimension)
29                   (tree.operate(op, this.value, other.value),
30                   this.unit || other.unit);
31     }
32 };
33
34 })(require('less/tree'));