1/** 2 * @namespace WPGMZA 3 * @module GoogleVertexContextMenu 4 * @requires wpgmza_api_call 5 */ 6jQuery(function($) { 7 8 if(WPGMZA.settings.engine != "google-maps") 9 return; 10 11 if(WPGMZA.googleAPIStatus && WPGMZA.googleAPIStatus.code == "USER_CONSENT_NOT_GIVEN") 12 return; 13 14 if(typeof google === 'undefined' || typeof google.maps === 'undefined' || typeof google.maps.OverlayView === 'undefined'){ 15 return; 16 } 17 18 WPGMZA.GoogleVertexContextMenu = function(mapEditPage) 19 { 20 var self = this; 21 22 this.mapEditPage = mapEditPage; 23 24 this.element = document.createElement("div"); 25 this.element.className = "wpgmza-vertex-context-menu"; 26 this.element.innerHTML = "Delete"; 27 28 google.maps.event.addDomListener(this.element, "click", function(event) { 29 self.removeVertex(); 30 event.preventDefault(); 31 event.stopPropagation(); 32 return false; 33 }); 34 } 35 36 WPGMZA.GoogleVertexContextMenu.prototype = new google.maps.OverlayView(); 37 38 WPGMZA.GoogleVertexContextMenu.prototype.onAdd = function() 39 { 40 var self = this; 41 var map = this.getMap(); 42 43 this.getPanes().floatPane.appendChild(this.element); 44 this.divListener = google.maps.event.addDomListener(map.getDiv(), "mousedown", function(e) { 45 if(e.target != self.element) 46 self.close(); 47 }, true); 48 } 49 50 WPGMZA.GoogleVertexContextMenu.prototype.onRemove = function() 51 { 52 google.maps.event.removeListener(this.divListener); 53 this.element.parentNode.removeChild(this.element); 54 55 this.set("position"); 56 this.set("path"); 57 this.set("vertex"); 58 } 59 60 WPGMZA.GoogleVertexContextMenu.prototype.open = function(map, path, vertex) 61 { 62 this.set('position', path.getAt(vertex)); 63 this.set('path', path); 64 this.set('vertex', vertex); 65 this.setMap(map); 66 this.draw(); 67 } 68 69 WPGMZA.GoogleVertexContextMenu.prototype.close = function() 70 { 71 this.setMap(null); 72 } 73 74 WPGMZA.GoogleVertexContextMenu.prototype.draw = function() 75 { 76 var position = this.get('position'); 77 var projection = this.getProjection(); 78 79 if (!position || !projection) 80 return; 81 82 var point = projection.fromLatLngToDivPixel(position); 83 this.element.style.top = point.y + 'px'; 84 this.element.style.left = point.x + 'px'; 85 } 86 87 WPGMZA.GoogleVertexContextMenu.prototype.removeVertex = function() 88 { 89 var path = this.get('path'); 90 var vertex = this.get('vertex'); 91 92 if (!path || vertex == undefined) { 93 this.close(); 94 return; 95 } 96 97 path.removeAt(vertex); 98 this.close(); 99 } 100 101});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.