FramedCloud.js 8.3 KB

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