jenkins-bot has submitted this change and it was merged.
Change subject: Remove mw.kartographer, use module interface instead.
......................................................................
Remove mw.kartographer, use module interface instead.
Bug: T140520
Change-Id: I18549fe448a71aa811df6bc1b0fdc87a1cd7ea74
---
M modules/fullscreen/MapDialog.js
M modules/kartographer.js
M modules/live/FullScreenControl.js
M modules/mapframe/mapframe.js
M modules/maplink/maplink.js
5 files changed, 30 insertions(+), 31 deletions(-)
Approvals:
Yurik: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/fullscreen/MapDialog.js b/modules/fullscreen/MapDialog.js
index b7a1b84..5901abe 100644
--- a/modules/fullscreen/MapDialog.js
+++ b/modules/fullscreen/MapDialog.js
@@ -9,7 +9,7 @@
* @class Kartographer.Fullscreen.MapDialog
* @extends OO.ui.Dialog
*/
-module.MapDialog = ( function ( $, mw, kartoLive, router, CloseControl ) {
+module.MapDialog = ( function ( $, mw, kartographer, kartoLive, router,
CloseControl ) {
/**
* @constructor
@@ -101,7 +101,7 @@
* Tells the router to navigate to the current full screen map route.
*/
MapDialog.prototype.updateHash = function () {
- var hash = mw.kartographer.getMapHash( this.mapData, this.map );
+ var hash = kartographer.getMapHash( this.mapData, this.map );
// Avoid extra operations
if ( this.lastHash !== hash ) {
@@ -191,6 +191,7 @@
} )(
jQuery,
mediaWiki,
+ require( 'ext.kartographer.init' ),
require( 'ext.kartographer.live' ),
require( 'mediawiki.router' ),
module.FullScreenCloseControl
diff --git a/modules/kartographer.js b/modules/kartographer.js
index 6dce207..437e461 100644
--- a/modules/kartographer.js
+++ b/modules/kartographer.js
@@ -1,7 +1,7 @@
/* globals module */
/**
- * The base module creates the `mw.kartographer` namespace and defines common
- * utility methods.
+ * This module contains utility methods that may be useful to all other
+ * modules.
*
* @alias ext.kartographer.init
* @class Kartographer
@@ -9,9 +9,7 @@
*/
( function ( $, mw ) {
- var windowManager, mapDialog;
-
- mw.kartographer = mw.kartographer || {};
+ var windowManager, mapDialog, openFullscreenMap;
function getWindowManager() {
if ( !windowManager ) {
@@ -38,7 +36,7 @@
* @param {number} [fullScreenState.latitude]
* @param {number} [fullScreenState.longitude]
*/
- mw.kartographer.openFullscreenMap = ( function () {
+ openFullscreenMap = ( function () {
var counter = -1;
@@ -56,8 +54,6 @@
if ( mapData instanceof L.Map ) {
map = mapData;
mapData = getMapData( $(
map.getContainer() ).closest( '.mw-kartographer-interactive' ) );
- } else if ( mapData && mapData.isMapframe ) {
- map = mw.kartographer.maps[
mapData.maptagId ];
}
$.extend( dialogData, mapData, {
@@ -110,7 +106,7 @@
* read the current zoom and center from the map object.
* @return {string} The route to open the map in full screen mode.
*/
- mw.kartographer.getMapHash = function ( data, map ) {
+ function getMapHash( data, map ) {
var hash = '/' + ( data.isMapframe ? 'map' : 'maplink' ),
mapPosition,
@@ -129,7 +125,7 @@
}
return hash;
- };
+ }
/**
* Convenient method that gets the current position of the map.
@@ -230,8 +226,8 @@
}
module.exports = {
- getMapHash: mw.kartographer.getMapHash,
- openFullscreenMap: mw.kartographer.openFullscreenMap,
+ getMapHash: getMapHash,
+ openFullscreenMap: openFullscreenMap,
getMapData: getMapData,
getMapPosition: getMapPosition,
getFullScreenState: getFullScreenState,
diff --git a/modules/live/FullScreenControl.js
b/modules/live/FullScreenControl.js
index e1ade8c..ba59d1c 100644
--- a/modules/live/FullScreenControl.js
+++ b/modules/live/FullScreenControl.js
@@ -44,13 +44,13 @@
},
updateHash: function () {
- var hash = mw.kartographer.getMapHash(
this.options.mapData, this.map );
+ var hash = kartographer.getMapHash(
this.options.mapData, this.map );
this.link.href = '#' + hash;
},
onShowFullScreen: function ( e ) {
L.DomEvent.stop( e );
- mw.kartographer.openFullscreenMap( this.map,
kartographer.getMapPosition( this.map ) );
+ kartographer.openFullscreenMap( this.map,
kartographer.getMapPosition( this.map ) );
}
} );
} )( require( 'ext.kartographer.init' ), require( 'mediawiki.router' ) );
diff --git a/modules/mapframe/mapframe.js b/modules/mapframe/mapframe.js
index b07147c..5921348 100644
--- a/modules/mapframe/mapframe.js
+++ b/modules/mapframe/mapframe.js
@@ -1,4 +1,4 @@
-/* globals require */
+/* globals module, require */
/**
* Frame module.
*
@@ -10,15 +10,14 @@
* @class Kartographer.Frame
* @singleton
*/
-( function ( $, mw, kartographer, kartoLive, router ) {
+module.exports = ( function ( $, mw, kartographer, kartoLive, router ) {
/**
- * References the map containers of the page.
+ * References the mapframe containers of the page.
*
* @type {HTMLElement[]}
- * @member mw.kartographer
*/
- mw.kartographer.maps = [];
+ var maps = [];
/**
* Wraps a map container to make it (and its map) responsive on
@@ -122,7 +121,7 @@
map.doubleClickZoom.disable();
mapsInArticle.push( map );
- mw.kartographer.maps[ index ] = map;
+ maps[ index ] = map;
map.on( 'dblclick', function () {
if ( router.isSupported() ) {
@@ -146,19 +145,21 @@
// #/map/0/5
// #/map/0/16/-122.4006/37.7873
router.route(
/map\/([0-9]+)(?:\/([0-9]+))?(?:\/([\-\+]?\d+\.?\d{0,5})?\/([\-\+]?\d+\.?\d{0,5})?)?/,
function ( maptagId, zoom, latitude, longitude ) {
- var map = mw.kartographer.maps[ maptagId ];
+ var map = maps[ maptagId ];
if ( !map ) {
router.navigate( '' );
return;
}
- mw.kartographer.openFullscreenMap( map,
kartographer.getFullScreenState( zoom, latitude, longitude ) );
+ kartographer.openFullscreenMap( map,
kartographer.getFullScreenState( zoom, latitude, longitude ) );
} );
// Check if we need to open a map in full screen.
router.checkRoute();
} );
} );
+
+ return maps;
} )(
jQuery,
mediaWiki,
diff --git a/modules/maplink/maplink.js b/modules/maplink/maplink.js
index 76d04a3..e107106 100644
--- a/modules/maplink/maplink.js
+++ b/modules/maplink/maplink.js
@@ -1,4 +1,4 @@
-/* globals require */
+/* globals module, require */
/**
* Link module.
*
@@ -10,15 +10,14 @@
* @class Kartographer.Link
* @singleton
*/
-( function ( $, mw, kartographer, router ) {
+module.exports = ( function ( $, mw, kartographer, router ) {
/**
* References the maplinks of the page.
*
* @type {HTMLElement[]}
- * @member mw.kartographer
*/
- mw.kartographer.maplinks = [];
+ var maplinks = [];
/**
* This code will be executed once the article is rendered and ready.
@@ -31,7 +30,7 @@
// search outside. This is an anti-pattern and should be
improved...
// Meanwhile #content is better than searching the full
document.
$( '.mw-kartographer-link', '#content' ).each( function ( index
) {
- mw.kartographer.maplinks[ index ] = this;
+ maplinks[ index ] = this;
$( this ).data( 'maptag-id', index );
this.href = '#' + '/maplink/' + index;
@@ -43,7 +42,7 @@
// #/maplink/0/5
// #/maplink/0/16/-122.4006/37.7873
router.route(
/maplink\/([0-9]+)(?:\/([0-9]+))?(?:\/([\-\+]?\d+\.?\d{0,5})?\/([\-\+]?\d+\.?\d{0,5})?)?/,
function ( maptagId, zoom, latitude, longitude ) {
- var link = mw.kartographer.maplinks[ maptagId ],
+ var link = maplinks[ maptagId ],
data;
if ( !link ) {
@@ -51,12 +50,14 @@
return;
}
data = kartographer.getMapData( link );
- mw.kartographer.openFullscreenMap( data,
kartographer.getFullScreenState( zoom, latitude, longitude ) );
+ kartographer.openFullscreenMap( data,
kartographer.getFullScreenState( zoom, latitude, longitude ) );
} );
// Check if we need to open a map in full screen.
router.checkRoute();
} );
+
+ return maplinks;
} )(
jQuery,
mediaWiki,
--
To view, visit https://gerrit.wikimedia.org/r/299269
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I18549fe448a71aa811df6bc1b0fdc87a1cd7ea74
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: JGirault <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits