Skip to content

Commit

Permalink
Merge pull request openlayers#423 from marcjansen/no-$
Browse files Browse the repository at this point in the history
Remove the aliasing of OpenLayers.Util.getElement to window.$
  • Loading branch information
marcjansen committed May 29, 2012
2 parents 989259c + acb9f95 commit 366faf6
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 75 deletions.
12 changes: 6 additions & 6 deletions examples/editing-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ map.addControl(draw);
draw.activate();

// handle clicks on method links
$("insertXY").onclick = function() {
document.getElementById("insertXY").onclick = function() {
var values = parseInput(
window.prompt(
"Enter map coordinates for new point (e.g. '-111, 46')", "x, y"
Expand All @@ -30,7 +30,7 @@ $("insertXY").onclick = function() {
draw.insertXY(values[0], values[1]);
}
};
$("insertDeltaXY").onclick = function() {
document.getElementById("insertDeltaXY").onclick = function() {
var values = parseInput(
window.prompt(
"Enter offset values for new point (e.g. '15, -10')", "dx, dy"
Expand All @@ -40,7 +40,7 @@ $("insertDeltaXY").onclick = function() {
draw.insertDeltaXY(values[0], values[1]);
}
};
$("insertDirectionLength").onclick = function() {
document.getElementById("insertDirectionLength").onclick = function() {
var values = parseInput(
window.prompt(
"Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length"
Expand All @@ -50,7 +50,7 @@ $("insertDirectionLength").onclick = function() {
draw.insertDirectionLength(values[0], values[1]);
}
};
$("insertDeflectionLength").onclick = function() {
document.getElementById("insertDeflectionLength").onclick = function() {
var values = parseInput(
window.prompt(
"Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length"
Expand All @@ -60,10 +60,10 @@ $("insertDeflectionLength").onclick = function() {
draw.insertDeflectionLength(values[0], values[1]);
}
};
$("cancel").onclick = function() {
document.getElementById("cancel").onclick = function() {
draw.cancel();
};
$("finishSketch").onclick = function() {
document.getElementById("finishSketch").onclick = function() {
draw.finishSketch();
};

Expand Down
2 changes: 1 addition & 1 deletion examples/game-accel-ball.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
function init() {
map = new OpenLayers.Map( 'map',
{
'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight),
'maxExtent': new OpenLayers.Bounds(0, 0, document.getElementById("map").clientWidth, document.getElementById("map").clientHeight),
controls: [],
maxResolution: 'auto'}
);
Expand Down
9 changes: 4 additions & 5 deletions examples/geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@ geolocate.events.register("locationupdated",geolocate,function(e) {
geolocate.events.register("locationfailed",this,function() {
OpenLayers.Console.log('Location detection failed');
});

$('locate').onclick = function() {
document.getElementById('locate').onclick = function() {
vector.removeAllFeatures();
geolocate.deactivate();
$('track').checked = false;
document.getElementById('track').checked = false;
geolocate.watch = false;
firstGeolocation = true;
geolocate.activate();
};
$('track').onclick = function() {
document.getElementById('track').onclick = function() {
vector.removeAllFeatures();
geolocate.deactivate();
if (this.checked) {
Expand All @@ -110,4 +109,4 @@ $('track').onclick = function() {
geolocate.activate();
}
};
$('track').checked = false;
document.getElementById('track').checked = false;
3 changes: 1 addition & 2 deletions examples/getfeatureinfo-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
</style>
<script defer="defer" type="text/javascript">
OpenLayers.ProxyHost = "proxy.cgi?url=";

var map, infocontrols, water, highlightlayer;

function load() {
Expand Down Expand Up @@ -125,7 +124,7 @@
highlightLayer.addFeatures(evt.features);
highlightLayer.redraw();
} else {
$('responseText').innerHTML = evt.text;
document.getElementById('responseText').innerHTML = evt.text;
}
}

Expand Down
5 changes: 3 additions & 2 deletions examples/select-feature.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, drawControls;

OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
function init(){
map = new OpenLayers.Map('map');
Expand All @@ -33,10 +34,10 @@
});
vectors.events.on({
'featureselected': function(feature) {
$('counter').innerHTML = this.selectedFeatures.length;
document.getElementById('counter').innerHTML = this.selectedFeatures.length;
},
'featureunselected': function(feature) {
$('counter').innerHTML = this.selectedFeatures.length;
document.getElementById('counter').innerHTML = this.selectedFeatures.length;
}
});

Expand Down
23 changes: 11 additions & 12 deletions examples/snap-split.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
<script type="text/javascript">

OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';

function init() {
initMap();
initUI();
}


var map, draw, modify, snap, split, vectors;
function initMap() {

Expand Down Expand Up @@ -185,28 +184,28 @@
*/
function initUI() {
// add behavior to snap elements
var snapCheck = $("snap_toggle");
var snapCheck = document.getElementById("snap_toggle");
snapCheck.checked = true;
snapCheck.onclick = function() {
if(snapCheck.checked) {
snap.activate();
$("snap_options").style.display = "block";
document.getElementById("snap_options").style.display = "block";
} else {
snap.deactivate();
$("snap_options").style.display = "none";
document.getElementById("snap_options").style.display = "none";
}
};
var target, type, tog, tol;
var types = ["node", "vertex", "edge"];
var target = snap.targets[0];
for(var j=0; j<types.length; ++j) {
type = types[j];
tog = $("target_" + type);
tog = document.getElementById("target_" + type);
tog.checked = target[type];
tog.onclick = (function(tog, type, target) {
return function() {target[type] = tog.checked;}
})(tog, type, target);
tol = $("target_" + type + "Tolerance");
tol = document.getElementById("target_" + type + "Tolerance");
tol.value = target[type + "Tolerance"];
tol.onchange = (function(tol, type, target) {
return function() {
Expand All @@ -216,24 +215,24 @@
}

// add behavior to split elements
var splitCheck = $("split_toggle");
var splitCheck = document.getElementById("split_toggle");
splitCheck.checked = true;
splitCheck.onclick = function() {
if(splitCheck.checked) {
split.activate();
$("split_options").style.display = "block";
document.getElementById("split_options").style.display = "block";
} else {
split.deactivate();
$("split_options").style.display = "none";
document.getElementById("split_options").style.display = "none";
}
};
var edgeCheck = $("edge_toggle");
var edgeCheck = document.getElementById("edge_toggle");
edgeCheck.checked = split.edge;
edgeCheck.onclick = function() {
split.edge = edgeCheck.checked;
};

$("clear").onclick = function() {
document.getElementById("clear").onclick = function() {
modify.deactivate();
vectors.destroyFeatures();
};
Expand Down
10 changes: 5 additions & 5 deletions examples/snapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';

function init() {
initMap();
initUI();
Expand Down Expand Up @@ -194,7 +194,7 @@
* property values.
*/
function initUI() {
var check = $("snapping");
var check = document.getElementById("snapping");
check.checked = true;
check.onclick = function() {
if(check.checked) {
Expand All @@ -204,7 +204,7 @@
}
};

var sel = $("editable");
var sel = document.getElementById("editable");
sel.value = "poly";
sel.onchange = function() {
updateEditable(sel.value);
Expand All @@ -216,12 +216,12 @@
target = snap.targets[i];
for(var j=0; j<types.length; ++j) {
type = types[j];
tog = $(i + "_" + type);
tog = document.getElementById(i + "_" + type);
tog.checked = target[type];
tog.onclick = (function(tog, type, target) {
return function() {target[type] = tog.checked;}
})(tog, type, target);
tol = $(i + "_" + type + "Tolerance");
tol = document.getElementById(i + "_" + type + "Tolerance");
tol.value = target[type + "Tolerance"];
tol.onchange = (function(tol, type, target) {
return function() {
Expand Down
4 changes: 2 additions & 2 deletions examples/strategy-cluster-extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ var map, vectorlayer, features, stylemap, select;
} else {
info += '&nbsp;&nbsp;Single feature of clazz = ' + feature.attributes.clazz;
}
$('info').innerHTML = info;
document.getElementById('info').innerHTML = info;
};

// The function that gets called on feature selection. Shows information
// about the number of "points" on the map.
var updateGeneralInformation = function() {
var info = 'Currently ' + vectorlayer.features.length + ' points are shown on the map.';
$('generalinfo').innerHTML = info;
document.getElementById('generalinfo').innerHTML = info;
};

// instanciate the map
Expand Down
13 changes: 6 additions & 7 deletions examples/strategy-cluster-threshold.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">

// create a semi-random grid of features to be clustered
var dx = 3;
var dy = 3;
Expand Down Expand Up @@ -90,24 +89,24 @@
map.setCenter(new OpenLayers.LonLat(0, 0), 2);

reset();
$("reset").onclick = reset;
document.getElementById("reset").onclick = reset;

}

function reset() {
var distance = parseInt($("distance").value);
var threshold = parseInt($("threshold").value);
var distance = parseInt(document.getElementById("distance").value);
var threshold = parseInt(document.getElementById("threshold").value);
strategy.distance = distance || strategy.distance;
strategy.threshold = threshold || strategy.threshold;
$("distance").value = strategy.distance;
$("threshold").value = strategy.threshold || "null";
document.getElementById("distance").value = strategy.distance;
document.getElementById("threshold").value = strategy.threshold || "null";
clusters.removeFeatures(clusters.features);
clusters.addFeatures(features);
}

function display(event) {
var f = event.feature;
var el = $("output");
var el = document.getElementById("output");
if(f.cluster) {
el.innerHTML = "cluster of " + f.attributes.count;
} else {
Expand Down
17 changes: 9 additions & 8 deletions examples/strategy-cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<script src="Jugl.js"></script>
<script src="animator.js"></script>
<script type="text/javascript">

var map, template;

/**
Expand Down Expand Up @@ -171,21 +172,21 @@

function display(event) {
// clear previous photo list and create new one
$("photos").innerHTML = "";
document.getElementById("photos").innerHTML = "";
var node = template.process({
context: {features: event.feature.cluster},
clone: true,
parent: $("photos")
parent: document.getElementById("photos")
});
// set up forward/rewind
var forward = Animator.apply($("list"), ["start", "end"], {duration: 1500});
$("scroll-end").onmouseover = function() {forward.seekTo(1)};
$("scroll-end").onmouseout = function() {forward.seekTo(forward.state)};
$("scroll-start").onmouseover = function() {forward.seekTo(0)};
$("scroll-start").onmouseout = function() {forward.seekTo(forward.state)};
var forward = Animator.apply(document.getElementById("list"), ["start", "end"], {duration: 1500});
document.getElementById("scroll-end").onmouseover = function() {forward.seekTo(1)};
document.getElementById("scroll-end").onmouseout = function() {forward.seekTo(forward.state)};
document.getElementById("scroll-start").onmouseover = function() {forward.seekTo(0)};
document.getElementById("scroll-start").onmouseout = function() {forward.seekTo(forward.state)};
// set up photo zoom
for(var i=0; i<event.feature.cluster.length; ++i) {
listen($("link-" + i), Animator.apply($("photo-" + i), ["thumb", "big"]));
listen(document.getElementById("link-" + i), Animator.apply(document.getElementById("photo-" + i), ["thumb", "big"]));
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tilecache.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script type="text/javascript">
var map, layer;
function init(){
map = new OpenLayers.Map( $('map'), {
map = new OpenLayers.Map( 'map', {
resolutions: [0.087890625, 0.0439453125, 0.02197265625, 0.010986328125]
});
layer = new OpenLayers.Layer.TileCache("TileCache Layer",
Expand Down
Loading

0 comments on commit 366faf6

Please sign in to comment.