r69534 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69533‎ | r69534 | r69535 >
Date:05:06, 19 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Renamed form JS files
Modified paths:
  • /trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsForms.js (added) (history)
  • /trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFunctions.js (deleted) (history)
  • /trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersForms.js (added) (history)
  • /trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFunctions.js (deleted) (history)
  • /trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsForms.js (added) (history)
  • /trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFunctions.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFunctions.js
@@ -1,62 +0,0 @@
2 - /**
3 - * Javascript functions for Yahoo! Maps functionality in Semantic Maps
4 - *
5 - * @file SM_YahooMapsFunctions.js
6 - * @ingroup SMYahooMaps
7 - *
8 - * @author Jeroen De Dauw
9 - */
10 -
11 -/**
12 - * This function holds specific functionality for the Yahoo! Maps form input of Semantic Maps.
13 - */
14 -function makeFormInputYahooMap( mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon ) {
15 - var map = createYahooMap(
16 - document.getElementById( mapName ),
17 - new YGeoPoint( lat, lon ),
18 - zoom,
19 - type,
20 - types,
21 - controls,
22 - scrollWheelZoom,
23 - [ { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } ]
24 - );
25 -
26 - // Show a starting marker only if marker coordinates are provided.
27 - if ( marker_lat != null && marker_lon != null ) {
28 - map.addOverlay( createYMarker( new YGeoPoint( marker_lat, marker_lon ) ) );
29 - }
30 -
31 - // Click event handler for updating the location of the marker.
32 - YEvent.Capture(map, EventsList.MouseClick,
33 - function(_e, point) {
34 - var loc = new YGeoPoint(point.Lat, point.Lon)
35 - map.removeMarkersAll();
36 - document.getElementById(locationFieldName).value = convertLatToDMS(point.Lat)+', '+convertLngToDMS(point.Lon);
37 - map.addMarker(loc);
38 - map.panToLatLon(loc);
39 - }
40 - );
41 -
42 - // Make the map variable available for other functions
43 - if (!window.YMaps) window.YMaps = new Object;
44 - eval("window.YMaps." + mapName + " = map;");
45 -}
46 -
47 -/**
48 - * This function holds specific functionality for the Yahoo! Maps form input of Semantic Maps
49 - * TODO: Refactor as much code as possible to non specific functions
50 - */
51 -function showYAddress(address, mapName, outputElementName, notFoundFormat) {
52 - var map = YMaps[mapName];
53 -
54 - map.removeMarkersAll();
55 - map.drawZoomAndCenter(address);
56 -
57 - YEvent.Capture(map, EventsList.onEndGeoCode,
58 - function(resultObj) {
59 - map.addOverlay(new YMarker(resultObj.GeoPoint));
60 - document.getElementById(outputElementName).value = convertLatToDMS(resultObj.GeoPoint.Lat) + ', ' + convertLngToDMS(resultObj.GeoPoint.Lon);
61 - }
62 - );
63 -}
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsForms.js
@@ -0,0 +1,62 @@
 2+ /**
 3+ * Javascript functions for Yahoo! Maps functionality in Semantic Maps
 4+ *
 5+ * @file SM_YahooMapsFunctions.js
 6+ * @ingroup SMYahooMaps
 7+ *
 8+ * @author Jeroen De Dauw
 9+ */
 10+
 11+/**
 12+ * This function holds specific functionality for the Yahoo! Maps form input of Semantic Maps.
 13+ */
 14+function makeFormInputYahooMap( mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon ) {
 15+ var map = createYahooMap(
 16+ document.getElementById( mapName ),
 17+ new YGeoPoint( lat, lon ),
 18+ zoom,
 19+ type,
 20+ types,
 21+ controls,
 22+ scrollWheelZoom,
 23+ [ { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } ]
 24+ );
 25+
 26+ // Show a starting marker only if marker coordinates are provided.
 27+ if ( marker_lat != null && marker_lon != null ) {
 28+ map.addOverlay( createYMarker( new YGeoPoint( marker_lat, marker_lon ) ) );
 29+ }
 30+
 31+ // Click event handler for updating the location of the marker.
 32+ YEvent.Capture(map, EventsList.MouseClick,
 33+ function(_e, point) {
 34+ var loc = new YGeoPoint(point.Lat, point.Lon)
 35+ map.removeMarkersAll();
 36+ document.getElementById(locationFieldName).value = convertLatToDMS(point.Lat)+', '+convertLngToDMS(point.Lon);
 37+ map.addMarker(loc);
 38+ map.panToLatLon(loc);
 39+ }
 40+ );
 41+
 42+ // Make the map variable available for other functions
 43+ if (!window.YMaps) window.YMaps = new Object;
 44+ eval("window.YMaps." + mapName + " = map;");
 45+}
 46+
 47+/**
 48+ * This function holds specific functionality for the Yahoo! Maps form input of Semantic Maps
 49+ * TODO: Refactor as much code as possible to non specific functions
 50+ */
 51+function showYAddress(address, mapName, outputElementName, notFoundFormat) {
 52+ var map = YMaps[mapName];
 53+
 54+ map.removeMarkersAll();
 55+ map.drawZoomAndCenter(address);
 56+
 57+ YEvent.Capture(map, EventsList.onEndGeoCode,
 58+ function(resultObj) {
 59+ map.addOverlay(new YMarker(resultObj.GeoPoint));
 60+ document.getElementById(outputElementName).value = convertLatToDMS(resultObj.GeoPoint.Lat) + ', ' + convertLngToDMS(resultObj.GeoPoint.Lon);
 61+ }
 62+ );
 63+}
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsForms.js
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php
@@ -48,7 +48,7 @@
4949 global $wgOut;
5050 global $smgScriptPath, $smgYahooFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
5151
52 - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/YahooMaps/SM_YahooMapsFunctions{$egMapsJsExt}?$smgStyleVersion" ) );
 52+ $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/YahooMaps/SM_YahooMapsForms{$egMapsJsExt}?$smgStyleVersion" ) );
