OpenLayers OpenLayers

Changeset 6658

Show
Ignore:
Timestamp:
03/28/08 04:47:47 (10 months ago)
Author:
euzuro
Message:

create dom notes for alternative relative views only when they are needed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/euzuro/pop/lib/OpenLayers/Popup/Framed.js

    r6651 r6658  
    110110        this.groupDiv.style.width = "100%"; 
    111111         
    112         this.createFrames()
     112        this.frames = {}
    113113    }, 
    114114 
     
    244244 
    245245    /** 
    246      * Method: createFrames 
    247      */ 
    248     createFrames: function() { 
    249  
    250         this.frames = {}; 
    251          
    252         for (var pos in this.positionBlocks) { 
    253  
    254             var fPosition = { 
    255                 'blocks': [] 
    256             }; 
    257             this.frames[pos] = fPosition; 
    258  
    259             fPosition.div = OpenLayers.Util.createDiv(pos + "-popup",  
    260                 null, null, null, 'relative' 
     246     * Method: createFrame 
     247     *  
     248     * Parameters: 
     249     * pos - {String} 
     250     *  
     251     * Returns: 
     252     * {Object} Frame entry, with blocks array 
     253     */ 
     254    createFrame: function(pos) { 
     255        var frame  = { 
     256            'blocks': [] 
     257        }; 
     258 
     259        frame.div = OpenLayers.Util.createDiv(pos + "-popup",  
     260            null, null, null, 'relative' 
     261        ); 
     262        frame.div.style.height = '100%'; 
     263        frame.div.style.width = '100%'; 
     264        this.groupDiv.appendChild(frame.div); 
     265 
     266        var position = this.positionBlocks[pos]; 
     267        for (var i = 0; i < position.blocks.length; i++) { 
     268 
     269            var fBlock = {}; 
     270            frame.blocks.push(fBlock); 
     271 
     272            var divId = this.id + '_FrameDecorationDiv_' + i; 
     273            fBlock.div = OpenLayers.Util.createDiv(divId,  
     274                null, null, null, "absolute", null, "hidden", null 
    261275            ); 
    262             fPosition.div.style.height = '100%'; 
    263             fPosition.div.style.width = '100%'; 
    264             this.groupDiv.appendChild(fPosition.div); 
    265  
    266             var position = this.positionBlocks[pos]; 
    267             for (var i = 0; i < position.blocks.length; i++) { 
    268      
    269                 var fBlock = {}; 
    270                 fPosition.blocks.push(fBlock); 
    271      
    272                 var divId = this.id + '_FrameDecorationDiv_' + i; 
    273                 fBlock.div = OpenLayers.Util.createDiv(divId,  
    274                     null, null, null, "absolute", null, "hidden", null 
    275                 ); 
    276      
    277                 var imgId = this.id + '_FrameDecorationImg_' + i; 
    278                 fBlock.image = OpenLayers.Util.createAlphaImageDiv(imgId,  
    279                     null, this.imageSize, this.imageSrc,  
    280                     "absolute", null, null, null 
    281                 ); 
    282      
    283                 fBlock.div.appendChild(fBlock.image); 
    284                 fPosition.div.appendChild(fBlock.div); 
    285             } 
    286         } 
     276 
     277            var imgId = this.id + '_FrameDecorationImg_' + i; 
     278            fBlock.image = OpenLayers.Util.createAlphaImageDiv(imgId,  
     279                null, this.imageSize, this.imageSrc,  
     280                "absolute", null, null, null 
     281            ); 
     282 
     283            fBlock.div.appendChild(fBlock.image); 
     284            frame.div.appendChild(fBlock.div); 
     285        } 
     286         
     287        return frame; 
    287288    }, 
    288289     
     
    297298        for (var pos in this.positionBlocks) { 
    298299            var position = this.positionBlocks[pos]; 
    299             var fPosition = this.frames[pos]; 
     300            var frame = this.frames[pos]; 
    300301 
    301302            if (pos != this.relativePosition) { 
    302                 OpenLayers.Element.hide(fPosition.div); 
     303                if (frame) { 
     304                    OpenLayers.Element.hide(frame.div); 
     305                } 
    303306            } else { 
    304                 OpenLayers.Element.show(fPosition.div); 
     307                if (!frame) { 
     308                    frame = this.frames[pos] = this.createFrame(pos); 
     309                } 
     310                OpenLayers.Element.show(frame.div); 
    305311                 
    306312                for (var i = 0; i < position.blocks.length; i++) { 
    307313     
    308314                    var block = position.blocks[i]; 
    309                     var fBlock = fPosition.blocks[i]; 
     315                    var fBlock = frame.blocks[i]; 
    310316     
    311317                    // adjust sizes