From: Anton Khorev Date: Fri, 7 Jun 2024 14:38:03 +0000 (+0300) Subject: Convert richtext edit/preview buttons into tabs X-Git-Tag: live~266^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/ef5352332e02c2f3a9c9d5cc7594ec8da02cb64e Convert richtext edit/preview buttons into tabs --- diff --git a/app/assets/javascripts/richtext.js b/app/assets/javascripts/richtext.js index 70909243b..cfba5c923 100644 --- a/app/assets/javascripts/richtext.js +++ b/app/assets/javascripts/richtext.js @@ -14,9 +14,6 @@ $(document).ready(function () { /* Disable all the edit buttons */ $(".richtext_doedit").prop("disabled", true); - /* Enable the preview buttons */ - $(".richtext_dopreview").prop("disabled", false); - /* * Install a click handler to switch to edit mode when the * edit button is pressed. @@ -28,8 +25,8 @@ $(document).ready(function () { preview.hide(); editor.show(); - $(this).siblings(".richtext_dopreview").prop("disabled", false); - $(this).prop("disabled", true); + $(this).parents(".richtext_container").find(".richtext_dopreview").prop("disabled", false).removeClass("active"); + $(this).prop("disabled", true).addClass("active"); }); /* @@ -56,7 +53,7 @@ $(document).ready(function () { preview.css("min-height", minHeight + "px"); preview.show(); - $(this).siblings(".richtext_doedit").prop("disabled", false); - $(this).prop("disabled", true); + $(this).parents(".richtext_container").find(".richtext_doedit").prop("disabled", false).removeClass("active"); + $(this).prop("disabled", true).addClass("active"); }); }); diff --git a/app/views/shared/_richtext_field.html.erb b/app/views/shared/_richtext_field.html.erb index 6f5b6d3d9..74d609cd5 100644 --- a/app/views/shared/_richtext_field.html.erb +++ b/app/views/shared/_richtext_field.html.erb @@ -1,5 +1,13 @@
+ <%= builder.text_area(attribute, options.merge(:wrapper => false, "data-preview-url" => preview_url(:type => type))) %>
@@ -7,8 +15,6 @@
<%= render :partial => "shared/#{type}_help" %> - <%= button_tag t(".edit"), :type => "button", :id => "#{id}_doedit", :class => "richtext_doedit btn btn-primary", :disabled => true %> - <%= button_tag t(".preview"), :type => "button", :id => "#{id}_dopreview", :class => "richtext_dopreview btn btn-primary" %>