r83436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83435‎ | r83436 | r83437 >
Date:05:40, 7 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
improved popup contents handling
Modified paths:
  • /branches/Maps0.8/includes/features/Maps_BasePointMap.php (modified) (history)
  • /branches/Maps0.8/includes/manipulations/Maps_ParamZoom.php (modified) (history)
  • /branches/Maps0.8/includes/services/OpenLayers/jquery.openlayers.js (modified) (history)

Diff [purge]

Index: branches/Maps0.8/includes/services/OpenLayers/jquery.openlayers.js
@@ -152,29 +152,21 @@
153153 var marker;
154154
155155 if ( markerData.icon != "" ) {
156 - marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon));
 156+ marker = new OpenLayers.Marker( markerData.lonlat, new OpenLayers.Icon( markerData.icon ) );
157157 } else {
158 - marker = new OpenLayers.Marker(markerData.lonlat);
 158+ marker = new OpenLayers.Marker( markerData.lonlat );
159159 }
160160
161 - if ( markerData.text != '' || markerData.title != '' ) {
 161+ if ( markerData.text != '' ) {
162162 // This is the handler for the mousedown event on the marker, and displays the popup.
163163 marker.events.register('mousedown', marker,
164 - function(evt) {
165 - var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true);
166 -
167 - if ( markerData.title != '' && markerData.text != '' ) { // Add the title and text to the popup text.
168 - popup.setContentHTML('<b>' + markerData.title + '</b><hr />' + markerData.text);
169 - }
170 - else {
171 - popup.setContentHTML(markerData.title + markerData.text);
172 - }
173 -
174 - markerLayer.map.addPopup(popup);
175 - OpenLayers.Event.stop(evt); // Stop the event.
 164+ function( evt ) {
 165+ var popup = new OpenLayers.Feature( markerLayer, markerData.lonlat ).createPopup( true );
 166+ popup.setContentHTML( markerData.text );
 167+ markerLayer.map.addPopup( popup );
 168+ OpenLayers.Event.stop( evt ); // Stop the event.
176169 }
177170 );
178 -
179171 }
180172
181173 return marker;
Index: branches/Maps0.8/includes/manipulations/Maps_ParamZoom.php
@@ -29,10 +29,10 @@
3030 */
3131 public function doManipulation( &$value, Parameter $parameter, array &$parameters ) {
3232 // If there are multiple points and the value was not provided or incorrect (=defaulted),
33 - // set it to 'null', so the mapping service can figure out the optimal value.
 33+ // set it to false, so the mapping service can figure out the optimal value.
3434 if ( $parameter->wasSetToDefault() && count( $parameters['coordinates']->getValue() ) > 1 ) {
3535 $value = false;
3636 }
3737 }
3838
39 -}
\ No newline at end of file
 39+}
Index: branches/Maps0.8/includes/features/Maps_BasePointMap.php
@@ -154,9 +154,13 @@
155155 if ( $location->isValid() ) {
156156 $jsonObj = $location->getJSONObject( $params['title'], $params['label'], $iconUrl );
157157
158 - $jsonObj['title'] = strip_tags( $parser->parse( $jsonObj['title'], $wgTitle, new ParserOptions() )->getText() );
 158+ $jsonObj['title'] = $parser->parse( $jsonObj['title'], $wgTitle, new ParserOptions() )->getText();
159159 $jsonObj['text'] = $parser->parse( $jsonObj['text'], $wgTitle, new ParserOptions() )->getText();
160160
 161+ $hasTitleAndtext = $jsonObj['title'] != '' && $jsonObj['text'] != '';
 162+ $jsonObj['text'] = ( $hasTitleAndtext ? '<b>' . $jsonObj['title'] . '</b><hr />' : $jsonObj['title'] ) . $jsonObj['text'];
 163+ $jsonObj['title'] = strip_tags( $jsonObj['title'] );
 164+
161165 $params['locations'][] = $jsonObj;
162166 }
163167 }

Status & tagging log