Skip to content

Commit

Permalink
Merge pull request #159 from projectblacklight/osd-fixes
Browse files Browse the repository at this point in the history
Openseadragon fixes
  • Loading branch information
dnoneill authored Oct 11, 2024
2 parents 997fc63 + 5fb448c commit f4549ad
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<div class="osd-toolbar row">
<div class="col-md-6 pagination">
<% if count > 1 %>
<% osd_config = osd_config_referencestrip.merge(osd_config) %>
<a id="<%= id_prefix %>-previous"><%= render Blacklight::Gallery::Icons::ChevronLeftComponent.new %></a>
<span id="<%= id_prefix %>-page">1</span> of <%= count %>
<a id="<%= id_prefix %>-next"><%= render Blacklight::Gallery::Icons::ChevronRightComponent.new %></a>
<% multi_page_osd_config = osd_config_referencestrip.merge(osd_config) %>
<a id="<%= @id_prefix %>-previous"><%= render Blacklight::Gallery::Icons::ChevronLeftComponent.new %></a>
<span id="<%= @id_prefix %>-page">1</span>&nbsp; of <%= count %>
<a id="<%= @id_prefix %>-next"><%= render Blacklight::Gallery::Icons::ChevronRightComponent.new %></a>
<% end %>
</div>
<div class="col-md-6 controls">
<a id="<%= id_prefix %>-zoom-in"><%= render Blacklight::Gallery::Icons::AddCircleComponent.new %></a>
<a id="<%= id_prefix %>-zoom-out"><%= render Blacklight::Gallery::Icons::RemoveCircleComponent.new %></a>
<a id="<%= id_prefix %>-home"><%= render Blacklight::Gallery::Icons::ResizeSmallComponent.new %></a>
<a id="<%= id_prefix %>-full-page"><%= render Blacklight::Gallery::Icons::CustomFullscreenComponent.new %></a>
<a id="<%= @id_prefix %>-zoom-in"><%= render Blacklight::Gallery::Icons::AddCircleComponent.new %></a>
<a id="<%= @id_prefix %>-zoom-out"><%= render Blacklight::Gallery::Icons::RemoveCircleComponent.new %></a>
<a id="<%= @id_prefix %>-home"><%= render Blacklight::Gallery::Icons::ResizeSmallComponent.new %></a>
<a id="<%= @id_prefix %>-full-page"><%= render Blacklight::Gallery::Icons::CustomFullscreenComponent.new %></a>
</div>
</div>
<%= helpers.openseadragon_picture_tag image, class: 'osd-image row', data: { openseadragon: osd_config } %>
<%= helpers.openseadragon_picture_tag image, class: 'osd-image row', data: { openseadragon: multi_page_osd_config ? multi_page_osd_config : osd_config } %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(document:, presenter:, view_config: nil, classes: [], **kwargs)
@presenter = presenter
@view_config = view_config
@classes = classes
@id_prefix = id_prefix
end

def image
Expand All @@ -33,21 +34,20 @@ def render?
def osd_config
{
crossOriginPolicy: false,
zoomInButton: "#{id_prefix}-zoom-in",
zoomOutButton: "#{id_prefix}-zoom-out",
homeButton: "#{id_prefix}-home",
fullPageButton: "#{id_prefix}-full-page",
nextButton: "#{id_prefix}-next",
previousButton: "#{id_prefix}-previous"
zoomInButton: "#{@id_prefix}-zoom-in",
zoomOutButton: "#{@id_prefix}-zoom-out",
homeButton: "#{@id_prefix}-home",
fullPageButton: "#{@id_prefix}-full-page",
nextButton: "#{@id_prefix}-next",
previousButton: "#{@id_prefix}-previous"
}
end

def osd_config_referencestrip
{
showReferenceStrip: true,
referenceStripPosition: 'OUTSIDE',
sequenceMode: true,
referenceStripScroll: 'vertical',
referenceStripWidth: 100,
referenceStripBackgroundColor: 'transparent'
}
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::Gallery::OpenseadragonEmbedComponent, type: :component do
subject(:component) do
described_class.new(
document: document,
presenter: presenter,
**attr
)
end

let(:attr) { {} }
let(:view_context) { vc_test_controller.view_context }
let(:render) do
component.render_in(view_context)
end

let(:rendered) do
Capybara::Node::Simple.new(render)
end

let(:document) do
SolrDocument.new(
id: 'x'
)
end

let(:presenter) { Blacklight::IndexPresenter.new(document, view_context, blacklight_config) }

before do
allow(view_context).to receive(:current_search_session).and_return(nil)
allow(view_context).to receive(:search_session).and_return({})
allow(view_context).to receive(:blacklight_config).and_return(blacklight_config)
end

describe 'openseadragon viewer' do
let(:blacklight_config) do
Blacklight::Configuration.new.tap do |config|
config.index.slideshow_method = :xyz
if Blacklight::VERSION > '8'
config.track_search_session.storage = false
else
config.track_search_session = false
end
end
end
it 'uses a single @id_prefix to generate unique control ids' do
expect(component.osd_config[:zoomInButton]).to include(component.instance_variable_get(:@id_prefix))
expect(component.osd_config[:zoomOutButton]).to include(component.instance_variable_get(:@id_prefix))
expect(component.osd_config[:homeButton]).to include(component.instance_variable_get(:@id_prefix))
expect(component.osd_config[:fullPageButton]).to include(component.instance_variable_get(:@id_prefix))
expect(component.osd_config[:nextButton]).to include(component.instance_variable_get(:@id_prefix))
expect(component.osd_config[:previousButton]).to include(component.instance_variable_get(:@id_prefix))
end
end
end

0 comments on commit f4549ad

Please sign in to comment.