mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Merge "Append surface & toolbar components in the correct places"
This commit is contained in:
commit
24d313c255
|
@ -490,7 +490,6 @@ ve.init.mw.DesktopArticleTarget.prototype.activate = function ( dataPromise ) {
|
||||||
*/
|
*/
|
||||||
ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
|
ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
|
||||||
$( 'html' ).removeClass( 've-activating' ).addClass( 've-active' );
|
$( 'html' ).removeClass( 've-activating' ).addClass( 've-active' );
|
||||||
this.$editableContent.after( this.getSurface().$element );
|
|
||||||
if ( !this.editingTabDialog ) {
|
if ( !this.editingTabDialog ) {
|
||||||
// We have to focus the page after hiding the original content, otherwise
|
// We have to focus the page after hiding the original content, otherwise
|
||||||
// in firefox the contentEditable container was below the view page, and
|
// 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)
|
* 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.
|
* Then, if we do, actually switches to view mode.
|
||||||
|
|
|
@ -300,8 +300,6 @@ ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
|
||||||
this.getSurface().getModel().connect( this, {
|
this.getSurface().getModel().connect( this, {
|
||||||
history: 'updateToolbarSaveButtonState'
|
history: 'updateToolbarSaveButtonState'
|
||||||
} );
|
} );
|
||||||
this.setupToolbarSaveButton();
|
|
||||||
this.attachToolbarSaveButton();
|
|
||||||
this.restoreEditSection();
|
this.restoreEditSection();
|
||||||
|
|
||||||
// Parent method
|
// Parent method
|
||||||
|
@ -1465,31 +1463,43 @@ ve.init.mw.ArticleTarget.prototype.createSurface = function () {
|
||||||
return surface;
|
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.
|
* Add content and event bindings to toolbar save button.
|
||||||
*
|
*
|
||||||
* @param {Object} [config] Configuration options for the button
|
* @param {Object} [config] Configuration options for the button
|
||||||
*/
|
*/
|
||||||
ve.init.mw.ArticleTarget.prototype.setupToolbarSaveButton = function ( config ) {
|
ve.init.mw.ArticleTarget.prototype.setupToolbarSaveButton = function ( config ) {
|
||||||
this.toolbarSaveButton = new OO.ui.ButtonWidget( ve.extendObject( {
|
if ( !this.toolbarSaveButton ) {
|
||||||
label: ve.msg( 'visualeditor-toolbar-savedialog' ),
|
this.toolbarSaveButton = new OO.ui.ButtonWidget( ve.extendObject( {
|
||||||
flags: [ 'progressive', 'primary' ],
|
label: ve.msg( 'visualeditor-toolbar-savedialog' ),
|
||||||
disabled: !this.restoring
|
flags: [ 'progressive', 'primary' ],
|
||||||
}, config ) );
|
disabled: !this.restoring
|
||||||
|
}, config ) );
|
||||||
|
|
||||||
// NOTE (phuedx, 2014-08-20): This class is used by the firsteditve guided
|
// NOTE (phuedx, 2014-08-20): This class is used by the firsteditve guided
|
||||||
// tour to attach a guider to the "Save page" button.
|
// tour to attach a guider to the "Save page" button.
|
||||||
this.toolbarSaveButton.$element.addClass( 've-ui-toolbar-saveButton' );
|
this.toolbarSaveButton.$element.addClass( 've-ui-toolbar-saveButton' );
|
||||||
|
|
||||||
if ( ve.msg( 'accesskey-save' ) !== '-' && 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
|
// 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.elementsThatHadOurAccessKey = $( '[accesskey="' + ve.msg( 'accesskey-save' ) + '"]' ).removeAttr( 'accesskey' );
|
||||||
this.toolbarSaveButton.$button.attr( 'accesskey', ve.msg( 'accesskey-save' ) );
|
this.toolbarSaveButton.$button.attr( 'accesskey', ve.msg( 'accesskey-save' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toolbarSaveButton.connect( this, { click: 'onToolbarSaveButtonClick' } );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateToolbarSaveButtonState();
|
this.updateToolbarSaveButtonState();
|
||||||
|
|
||||||
this.toolbarSaveButton.connect( this, { click: 'onToolbarSaveButtonClick' } );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -303,9 +303,8 @@ ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) {
|
||||||
surface.$element.addClass( 've-init-mw-target-surface' );
|
surface.$element.addClass( 've-init-mw-target-surface' );
|
||||||
target.track( 'trace.createSurface.exit' );
|
target.track( 'trace.createSurface.exit' );
|
||||||
|
|
||||||
target.$element.append( surface.$element );
|
|
||||||
|
|
||||||
target.dummyToolbar = false;
|
target.dummyToolbar = false;
|
||||||
|
|
||||||
target.setSurface( surface );
|
target.setSurface( surface );
|
||||||
|
|
||||||
setTimeout( function () {
|
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,
|
// Now that the surface is attached to the document and ready,
|
||||||
// let it initialize itself
|
// let it initialize itself
|
||||||
surface.initialize();
|
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' );
|
target.track( 'trace.initializeSurface.exit' );
|
||||||
setTimeout( callback );
|
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 );
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue