Blame view

js/app/views/ColorMap.js 3.1 KB
28ce2479   Erdogan Furkan   Last modification...
1
2
3
4
5
6
Ext.define('amdaUI.ColorMap', {
    extend: 'Ext.form.ComboBox',
    alias: 'widget.colormap',
   

    data : [],
1c1417db   Benjamin Renard   Fix bug after merge
7
    onValueChange: null,
28ce2479   Erdogan Furkan   Last modification...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

    constructor:function(config){
        this.getData();
        this.init(config);
		this.callParent();
    },

    getData:function(){
        var me = this;
        amdaDefaultConfigs.availableColorMaps.forEach(function(color){
			me.data.push({key:color.key,name:color.value, iconUrl:'generic_data/colormaps/'+ color.svgFile})
		});
    },
    init: function(config){
        var me = this;
        var size = (typeof config !== "undefined" && config.size) ? config.size : '12';
b350c87a   Benjamin Renard   Fix color map sel...
24
25
26
27
        var hideFieldLabel = true;
        if (typeof config !== "undefined") {
            hideFieldLabel = (config.hideFieldLabel !== false);
        }
28ce2479   Erdogan Furkan   Last modification...
28
29
30
        Ext.apply(this,{
            xtype:'combobox',
            name: (typeof config !== "undefined" && config.name) ? config.name:null,
b350c87a   Benjamin Renard   Fix color map sel...
31
32
            fieldLabel: hideFieldLabel ? '' : 'Color Map&nbsp;<img amda_clicktip="colourMaps" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
            store: new Ext.data.Store({
28ce2479   Erdogan Furkan   Last modification...
33
34
35
36
37
38
39
40
41
42
43
            fields: ['key','name', 'iconUrl'],
            data: me.data
        }),
        displayField: 'name',
        valueField: 'key',
        tpl: '<tpl for="."><div class="x-boundlist-item"><span data-qtip="{name}"> \
                <img src="{iconUrl}" class="svg-icon" style="height:'+size+'px;"> \
                </span>\
            </div></tpl>',
        editable: false,
        queryMode: 'local',
b350c87a   Benjamin Renard   Fix color map sel...
44
        onValueChange: (typeof config !== "undefined" && config.onValueChange) ? config.onValueChange : null,
28ce2479   Erdogan Furkan   Last modification...
45
46
47
        listeners: {
            change: function (combo, newValue, oldValue, eOpts) {
                var iconUrl="";
9b67ae6b   Benjamin Renard   Merge FER_10934 i...
48
                var colorName = "";
28ce2479   Erdogan Furkan   Last modification...
49
50
51
                me.data.forEach(function(colorData){
                    if(colorData.key == newValue ){
                        iconUrl= colorData.iconUrl;
9b67ae6b   Benjamin Renard   Merge FER_10934 i...
52
                        colorName = colorData.name;
28ce2479   Erdogan Furkan   Last modification...
53
54
55
56
57
58
59
                    }
                });
                combo.inputEl.setStyle('background-image', 'url(' + iconUrl + ')');
                combo.inputEl.setStyle('background-size', '100%');
                combo.inputEl.setStyle('background-repeat', 'no-repeat');
                combo.inputEl.setStyle('background-position', 'center');
                combo.inputEl.setStyle('font-size', '0');
9b67ae6b   Benjamin Renard   Merge FER_10934 i...
60
61
62

                combo.inputEl.set({ "data-qtip": Ext.String.htmlDecode(colorName) });

1c1417db   Benjamin Renard   Fix bug after merge
63
64
                if (me.onValueChange)
                    me.onValueChange(me.name, newValue, oldValue);
28ce2479   Erdogan Furkan   Last modification...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
            },
            click: {
                element: 'el',
                fn: function(e,t) { 
                    var me = t,
                    text = me.getAttribute('amda_clicktip');
                    if (text) {
                        e.preventDefault();
                        AmdaAction.getInfo({name : text}, function(res,e) {
                            if (res.success) myDesktopApp.infoMsg(res.result);
                        });
                    }
                }
            },
            scope:this
        },
        })
    }
});