Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{{!
2
    This file is part of Moodle - http://moodle.org/
3
 
4
    Moodle is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8
 
9
    Moodle is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU General Public License for more details.
13
 
14
    You should have received a copy of the GNU General Public License
15
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
}}
17
{{!
18
    @template core/chart
19
 
20
    Chart rendering.
21
 
22
    Example context (json):
23
    {
24
        "withtable": true,
25
        "chartdata": "null"
26
    }
27
}}
28
<div class="chart-area" id="chart-area-{{uniqid}}">
1441 ariadna 29
    <div class="chart-image" role="presentation" {{#withtable}}aria-describedby="chart-table-data-{{uniqid}}" {{/withtable}}></div>
30
    {{#withtable}}
31
        <div class="chart-table">
32
            <p class="chart-table-expand">
33
                <a href="#" aria-controls="chart-table-data-{{uniqid}}" role="button">
34
                    {{#str}}showchartdata, moodle{{/str}}
35
                </a>
36
            </p>
37
            <div class="chart-table-data" id="chart-table-data-{{uniqid}}" role="complementary" aria-expanded="false"></div>
38
        </div>
39
    {{/withtable}}
1 efrain 40
</div>
41
 
42
{{#js}}
43
require([
44
    'jquery',
45
    'core/chart_builder',
46
    'core/chart_output_chartjs',
47
    'core/chart_output_htmltable',
48
], function($, Builder, Output, OutputTable) {
49
    var data = {{{chartdata}}},
50
        uniqid = "{{uniqid}}",
51
        chartArea = $('#chart-area-' + uniqid),
52
        chartImage = chartArea.find('.chart-image'),
53
        chartTable = chartArea.find('.chart-table-data'),
54
        chartLink = chartArea.find('.chart-table-expand a');
55
    Builder.make(data).then(function(ChartInst) {
56
        new Output(chartImage, ChartInst);
57
        new OutputTable(chartTable, ChartInst);
58
    });
59
 
60
    chartLink.on('click', function(e) {
61
        e.preventDefault();
62
        if (chartTable.is(':visible')) {
63
            chartTable.hide();
64
            chartLink.text({{#quote}}{{#str}}showchartdata, moodle{{/str}}{{/quote}});
65
            chartTable.attr('aria-expanded', false);
66
        } else {
67
            chartTable.show();
68
            chartLink.text({{#quote}}{{#str}}hidechartdata, moodle{{/str}}{{/quote}});
69
            chartTable.attr('aria-expanded', true);
70
        }
71
    });
72
});
73
{{/js}}