r101263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101262‎ | r101263 | r101264 >
Date:14:39, 29 October 2011
Author:liangent
Status:deferred
Tags:
Comment:
* Followup r101262: Fix the bug that .mw-customcollapsiblechildren does not work together with .mw-collapsed correctly
* Fix the bug that #mw-customcollapsible-* with .mw-collapsed are not hidden instantly (the fourth argument of toggleElement)
* In customcollapsible, .mw-customtoggletext inside #mw-customtoggle-* or .mw-customtoggle will be replaced with proper expandtext or collapsetext
* Indention fix in original file
Modified paths:
  • /branches/liangent/makeCollapsible_custom/phase3/resources/jquery/jquery.makeCollapsible.js (modified) (history)

Diff [purge]

Index: branches/liangent/makeCollapsible_custom/phase3/resources/jquery/jquery.makeCollapsible.js
@@ -201,16 +201,30 @@
202202 },
203203 // Toggles customcollapsible
204204 toggleLinkCustom = function( $that, e, $collapsible ) {
 205+ var instantHide = true;
205206 // For the initial state call of customtogglers there is no event passed
206207 if (e) {
207208 e.preventDefault();
208 - e.stopPropagation();
 209+ e.stopPropagation();
 210+ $collapsible.toggleClass( 'mw-collapsed' );
 211+ instantHide = false;
209212 }
210 - // Get current state and toggle to the opposite
211 - var action = $collapsible.hasClass( 'mw-collapsed' ) ? 'expand' : 'collapse';
212 - $collapsible.toggleClass( 'mw-collapsed' );
213 - toggleElement( $collapsible, action, $that );
214213
 214+ // It's expanded right now
 215+ if ( $collapsible.hasClass( 'mw-collapsed' ) ) {
 216+ // Change text to "Show"
 217+ $( '.mw-customtoggletext', $that ).text( expandtext );
 218+ // Collapse element
 219+ toggleElement( $collapsible, 'collapse', $that, instantHide );
 220+
 221+ // It's collapsed right now
 222+ } else {
 223+ // Change text to "Hide"
 224+ $( '.mw-customtoggletext', $that ).text( collapsetext );
 225+ // Expand element
 226+ toggleElement( $collapsible, 'expand', $that, instantHide );
 227+ }
 228+ return;
215229 };
216230
217231 // Use custom text or default ?
@@ -260,8 +274,9 @@
261275
262276 // Initial state
263277 if ( $that.hasClass( 'mw-collapsed' ) ) {
264 - $that.removeClass( 'mw-collapsed' );
265278 toggleLinkCustom( $customTogglers, null, $that );
 279+ } else {
 280+ $( '.mw-customtoggletext', $customTogglers ).text( collapsetext );
266281 }
267282
268283 // Custom toggle link specified by children with a certain class
@@ -275,13 +290,14 @@
276291 toggleLinkCustom( $(this), e, $that );
277292 } );
278293 } else {
279 - mw.log( _fn + '<children> .mw-customtoggle: Missing toggler!' );
 294+ mw.log( _fn + '.mw-customcollapsiblechildren: Missing toggler!' );
280295 }
281296
282297 // Initial state
283298 if ( $that.hasClass( 'mw-collapsed' ) ) {
284 - $that.removeClass( 'mw-collapsed' );
285299 toggleLinkCustom( $customTogglers, null, $that );
 300+ } else {
 301+ $( '.mw-customtoggletext', $customTogglers ).text( collapsetext );
286302 }
287303
288304 // If this is not a custom case, do the default:
@@ -346,7 +362,8 @@
347363 }
348364
349365 // Initial state (only for those that are not custom)
350 - if ( $that.hasClass( 'mw-collapsed' ) && ( $that.attr( 'id' ) || '').indexOf( 'mw-customcollapsible-' ) !== 0 ) {
 366+ if ( $that.hasClass( 'mw-collapsed' ) && !$that.hasClass( 'mw-customcollapsiblechildren' )
 367+ && ( $that.attr( 'id' ) || '').indexOf( 'mw-customcollapsible-' ) !== 0 ) {
351368 $that.removeClass( 'mw-collapsed' );
352369 // The collapsible element could have multiple togglers
353370 // To toggle the initial state only click one of them (ie. the first one, eq(0) )

Follow-up revisions

RevisionCommit summaryAuthorDate
r101275* Followup r101263: Fix the bug that if there're more than one custom toggles...liangent18:06, 29 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101262Allow custom toggle links to be specified by children with a certain class....liangent13:44, 29 October 2011

Status & tagging log