Changeset 4302
- Timestamp:
- 09/14/07 16:08:47 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Ajax.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/BaseTypes.js (modified) (11 diffs)
- trunk/openlayers/lib/OpenLayers/BaseTypes/Element.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Control/MouseDefaults.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/PanZoom.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Control/Panel.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Events.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Format/WKT.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Format/XML.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Handler/Keyboard.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Handler/MouseWheel.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/WFS.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Popup.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Tile/Image.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (3 diffs)
- trunk/openlayers/tests/Geometry/test_Surface.html (modified) (1 diff)
- trunk/openlayers/tests/test_BaseTypes.html (modified) (7 diffs)
- trunk/openlayers/tests/test_Feature.html (modified) (1 diff)
- trunk/openlayers/tests/test_Geometry.html (modified) (2 diffs)
- trunk/openlayers/tests/test_Popup.html (modified) (1 diff)
- trunk/openlayers/tests/test_Tile.html (modified) (1 diff)
- trunk/openlayers/tests/test_Util.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Ajax.js
r4110 r4302 54 54 onComplete, onFailure) { 55 55 56 if (OpenLayers.ProxyHost && uri.startsWith("http")) {56 if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(uri, "http")) { 57 57 uri = OpenLayers.ProxyHost + escape(uri); 58 58 } 59 59 60 var success = (onComplete) ? onComplete.bind(caller)60 var success = (onComplete) ? OpenLayers.Function.bind(onComplete, caller) 61 61 : OpenLayers.nullHandler; 62 62 63 var failure = (onFailure) ? onFailure.bind(caller)63 var failure = (onFailure) ? OpenLayers.Function.bind(onFailure, caller) 64 64 : OpenLayers.nullHandler; 65 65 … … 308 308 if (this.options.asynchronous) { 309 309 this.transport.onreadystatechange = 310 this.onStateChange.bind(this);310 OpenLayers.Function.bind(this.onStateChange, this); 311 311 312 setTimeout( (function() {313 this.respondToReadyState(1)314 }).bind(this), 10);312 setTimeout(OpenLayers.Function.bind( 313 (function() {this.respondToReadyState(1)}),this), 10 314 ); 315 315 } 316 316 trunk/openlayers/lib/OpenLayers/BaseTypes.js
r4216 r4302 5 5 /** 6 6 * Header: OpenLayers Base Types 7 * Modifications to standard JavaScript types are described here.7 * OpenLayers custom string, number and function functions are described here. 8 8 */ 9 9 … … 14 14 *********************/ 15 15 16 OpenLayers.String = { 17 /** 18 * APIMethod: OpenLayers.String.startsWith 19 * Whether or not a string starts with another string. 20 * 21 * Parameters: 22 * str - {String} The string to test. 23 * sub - {Sring} The substring to look for. 24 * 25 * Returns: 26 * {Boolean} The first string starts with the second. 27 */ 28 startsWith: function(str, sub) { 29 return (str.indexOf(sub) == 0); 30 }, 31 32 /** 33 * APIMethod: OpenLayers.String.contains 34 * Whether or not a string contains another string. 35 * 36 * Parameters: 37 * str - {String} The string to test. 38 * sub - {String} The substring to look for. 39 * 40 * Returns: 41 * {Boolean} The first string contains the second. 42 */ 43 contains: function(str, sub) { 44 return (str.indexOf(sub) != -1); 45 }, 46 47 /** 48 * APIMethod: OpenLayers.String.trim 49 * Removes leading and trailing whitespace characters from a string. 50 * 51 * Parameters: 52 * str - {String} The (potentially) space padded string. This string is not 53 * modified. 54 * 55 * Returns: 56 * {String} A trimmed version of the string - all leading and 57 * trailing spaces removed. 58 */ 59 trim: function(str) { 60 return str.replace(/^\s*(.*?)\s*$/, "$1"); 61 }, 62 63 /** 64 * APIMethod: OpenLayers.String.camelize 65 * Camel-case a hyphenated string. 66 * Ex. "chicken-head" becomes "chickenHead", and 67 * "-chicken-head" becomes "ChickenHead". 68 * 69 * Parameters: 70 * str - {String} The string to be camelized. The original is not modified. 71 * 72 * Returns: 73 * {String} The string, camelized 74 */ 75 camelize: function(str) { 76 var oStringList = str.split('-'); 77 var camelizedString = oStringList[0]; 78 for (var i = 1; i < oStringList.length; i++) { 79 var s = oStringList[i]; 80 camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 81 } 82 return camelizedString; 83 } 84 }; 16 85 17 86 /** 18 87 * APIMethod: String.startsWith 19 * Whether or not a string starts with another string.88 * Deprecated. Whether or not a string starts with another string. 20 89 * 21 90 * Parameters: … … 26 95 */ 27 96 String.prototype.startsWith = function(sStart) { 28 return (this.substr(0,sStart.length) == sStart); 97 OpenLayers.Console.warn( 98 "This method has been deprecated and will be removed in 3.0. " + 99 "Please use OpenLayers.String.startsWith instead" 100 ); 101 return OpenLayers.String.startsWith(this, sStart); 29 102 }; 30 103 31 104 /** 32 105 * APIMethod: String.contains 33 * Whether or not a string contains another string.106 * Deprecated. Whether or not a string contains another string. 34 107 * 35 108 * Parameters: … … 40 113 */ 41 114 String.prototype.contains = function(str) { 42 return (this.indexOf(str) != -1); 115 OpenLayers.Console.warn( 116 "This method has been deprecated and will be removed in 3.0. " + 117 "Please use OpenLayers.String.contains instead" 118 ); 119 return OpenLayers.String.contains(this, str); 43 120 }; 44 121 45 122 /** 46 123 * APIMethod: String.trim 47 * Removes leading and trailing whitespace characters from a string.124 * Deprecated. Removes leading and trailing whitespace characters from a string. 48 125 * 49 126 * Returns: … … 52 129 */ 53 130 String.prototype.trim = function() { 54 return this.replace(/^\s+/, '').replace(/\s+$/, ''); 131 OpenLayers.Console.warn( 132 "This method has been deprecated and will be removed in 3.0. " + 133 "Please use OpenLayers.String.trim instead" 134 ); 135 return OpenLayers.String.trim(this); 55 136 }; 56 137 57 138 /** 58 139 * APIMethod: camelize 59 * Camel-case a hyphenated string.140 * Deprecated. Camel-case a hyphenated string. 60 141 * Ex. "chicken-head" becomes "chickenHead", and 61 142 * "-chicken-head" becomes "ChickenHead". … … 65 146 */ 66 147 String.prototype.camelize = function() { 67 var oStringList = this.split('-'); 68 var camelizedString = oStringList[0]; 69 for (var i = 1; i < oStringList.length; i++) { 70 var s = oStringList[i]; 71 camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 72 } 73 return camelizedString; 148 OpenLayers.Console.warn( 149 "This method has been deprecated and will be removed in 3.0. " + 150 "Please use OpenLayers.String.camelize instead" 151 ); 152 return OpenLayers.String.camelize(this); 74 153 }; 75 154 … … 81 160 *********************/ 82 161 162 OpenLayers.Number = { 163 /** 164 * APIMethod: OpenLayers.Number.limitSigDigs 165 * Limit the number of significant digits on an integer. 166 * 167 * Parameters: 168 * num - {Integer} 169 * sig - {Integer} 170 * 171 * Returns: 172 * {Integer} The number, rounded to the specified number of significant 173 * digits. 174 */ 175 limitSigDigs: function(num, sig) { 176 var fig; 177 if(sig > 0) { 178 fig = parseFloat(num.toPrecision(sig)); 179 } else { 180 fig = 0; 181 } 182 return fig; 183 } 184 }; 185 83 186 /** 84 187 * APIMethod: Number.limitSigDigs 85 * Limit the number of significant digits on an integer. Does *not* work86 * w ith floats!188 * Deprecated. Limit the number of significant digits on an integer. Does *not* 189 * work with floats! 87 190 * 88 191 * Parameters: … … 94 197 */ 95 198 Number.prototype.limitSigDigs = function(sig) { 96 var numStr = (sig > 0) ? this.toString() : "0"; 97 if (numStr.contains(".")) { 98 var msg = "limitSigDig can not be called on a floating point number"; 99 OpenLayers.Console.error(msg); 100 return null; 101 } 102 if ( (sig > 0) && (sig < numStr.length) ) { 103 var exp = numStr.length - sig; 104 numStr = Math.round( this / Math.pow(10, exp)) * Math.pow(10, exp); 105 } 106 return parseInt(numStr); 199 OpenLayers.Console.warn( 200 "This method has been deprecated and will be removed in 3.0. " + 201 "Please use OpenLayers.Number.limitSigDigs instead" 202 ); 203 return OpenLayers.Number.limitSigDigs(this, sig); 107 204 }; 108 205 … … 114 211 *********************/ 115 212 213 OpenLayers.Function = { 214 /** 215 * APIMethod: OpenLayers.Function.bind 216 * Bind a function to an object. Method to easily create closures with 217 * 'this' altered. 218 * 219 * Parameters: 220 * func - {Function} Input function. 221 * object - {Object} The object to bind to the input function (as this). 222 * 223 * Returns: 224 * {Function} A closure with 'this' set to the passed in object. 225 */ 226 bind: function(func, object) { 227 // create a reference to all arguments past the second one 228 var args = Array.prototype.slice.apply(arguments, [2]); 229 return function() { 230 // Push on any additional arguments from the actual function call. 231 // These will come after those sent to the bind call. 232 var newArgs = args.concat( 233 Array.prototype.slice.apply(arguments, [0]) 234 ); 235 return func.apply(object, newArgs); 236 }; 237 }, 238 239 /** 240 * APIMethod: OpenLayers.Function.bindAsEventListener 241 * Bind a function to an object, and configure it to receive the event 242 * object as first parameter when called. 243 * 244 * Parameters: 245 * func - {Function} Input function to serve as an event listener. 246 * object - {Object} A reference to this. 247 * 248 * Returns: 249 * {Function} 250 */ 251 bindAsEventListener: function(func, object) { 252 return function(event) { 253 return func.call(object, event || window.event); 254 }; 255 } 256 }; 257 116 258 /** 117 259 * APIMethod: Function.bind 118 * Bind a function to an object.260 * Deprecated. Bind a function to an object. 119 261 * Method to easily create closures with 'this' altered. 120 262 * … … 127 269 */ 128 270 Function.prototype.bind = function() { 129 var __method = this; 130 var args = []; 131 var object = arguments[0]; 132 133 for (var i = 1; i < arguments.length; i++) { 134 args.push(arguments[i]); 135 } 136 137 return function(moreargs) { 138 var i; 139 var newArgs = []; 140 for (i = 0; i < args.length; i++) { 141 newArgs.push(args[i]); 142 } 143 for (i = 0; i < arguments.length; i++) { 144 newArgs.push(arguments[i]); 145 } 146 return __method.apply(object, newArgs); 147 }; 271 OpenLayers.Console.warn( 272 "This method has been deprecated and will be removed in 3.0. " + 273 "Please use OpenLayers.Function.bind instead" 274 ); 275 // new function takes the same arguments with this function up front 276 Array.prototype.unshift.apply(arguments, [this]); 277 return OpenLayers.Function.bind.apply(null, arguments); 148 278 }; 149 279 150 280 /** 151 281 * APIMethod: Function.bindAsEventListener 152 * Bind a function to an object, and configure it to receive the event object153 * as first parameter when called.282 * Deprecated. Bind a function to an object, and configure it to receive the 283 * event object as first parameter when called. 154 284 * 155 285 * Parameters: … … 160 290 */ 161 291 Function.prototype.bindAsEventListener = function(object) { 162 var __method = this; 163 return function(event) { 164 return __method.call(object, event || window.event); 165 }; 166 }; 292 OpenLayers.Console.warn( 293 "This method has been deprecated and will be removed in 3.0. " + 294 "Please use OpenLayers.Function.bindAsEventListener instead" 295 ); 296 return OpenLayers.Function.bindAsEventListener(this, object); 297 }; trunk/openlayers/lib/OpenLayers/BaseTypes/Element.js
r4110 r4302 136 136 getStyle: function(element, style) { 137 137 element = OpenLayers.Util.getElement(element); 138 var value = element.style[ style.camelize()];138 var value = element.style[OpenLayers.String.camelize(style)]; 139 139 if (!value) { 140 140 if (document.defaultView && … … 144 144 value = css ? css.getPropertyValue(style) : null; 145 145 } else if (element.currentStyle) { 146 value = element.currentStyle[ style.camelize()];146 value = element.currentStyle[OpenLayers.String.camelize(style)]; 147 147 } 148 148 } trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js
r4229 r4302 280 280 } 281 281 OpenLayers.Event.observe(inputElem, "mouseup", 282 this.onInputClick.bindAsEventListener(context)); 282 OpenLayers.Function.bindAsEventListener(this.onInputClick, 283 context) 284 ); 283 285 284 286 // create span … … 291 293 : "baseline"; 292 294 OpenLayers.Event.observe(labelSpan, "click", 293 this.onInputClick.bindAsEventListener(context)); 295 OpenLayers.Function.bindAsEventListener(this.onInputClick, 296 context) 297 ); 294 298 // create line break 295 299 var br = document.createElement("br"); … … 464 468 465 469 OpenLayers.Event.observe(this.div, "mouseup", 466 this.mouseUp.bindAsEventListener(this));470 OpenLayers.Function.bindAsEventListener(this.mouseUp, this)); 467 471 OpenLayers.Event.observe(this.div, "click", 468 472 this.ignoreEvent); 469 473 OpenLayers.Event.observe(this.div, "mousedown", 470 this.mouseDown.bindAsEventListener(this));474 OpenLayers.Function.bindAsEventListener(this.mouseDown, this)); 471 475 OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent); 472 476 … … 497 501 this.baseLayersDiv.style.paddingLeft = "10px"; 498 502 /*OpenLayers.Event.observe(this.baseLayersDiv, "click", 499 this.onLayerClick.bindAsEventListener(this));503 OpenLayers.Function.bindAsEventListener(this.onLayerClick, this)); 500 504 */ 501 505 … … 546 550 this.maximizeDiv.style.left = ""; 547 551 this.maximizeDiv.style.display = "none"; 548 OpenLayers.Event.observe(this.maximizeDiv, 549 "click",550 this.maximizeControl.bindAsEventListener(this));552 OpenLayers.Event.observe(this.maximizeDiv, "click", 553 OpenLayers.Function.bindAsEventListener(this.maximizeControl, this) 554 ); 551 555 552 556 this.div.appendChild(this.maximizeDiv); … … 565 569 this.minimizeDiv.style.left = ""; 566 570 this.minimizeDiv.style.display = "none"; 567 OpenLayers.Event.observe(this.minimizeDiv, 568 "click",569 this.minimizeControl.bindAsEventListener(this));571 OpenLayers.Event.observe(this.minimizeDiv, "click", 572 OpenLayers.Function.bindAsEventListener(this.minimizeControl, this) 573 ); 570 574 571 575 this.div.appendChild(this.minimizeDiv); trunk/openlayers/lib/OpenLayers/Control/MouseDefaults.js
r4110 r4302 85 85 registerWheelEvents: function() { 86 86 87 this.wheelObserver = this.onWheelEvent.bindAsEventListener(this); 87 this.wheelObserver = OpenLayers.Function.bindAsEventListener( 88 this.onWheelEvent, this 89 ); 88 90 89 91 //register mousewheel events specifically on the window and document trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js
r4242 r4302 219 219 this.maximizeDiv.style.display = 'none'; 220 220 this.maximizeDiv.className = this.displayClass + 'MaximizeButton'; 221 OpenLayers.Event.observe(this.maximizeDiv, 222 'click', 223 this.maximizeControl.bindAsEventListener(this)); 221 OpenLayers.Event.observe(this.maximizeDiv, 'click', 222 OpenLayers.Function.bindAsEventListener(this.maximizeControl, 223 this) 224 ); 224 225 this.div.appendChild(this.maximizeDiv); 225 226 … … 234 235 this.minimizeDiv.style.display = 'none'; 235 236 this.minimizeDiv.className = this.displayClass + 'MinimizeButton'; 236 OpenLayers.Event.observe(this.minimizeDiv, 237 'click', 238 this.minimizeControl.bindAsEventListener(this)); 237 OpenLayers.Event.observe(this.minimizeDiv, 'click', 238 OpenLayers.Function.bindAsEventListener(this.minimizeControl, 239 this) 240 ); 239 241 this.div.appendChild(this.minimizeDiv); 240 242 trunk/openlayers/lib/OpenLayers/Control/PanZoom.js
r4110 r4302 113 113 114 114 OpenLayers.Event.observe(btn, "mousedown", 115 this.buttonDown.bindAsEventListener(btn));115 OpenLayers.Function.bindAsEventListener(this.buttonDown, btn)); 116 116 OpenLayers.Event.observe(btn, "dblclick", 117 this.doubleClick.bindAsEventListener(btn));117 OpenLayers.Function.bindAsEventListener(this.doubleClick, btn)); 118 118 OpenLayers.Event.observe(btn, "click", 119 this.doubleClick.bindAsEventListener(btn));119 OpenLayers.Function.bindAsEventListener(this.doubleClick, btn)); 120 120 btn.action = id; 121 121 btn.map = this.map; trunk/openlayers/lib/OpenLayers/Control/Panel.js
r4110 r4302 171 171 controls[i].panel_div = element; 172 172 OpenLayers.Event.observe(controls[i].panel_div, "click", 173 this.onClick.bind(this, controls[i]));173 OpenLayers.Function.bind(this.onClick, this, controls[i])); 174 174 OpenLayers.Event.observe(controls[i].panel_div, "mousedown", 175 OpenLayers.Event.stop.bindAsEventListener());175 OpenLayers.Function.bindAsEventListener(OpenLayers.Event.stop)); 176 176 } 177 177 trunk/openlayers/lib/OpenLayers/Events.js
r4271 r4302 405 405 // keep a bound copy of handleBrowserEvent() so that we can 406 406 // pass the same function to both Event.observe() and .stopObserving() 407 this.eventHandler = this.handleBrowserEvent.bindAsEventListener(this); 407 this.eventHandler = OpenLayers.Function.bindAsEventListener( 408 this.handleBrowserEvent, this 409 ); 408 410 409 411 // if eventTypes is specified, create a listeners list for each trunk/openlayers/lib/OpenLayers/Format/WKT.js
r4110 r4302 209 209 */ 210 210 'point': function(str) { 211 var coords = str.trim().split(this.regExes.spaces);211 var coords = OpenLayers.String.trim(str).split(this.regExes.spaces); 212 212 return new OpenLayers.Feature.Vector( 213 213 new OpenLayers.Geometry.Point(coords[0], coords[1]) … … 222 222 */ 223 223 'multipoint': function(str) { 224 var points = str.trim().split(',');224 var points = OpenLayers.String.trim(str).split(','); 225 225 var components = []; 226 226 for(var i=0; i<points.length; ++i) { … … 239 239 */ 240 240 'linestring': function(str) { 241 var points = str.trim().split(',');241 var points = OpenLayers.String.trim(str).split(','); 242 242 var components = []; 243 243 for(var i=0; i<points.length; ++i) { … … 257 257 'multilinestring': function(str) { 258 258 var line; 259 var lines = str.trim().split(this.regExes.parenComma);259 var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma); 260 260 var components = []; 261 261 for(var i=0; i<lines.length; ++i) { … … 276 276 'polygon': function(str) { 277 277 var ring, linestring, linearring; 278 var rings = str.trim().split(this.regExes.parenComma);278 var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma); 279 279 var components = []; 280 280 for(var i=0; i<rings.length; ++i) { … … 297 297 'multipolygon': function(str) { 298 298 var polygon; 299 var polygons = str.trim().split(this.regExes.doubleParenComma);299 var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma); 300 300 var components = []; 301 301 for(var i=0; i<polygons.length; ++i) { … … 317 317 // separate components of the collection with | 318 318 str = str.replace(/,\s*([A-Za-z])/g, '|$1'); 319 var wktArray = str.trim().split('|');319 var wktArray = OpenLayers.String.trim(str).split('|'); 320 320 var components = []; 321 321 for(var i=0; i<wktArray.length; ++i) { trunk/openlayers/lib/OpenLayers/Format/XML.js
r4255 r4302 61 61 } 62 62 var node = OpenLayers.Util.Try( 63 (function() { 64 var xmldom; 65 /** 66 * Since we want to be able to call this method on the prototype 67 * itself, this.xmldom may not exist even if in IE. 68 */ 69 if(window.ActiveXObject && !this.xmldom) { 70 xmldom = new ActiveXObject("Microsoft.XMLDOM"); 71 } else { 72 xmldom = this.xmldom; 73 74 } 75 xmldom.loadXML(text); 76 return xmldom; 77 }).bind(this), 63 OpenLayers.Function.bind(( 64 function() { 65 var xmldom; 66 /** 67 * Since we want to be able to call this method on the prototype 68 * itself, this.xmldom may not exist even if in IE. 69 */ 70 if(window.ActiveXObject && !this.xmldom) { 71 xmldom = new ActiveXObject("Microsoft.XMLDOM"); 72 } else { 73 xmldom = this.xmldom; 74 75 } 76 xmldom.loadXML(text); 77 return xmldom; 78 } 79 ), this), 78 80 function() { 79 81 return new DOMParser().parseFromString(text, 'text/xml'); trunk/openlayers/lib/OpenLayers/Handler/Keyboard.js
r4108 r4302 50 50 OpenLayers.Handler.prototype.initialize.apply(this, arguments); 51 51 // cache the bound event listener method so it can be unobserved later 52 this.eventListener = this.handleKeyEvent.bindAsEventListener(this); 52 this.eventListener = OpenLayers.Function.bindAsEventListener( 53 this.handleKeyEvent, this 54 ); 53 55 }, 54 56 trunk/openlayers/lib/OpenLayers/Handler/MouseWheel.js
r4110 r4302 40 40 initialize: function(control, callbacks, options) { 41 41 OpenLayers.Handler.prototype.initialize.apply(this, arguments); 42 this.wheelListener = this.onWheelEvent.bindAsEventListener(this); 42 this.wheelListener = OpenLayers.Function.bindAsEventListener( 43 this.onWheelEvent, this 44 ); 43 45 }, 44 46 trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js
r4252 r4302 229 229 var popup = this.createPopup(); 230 230 OpenLayers.Event.observe(popup.div, "click", 231 function() { 232 for(var i=0; i < this.layer.map.popups.length; i++) { 233 this.layer.map.removePopup(this.layer.map.popups[i]); 234 } 235 }.bind(this)); 231 OpenLayers.Function.bind(function() { 232 for(var i=0; i < this.layer.map.popups.length; i++) { 233 this.layer.map.removePopup(this.layer.map.popups[i]); 234 } 235 }, this) 236 ); 236 237 this.layer.map.addPopup(popup); 237 238 } trunk/openlayers/lib/OpenLayers/Layer/WFS.js
r4252 r4302 394 394 395 395 var url = this.url; 396 if (OpenLayers.ProxyHost && this.url.startsWith("http")) { 396 if (OpenLayers.ProxyHost && 397 OpenLayers.String.startsWith(this.url, "http")) { 397 398 url = OpenLayers.ProxyHost + escape(this.url); 398 399 } 399 400 400 var success = this.commitSuccess.bind(this);401 402 var failure = this.commitFailure.bind(this);401 var success = OpenLayers.Function.bind(this.commitSuccess, this); 402 403 var failure = OpenLayers.Function.bind(this.commitFailure, this); 403 404 404 405 data = OpenLayers.Ajax.serializeXMLToString(data); trunk/openlayers/lib/OpenLayers/Map.js
r4261 r4302 302 302 // Because Mozilla does not support the "resize" event for elements 303 303 // other than "window", we need to put a hack here. 304 if ( navigator.appName.contains("Microsoft")) {304 if (OpenLayers.String.contains(navigator.appName, "Microsoft")) { 305 305 // If IE, register the resize on the div 306 306 this.events.register("resize", this, this.updateSize); … … 309 309 // Note that this is ok, as updateSize() does nothing if the 310 310 // map's size has not actually changed. 311 OpenLayers.Event.observe(window, 'resize', 312 this.updateSize.bind(this));311 OpenLayers.Event.observe(window, 'resize', 312 OpenLayers.Function.bind(this.updateSize, this)); 313 313 } 314 314 … … 355 355 this.popups = []; 356 356 357 this.unloadDestroy = this.destroy.bind(this);357 this.unloadDestroy = OpenLayers.Function.bind(this.destroy, this); 358 358 359 359 trunk/openlayers/lib/OpenLayers/Popup.js
r4251 r4302 171 171 } 172 172 OpenLayers.Event.observe(closeImg, "click", 173 closePopup.bindAsEventListener(this));173 OpenLayers.Function.bindAsEventListener(closePopup, this)); 174 174 175 175 } trunk/openlayers/lib/OpenLayers/Tile/Image.js
r4110 r4302 178 178 179 179 OpenLayers.Event.observe( this.imgDiv, "load", 180 this.checkImgURL.bind(this) );180 OpenLayers.Function.bind(this.checkImgURL, this) ); 181 181 */ 182 182 this.frame.appendChild(this.imgDiv); … … 207 207 } 208 208 } 209 OpenLayers.Event.observe(this.imgDiv, 'load', onload.bind(this)); 209 OpenLayers.Event.observe(this.imgDiv, 'load', 210 OpenLayers.Function.bind(onload, this)); 210 211 211 212 }, trunk/openlayers/lib/OpenLayers/Util.js
r4110 r4302 256 256 image.style.display = "none"; 257 257 OpenLayers.Event.observe(image, "load", 258 OpenLayers.Util.onImageLoad.bind(image));258 OpenLayers.Function.bind(OpenLayers.Util.onImageLoad, image)); 259 259 OpenLayers.Event.observe(image, "error", 260 OpenLayers.Util.onImageLoadError.bind(image));260 OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError, image)); 261 261 262 262 } … … 454 454 img.style.display = "none"; 455 455 OpenLayers.Event.observe(img, "load", 456 OpenLayers.Util.onImageLoad.bind(div));456 OpenLayers.Function.bind(OpenLayers.Util.onImageLoad, div)); 457 457 OpenLayers.Event.observe(img, "error", 458 OpenLayers.Util.onImageLoadError.bind(div));458 OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError, div)); 459 459 } 460 460 … … 792 792 //parse out parameters portion of url string 793 793 var paramsString = ""; 794 if ( url.contains('?')) {794 if (OpenLayers.String.contains(url, '?')) { 795 795 var start = url.indexOf('?') + 1; 796 var end = url.contains("#") ? url.indexOf('#') : url.length; 796 var end = OpenLayers.String.contains(url, "#") ? 797 url.indexOf('#') : url.length; 797 798 paramsString = url.substring(start, end); 798 799 } trunk/openlayers/tests/Geometry/test_Surface.html
r4059 r4302 10 10 11 11 t.eq(g.CLASS_NAME, "OpenLayers.Geometry.Surface", "correct CLASS_NAME") 12 t.ok(g.id.startsWith("OpenLayers.Geometry.Surface_"), "id correctly set"); 12 t.ok(OpenLayers.String.startsWith(g.id, "OpenLayers.Geometry.Surface_"), 13 "id correctly set"); 13 14 } 14 15 trunk/openlayers/tests/test_BaseTypes.html
r4296 r4302 12 12 var test2 = "beet"; 13 13 14 t.ok(str.startsWith("chicken"), " 'chickenHead' starts with 'chicken'"); 15 t.ok(!str.startsWith("Head"), " 'chickenHead' contains 'Head' but does *not* start with it"); 16 t.ok(!str.startsWith("beet"), "'chickenHead' doesnt start with 'beet'"); 14 t.ok(OpenLayers.String.startsWith(str, "chicken"), 15 "'chickenHead' starts with 'chicken'"); 16 t.ok(!OpenLayers.String.startsWith(str, "Head"), 17 "'chickenHead' does not start with 'Head'"); 18 t.ok(!OpenLayers.String.startsWith(str, "beet"), 19 "'chickenHead' doesnt start with 'beet'"); 17 20 } 18 21 … … 22 25 var str = "chickenHead"; 23 26 24 t.ok(str.contains("chicken"), "(beginning) 'chickenHead' contains with 'chicken'"); 25 t.ok(str.contains("ick"), "(middle) 'chickenHead' contains with 'ick'"); 26 t.ok(str.contains("Head"), "(end) 'chickenHead' contains with 'Head'"); 27 t.ok(!str.startsWith("beet"), "'chickenHead' doesnt start with 'beet'"); 27 t.ok(OpenLayers.String.contains(str, "chicken"), 28 "(beginning) 'chickenHead' contains with 'chicken'"); 29 t.ok(OpenLayers.String.contains(str, "ick"), 30 "(middle) 'chickenHead' contains with 'ick'"); 31 t.ok(OpenLayers.String.contains(str, "Head"), 32 "(end) 'chickenHead' contains with 'Head'"); 33 t.ok(!OpenLayers.String.startsWith(str, "beet"), 34 "'chickenHead' doesnt start with 'beet'"); 28 35 } 29 36 … … 32 39 33 40 var str = "chickenHead"; 34 t.eq(str.trim(), "chickenHead", "string with no extra whitespace is left alone"); 41 t.eq(OpenLayers.String.trim(str), 42 "chickenHead", "string with no extra whitespace is left alone"); 35 43 36 44 str = " chickenHead"; 37 t.eq(str.trim(), "chickenHead", "string with extra whitespace at beginning is trimmed correctly"); 45 t.eq(OpenLayers.String.trim(str), 46 "chickenHead", "string with extra whitespace at beginning is trimmed correctly"); 38 47 39 48 str = "chickenHead "; 40 t.eq(str.trim(), "chickenHead", "string with extra whitespace at end is trimmed correctly");
