[dw-free] Add "Flat" and "Top-level comments only" control links to the bottom of comments pages too
[commit: http://hg.dwscoalition.org/dw-free/rev/7320f6e8c271]
http://bugs.dwscoalition.org/show_bug.cgi?id=4023
Add the links to the bottom for both site skinned and custom comment pages.
Tweak JS to use classes rather than ids, because there are two of these now.
Patch by
ninetydegrees, with some input from
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=4023
Add the links to the bottom for both site skinned and custom comment pages.
Tweak JS to use classes rather than ids, because there are two of these now.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/s2layers/core2.s2
- htdocs/js/jquery.threadexpander.js
- htdocs/js/thread_expander.js
- htdocs/talkread.bml
-------------------------------------------------------------------------------- diff -r 99ffce26d485 -r 7320f6e8c271 bin/upgrading/s2layers/core2.s2 --- a/bin/upgrading/s2layers/core2.s2 Mon Dec 26 07:56:11 2011 +0000 +++ b/bin/upgrading/s2layers/core2.s2 Wed Dec 28 15:47:50 2011 +0800 @@ -491,7 +491,8 @@ var bool filter "True if the current view is filtered."; var bool show_expand_all "True if we should show the expand_all option."; - function print () "Prints the nav bar, including the comment_pages bar"; + function print () "Prints the nav bar, including the comment_pages bar, with a default CSS class"; + function print(string{} extra) "Prints the nav bar with the given attributes. Accepts 'class'"; } @@ -5766,11 +5767,11 @@ "<div id='comments'><div class='inner'>"; $.comment_pages->print({ "anchor" => "comments", "class" => "comment-pages toppages" }); if ( $e.comments.comments_disabled_maintainer ) { - """<div class='comments-message'>$*text_comments_disabled_maintainer</div>"""; + """<div class='comments-message'>$*text_comments_disabled_maintainer</div>"""; } if ($.comment_pages.total_subitems > 0) { - $.comment_nav->print(); - $this->print_multiform_start(); + $.comment_nav->print({ "class" => "comment-pages toppages" }); + $this->print_multiform_start(); } $this->print_comments($.comments); if ($.comment_pages.total_subitems > 0) { @@ -5783,6 +5784,9 @@ "</div>"; } $.comment_pages->print({ "anchor" => "comments", "class" => "comment-pages bottompages" }); + if ($.comment_pages.total_subitems > 0) { + $.comment_nav->print({ "class" => "comment-pages bottompages" }); + } "</div></div>"; } @@ -5951,12 +5955,17 @@ "</div>"; } -function CommentNav::print -{ +function CommentNav::print() { + $this->print({ "class" => "" }); +} + +function CommentNav::print(string{} opts) { + + var string class = $opts{"class"} ? $opts{"class"} : "pages"; var string sep = $.url->contains( "?" ) ? "&" : "?"; var string page_arg = $.current_page > 1 ? "&page=$.current_page" : ""; - print "<div class='comment-pages'>"; + print "<div class='$class'>"; var string{} links = { "flat" => """<a href="$.url${sep}view=flat#comments">Flat</a>""", @@ -5974,7 +5983,7 @@ } if ( $.show_expand_all ) { - print "<span id='expand_all'> | $links{"expand_all"}</span>"; + print "<span class='expand_all'> | $links{"expand_all"}</span>"; } print "</div>"; } diff -r 99ffce26d485 -r 7320f6e8c271 htdocs/js/jquery.threadexpander.js --- a/htdocs/js/jquery.threadexpander.js Mon Dec 26 07:56:11 2011 +0000 +++ b/htdocs/js/jquery.threadexpander.js Wed Dec 28 15:47:50 2011 +0800 @@ -79,7 +79,7 @@ } // remove the expand_all option if all comments are expanded - var expand_all_span = $('#expand_all'); + var expand_all_span = $('.expand_all'); if (expand_all_span.length > 0) { if (getUnexpandedComments(LJ).length == 0) { expand_all_span.fadeOut('fast'); diff -r 99ffce26d485 -r 7320f6e8c271 htdocs/js/thread_expander.js --- a/htdocs/js/thread_expander.js Mon Dec 26 07:56:11 2011 +0000 +++ b/htdocs/js/thread_expander.js Wed Dec 28 15:47:50 2011 +0800 @@ -49,8 +49,8 @@ } Expander.prototype.loadingStateOff = function(){ - var expand_all = document.getElementById("expand_all"); - if (expand_all != null) { + var expand_all = DOM.getElementsByClassName( document, "expand_all" ); + if (expand_all.length > 0) { // if all comments have been expanded, remove the expand_all entry var LJ = window.LJ_cmtinfo; var removeExpandAll = true; @@ -59,8 +59,12 @@ removeExpandAll = false; } } + if (removeExpandAll) { - expand_all.parentNode.removeChild(expand_all); + for(var i = 0; i < expand_all.length; i++) { + var ele = expand_all[i]; + ele.parentNode.removeChild(ele); + } } } diff -r 99ffce26d485 -r 7320f6e8c271 htdocs/talkread.bml --- a/htdocs/talkread.bml Mon Dec 26 07:56:11 2011 +0000 +++ b/htdocs/talkread.bml Wed Dec 28 15:47:50 2011 +0800 @@ -777,22 +777,24 @@ $ret .= "<br>\n"; # comment nav + my $viewlinks = ""; my $view_mode = $flat_mode ? "flat" : $top_only ? "top-only" : "threaded"; if ( $view_mode eq "threaded" ) { - $ret .= "(<a href = '" . BML::self_link( { view => 'flat' } ) . "#comments'>" . BML::ml('.commentnav.flat') . "</a>) (<a href = '" . BML::self_link( { view => 'top-only' } ) . "#comments'>" . BML::ml('.commentnav.toponly') . "</a>)"; + $viewlinks .= "(<a href = '" . BML::self_link( { view => 'flat' } ) . "#comments'>" . BML::ml('.commentnav.flat') . "</a>) (<a href = '" . BML::self_link( { view => 'top-only' } ) . "#comments'>" . BML::ml('.commentnav.toponly') . "</a>)"; } elsif ( $view_mode eq "flat" ) { - $ret .= "(<a href = '" . BML::self_link( { view => '' } ) . "#comments'>" . BML::ml('.commentnav.threaded') . "</a>) (<a href = '" . BML::self_link( { view => 'top-only' } ) . "#comments'>" . BML::ml('.commentnav.toponly') . "</a>)"; + $viewlinks .= "(<a href = '" . BML::self_link( { view => '' } ) . "#comments'>" . BML::ml('.commentnav.threaded') . "</a>) (<a href = '" . BML::self_link( { view => 'top-only' } ) . "#comments'>" . BML::ml('.commentnav.toponly') . "</a>)"; } elsif ( $view_mode eq "top-only" ) { - $ret .= "(<a href = '" . BML::self_link( { view => '' } ) . "#comments'>" . BML::ml('.commentnav.threaded') . "</a>) (<a href = '" . BML::self_link( { view => 'flat' } ) . "#comments'>" . BML::ml('.commentnav.flat') . "</a>)"; + $viewlinks .= "(<a href = '" . BML::self_link( { view => '' } ) . "#comments'>" . BML::ml('.commentnav.threaded') . "</a>) (<a href = '" . BML::self_link( { view => 'flat' } ) . "#comments'>" . BML::ml('.commentnav.flat') . "</a>)"; } if ( $u->thread_expand_all( $remote ) && $has_collapsed && $view_mode ne "top-only" ) { my $expand_all_url = $page > 1 ? BML::self_link( { expand_all => '1', page => $page } ) . "#comments" : BML::self_link( { expand_all => '1' } ) . "#comments"; - $ret .= "<span id='expand_all'> (<a href=\"$expand_all_url\" onClick=\"Expander.make(this,'$expand_all_url',-1,true,false);return false;\">" . $T{expandall} . "</a>)</span>"; + $viewlinks .= "<span class='expand_all'> (<a href=\"$expand_all_url\" onClick=\"Expander.make(this,'$expand_all_url',-1,true,false);return false;\">" . $T{expandall} . "</a>)</span>"; } + + $ret .= $viewlinks; $ret .= "</b></p>"; - $ret .= "<div align='center'>" . LJ::make_qr_target('top') . "</div>" if $remote; my $styleopts = LJ::viewing_style_opts( %GET ); @@ -846,6 +848,9 @@ $ret .= "(<a href='$posturl'>$T{'postcomments'}</a>)"; } } + + $ret .= "<br>\n"; + $ret .= $viewlinks; $ret .= "</b></p>"; $ret .= "<div align='center'>" . LJ::make_qr_target('bottom') . "</div>" if $remote; --------------------------------------------------------------------------------
no subject
no subject
no subject
no subject