Class: EmbeddableContent::Images::ModalDialog

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
app/services/embeddable_content/images/modal_dialog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_processor) ⇒ ModalDialog

Returns a new instance of ModalDialog.



11
12
13
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 11

def initialize(node_processor)
  @node_processor = node_processor
end

Instance Attribute Details

#node_processorObject (readonly)

Returns the value of attribute node_processor.



6
7
8
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 6

def node_processor
  @node_processor
end

Instance Method Details

#attribution_display_textObject



22
23
24
25
26
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 22

def attribution_display_text
  [attribution.owner_and_title_info,
   attribution.license.name,
   attribution.via_reference].join('. ').strip + '.'
end

#attribution_idObject



69
70
71
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 69

def attribution_id
  record_css_id_for 'dialog-attribution'
end

#caption_idObject



65
66
67
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 65

def caption_id
  record_css_id_for 'dialog-caption'
end

#close_button_attrsObject



42
43
44
45
46
47
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 42

def close_button_attrs
  { 'aria-hidden':  'true',
    height:         '18',
    width:          '18',
    viewBox:        '0 0 1200 1200' }
end

#container_attrsObject



28
29
30
31
32
33
34
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 28

def container_attrs
  { tabindex:           '-1',
    role:               'dialog',
    'aria-labelledby':  labelled_by_id,
    'aria-describedby': described_by_id,
    'aria-label':       'Image information' }
end

#described_by_idObject



57
58
59
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 57

def described_by_id
  record_css_id_for 'dialog-long-description'
end

#descriptionObject



49
50
51
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 49

def description
  node_processor.long_description
end

#img_tag_attrsObject



15
16
17
18
19
20
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 15

def img_tag_attrs
  { src:   s3_ttl_url,
    width: '80%',
    alt:   strip_tags(alt_text),
    role:  :image }
end

#labelled_by_idObject



53
54
55
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 53

def labelled_by_id
  record_css_id_for 'dialog-alt-text'
end

#target_attrsObject



36
37
38
39
40
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 36

def target_attrs
  { 'id':          target_div_id,
    'hidden':      'true',
    'aria-hidden': 'true' }
end

#target_div_idObject



61
62
63
# File 'app/services/embeddable_content/images/modal_dialog.rb', line 61

def target_div_id
  record_css_id_for 'modal-target'
end