X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eebe1f1d3ed885e94725c07d24e0483f603f03da..bab796bc7eb0b44eeb15d6fee567440647bc57e0:/app/assets/javascripts/leaflet.share.js?ds=sidebyside diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 548be3fcc..664aebaa5 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -14,37 +14,68 @@ L.OSM.share = function (options) { .appendTo($container); var $ui = $('
') - .attr('class', 'share-ui') - .appendTo(options.uiPane); + .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); + function toggle(e) { e.stopPropagation(); e.preventDefault(); - - var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right'); - - if ($ui.is(':visible')) { - $(control.options.uiPane).hide(); - controlContainer.css({paddingRight: '0'}); - } else { - $(control.options.uiPane).show(); - controlContainer.css({paddingRight: '200px'}); - } + 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];