Merge "Append surface & toolbar components in the correct places"

This commit is contained in:
jenkins-bot 2016-05-26 15:59:35 +00:00 committed by Gerrit Code Review
commit 24d313c255
3 changed files with 57 additions and 20 deletions

View file

@ -490,7 +490,6 @@ ve.init.mw.DesktopArticleTarget.prototype.activate = function ( dataPromise ) {
*/
ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
$( 'html' ).removeClass( 've-activating' ).addClass( 've-active' );
this.$editableContent.after( this.getSurface().$element );
if ( !this.editingTabDialog ) {
// We have to focus the page after hiding the original content, otherwise
// in firefox the contentEditable container was below the view page, and
@ -500,6 +499,18 @@ ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
}
};
/**
* @inheritdoc
*/
ve.init.mw.DesktopArticleTarget.prototype.setSurface = function ( surface ) {
if ( surface !== this.surface ) {
this.$editableContent.after( surface.$element );
}
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.setSurface.apply( this, arguments );
};
/**
* Determines whether we want to switch to view mode or not (displaying a dialog if necessary)
* Then, if we do, actually switches to view mode.

View file

@ -300,8 +300,6 @@ ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
this.getSurface().getModel().connect( this, {
history: 'updateToolbarSaveButtonState'
} );
this.setupToolbarSaveButton();
this.attachToolbarSaveButton();
this.restoreEditSection();
// Parent method
@ -1465,31 +1463,43 @@ ve.init.mw.ArticleTarget.prototype.createSurface = function () {
return surface;
};
/**
* @inheritdoc
*/
ve.init.mw.ArticleTarget.prototype.setupToolbar = function () {
// Parent method
ve.init.mw.ArticleTarget.super.prototype.setupToolbar.apply( this, arguments );
this.setupToolbarSaveButton();
this.attachToolbarSaveButton();
};
/**
* Add content and event bindings to toolbar save button.
*
* @param {Object} [config] Configuration options for the button
*/
ve.init.mw.ArticleTarget.prototype.setupToolbarSaveButton = function ( config ) {
this.toolbarSaveButton = new OO.ui.ButtonWidget( ve.extendObject( {
label: ve.msg( 'visualeditor-toolbar-savedialog' ),
flags: [ 'progressive', 'primary' ],
disabled: !this.restoring
}, config ) );
if ( !this.toolbarSaveButton ) {
this.toolbarSaveButton = new OO.ui.ButtonWidget( ve.extendObject( {
label: ve.msg( 'visualeditor-toolbar-savedialog' ),
flags: [ 'progressive', 'primary' ],
disabled: !this.restoring
}, config ) );
// NOTE (phuedx, 2014-08-20): This class is used by the firsteditve guided
// tour to attach a guider to the "Save page" button.
this.toolbarSaveButton.$element.addClass( 've-ui-toolbar-saveButton' );
// NOTE (phuedx, 2014-08-20): This class is used by the firsteditve guided
// tour to attach a guider to the "Save page" button.
this.toolbarSaveButton.$element.addClass( 've-ui-toolbar-saveButton' );
if ( ve.msg( 'accesskey-save' ) !== '-' && ve.msg( 'accesskey-save' ) !== '' ) {
// FlaggedRevs tries to use this - it's useless on VE pages because all that stuff gets hidden, but it will still conflict so get rid of it
this.elementsThatHadOurAccessKey = $( '[accesskey="' + ve.msg( 'accesskey-save' ) + '"]' ).removeAttr( 'accesskey' );
this.toolbarSaveButton.$button.attr( 'accesskey', ve.msg( 'accesskey-save' ) );
if ( ve.msg( 'accesskey-save' ) !== '-' && ve.msg( 'accesskey-save' ) !== '' ) {
// FlaggedRevs tries to use this - it's useless on VE pages because all that stuff gets hidden, but it will still conflict so get rid of it
this.elementsThatHadOurAccessKey = $( '[accesskey="' + ve.msg( 'accesskey-save' ) + '"]' ).removeAttr( 'accesskey' );
this.toolbarSaveButton.$button.attr( 'accesskey', ve.msg( 'accesskey-save' ) );
}
this.toolbarSaveButton.connect( this, { click: 'onToolbarSaveButtonClick' } );
}
this.updateToolbarSaveButtonState();
this.toolbarSaveButton.connect( this, { click: 'onToolbarSaveButtonClick' } );
};
/**

View file

@ -303,9 +303,8 @@ ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) {
surface.$element.addClass( 've-init-mw-target-surface' );
target.track( 'trace.createSurface.exit' );
target.$element.append( surface.$element );
target.dummyToolbar = false;
target.setSurface( surface );
setTimeout( function () {
@ -316,9 +315,26 @@ ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) {
// Now that the surface is attached to the document and ready,
// let it initialize itself
surface.initialize();
if ( surface.debugBar ) {
// Move debug bar to end of target if the surface is nested
target.$element.append( surface.debugBar.$element );
}
target.track( 'trace.initializeSurface.exit' );
setTimeout( callback );
} );
} );
} );
};
/**
* @inheritdoc
*/
ve.init.mw.Target.prototype.setSurface = function ( surface ) {
if ( !surface.$element.parent().length ) {
this.$element.append( surface.$element );
}
// Parent method
ve.init.mw.Target.super.prototype.setSurface.apply( this, arguments );
};