Skip to content

Commit f4549ad

Browse files
authored
Merge pull request #159 from projectblacklight/osd-fixes
Openseadragon fixes
2 parents 997fc63 + 5fb448c commit f4549ad

File tree

3 files changed

+75
-17
lines changed

3 files changed

+75
-17
lines changed

app/components/blacklight/gallery/openseadragon_embed_component.html.erb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<div class="osd-toolbar row">
33
<div class="col-md-6 pagination">
44
<% if count > 1 %>
5-
<% osd_config = osd_config_referencestrip.merge(osd_config) %>
6-
<a id="<%= id_prefix %>-previous"><%= render Blacklight::Gallery::Icons::ChevronLeftComponent.new %></a>
7-
<span id="<%= id_prefix %>-page">1</span> of <%= count %>
8-
<a id="<%= id_prefix %>-next"><%= render Blacklight::Gallery::Icons::ChevronRightComponent.new %></a>
5+
<% multi_page_osd_config = osd_config_referencestrip.merge(osd_config) %>
6+
<a id="<%= @id_prefix %>-previous"><%= render Blacklight::Gallery::Icons::ChevronLeftComponent.new %></a>
7+
<span id="<%= @id_prefix %>-page">1</span>&nbsp; of <%= count %>
8+
<a id="<%= @id_prefix %>-next"><%= render Blacklight::Gallery::Icons::ChevronRightComponent.new %></a>
99
<% end %>
1010
</div>
1111
<div class="col-md-6 controls">
12-
<a id="<%= id_prefix %>-zoom-in"><%= render Blacklight::Gallery::Icons::AddCircleComponent.new %></a>
13-
<a id="<%= id_prefix %>-zoom-out"><%= render Blacklight::Gallery::Icons::RemoveCircleComponent.new %></a>
14-
<a id="<%= id_prefix %>-home"><%= render Blacklight::Gallery::Icons::ResizeSmallComponent.new %></a>
15-
<a id="<%= id_prefix %>-full-page"><%= render Blacklight::Gallery::Icons::CustomFullscreenComponent.new %></a>
12+
<a id="<%= @id_prefix %>-zoom-in"><%= render Blacklight::Gallery::Icons::AddCircleComponent.new %></a>
13+
<a id="<%= @id_prefix %>-zoom-out"><%= render Blacklight::Gallery::Icons::RemoveCircleComponent.new %></a>
14+
<a id="<%= @id_prefix %>-home"><%= render Blacklight::Gallery::Icons::ResizeSmallComponent.new %></a>
15+
<a id="<%= @id_prefix %>-full-page"><%= render Blacklight::Gallery::Icons::CustomFullscreenComponent.new %></a>
1616
</div>
1717
</div>
18-
<%= helpers.openseadragon_picture_tag image, class: 'osd-image row', data: { openseadragon: osd_config } %>
18+
<%= helpers.openseadragon_picture_tag image, class: 'osd-image row', data: { openseadragon: multi_page_osd_config ? multi_page_osd_config : osd_config } %>
1919
</div>

app/components/blacklight/gallery/openseadragon_embed_component.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def initialize(document:, presenter:, view_config: nil, classes: [], **kwargs)
1212
@presenter = presenter
1313
@view_config = view_config
1414
@classes = classes
15+
@id_prefix = id_prefix
1516
end
1617

1718
def image
@@ -33,21 +34,20 @@ def render?
3334
def osd_config
3435
{
3536
crossOriginPolicy: false,
36-
zoomInButton: "#{id_prefix}-zoom-in",
37-
zoomOutButton: "#{id_prefix}-zoom-out",
38-
homeButton: "#{id_prefix}-home",
39-
fullPageButton: "#{id_prefix}-full-page",
40-
nextButton: "#{id_prefix}-next",
41-
previousButton: "#{id_prefix}-previous"
37+
zoomInButton: "#{@id_prefix}-zoom-in",
38+
zoomOutButton: "#{@id_prefix}-zoom-out",
39+
homeButton: "#{@id_prefix}-home",
40+
fullPageButton: "#{@id_prefix}-full-page",
41+
nextButton: "#{@id_prefix}-next",
42+
previousButton: "#{@id_prefix}-previous"
4243
}
4344
end
4445

4546
def osd_config_referencestrip
4647
{
4748
showReferenceStrip: true,
48-
referenceStripPosition: 'OUTSIDE',
49+
sequenceMode: true,
4950
referenceStripScroll: 'vertical',
50-
referenceStripWidth: 100,
5151
referenceStripBackgroundColor: 'transparent'
5252
}
5353
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
RSpec.describe Blacklight::Gallery::OpenseadragonEmbedComponent, type: :component do
6+
subject(:component) do
7+
described_class.new(
8+
document: document,
9+
presenter: presenter,
10+
**attr
11+
)
12+
end
13+
14+
let(:attr) { {} }
15+
let(:view_context) { vc_test_controller.view_context }
16+
let(:render) do
17+
component.render_in(view_context)
18+
end
19+
20+
let(:rendered) do
21+
Capybara::Node::Simple.new(render)
22+
end
23+
24+
let(:document) do
25+
SolrDocument.new(
26+
id: 'x'
27+
)
28+
end
29+
30+
let(:presenter) { Blacklight::IndexPresenter.new(document, view_context, blacklight_config) }
31+
32+
before do
33+
allow(view_context).to receive(:current_search_session).and_return(nil)
34+
allow(view_context).to receive(:search_session).and_return({})
35+
allow(view_context).to receive(:blacklight_config).and_return(blacklight_config)
36+
end
37+
38+
describe 'openseadragon viewer' do
39+
let(:blacklight_config) do
40+
Blacklight::Configuration.new.tap do |config|
41+
config.index.slideshow_method = :xyz
42+
if Blacklight::VERSION > '8'
43+
config.track_search_session.storage = false
44+
else
45+
config.track_search_session = false
46+
end
47+
end
48+
end
49+
it 'uses a single @id_prefix to generate unique control ids' do
50+
expect(component.osd_config[:zoomInButton]).to include(component.instance_variable_get(:@id_prefix))
51+
expect(component.osd_config[:zoomOutButton]).to include(component.instance_variable_get(:@id_prefix))
52+
expect(component.osd_config[:homeButton]).to include(component.instance_variable_get(:@id_prefix))
53+
expect(component.osd_config[:fullPageButton]).to include(component.instance_variable_get(:@id_prefix))
54+
expect(component.osd_config[:nextButton]).to include(component.instance_variable_get(:@id_prefix))
55+
expect(component.osd_config[:previousButton]).to include(component.instance_variable_get(:@id_prefix))
56+
end
57+
end
58+
end

0 commit comments

Comments
 (0)