[Rt-commit] rt branch, 4.0/toggle-folding, created. rt-4.0.2-40-g191d9a1

Thomas Sibley trs at bestpractical.com
Fri Sep 2 13:00:12 EDT 2011


The branch, 4.0/toggle-folding has been created
        at  191d9a1aa912d979cdf254421aae27754a529fd5 (commit)

- Log -----------------------------------------------------------------
commit b789bfb5652f95c6308485ba3286c1171c97b24a
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Sep 2 12:50:35 2011 -0400

    Use classes, not inline style attributes, to open/close quote folding
    
    This approach is cleaner and makes it much easier to select open or
    closed folds without having to match on a CSS property value.
    
    Both the message stanza and the folder link will now have the
    appropriate class state at all times.
    
    Minor caveat: IE 6 handles .foo.bar selectors as if they were .bar
    alone.  This means that in IE 6 any element matching .closed will get
    display: none.  Fortunately we don't use .closed anywhere else.  If we
    ever need to, we can rename the quote fold classes to be more specific.

diff --git a/share/html/NoAuth/css/base/history-folding.css b/share/html/NoAuth/css/base/history-folding.css
index 76f6534..7d102ee 100644
--- a/share/html/NoAuth/css/base/history-folding.css
+++ b/share/html/NoAuth/css/base/history-folding.css
@@ -60,6 +60,10 @@
     content: " - ";
 }
 
+.message-stanza.closed {
+    display: none;
+}
+
 /* Message quoting */
 
 .message-stanza {
diff --git a/share/html/NoAuth/js/history-folding.js b/share/html/NoAuth/js/history-folding.js
index 8c8a986..6afe868 100644
--- a/share/html/NoAuth/js/history-folding.js
+++ b/share/html/NoAuth/js/history-folding.js
@@ -47,15 +47,11 @@
 %# END BPS TAGGED BLOCK }}}
 function fold_message_stanza(e,showmsg, hidemsg) {
     var box = jQuery(e).next("br").next('.message-stanza');
-    if ( box.css('display') == 'none') {
-        box.css('display', 'block');
-        jQuery(e).addClass('open');
-        jQuery(e).removeClass('closed');
+    if ( box.hasClass('closed') ) {
+        jQuery([e, box[0]]).removeClass('closed').addClass('open');
         jQuery(e).text( hidemsg);
     } else {
-        box.css('display', 'none');
-        jQuery(e).addClass('closed');
-        jQuery(e).removeClass('open');
+        jQuery([e, box[0]]).addClass('closed').removeClass('open');
         jQuery(e).text( showmsg);
     }
 }
diff --git a/share/html/Ticket/Elements/FoldStanzaJS b/share/html/Ticket/Elements/FoldStanzaJS
index 8f355ee..4c13b64 100644
--- a/share/html/Ticket/Elements/FoldStanzaJS
+++ b/share/html/Ticket/Elements/FoldStanzaJS
@@ -46,5 +46,5 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <span
-    class="message-stanza-folder"
+    class="message-stanza-folder closed"
     onclick="fold_message_stanza(this, '<%loc('Show quoted text')%>', '<%loc('Hide quoted text')%>');"><%loc('Show quoted text')%></span><br />\
diff --git a/share/html/Ticket/Elements/ShowMessageStanza b/share/html/Ticket/Elements/ShowMessageStanza
index 3538e30..221ab86 100755
--- a/share/html/Ticket/Elements/ShowMessageStanza
+++ b/share/html/Ticket/Elements/ShowMessageStanza
@@ -114,9 +114,9 @@ AGAIN: foreach ( ; $i < @$Message; $i++ ) {
         if ( $Depth == 1 ) {
             $m->comp('FoldStanzaJS');
         }
-        $m->out(   '<div class="message-stanza"'
-                 . ( $Depth == 1 ? ' style="display: none;" ' : '' )
-                 . '>' );
+        my @classes = ('message-stanza');
+        push @classes, $Depth == 1 ? 'closed' : 'open';
+        $m->out(   '<div class="' . join(" ", @classes) . '">' );
     }
     if ( length $para ) {
         $print_content->( \$para );

commit 191d9a1aa912d979cdf254421aae27754a529fd5
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Sep 2 12:54:01 2011 -0400

    Add a link to toggle all quote folds at once
    
    As an aside, we really need a l10n dictionary in javascript instead of
    embedding translated strings everywhere.

diff --git a/share/html/NoAuth/js/history-folding.js b/share/html/NoAuth/js/history-folding.js
index 6afe868..66a9439 100644
--- a/share/html/NoAuth/js/history-folding.js
+++ b/share/html/NoAuth/js/history-folding.js
@@ -55,3 +55,19 @@ function fold_message_stanza(e,showmsg, hidemsg) {
         jQuery(e).text( showmsg);
     }
 }
+
+function toggle_all_folds(e, showmsg, hidemsg) {
+    var link    = jQuery(e);
+    var history = link.closest(".history");
+    var dir     = link.attr('data-direction');
+
+    if (dir == 'open') {
+        history.find(".message-stanza-folder.closed").click();
+        link.attr('data-direction', 'closed').text(hidemsg);
+    }
+    else if (dir == 'closed') {
+        history.find(".message-stanza-folder.open").click();
+        link.attr('data-direction', 'open').text(showmsg);
+    }
+    return false;
+}
diff --git a/share/html/Ticket/Elements/ShowHistory b/share/html/Ticket/Elements/ShowHistory
index a4b1fdc..411ba33 100755
--- a/share/html/Ticket/Elements/ShowHistory
+++ b/share/html/Ticket/Elements/ShowHistory
@@ -60,6 +60,12 @@ if ($ShowDisplayModes or $ShowTitle) {
     if ($ShowDisplayModes) {
         $titleright = '';
         
+        my $open_all  = $m->interp->apply_escapes( loc("Show all quotes"), 'h' );
+        my $close_all = $m->interp->apply_escapes( loc("Hide all quotes"), 'h' );
+        $titleright .=    '<a href="#" data-direction="open" '
+                        . qq{onclick='return toggle_all_folds(this, "$open_all", "$close_all");'}
+                        . ">$open_all</a> — ";
+
         if ($ShowHeaders) {
             $titleright .= qq{<a href="$URIFile?id=} .
                            $Ticket->id.qq{">} .

-----------------------------------------------------------------------


More information about the Rt-commit mailing list