LivePreview: Notifiy user about errors
authorDerk-Jan Hartman <hartman.wiki@gmail.com>
Sat, 28 Feb 2015 15:26:25 +0000 (16:26 +0100)
committerDerk-Jan Hartman <hartman.wiki@gmail.com>
Wed, 25 Mar 2015 22:57:17 +0000 (23:57 +0100)
Bug: T90490
Change-Id: Ic52311839c175a213065eec442e50b4de0463822

languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.action/mediawiki.action.edit.preview.js

index 56bfbbc..be318e6 100644 (file)
        "missingcommentheader": "<strong>Reminder:</strong> You have not provided a subject/headline for this comment.\nIf you click \"{{int:savearticle}}\" again, your edit will be saved without one.",
        "summary-preview": "Summary preview:",
        "subject-preview": "Subject/headline preview:",
+       "previewerrortext": "An error occurred while attempting to preview your changes.",
        "blockedtitle": "User is blocked",
        "blockedtext": "<strong>Your username or IP address has been blocked.</strong>\n\nThe block was made by $1.\nThe reason given is <em>$2</em>.\n\n* Start of block: $8\n* Expiry of block: $6\n* Intended blockee: $7\n\nYou can contact $1 or another [[{{MediaWiki:Grouppage-sysop}}|administrator]] to discuss the block.\nYou cannot use the \"email this user\" feature unless a valid email address is specified in your [[Special:Preferences|account preferences]] and you have not been blocked from using it.\nYour current IP address is $3, and the block ID is #$5.\nPlease include all above details in any queries you make.",
        "autoblockedtext": "Your IP address has been automatically blocked because it was used by another user, who was blocked by $1.\nThe reason given is:\n\n:<em>$2</em>\n\n* Start of block: $8\n* Expiry of block: $6\n* Intended blockee: $7\n\nYou may contact $1 or one of the other [[{{MediaWiki:Grouppage-sysop}}|administrators]] to discuss the block.\n\nNote that you may not use the \"email this user\" feature unless you have a valid email address registered in your [[Special:Preferences|user preferences]] and you have not been blocked from using it.\n\nYour current IP address is $3, and the block ID is #$5.\nPlease include all above details in any queries you make.",
index 1484107..ffd48c7 100644 (file)
        "missingcommentheader": "Edit summary that is shown if you enable \"Prompt me when entering a blank summary\" and add a new section without headline to a talk page.\n\nSee also:\n* {{msg-mw|Missingsummary}}\n* {{msg-mw|Savearticle}}",
        "summary-preview": "Preview of the edit summary, shown under the edit summary itself.\nShould match: {{msg-mw|summary}}.",
        "subject-preview": "Should match {{msg-mw|subject}}",
+       "previewerrortext": "When a user has the editing preference LivePreview enabled, clicked the Preview or Show Changes button in the edit page and the action did not succeed.",
        "blockedtitle": "Used as title displayed for blocked users. The corresponding message body is one of the following messages:\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Autoblockedtext|notext=1}}",
        "blockedtext": "Text displayed to blocked users.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - the blocking sysop (with a link to his/her userpage)\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the blocking sysop's username (plain text, without the link)\n* $5 - the unique numeric identifier of the applied autoblock\n* $6 - the expiry of the block\n* $7 - the intended target of the block (what the blocking user specified in the blocking form)\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Autoblockedtext}}",
        "autoblockedtext": "Text displayed to automatically blocked users.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - the blocking sysop (with a link to his/her userpage)\n* $2 - the reason for the block (in case of autoblocks: {{msg-mw|autoblocker}})\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the blocking sysop's username (plain text, without the link). Use it for GENDER.\n* $5 - the unique numeric identifier of the applied autoblock\n* $6 - the expiry of the block\n* $7 - the intended target of the block (what the blocking user specified in the blocking form)\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext}}",
index 69a6ff7..448f502 100644 (file)
@@ -1097,6 +1097,7 @@ return array(
                        'summary-preview',
                        'subject-preview',
                        'parentheses',
+                       'previewerrortext',
                ),
        ),
        'mediawiki.action.edit.stash' => array(
index c86f7c5..1878c89 100644 (file)
                                opacity: 1
                        }, 'fast' );
                } );
+               request.fail( function ( code, result ) {
+                       var errorMsg = 'API error: ' +  code;
+                       if ( code === 'http' ) {
+                               errorMsg = 'HTTP error: ';
+                               if ( result.exception ) {
+                                       errorMsg += result.exception;
+                               } else {
+                                       errorMsg += result.textStatus;
+                               }
+                       }
+                       $wikiPreview.children( '.mw-content-ltr,.mw-content-rtl' )
+                               .empty()
+                               .append( $( '<div>' )
+                                       .addClass( 'errorbox' )
+                                       .html( '<strong>' + mw.message( 'previewerrortext' ).escaped() + '</strong><br>' )
+                                       .append( document.createTextNode( errorMsg ) ) );
+                       $wikiPreview.show();
+               } );
        }
 
        $( function () {