OpenLayers OpenLayers

Changeset 7461

Show
Ignore:
Timestamp:
07/01/08 15:45:10 (5 months ago)
Author:
tschaub
Message:

merge r7368:HEAD from behavior sandbox

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/topp/almanac/lib/OpenLayers.js

    r7399 r7461  
    196196            "OpenLayers/Strategy/GreedySave.js", 
    197197            "OpenLayers/Strategy/Autosave.js", 
     198            "OpenLayers/Strategy/Cluster.js", 
    198199            "OpenLayers/Strategy/Paging.js", 
    199200            "OpenLayers/Protocol.js", 
  • sandbox/topp/almanac/lib/OpenLayers/Layer/Vector.js

    r7412 r7461  
    393393        var notify = !options || !options.silent; 
    394394        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); 
    398397            if(ret === false) { 
    399398                return; 
    400399            } 
     400            features = event.features; 
    401401        } 
    402402         
  • sandbox/topp/almanac/lib/OpenLayers/Strategy/Paging.js

    r7420 r7461  
    1212     
    1313    /** 
    14      * Property: cache 
     14     * Property: features 
    1515     * {Array(<OpenLayers.Feature.Vector>)} Cached features. 
    1616     */ 
    17     cache: null, 
     17    features: null, 
    1818     
    1919    /** 
     
    6464     */ 
    6565    deactivate: function() { 
    66         delete this.layer.page; 
    6766        this.clearCache(); 
    6867        this.layer.events.un({ 
     
    7574     * Method: cacheFeatures 
    7675     * Cache features before they are added to the layer. 
    77      * 
    78      * Returns: 
    79      * {Boolean} False to stop layer from being added to the layer. 
    8076     */ 
    8177    cacheFeatures: function(event) { 
    82         var propigate = true; 
    8378        if(!this.paging) { 
    8479            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        } 
    9083    }, 
    9184     
     
    9689     */ 
    9790    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; 
    10497        this.num = null; 
    10598    }, 
     
    113106     */ 
    114107    pageCount: function() { 
    115         var numFeatures = this.cache ? this.cache.length : 0; 
     108        var numFeatures = this.features ? this.features.length : 0; 
    116109        return Math.ceil(numFeatures / this.length); 
    117110    }, 
     
    152145     * {Boolean} A new page was displayed. 
    153146     */ 
    154     pageNext: function() { 
     147    pageNext: function(event) { 
    155148        var changed = false; 
    156         if(this.cache) { 
     149        if(this.features) { 
    157150            if(this.num === null) { 
    158151                this.num = -1; 
    159152            } 
    160153            var start = (this.num + 1) * this.length; 
    161             changed = this.page(start); 
     154            changed = this.page(start, event); 
    162155        } 
    163156        return changed; 
     
    173166    pagePrevious: function() { 
    174167        var changed = false; 
    175         if(this.cache) { 
     168        if(this.features) { 
    176169            if(this.num === null) { 
    177170                this.num = this.pageCount(); 
     
    190183     * {Boolean} A new page was displayed. 
    191184     */ 
    192     page: function(start) { 
     185    page: function(start, event) { 
    193186        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) { 
    196189                var num = Math.floor(start / this.length); 
    197190                if(num != this.num) { 
    198191                    this.paging = true; 
    199                     var features = this.cache.slice(start, start + this.length); 
     192                    var features = this.features.slice(start, start + this.length); 
    200193                    this.layer.removeFeatures(this.layer.features); 
    201                     this.layer.addFeatures(features, {silent: true}); 
    202194                    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                    } 
    208203                    this.paging = false; 
    209204                    changed = true;