Inchikutty has uploaded a new change for review. https://gerrit.wikimedia.org/r/112342
Change subject: [WIP] UploadWizard:OSM embedding ...................................................................... [WIP] UploadWizard:OSM embedding Work In Progress!!! Bug:56614 Change-Id: I3daee45a61afbf7ca0dda620f1f61a296586c545 --- M resources/mw.GeoMap.js M resources/uploadWizard.css 2 files changed, 52 insertions(+), 52 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard refs/changes/42/112342/1 diff --git a/resources/mw.GeoMap.js b/resources/mw.GeoMap.js index f1632a5..657cbb3 100644 --- a/resources/mw.GeoMap.js +++ b/resources/mw.GeoMap.js @@ -13,30 +13,40 @@ _this.isGeoMapInitialized = false; _this.map = null; - mw.GeoMap.numInstances = ( mw.GeoMap.numInstances || 0 ) + 1; - var mapId = "mapcontainer-mwe-loc-map-"+ mw.GeoMap.numInstances; - var mapDiv = $( '<div class="mwe-loc-map"id="'+mapId+'"></div>' ); - _this.$form.find( '.mwe-location-label' ).append( mapDiv ); + mw.GeoMap.mapId = ( mw.GeoMap.mapId || 0 ) + 1; + var mapDiv = $( '<div class="mwe-loc-map"id="mwe-location-map'+mw.GeoMap.mapId+'"></div>' ); + var showStaticMap = $( '<div class="mwe-loc-map-label"id="mwe-loc-map-label"></div>' ).append($('<a class="mwe-loc-link">static</a>')); + var showLeafletMap = $( '<div class="mwe-loc-map-label"id="mwe-loc-map-label"></div>' ).append($('<a class="mwe-loc-link">dynamic</a>')); + var geoMapDiv = $( '<div class="mwe-location-map"></div>' ) + .append( showStaticMap, showLeafletMap, mapDiv ); + _this.$form.find( '.mwe-location-label' ).append( geoMapDiv ); var $list = _this.$form.find( '.mwe-loc-lat, .mwe-loc-lon ' ); - $list.on( 'input keyup change cut paste', function() { + $list.on( 'input cut keyup paste uw-copy', function() { if ( $list.valid() ){ if( _this.isGeoMapInitialized ){ - _this.geoMap( $list.eq(0).val(), $list.eq(1).val() ); + _this.geoMapInit( $list.eq(0).val(), $list.eq(1).val(), mapDiv ); } else{ _this.staticMap( $list.eq(0).val(), $list.eq(1).val(), mapDiv ); } + showLeafletMap.click( function(){ + _this.mapRemove( mapDiv ); + _this.geoMapInit( $list.eq(0).val(), $list.eq(1).val(), mapDiv ); + }); + showStaticMap.click( function(){ + _this.mapRemove( mapDiv ); + _this.staticMap( $list.eq(0).val(), $list.eq(1).val(), mapDiv ); + }); } else{ - if( _this.isGeoMapInitialized ){ - _this.geoMapRemove( mapDiv ); - } - else{ - _this.staticMapRemove( mapDiv ); - } + _this.mapRemove( mapDiv ); } }); + +/* $list.trigger( "uw-input", function() { + $(this).on ('input cut keyup paste'); + });*/ _this.marker = L.marker([ 0 , 0 ]); L.Icon.Default.imagePath = '../extensions/UploadWizard/resources/leaflet/images'; @@ -65,21 +75,9 @@ */ staticMap: function( latVal , lonVal, mapDiv ) { var _this =this; - _this.staticMapRemove( mapDiv ); + _this.mapRemove( mapDiv ); var link = _this.staticMapLink( latVal, lonVal ); - $( '<img></img>' ).attr('src', link ).addClass('mwe-loc-map').appendTo( mapDiv ) - .click( function(){ - _this.staticMapRemove( mapDiv ); - _this.geoMapInit( latVal, lonVal, mapDiv ); - }); - }, - - /** - *Removes static map - *@param {HTMLDivElement} MapDiv The div that contains static map - */ - staticMapRemove: function( mapDiv ) { - mapDiv.empty(); + $( '<img></img>' ).attr('src', link ).addClass('mwe-loc-map').appendTo( mapDiv ); }, /** @@ -89,20 +87,13 @@ *@param {HTMLDivElement} MapDiv The div to append the map into */ geoMapInit: function( latVal, lonVal, mapDiv) { - this.map = new L.map( mapDiv.attr("id"), { center: [ latVal, lonVal ], zoom: 14 } ); - this.isGeoMapInitialized = true; - new L.TileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ - minZoom: 1, maxZoom: 20, attribution: 'Map data by OpenStreetMap contributors' } ) - .addTo( this.map ); - this.geoMap( latVal, lonVal ); - }, - - /** - *Displays leaflet map - *@param {Number} latitude - *@param {Number} longitude - */ - geoMap: function( latVal, lonVal ) { + if( !this.isGeoMapInitialized ){ + this.map = new L.map( mapDiv.attr("id"), { center: [ latVal, lonVal ], zoom: 14 } ); + this.isGeoMapInitialized = true; + new L.TileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ + minZoom: 1, maxZoom: 16, attribution: 'Map data by OpenStreetMap contributors' } ) + .addTo( this.map ); + } var _this = this; var latlng = L.latLng ( latVal , lonVal ); this.markMapView( latlng ); @@ -112,14 +103,16 @@ }, /** - *Removes leaflet map + *Removes map *@param {HTMLDivElement} MapDiv The div that contains static map */ - geoMapRemove: function( mapDiv ) { - this.isGeoMapInitialized = false; - this.map.removeLayer(this.marker); - this.map.remove(); - this.map = null; + mapRemove: function( mapDiv ) { + if( this.isGeoMapInitialized ){ + this.isGeoMapInitialized = false; + this.map.removeLayer(this.marker); + this.map.remove(); + this.map = null; + } mapDiv.empty(); }, diff --git a/resources/uploadWizard.css b/resources/uploadWizard.css index f35ce17..afef96b 100644 --- a/resources/uploadWizard.css +++ b/resources/uploadWizard.css @@ -799,14 +799,17 @@ .mwe-location-alt { font-style:italic; } -/* Refer ---> http://stackoverflow.com/questions/17047694/add-line-break-to-before-or-after-pseudo-element-content */ -.mwe-loc-link:before { - content:'\a'; - white-space:pre; -} -.mwe-loc-link a{ +a.mwe-loc-link { cursor:pointer; +} +div.mwe-location-map{ + float:right; + background-color:white; + position: relative; + height:250px; + width: 280px; + padding:5 px; } div.mwe-loc-map{ @@ -820,6 +823,10 @@ img.mwe-loc-map { display: block; } +div.mwe-loc-map-label{ + float:left; + width:140px; +} .mwe-upwiz-category-will-be-added { font-style:italic; -- To view, visit https://gerrit.wikimedia.org/r/112342 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3daee45a61afbf7ca0dda620f1f61a296586c545 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: Inchikutty <inchikutt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits