diff --git a/app/views/bookmarks/_bookmark_blurb.html.erb b/app/views/bookmarks/_bookmark_blurb.html.erb
index 8a35ee3da2..597b827c5d 100644
--- a/app/views/bookmarks/_bookmark_blurb.html.erb
+++ b/app/views/bookmarks/_bookmark_blurb.html.erb
@@ -4,7 +4,7 @@
<% if bookmarkable.blank? %>
- <%= ts("This has been deleted, sorry!") %>
+ <%= t(".deleted") %>
<% # Bookmarks of deleted items need a div because they can still be edited. %>
<% else %>
@@ -25,9 +25,9 @@
<% if logged_in? && !is_author_of?(bookmark) %>
<% if (current_user_bookmark ||= bookmark_if_exists(bookmarkable)) %>
- <%= link_to ts("Saved"), edit_bookmark_path(current_user_bookmark), id: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
+ <%= link_to t(".saved"), edit_bookmark_path(current_user_bookmark), data: { path: edit_bookmark_path(current_user_bookmark) }, class: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
<% else %>
- <%= link_to ts("Save"), get_new_bookmark_path(bookmarkable), id: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
+ <%= link_to t(".save"), get_new_bookmark_path(bookmarkable), class: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
<% end %>
<% end %>
diff --git a/app/views/bookmarks/_bookmark_owner_navigation.html.erb b/app/views/bookmarks/_bookmark_owner_navigation.html.erb
index b3bf21ef81..b674b37bb2 100644
--- a/app/views/bookmarks/_bookmark_owner_navigation.html.erb
+++ b/app/views/bookmarks/_bookmark_owner_navigation.html.erb
@@ -1,12 +1,12 @@
<% # expects "bookmark" %>
<% bookmark_form_id = (bookmark.bookmarkable.blank? ? "#{bookmark.id}" : "#{bookmark.bookmarkable.id}") %>
- - <%= link_to ts("Edit"), edit_bookmark_path(bookmark), id: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
- - <%= link_to ts("Delete"), confirm_delete_bookmark_path(bookmark), data: {confirm: ts('Are you sure you want to delete this bookmark?')} %>
+ - <%= link_to t(".edit"), edit_bookmark_path(bookmark), data: { path: edit_bookmark_path(bookmark) }, class: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
+ - <%= link_to t(".delete"), confirm_delete_bookmark_path(bookmark), data: { confirm: t(".delete_confirmation") } %>
- <%= collection_link(bookmark) %>
<% if bookmark.bookmarkable.is_a?(Work) && !bookmark.bookmarkable.unrevealed? %>
-
- <%= link_to_modal ts("Share"), for: share_bookmark_path(bookmark), title: ts("Share Bookmark") %>
+ <%= link_to_modal t(".share"), for: share_bookmark_path(bookmark), title: t(".share_bookmark") %>
<% end %>
diff --git a/app/views/bookmarks/_bookmarkable_blurb.html.erb b/app/views/bookmarks/_bookmarkable_blurb.html.erb
index 672f57e087..806126adfc 100644
--- a/app/views/bookmarks/_bookmarkable_blurb.html.erb
+++ b/app/views/bookmarks/_bookmarkable_blurb.html.erb
@@ -16,15 +16,9 @@
-
<% if current_user_bookmark ||= bookmark_if_exists(unwrapped) %>
- <%= link_to ts("Saved"),
- edit_bookmark_path(current_user_bookmark),
- id: "bookmark_form_trigger_for_#{bookmarkable.id}",
- remote: true %>
+ <%= link_to t(".saved"), edit_bookmark_path(current_user_bookmark), data: { path: edit_bookmark_path(current_user_bookmark) }, class: "bookmark_form_trigger_for_#{bookmarkable.id}", remote: true %>
<% else %>
- <%= link_to ts("Save"),
- new_polymorphic_path([bookmarkable, Bookmark]),
- id: "bookmark_form_trigger_for_#{bookmarkable.id}",
- remote: true %>
+ <%= link_to t(".save"), new_polymorphic_path([bookmarkable, Bookmark]), class: "bookmark_form_trigger_for_#{bookmarkable.id}", remote: true %>
<% end %>
diff --git a/app/views/bookmarks/bookmark_form_dynamic.js.erb b/app/views/bookmarks/bookmark_form_dynamic.js.erb
index c969550460..da09bea436 100644
--- a/app/views/bookmarks/bookmark_form_dynamic.js.erb
+++ b/app/views/bookmarks/bookmark_form_dynamic.js.erb
@@ -2,21 +2,19 @@
<% bookmark_form_id = (@bookmarkable.blank? ? "#{@bookmark.id}" : "#{@bookmarkable.id}") %>
var bookmark_div = $j('#bookmark_form_placement_for_<%= bookmark_form_id %>');
-var bookmark_close = $j('#bookmark_form_close_for_<%= bookmark_form_id %>');
-var bookmark_open = $j('#bookmark_form_trigger_for_<%= bookmark_form_id %>');
-bookmark_div.html("<%= escape_javascript(render "bookmarks/bookmark_form", :bookmarkable => @bookmarkable, :bookmark => @bookmark, :button_name => @button_name, :action => @action, :in_page => true, :dynamic => true) %>");
-bookmark_open.hide();
+if (!bookmark_div.children().length) { bookmark_div.html("<%= escape_javascript(render "bookmarks/bookmark_form", :bookmarkable => @bookmarkable, :bookmark => @bookmark, :button_name => @button_name, :action => @action, :in_page => true, :dynamic => true) %>"); }
+$j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').hide();
-$j('#bookmark_form_close_for_<%= bookmark_form_id %>').click(function(){
- bookmark_div.hide();
- bookmark_open.show();
+$j('#bookmark_form_close_for_<%= bookmark_form_id %>').click(function(){
+ $j('#bookmark_form_placement_for_<%= bookmark_form_id %>').hide();
+ $j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').show();
+ $j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').attr('href', j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').attr("data-path"));
});
// if canceled we don't want to generate the form a second time, just reopen it
-bookmark_open.attr('href', '#');
-$j("#bookmark_form_trigger_for_<%= bookmark_form_id %>").click(function(event){
- bookmark_div.show();
- bookmark_open.hide();
+$j(".bookmark_form_trigger_for_<%= bookmark_form_id %>").click(function(event){
+ $j('#bookmark_form_placement_for_<%= bookmark_form_id %>').show();
+ $j('.bookmark_form_trigger_for_<%= bookmark_form_id %>').hide();
event.preventDefault();
-});
+});
\ No newline at end of file
diff --git a/app/views/bookmarks/index.html.erb b/app/views/bookmarks/index.html.erb
index baeb832202..7293d1419f 100755
--- a/app/views/bookmarks/index.html.erb
+++ b/app/views/bookmarks/index.html.erb
@@ -14,23 +14,23 @@
<% if current_user.is_a?(User) || @tag || @facets.present? %>
<% if logged_in? && (@user == current_user || (@owner.blank? && @bookmarkable.blank?) || @collection) %>
- - <%= link_to ts("Bookmark External Work"), new_external_work_path %>
+ - <%= link_to t(".navigation.new_external_work"), new_external_work_path %>
<% elsif params[:work_id] || params[:series_id] || params[:external_work_id] %>
<% bookmark_form_id = (@bookmarkable.blank? ? "#{@bookmark.id}" : "#{@bookmarkable.id}") %>
<% # let the user reading this bookmark save a copy for themselves %>
<% if logged_in? && !is_author_of?(@bookmark) %>
-
<% if (current_user_bookmark ||= bookmark_if_exists(@bookmarkable)) %>
- <%= link_to ts("Edit Bookmark"), edit_bookmark_path(current_user_bookmark), :id => "bookmark_form_trigger_for_#{bookmark_form_id}", :remote => true %>
+ <%= link_to t(".navigation.edit"), edit_bookmark_path(current_user_bookmark), data: { path: edit_bookmark_path(current_user_bookmark) }, class: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
<% else %>
- <%= link_to ts("Bookmark"), get_new_bookmark_path(@bookmarkable), :id => "bookmark_form_trigger_for_#{bookmark_form_id}", :remote => true %>
+ <%= link_to t(".navigation.new"), get_new_bookmark_path(@bookmarkable), class: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %>
<% end %>
<% end %>
<% end %>
<% if @tag %>
- - <%= span_if_current ts('Works'), tag_works_path(@tag) %>
- - <%= span_if_current ts('Bookmarks'), tag_bookmarks_path(@tag) %>
+ - <%= span_if_current t(".navigation.works"), tag_works_path(@tag) %>
+ - <%= span_if_current t(".navigation.bookmarks"), tag_bookmarks_path(@tag) %>
<% end %>
<% if @facets.present? %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml
index 7a83d4b383..a4022afea4 100644
--- a/config/locales/views/en.yml
+++ b/config/locales/views/en.yml
@@ -536,8 +536,21 @@ en:
hide_works: hide their works or bookmarks from you
intro: 'Blocking a user will not:'
bookmarks:
+ bookmark_blurb:
+ deleted: This has been deleted, sorry!
+ save: Save
+ saved: Saved
+ bookmark_owner_navigation:
+ delete: Delete
+ delete_confirmation: Are you sure you want to delete this bookmark?
+ edit: Edit
+ share: Share
+ share_bookmark: Share Bookmark
bookmark_user_module:
bookmarked_by_html: Bookmarked by %{pseud_link}
+ bookmarkable_blurb:
+ save: Save
+ saved: Saved
filters:
from: From
to: To
@@ -545,6 +558,12 @@ en:
index:
advanced_search: try our advanced search
choose_fandom: choose a fandom
+ navigation:
+ bookmarks: Bookmarks
+ edit: Edit Bookmark
+ new: Boorkmark
+ new_external_work: Bookmark External Work
+ works: Works
recent_bookmarks_html: These are some of the latest bookmarks created on the Archive. To find more bookmarks, %{choose_fandom_link} or %{advanced_search_link}.
search_form:
word_count: Word count
diff --git a/features/bookmarks/bookmark_javascript.feature b/features/bookmarks/bookmark_javascript.feature
new file mode 100644
index 0000000000..bcbbd291b7
--- /dev/null
+++ b/features/bookmarks/bookmark_javascript.feature
@@ -0,0 +1,41 @@
+@bookmarks
+Feature: Edit bookmarks with javascript enabled
+ In order to have a good user experience
+ As a humble user
+ I want to be able to edit bookmarks with javascript enabled
+
+ Background:
+ Given a canonical fandom "The Bookmarks"
+ And the work "Bookmark: The Beginnings" by "bookmarker" with fandom "The Bookmarks"
+ And the work "Bookmark: The Sequel" by "bookmarker" with fandom "The Bookmarks"
+ And all indexing jobs have been run
+ And the dashboard counts have expired
+ And I am logged in as "bookmarker"
+
+ @javascript
+ Scenario: Opening multiple edit forms lets you close all of them (AO3-7214)
+ Given I am logged in as "recengine"
+ And I bookmark the work "Bookmark: The Beginnings"
+ And I bookmark the work "Bookmark: The Sequel"
+ And all indexing jobs have been run
+ When I follow "Bookmarks"
+ And I follow "Edit"
+ And I follow "Edit"
+ Then I should not see "Edit"
+ When I exit the bookmark edit form
+ And I exit the bookmark edit form
+ Then I should not see "save a bookmark!"
+
+ @javascript
+ Scenario: The edit form can be reopened after closing it with "X" on some pages (AO3-7215)
+ Given I am logged in as "recengine"
+ And I bookmark the work "Bookmark: The Beginnings"
+ When I view the work "Bookmark: The Beginnings"
+ And I follow "1"
+ And I follow "Edit"
+ Then I should see "save a bookmark!"
+ And I should not see "Edit Bookmark"
+ When I exit the bookmark edit form
+ Then I should see "Edit Bookmark"
+ When I follow "Edit"
+ Then I should see "save a bookmark!"
diff --git a/features/step_definitions/bookmark_steps.rb b/features/step_definitions/bookmark_steps.rb
index 023e57f3d4..a2bc6a092d 100644
--- a/features/step_definitions/bookmark_steps.rb
+++ b/features/step_definitions/bookmark_steps.rb
@@ -425,6 +425,11 @@ def submit_bookmark_form(pseud, note, tags, collection)
visit work_path(work)
end
+# Capybara will not find links without href with the click_link method (see issue #379 on the capybara repository)
+When "I exit the bookmark edit form" do
+ find("a", text: "×").click
+end
+
When /^I add my bookmark to the collection "([^\"]*)"$/ do |collection_name|
step %{I follow "Add To Collection"}
fill_in("collection_names", with: collection_name)