]> git.openstreetmap.org Git - rails.git/commitdiff
Toggle between Link / Short Link / HTML
authorJohn Firebaugh <john.firebaugh@gmail.com>
Wed, 31 Jul 2013 19:19:59 +0000 (12:19 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 5 Aug 2013 15:31:47 +0000 (08:31 -0700)
app/assets/javascripts/leaflet.share.js
app/assets/stylesheets/common.css.scss
config/locales/en.yml

index 15e4a722989f029065d5b1053c8285f49e979780..a32dfc20bbfeb3c1e5881572efeb8f9942704d4b 100644 (file)
@@ -34,7 +34,7 @@ L.OSM.share = function (options) {
         $('<h4>')
           .text(I18n.t('javascripts.share.title')));
 
-    // Link
+    // Link / Embed
 
     var $linkSection = $('<div>')
       .attr('class', 'section share-link')
@@ -62,11 +62,31 @@ L.OSM.share = function (options) {
           .append(I18n.t('javascripts.share.include_marker')));
 
     $('<div>')
-      .attr('class', 'form-row')
+      .attr('class', 'share-tabs')
       .appendTo($form)
       .append($('<label>')
+        .attr('class', 'active')
         .attr('for', 'long_input')
         .text(I18n.t('javascripts.share.long_link')))
+      .append($('<label>')
+        .attr('for', 'short_input')
+        .text(I18n.t('javascripts.share.short_link')))
+      .append($('<label>')
+        .attr('for', 'embed_html')
+        .text(I18n.t('javascripts.share.embed')))
+      .on('click', 'label', function() {
+        var id = '#' + $(this).attr('for');
+        $linkSection.find('.share-tabs label')
+          .removeClass('active');
+        $(this).addClass('active');
+        $linkSection.find('.share-tab').hide();
+        $linkSection.find('.share-tab:has(' + id + ')').show();
+      });
+
+    $('<div>')
+      .attr('class', 'form-row share-tab')
+      .css('display', 'block')
+      .appendTo($form)
       .append($('<input>')
         .attr('id', 'long_input')
         .attr('type', 'text')
@@ -78,11 +98,8 @@ L.OSM.share = function (options) {
           .attr('class', 'icon link')));
 
     $('<div>')
-      .attr('class', 'form-row')
+      .attr('class', 'form-row share-tab')
       .appendTo($form)
-      .append($('<label>')
-        .attr('for', 'short_input')
-        .text(I18n.t('javascripts.share.short_link')))
       .append($('<input>')
         .attr('id', 'short_input')
         .attr('type', 'text')
@@ -93,31 +110,18 @@ L.OSM.share = function (options) {
         .append($('<span>')
           .attr('class', 'icon link')));
 
-    // Embed
-
-    var $embedSection = $('<div>')
-      .attr('class', 'section share-embed')
-      .appendTo($ui);
-
-    var $form = $('<form>')
-      .attr('class', 'standard-form')
-      .appendTo($embedSection);
-
     $('<div>')
-      .attr('class', 'form-row')
+      .attr('class', 'form-row share-tab')
       .appendTo($form)
-      .append($('<label>')
-        .attr('for', 'embed_html')
-        .text(I18n.t('javascripts.share.embed')))
       .append(
         $('<textarea>')
           .attr('id', 'embed_html')
-          .on('click', select));
-
-    $('<p>')
-      .attr('class', 'deemphasize')
-      .text(I18n.t('javascripts.share.paste_html'))
-      .appendTo($linkSection);
+          .on('click', select))
+      .append(
+        $('<p>')
+          .attr('class', 'deemphasize')
+          .text(I18n.t('javascripts.share.paste_html'))
+          .appendTo($linkSection));
 
     // Image
 
index bd313fe334d8c0a6110eeecfe9eea5c523cae69a..acd195a3dc0dd622a10110dc70cc65f972603091 100644 (file)
@@ -637,6 +637,33 @@ a.donate {
 }
 
 .share-ui {
+  .share-tabs {
+    margin-bottom: 10px;
+
+    label {
+      background-color: $lightblue;
+      padding: 5px 10px;
+    }
+
+    label:first-child {
+      border-right: 1px solid #fff;
+      border-radius: 4px 0 0 4px;
+    }
+
+    label:last-child {
+      border-left: 1px solid #fff;
+      border-radius: 0 4px 4px 0;
+    }
+
+    label.active {
+      background-color: $blue;
+    }
+  }
+
+  .share-tab {
+    display: none;
+  }
+
   .share-link {
     #long_input,
     #short_input {
index ae6f801916423479534903b096ed818f6bfc3e9c..7d417fecc3c15c6baa14304f294edd1be864689f 100644 (file)
@@ -2053,9 +2053,9 @@ en:
       cancel: "Cancel"
       image: "Image"
       link: "Link or HTML"
+      long_link: "Link"
       short_link: "Short Link"
-      long_link: "Long Link"
-      embed: "Embeddable HTML"
+      embed: "HTML"
       custom_dimensions: "Set custom dimensions"
       format: "Format"
       scale: "Scale"