[MediaWiki-commits] [Gerrit] Append surface & toolbar components in the correct places - change (mediawiki...VisualEditor)

2016-05-26 Thread jenkins-bot (Code Review)
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( 

[MediaWiki-commits] [Gerrit] Append surface & toolbar components in the correct places - change (mediawiki...VisualEditor)

2016-05-26 Thread Esanders (Code Review)
Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/290918

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, 58 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/18/290918/1

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..eb341cb 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,19 @@
 };
 
 /**
+ * @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
+