From: Derk-Jan Hartman Date: Sat, 28 Feb 2015 15:26:25 +0000 (+0100) Subject: LivePreview: Notifiy user about errors X-Git-Tag: 1.31.0-rc.0~11997^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=fa836dfd8e053a1c6b07ac5d3ecc08c06737c0e3;p=lhc%2Fweb%2Fwiklou.git LivePreview: Notifiy user about errors Bug: T90490 Change-Id: Ic52311839c175a213065eec442e50b4de0463822 --- diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 56bfbbcb11..be318e6d88 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -598,6 +598,7 @@ "missingcommentheader": "Reminder: 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": "Your username or IP address has been blocked.\n\nThe block was made by $1.\nThe reason given is $2.\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:$2\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.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 1484107339..ffd48c7821 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -763,6 +763,7 @@ "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}}", diff --git a/resources/Resources.php b/resources/Resources.php index 69a6ff7149..448f502320 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1097,6 +1097,7 @@ return array( 'summary-preview', 'subject-preview', 'parentheses', + 'previewerrortext', ), ), 'mediawiki.action.edit.stash' => array( diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js index c86f7c5255..1878c89d9f 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js @@ -217,6 +217,24 @@ 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( $( '
' ) + .addClass( 'errorbox' ) + .html( '' + mw.message( 'previewerrortext' ).escaped() + '
' ) + .append( document.createTextNode( errorMsg ) ) ); + $wikiPreview.show(); + } ); } $( function () {