Change richtext edit/preview buttons type to non-submit
This commit is contained in:
parent
3cc0458468
commit
2ba7eab67d
3 changed files with 10 additions and 14 deletions
|
@ -21,7 +21,7 @@ $(document).ready(function () {
|
|||
* Install a click handler to switch to edit mode when the
|
||||
* edit button is pressed.
|
||||
*/
|
||||
$(".richtext_doedit").click(function (event) {
|
||||
$(".richtext_doedit").click(function () {
|
||||
var editor = $(this).parents(".richtext_container").find("textarea");
|
||||
var preview = $(this).parents(".richtext_container").find(".richtext_preview");
|
||||
|
||||
|
@ -30,15 +30,13 @@ $(document).ready(function () {
|
|||
|
||||
$(this).siblings(".richtext_dopreview").prop("disabled", false);
|
||||
$(this).prop("disabled", true);
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
/*
|
||||
* Install a click handler to switch to preview mode when the
|
||||
* preview button is pressed.
|
||||
*/
|
||||
$(".richtext_dopreview").click(function (event) {
|
||||
$(".richtext_dopreview").click(function () {
|
||||
var editor = $(this).parents(".richtext_container").find("textarea");
|
||||
var preview = $(this).parents(".richtext_container").find(".richtext_preview");
|
||||
var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height();
|
||||
|
@ -60,7 +58,5 @@ $(document).ready(function () {
|
|||
|
||||
$(this).siblings(".richtext_doedit").prop("disabled", false);
|
||||
$(this).prop("disabled", true);
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<div class="card bg-body-tertiary h-100">
|
||||
<div class="card-body">
|
||||
<%= render :partial => "shared/#{type}_help" %>
|
||||
<%= submit_tag t(".edit"), :id => "#{id}_doedit", :class => "richtext_doedit btn btn-primary", :disabled => true %>
|
||||
<%= submit_tag t(".preview"), :id => "#{id}_dopreview", :class => "richtext_dopreview btn btn-primary" %>
|
||||
<%= 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" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -119,9 +119,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
|
||||
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
|
||||
assert_select "input[name=commit][type=submit][value=Publish]", :count => 1
|
||||
assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
|
||||
assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
|
||||
assert_select "input", :count => 6
|
||||
assert_select "button[type=button]", :text => "Edit", :count => 1
|
||||
assert_select "button[type=button]", :text => "Preview", :count => 1
|
||||
assert_select "input", :count => 4
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -272,9 +272,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
|
||||
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
|
||||
assert_select "input[name=commit][type=submit][value=Update]", :count => 1
|
||||
assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
|
||||
assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
|
||||
assert_select "input", :count => 7
|
||||
assert_select "button[type=button]", :text => "Edit", :count => 1
|
||||
assert_select "button[type=button]", :text => "Preview", :count => 1
|
||||
assert_select "input", :count => 5
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue