Merge "mw.Target: Fix document focus scroll bug"

This commit is contained in:
jenkins-bot 2013-12-06 21:40:50 +00:00 committed by Gerrit Code Review
commit ed43cab350
3 changed files with 31 additions and 2 deletions

View file

@ -22,6 +22,11 @@ ve.init.mw.MobileViewTarget = function VeInitMwMobileViewTarget( $el ) {
ve.init.mw.Target.call(
this, $el, mw.config.get( 'wgRelevantPageName' ), currentUri.query.oldid
);
// Events
this.connect( this, {
'surfaceReady': 'onSurfaceReady'
} );
};
/* Inheritance */
@ -64,3 +69,12 @@ ve.init.mw.MobileViewTarget.static.surfaceCommands = [
'heading6',
'preformatted'
];
/* Methods */
/**
* Once surface is ready ready, init UI.
*/
ve.init.mw.MobileViewTarget.prototype.onSurfaceReady = function () {
this.$document[0].focus();
};

View file

@ -260,11 +260,15 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceReady = function () {
'history': 'updateToolbarSaveButtonState'
} );
this.surface.setPasteRules( this.constructor.static.pasteRules );
// Update UI
this.transformPageTitle();
this.changeDocumentTitle();
this.hidePageContent();
this.hideSpinner();
this.$document[0].focus();
this.setupToolbarButtons();
this.attachToolbarButtons();
this.restoreScrollPosition();

View file

@ -43,6 +43,11 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId )
this.submitUrl = ( new mw.Uri( mw.util.getUrl( this.pageName ) ) )
.extend( { 'action': 'submit' } );
/**
* @property {ve.ui.Surface}
*/
this.surface = null;
this.modules = [
'ext.visualEditor.core',
'ext.visualEditor.data'
@ -74,6 +79,12 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId )
};
/**
* Fired when the #surface is ready.
*
* By default the surface document is not focussed. If the target wants
* the browsers' focus to be in the surface (ready for typing and cursoring)
* call `this.$document[0].focus();` in a handler for this event.
*
* @event surfaceReady
*/
@ -316,7 +327,6 @@ ve.init.mw.Target.prototype.onReady = function () {
this.edited = false;
this.setUpSurface( this.doc, ve.bind( function () {
this.startSanityCheck();
this.$document[0].focus();
this.emit( 'surfaceReady' );
}, this ) );
};
@ -1075,7 +1085,7 @@ ve.init.mw.Target.prototype.setUpSurface = function ( doc, callback ) {
var dmDoc = ve.dm.converter.getModelFromDom( doc );
setTimeout( function () {
// Create ui.Surface (also creates ce.Surface and dm.Surface and builds CE tree)
target.surface = new ve.ui.Surface( dmDoc, target.surfaceOptions );
target.surface = new ve.ui.Surface( dmDoc );
target.surface.$element.addClass( 've-init-mw-viewPageTarget-surface' );
setTimeout( function () {
// Initialize surface
@ -1083,6 +1093,7 @@ ve.init.mw.Target.prototype.setUpSurface = function ( doc, callback ) {
target.$document = target.surface.$element.find( '.ve-ce-documentNode' );
target.$element.append( target.surface.$element );
target.setUpToolbar();
target.$document.attr( {
'lang': mw.config.get( 'wgVisualEditor' ).pageLanguageCode,
'dir': mw.config.get( 'wgVisualEditor' ).pageLanguageDir