Revert r92238: partial addition of broken test cases to qunit test suite; loading...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 15 Jul 2011 17:29:17 +0000 (17:29 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 15 Jul 2011 17:29:17 +0000 (17:29 +0000)
languages/messages/MessagesEn.php
maintenance/language/messages.inc
resources/Resources.php
resources/mediawiki.page/mediawiki.page.ajaxCategories.js
resources/mediawiki/mediawiki.util.js
tests/qunit/index.html
tests/qunit/suites/resources/jquery/jquery.localize.js
tests/qunit/suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js

index c34e888..e64fd6b 100644 (file)
@@ -4602,9 +4602,6 @@ Click "Save" to save your edit.',
 'ajax-add-category-summary'    => 'Add category "$1"',
 'ajax-edit-category-summary'   => 'Change category "$1" to "$2"',
 'ajax-remove-category-summary' => 'Remove category "$1"',
-'ajax-add-category-question'   => 'Why do you want to add category "$1"?',
-'ajax-edit-category-question'  => 'Why do you want to change category "$1" to "$2"?',
-'ajax-remove-category-question'=> 'Why do you want to remove category "$1"?',
 'ajax-confirm-actionsummary'   => 'Action to take:',
 'ajax-error-title'             => 'Error',
 'ajax-error-dismiss'           => 'OK',
index 90b3252..a66d1a5 100644 (file)
@@ -3473,9 +3473,6 @@ $wgMessageStructure = array(
                'ajax-add-category-summary',
                'ajax-edit-category-summary',
                'ajax-remove-category-summary',
-               'ajax-add-category-question',
-               'ajax-edit-category-question',
-               'ajax-remove-category-question',
                'ajax-confirm-actionsummary',
                'ajax-error-title',
                'ajax-error-dismiss',
index 272a033..98b508e 100644 (file)
@@ -508,9 +508,6 @@ return array(
                        'ajax-add-category-summary',
                        'ajax-remove-category-summary',
                        'ajax-edit-category-summary',
-                       'ajax-add-category-question',
-                       'ajax-edit-category-question',
-                       'ajax-remove-category-question',
                        'ajax-confirm-actionsummary',
                        'ajax-error-title',
                        'ajax-error-dismiss',
index 9f52715..ff3b727 100644 (file)
@@ -85,7 +85,7 @@ var ajaxCategories = function ( options ) {
                // strip out bad characters
                cat = _stripIllegals ( cat );
 
-               if ( $.isEmpty( cat ) || this.containsCat( cat ) ) { 
+               if ( $.isEmpty( cat ) || _containsCat( cat ) ) { 
                        return; 
                }
 
@@ -157,7 +157,7 @@ var ajaxCategories = function ( options ) {
         * 
         * @return boolean True for exists
         */
-       this.containsCat = function ( cat ) {
+       _containsCat = function ( cat ) {
                return _getCats().filter( function() { return $.ucFirst(this) == $.ucFirst(cat); } ).length !== 0;
        };
        
@@ -449,7 +449,7 @@ var ajaxCategories = function ( options ) {
                var category = $( this ).parent().find( '.mw-addcategory-input' ).val();
                category = $.ucFirst( category );
 
-               if ( this.containsCat(category) ) {
+               if ( _containsCat(category) ) {
                        _showError( mw.msg( 'ajax-category-already-present', category ) );
                        return;
                }
@@ -463,7 +463,6 @@ var ajaxCategories = function ( options ) {
                        },
                        summary,
                        function() {
-                               $container.find( '#mw-normal-catlinks>.mw-addcategory-prompt' ).toggle();
                                _insertCatDOM( category, false );
                        }
                );
@@ -688,4 +687,8 @@ var ajaxCategories = function ( options ) {
 // Now make a new version
 mw.ajaxCategories = new ajaxCategories();
 
+// Executing only on doc.ready, so that everyone 
+// gets a chance to set mw.config.set('disableAJAXCategories')
+$( document ).ready( mw.ajaxCategories.setup() );
+
 } )( jQuery, mediaWiki );
\ No newline at end of file
index 38584c0..ebd63ef 100644 (file)
                                                        $tocToggleLink.click();
                                                }
                                        }
-                                       /* Ajax Categories */
-                                       if ( mw.ajaxCategories ) {
-                                               // Execute only on doc.ready, so that everyone 
-                                               // gets a chance to set mw.config.set('disableAJAXCategories')
-                                               mw.ajaxCategories.setup()
-                                       }
                                } );
 
                                return true;
index f27f1d2..f0db23c 100644 (file)
        <script src="../../resources/jquery/jquery.localize.js"></script>
        <script src="../../resources/jquery/jquery.tabIndex.js"></script>
        <script src="../../resources/jquery/jquery.tablesorter.js"></script>
-       <script src="../../resources/jquery/jquery.suggestions.js"></script>
        <script src="../../resources/mediawiki/mediawiki.Title.js"></script>
        <script src="../../resources/mediawiki.special/mediawiki.special.js"></script>
        <script src="../../resources/mediawiki.special/mediawiki.special.recentchanges.js"></script>
-       <script src="../../resources/mediawiki.page/mediawiki.page.ajaxCategories.js"></script>
 
        <!-- QUnit: Load framework -->
        <link rel="stylesheet" href="../../resources/jquery/jquery.qunit.css" />
@@ -77,7 +75,6 @@
        <script src="suites/resources/jquery/jquery.tablesorter.test.js" charset="UTF-8"></script>
        <script src="suites/resources/mediawiki/mediawiki.Title.js"></script>
        <script src="suites/resources/mediawiki.special/mediawiki.special.recentchanges.js"></script>
-       <!--<script src="suites/resources/mediawiki.page/mediawiki.page.ajaxCategories.js"></script>-->
 </head>
 <body>
        <h1 id="qunit-header">MediaWiki JavaScript Test Suite</h1>
@@ -88,7 +85,7 @@
        <h2 id="qunit-userAgent"></h2>
        <ol id="qunit-tests"></ol>
 
-<!-- Scripts inserting stuff here shall remove it themselves! -->
+<!-- Scripts inserting stuff here shall remove it themselfs! -->
 <div id="content"></div>
 </body>
 </html>
index 43eac09..774cbc3 100644 (file)
@@ -12,14 +12,16 @@ test( 'Handle basic replacements', function() {
        mw.messages.set( 'basic', 'Basic stuff' );
 
        // Tag: html:msg
-       html = '<div><span><html:msg key="basic"></span></div>';
+       html = '<div><span><html:msg key="basic"/></span></div>';
        $lc = $( html ).localize().find( 'span' );
+       console.log($lc.length);
 
        strictEqual( $lc.text(), 'Basic stuff', 'Tag: html:msg' );
 
        // Tag: msg (deprecated)
-       html = '<div><span><msg key="basic"></span></div>';
+       html = '<div><span><msg key="basic"/></span></div>';
        $lc = $( html ).localize().find( 'span' );
+       $('body').append($lc);
 
        strictEqual( $lc.text(), 'Basic stuff', 'Tag: msg' );
 
@@ -46,7 +48,7 @@ test( 'Proper escaping', function() {
        // making sure it is actually using text() and attr() (or something with the same effect)
 
        // Text escaping
-       html = '<div><span><html:msg key="properfoo"></span></div>';
+       html = '<div><span><html:msg key="properfoo"/></span></div>';
        $lc = $( html ).localize().find( 'span' );
 
        strictEqual( $lc.text(), mw.msg( 'properfoo' ), 'Content is inserted as text, not as html.' );
index 8d87b0e..7e26300 100644 (file)
@@ -33,4 +33,42 @@ test( 'Testing containsCat', function() {
        equal(ret, true);
 });
 
+})( mediaWiki );
+console.log('wtf0');
+(function( mw ) {
+
+console.log('wtf1');
+module( 'mediawiki.page.ajaxCategories.js' );
+mw.config.set( 'wgNamespaceIds', {'category' : 14} );
+test( '-- Initial check', function() {
+       expect(1);
+       ok( mw.ajaxCategories, 'mw.ajaxCategories defined' );
+});
+
+/**
+ * Create a category list like the one found below articles.
+ * @param {String[]} categories
+ * @return jQuery
+ */
+var listCreate = function( categories ) {
+       var $container = $('<div id="catlinks" class="catlinks"><div id="mw-normal-catlinks"><ul></ul></div></div>'),
+               $ul = $container.find('ul');
+       $.each( categories, function(i, str) {
+               var $li = $('<li>');
+               $li.text(str).appendTo($ul);
+       });
+       
+       return $container;
+};
+catList1 = ['Earth satellites', 'Space stations', 'astronauts'];
+
+test( 'Testing containsCat', function() {
+       expect(1);
+       $( 'body' ).append( listCreate(catList1) );
+       mw.ajaxCategories.setup();
+       var ret = mw.ajaxCategories.containsCat('Earth satellites')
+
+       equal(ret, true);
+});
+
 })( mediaWiki );
\ No newline at end of file