X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/7b626f31be8a5f60d285d39d9b1063de776ddfe0..258e66299ac45c4dbb951dee0a92194301b31737:/app/assets/javascripts/application.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index dcc5d43f8..225ddaf44 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,271 +1,142 @@ //= require jquery //= require jquery_ujs -//= require jquery.autogrowtextarea //= require jquery.timers +//= require jquery.cookie +//= require jquery.throttle-debounce //= require augment -//= require openlayers +//= require osm +//= require leaflet +//= require leaflet.osm +//= require leaflet.hash +//= require leaflet.zoom +//= require leaflet.extend +//= require leaflet.locationfilter //= require i18n/translations -//= require globals -//= require browse -//= require export +//= require oauth +//= require piwik //= require map //= require menu +//= require sidebar +//= require richtext +//= require geocoder +//= require querystring -if ( !Array.prototype.forEach ) { - Array.prototype.forEach = function(fn, scope) { - for(var i = 0, len = this.length; i < len; ++i) { - fn.call(scope || this, this[i], i, this); - } - } -} - -/* - * Called as the user scrolls/zooms around to aniplate hrefs of the - * view tab and various other links - */ -function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) { - var decimals = Math.pow(10, Math.floor(zoom/3)); - var node; - - lat = Math.round(lat * decimals) / decimals; - lon = Math.round(lon * decimals) / decimals; - - if (minlon) { - minlon = Math.round(minlon * decimals) / decimals; - minlat = Math.round(minlat * decimals) / decimals; - maxlon = Math.round(maxlon * decimals) / decimals; - maxlat = Math.round(maxlat * decimals) / decimals; - } - - $(".geolink").each(function (index, link) { - var args = getArgs(link.href); - - if ($(link).hasClass("llz")) { - args.lat = lat; - args.lon = lon; - args.zoom = zoom; - } else if (minlon && $(link).hasClass("bbox")) { - args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat; - } - - if (layers && $(link).hasClass("layers")) { - args.layers = layers; - } - - if (objtype && $(link).hasClass("object")) { - args[objtype] = objid; - } - - var classes = $(link).attr("class").split(" "); +var querystring = require('querystring-component'); - $(classes).each(function (index, classname) { - if (match = classname.match(/^minzoom([0-9]+)$/)) { - var minzoom = match[1]; - var name = link.id.replace(/anchor$/, ""); +function zoomPrecision(zoom) { + return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); +} - $(link).off("click.minzoom"); +function normalBounds(bounds) { + if (bounds instanceof L.LatLngBounds) return bounds; + return new L.LatLngBounds( + new L.LatLng(bounds[0][0], bounds[0][1]), + new L.LatLng(bounds[1][0], bounds[1][1])); +} - if (zoom >= minzoom) { - $(link).attr("title", I18n.t("javascripts.site." + name + "_tooltip")); - $(link).removeClass("disabled"); - } else { - $(link).on("click.minzoom", function () { alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false; }); - $(link).attr("title", I18n.t("javascripts.site." + name + "_disabled_tooltip")); - $(link).addClass("disabled"); - } - } +function remoteEditHandler(bbox, select) { + var loaded = false, + query = { + left: bbox.getWest() - 0.0001, + top: bbox.getNorth() + 0.0001, + right: bbox.getEast() + 0.0001, + bottom: bbox.getSouth() - 0.0001 + }; + + if (select) query.select = select; + + var iframe = $('