X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a6ac56c5e510395d160cdb7ccc7a88d87403e687..1debc147b8c4d9c917d54a279dcf0e2718e0665e:/app/assets/javascripts/leaflet.share.js diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 6653a5b92..664aebaa5 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -16,13 +16,51 @@ L.OSM.share = function (options) { var $ui = $('
') .attr('class', 'share-ui'); - $('

') - .text(I18n.t('javascripts.share.title')) - .appendTo($ui); + $('
') + .appendTo($ui) + .append( + $('') + .html('»') + .attr('class', 'close-button') + .attr('href', '#') + .bind('click', toggle)) + .append( + $('

') + .text(I18n.t('javascripts.share.title'))); - var $input = $('') + var $share_link = $('
') .appendTo($ui); + var $title = $('

') + .text(I18n.t('javascripts.share.link')) + .appendTo($share_link); + + var $input = $('') + .attr('type', 'text') + .appendTo($share_link); + + var $list = $('
    ') + .appendTo($share_link); + + var $short_option = $('
  • ') + .appendTo($list); + + var $short_url_label = $('') + .attr('for', 'short_url') + .appendTo($short_option); + + var $short_url_input = $('') + .attr('id', 'short_url') + .attr('type', 'checkbox') + .prop('checked', 'checked') + .appendTo($short_url_label) + .bind('change', function() { + options.short = $(this).prop('checked'); + update(); + }); + + $short_url_label.append(I18n.t('javascripts.share.short_url')); + map.on('moveend layeradd layerremove', update); options.sidebar.addPane($ui); @@ -31,12 +69,13 @@ L.OSM.share = function (options) { e.stopPropagation(); e.preventDefault(); options.sidebar.togglePane($ui); + $input.select(); } function update() { - var center = map.getCenter().wrap(); - var layers = getMapLayers(map); - $input.val(options.getUrl(map)); + $input.val( + options.short ? options.getShortUrl(map) : options.getUrl(map) + ); } return $container[0];