Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{{!
This file is part of Moodle - http://moodle.org/

Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template unilabeltype_accordion/accordion
    Template to show collapsable elements as an accordion.

    Example context (json):
    {
        "showintro": false,
        "intro": "",
        "segments": [
            {
                "id": "4",
                "accordionid": "1",
                "heading": "Heading-1",
                "content": "Content-1"
            },
            {
                "id": "5",
                "accordionid": "1",
                "heading": "Heading-2",
                "content": "Content-2"
            },
            {
                "id": "6",
                "accordionid": "1",
                "heading": "Heading-3",
                "content": "Content-3"
            }
        ],
        "cmid": "3",
        "plugin": "unilabeltype_accordion",
        "collapse": false
    }
}}

{{#showintro}}
    {{{intro}}}
{{/showintro}}
<div class="accordion" id="accordion-wrapper-{{uniqid}}-{{cmid}}">
{{#segments}}
    <div class="card" id="accordion-{{uniqid}}-{{id}}">
        <div class="card-header" id="accordion-heading-{{uniqid}}-{{id}}">
            <button id="unilabel-button-{{uniqid}}-{{id}}" class="btn btn-link btn-block collapsed" type="button" data-toggle="collapse" data-target="#accordion-segment-{{uniqid}}-{{id}}" aria-expanded="false" aria-controls="accordion-segment-{{uniqid}}-{{id}}">
                {{{ heading }}}
            </button>
        </div>
        <div id="accordion-segment-{{uniqid}}-{{id}}" class="collapse" aria-labelledby="accordion-heading-{{uniqid}}-{{id}}" {{^collapse}}data-parent="#accordion-wrapper-{{uniqid}}-{{cmid}}"{{/collapse}}>
            <div class="card-body">
                {{{ content }}}
            </div>
        </div>
    </div>
{{/segments}}
</div>
{{#js}}
    require(['mod_unilabel/collapse_helper'], function(collapsehelper) {
        collapsehelper.init("#accordion-wrapper-{{uniqid}}-{{cmid}} .card .card-header button");
    });
{{/js}}