5353 $this->service->addDependencies( $wgOut );
5454 }
5555
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFunctions.js
@@ -1,98 +0,0 @@
2 - /**
3 - * Javascript functions for OpenLayers functionality in Semantic Maps
4 - *
5 - * @file SM_OpenLayersFunctions.js
6 - * @ingroup SMOpenLayers
7 - *
8 - * @author Jeroen De Dauw
9 - */
10 -
11 -/**
12 - * This function holds specific functionality for the Open Layers form input of Semantic Maps.
13 - */
14 -function makeFormInputOpenLayer( mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls, height, langCode ) {
15 - var markers = Array();
16 -
17 - // Show a starting marker only if marker coordinates are provided.
18 - if ( marker_lat != null && marker_lon != null ) {
19 - markers.push( { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } );
20 - }
21 -
22 - // Click event handler for updating the location of the marker
23 - // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
24 - OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
25 - defaultHandlerOptions: {
26 - 'single': true,
27 - 'double': false,
28 - 'pixelTolerance': 0,
29 - 'stopSingle': false,
30 - 'stopDouble': false
31 - },
32 -
33 - initialize: function(options) {
34 - this.handlerOptions = OpenLayers.Util.extend(
35 - {}, this.defaultHandlerOptions
36 - );
37 - OpenLayers.Control.prototype.initialize.apply(
38 - this, arguments
39 - );
40 - this.handler = new OpenLayers.Handler.Click(
41 - this, {
42 - 'click': this.trigger
43 - }, this.handlerOptions
44 - );
45 - },
46 -
47 - trigger: function(e) {
48 - var lonlat = map.getLonLatFromViewPortPx(e.xy);
49 -
50 - replaceMarker(mapName, lonlat);
51 -
52 - var proj = new OpenLayers.Projection("EPSG:4326");
53 - lonlat.transform(map.getProjectionObject(), proj);
54 -
55 - document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon);
56 - }
57 -
58 - });
59 -
60 - var clickHanler = new OpenLayers.Control.Click();
61 - controls.push(clickHanler);
62 -
63 - var map = initOpenLayer( mapName, lon, lat, zoom, layers, controls, markers, height, langCode );
64 -
65 - // Make the map variable available for other functions
66 - if (!window.OLMaps) window.OLMaps = new Object;
67 - eval("window.OLMaps." + mapName + " = map;");
68 -}
69 -
70 -/**
71 - * Remove all markers from an OL map (that's in window.OLMaps), and place a new one.
72 - *
73 - * @param mapName Name of the map as in OLMaps[mapName].
74 - * @param newLocation The location for the new marker.
75 - * @return
76 - */
77 -function replaceMarker(mapName, newLocation) {
78 - var map = OLMaps[mapName];
79 - var markerLayer = map.getLayer('markerLayer');
80 -
81 - removeMarkers(markerLayer);
82 - markerLayer.addMarker(getOLMarker(markerLayer, getOLMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject()));
83 -
84 - map.panTo(newLocation);
85 -}
86 -
87 -/**
88 - * Removes all markers from a marker layer.
89 - *
90 - * @param markerLayer The layer to remove all markers from.
91 - * @return
92 - */
93 -function removeMarkers(markerLayer) {
94 - var markerCollection = markerLayer.markers;
95 -
96 - for (var i = 0; i < markerCollection.length; i++) {
97 - markerLayer.removeMarker(markerCollection[i]);
98 - }
99 -}
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersForms.js
@@ -0,0 +1,98 @@
 2+ /**
 3+ * Javascript functions for OpenLayers functionality in Semantic Maps
 4+ *
 5+ * @file SM_OpenLayersFunctions.js
 6+ * @ingroup SMOpenLayers
 7+ *
 8+ * @author Jeroen De Dauw
 9+ */
 10+
 11+/**
 12+ * This function holds specific functionality for the Open Layers form input of Semantic Maps.
 13+ */
 14+function makeFormInputOpenLayer( mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls, height, langCode ) {
 15+ var markers = Array();
 16+
 17+ // Show a starting marker only if marker coordinates are provided.
 18+ if ( marker_lat != null && marker_lon != null ) {
 19+ markers.push( { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } );
 20+ }
 21+
 22+ // Click event handler for updating the location of the marker
 23+ // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
 24+ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
 25+ defaultHandlerOptions: {
 26+ 'single': true,
 27+ 'double': false,
 28+ 'pixelTolerance': 0,
 29+ 'stopSingle': false,
 30+ 'stopDouble': false
 31+ },
 32+
 33+ initialize: function(options) {
 34+ this.handlerOptions = OpenLayers.Util.extend(
 35+ {}, this.defaultHandlerOptions
 36+ );
 37+ OpenLayers.Control.prototype.initialize.apply(
 38+ this, arguments
 39+ );
 40+ this.handler = new OpenLayers.Handler.Click(
 41+ this, {
 42+ 'click': this.trigger
 43+ }, this.handlerOptions
 44+ );
 45+ },
 46+
 47+ trigger: function(e) {
 48+ var lonlat = map.getLonLatFromViewPortPx(e.xy);
 49+
 50+ replaceMarker(mapName, lonlat);
 51+
 52+ var proj = new OpenLayers.Projection("EPSG:4326");
 53+ lonlat.transform(map.getProjectionObject(), proj);
 54+
 55+ document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon);
 56+ }
 57+
 58+ });
 59+
 60+ var clickHanler = new OpenLayers.Control.Click();
 61+ controls.push(clickHanler);
 62+
 63+ var map = initOpenLayer( mapName, lon, lat, zoom, layers, controls, markers, height, langCode );
 64+
 65+ // Make the map variable available for other functions
 66+ if (!window.OLMaps) window.OLMaps = new Object;
 67+ eval("window.OLMaps." + mapName + " = map;");
 68+}
 69+
 70+/**
 71+ * Remove all markers from an OL map (that's in window.OLMaps), and place a new one.
 72+ *
 73+ * @param mapName Name of the map as in OLMaps[mapName].
 74+ * @param newLocation The location for the new marker.
 75+ * @return
 76+ */
 77+function replaceMarker(mapName, newLocation) {
 78+ var map = OLMaps[mapName];
 79+ var markerLayer = map.getLayer('markerLayer');
 80+
 81+ removeMarkers(markerLayer);
 82+ markerLayer.addMarker(getOLMarker(markerLayer, getOLMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject()));
 83+
 84+ map.panTo(newLocation);
 85+}
 86+
 87+/**
 88+ * Removes all markers from a marker layer.
 89+ *
 90+ * @param markerLayer The layer to remove all markers from.
 91+ * @return
 92+ */
 93+function removeMarkers(markerLayer) {
 94+ var markerCollection = markerLayer.markers;
 95+
 96+ for (var i = 0; i < markerCollection.length; i++) {
 97+ markerLayer.removeMarker(markerCollection[i]);
 98+ }
 99+}
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersForms.js
___________________________________________________________________
Added: svn:eol-style
1100 + native
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php
@@ -38,7 +38,7 @@
3939 global $wgOut;
4040 global $smgScriptPath, $smgOLFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
4141
42 - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/OpenLayers/SM_OpenLayersFunctions{$egMapsJsExt}?$smgStyleVersion" ) );
 42+ $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/OpenLayers/SM_OpenLayersForms{$egMapsJsExt}?$smgStyleVersion" ) );
