OpenLayers OpenLayers

Changeset 333

Show
Ignore:
Timestamp:
05/24/06 19:14:34 (3 years ago)
Author:
euzuro
Message:

adding skeleton for anchored popup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Popup/Anchored.js

    r326 r333  
    44* @class 
    55*/ 
    6 OpenLayers.Popup = Class.create(); 
    7  
    8 OpenLayers.Popup.count = 0; 
    9 OpenLayers.Popup.SIZE = new OpenLayers.Size(200, 200); 
    10 OpenLayers.Popup.COLOR = "white"; 
    11 OpenLayers.Popup.OPACITY = 1; 
    12 OpenLayers.Popup.BORDER = "0px"; 
    13  
    14 OpenLayers.Popup.prototype = { 
    15  
    16     /** @type String */ 
    17     id: "", 
    18  
    19     /** reference to the parent DIV to which this popup is @type DOMElement */ 
    20     parent: null, 
    21  
    22     /** @type OpenLayers.LonLat */ 
    23     lonlat: null, 
    24  
    25     /** @type DOMElement */ 
    26     div: null, 
    27  
    28     /** @type OpenLayers.Size*/ 
    29     size: null,     
    30  
    31     /** @type String */ 
    32     contentHTML: "", 
    33      
    34     /** @type String */ 
    35     backgroundColor: "", 
    36      
    37     /** @type float */ 
    38     opacity: "", 
    39  
    40     /** @type String */ 
    41     border: "", 
    42  
     6OpenLayers.Popup.Anchored = Class.create(); 
     7OpenLayers.Popup.Anchored.prototype = 
     8   Object.extend( new OpenLayers.Popup(), { 
    439 
    4410    /**  
     
    5117    */ 
    5218    initialize:function(id, lonlat, size, contentHTML) { 
    53         OpenLayers.Popup.count += 1; 
    54         this.id = (id != null) ? id : "Popup" + OpenLayers.Popup.count; 
    55         this.lonlat = lonlat; 
    56         this.size = (size != null) ? size : OpenLayers.Popup.SIZE; 
    57         if (contentHTML != null) {  
    58              this.contentHTML = contentHTML; 
    59         } 
    60         this.backgroundColor = OpenLayers.Popup.COLOR; 
    61         this.opacity = OpenLayers.Popup.OPACITY; 
    62         this.border = OpenLayers.Popup.BORDER; 
     19        OpenLayers.Popup.prototype.initialize.apply(this, arguments); 
    6320    }, 
    6421 
     
    6623    */ 
    6724    destroy: function() { 
    68         if ((this.div) && (this.div.parentNode)) { 
    69             this.div.parentNode.removeChild(this.div); 
    70         } 
    71         this.div = null; 
     25        OpenLayers.Popup.prototype.destroy.apply(this, arguments); 
    7226    }, 
    7327 
    7428    /**  
    7529    * @param {OpenLayers.Pixel} px 
     30    *  
     31    * @returns Reference to a div that contains the drawn popup 
     32    * @type DOMElement 
    7633    */ 
    7734    draw: function(px) { 
    78         if (this.div == null) { 
    79             this.div = OpenLayers.Util.createDiv(this.id + "_div", 
    80                                                   null, 
    81                                                   null, 
    82                                                   "hidden"); 
    83         } 
    84         this.setSize(); 
    85         this.setBackgroundColor(); 
    86         this.setOpacity(); 
    87         this.setBorder(); 
    88         this.setContentHTML(); 
    89         this.moveTo(px); 
    90  
    91         return this.div; 
     35        OpenLayers.Popup.prototype.draw.apply(this, arguments); 
    9236    }, 
    9337 
     
    9640    */ 
    9741    moveTo: function(px) { 
    98         if ((px != null) && (this.div != null)) { 
    99             this.div.style.left = px.x + "px"; 
    100             this.div.style.top = px.y + "px"; 
    101         } 
     42        OpenLayers.Popup.prototype.moveTo.apply(this, arguments); 
    10243    }, 
    10344 
    104     /** 
    105     * @param {OpenLayers.Size} size 
    106     */ 
    107     setSize:function(size) {  
    108         if (size != undefined) { 
    109             this.size = size;  
    110         } 
    111          
    112         if (this.div != null) { 
    113             this.div.style.width = this.size.w; 
    114             this.div.style.height = this.size.h; 
    115         }        
    116     },   
    117  
    118     /** 
    119     * @param {String} color 
    120     */ 
    121     setBackgroundColor:function(color) {  
    122         if (color != undefined) { 
    123             this.backgroundColor = color;  
    124         } 
    125          
    126         if (this.div != null) { 
    127             this.div.style.backgroundColor = this.backgroundColor; 
    128         }        
    129     },   
    130      
    131     /** 
    132     * @param {float} opacity 
    133     */ 
    134     setOpacity:function(opacity) {  
    135         if (opacity != undefined) { 
    136             this.opacity = opacity;  
    137         } 
    138          
    139         if (this.div != null) { 
    140             // for Mozilla and Safari 
    141             this.div.style.opacity = this.opacity; 
    142  
    143             // for IE 
    144             this.div.style.filter = 'alpha(opacity=' + this.opacity*100 + ')'; 
    145         }        
    146     },   
    147      
    148     /** 
    149     * @param {int} border 
    150     */ 
    151     setBorder:function(border) {  
    152         if (border != undefined) { 
    153             this.border = border; 
    154         } 
    155          
    156         if (this.div != null) { 
    157             this.div.style.border = this.border; 
    158         } 
    159     },       
    160      
    161     /** 
    162     * @param {String} contentHTML 
    163     */ 
    164     setContentHTML:function(contentHTML) { 
    165         if (contentHTML != null) { 
    166             this.contentHTML = contentHTML; 
    167         } 
    168          
    169         if (this.div != null) { 
    170             this.div.innerHTML = this.contentHTML; 
    171         }     
    172     }, 
    173  
    174     CLASS_NAME: "OpenLayers.Popup" 
    175 }; 
     45    CLASS_NAME: "OpenLayers.Popup.Anchored" 
     46});