Proyectos de Subversion Moodle

Rev

| 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 mod_forum/forum_discussion
19
 
20
    Template for displaying a single forum discussion.
21
 
22
    Classes required for JS:
23
    * none
24
 
25
    Data attributes required for JS:
26
    * none
27
 
28
    Example context (json):
29
    {
30
        "html": {
31
            "hasanyactions": true,
32
            "posts": "<article id='p33' class='forum-post-container mb-2' data-post-id='33'></article>",
33
            "modeselectorform": "<div class='singleselect d-inline-block'> <form method='get' action='http://localhost/m/pg_stable_master/mod/forum/discuss.php' class='d-flex flex-wrap' id='mode'></div>",
34
            "subscribe": null,
35
            "movediscussion": null,
36
            "pindiscussion": null,
37
            "neighbourlinks": "<div class='discussion-nav clearfix'></div>",
38
            "exportdiscussion": null
39
        },
40
        "throttlingwarningmsg": "You are approaching the posting threshold. You have posted 3 times in the last 1 week and the limit is 4 posts."
41
    }
42
}}
43
 
44
<div id="discussion-container-{{uniqid}}" data-content="forum-discussion">
45
{{#html}}
46
    {{{neighbourlinks}}}
47
 
48
    <div class="d-flex flex-column flex-sm-row mb-1">
49
        <div>{{{exportdiscussion}}}</div>
50
        <div class="{{#exportdiscussion}}ml-2{{/exportdiscussion}}">{{{modeselectorform}}}</div>
51
        <div class="ml-2">{{{movediscussion}}}</div>
52
        {{#hasanyactions}}
53
            <div class="drop-down ml-auto" data-container="discussion-tools">
54
                {{> mod_forum/forum_action_menu}}
55
            </div>
56
        {{/hasanyactions}}
57
    </div>
58
{{/html}}
59
 
60
{{#notifications}}
61
    {{> core/notification}}
62
{{/notifications}}
63
 
64
{{{html.posts}}}
65
 
66
{{#html.neighbourlinks}}{{{.}}}{{/html.neighbourlinks}}
67
</div>
68
{{#js}}
69
require(
70
[
71
    'jquery',
72
    'core/templates',
73
    'mod_forum/discussion',
74
    'mod_forum/posts_list',
75
    'mod_forum/lock_toggle',
76
    'mod_forum/favourite_toggle',
77
    'mod_forum/pin_toggle',
78
    'mod_forum/subscription_toggle'
79
],
80
function(
81
    $,
82
    Templates,
83
    Discussion,
84
    PostsList,
85
    LockToggle,
86
    FavouriteToggle,
87
    Pin,
88
    SubscribeToggle
89
) {
90
    var root = $("[data-content='forum-discussion']");
91
    Discussion.init(root);
92
    PostsList.init(root, {{#quote}}{{throttlingwarningmsg}}{{/quote}});
93
    root = $('[data-container="discussion-tools"]');
94
    LockToggle.init(root, true);
95
    FavouriteToggle.init(root, true, function(toggleElement, context) {
96
        return Templates.render('mod_forum/discussion_favourite_toggle', context)
97
            .then(function(html, js) {
98
                return Templates.replaceNode(toggleElement, html, js);
99
            });
100
    });
101
    Pin.init(root, true, function(toggleElement, context) {
102
        return Templates.render('mod_forum/discussion_pin_toggle', context)
103
            .then(function(html, js) {
104
                return Templates.replaceNode(toggleElement, html, js);
105
            });
106
    });
107
    SubscribeToggle.init(root, true, function(toggleElement, context) {
108
        return Templates.render('mod_forum/discussion_subscription_toggle', context)
109
            .then(function(html, js) {
110
                return Templates.replaceNode(toggleElement, html, js);
111
            });
112
    });
113
});
114
{{/js}}