2013-10-11 18:42:46 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization MobileViewTarget class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-10-11 18:42:46 +00:00
|
|
|
* @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
|
2014-02-06 23:26:52 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
* @cfg {number} [section] Number of the section target should scroll to
|
2013-10-11 18:42:46 +00:00
|
|
|
*/
|
2014-02-06 23:26:52 +00:00
|
|
|
ve.init.mw.MobileViewTarget = function VeInitMwMobileViewTarget( $container, config ) {
|
2013-10-11 18:42:46 +00:00
|
|
|
var currentUri = new mw.Uri();
|
2014-02-06 23:26:52 +00:00
|
|
|
config = config || {};
|
2013-10-11 18:42:46 +00:00
|
|
|
|
|
|
|
// Parent constructor
|
|
|
|
ve.init.mw.Target.call(
|
2014-02-06 23:26:52 +00:00
|
|
|
this, $container, mw.config.get( 'wgRelevantPageName' ), currentUri.query.oldid
|
2013-10-11 18:42:46 +00:00
|
|
|
);
|
2013-12-06 20:01:03 +00:00
|
|
|
|
2014-02-06 23:26:52 +00:00
|
|
|
this.section = config.section;
|
|
|
|
|
2013-12-06 20:01:03 +00:00
|
|
|
// Events
|
|
|
|
this.connect( this, {
|
|
|
|
'surfaceReady': 'onSurfaceReady'
|
|
|
|
} );
|
2013-10-11 18:42:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.init.mw.MobileViewTarget, ve.init.mw.Target );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
ve.init.mw.MobileViewTarget.static.toolbarGroups = [
|
2014-05-02 20:08:16 +00:00
|
|
|
// Style
|
2014-03-14 19:52:40 +00:00
|
|
|
{ 'include': [ 'bold', 'italic' ] },
|
2014-05-02 20:08:16 +00:00
|
|
|
// Link
|
|
|
|
{ 'include': [ 'link' ] },
|
|
|
|
// Cite
|
|
|
|
{
|
|
|
|
'type': 'list',
|
2014-05-13 23:49:22 +00:00
|
|
|
'icon': 'reference',
|
|
|
|
'title': OO.ui.deferMsg( 'visualeditor-toolbar-cite-label' ),
|
2014-05-02 20:08:16 +00:00
|
|
|
'include': [ { 'group': 'cite' } ]
|
|
|
|
}
|
2013-10-11 18:42:46 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
ve.init.mw.MobileViewTarget.static.surfaceCommands = [
|
|
|
|
'bold',
|
2014-03-14 19:52:40 +00:00
|
|
|
'italic',
|
|
|
|
'link'
|
2013-10-11 18:42:46 +00:00
|
|
|
];
|
2013-12-06 20:01:03 +00:00
|
|
|
|
2013-12-10 01:39:46 +00:00
|
|
|
ve.init.mw.MobileViewTarget.static.name = 'mobile';
|
|
|
|
|
2013-12-06 20:01:03 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Once surface is ready ready, init UI.
|
|
|
|
*/
|
|
|
|
ve.init.mw.MobileViewTarget.prototype.onSurfaceReady = function () {
|
|
|
|
this.$document[0].focus();
|
2014-02-06 23:26:52 +00:00
|
|
|
this.restoreEditSection();
|
2013-12-06 20:01:03 +00:00
|
|
|
};
|
2014-02-06 23:33:21 +00:00
|
|
|
|
2014-03-14 19:52:40 +00:00
|
|
|
/**
|
|
|
|
* Create a surface.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {ve.dm.Document} dmDoc Document model
|
|
|
|
* @returns {ve.ui.MobileSurface}
|
|
|
|
*/
|
2014-04-17 00:41:18 +00:00
|
|
|
ve.init.mw.MobileViewTarget.prototype.createSurface = function ( dmDoc ) {
|
2014-03-14 19:52:40 +00:00
|
|
|
return new ve.ui.MobileSurface( dmDoc );
|
|
|
|
};
|
|
|
|
|
2014-02-06 23:33:21 +00:00
|
|
|
/**
|
2014-02-07 22:04:35 +00:00
|
|
|
* @inheritdoc
|
2014-02-06 23:33:21 +00:00
|
|
|
*/
|
2014-02-07 22:04:35 +00:00
|
|
|
ve.init.mw.MobileViewTarget.prototype.setUpToolbar = function () {
|
|
|
|
// Parent method
|
|
|
|
ve.init.mw.Target.prototype.setUpToolbar.call( this );
|
|
|
|
|
2014-02-06 23:33:21 +00:00
|
|
|
this.toolbar.$element
|
2014-02-07 22:04:35 +00:00
|
|
|
// FIXME shouldn't be using viewPageTarget styles
|
2014-02-06 23:33:21 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-toolbar' )
|
2014-02-07 22:04:35 +00:00
|
|
|
// Move the toolbar to the overlay header
|
2014-02-07 19:08:24 +00:00
|
|
|
.appendTo( '.overlay-header > .toolbar' );
|
2014-02-06 23:33:21 +00:00
|
|
|
};
|