2170_anonfuncs.diff: created functions returning true and false instead of using anonymous functions all over. p=rcoup, r=me (see #2170)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9759 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -431,6 +431,38 @@ OpenLayers.Function = {
|
|||||||
return function(event) {
|
return function(event) {
|
||||||
return func.call(object, event || window.event);
|
return func.call(object, event || window.event);
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIFunction: False
|
||||||
|
* A simple function to that just does "return false". We use this to
|
||||||
|
* avoid attaching anonymous functions to DOM event handlers, which
|
||||||
|
* causes "issues" on IE<8.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* document.onclick = OpenLayers.Function.False;
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Boolean}
|
||||||
|
*/
|
||||||
|
False : function() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIFunction: True
|
||||||
|
* A simple function to that just does "return true". We use this to
|
||||||
|
* avoid attaching anonymous functions to DOM event handlers, which
|
||||||
|
* causes "issues" on IE<8.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* document.onclick = OpenLayers.Function.True;
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Boolean}
|
||||||
|
*/
|
||||||
|
True : function() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ OpenLayers.Control = OpenLayers.Class({
|
|||||||
if (!this.allowSelection) {
|
if (!this.allowSelection) {
|
||||||
this.div.className += " olControlNoSelect";
|
this.div.className += " olControlNoSelect";
|
||||||
this.div.setAttribute("unselectable", "on", 0);
|
this.div.setAttribute("unselectable", "on", 0);
|
||||||
this.div.onselectstart = function() { return(false); };
|
this.div.onselectstart = OpenLayers.Function.False;
|
||||||
}
|
}
|
||||||
if (this.title != "") {
|
if (this.title != "") {
|
||||||
this.div.title = this.title;
|
this.div.title = this.title;
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ OpenLayers.Control.MouseDefaults = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||||
}
|
}
|
||||||
document.onselectstart=function() { return false; };
|
document.onselectstart = OpenLayers.Function.False;
|
||||||
OpenLayers.Event.stop(evt);
|
OpenLayers.Event.stop(evt);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ OpenLayers.Control.MouseToolbar = OpenLayers.Class(
|
|||||||
this.map.div.style.cursor = "move";
|
this.map.div.style.cursor = "move";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
document.onselectstart = function() { return false; };
|
document.onselectstart = OpenLayers.Function.False;
|
||||||
OpenLayers.Event.stop(evt);
|
OpenLayers.Event.stop(evt);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
draw: function() {
|
draw: function() {
|
||||||
// disable right mouse context menu for support of right click events
|
// disable right mouse context menu for support of right click events
|
||||||
if (this.handleRightClicks) {
|
if (this.handleRightClicks) {
|
||||||
this.map.viewPortDiv.oncontextmenu = function () { return false;};
|
this.map.viewPortDiv.oncontextmenu = OpenLayers.Function.False;
|
||||||
}
|
}
|
||||||
|
|
||||||
var clickCallbacks = {
|
var clickCallbacks = {
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
OpenLayers.Event.stop(evt);
|
OpenLayers.Event.stop(evt);
|
||||||
|
|
||||||
if(!this.oldOnselectstart) {
|
if(!this.oldOnselectstart) {
|
||||||
this.oldOnselectstart = (document.onselectstart) ? document.onselectstart : function() { return true; };
|
this.oldOnselectstart = (document.onselectstart) ? document.onselectstart : OpenLayers.Function.True;
|
||||||
document.onselectstart = function() {return false;};
|
document.onselectstart = OpenLayers.Function.False;
|
||||||
}
|
}
|
||||||
|
|
||||||
propagate = !this.stopDown;
|
propagate = !this.stopDown;
|
||||||
@@ -218,7 +218,7 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
this.callback("move", [evt.xy]);
|
this.callback("move", [evt.xy]);
|
||||||
if(!this.oldOnselectstart) {
|
if(!this.oldOnselectstart) {
|
||||||
this.oldOnselectstart = document.onselectstart;
|
this.oldOnselectstart = document.onselectstart;
|
||||||
document.onselectstart = function() {return false;};
|
document.onselectstart = OpenLayers.Function.False;
|
||||||
}
|
}
|
||||||
this.last = this.evt.xy;
|
this.last = this.evt.xy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
// without this, resolution properties must be specified at the
|
// without this, resolution properties must be specified at the
|
||||||
// map-level for this temporary layer to init its resolutions
|
// map-level for this temporary layer to init its resolutions
|
||||||
// correctly
|
// correctly
|
||||||
calculateInRange: function() { return true; }
|
calculateInRange: OpenLayers.Function.True
|
||||||
}, this.layerOptions);
|
}, this.layerOptions);
|
||||||
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
|
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
|
||||||
this.map.addLayer(this.layer);
|
this.map.addLayer(this.layer);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, {
|
|||||||
// without this, resolution properties must be specified at the
|
// without this, resolution properties must be specified at the
|
||||||
// map-level for this temporary layer to init its resolutions
|
// map-level for this temporary layer to init its resolutions
|
||||||
// correctly
|
// correctly
|
||||||
calculateInRange: function() { return true; }
|
calculateInRange: OpenLayers.Function.True
|
||||||
};
|
};
|
||||||
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
|
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
|
||||||
this.map.addLayer(this.layer);
|
this.map.addLayer(this.layer);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ OpenLayers.Layer.VirtualEarth = OpenLayers.Class(
|
|||||||
// http://blogs.msdn.com/virtualearth/archive/2007/09/28/locking-a-virtual-earth-map.aspx
|
// http://blogs.msdn.com/virtualearth/archive/2007/09/28/locking-a-virtual-earth-map.aspx
|
||||||
//
|
//
|
||||||
this.mapObject.LoadMap(null, null, this.type, true);
|
this.mapObject.LoadMap(null, null, this.type, true);
|
||||||
this.mapObject.AttachEvent("onmousedown", function() {return true; });
|
this.mapObject.AttachEvent("onmousedown", OpenLayers.Function.True);
|
||||||
|
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
this.mapObject.HideDashboard();
|
this.mapObject.HideDashboard();
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
// IE hack to make elements unselectable, to prevent 'blue flash'
|
// IE hack to make elements unselectable, to prevent 'blue flash'
|
||||||
// while dragging vectors; #1410
|
// while dragging vectors; #1410
|
||||||
node.unselectable = 'on';
|
node.unselectable = 'on';
|
||||||
node.onselectstart = function() { return(false); };
|
node.onselectstart = OpenLayers.Function.False;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user