jenkins-bot has submitted this change and it was merged. Change subject: Append surface & toolbar components in the correct places ......................................................................
Append surface & toolbar components in the correct places Use setSurface and setupToolbar to position the surface and the toolbar save button in the DOM. Change-Id: Ide634848f4e78501724c358bcb1fdab8abd491b9 --- M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js M modules/ve-mw/init/ve.init.mw.ArticleTarget.js M modules/ve-mw/init/ve.init.mw.Target.js 3 files changed, 57 insertions(+), 20 deletions(-) Approvals: Jforrester: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js index 76a68f6..972586d 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -490,7 +490,6 @@ */ 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 @@ -501,6 +500,18 @@ }; /** + * @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. * diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js index 73001f7..7dd392d 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js @@ -300,8 +300,6 @@ this.getSurface().getModel().connect( this, { history: 'updateToolbarSaveButtonState' } ); - this.setupToolbarSaveButton(); - this.attachToolbarSaveButton(); this.restoreEditSection(); // Parent method @@ -1466,30 +1464,42 @@ }; /** + * @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' } ); }; /** diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 1e47426..b4a61f6 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -303,9 +303,8 @@ 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 @@ // 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 ); +}; -- To view, visit https://gerrit.wikimedia.org/r/290918 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ide634848f4e78501724c358bcb1fdab8abd491b9 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits