]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.share.js
Auto-select share link text
[rails.git] / app / assets / javascripts / leaflet.share.js
index 773145bedfcb7257b7f14aefd6b14c08c90c4ce5..e34d5ffdb67c442d1b19fdfe6862768c4e60fe42 100644 (file)
@@ -16,21 +16,29 @@ L.OSM.share = function (options) {
     var $ui = $('<div>')
       .attr('class', 'share-ui');
 
-    $('<section>')
+    $('<header>')
+      .attr('class', 'sidebar_heading')
       .appendTo($ui)
       .append(
-      $('<h2>')
-        .text(I18n.t('javascripts.share.title')));
+        $('<a>')
+          .text(I18n.t('javascripts.close'))
+          .attr('class', 'sidebar_close')
+          .attr('href', '#')
+          .bind('click', toggle))
+      .append(
+        $('<h4>')
+          .text(I18n.t('javascripts.share.title')));
 
-    var $share_link = $('<section></section>')
+    var $share_link = $('<section>')
       .appendTo($ui);
 
-    var $title = $('<h3></h3>')
+    var $title = $('<h4>')
       .text(I18n.t('javascripts.share.link'))
       .appendTo($share_link);
 
     var $input = $('<input />')
       .attr('type', 'text')
+      .on('click', select)
       .appendTo($share_link);
 
     var $list = $('<ul>')
@@ -72,6 +80,10 @@ L.OSM.share = function (options) {
       );
     }
 
+    function select() {
+      $(this).select();
+    }
+
     return $container[0];
   };