Sha256: 164bb7dc3461ba6052cacdb95dac30d80ef1c0a4241165218c089eb32182e3ba

Contents?: true

Size: 1.19 KB

Versions: 44

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # iiif-crop options helpers
  module CropHelper
    def iiif_cropper_tags(f, initial_crop_selection:)
      content_tag(:div) do
        concat f.hidden_field(:iiif_manifest_url)
        concat f.hidden_field(:iiif_canvas_id)
        concat f.hidden_field(:iiif_image_id)
        concat f.hidden_field(:iiif_region)
        concat f.hidden_field(:iiif_tilesource)
        concat iiif_cropper_tag(f, initial_crop_selection: initial_crop_selection)
      end
    end

    def iiif_cropper_tag(f, initial_crop_selection:)
      content_tag :div, '', id: "#{form_prefix(f)}_iiif_cropper", data: {
        behavior: 'iiif-cropper',
        cropper_key: f.object.model_name.singular_route_key,
        'crop-width': initial_crop_selection.first,
        'crop-height': initial_crop_selection.last
      }
    end

    def iiif_upload_tag(f)
      content_tag(:div) do
        concat f.file_field_without_bootstrap :file, name: 'featured_image[image]', data: { endpoint: polymorphic_path(f.object.model_name.route_key) }
        concat f.hidden_field :upload_id
      end
    end

    def form_prefix(f)
      f.object_name.parameterize(separator: '_')
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
blacklight-spotlight-4.2.0 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.1.2 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.1.1 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.1.0 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.0.3 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.0.2 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.0.1 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-4.0.0 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta10 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta9 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta8 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.5.0.4 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta7 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.5.0.3 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta6 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta5 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta4 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta3 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.6.0.beta1 app/helpers/spotlight/crop_helper.rb
blacklight-spotlight-3.5.0.2 app/helpers/spotlight/crop_helper.rb