From ae2f5134b287723fc80fcc410405b8442829166d Mon Sep 17 00:00:00 2001 From: Juliusz Gonera Date: Thu, 6 Feb 2014 15:26:52 -0800 Subject: [PATCH] Make MobileViewTarget scroll to desired section Implements https://wikimedia.mingle.thoughtworks.com/projects/mobile/cards/1626 Also, rename $el to $container so that it matches the docs. Change-Id: I9f41ec6fb88f6f21e698553216ccf2c3231589c1 --- .../ve-mw/init/targets/ve.init.mw.MobileViewTarget.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js b/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js index 1a1c556a16..8010d3afb6 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.MobileViewTarget.js @@ -14,15 +14,20 @@ * * @constructor * @param {jQuery} $container Container to render target into + * @param {Object} [config] Configuration options + * @cfg {number} [section] Number of the section target should scroll to */ -ve.init.mw.MobileViewTarget = function VeInitMwMobileViewTarget( $el ) { +ve.init.mw.MobileViewTarget = function VeInitMwMobileViewTarget( $container, config ) { var currentUri = new mw.Uri(); + config = config || {}; // Parent constructor ve.init.mw.Target.call( - this, $el, mw.config.get( 'wgRelevantPageName' ), currentUri.query.oldid + this, $container, mw.config.get( 'wgRelevantPageName' ), currentUri.query.oldid ); + this.section = config.section; + // Events this.connect( this, { 'surfaceReady': 'onSurfaceReady' @@ -55,6 +60,7 @@ ve.init.mw.MobileViewTarget.static.surfaceCommands = [ */ ve.init.mw.MobileViewTarget.prototype.onSurfaceReady = function () { this.$document[0].focus(); + this.restoreEditSection(); }; /**