From 0074328fbbac6967d5dda2f3b0f3f98a91d17a01 Mon Sep 17 00:00:00 2001 From: John Postlethwait Date: Fri, 11 May 2012 23:37:35 -0700 Subject: 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 --- bin/lib/less/tree/directive.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bin/lib/less/tree/directive.js (limited to 'bin/lib/less/tree/directive.js') diff --git a/bin/lib/less/tree/directive.js b/bin/lib/less/tree/directive.js new file mode 100644 index 00000000..27538332 --- /dev/null +++ b/bin/lib/less/tree/directive.js @@ -0,0 +1,35 @@ +(function (tree) { + +tree.Directive = function (name, value, features) { + this.name = name; + + if (Array.isArray(value)) { + this.ruleset = new(tree.Ruleset)([], value); + this.ruleset.allowImports = true; + } else { + this.value = value; + } +}; +tree.Directive.prototype = { + toCSS: function (ctx, env) { + if (this.ruleset) { + this.ruleset.root = true; + return this.name + (env.compress ? '{' : ' {\n ') + + this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') + + (env.compress ? '}': '\n}\n'); + } else { + return this.name + ' ' + this.value.toCSS() + ';\n'; + } + }, + eval: function (env) { + env.frames.unshift(this); + this.ruleset = this.ruleset && this.ruleset.eval(env); + env.frames.shift(); + return this; + }, + variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) }, + find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) }, + rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) } +}; + +})(require('../tree')); -- cgit v1.2.1