PageSourceSearch

https://www.cancerhotspots.org/src/js/render/ClusterRender.js

js cancerhotspots.org collected 2026-10-03 21:18:50 UTC 3,079 bytes, 92 lines download raw bytes

1/*
2 * Copyright (c) 2016 Memorial Sloan-Kettering Cancer Center.
3 *
4 * This library is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
6 * FOR A PARTICULAR PURPOSE. The software and documentation provided hereunder
7 * is on an "as is" basis, and Memorial Sloan-Kettering Cancer Center has no
8 * obligations to provide maintenance, support, updates, enhancements or
9 * modifications. In no event shall Memorial Sloan-Kettering Cancer Center be
10 * liable to any party for direct, indirect, special, incidental or
11 * consequential damages, including lost profits, arising out of the use of this
12 * software and its documentation, even if Memorial Sloan-Kettering Cancer
13 * Center has been advised of the possibility of such damage.
14 */
15
16/*
17 * This file is part of cBioPortal Cancer Hotspots.
18 *
19 * cBioPortal is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU Affero General Public License as
21 * published by the Free Software Foundation, either version 3 of the
22 * License.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 * GNU Affero General Public License for more details.
28 *
29 * You should have received a copy of the GNU Affero General Public License
30 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
31 */
32
33/**
34 * @author Selcuk Onur Sumer
35 */
36function ClusterRender(options)
37{
38    var _defaultOpts = {
39        templateId: "cluster_column",
40        dataManager: false
41    };
42
43    // merge options with default options to use defaults for missing values
44    var _options = jQuery.extend(true, {}, _defaultOpts, options);
45
46    function render(data, type)
47    {
48        if (type === 'sort')
49        {
50            return data;
51        }
52        else
53        {
54            var templateFn = _.template($("#" + _options.templateId).html());
55            return templateFn({clusterId: data});
56        }
57    }
58
59    function postRender(td, cellData, rowData, row, col)
60    {
61        var tooltipOpts = TooltipUtils.defaultTooltipOpts();
62        tooltipOpts.content = "Check to highlight residues in the diagram";
63
64        cbio.util.addTargetedQTip($(td).find('input'), tooltipOpts);
65
66        addEventListeners(td, cellData);
67    }
68
69    function addEventListeners(td, cellData)
70    {
71        $(td).find('input').on('change', function ()
72        {
73            if (_options.dataManager)
74            {
75                if ($(this).is(":checked"))
76                {
77                    // filter all lollipops corresponding to this cluster
78                    _options.dataManager.filterClusters([cellData]);
79                }
80                else
81                {
82                    // remove filters
83                    _options.dataManager.unfilterClusters([cellData]);
84                }
85            }
86        });
87    }
88
89    this.render = render;
90    this.postRender = postRender;
91}
92

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.