mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
c6b997d0ba
Follows-up I55ef2622c9eacc which activated code introduced in mw.Target in commits before that one that caused a change in the execution order. Hiding of page content (regular wiki page content provided by original view request) must happen before the surface document is focussed. We used to hide the content from mw.ViewPageTarget#setUpSurface, which is called from #onReady, which focusses the document after setUpSurface is done. Most of this code was moved to mw.ViewPageTarget#onSurfaceReady which is the listener for the surfaceReady event emitted from If our surface document gets focus while the original wikipage content container is still there, the view port is forced to scroll down because our surface is the next element sibling after the wikipage container in the DOM. And browsers (apparently Chrome is not affected) naturally retain scroll position even if the elements above the one you "scrolled to" disappear. We can't (and shouldn't) move the hidePageContent call because that's the responsibility of the Target subclass, so instead moved the document focus to below the hidePageContent which is now also part of the responsibility of the Target subclass. Also: * Removed target.surfaceOptions reference because that property does not exist. We never passed a second argument here, and whatever this was intended for, doesn't exist. Bug: 58089 Change-Id: I230fbd5401cbd6e3b9450c7f156650409be8ef16
81 lines
1.7 KiB
JavaScript
81 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor MediaWiki Initialization MobileViewTarget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/*global mw*/
|
|
|
|
/**
|
|
*
|
|
* @class
|
|
* @extends ve.init.mw.Target
|
|
*
|
|
* @constructor
|
|
* @param {jQuery} $container Container to render target into
|
|
*/
|
|
ve.init.mw.MobileViewTarget = function VeInitMwMobileViewTarget( $el ) {
|
|
var currentUri = new mw.Uri();
|
|
|
|
// Parent constructor
|
|
ve.init.mw.Target.call(
|
|
this, $el, mw.config.get( 'wgRelevantPageName' ), currentUri.query.oldid
|
|
);
|
|
|
|
// Events
|
|
this.connect( this, {
|
|
'surfaceReady': 'onSurfaceReady'
|
|
} );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.init.mw.MobileViewTarget, ve.init.mw.Target );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.init.mw.MobileViewTarget.static.toolbarGroups = [
|
|
{ 'include': [ 'undo', 'redo' ] },
|
|
{
|
|
'type': 'menu',
|
|
'include': [ { 'group': 'format' } ],
|
|
'promote': [ 'paragraph' ],
|
|
'demote': [ 'preformatted', 'heading1' ]
|
|
},
|
|
{ 'include': [ 'bold', 'italic', 'link', 'clear' ] },
|
|
{ 'include': [ 'number', 'bullet', 'outdent', 'indent' ] },
|
|
{ 'include': '*', 'exclude': [ { 'group': 'format' }, 'reference', 'referenceList', 'mediaEdit', 'mediaInsert', 'transclusion' ] }
|
|
];
|
|
|
|
ve.init.mw.MobileViewTarget.static.surfaceCommands = [
|
|
'undo',
|
|
'redo',
|
|
'bold',
|
|
'italic',
|
|
'link',
|
|
'clear',
|
|
'underline',
|
|
'subscript',
|
|
'superscript',
|
|
'indent',
|
|
'outdent',
|
|
'paragraph',
|
|
'heading1',
|
|
'heading2',
|
|
'heading3',
|
|
'heading4',
|
|
'heading5',
|
|
'heading6',
|
|
'preformatted'
|
|
];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Once surface is ready ready, init UI.
|
|
*/
|
|
ve.init.mw.MobileViewTarget.prototype.onSurfaceReady = function () {
|
|
this.$document[0].focus();
|
|
};
|