Changeset 8091
- Timestamp:
- 10/04/08 16:13:28 (2 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Icon.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Markers.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Marker.js (modified) (1 diff)
- trunk/openlayers/tests/Icon.html (modified) (1 diff)
- trunk/openlayers/tests/Layer/Markers.html (modified) (1 diff)
- trunk/openlayers/tests/Marker.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Icon.js
r6251 r8091 194 194 this.imageDiv.style.display = (display) ? "" : "none"; 195 195 }, 196 197 198 /** 199 * APIMethod: isDrawn 200 * 201 * Returns: 202 * {Boolean} Whether or not the icon is drawn. 203 */ 204 isDrawn: function() { 205 // nodeType 11 for ie, whose nodes *always* have a parentNode 206 // (of type document fragment) 207 var isDrawn = (this.imageDiv && this.imageDiv.parentNode && 208 (this.imageDiv.parentNode.nodeType != 11)); 209 210 return isDrawn; 211 }, 196 212 197 213 CLASS_NAME: "OpenLayers.Icon" trunk/openlayers/lib/OpenLayers/Layer/Markers.js
r7627 r8091 126 126 (marker.icon.imageDiv.parentNode == this.div) ) { 127 127 this.div.removeChild(marker.icon.imageDiv); 128 marker.drawn = false;129 128 } 130 129 } … … 157 156 marker.display(false); 158 157 } else { 159 var markerImg = marker.draw(px);160 if (!marker.drawn) {158 if (!marker.isDrawn()) { 159 var markerImg = marker.draw(px); 161 160 this.div.appendChild(markerImg); 162 marker.drawn = true;163 161 } 164 162 } trunk/openlayers/lib/OpenLayers/Marker.js
r7138 r8091 131 131 132 132 /** 133 * APIMethod: isDrawn 134 * 135 * Returns: 136 * {Boolean} Whether or not the marker is drawn. 137 */ 138 isDrawn: function() { 139 var isDrawn = (this.icon && this.icon.isDrawn()); 140 return isDrawn; 141 }, 142 143 /** 133 144 * Method: onScreen 134 145 * trunk/openlayers/tests/Icon.html
r8088 r8091 34 34 t.eq(parseFloat(icon.imageDiv.style.opacity), 0.5, "icon.setOpacity() works"); 35 35 } 36 37 function test_Icon_isDrawn(t) { 38 t.plan(4); 39 40 var icon = {}; 41 42 //no imageDiv 43 var drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []); 44 t.ok(!drawn, "icon with no imageDiv not drawn"); 45 46 //imageDiv no parentNode 47 icon.imageDiv = {}; 48 drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []); 49 t.ok(!drawn, "icon with imageDiv with no parentNode not drawn"); 50 51 //imageDiv with parent 52 icon.imageDiv.parentNode = {}; 53 drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []); 54 t.ok(drawn, "icon with imageDiv with parentNode drawn"); 55 56 //imageDiv with parent but nodetype 11 57 icon.imageDiv.parentNode = {'nodeType': 11}; 58 drawn = OpenLayers.Icon.prototype.isDrawn.apply(icon, []); 59 t.ok(!drawn, "imageDiv with parent but nodetype 11 not drawn"); 60 } 61 36 62 37 63 trunk/openlayers/tests/Layer/Markers.html
r6724 r8091 47 47 48 48 } 49 49 50 function test_Layer_Markers_destroy (t) { 50 51 t.plan( 1 ); trunk/openlayers/tests/Marker.html
r6724 r8091 135 135 map.destroy(); 136 136 } 137 138 function test_Marker_isDrawn(t) { 139 t.plan(3); 140 141 var marker = {}; 142 143 //no icon 144 var drawn = OpenLayers.Marker.prototype.isDrawn.apply(marker, []); 145 t.ok(!drawn, "marker with no icon not drawn"); 146 147 //not drawn icon 148 marker.icon = { isDrawn: function() { return false; } }; 149 drawn = OpenLayers.Marker.prototype.isDrawn.apply(marker, []); 150 t.ok(!drawn, "marker with not drawn icon not drawn"); 151 152 //drawn icon 153 marker.icon.isDrawn = function() { return true; }; 154 drawn = OpenLayers.Marker.prototype.isDrawn.apply(marker, []); 155 t.ok(drawn, "marker with drawn icon drawn"); 156 } 137 157 138 158 </script>
