X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2a9286a16a0ca0e6aa025b13771d3118040b9d60..7094370208712e77d92ea2ad0d76e160742d6c0a:/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 7d5eb0cc9..b808bc435 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -1,65 +1,75 @@ -//= require templates/map/share +L.OSM.share = function (options) { + var control = L.control(options); -L.Control.Share = L.Control.extend({ - options: { - position: 'topright', - title: 'Share', - url: function(map) { - return ''; - } - }, + control.onAdd = function (map) { + var $container = $('
') + .attr('class', 'control-share'); - onAdd: function (map) { - var className = 'leaflet-control-locate', - classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control', - container = L.DomUtil.create('div', classNames); + $('') + .attr('class', 'control-button') + .attr('href', '#') + .attr('title', 'Share') + .html('') + .on('click', toggle) + .appendTo($container); - var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container); - link.href = '#'; - link.title = this.options.title; + var $ui = $('
') + .attr('class', 'share-ui'); - this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container); + $('
') + .attr('class', 'sidebar_heading') + .appendTo($ui) + .append( + $('') + .text(I18n.t('javascripts.close')) + .attr('class', 'sidebar_close') + .attr('href', '#') + .bind('click', toggle)) + .append( + $('

') + .text(I18n.t('javascripts.share.title'))); - L.DomEvent - .on(this._uiPane, 'click', L.DomEvent.stopPropagation) - .on(this._uiPane, 'click', L.DomEvent.preventDefault) - .on(this._uiPane, 'dblclick', L.DomEvent.preventDefault); + var $linkSection = $('
') + .attr('class', 'section share-link') + .appendTo($ui); - var h2 = L.DomUtil.create('h2', '', this._uiPane); - h2.innerHTML = I18n.t('javascripts.share.title'); + $('

') + .text(I18n.t('javascripts.share.link')) + .appendTo($linkSection); - this._linkInput = L.DomUtil.create('input', '', this._uiPane); + var $shortLink, $longLink; - L.DomEvent - .on(link, 'click', L.DomEvent.stopPropagation) - .on(link, 'click', L.DomEvent.preventDefault) - .on(link, 'click', this._toggle, this) - .on(link, 'dblclick', L.DomEvent.stopPropagation); + $('