4343 $this->service->addDependencies( $wgOut );
4444 }
4545
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFunctions.js
@@ -1,64 +0,0 @@
2 - /**
3 - * Javascript functions for Google Maps functionality in Semantic Maps
4 - *
5 - * @file SM_GoogleMapFunctions.js
6 - * @ingroup SMGoogleMaps
7 - *
8 - * @author Jeroen De Dauw
9 - */
10 -
11 -/**
12 - * This function holds specific functionality for the Google Maps form input of Semantic Maps
13 - */
14 -function makeGoogleMapFormInput( mapName, locationFieldName, mapOptions, marker_lat, marker_lon ) {
15 - if ( GBrowserIsCompatible() ) {
16 - mapOptions.centre = new GLatLng(mapOptions.lat, mapOptions.lon);
17 - var map = createGoogleMap( mapName, mapOptions, [ { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } ] );
18 -
19 - // Show a starting marker only if marker coordinates are provided
20 - if ( marker_lat != null && marker_lon != null ) {
21 - map.addOverlay( new GMarker( new GLatLng( marker_lat, marker_lon ) ) );
22 - }
23 -
24 - // Click event handler for updating the location of the marker
25 - GEvent.addListener(map, "click",
26 - function(overlay, point) {
27 - if (overlay) {
28 - map.removeOverlay(overlay);
29 - } else {
30 - map.clearOverlays();
31 - document.getElementById(locationFieldName).value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x);
32 - map.addOverlay(new GMarker(point));
33 - map.panTo(point);
34 - }
35 - }
36 - );
37 -
38 - // Make the map variable available for other functions
39 - if (!window.GMaps) window.GMaps = new Object;
40 - eval("window.GMaps." + mapName + " = map;");
41 - }
42 -}
43 -
44 -/**
45 - * This function holds specific functionality for the Google Maps form input of Semantic Maps
46 - */
47 -function showGAddress(address, mapName, outputElementName, notFoundFormat) {
48 - var map = GMaps[mapName];
49 - var geocoder = new GClientGeocoder();
50 -
51 - geocoder.getLatLng(address,
52 - function(point) {
53 - if (!point) {
54 - window.alert(address + ' ' + notFoundFormat);
55 - } else {
56 - map.clearOverlays();
57 - map.setCenter(point, 14);
58 - var marker = new GMarker(point);
59 - map.addOverlay(marker);
60 - document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x);
61 - }
62 - }
63 - );
64 -
65 -}
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php
@@ -52,7 +52,7 @@
5353 global $wgOut;
5454 global $smgScriptPath, $smgGoogleFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
5555
56 - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/GoogleMaps/SM_GoogleMapsFunctions{$egMapsJsExt}?$smgStyleVersion" ) );
 56+ $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/GoogleMaps/SM_GoogleMapsForms{$egMapsJsExt}?$smgStyleVersion" ) );
