Index: trunk/extensions/UploadWizard/js/jquery/plugins/jquery.mwCoolCats.js |
— | — | @@ -1,26 +1,18 @@ |
2 | | -RegExp.escape = (function() { |
3 | | - var specials = [ |
4 | | - '/', '.', '*', '+', '?', '|', |
5 | | - '(', ')', '[', ']', '{', '}', '\\' |
6 | | - ]; |
| 2 | +( function ( $j ) { $j.fn.mwCoolCats = function( options ) { |
7 | 3 | |
8 | | - sRE = new RegExp( |
9 | | - '(\\' + specials.join('|\\') + ')', 'g' |
10 | | - ); |
11 | | - |
12 | | - return function(text) { |
13 | | - return text.replace(sRE, '\\$1'); |
14 | | - } |
15 | | -})(); |
16 | | -(function($){ |
17 | | - $.fn.mwCoolCats = function(options) { |
18 | 4 | var defaults = { |
19 | 5 | buttontext: 'Add' |
20 | 6 | }; |
21 | | - var settings = $.extend( {}, defaults, options); |
| 7 | + |
| 8 | + var settings = $j.extend( {}, defaults, options); |
| 9 | + |
| 10 | + // usually Category:Foo |
| 11 | + var categoryNamespace = wgFormattedNamespaces[wgNamespaceIds['category']]; |
| 12 | + |
22 | 13 | var $container; |
23 | 14 | return this.each( function() { |
24 | 15 | var _this = $j( this ); |
| 16 | + _this.addClass( 'categoryInput' ); |
25 | 17 | |
26 | 18 | _this.suggestions( { |
27 | 19 | 'fetch': _fetchSuggestions, |
— | — | @@ -57,7 +49,6 @@ |
58 | 50 | } |
59 | 51 | }); |
60 | 52 | |
61 | | - var categoryNamespace = mw.getConfig( 'categoryNamespace' ); |
62 | 53 | this.getWikiText = function() { |
63 | 54 | return _getCats().map( function() { return '[[' + categoryNamespace + ':' + this + ']]'; } ) |
64 | 55 | .toArray() |
— | — | @@ -86,9 +77,9 @@ |
87 | 78 | |
88 | 79 | function _catLink( cat ) { |
89 | 80 | var catLink = |
90 | | - encodeURIComponent( wgFormattedNamespaces[wgNamespaceIds['category']] ) |
| 81 | + encodeURIComponent( categoryNamespace ) |
91 | 82 | + ':' |
92 | | - + encodeURIComponent( mw.ucfirst( $j.trim( cat ).replace(/ /g, '_' ) ) ); |
| 83 | + + encodeURIComponent( mw.ucfirst( cat.replace(/ /g, '_' ) ) ); |
93 | 84 | |
94 | 85 | // wgServer typically like 'http://commons.prototype.wikimedia.org' |
95 | 86 | // wgArticlePath typically like '/wiki/$1' |
— | — | @@ -100,7 +91,7 @@ |
101 | 92 | } |
102 | 93 | |
103 | 94 | function _getCats() { |
104 | | - return $container.find('ul li a.cat').map( function() { return this.text; } ); |
| 95 | + return $container.find('ul li a.cat').map( function() { return $j.trim( this.text ); } ); |
105 | 96 | } |
106 | 97 | |
107 | 98 | function _containsCat( cat ) { |
— | — | @@ -136,5 +127,4 @@ |
137 | 128 | $j( _this ).data( 'request', request ); |
138 | 129 | } |
139 | 130 | |
140 | | - |
141 | | - }})(jQuery); |
| 131 | +}})(jQuery); |
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js |
— | — | @@ -1284,7 +1284,9 @@ |
1285 | 1285 | // all other fields validated with validator js |
1286 | 1286 | var formValid = _this.$form.valid(); |
1287 | 1287 | return titleInputValid && formValid; |
1288 | | - |
| 1288 | + |
| 1289 | + // categories are assumed valid |
| 1290 | + |
1289 | 1291 | // the license, if any |
1290 | 1292 | |
1291 | 1293 | // pop open the 'more-options' if the date is bad |
— | — | @@ -1720,14 +1722,12 @@ |
1721 | 1723 | getWikiText: function() { |
1722 | 1724 | var _this = this; |
1723 | 1725 | |
1724 | | - // XXX validate! |
| 1726 | + // if invalid, should produce side effects in the form |
| 1727 | + // instructing user to fix. |
1725 | 1728 | if ( ! _this.valid() ) { |
1726 | | - alert( "THIS DEED IS NOT READY" ); |
1727 | 1729 | return null; |
1728 | 1730 | } |
1729 | 1731 | |
1730 | | - |
1731 | | - |
1732 | 1732 | wikiText = ''; |
1733 | 1733 | |
1734 | 1734 | |
— | — | @@ -1773,19 +1773,21 @@ |
1774 | 1774 | |
1775 | 1775 | wikiText += '{{Information\n' + info + '}}\n'; |
1776 | 1776 | |
1777 | | - |
1778 | | - wikiText += "=={{int:license-header}}==\n"; |
1779 | | - |
1780 | | - wikiText += deed.getLicenseWikiText(); |
| 1777 | + // add a location template if possible |
1781 | 1778 | |
1782 | | - // add a location template |
1783 | | - |
1784 | 1779 | // add an "anything else" template if needed |
1785 | 1780 | var otherInfoWikiText = $j( _this.otherInformationInput ).val().trim(); |
1786 | 1781 | if ( ! mw.isEmpty( otherInfoWikiText ) ) { |
1787 | 1782 | wikiText += "=={{int:otherinfo}}==\n"; |
1788 | 1783 | wikiText += otherInfoWikiText; |
1789 | 1784 | } |
| 1785 | + |
| 1786 | + wikiText += "=={{int:license-header}}==\n"; |
| 1787 | + |
| 1788 | + // in the other implementations, category text follows immediately after license text. This helps |
| 1789 | + // group categories together, maybe? |
| 1790 | + wikiText += deed.getLicenseWikiText() + _this.div.find( '.categoryInput' ).get(0).getWikiText(); |
| 1791 | + |
1790 | 1792 | |
1791 | 1793 | return wikiText; |
1792 | 1794 | }, |