Changeset 7461
- Timestamp:
- 07/01/08 15:45:10 (5 months ago)
- Files:
-
- sandbox/topp/almanac/OpenLayers.js (copied) (copied from sandbox/vector-behavior/OpenLayers.js)
- sandbox/topp/almanac/examples/animator.js (copied) (copied from sandbox/vector-behavior/examples/animator.js)
- sandbox/topp/almanac/examples/strategy-cluster.html (copied) (copied from sandbox/vector-behavior/examples/strategy-cluster.html)
- sandbox/topp/almanac/examples/strategy-paging.html (copied) (copied from sandbox/vector-behavior/examples/strategy-paging.html)
- sandbox/topp/almanac/lib/OpenLayers.js (modified) (1 diff)
- sandbox/topp/almanac/lib/OpenLayers/Layer/Vector.js (modified) (1 diff)
- sandbox/topp/almanac/lib/OpenLayers/Strategy/Cluster.js (copied) (copied from sandbox/vector-behavior/lib/OpenLayers/Strategy/Cluster.js)
- sandbox/topp/almanac/lib/OpenLayers/Strategy/Paging.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/topp/almanac/lib/OpenLayers.js
r7399 r7461 196 196 "OpenLayers/Strategy/GreedySave.js", 197 197 "OpenLayers/Strategy/Autosave.js", 198 "OpenLayers/Strategy/Cluster.js", 198 199 "OpenLayers/Strategy/Paging.js", 199 200 "OpenLayers/Protocol.js", sandbox/topp/almanac/lib/OpenLayers/Layer/Vector.js
r7412 r7461 393 393 var notify = !options || !options.silent; 394 394 if(notify) { 395 var ret = this.events.triggerEvent("beforefeaturesadded", { 396 features: features} 397 ); 395 var event = {features: features}; 396 var ret = this.events.triggerEvent("beforefeaturesadded", event); 398 397 if(ret === false) { 399 398 return; 400 399 } 400 features = event.features; 401 401 } 402 402 sandbox/topp/almanac/lib/OpenLayers/Strategy/Paging.js
r7420 r7461 12 12 13 13 /** 14 * Property: cache14 * Property: features 15 15 * {Array(<OpenLayers.Feature.Vector>)} Cached features. 16 16 */ 17 cache: null,17 features: null, 18 18 19 19 /** … … 64 64 */ 65 65 deactivate: function() { 66 delete this.layer.page;67 66 this.clearCache(); 68 67 this.layer.events.un({ … … 75 74 * Method: cacheFeatures 76 75 * Cache features before they are added to the layer. 77 *78 * Returns:79 * {Boolean} False to stop layer from being added to the layer.80 76 */ 81 77 cacheFeatures: function(event) { 82 var propigate = true;83 78 if(!this.paging) { 84 79 this.clearCache(); 85 this.cache = event.features; 86 this.pageNext(); 87 propigate = false; 88 } 89 return propigate; 80 this.features = event.features; 81 this.pageNext(event); 82 } 90 83 }, 91 84 … … 96 89 */ 97 90 clearCache: function() { 98 if(this. cache) {99 for(var i=0; i<this. cache.length; ++i) {100 this. cache[i].destroy();101 } 102 } 103 this. cache= null;91 if(this.features) { 92 for(var i=0; i<this.features.length; ++i) { 93 this.features[i].destroy(); 94 } 95 } 96 this.features = null; 104 97 this.num = null; 105 98 }, … … 113 106 */ 114 107 pageCount: function() { 115 var numFeatures = this. cache ? this.cache.length : 0;108 var numFeatures = this.features ? this.features.length : 0; 116 109 return Math.ceil(numFeatures / this.length); 117 110 }, … … 152 145 * {Boolean} A new page was displayed. 153 146 */ 154 pageNext: function( ) {147 pageNext: function(event) { 155 148 var changed = false; 156 if(this. cache) {149 if(this.features) { 157 150 if(this.num === null) { 158 151 this.num = -1; 159 152 } 160 153 var start = (this.num + 1) * this.length; 161 changed = this.page(start );154 changed = this.page(start, event); 162 155 } 163 156 return changed; … … 173 166 pagePrevious: function() { 174 167 var changed = false; 175 if(this. cache) {168 if(this.features) { 176 169 if(this.num === null) { 177 170 this.num = this.pageCount(); … … 190 183 * {Boolean} A new page was displayed. 191 184 */ 192 page: function(start ) {185 page: function(start, event) { 193 186 var changed = false; 194 if(this. cache) {195 if(start >= 0 && start < this. cache.length) {187 if(this.features) { 188 if(start >= 0 && start < this.features.length) { 196 189 var num = Math.floor(start / this.length); 197 190 if(num != this.num) { 198 191 this.paging = true; 199 var features = this. cache.slice(start, start + this.length);192 var features = this.features.slice(start, start + this.length); 200 193 this.layer.removeFeatures(this.layer.features); 201 this.layer.addFeatures(features, {silent: true});202 194 this.num = num; 203 this.layer.events.triggerEvent("featuresadded", { 204 features: features, 205 pageNum: this.num, 206 pageCount: this.pageCount() 207 }); 195 // modify the event if any 196 if(event && event.features) { 197 // this.was called by an event listener 198 event.features = features; 199 } else { 200 // this was called directly on the strategy 201 this.layer.addFeatures(features); 202 } 208 203 this.paging = false; 209 204 changed = true;
