1/** 2 * @namespace WPGMZA 3 * @module ProShape 4 * @requires WPGMZA.Shape 5 */ 6jQuery(function($) { 7 8 var Parent = WPGMZA.Shape; 9 10 /** 11 * A generic shape relay so that shapes can share common polygon features 12 */ 13 WPGMZA.ProShape = function(options, engineFeature) 14 { 15 var self = this; 16 WPGMZA.assertInstanceOf(this, "ProShape"); 17 18 Parent.apply(this, arguments); 19 20 this.on("mouseover", function(event) { 21 self.onMouseOver(event); 22 }); 23 24 this.on("mouseout", function(event) { 25 self.onMouseOut(event); 26 }); 27 28 this.on("click", function(event) { 29 self.onClick(event); 30 }); 31 } 32 33 WPGMZA.extend(WPGMZA.ProShape, WPGMZA.Shape); 34 35 WPGMZA.ProShape.BASE_LAYER_INDEX = 99999; 36 37 WPGMZA.ProShape.LINE_STYLES = { 38 SOLID : 0, 39 DASHED : 1, 40 DOTTED : 2 41 }; 42 43 Object.defineProperty(WPGMZA.ProShape.prototype, "hoverFillColor", { 44 enumerable: true, 45 46 "get": function() 47 { 48 if(!this.ohFillColor || !this.ohFillColor.length) 49 return "#000000"; 50 51 return "#" + this.ohFillColor.replace(/^#/, ""); 52 }, 53 "set": function(a){ 54 this.ohFillColor = a; 55 } 56 57 }); 58 59 Object.defineProperty(WPGMZA.ProShape.prototype, "hoverStrokeColor", { 60 enumerable: true, 61 62 "get": function() 63 { 64 if(!this.ohLineColor || !this.ohLineColor.length) 65 return "#000000"; 66 67 return "#" + this.ohLineColor.replace(/^#/, ""); 68 }, 69 "set": function(a){ 70 this.ohLineColor = a; 71 } 72 73 }); 74 75 Object.defineProperty(WPGMZA.ProShape.prototype, "hoverFillOpacity", { 76 enumerable: true, 77 78 "get": function() 79 { 80 if(!this.ohFillOpacity){ 81 return 0.5; 82 } 83 84 return this.ohFillOpacity; 85 }, 86 "set": function(a){ 87 this.ohFillOpacity = a; 88 } 89 90 }); 91 92 Object.defineProperty(WPGMZA.ProShape.prototype, "hoverLineOpacity", { 93 enumerable: true, 94 95 "get": function() 96 { 97 if(!this.ohLineOpacity){ 98 return 0.5; 99 } 100 101 return this.ohLineOpacity; 102 }, 103 "set": function(a){ 104 this.ohLineOpacity = a; 105 } 106 107 }); 108 109 Object.defineProperty(WPGMZA.ProShape.prototype, "layergroup", { 110 enumerable : true, 111 get: function() { 112 if(this._layergroup){ 113 return this._layergroup; 114 } 115 return 0; 116 }, 117 set: function(value) { 118 if(parseInt(value)){ 119 this._layergroup = parseInt(value) + WPGMZA.ProShape.BASE_LAYER_INDEX; 120 } 121 } 122 }); 123 124 Object.defineProperty(WPGMZA.ProShape.prototype, "lineStyle", { 125 enumerable : true, 126 get: function() { 127 if(this.linestyle && parseInt(this.linestyle)){ 128 return parseInt(this.linestyle); 129 } 130 return 0; 131 }, 132 set: function(value) { 133 if(parseInt(value)){ 134 this.linestyle = parseInt(value); 135 } 136 } 137 }); 138 139 WPGMZA.ProShape.prototype.onClick = function(event){ 140 if(!this.map || !this.map.settings){ 141 return; 142 } 143 144 if(this.map.settings.disable_polygon_info_windows){ 145 return; 146 } 147 148 if(!WPGMZA.settings.wpgmza_settings_map_open_marker_by || WPGMZA.settings.wpgmza_settings_map_open_marker_by != WPGMZA.InfoWindow.OPEN_BY_HOVER){ 149 this.openInfoWindow(); 150 } 151 } 152 153 WPGMZA.ProShape.prototype.onMouseOver = function(event){ 154 if(!this.map.settings.disable_polygon_info_windows){ 155 if(WPGMZA.settings.wpgmza_settings_map_open_marker_by && WPGMZA.settings.wpgmza_settings_map_open_marker_by == WPGMZA.InfoWindow.OPEN_BY_HOVER){ 156 this.openInfoWindow(); 157 } 158 } 159 160 if(!parseInt(this.hoverEnabled)){ 161 return; 162 } 163
164 this.revertOptions = this.getScalarProperties(); 165 166 var options = { 167 fillColor: this.hoverFillColor, 168 strokeColor: this.hoverStrokeColor, 169 fillOpacity: this.hoverFillOpacity, 170 strokeOpacity: this.hoverLineOpacity 171 }; 172 173 this.setOptions(options); 174 } 175 176 WPGMZA.ProShape.prototype.onMouseOut = function(event){ 177 if(!parseInt(this.hoverEnabled)){ 178 return; 179 } 180 181 var options = { 182 fillColor: this.fillColor, 183 strokeColor: this.strokeColor, 184 fillOpacity: this.fillOpacity, 185 strokeOpacity: this.strokeOpacity 186 }; 187 188 if(this.revertOptions){ 189 options = this.revertOptions; 190 this.revertOptions = false; 191 } 192 193 this.setOptions(options); 194 } 195 196 WPGMZA.ProShape.prototype.onAdded = function(){ 197 WPGMZA.Shape.prototype.onAdded.call(this, arguments); 198 199 if(this.layergroup){ 200 this.setLayergroup(this.layergroup); 201 } 202 203 if(this.lineStyle){ 204 this.setLineStyle(this.lineStyle); 205 } 206 } 207 208 WPGMZA.ProShape.prototype.openInfoWindow = function() { 209 if(!this.map) { 210 console.warn("Cannot open infowindow for shape with no map"); 211 return; 212 } 213 214 if(this.infoWindow){ 215 if(this.infoWindow.state && this.infoWindow.state === WPGMZA.InfoWindow.STATE_OPEN){ 216 return; 217 } 218 } 219 220 if(this.map.lastInteractedMarker){ 221 this.map.lastInteractedMarker.infoWindow.close(); 222 } 223 224 this.map.lastInteractedMarker = this; 225 226 this.initInfoWindow(); 227 228 this.title = this.name; 229 this.pic = ""; 230 this.infoWindow.open(this.map, this); 231 this.infoWindow.setPosition(this.getPosition()); 232 233 if(this.infoWindow.element && this.infoWindow.element.classList){ 234 this.infoWindow.element.classList.add('ol-info-window-shape'); 235 } 236 237 if(!this.infoWindow.getContent().length || !this.infoWindow.getContent().replace(/<[^>]*>/g, '').trim().length){ 238 this.infoWindow.close(); 239 } 240 } 241 242 WPGMZA.ProShape.prototype.initInfoWindow = function(){ 243 if(this.infoWindow){ 244 return; 245 } 246 247 this.infoWindow = WPGMZA.InfoWindow.createInstance(); 248 } 249 250 WPGMZA.ProShape.prototype.getPosition = function(){ 251 return this.position; 252 } 253 254 WPGMZA.ProShape.prototype.initShapeLabels = function(){ 255 if(WPGMZA.getMapByID(this.map_id)){ 256 var settings = WPGMZA.getMapByID(this.map_id).settings; 257 if(settings && settings.polygon_labels){ 258 if(this.name){ 259 var pos = this.getPosition(); 260 261 this.shapeLabel = WPGMZA.Text.createInstance({ 262 text: this.name, 263 map: WPGMZA.getMapByID(this.map_id), 264 position: new WPGMZA.LatLng(pos), 265 }); 266 } 267 } 268 } 269 } 270 271 WPGMZA.ProShape.prototype.setLayergroup = function(layergroup){ 272 this.layergroup = layergroup; 273 if(this.layergroup){ 274 this.setOptions({ 275 zIndex: this.layergroup 276 }); 277 } 278 } 279 280 WPGMZA.ProShape.prototype.setLineStyle = function(linestyle){ 281 this.lineStyle = linestyle; 282 switch(this.lineStyle){ 283 case WPGMZA.ProShape.LINE_STYLES.DASHED: 284 this.setOptions({ 285 lineDashArray : "8 16" 286 }); 287 break; 288 case WPGMZA.ProShape.LINE_STYLES.DOTTED: 289 this.setOptions({ 290 lineDashArray : "0 16" 291 }); 292 break; 293 case WPGMZA.ProShape.LINE_STYLES.SOLID: 294 default: 295 this.setOptions({ 296 lineDashArray : false 297 }); 298 break; 299 } 300 } 301});
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.