summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/template/en/default/hook/bug/comments-aftercomments.html.tmpl
blob: 65bf77967cfed80c2b2c74d261a49ace33507ced (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% IF has_tbpl_comment %]
  [% expand_caption   = 'Expand TinderboxPushlog Comments' %]
  [% collapse_caption = 'Collapse TinderboxPushlog Comments' %]
  [% show_caption     = 'Show TinderboxPushlog Comments' %]
  [% hide_caption     = 'Hide TinderboxPushlog Comments' %]
  <script>
    YAHOO.util.Event.onDOMReady(function () {
        var ul = document.getElementsByClassName('bz_collapse_expand_comments');
        if (ul.length == 0)
            return;

        var li = document.createElement('li');
        var a = document.createElement('a');
        Dom.setAttribute(a, 'href', 'javascript:void(0)');
        Dom.setAttribute(a, 'id', 'tbpl_toggle_collapse');
        a.innerHTML = '[% expand_caption FILTER js %]';
        YAHOO.util.Event.on(a, 'click', function() {
            var a = document.getElementById('tbpl_toggle_collapse');
            var do_expand = a.innerHTML == '[% expand_caption FILTER js %]';
            for (var i = 0, n = tbpl_comment_ids.length; i < n; i++) {
                var id = tbpl_comment_ids[i];
                var link = document.getElementById('comment_link_' + id);
                var text = document.getElementById('comment_text_' + id);
                if (do_expand) {
                    expand_comment(link, text);
                } else {
                    collapse_comment(link, text);
                }
            }
            a.innerHTML = do_expand
              ? '[% collapse_caption FILTER js %]'
              : '[% expand_caption FILTER js %]';
        });
        li.appendChild(a);
        ul[0].appendChild(li);

        li = document.createElement('li');
        a = document.createElement('a');
        Dom.setAttribute(a, 'href', 'javascript:void(0)');
        Dom.setAttribute(a, 'id', 'tbpl_toggle_visible');
        a.innerHTML = '[% hide_caption FILTER js %]';
        YAHOO.util.Event.on(a, 'click', function() {
            var a = document.getElementById('tbpl_toggle_visible');
            var do_show = a.innerHTML == '[% show_caption FILTER js %]';
            for (var i = 0, n = tbpl_comment_ids.length; i < n; i++) {
                var id = tbpl_comment_ids[i];
                if (do_show) {
                    Dom.removeClass('c' + id, 'bz_default_hidden');
                } else {
                    Dom.addClass('c' + id, 'bz_default_hidden');
                }
            }
            a.innerHTML = do_show
              ? '[% hide_caption FILTER js %]'
              : '[% show_caption FILTER js %]';
        });
        li.appendChild(a);
        ul[0].appendChild(li);
    });
  </script>
[% END %]