3 var comment_template = false; |
3 var comment_template = false; |
4 var comment_render_track = 0; |
4 var comment_render_track = 0; |
5 |
5 |
6 window.ajaxComments = function(parms) |
6 window.ajaxComments = function(parms) |
7 { |
7 { |
8 load_component(['l10n', 'paginate', 'template-compiler', 'toolbar', 'flyin']); |
8 load_component(['l10n', 'paginate', 'template-compiler', 'toolbar', 'flyin', 'jquery', 'jquery-ui']); |
9 setAjaxLoading(); |
9 setAjaxLoading(); |
10 var pid = strToPageID(title); |
10 var pid = strToPageID(title); |
11 if(!parms) |
11 if(!parms) |
12 { |
12 { |
13 var parms = { |
13 var parms = { |
14 'mode' : 'fetch' |
14 mode: 'fetch', |
|
15 pagenum: 0 |
15 }; |
16 }; |
16 } |
17 } |
17 parms.page_id = pid[0]; |
18 parms.page_id = pid[0]; |
18 parms.namespace = pid[1]; |
19 parms.namespace = pid[1]; |
19 if(comment_template) |
20 if(comment_template) |
33 } |
34 } |
34 var response = parseJSON(ajax.responseText); |
35 var response = parseJSON(ajax.responseText); |
35 switch(response.mode) |
36 switch(response.mode) |
36 { |
37 { |
37 case 'fetch': |
38 case 'fetch': |
38 document.getElementById('ajaxEditContainer').innerHTML = '<div class="wait-box">Rendering '+response.count_total+' comments...</div>'; |
|
39 if(response.template) |
39 if(response.template) |
40 comment_template = response.template; |
40 comment_template = response.template; |
41 setAjaxLoading(); |
41 setAjaxLoading(); |
42 renderComments(response); |
42 renderComments(response); |
43 unsetAjaxLoading(); |
43 unsetAjaxLoading(); |
|
44 break; |
|
45 case 'refetch': |
|
46 var html = ''; |
|
47 for ( var i = 0; i < response.comments.length; i++ ) |
|
48 { |
|
49 html += window._render_comment(response.comments[i], response); |
|
50 } |
|
51 $('#' + response.passback.paginator_id + '_0') |
|
52 .css('height', 'auto') |
|
53 .css('background-color', 'transparent') |
|
54 .css('background-image', 'none') |
|
55 .fadeTo('fast', 100) |
|
56 .html(html); |
44 break; |
57 break; |
45 case 'redraw': |
58 case 'redraw': |
46 redrawComment(response); |
59 redrawComment(response); |
47 break; |
60 break; |
48 case 'annihilate': |
61 case 'annihilate': |
116 // Comment display |
129 // Comment display |
117 |
130 |
118 if ( data.count_total > 0 ) |
131 if ( data.count_total > 0 ) |
119 { |
132 { |
120 comment_render_track = 0; |
133 comment_render_track = 0; |
121 var commentpages = new paginator(data.comments, _render_comment, 0, 10, data); |
134 var commentpages = new paginator(data.comments, _render_comment, 0, data.per_page, data, Math.ceil(data.count_total / data.per_page), window._comment_page_flip); |
122 html += commentpages.html; |
135 html += commentpages.html; |
123 } |
136 } |
124 |
137 |
125 if ( data.auth_post_comments ) |
138 if ( data.auth_post_comments ) |
126 { |
139 { |
628 span.innerHTML = count_msg; |
641 span.innerHTML = count_msg; |
629 status.appendChild(span); |
642 status.appendChild(span); |
630 } |
643 } |
631 } |
644 } |
632 |
645 |
|
646 window._comment_page_flip = function(paginator, page_number) |
|
647 { |
|
648 // get ID |
|
649 var random_id = paginator.random_id; |
|
650 // update paginate control |
|
651 paginator.set_page(page_number); |
|
652 $('.' + random_id + '_control').html(paginator._build_control(page_number)); |
|
653 paginator.offset = page_number; |
|
654 // set to loading state |
|
655 $('#' + random_id + '_0') |
|
656 .css('height', 500) |
|
657 .html('') |
|
658 .fadeTo("fast", 0.7) |
|
659 .css('background-position', 'center 51px') |
|
660 .css('background-repeat', 'no-repeat') |
|
661 .css('background-color', 'white') |
|
662 .css('background-image', 'url(' + cdnPath + '/images/loading-big.gif' + ')') |
|
663 .animate({ height: 150 }, 500, function() |
|
664 { |
|
665 // load the new comments |
|
666 ajaxComments({ |
|
667 mode: 'fetch', |
|
668 pagenum: page_number, |
|
669 passback: { |
|
670 paginator_id: random_id |
|
671 } |
|
672 }); |
|
673 }); |
|
674 } |
|
675 |
633 window.viewCommentIP = function(id, local_id) |
676 window.viewCommentIP = function(id, local_id) |
634 { |
677 { |
635 // set "loading" indicator on IP button |
678 // set "loading" indicator on IP button |
636 var span = $dynano('comment_ip_' + local_id).object; |
679 var span = $dynano('comment_ip_' + local_id).object; |
637 if ( !span ) |
680 if ( !span ) |