Changeset 3545
- Timestamp:
- 06/29/07 11:59:20 (1 year ago)
- Files:
-
- trunk/openlayers/apidoc_config (copied) (copied from sandbox/tschaub/naturaldocs/apidoc_config)
- trunk/openlayers/apidoc_config/Languages.txt (copied) (copied from sandbox/tschaub/naturaldocs/apidoc_config/Languages.txt)
- trunk/openlayers/apidoc_config/Menu.txt (copied) (copied from sandbox/tschaub/naturaldocs/apidoc_config/Menu.txt)
- trunk/openlayers/apidoc_config/OL.css (copied) (copied from sandbox/tschaub/naturaldocs/apidoc_config/OL.css)
- trunk/openlayers/apidoc_config/Topics.txt (copied) (copied from sandbox/tschaub/naturaldocs/apidoc_config/Topics.txt)
- trunk/openlayers/doc (copied) (copied from sandbox/tschaub/naturaldocs/doc)
- trunk/openlayers/doc/authors.txt (copied) (copied from sandbox/tschaub/naturaldocs/doc/authors.txt)
- trunk/openlayers/doc/customization (copied) (copied from sandbox/tschaub/naturaldocs/doc/customization)
- trunk/openlayers/doc/readme.txt (copied) (copied from sandbox/tschaub/naturaldocs/doc/readme.txt)
- trunk/openlayers/doc_config (copied) (copied from sandbox/tschaub/naturaldocs/doc_config)
- trunk/openlayers/doc_config/Languages.txt (copied) (copied from sandbox/tschaub/naturaldocs/doc_config/Languages.txt)
- trunk/openlayers/doc_config/Menu.txt (copied) (copied from sandbox/tschaub/naturaldocs/doc_config/Menu.txt)
- trunk/openlayers/doc_config/OL.css (copied) (copied from sandbox/tschaub/naturaldocs/doc_config/OL.css)
- trunk/openlayers/doc_config/Topics.txt (copied) (copied from sandbox/tschaub/naturaldocs/doc_config/Topics.txt)
- trunk/openlayers/lib/OpenLayers.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Ajax.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/BaseTypes.js (modified) (52 diffs)
- trunk/openlayers/lib/OpenLayers/Console.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Control.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Control/ArgParser.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Control/DragPan.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/DrawFeature.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/EditingToolbar.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/KeyboardDefaults.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js (modified) (18 diffs)
- trunk/openlayers/lib/OpenLayers/Control/MouseDefaults.js (modified) (16 diffs)
- trunk/openlayers/lib/OpenLayers/Control/MousePosition.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Control/MouseToolbar.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Control/NavToolbar.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/Navigation.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js (modified) (26 diffs)
- trunk/openlayers/lib/OpenLayers/Control/PanZoom.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js (modified) (13 diffs)
- trunk/openlayers/lib/OpenLayers/Control/Panel.js (modified) (10 diffs)
- trunk/openlayers/lib/OpenLayers/Control/Permalink.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Control/Scale.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Control/ZoomBox.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/ZoomToMaxExtent.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Events.js (modified) (20 diffs)
- trunk/openlayers/lib/OpenLayers/Feature.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Feature/Vector.js (modified) (12 diffs)
- trunk/openlayers/lib/OpenLayers/Feature/WFS.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Format.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Format/GML.js (modified) (10 diffs)
- trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Format/KML.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Format/WFS.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Format/WKT.js (modified) (16 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry.js (modified) (12 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/Collection.js (modified) (16 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/Curve.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/LineString.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/LinearRing.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/MultiLineString.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/MultiPoint.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/MultiPolygon.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/Point.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/Polygon.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/Rectangle.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Geometry/Surface.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Handler.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Box.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Drag.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Feature.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Keyboard.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/MouseWheel.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Path.js (modified) (14 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Point.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Handler/Polygon.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Icon.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (24 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Boxes.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/EventPane.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/FixedZoomLevels.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/GML.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Google.js (modified) (23 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/HTTPRequest.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Image.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/KaMap.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/MapServer.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/MapServer/Untiled.js (modified) (11 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Markers.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/MultiMap.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/TMS.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Text.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Vector.js (modified) (19 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/VirtualEarth.js (modified) (15 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WFS.js (modified) (13 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WMS.js (modified) (9 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WMS/Untiled.js (modified) (13 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WorldWind.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Yahoo.js (modified) (19 diffs)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (57 diffs)
- trunk/openlayers/lib/OpenLayers/Marker.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Marker/Box.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Popup.js (modified) (22 diffs)
- trunk/openlayers/lib/OpenLayers/Popup/Anchored.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js (modified) (10 diffs)
- trunk/openlayers/lib/OpenLayers/Renderer.js (modified) (12 diffs)
- trunk/openlayers/lib/OpenLayers/Renderer/Elements.js (modified) (11 diffs)
- trunk/openlayers/lib/OpenLayers/Renderer/SVG.js (modified) (19 diffs)
- trunk/openlayers/lib/OpenLayers/Renderer/VML.js (modified) (24 diffs)
- trunk/openlayers/lib/OpenLayers/SingleFile.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Tile.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Tile/Image.js (modified) (11 diffs)
- trunk/openlayers/lib/OpenLayers/Tile/WFS.js (modified) (11 diffs)
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (38 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers.js
r3543 r3545 7 7 */ 8 8 9 ////10 /// This blob sucks in all the files in uncompressed form for ease of use11 ///12 9 (function() { 13 10 /** … … 18 15 */ 19 16 var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile); 17 20 18 /** 19 * Namespace: OpenLayers 21 20 * The OpenLayers object provides a namespace for all things OpenLayers 22 * @type Object23 21 */ 24 22 OpenLayers = { 25 23 26 24 /** 27 * @type String28 * @private25 * Property: _scriptName 26 * {String} Relative path of this script. 29 27 */ 30 28 _scriptName: (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js", 31 29 32 30 /** 33 * @type String 34 * @returns Path to this script 35 * @private 31 * Function: _getScriptLocation 32 * Return the path to this script. 33 * 34 * Return: 35 * Path to this script 36 36 */ 37 37 _getScriptLocation: function () { … … 185 185 } 186 186 })(); 187 188 /** 189 * Constant: VERSION_NUMBER 190 */ 187 191 OpenLayers.VERSION_NUMBER="$Revision$"; trunk/openlayers/lib/OpenLayers/Ajax.js
r3347 r3545 38 38 }; 39 39 40 /** Background load a document 41 * 42 * @param {String} uri URI of source doc 43 * @param {String} params Params on get (doesnt seem to work) 44 * @param {Object} caller object which gets callbacks 45 * @param {Function} onComplete callback for success 46 * @param {Function} onFailure callback for failure 47 * 48 * Both callbacks optional (though silly) 49 */ 40 /** 41 * Function: loadURL 42 * Background load a document. 43 * 44 * Parameters: 45 * uri - {String} URI of source doc 46 * params - {String} Params on get (doesnt seem to work) 47 * caller - {Object} object which gets callbacks 48 * onComplete - {Function} callback for success 49 * onFailure - {Function} callback for failure 50 * 51 * Both callbacks optional (though silly) 52 */ 50 53 OpenLayers.loadURL = function(uri, params, caller, 51 54 onComplete, onFailure) { … … 71 74 }; 72 75 73 /** Parse XML into a doc structure 74 * @param {String} text 75 * 76 * @returns Parsed Ajax Response ?? 77 * @type ? 78 */ 76 /** 77 * Function: parseXMLString 78 * Parse XML into a doc structure 79 * 80 * Parameters: 81 * text - {String} 82 * 83 * Return: 84 * {?} Parsed AJAX Responsev 85 */ 79 86 OpenLayers.parseXMLString = function(text) { 80 87 … … 109 116 }; 110 117 118 119 /** 120 * Namespace: OpenLayers.Ajax 121 */ 111 122 OpenLayers.Ajax = { 112 emptyFunction: function () {}, 113 114 getTransport: function() { 115 return OpenLayers.Util.Try( 116 function() {return new ActiveXObject('Msxml2.XMLHTTP')}, 117 function() {return new ActiveXObject('Microsoft.XMLHTTP')}, 118 function() {return new XMLHttpRequest()} 119 ) || false; 120 }, 121 122 activeRequestCount: 0 123 }; 124 123 124 /** 125 * Method: emptyFunction 126 */ 127 emptyFunction: function () {}, 128 129 /** 130 * Method: getTransport 131 * 132 * Return: 133 * {Object} Transport mechanism for whichever browser we're in, or false if 134 * none available. 135 */ 136 getTransport: function() { 137 return OpenLayers.Util.Try( 138 function() {return new ActiveXObject('Msxml2.XMLHTTP')}, 139 function() {return new ActiveXObject('Microsoft.XMLHTTP')}, 140 function() {return new XMLHttpRequest()} 141 ) || false; 142 }, 143 144 /** 145 * Property: activeRequestCount 146 * {Integer} 147 */ 148 activeRequestCount: 0 149 }; 150 151 /** 152 * Namespace: OpenLayers.Ajax.Responders 153 * {Object} 154 */ 125 155 OpenLayers.Ajax.Responders = { 126 responders: [], 127 128 register: function(responderToAdd) { 129 for (var i = 0; i < this.responders.length; i++) 130 if (responderToAdd == this.responders[i]) 131 return; 132 this.responders.push(responderToAdd); 133 }, 134 135 dispatch: function(callback, request, transport, json) { 136 for (var i = 0; i < this.responders.length; i++) { 137 responder = this.responders[i]; 138 if (responder[callback] && typeof responder[callback] == 'function') { 139 try { 140 responder[callback].apply(responder, [request, transport, json]); 141 } catch (e) {} 142 } 156 157 /** 158 * Property: responders 159 * {Array} 160 */ 161 responders: [], 162 163 /** 164 * Method: register 165 * 166 * Parameters: 167 * responderToAdd - {?} 168 */ 169 register: function(responderToAdd) { 170 for (var i = 0; i < this.responders.length; i++) 171 if (responderToAdd == this.responders[i]) 172 return; 173 this.responders.push(responderToAdd); 174 }, 175 176 /** 177 * Method: dispatch 178 * 179 * Parameters: 180 * callback - {?} 181 * request - {?} 182 * transport - {?} 183 * json - {?} 184 */ 185 dispatch: function(callback, request, transport, json) { 186 for (var i = 0; i < this.responders.length; i++) { 187 responder = this.responders[i]; 188 189 if (responder[callback] && 190 typeof responder[callback] == 'function') { 191 try { 192 responder[callback].apply(responder, 193 [request, transport, json]); 194 } catch (e) {} 195 } 196 } 143 197 } 144 }145 198 }; 146 199 147 200 OpenLayers.Ajax.Responders.register({ 148 onCreate: function() { 149 OpenLayers.Ajax.activeRequestCount++; 150 }, 151 152 onComplete: function() { 153 OpenLayers.Ajax.activeRequestCount--; 154 } 201 /** 202 * Function: onCreate 203 */ 204 onCreate: function() { 205 OpenLayers.Ajax.activeRequestCount++; 206 }, 207 208 /** 209 * Function: onComplete 210 */ 211 onComplete: function() { 212 OpenLayers.Ajax.activeRequestCount--; 213 } 155 214 }); 156 215 216 /** 217 * Namespace: OpenLayers.Ajax.Base 218 * {Object} 219 */ 157 220 OpenLayers.Ajax.Base = function() {}; 158 221 OpenLayers.Ajax.Base.prototype = { 159 setOptions: function(options) { 160 this.options = { 161 method: 'post', 162 asynchronous: true, 163 parameters: '' 222 223 /** 224 * Function: setOptions 225 * 226 * Parameters: 227 * options - {Object} 228 */ 229 setOptions: function(options) { 230 this.options = { 231 'method': 'post', 232 'asynchronous': true, 233 'parameters': '' 234 }; 235 OpenLayers.Util.extend(this.options, options || {}); 236 }, 237 238 /** 239 * Function: responseIsSuccess 240 * 241 * Return: 242 * {Boolean} 243 */ 244 responseIsSuccess: function() { 245 return this.transport.status == undefined || 246 this.transport.status == 0 || 247 (this.transport.status >= 200 && this.transport.status < 300); 248 }, 249 250 /** 251 * Function: responseIsFailure 252 * 253 * Return: 254 * {Boolean} 255 */ 256 responseIsFailure: function() { 257 return !this.responseIsSuccess(); 164 258 } 165 OpenLayers.Util.extend(this.options, options || {}); 166 }, 167 168 responseIsSuccess: function() { 169 return this.transport.status == undefined 170 || this.transport.status == 0 171 || (this.transport.status >= 200 && this.transport.status < 300); 172 }, 173 174 responseIsFailure: function() { 175 return !this.responseIsSuccess(); 176 } 177 } 178 259 }; 260 261 /** 262 * Class: OpenLayers.Ajax.Request 263 * 264 * Inherit: 265 * - <OpenLayers.Ajax.Base> 266 */ 179 267 OpenLayers.Ajax.Request = OpenLayers.Class.create(); 268 269 /** 270 * Property: Events 271 * {Array(String)} 272 */ 180 273 OpenLayers.Ajax.Request.Events = 181 274 ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; 182 275 183 OpenLayers.Ajax.Request.prototype = OpenLayers.Class.inherit( OpenLayers.Ajax.Base, { 184 initialize: function(url, options) { 185 this.transport = OpenLayers.Ajax.getTransport(); 186 this.setOptions(options); 187 this.request(url); 188 }, 189 190 request: function(url) { 191 var parameters = this.options.parameters || ''; 192 if (parameters.length > 0) parameters += '&_='; 193 194 try { 195 this.url = url; 196 if (this.options.method == 'get' && parameters.length > 0) 197 this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; 198 199 OpenLayers.Ajax.Responders.dispatch('onCreate', this, this.transport); 200 201 this.transport.open(this.options.method, this.url, 202 this.options.asynchronous); 203 204 if (this.options.asynchronous) { 205 this.transport.onreadystatechange = this.onStateChange.bind(this); 206 setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); 207 } 208 209 this.setRequestHeaders(); 210 211 var body = this.options.postBody ? this.options.postBody : parameters; 212 this.transport.send(this.options.method == 'post' ? body : null); 213 214 /* Force Firefox to handle ready state 4 for synchronous requests */ 215 if (!this.options.asynchronous && this.transport.overrideMimeType) { 216 this.onStateChange(); 217 } 218 219 } catch (e) { 220 this.dispatchException(e); 276 OpenLayers.Ajax.Request.prototype = 277 OpenLayers.Class.inherit( OpenLayers.Ajax.Base, { 278 279 /** 280 * Constructor: OpenLayers.Ajax.Request 281 * 282 * Parameters: 283 * url - {String} 284 * options - {Object} 285 */ 286 initialize: function(url, options) { 287 this.transport = OpenLayers.Ajax.getTransport(); 288 this.setOptions(options); 289 this.request(url); 290 }, 291 292 /** 293 * Method: request 294 * 295 * Parameters: 296 * url - {String} 297 */ 298 request: function(url) { 299 var parameters = this.options.parameters || ''; 300 if (parameters.length > 0) parameters += '&_='; 301 302 try { 303 this.url = url; 304 if (this.options.method == 'get' && parameters.length > 0) { 305 this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; 306 } 307 308 OpenLayers.Ajax.Responders.dispatch('onCreate', 309 this, 310 this.transport); 311 312 this.transport.open(this.options.method, 313 this.url, 314 this.options.asynchronous); 315 316 if (this.options.asynchronous) { 317 this.transport.onreadystatechange = 318 this.onStateChange.bind(this); 319 320 setTimeout((function() { 321 this.respondToReadyState(1) 322 }).bind(this), 10); 323 } 324 325 this.setRequestHeaders(); 326 327 var body = this.options.postBody ? this.options.postBody 328 : parameters; 329 this.transport.send(this.options.method == 'post' ? body : null); 330 331 // Force Firefox to handle ready state 4 for synchronous requests 332 if (!this.options.asynchronous && 333 this.transport.overrideMimeType) { 334 335 this.onStateChange(); 336 } 337 338 } catch (e) { 339 this.dispatchException(e); 340 } 341 }, 342 343 /** 344 * Method: setRequestHeaders 345 */ 346 setRequestHeaders: function() { 347 var requestHeaders = [ 348 'X-Requested-With', 349 'XMLHttpRequest', 350 'X-Prototype-Version', 351 'OpenLayers' 352 ]; 353 354 if (this.options.method == 'post' && !this.options.postBody) { 355 requestHeaders.push('Content-type', 356 'application/x-www-form-urlencoded'); 357 358 // Force "Connection: close" for Mozilla browsers to work around 359 // a bug where XMLHttpReqeuest sends an incorrect Content-length 360 // header. See Mozilla Bugzilla #246651. 361 if (this.transport.overrideMimeType) { 362 requestHeaders.push('Connection', 'close'); 363 } 364 } 365 366 if (this.options.requestHeaders) { 367 requestHeaders.push.apply(requestHeaders, 368 this.options.requestHeaders); 369 } 370 371 for (var i = 0; i < requestHeaders.length; i += 2) { 372 this.transport.setRequestHeader(requestHeaders[i], 373 requestHeaders[i+1]); 374 } 375 }, 376 377 /** 378 * Method: onStateChange 379 */ 380 onStateChange: function() { 381 var readyState = this.transport.readyState; 382 if (readyState != 1) { 383 this.respondToReadyState(this.transport.readyState); 384 } 385 }, 386 387 /** 388 * Method: header 389 * 390 * Return: 391 * {?} 392 */ 393 header: function(name) { 394 try { 395 return this.transport.getResponseHeader(name); 396 } catch (e) {} 397 }, 398 399 /** 400 * Method: evalJSON 401 * 402 * Return: 403 * {?} 404 */ 405 evalJSON: function() { 406 try { 407 return eval(this.header('X-JSON')); 408 } catch (e) {} 409 }, 410 411 /** 412 * Method: evalResponse 413 * 414 * Return: 415 * {?} 416 */ 417 evalResponse: function() { 418 try { 419 return eval(this.transport.responseText); 420 } catch (e) { 421 this.dispatchException(e); 422 } 423 }, 424 425 /** 426 * Method: respondToReadyState 427 * 428 * Parameters: 429 * readyState - {?} 430 */ 431 respondToReadyState: function(readyState) { 432 var event = OpenLayers.Ajax.Request.Events[readyState]; 433 var transport = this.transport, json = this.evalJSON(); 434 435 if (event == 'Complete') { 436 try { 437 var responseSuccess = this.responseIsSuccess() ? 'Success' 438 : 'Failure'; 439 440 (this.options['on' + this.transport.status] || 441 this.options['on' + responseSuccess] || 442 OpenLayers.Ajax.emptyFunction)(transport, json); 443 } catch (e) { 444 this.dispatchException(e); 445 } 446 447 var contentType = this.header('Content-type') || ''; 448 if (contentType.match(/^text\/javascript/i)) { 449 this.evalResponse(); 450 } 451 } 452 453 try { 454 (this.options['on' + event] || 455 OpenLayers.Ajax.emptyFunction)(transport, json); 456 OpenLayers.Ajax.Responders.dispatch('on' + event, 457 this, 458 transport, 459 json); 460 } catch (e) { 461 this.dispatchException(e); 462 } 463 464 // Avoid memory leak in MSIE: clean up the oncomplete event handler 465 if (event == 'Complete') { 466 this.transport.onreadystatechange = OpenLayers.Ajax.emptyFunction; 467 } 468 }, 469 470 /** 471 * Method: dispatchException 472 * 473 * Parameters: 474 * exception - {?} 475 */ 476 dispatchException: function(exception) { 477 if (this.options.onException) { 478 this.options.onException(this, exception); 479 } else { 480 // if we get here, Responders.dispatch('onException') will never 481 // be called. too bad. we should probably take out the Responders 482 // stuff anyway. 483 throw exception; 484 } 485 OpenLayers.Ajax.Responders.dispatch('onException', this, exception); 221 486 } 222 }, 223 224 setRequestHeaders: function() { 225 var requestHeaders = 226 ['X-Requested-With', 'XMLHttpRequest', 227 'X-Prototype-Version', 'OpenLayers']; 228 229 if (this.options.method == 'post' && !this.options.postBody) { 230 requestHeaders.push('Content-type', 231 'application/x-www-form-urlencoded'); 232 233 /* Force "Connection: close" for Mozilla browsers to work around 234 * a bug where XMLHttpReqeuest sends an incorrect Content-length 235 * header. See Mozilla Bugzilla #246651. 236 */ 237 if (this.transport.overrideMimeType) 238 requestHeaders.push('Connection', 'close'); 487 488 }); 489 490 /** 491 * Function: getElementsByTagNameNS 492 * 493 * Parameters: 494 * parentnode - {?} 495 * nsuri - {?} 496 * nsprefix - {?} 497 * tagname - {?} 498 * 499 * Return: 500 * {?} 501 */ 502 OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri, 503 nsprefix, tagname) { 504 var elem = null; 505 if (parentnode.getElementsByTagNameNS) { 506 elem = parentnode.getElementsByTagNameNS(nsuri, tagname); 507 } else { 508 elem = parentnode.getElementsByTagName(nsprefix + ':' + tagname); 239 509 } 240 241 if (this.options.requestHeaders) 242 requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); 243 244 for (var i = 0; i < requestHeaders.length; i += 2) 245 this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); 246 }, 247 248 onStateChange: function() { 249 var readyState = this.transport.readyState; 250 if (readyState != 1) 251 this.respondToReadyState(this.transport.readyState); 252 }, 253 254 header: function(name) { 255 try { 256 return this.transport.getResponseHeader(name); 257 } catch (e) {} 258 }, 259 260 evalJSON: function() { 261 try { 262 return eval(this.header('X-JSON')); 263 } catch (e) {} 264 }, 265 266 evalResponse: function() { 267 try { 268 return eval(this.transport.responseText); 269 } catch (e) { 270 this.dispatchException(e); 271 } 272 }, 273 274 respondToReadyState: function(readyState) { 275 var event = OpenLayers.Ajax.Request.Events[readyState]; 276 var transport = this.transport, json = this.evalJSON(); 277 278 if (event == 'Complete') { 279 try { 280 (this.options['on' + this.transport.status] 281 || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] 282 || OpenLayers.Ajax.emptyFunction)(transport, json); 283 } catch (e) { 284 this.dispatchException(e); 285 } 286 287 if ((this.header('Content-type') || '').match(/^text\/javascript/i)) 288 this.evalResponse(); 289 } 290 291 try { 292 (this.options['on' + event] || OpenLayers.Ajax.emptyFunction)(transport, json); 293 OpenLayers.Ajax.Responders.dispatch('on' + event, this, transport, json); 294 } catch (e) { 295 this.dispatchException(e); 296 } 297 298 /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ 299 if (event == 'Complete') 300 this.transport.onreadystatechange = OpenLayers.Ajax.emptyFunction; 301 }, 302 303 dispatchException: function(exception) { 304 if (this.options.onException) { 305 this.options.onException(this, exception); 306 } else { 307 // if we get here, Responders.dispatch('onException') will never 308 // be called. too bad. we should probably take out the Responders 309 // stuff anyway. 310 throw exception; 311 } 312 OpenLayers.Ajax.Responders.dispatch('onException', this, exception); 313 } 314 }); 315 316 OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri, nsprefix, tagname) { 317 return parentnode.getElementsByTagNameNS ? 318 parentnode.getElementsByTagNameNS(nsuri, tagname) 319 : parentnode.getElementsByTagName(nsprefix + ':' + tagname); 320 } 321 322 /** 510 return elem; 511 }; 512 513 514 /** 515 * Function: serializeXMLToString 323 516 * Wrapper function around XMLSerializer, which doesn't exist/work in 324 * IE/Safari. We need to come up with a way to serialize in those browser: 325 * for now, these browsers will just fail. 326 * #535, #536 327 * 328 * @param {XMLNode} xmldom xml dom to serialize 517 * IE/Safari. We need to come up with a way to serialize in those browser: 518 * for now, these browsers will just fail. #535, #536 519 * 520 * Parameters: 521 * xmldom {XMLNode} xml dom to serialize 522 * 523 * Return: 524 * {?} 329 525 */ 330 526 OpenLayers.Ajax.serializeXMLToString = function(xmldom) { trunk/openlayers/lib/OpenLayers/BaseTypes.js
r3323 r3545 3 3 * for the full text of the license. */ 4 4 5 6 /* OpenLayers.Class metaclass */ 5 /** 6 * Header: OpenLayers Base Types 7 * Basic types in OpenLayers are described here. 8 */ 9 10 /** 11 * Namespace: OpenLayers.Class 12 * Contains functions to create OpenLayers style classes. 13 */ 7 14 OpenLayers.Class = { 8 15 isPrototype: function () {}, // magic anonymous value 9 16 17 /** 18 * APIFunction: create 19 * Create an OpenLayers style class 20 * 21 * Return: 22 * An OpenLayers class 23 */ 10 24 create: function() { 11 25 return function() { … … 15 29 }, 16 30 31 /** 32 * APIFunction: inherit 33 * Inherit from one or more OpenLayers style classes 34 * 35 * Parameters: 36 * class - One or more classes can be provided as arguments 37 * 38 * Return: 39 * An object prototype 40 */ 17 41 inherit: function () { 18 42 var superClass = arguments[0]; … … 55 79 56 80 /** 57 * @class 58 * 81 * Class: OpenLayers.Pixel 59 82 * This class represents a screen coordinate, in x and y coordinates 60 83 */ … … 62 85 OpenLayers.Pixel.prototype = { 63 86 64 /** @type float */ 87 /** 88 * APIProperty: x 89 * {Number} The x coordinate 90 */ 65 91 x: 0.0, 66 92 67 /** @type float */ 93 /** 94 * APIProperty: x 95 * {Number} The x coordinate 96 */ 68 97 y: 0.0, 69 98 70 /** 71 * @constructor 72 * 73 * @param {float} x 74 * @param {float} y 75 */ 99 /** 100 * Constructor: OpenLayers.Pixel 101 * Create a new OpenLayers.Pixel instance 102 * 103 * Parameters: 104 * x - {Number} The x coordinate 105 * y - {Number} The y coordinate 106 * 107 * Return: 108 * An instance of OpenLayers.Pixel 109 */ 76 110 initialize: function(x, y) { 77 111 this.x = parseFloat(x); … … 80 114 81 115 /** 82 * @return string representation of Pixel. ex: "x=200.4,y=242.2" 83 * @type str 84 */ 116 * Method: toString 117 * Cast this object into a string 118 * 119 * Return: 120 * {String} The string representation of Pixel. ex: "x=200.4,y=242.2" 121 */ 85 122 toString:function() { 86 123 return ("x=" + this.x + ",y=" + this.y); … … 88 125 89 126 /** 90 * @type OpenLayers.Pixel 127 * APIMethod: clone 128 * Return a clone of this pixel object 129 * 130 * Return: 131 * {<OpenLayers.Pixel>} A clone pixel 91 132 */ 92 133 clone:function() { … … 94 135 }, 95 136
