Module: Mirador::ViewHelpers

Defined in:
lib/mirador_rails/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#mirador_tag(id: SecureRandom.uuid, height: '100%', width: '100%', position: 'relative', display: 'block', options: {}) ⇒ Object

Parameters:

  • id (String) (defaults to: SecureRandom.uuid)
  • height (String) (defaults to: '100%')
  • width (String) (defaults to: '100%')
  • position (String) (defaults to: 'relative')
  • display (String) (defaults to: 'block')
  • options (Hash) (defaults to: {})

    Mirador settings



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mirador_rails/view_helpers.rb', line 10

def mirador_tag(id: SecureRandom.uuid, height: '100%', width: '100%', position: 'relative', display: 'block', options: {})
  config = {
    id: id,
    buildPath: '/assets/',
    i18nPath: '',
    imagesPath: ''
  }.merge(options)

  styles = "height: #{height}; width: #{width}; " \
           "position: #{position}; display: #{display};"
  output = []
  output << (:div, '', id: id, style: styles)
  output << '<script type="text/javascript">'       \
            '  $(function() {'                      \
            "    Mirador(#{config.to_json})"        \
            '  });'                                 \
            '</script>'
  output.join.html_safe
end