Index: trunk/extensions/UploadWizard/resources/jquery/jquery.mwCoolCats.js |
— | — | @@ -5,11 +5,14 @@ |
6 | 6 | */ |
7 | 7 | ( function ( $j ) { $j.fn.mwCoolCats = function( options ) { |
8 | 8 | |
| 9 | + debugger; |
9 | 10 | var defaults = { |
10 | | - buttontext: 'Add' |
| 11 | + buttontext: 'Add', |
| 12 | + hiddenCats: [], |
| 13 | + cats: [] |
11 | 14 | }; |
12 | 15 | |
13 | | - var settings = $j.extend( {}, defaults, options); |
| 16 | + var settings = $j.extend( {}, defaults, options ); |
14 | 17 | |
15 | 18 | // usually Category:Foo |
16 | 19 | var categoryNamespace = wgFormattedNamespaces[wgNamespaceIds['category']]; |
— | — | @@ -61,8 +64,12 @@ |
62 | 65 | .join( "\n" ); |
63 | 66 | }; |
64 | 67 | |
| 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 | + |
65 | 72 | _processInput(); |
66 | | - }); |
| 73 | + } ); |
67 | 74 | |
68 | 75 | function _processInput() { |
69 | 76 | var $input = $container.find( 'input' ); |
— | — | @@ -70,15 +77,20 @@ |
71 | 78 | $input.val(""); |
72 | 79 | } |
73 | 80 | |
74 | | - function _insertCat( cat ) { |
| 81 | + function _insertCat( cat, isHidden ) { |
75 | 82 | if ( mw.isEmpty( cat ) || _containsCat( cat ) ) { |
76 | 83 | return; |
77 | 84 | } |
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 | + } |
80 | 94 | $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(); } ) ); |
83 | 95 | } |
84 | 96 | |
85 | 97 | function _catLink( cat ) { |
— | — | @@ -133,4 +145,4 @@ |
134 | 146 | $j( _this ).data( 'request', request ); |
135 | 147 | } |
136 | 148 | |
137 | | -}})(jQuery); |
| 149 | +}; } )( jQuery ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -917,13 +917,17 @@ |
918 | 918 | $j( containerDiv ).append( _this.div ); |
919 | 919 | |
920 | 920 | // make this a category picker |
| 921 | + var hiddenCats = []; |
| 922 | + if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) ) { |
| 923 | + hiddenCats.push( mw.UploadWizard.config.autoCategory ); |
| 924 | + } |
921 | 925 | $categoriesDiv.find( '.mwe-upwiz-details-input' ) |
922 | 926 | .find( 'input' ) |
923 | | - .mwCoolCats( { buttontext: gM( 'mwe-upwiz-categories-add' ) } ); |
| 927 | + .mwCoolCats( { |
| 928 | + hiddenCats: hiddenCats, |
| 929 | + buttontext: gM( 'mwe-upwiz-categories-add' ) |
| 930 | + } ); |
924 | 931 | |
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 | | - |
928 | 932 | }; |
929 | 933 | |
930 | 934 | mw.UploadWizardDetails.prototype = { |
Index: trunk/extensions/UploadWizard/SpecialUploadWizard.php |
— | — | @@ -86,10 +86,13 @@ |
87 | 87 | */ |
88 | 88 | public function addJsVars( $subPage ) { |
89 | 89 | global $wgUser, $wgOut, $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI, |
90 | | - $wgEnableFirefogg, $wgFileExtensions,$wgUploadWizardDebug, $wgSitename; |
| 90 | + $wgEnableFirefogg, $wgFileExtensions,$wgUploadWizardDebug, $wgSitename, |
| 91 | + $wgUploadWizardAutoCategory; |
91 | 92 | |
92 | 93 | $wgOut->addScript( Skin::makeVariablesScript( array( |
93 | 94 | 'wgUploadWizardDebug' => (bool)$wgUploadWizardDebug, |
| 95 | + |
| 96 | + 'wgUploadWizardAutoCategory' => $wgUploadWizardAutoCategory, |
94 | 97 | |
95 | 98 | // uncertain if this is relevant. Can we do license preview with API? |
96 | 99 | 'wgAjaxLicensePreview' => $wgUseAjax && $wgAjaxLicensePreview, |
Index: trunk/extensions/UploadWizard/UploadWizardPage.js |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | |
18 | 18 | var config = { |
19 | 19 | debug: wgUploadWizardDebug, |
| 20 | + autoCategory: wgUploadWizardAutoCategory, |
20 | 21 | userName: wgUserName, |
21 | 22 | userLanguage: wgUserLanguage, |
22 | 23 | fileExtensions: wgFileExtensions, |