5757 $this->service->addDependencies( $wgOut );
5858 }
5959
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsForms.js
@@ -0,0 +1,64 @@
 2+ /**
 3+ * Javascript functions for Google Maps functionality in Semantic Maps
 4+ *
 5+ * @file SM_GoogleMapFunctions.js
 6+ * @ingroup SMGoogleMaps
 7+ *
 8+ * @author Jeroen De Dauw
 9+ */
 10+
 11+/**
 12+ * This function holds specific functionality for the Google Maps form input of Semantic Maps
 13+ */
 14+function makeGoogleMapFormInput( mapName, locationFieldName, mapOptions, marker_lat, marker_lon ) {
 15+ if ( GBrowserIsCompatible() ) {
 16+ mapOptions.centre = new GLatLng(mapOptions.lat, mapOptions.lon);
 17+ var map = createGoogleMap( mapName, mapOptions, [ { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } ] );
 18+
 19+ // Show a starting marker only if marker coordinates are provided
 20+ if ( marker_lat != null && marker_lon != null ) {
 21+ map.addOverlay( new GMarker( new GLatLng( marker_lat, marker_lon ) ) );
 22+ }
 23+
 24+ // Click event handler for updating the location of the marker
 25+ GEvent.addListener(map, "click",
 26+ function(overlay, point) {
 27+ if (overlay) {
 28+ map.removeOverlay(overlay);
 29+ } else {
 30+ map.clearOverlays();
 31+ document.getElementById(locationFieldName).value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x);
 32+ map.addOverlay(new GMarker(point));
 33+ map.panTo(point);
 34+ }
 35+ }
 36+ );
 37+
 38+ // Make the map variable available for other functions
 39+ if (!window.GMaps) window.GMaps = new Object;
 40+ eval("window.GMaps." + mapName + " = map;");
 41+ }
 42+}
 43+
 44+/**
 45+ * This function holds specific functionality for the Google Maps form input of Semantic Maps
 46+ */
 47+function showGAddress(address, mapName, outputElementName, notFoundFormat) {
 48+ var map = GMaps[mapName];
 49+ var geocoder = new GClientGeocoder();
 50+
 51+ geocoder.getLatLng(address,
 52+ function(point) {
 53+ if (!point) {
 54+ window.alert(address + ' ' + notFoundFormat);
 55+ } else {
 56+ map.clearOverlays();
 57+ map.setCenter(point, 14);
 58+ var marker = new GMarker(point);
 59+ map.addOverlay(marker);
 60+ document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x);
 61+ }
 62+ }
 63+ );
 64+
 65+}
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsForms.js
___________________________________________________________________
Added: svn:eol-style
166 + native

Status & tagging log