var querystring = require('querystring-component');
-function remoteEditHandler(bbox, object) {
- var loaded = false,
- url = document.location.protocol === "https:" ?
- "https://127.0.0.1:8112/load_and_zoom?" :
- "http://127.0.0.1:8111/load_and_zoom?",
- query = {
- left: bbox.getWest() - 0.0001,
- top: bbox.getNorth() + 0.0001,
- right: bbox.getEast() + 0.0001,
- bottom: bbox.getSouth() - 0.0001
- };
-
- if (object) query.select = object.type + object.id;
-
- var iframe = $('<iframe>')
- .hide()
- .appendTo('body')
- .attr("src", url + querystring.stringify(query))
- .on('load', function() {
- $(this).remove();
- loaded = true;
- });
-
- setTimeout(function () {
- if (!loaded) {
- alert(I18n.t('site.index.remote_failed'));
- iframe.remove();
- }
- }, 1000);
-
- return false;
-}
-
/*
* Called as the user scrolls/zooms around to maniplate hrefs of the
* view tab and various other links
I18n.t('javascripts.site.edit_disabled_tooltip') : '');
}
-function escapeHTML(string) {
- var htmlEscapes = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": '''
- };
- return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
- return htmlEscapes[match];
- });
-}
-
function maximiseMap() {
$("#content").addClass("maximised");
}
map.removeLayer(marker);
}
- marker = L.marker(e.latlng, {icon: getUserIcon()}).addTo(map)
+ marker = L.marker(e.latlng, {icon: OSM.getUserIcon()}).addTo(map)
.bindPopup(I18n.t('diary_entry.edit.marker_text'));
}
map.setView(centre, params.zoom);
if ($("#latitude").val() && $("#longitude").val()) {
- marker = L.marker(centre, {icon: getUserIcon()}).addTo(map)
+ marker = L.marker(centre, {icon: OSM.getUserIcon()}).addTo(map)
.bindPopup(I18n.t('diary_entry.edit.marker_text'));
}
.addTo(map);
if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
- initializeNotes(map);
+ OSM.initializeNotes(map);
if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
map.addLayer(map.noteLayer);
}
- initializeBrowse(map);
+ OSM.initializeBrowse(map);
if (params.layers.indexOf(map.dataLayer.options.code) >= 0) {
map.addLayer(map.dataLayer);
}
map.setView([params.lat, params.lon], params.zoom);
}
- var marker = L.marker([0, 0], {icon: getUserIcon()});
+ var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
if (params.marker) {
marker.setLatLng([params.mlat, params.mlon]).addTo(map);
marker.setLatLng(center).addTo(map);
});
+ function remoteEditHandler(bbox, object) {
+ var loaded = false,
+ url = document.location.protocol === "https:" ?
+ "https://127.0.0.1:8112/load_and_zoom?" :
+ "http://127.0.0.1:8111/load_and_zoom?",
+ query = {
+ left: bbox.getWest() - 0.0001,
+ top: bbox.getNorth() + 0.0001,
+ right: bbox.getEast() + 0.0001,
+ bottom: bbox.getSouth() - 0.0001
+ };
+
+ if (object) query.select = object.type + object.id;
+
+ var iframe = $('<iframe>')
+ .hide()
+ .appendTo('body')
+ .attr("src", url + querystring.stringify(query))
+ .on('load', function() {
+ $(this).remove();
+ loaded = true;
+ });
+
+ setTimeout(function () {
+ if (!loaded) {
+ alert(I18n.t('site.index.remote_failed'));
+ iframe.remove();
+ }
+ }, 1000);
+
+ return false;
+ }
+
$("a[data-editor=remote]").click(function(e) {
var params = OSM.mapParams(this.search);
remoteEditHandler(map.getBounds(), params.object);
-function initializeBrowse(map) {
+OSM.initializeBrowse = function (map) {
var browseBounds;
var selectedLayer;
var dataLayer = map.dataLayer;
// Stash the currently drawn feature
selectedLayer = layer;
}
-}
+};
-function initializeNotes(map) {
+OSM.initializeNotes = function (map) {
var noteLayer = map.noteLayer,
notes = {};
noteLoader = null;
}
}
-}
+};
if (!marker) {
var data = $(this).find("a.set_position").data();
- marker = L.marker([data.lat, data.lon], {icon: getUserIcon()});
+ marker = L.marker([data.lat, data.lon], {icon: OSM.getUserIcon()});
$(this).data("marker", marker);
}
}
});
-function getUserIcon(url) {
+OSM.getUserIcon = function (url) {
return L.icon({
iconUrl: url || OSM.MARKER_RED,
iconSize: [25, 41],
shadowUrl: OSM.MARKER_SHADOW,
shadowSize: [41, 41]
});
-}
+};
update();
}
+ function escapeHTML(string) {
+ var htmlEscapes = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": '''
+ };
+ return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
+ return htmlEscapes[match];
+ });
+ }
+
function update() {
var bounds = map.getBounds();
}
if ($("#map").hasClass("set_location")) {
- var marker = L.marker([0, 0], {icon: getUserIcon()});
+ var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
if (OSM.home) {
marker.setLatLng([OSM.home.lat, OSM.home.lon]);
$("[data-user]").each(function () {
var user = $(this).data('user');
if (user.lon && user.lat) {
- L.marker([user.lat, user.lon], {icon: getUserIcon(user.icon)}).addTo(map)
+ L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
.bindPopup(user.description);
}
});
L: true
OSM: true
Piwik: true
- escapeHTML: false
- getUserIcon: false
- initializeBrowse: false
- initializeNotes: false
maximiseMap: false
minimiseMap: false
querystring: false
- remoteEditHandler: false
updateLinks: false