r112851 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112850‎ | r112851 | r112852 >
Date:23:43, 1 March 2012
Author:krinkle
Status:ok
Tags:
Comment:
[CategoryTree] clean up JS
* 0 is falsy, cover for that case
* Add comments explaining the numbers, these come from PHP constants, via $wgCategoryTreePageCategoryOptions end up in data- attributes
* Follow-up r112849
Modified paths:
  • /trunk/extensions/CategoryTree/modules/ext.categoryTree.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/modules/ext.categoryTree.js
@@ -110,7 +110,8 @@
111111 // Element may not have a .CategoryTreeTag parent, fallback to defauls
112112 // Probably a CategoryPage (@todo: based on what?)
113113 ctTitle = $link.data( 'ct-title' );
114 - ctMode = $linkParentCTTag.data( 'ct-mode' ) || undefined;
 114+ ctMode = $linkParentCTTag.data( 'ct-mode' );
 115+ ctMode = typeof ctMode === 'number' ? ctMode : undefined;
115116 ctOptions = $linkParentCTTag.data( 'ct-options' ) || mw.config.get( 'wgCategoryTreePageCategoryOptions' );
116117
117118 // Mode and options have defaults or fallbacks, title does not.
@@ -133,15 +134,19 @@
134135
135136 if ( data === '' ) {
136137 switch ( ctMode ) {
 138+ // CT_MODE_CATEGORIES = 0
137139 case 0:
138140 data = mw.msg( 'categorytree-no-subcategories' );
139141 break;
 142+ // CT_MODE_PAGES = 10
140143 case 10:
141144 data = mw.msg( 'categorytree-no-pages' );
142145 break;
 146+ // CT_MODE_PARENTS = 100
143147 case 100:
144148 data = mw.msg( 'categorytree-no-parent-categories' );
145149 break;
 150+ // CT_MODE_ALL = 20
146151 default:
147152 data = mw.msg( 'categorytree-nothing-found' );
148153 }
@@ -153,6 +158,7 @@
154159 .html( data )
155160 .find( '.CategoryTreeToggle' )
156161 .click( categoryTree.handleNode );
 162+
157163 categoryTree.showToggles();
158164 } )
159165 .error( error );

Sign-offs

UserFlagDate
Nikerabbitinspected09:51, 2 March 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r112862MFT r112849, r112851, r112856, r112859aaron00:40, 2 March 2012
r113037MFT r110703, r110933, r111011, r111218, r112520, r112524, r112660, r112687, r...reedy14:59, 5 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112849[CategoryTree] clean up JS, fix undefined bug...krinkle23:04, 1 March 2012

Status & tagging log