Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/262736

Change subject: Cleanup HTML output
......................................................................

Cleanup HTML output

For parsing consistency always output
  <div class="mw-kartographer mw-kartographer-{mode}">
as the root element.                                    )

Change-Id: I9ff808430cd91125554a167071db4b25944f9f42
---
M Kartographer.hooks.php
M modules/kartographer.js
D styles/live.less
D styles/static.less
R styles/styles.less
5 files changed, 24 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer 
refs/changes/36/262736/1

diff --git a/Kartographer.hooks.php b/Kartographer.hooks.php
index 0719dec..c6c0823 100644
--- a/Kartographer.hooks.php
+++ b/Kartographer.hooks.php
@@ -131,19 +131,24 @@
                }
 
                $html = '';
+               $attrs = array(
+                       'class' => 'mw-kartographer mw-kartographer-' . $mode,
+               );
                switch ( $mode ) {
                        case 'static':
                                // 
http://.../img/{source},{zoom},{lat},{lon},{width}x{height} [ @{scale}x ] 
.{format}
                                // Optional query value:  ? data = 
{title}|{group1}|{group2}|...
                                global $wgKartographerMapServer, 
$wgKartographerSrcsetScales;
 
-                               $statParams = sprintf( 
'%s/img/%s,%s,%s,%s,%sx%s', $wgKartographerMapServer, $style,
-                                               $zoom, $lat, $lon, $width, 
$height );
-                               $attrs = array(
-                                               'class' => 
'mw-kartographer-img',
-                                               'src' => $statParams . '.jpeg' 
. $dataParam,
-                                               'width' => $width,
-                                               'height' => $height,
+                               $statParams = sprintf( 
'%s/img/%s,%s,%s,%s,%sx%s',
+                                       $wgKartographerMapServer, $style,
+                                       $zoom, $lat, $lon, $width, $height
+                               );
+
+                               $imgAttrs = array(
+                                       'src' => $statParams . '.jpeg' . 
$dataParam,
+                                       'width' => $width,
+                                       'height' => $height,
                                );
                                if ( $wgKartographerSrcsetScales ) {
                                        $srcSet = array();
@@ -151,22 +156,23 @@
                                                $s = '@' . $scale . 'x';
                                                $srcSet[$scale] = $statParams . 
$s . '.jpeg' . $dataParam;
                                        }
-                                       $attrs['srcset'] = Html::srcSet( 
$srcSet );
+                                       $imgAttrs['srcset'] = Html::srcSet( 
$srcSet );
                                }
 
                                $output->addModules( 'ext.kartographer.static' 
);
-                               $html = Html::rawElement( 'img', $attrs );
+                               $html = Html::rawElement( 'div', $attrs,
+                                       Html::rawElement( 'img', $imgAttrs )
+                               );
                                break;
 
                        case 'interactive':
-                               $attrs = array(
-                                               'class' => 
'mw-kartographer-live',
-                                               'style' => 
"width:${width}px;height:${height}px",
-                                               'data-style' => $style,
-                                               'data-zoom' => $zoom,
-                                               'data-lat' => $lat,
-                                               'data-lon' => $lon,
-                               );
+                               $attrs = array_merge( $attrs, array(
+                                       'style' => 
"width:${width}px;height:${height}px;",
+                                       'data-style' => $style,
+                                       'data-zoom' => $zoom,
+                                       'data-lat' => $lat,
+                                       'data-lon' => $lon,
+                               ) );
                                if ( $groups ) {
                                        $attrs['data-overlays'] = 
FormatJson::encode( $groups, false,
                                                        FormatJson::ALL_OK );
diff --git a/modules/kartographer.js b/modules/kartographer.js
index 92cf5c0..680fe0e 100644
--- a/modules/kartographer.js
+++ b/modules/kartographer.js
@@ -37,7 +37,7 @@
                urlFormat = '/{z}/{x}/{y}' + scale + '.png';
                mapData = mw.config.get( 'wgKartographerLiveData' ) || {};
 
-               $content.find( '.mw-kartographer-live' ).each( function () {
+               $content.find( '.mw-kartographer-interactive' ).each( function 
() {
                        var dataLayer, geoJson,
                                $this = $( this ),
                                style = $this.data( 'style' ),
diff --git a/styles/live.less b/styles/live.less
deleted file mode 100644
index e86ba6a..0000000
--- a/styles/live.less
+++ /dev/null
@@ -1,3 +0,0 @@
-.mw-kartographer-live {
-       display: inline-block;
-}
diff --git a/styles/static.less b/styles/static.less
deleted file mode 100644
index 353f6cf..0000000
--- a/styles/static.less
+++ /dev/null
@@ -1,3 +0,0 @@
-.mw-kartographer-img {
-       display: inline-block;
-}
diff --git a/styles/error.less b/styles/styles.less
similarity index 100%
rename from styles/error.less
rename to styles/styles.less

-- 
To view, visit https://gerrit.wikimedia.org/r/262736
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ff808430cd91125554a167071db4b25944f9f42
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to