summaryrefslogtreecommitdiff
path: root/web/viewsjs/reports/josm_styles.js.erb
blob: 4e4ec134afd57b8d34c5fb8c15d334ad9cde1b64 (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
function create_flexigrid_with_option(stylename) {
    create_flexigrid('grid-rules', {
        url: '/api/2/josm/styles/' + stylename,
        colModel: [
            { display: texts.osm.key,   name: 'k', width: 300, sortable: true },
            { display: texts.osm.value, name: 'v', width: 300, sortable: true },
            { display: 'Icon', name: 'icon', width: 30, sortable: false, align: 'center' },
            { display: 'Line', name: 'line', width: 30, sortable: false, align: 'center' },
            { display: 'Area', name: 'area', width: 30, sortable: false, align: 'center' }
        ],
        searchitems: [
            { display: 'Key/Value', name: 'k' }
        ],
        sortname: 'k',
        sortorder: 'asc',
        preProcess: function(data) {
            data.rows = jQuery.map(data.data, function(row, i) {
                return { 'cell': [
                    link_to_key(row.k),
                    row.v ? link_to_value(row.k, row.v) : row.b ? (row.b + ' (Boolean)') : '*',
                    row.icon ? '<img src="/api/2/josm/styles/images?style=standard&image=' + row.icon + '" title="' + row.icon + '" alt=""/>' : '',
                    '<div>' + (row.line_width > 0 ? '<div title="' + row.line_color + '" style="height: ' + row.line_width + 'px; margin-top: ' + (10 - Math.round(row.line_width/2)) + 'px; padding: 0; background-color: ' + row.line_color + '"></div>' : '') + '</div>',
                    row.area_color ? '<div title="' + row.area_color + '" style="height: 18px; background-color: ' + row.area_color + '"></div>' : ''
                ] };
            });
            return data;
        }
    });
}

function page_init() {
    page_init2();
}