summaryrefslogtreecommitdiffstats
path: root/qx08/source/class/tr/ui/Link.js
blob: dd7f33e4c1414577c3c630b1d364126b88f03f75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************
#module(Tr)
************************************************************************ */

/**
 * A label with the ability to link out. Based on Label.
 */
qx.Class.define('tr.ui.Link', {
    extend : qx.ui.basic.Label,




    /*
            *****************************************************************************
               CONSTRUCTOR
            *****************************************************************************
            */

    /**
             * @param text {String} Initial label
             * @param url  {String} Where to link to
             * @param color {String} Hex Color for the text
             * @param font {String} Font from string representation
             */
    construct : function(text, url, color, font) {
        this.base(arguments, text);

        if (color) {
            this.setTextColor(color);
        }

        if (font) {
            this.setFont(qx.bom.Font.fromString(font));
        }

        this.set({
            cursor  : 'pointer',
            opacity : 0.9
        });

        this.addListener('click', function(e) {
            window.open(url, '__new');
        });

        this.addListener('mouseover', function(e) {
            this.setOpacity(1);
        }, this);

        this.addListener('mouseout', function(e) {
            this.setOpacity(0.7);
        }, this);
    }
});