]> dev.renevier.net Git - syp.git/blob - openlayers/lib/OpenLayers/Popup/FramedCloud.js
initial commit
[syp.git] / openlayers / lib / OpenLayers / Popup / FramedCloud.js
1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2  * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3  * full text of the license. */
4
5 /**
6  * @requires OpenLayers/Popup/Framed.js
7  * @requires OpenLayers/Util.js
8  */
9
10 /**
11  * Class: OpenLayers.Popup.FramedCloud
12  * 
13  * Inherits from: 
14  *  - <OpenLayers.Popup.Framed>
15  */
16 OpenLayers.Popup.FramedCloud = 
17   OpenLayers.Class(OpenLayers.Popup.Framed, {
18
19     /** 
20      * Property: contentDisplayClass
21      * {String} The CSS class of the popup content div.
22      */
23     contentDisplayClass: "olFramedCloudPopupContent",
24
25     /**
26      * APIProperty: autoSize
27      * {Boolean} Framed Cloud is autosizing by default.
28      */
29     autoSize: true,
30
31     /**
32      * APIProperty: panMapIfOutOfView
33      * {Boolean} Framed Cloud does pan into view by default.
34      */
35     panMapIfOutOfView: true,
36
37     /**
38      * APIProperty: imageSize
39      * {<OpenLayers.Size>}
40      */
41     imageSize: new OpenLayers.Size(676, 736),
42
43     /**
44      * APIProperty: isAlphaImage
45      * {Boolean} The FramedCloud does not use an alpha image (in honor of the 
46      *     good ie6 folk out there)
47      */
48     isAlphaImage: false,
49
50     /** 
51      * APIProperty: fixedRelativePosition
52      * {Boolean} The Framed Cloud popup works in just one fixed position.
53      */
54     fixedRelativePosition: false,
55
56     /**
57      * Property: positionBlocks
58      * {Object} Hash of differen position blocks, keyed by relativePosition
59      *     two-character code string (ie "tl", "tr", "bl", "br")
60      */
61     positionBlocks: {
62         "tl": {
63             'offset': new OpenLayers.Pixel(44, 0),
64             'padding': new OpenLayers.Bounds(8, 40, 8, 9),
65             'blocks': [
66                 { // top-left
67                     size: new OpenLayers.Size('auto', 'auto'),
68                     anchor: new OpenLayers.Bounds(0, 51, 22, 0),
69                     position: new OpenLayers.Pixel(0, 0)
70                 },
71                 { //top-right
72                     size: new OpenLayers.Size(22, 'auto'),
73                     anchor: new OpenLayers.Bounds(null, 50, 0, 0),
74                     position: new OpenLayers.Pixel(-638, 0)
75                 },
76                 { //bottom-left
77                     size: new OpenLayers.Size('auto', 19),
78                     anchor: new OpenLayers.Bounds(0, 32, 22, null),
79                     position: new OpenLayers.Pixel(0, -631)
80                 },
81                 { //bottom-right
82                     size: new OpenLayers.Size(22, 18),
83                     anchor: new OpenLayers.Bounds(null, 32, 0, null),
84                     position: new OpenLayers.Pixel(-638, -632)
85                 },
86                 { // stem
87                     size: new OpenLayers.Size(81, 35),
88                     anchor: new OpenLayers.Bounds(null, 0, 0, null),
89                     position: new OpenLayers.Pixel(0, -688)
90                 }
91             ]
92         },
93         "tr": {
94             'offset': new OpenLayers.Pixel(-45, 0),
95             'padding': new OpenLayers.Bounds(8, 40, 8, 9),
96             'blocks': [
97                 { // top-left
98                     size: new OpenLayers.Size('auto', 'auto'),
99                     anchor: new OpenLayers.Bounds(0, 51, 22, 0),
100                     position: new OpenLayers.Pixel(0, 0)
101                 },
102                 { //top-right
103                     size: new OpenLayers.Size(22, 'auto'),
104                     anchor: new OpenLayers.Bounds(null, 50, 0, 0),
105                     position: new OpenLayers.Pixel(-638, 0)
106                 },
107                 { //bottom-left
108                     size: new OpenLayers.Size('auto', 19),
109                     anchor: new OpenLayers.Bounds(0, 32, 22, null),
110                     position: new OpenLayers.Pixel(0, -631)
111                 },
112                 { //bottom-right
113                     size: new OpenLayers.Size(22, 19),
114                     anchor: new OpenLayers.Bounds(null, 32, 0, null),
115                     position: new OpenLayers.Pixel(-638, -631)
116                 },
117                 { // stem
118                     size: new OpenLayers.Size(81, 35),
119                     anchor: new OpenLayers.Bounds(0, 0, null, null),
120                     position: new OpenLayers.Pixel(-215, -687)
121                 }
122             ]
123         },
124         "bl": {
125             'offset': new OpenLayers.Pixel(45, 0),
126             'padding': new OpenLayers.Bounds(8, 9, 8, 40),
127             'blocks': [
128                 { // top-left
129                     size: new OpenLayers.Size('auto', 'auto'),
130                     anchor: new OpenLayers.Bounds(0, 21, 22, 32),
131                     position: new OpenLayers.Pixel(0, 0)
132                 },
133                 { //top-right
134                     size: new OpenLayers.Size(22, 'auto'),
135                     anchor: new OpenLayers.Bounds(null, 21, 0, 32),
136                     position: new OpenLayers.Pixel(-638, 0)
137                 },
138                 { //bottom-left
139                     size: new OpenLayers.Size('auto', 21),
140                     anchor: new OpenLayers.Bounds(0, 0, 22, null),
141                     position: new OpenLayers.Pixel(0, -629)
142                 },
143                 { //bottom-right
144                     size: new OpenLayers.Size(22, 21),
145                     anchor: new OpenLayers.Bounds(null, 0, 0, null),
146                     position: new OpenLayers.Pixel(-638, -629)
147                 },
148                 { // stem
149                     size: new OpenLayers.Size(81, 33),
150                     anchor: new OpenLayers.Bounds(null, null, 0, 0),
151                     position: new OpenLayers.Pixel(-101, -674)
152                 }
153             ]
154         },
155         "br": {
156             'offset': new OpenLayers.Pixel(-44, 0),
157             'padding': new OpenLayers.Bounds(8, 9, 8, 40),
158             'blocks': [
159                 { // top-left
160                     size: new OpenLayers.Size('auto', 'auto'),
161                     anchor: new OpenLayers.Bounds(0, 21, 22, 32),
162                     position: new OpenLayers.Pixel(0, 0)
163                 },
164                 { //top-right
165                     size: new OpenLayers.Size(22, 'auto'),
166                     anchor: new OpenLayers.Bounds(null, 21, 0, 32),
167                     position: new OpenLayers.Pixel(-638, 0)
168                 },
169                 { //bottom-left
170                     size: new OpenLayers.Size('auto', 21),
171                     anchor: new OpenLayers.Bounds(0, 0, 22, null),
172                     position: new OpenLayers.Pixel(0, -629)
173                 },
174                 { //bottom-right
175                     size: new OpenLayers.Size(22, 21),
176                     anchor: new OpenLayers.Bounds(null, 0, 0, null),
177                     position: new OpenLayers.Pixel(-638, -629)
178                 },
179                 { // stem
180                     size: new OpenLayers.Size(81, 33),
181                     anchor: new OpenLayers.Bounds(0, null, null, 0),
182                     position: new OpenLayers.Pixel(-311, -674)
183                 }
184             ]
185         }
186     },
187
188     /**
189      * APIProperty: minSize
190      * {<OpenLayers.Size>}
191      */
192     minSize: new OpenLayers.Size(105, 10),
193
194     /**
195      * APIProperty: maxSize
196      * {<OpenLayers.Size>}
197      */
198     maxSize: new OpenLayers.Size(600, 660),
199
200     /** 
201      * Constructor: OpenLayers.Popup.FramedCloud
202      * 
203      * Parameters:
204      * id - {String}
205      * lonlat - {<OpenLayers.LonLat>}
206      * contentSize - {<OpenLayers.Size>}
207      * contentHTML - {String}
208      * anchor - {Object} Object to which we'll anchor the popup. Must expose 
209      *     a 'size' (<OpenLayers.Size>) and 'offset' (<OpenLayers.Pixel>) 
210      *     (Note that this is generally an <OpenLayers.Icon>).
211      * closeBox - {Boolean}
212      * closeBoxCallback - {Function} Function to be called on closeBox click.
213      */
214     initialize:function(id, lonlat, contentSize, contentHTML, anchor, closeBox, 
215                         closeBoxCallback) {
216
217         this.imageSrc = OpenLayers.Util.getImagesLocation() + 'cloud-popup-relative.png';
218         OpenLayers.Popup.Framed.prototype.initialize.apply(this, arguments);
219         this.contentDiv.className = this.contentDisplayClass;
220     },
221
222     /** 
223      * APIMethod: destroy
224      */
225     destroy: function() {
226         OpenLayers.Popup.Framed.prototype.destroy.apply(this, arguments);
227     },
228
229     CLASS_NAME: "OpenLayers.Popup.FramedCloud"
230 });