jenkins-bot has submitted this change and it was merged.
Change subject: mw.ViewPageTarget: Clean up nested binds and triple
model/connect
......................................................................
mw.ViewPageTarget: Clean up nested binds and triple model/connect
Change-Id: I67cabfdf0247dd0951b7d4f26c99d621aa2f7b0d
---
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
1 file changed, 32 insertions(+), 26 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 29a4b97..af1f588 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -1057,51 +1057,57 @@
* @param {Function} [callback] Callback to call when done
*/
ve.init.mw.ViewPageTarget.prototype.setUpSurface = function ( doc, callback ) {
- setTimeout( ve.bind( function () {
+ var target = this;
+ setTimeout( function () {
// Build linmod
var store = new ve.dm.IndexValueStore(),
internalList = new ve.dm.InternalList(),
data = ve.dm.converter.getDataFromDom( doc, store,
internalList );
- setTimeout( ve.bind( function () {
+ setTimeout( function () {
// Build DM tree
var dmDoc = new ve.dm.Document( data, undefined,
internalList );
- setTimeout( ve.bind( function () {
+ setTimeout( function () {
// Create ui.Surface (also creates ce.Surface
and dm.Surface and builds CE tree)
- this.surface = new ve.ui.Surface( dmDoc,
this.surfaceOptions );
- this.surface.$.addClass(
've-init-mw-viewPageTarget-surface' );
- setTimeout( ve.bind( function () {
+ target.surface = new ve.ui.Surface( dmDoc,
target.surfaceOptions );
+ target.surface.$.addClass(
've-init-mw-viewPageTarget-surface' );
+ setTimeout( function () {
// Initialize surface
- this.surface.connect( this, {
'toolbarPosition': 'onSurfaceToolbarPosition' } );
- this.surface.getContext().hide();
- this.$document = this.surface.$.find(
'.ve-ce-documentNode' );
- this.surface.getModel().connect( this,
{ 'transact': 'onSurfaceModelTransact' } );
- this.surface.getModel().connect( this,
{ 'change': 'onSurfaceModelChange' } );
- this.surface.getModel().connect( this,
{ 'history': 'updateToolbarSaveButtonState' } );
- this.$.append( this.surface.$ );
- this.setUpToolbar();
- this.transformPageTitle();
- this.changeDocumentTitle();
+ target.surface.connect( target, {
'toolbarPosition': 'onSurfaceToolbarPosition' } );
+ target.surface.getContext().hide();
+ target.$document =
target.surface.$.find( '.ve-ce-documentNode' );
+ target.surface.getModel().connect(
target, {
+ 'transact':
'onSurfaceModelTransact',
+ 'change':
'onSurfaceModelChange',
+ 'history':
'updateToolbarSaveButtonState'
+ } );
+ target.$.append( target.surface.$ );
+ target.setUpToolbar();
+ target.transformPageTitle();
+ target.changeDocumentTitle();
// Update UI
- this.hidePageContent();
- this.hideSpinner();
- this.active = true;
- this.$document.attr( {
+ target.hidePageContent();
+ target.hideSpinner();
+ target.active = true;
+ target.$document.attr( {
'lang': mw.config.get(
'wgVisualEditor' ).pageLanguageCode,
'dir': mw.config.get(
'wgVisualEditor' ).pageLanguageDir
} );
// Add appropriately mw-content-ltr or
mw-content-rtl class
- this.surface.view.$.addClass(
+ target.surface.view.$.addClass(
'mw-content-' + mw.config.get(
'wgVisualEditor' ).pageLanguageDir
);
- this.surface.initialize();
+
+ // Now that the surface is attached to
the document and ready,
+ // let it initialize itself
+ target.surface.initialize();
setTimeout( callback );
- }, this ) );
- }, this ) );
- }, this ) );
- }, this ) );
+ } );
+ } );
+ } );
+ } );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/76221
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I67cabfdf0247dd0951b7d4f26c99d621aa2f7b0d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits