MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/289341
Change subject: WIP: responsiveness in PHP
......................................................................
WIP: responsiveness in PHP
Change-Id: I661cfea6f28f00b88dae23950ede792254de9a3e
---
M includes/Tag/MapFrame.php
1 file changed, 31 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer
refs/changes/41/289341/1
diff --git a/includes/Tag/MapFrame.php b/includes/Tag/MapFrame.php
index 1ea7227..4406515 100644
--- a/includes/Tag/MapFrame.php
+++ b/includes/Tag/MapFrame.php
@@ -41,6 +41,20 @@
$output = $this->parser->getOutput();
+ $widthIsRelative = mb_substr( $this->width, -1 ) === '%';
+ if ( $widthIsRelative ) {
+ $width = is_numeric( $this->width ) ?
"{$this->width}px" : $this->width;
+ $outerStyle = "width:{$width};
height:{$this->height}px;";
+ $innerStyle = "height: {$this->height}";
+ } else {
+ $outerStyle = "max-width: {$this->width}; max-height:
{$this->height}";
+ $width = intval( preg_replace( '/px$/', '',
$this->width ) );
+ $height = intval( preg_replace( '/px$/', '',
$this->height ) );
+ $padding = ( 100 * $height ) / $width;
+ $innerStyle = "padding-bottom: $padding%";
+ }
+
+
switch ( $wgKartographerFrameMode ) {
/* Not implemented in Kartotherian yet
case 'static':
@@ -81,28 +95,34 @@
$output->addModules( 'ext.kartographer.live' );
- $attrs = $this->getDefaultAttributes();
- $attrs['class'] .= '
mw-kartographer-interactive';
+ $outerAttrs = $this->getDefaultAttributes();
+ $outerAttrs['class'] .= '
mw-kartographer-interactive';
if ( isset( $alignClasses[$this->align] ) ) {
- $attrs['class'] .= ' ' .
$alignClasses[$this->align];
+ $outerAttrs['class'] .= ' ' .
$alignClasses[$this->align];
}
- $width = is_numeric( $this->width ) ?
"{$this->width}px" : $this->width;
- $attrs['style'] = "width:{$width};
height:{$this->height}px;";
- $attrs['data-style'] = $this->mapStyle;
- $attrs['data-zoom'] = $this->zoom;
- $attrs['data-lat'] = $this->lat;
- $attrs['data-lon'] = $this->lon;
+ $outerAttrs['style'] = $outerStyle;
+ $outerAttrs['data-style'] = $this->mapStyle;
+ $outerAttrs['data-zoom'] = $this->zoom;
+ $outerAttrs['data-lat'] = $this->lat;
+ $outerAttrs['data-lon'] = $this->lon;
if ( $this->showGroups ) {
- $attrs['data-overlays'] =
FormatJson::encode( $this->showGroups, false,
+ $outerAttrs['data-overlays'] =
FormatJson::encode( $this->showGroups, false,
FormatJson::ALL_OK );
}
+
+ $innerDiv = Html::element( 'div',
+ [
+ 'class' =>
'mw-kartographer-responder',
+ 'style' => $innerStyle,
+ ]
+ );
$groups = $output->getExtensionData(
'kartographer_interact' );
$groups = $groups ?: [];
$groups = array_merge( $groups,
$this->showGroups );
$output->setExtensionData(
'kartographer_interact', $groups );
- return Html::rawElement( 'div', $attrs );
+ return Html::rawElement( 'div', $outerAttrs,
$innerDiv );
break;
default:
throw new UnexpectedValueException(
--
To view, visit https://gerrit.wikimedia.org/r/289341
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I661cfea6f28f00b88dae23950ede792254de9a3e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits