Theopolisme has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/97348


Change subject: jquery.makeCollapsible: collapse to caption support
......................................................................

jquery.makeCollapsible: collapse to caption support

When collapsing a table with a caption, hide everything
except the caption.

Bug: 47139
Change-Id: I034574cb4dd823d64ff2b3c349457aaddd84281d
---
M resources/jquery/jquery.makeCollapsible.css
M resources/jquery/jquery.makeCollapsible.js
2 files changed, 30 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/97348/1

diff --git a/resources/jquery/jquery.makeCollapsible.css 
b/resources/jquery/jquery.makeCollapsible.css
index 993fa8c..38938ab 100644
--- a/resources/jquery/jquery.makeCollapsible.css
+++ b/resources/jquery/jquery.makeCollapsible.css
@@ -3,6 +3,11 @@
        float: right;
 }
 
+/* collapse links in captions should be inline */
+caption .mw-collapsible-toggle {
+       float: none;
+}
+
 /* list-items go as wide as their parent element, don't float them inside list 
items */
 li .mw-collapsible-toggle {
        float: none;
diff --git a/resources/jquery/jquery.makeCollapsible.js 
b/resources/jquery/jquery.makeCollapsible.js
index 0cd6417..bac8606 100644
--- a/resources/jquery/jquery.makeCollapsible.js
+++ b/resources/jquery/jquery.makeCollapsible.js
@@ -235,7 +235,7 @@
                }
 
                return this.each( function () {
-                       var $collapsible, collapseText, expandText, $toggle, 
actionHandler, buildDefaultToggleLink,
+                       var $collapsible, collapseText, expandText, $caption, 
$toggle, actionHandler, buildDefaultToggleLink,
                                premadeToggleHandler, $toggleLink, $firstItem, 
collapsibleId, $customTogglers, firstval;
 
                        // Ensure class "mw-collapsible" is present in case 
.makeCollapsible()
@@ -313,16 +313,32 @@
                                // contents and add the toggle link. Different 
elements are
                                // treated differently.
                                if ( $collapsible.is( 'table' ) ) {
-                                       // The toggle-link will be in one the 
the cells (td or th) of the first row
-                                       $firstItem = $collapsible.find( 
'tr:first th, tr:first td' );
-                                       $toggle = $firstItem.find( '> 
.mw-collapsible-toggle' );
 
-                                       // If theres no toggle link, add it to 
the last cell
-                                       if ( !$toggle.length ) {
-                                               $toggleLink = 
buildDefaultToggleLink().prependTo( $firstItem.eq( -1 ) );
+                                       // If the table has a caption, collapse 
to the caption
+                                       // as opposed to the first row
+                                       $caption = $collapsible.find( 'caption' 
);
+                                       if ( $caption.length ) {
+                                               $toggle = $caption.find( '> 
.mw-collapsible-toggle' );
+
+                                               // If there is no toggle link, 
add it to the end of the caption
+                                               if ( !$toggle.length ) {
+                                                       $toggleLink = 
buildDefaultToggleLink().appendTo( $caption );
+                                               } else {
+                                                       actionHandler = 
premadeToggleHandler;
+                                                       $toggleLink = 
$toggle.on( 'click.mw-collapsible keypress.mw-collapsible', actionHandler );
+                                               }
                                        } else {
-                                               actionHandler = 
premadeToggleHandler;
-                                               $toggleLink = $toggle.on( 
'click.mw-collapsible keypress.mw-collapsible', actionHandler );
+                                               // The toggle-link will be in 
one the the cells (td or th) of the first row
+                                               $firstItem = $collapsible.find( 
'tr:first th, tr:first td' );
+                                               $toggle = $firstItem.find( '> 
.mw-collapsible-toggle' );
+
+                                               // If theres no toggle link, 
add it to the last cell
+                                               if ( !$toggle.length ) {
+                                                       $toggleLink = 
buildDefaultToggleLink().prependTo( $firstItem.eq( -1 ) );
+                                               } else {
+                                                       actionHandler = 
premadeToggleHandler;
+                                                       $toggleLink = 
$toggle.on( 'click.mw-collapsible keypress.mw-collapsible', actionHandler );
+                                               }
                                        }
 
                                } else if ( $collapsible.is( 'ul' ) || 
$collapsible.is( 'ol' ) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/97348
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I034574cb4dd823d64ff2b3c349457aaddd84281d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Theopolisme <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to