Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -3473,6 +3473,9 @@ |
3474 | 3474 | 'ajax-add-category-summary', |
3475 | 3475 | 'ajax-edit-category-summary', |
3476 | 3476 | 'ajax-remove-category-summary', |
| 3477 | + 'ajax-add-category-question', |
| 3478 | + 'ajax-edit-category-question', |
| 3479 | + 'ajax-remove-category-question', |
3477 | 3480 | 'ajax-confirm-actionsummary', |
3478 | 3481 | 'ajax-error-title', |
3479 | 3482 | 'ajax-error-dismiss', |
Index: trunk/phase3/tests/qunit/index.html |
— | — | @@ -47,9 +47,11 @@ |
48 | 48 | <script src="../../resources/jquery/jquery.localize.js"></script> |
49 | 49 | <script src="../../resources/jquery/jquery.tabIndex.js"></script> |
50 | 50 | <script src="../../resources/jquery/jquery.tablesorter.js"></script> |
| 51 | + <script src="../../resources/jquery/jquery.suggestions.js"></script> |
51 | 52 | <script src="../../resources/mediawiki/mediawiki.Title.js"></script> |
52 | 53 | <script src="../../resources/mediawiki.special/mediawiki.special.js"></script> |
53 | 54 | <script src="../../resources/mediawiki.special/mediawiki.special.recentchanges.js"></script> |
| 55 | + <script src="../../resources/mediawiki.page/mediawiki.page.ajaxCategories.js"></script> |
54 | 56 | |
55 | 57 | <!-- QUnit: Load framework --> |
56 | 58 | <link rel="stylesheet" href="../../resources/jquery/jquery.qunit.css" /> |
— | — | @@ -75,6 +77,7 @@ |
76 | 78 | <script src="suites/resources/jquery/jquery.tablesorter.test.js" charset="UTF-8"></script> |
77 | 79 | <script src="suites/resources/mediawiki/mediawiki.Title.js"></script> |
78 | 80 | <script src="suites/resources/mediawiki.special/mediawiki.special.recentchanges.js"></script> |
| 81 | + <!--<script src="suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js"></script>--> |
79 | 82 | </head> |
80 | 83 | <body> |
81 | 84 | <h1 id="qunit-header">MediaWiki JavaScript Test Suite</h1> |
— | — | @@ -85,7 +88,7 @@ |
86 | 89 | <h2 id="qunit-userAgent"></h2> |
87 | 90 | <ol id="qunit-tests"></ol> |
88 | 91 | |
89 | | -<!-- Scripts inserting stuff here shall remove it themselfs! --> |
| 92 | +<!-- Scripts inserting stuff here shall remove it themselves! --> |
90 | 93 | <div id="content"></div> |
91 | 94 | </body> |
92 | 95 | </html> |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js |
— | — | @@ -0,0 +1,36 @@ |
| 2 | +(function( mw ) { |
| 3 | + |
| 4 | +module( 'mediawiki.page.ajaxCategories.js' ); |
| 5 | +mw.config.set( 'wgNamespaceIds', {'category' : 14} ); |
| 6 | +test( '-- Initial check', function() { |
| 7 | + expect(1); |
| 8 | + ok( mw.ajaxCategories, 'mw.ajaxCategories defined' ); |
| 9 | +}); |
| 10 | + |
| 11 | +/** |
| 12 | + * Create a category list like the one found below articles. |
| 13 | + * @param {String[]} categories |
| 14 | + * @return jQuery |
| 15 | + */ |
| 16 | +var listCreate = function( categories ) { |
| 17 | + var $container = $('<div id="catlinks" class="catlinks"><div id="mw-normal-catlinks"><ul></ul></div></div>'), |
| 18 | + $ul = $container.find('ul'); |
| 19 | + $.each( categories, function(i, str) { |
| 20 | + var $li = $('<li>'); |
| 21 | + $li.text(str).appendTo($ul); |
| 22 | + }); |
| 23 | + |
| 24 | + return $container; |
| 25 | +}; |
| 26 | +catList1 = ['Earth satellites', 'Space stations', 'astronauts']; |
| 27 | + |
| 28 | +test( 'Testing containsCat', function() { |
| 29 | + expect(1); |
| 30 | + $( 'body' ).append( listCreate(catList1) ); |
| 31 | + mw.ajaxCategories.setup(); |
| 32 | + var ret = mw.ajaxCategories.containsCat('Earth satellites') |
| 33 | + |
| 34 | + equal(ret, true); |
| 35 | +}); |
| 36 | + |
| 37 | +})( mediaWiki ); |
\ No newline at end of file |
Property changes on: trunk/phase3/tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 38 | + native |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4602,6 +4602,9 @@ |
4603 | 4603 | 'ajax-add-category-summary' => 'Add category "$1"', |
4604 | 4604 | 'ajax-edit-category-summary' => 'Change category "$1" to "$2"', |
4605 | 4605 | 'ajax-remove-category-summary' => 'Remove category "$1"', |
| 4606 | +'ajax-add-category-question' => 'Why do you want to add category "$1"?', |
| 4607 | +'ajax-edit-category-question' => 'Why do you want to change category "$1" to "$2"?', |
| 4608 | +'ajax-remove-category-question'=> 'Why do you want to remove category "$1"?', |
4606 | 4609 | 'ajax-confirm-actionsummary' => 'Action to take:', |
4607 | 4610 | 'ajax-error-title' => 'Error', |
4608 | 4611 | 'ajax-error-dismiss' => 'OK', |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -508,6 +508,9 @@ |
509 | 509 | 'ajax-add-category-summary', |
510 | 510 | 'ajax-remove-category-summary', |
511 | 511 | 'ajax-edit-category-summary', |
| 512 | + 'ajax-add-category-question', |
| 513 | + 'ajax-edit-category-question', |
| 514 | + 'ajax-remove-category-question', |
512 | 515 | 'ajax-confirm-actionsummary', |
513 | 516 | 'ajax-error-title', |
514 | 517 | 'ajax-error-dismiss', |
Index: trunk/phase3/resources/mediawiki/mediawiki.util.js |
— | — | @@ -99,6 +99,12 @@ |
100 | 100 | $tocToggleLink.click(); |
101 | 101 | } |
102 | 102 | } |
| 103 | + /* Ajax Categories */ |
| 104 | + if ( mw.ajaxCategories ) { |
| 105 | + // Execute only on doc.ready, so that everyone |
| 106 | + // gets a chance to set mw.config.set('disableAJAXCategories') |
| 107 | + mw.ajaxCategories.setup() |
| 108 | + } |
103 | 109 | } ); |
104 | 110 | |
105 | 111 | return true; |
Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | // strip out bad characters |
87 | 87 | cat = _stripIllegals ( cat ); |
88 | 88 | |
89 | | - if ( $.isEmpty( cat ) || _containsCat( cat ) ) { |
| 89 | + if ( $.isEmpty( cat ) || this.containsCat( cat ) ) { |
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | * |
159 | 159 | * @return boolean True for exists |
160 | 160 | */ |
161 | | - _containsCat = function ( cat ) { |
| 161 | + this.containsCat = function ( cat ) { |
162 | 162 | return _getCats().filter( function() { return $.ucFirst(this) == $.ucFirst(cat); } ).length !== 0; |
163 | 163 | }; |
164 | 164 | |
— | — | @@ -449,7 +449,7 @@ |
450 | 450 | var category = $( this ).parent().find( '.mw-addcategory-input' ).val(); |
451 | 451 | category = $.ucFirst( category ); |
452 | 452 | |
453 | | - if ( _containsCat(category) ) { |
| 453 | + if ( this.containsCat(category) ) { |
454 | 454 | _showError( mw.msg( 'ajax-category-already-present', category ) ); |
455 | 455 | return; |
456 | 456 | } |
— | — | @@ -463,6 +463,7 @@ |
464 | 464 | }, |
465 | 465 | summary, |
466 | 466 | function() { |
| 467 | + $container.find( '#mw-normal-catlinks>.mw-addcategory-prompt' ).toggle(); |
467 | 468 | _insertCatDOM( category, false ); |
468 | 469 | } |
469 | 470 | ); |
— | — | @@ -687,8 +688,4 @@ |
688 | 689 | // Now make a new version |
689 | 690 | mw.ajaxCategories = new ajaxCategories(); |
690 | 691 | |
691 | | -// Executing only on doc.ready, so that everyone |
692 | | -// gets a chance to set mw.config.set('disableAJAXCategories') |
693 | | -$( document ).ready( mw.ajaxCategories.setup() ); |
694 | | - |
695 | 692 | } )( jQuery, mediaWiki ); |
\ No newline at end of file |