~ubuntu-branches/ubuntu/trusty/horizon/trusty-updates

« back to all changes in this revision

Viewing changes to bin/lib/less/tree/element.js

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2013-09-06 11:59:43 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20130906115943-h3td0l7tp16mb9oc
Tags: 1:2013.2~b3-0ubuntu1
* New upstream release.
* debian/control: Minimum python-openstack-auth version >= 1.1.1.
* debian/control: Add python-troveclient.
* debian/static: Refresh static assets for 2013.2~b3.
* debian/patches: ubuntu_local_settings.patch -> ubuntu_settings.patch, also
  patch location of secret key in openstack_dashboard/settings.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(function (tree) {
2
 
 
3
 
tree.Element = function (combinator, value, index) {
4
 
    this.combinator = combinator instanceof tree.Combinator ?
5
 
                      combinator : new(tree.Combinator)(combinator);
6
 
 
7
 
    if (typeof(value) === 'string') {
8
 
        this.value = value.trim();
9
 
    } else if (value) {
10
 
        this.value = value;
11
 
    } else {
12
 
        this.value = "";
13
 
    }
14
 
    this.index = index;
15
 
};
16
 
tree.Element.prototype.eval = function (env) {
17
 
    return new(tree.Element)(this.combinator,
18
 
                             this.value.eval ? this.value.eval(env) : this.value,
19
 
                             this.index);
20
 
};
21
 
tree.Element.prototype.toCSS = function (env) {
22
 
        var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
23
 
        if (value == '' && this.combinator.value.charAt(0) == '&') {
24
 
                return '';
25
 
        } else {
26
 
                return this.combinator.toCSS(env || {}) + value;
27
 
        }
28
 
};
29
 
 
30
 
tree.Combinator = function (value) {
31
 
    if (value === ' ') {
32
 
        this.value = ' ';
33
 
    } else if (value === '& ') {
34
 
        this.value = '& ';
35
 
    } else {
36
 
        this.value = value ? value.trim() : "";
37
 
    }
38
 
};
39
 
tree.Combinator.prototype.toCSS = function (env) {
40
 
    return {
41
 
        ''  : '',
42
 
        ' ' : ' ',
43
 
        '&' : '',
44
 
        '& ' : ' ',
45
 
        ':' : ' :',
46
 
        '+' : env.compress ? '+' : ' + ',
47
 
        '~' : env.compress ? '~' : ' ~ ',
48
 
        '>' : env.compress ? '>' : ' > '
49
 
    }[this.value];
50
 
};
51
 
 
52
 
})(require('../tree'));