Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
-
Property svn:executable set to
*
|
File size:
901 bytes
|
Line | |
---|
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')); |
---|
Note: See
TracBrowser
for help on using the repository browser.