r81550 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81549‎ | r81550 | r81551 >
Date:01:05, 5 February 2011
Author:neilk
Status:deferred (Comments)
Tags:
Comment:
followup to r77648 -- automatically added hidden categories such as Uploaded_by_UploadWizard are now configurable
Modified paths:
  • /trunk/extensions/UploadWizard/SpecialUploadWizard.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardPage.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/jquery/jquery.mwCoolCats.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/jquery/jquery.mwCoolCats.js
@@ -5,11 +5,14 @@
66 */
77 ( function ( $j ) { $j.fn.mwCoolCats = function( options ) {
88
 9+ debugger;
910 var defaults = {
10 - buttontext: 'Add'
 11+ buttontext: 'Add',
 12+ hiddenCats: [],
 13+ cats: []
1114 };
1215
13 - var settings = $j.extend( {}, defaults, options);
 16+ var settings = $j.extend( {}, defaults, options );
1417
1518 // usually Category:Foo
1619 var categoryNamespace = wgFormattedNamespaces[wgNamespaceIds['category']];
@@ -61,8 +64,12 @@
6265 .join( "\n" );
6366 };
6467
 68+ // initialize with some categories, if so configured
 69+ $j.each( settings.cats, function( i, cat ) { _insertCat( cat ); } );
 70+ $j.each( settings.hiddenCats, function( i, cat ) { _insertCat( cat, true ); } );
 71+
6572 _processInput();
66 - });
 73+ } );
6774
6875 function _processInput() {
6976 var $input = $container.find( 'input' );
@@ -70,15 +77,20 @@
7178 $input.val("");
7279 }
7380
74 - function _insertCat( cat ) {
 81+ function _insertCat( cat, isHidden ) {
7582 if ( mw.isEmpty( cat ) || _containsCat( cat ) ) {
7683 return;
7784 }
78 - var href = _catLink( cat );
79 - var $li = $j( '<li class="cat"></li>' );
 85+ var $li = $j( '<li/>' ).addClass( 'cat' );
 86+ var $anchor = $j( '<a/>' ).addClass( 'cat' ).append( cat );
 87+ $li.append( $anchor );
 88+ if ( isHidden ) {
 89+ $li.hide();
 90+ } else {
 91+ $anchor.attr( { target: "_new", href: _catLink( cat ) } );
 92+ $li.append( $j.fn.removeCtrl( null, 'mwe-upwiz-category-remove', function() { $li.remove(); } ) );
 93+ }
8094 $container.find( 'ul' ).append( $li );
81 - $li.append( '<a class="cat" target="_new" href="' + href + '">' + cat +' </a>' );
82 - $li.append( $j.fn.removeCtrl( null, 'mwe-upwiz-category-remove', function() { $li.remove(); } ) );
8395 }
8496
8597 function _catLink( cat ) {
@@ -133,4 +145,4 @@
134146 $j( _this ).data( 'request', request );
135147 }
136148
137 -}})(jQuery);
 149+}; } )( jQuery );
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -917,13 +917,17 @@
918918 $j( containerDiv ).append( _this.div );
919919
920920 // make this a category picker
 921+ var hiddenCats = [];
 922+ if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) ) {
 923+ hiddenCats.push( mw.UploadWizard.config.autoCategory );
 924+ }
921925 $categoriesDiv.find( '.mwe-upwiz-details-input' )
922926 .find( 'input' )
923 - .mwCoolCats( { buttontext: gM( 'mwe-upwiz-categories-add' ) } );
 927+ .mwCoolCats( {
 928+ hiddenCats: hiddenCats,
 929+ buttontext: gM( 'mwe-upwiz-categories-add' )
 930+ } );
924931
925 - // add hidden category for stats purposes
926 - $categoriesDiv.find( 'ul.cat-list' ).append( $j( '<li style="display: none;"><a class="cat">Uploaded with UploadWizard</a></li>' ) );
927 -
928932 };
929933
930934 mw.UploadWizardDetails.prototype = {
Index: trunk/extensions/UploadWizard/SpecialUploadWizard.php
@@ -86,10 +86,13 @@
8787 */
8888 public function addJsVars( $subPage ) {
8989 global $wgUser, $wgOut, $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI,
90 - $wgEnableFirefogg, $wgFileExtensions,$wgUploadWizardDebug, $wgSitename;
 90+ $wgEnableFirefogg, $wgFileExtensions,$wgUploadWizardDebug, $wgSitename,
 91+ $wgUploadWizardAutoCategory;
9192
9293 $wgOut->addScript( Skin::makeVariablesScript( array(
9394 'wgUploadWizardDebug' => (bool)$wgUploadWizardDebug,
 95+
 96+ 'wgUploadWizardAutoCategory' => $wgUploadWizardAutoCategory,
9497
9598 // uncertain if this is relevant. Can we do license preview with API?
9699 'wgAjaxLicensePreview' => $wgUseAjax && $wgAjaxLicensePreview,
Index: trunk/extensions/UploadWizard/UploadWizardPage.js
@@ -16,6 +16,7 @@
1717
1818 var config = {
1919 debug: wgUploadWizardDebug,
 20+ autoCategory: wgUploadWizardAutoCategory,
2021 userName: wgUserName,
2122 userLanguage: wgUserLanguage,
2223 fileExtensions: wgFileExtensions,

Follow-up revisions

RevisionCommit summaryAuthorDate
r81551followup to r81550 -- forgot to remove debugger;neilk01:10, 5 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77648Part 3 of r77646: reapply r76964, r76965, r76966catrope13:33, 3 December 2010

Comments

#Comment by NeilK (talk | contribs)   01:06, 5 February 2011

Whoops, there was a typo -- this is a followup to r77468, not r77648.

Status & tagging log