diff options
author | John Postlethwait <john.postlethwait@nebula.com> | 2012-05-11 23:37:35 -0700 |
---|---|---|
committer | John Postlethwait <john.postlethwait@nebula.com> | 2012-06-07 14:32:43 -0700 |
commit | 0074328fbbac6967d5dda2f3b0f3f98a91d17a01 (patch) | |
tree | 5eea54c65561786fbd88641dc65d85ac521a51b2 /bin/lib/less/tree/dimension.js | |
parent | 187785b28d7cfeb3fb4f87b67d71bc3dcf1f1354 (diff) | |
download | tuskar-ui-0074328fbbac6967d5dda2f3b0f3f98a91d17a01.tar.gz |
Updating Horizon to use LESS.
This changes all of the Bootstrap CSS and Horizon
CSS to use LESS. Horizon's specific CSS will be
organized into separate files in another commit,
as it is outside the scope of this BP.
We are also now packing LESS 1.3.0 directly within
Horizon.
Implementation of Blueprint transition-to-lesscss
Change-Id: Ie4be8b28ab3ce04ea21d7d5cd49c2ccb66bd8ade
Diffstat (limited to 'bin/lib/less/tree/dimension.js')
-rw-r--r-- | bin/lib/less/tree/dimension.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bin/lib/less/tree/dimension.js b/bin/lib/less/tree/dimension.js new file mode 100644 index 00000000..9a6fce3d --- /dev/null +++ b/bin/lib/less/tree/dimension.js @@ -0,0 +1,49 @@ +(function (tree) { + +// +// A number with a unit +// +tree.Dimension = function (value, unit) { + this.value = parseFloat(value); + this.unit = unit || null; +}; + +tree.Dimension.prototype = { + eval: function () { return this }, + toColor: function () { + return new(tree.Color)([this.value, this.value, this.value]); + }, + toCSS: function () { + var css = this.value + this.unit; + return css; + }, + + // In an operation between two Dimensions, + // we default to the first Dimension's unit, + // so `1px + 2em` will yield `3px`. + // In the future, we could implement some unit + // conversions such that `100cm + 10mm` would yield + // `101cm`. + operate: function (op, other) { + return new(tree.Dimension) + (tree.operate(op, this.value, other.value), + this.unit || other.unit); + }, + + // TODO: Perform unit conversion before comparing + compare: function (other) { + if (other instanceof tree.Dimension) { + if (other.value > this.value) { + return -1; + } else if (other.value < this.value) { + return 1; + } else { + return 0; + } + } else { + return -1; + } + } +}; + +})(require('../tree')); |