Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -3498,6 +3498,7 @@ |
3499 | 3499 | 'ajax-category-already-present', |
3500 | 3500 | 'ajax-category-hook-error', |
3501 | 3501 | 'ajax-api-error', |
| 3502 | + 'ajax-api-unknown-error', |
3502 | 3503 | ), |
3503 | 3504 | |
3504 | 3505 | ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4628,5 +4628,6 @@ |
4629 | 4629 | 'ajax-category-already-present' => 'This page already belongs to the category "$1"', |
4630 | 4630 | 'ajax-category-hook-error' => 'A local function prevented the changes from being saved.', |
4631 | 4631 | 'ajax-api-error' => 'The API returned an error: $1: $2.', |
| 4632 | +'ajax-api-unknown-error' => 'The API returned an unknown error.', |
4632 | 4633 | |
4633 | 4634 | ); |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -625,6 +625,7 @@ |
626 | 626 | 'ajax-category-already-present', |
627 | 627 | 'ajax-category-hook-error', |
628 | 628 | 'ajax-api-error', |
| 629 | + 'ajax-api-unknown-error', |
629 | 630 | ), |
630 | 631 | ), |
631 | 632 | 'mediawiki.page.ajaxCategories.init' => array( |
Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js |
— | — | @@ -664,14 +664,19 @@ |
665 | 665 | var redirect = json.query.redirects, |
666 | 666 | exists = !json.query.pages[-1]; |
667 | 667 | |
| 668 | + // If it's a redirect 'exists' is for the target, not the origin |
| 669 | + if ( redirect ) { |
| 670 | + // Register existance of redirect origin as well, |
| 671 | + // a non-existent page can't be a redirect. |
| 672 | + mw.Title.exist.set( catTitle.toString(), true ); |
| 673 | + |
| 674 | + // Override title with the redirect target |
| 675 | + catTitle = new mw.Title( redirect[0].to ).getMainText(); |
| 676 | + } |
| 677 | + |
668 | 678 | // Register existence |
669 | 679 | mw.Title.exist.set( catTitle.toString(), exists ); |
670 | 680 | |
671 | | - if ( redirect ) { |
672 | | - catTitle = new mw.Title( redirect[0].to ).getMainText(); |
673 | | - // Redirect existence as well (non-existant pages can't be redirects) |
674 | | - mw.Title.exist.set( catTitle.toString(), true ); |
675 | | - } |
676 | 681 | callback( catTitle ); |
677 | 682 | } ); |
678 | 683 | }, |
— | — | @@ -824,7 +829,7 @@ |
825 | 830 | |
826 | 831 | $link.removeData(); |
827 | 832 | |
828 | | - // Read static. |
| 833 | + // Re-add data |
829 | 834 | $link.data( { |
830 | 835 | saveButton: data.saveButton, |
831 | 836 | deleteButton: data.deleteButton, |
— | — | @@ -855,8 +860,17 @@ |
856 | 861 | $.post( |
857 | 862 | mw.util.wikiScript( 'api' ), |
858 | 863 | getTokenVars, |
859 | | - function( reply ) { |
860 | | - var infos = reply.query.pages; |
| 864 | + function( json ) { |
| 865 | + if ( 'error' in json ) { |
| 866 | + ajaxcat.showError( mw.msg( 'ajax-api-error', json.error.code, json.error.info ) ); |
| 867 | + return; |
| 868 | + } else if ( json.query && json.query.pages ) { |
| 869 | + var infos = json.query.pages; |
| 870 | + } else { |
| 871 | + ajaxcat.showError( mw.msg( 'ajax-api-unknown-error' ) ); |
| 872 | + return; |
| 873 | + } |
| 874 | + |
861 | 875 | $.each( infos, function( pageid, data ) { |
862 | 876 | var token = data.edittoken, |
863 | 877 | timestamp = data.revisions[0].timestamp, |
— | — | @@ -910,8 +924,8 @@ |
911 | 925 | * |
912 | 926 | * @param props {Object}: |
913 | 927 | * - modFn {Function} text-modifying function |
914 | | - * - dialogDescription {String} Changes done (HTML in the dialog) |
915 | | - * - editSummary {String} Changes done (text for edit summary) |
| 928 | + * - dialogDescription {String} Changes done (HTML for in the dialog, escape before hand if needed) |
| 929 | + * - editSummary {String} Changes done (text for the edit summary) |
916 | 930 | * - doneFn {Function} callback after everything is done |
917 | 931 | * - $link {jQuery} |
918 | 932 | * - action |
— | — | @@ -952,7 +966,7 @@ |
953 | 967 | |
954 | 968 | // Summary of the action to be taken |
955 | 969 | summaryHolder = $( '<p>' ) |
956 | | - .html( '<strong>' + mw.msg( 'ajax-category-question' ) + '</strong><br/>' + props.dialogDescription ); |
| 970 | + .html( '<strong>' + mw.message( 'ajax-category-question' ).escaped() + '</strong><br/>' + props.dialogDescription ); |
957 | 971 | |
958 | 972 | // Reason textbox. |
959 | 973 | reasonBox = $( '<input type="text" size="45"></input>' ) |