Merge "mw.ViewPageTarget: When saving a page as a redirect, update contentSub text"

This commit is contained in:
jenkins-bot 2014-06-10 17:50:58 +00:00 committed by Gerrit Code Review
commit cb0f964637
4 changed files with 12 additions and 4 deletions

View file

@ -114,6 +114,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
if ( $result === false ) {
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
}
$result['isRedirect'] = $page->isRedirect();
if ( isset( $saveresult['edit']['newrevid'] ) ) {
$result['newrevid'] = intval( $saveresult['edit']['newrevid'] );

View file

@ -191,6 +191,7 @@ $wgResourceModules += array(
'spamprotectiontext',
'summary-preview',
'parentheses',
'redirectpagesub',
// Messages needed by VE in init phase only (rest go below)
'visualeditor-loadwarning',

View file

@ -423,7 +423,7 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceReady = function () {
* @param {string} categoriesHtml Rendered categories HTML from server
* @param {number} [newid] New revision id, undefined if unchanged
*/
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, newid ) {
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, newid, isRedirect ) {
if ( !this.pageExists || this.restoring ) {
// This is a page creation or restoration, refresh the page
this.tearDownBeforeUnloadHandler();
@ -461,7 +461,7 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, ne
}
this.saveDialog.close();
this.saveDialog.reset();
this.replacePageContent( html, categoriesHtml );
this.replacePageContent( html, categoriesHtml, isRedirect );
this.setupSectionEditLinks();
this.tearDownBeforeUnloadHandler();
this.deactivate( true );
@ -1531,7 +1531,7 @@ ve.init.mw.ViewPageTarget.prototype.onWindowPopState = function ( e ) {
* @param {string} html Rendered HTML from server
* @param {string} categoriesHtml Rendered categories HTML from server
*/
ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, categoriesHtml ) {
ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, categoriesHtml, isRedirect ) {
var $content = $( $.parseHTML( html ) ), $editableContent;
if ( $( '#mw-imagepage-content' ).length ) {
@ -1552,6 +1552,11 @@ ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, catego
mw.hook( 'wikipage.content' ).fire( $editableContent.empty().append( $content ) );
$( '#catlinks' ).replaceWith( categoriesHtml );
if ( isRedirect ) {
$( '#contentSub' ).text( ve.msg( 'redirectpagesub' ) );
} else {
$( '#contentSub' ).text( '' );
}
};
/**

View file

@ -74,6 +74,7 @@ OO.inheritClass( ve.init.mw.Target, ve.init.Target );
* @param {string} html Rendered page HTML from server
* @param {string} categoriesHtml Rendered categories HTML from server
* @param {number} [newid] New revision id, undefined if unchanged
* @param {boolean} isRedirect Whether this page is now a redirect or not.
*/
/**
@ -542,7 +543,7 @@ ve.init.mw.Target.onSave = function ( doc, saveData, response ) {
} else if ( typeof data.content !== 'string' ) {
this.onSaveError( doc, saveData, null, 'Invalid HTML content in response from server', response );
} else {
this.emit( 'save', data.content, data.categorieshtml, data.newrevid );
this.emit( 'save', data.content, data.categorieshtml, data.newrevid, data.isRedirect );
}
};