Project

General

Profile

Defect #42084 » Move-tooltip-from-image-to-thumbnail-element.patch

Katsuya HIDAKA, 2025-01-13 16:58

View differences:

app/assets/stylesheets/application.css
1126 1126
div.attachments span.author { font-size: 0.9em; color: #888; }
1127 1127

  
1128 1128
div.thumbnails {margin:0.6em;}
1129
div.thumbnails div {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;}
1130
div.thumbnails img {margin: 3px; vertical-align: middle;}
1129
div.thumbnail {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;}
1130
div.thumbnail img {margin: 3px; vertical-align: middle;}
1131 1131
#history div.thumbnails {margin-left: 2em;}
1132 1132

  
1133 1133
p.other-formats { text-align: right; font-size:0.9em; color: #666; }
app/helpers/application_helper.rb
346 346
  def thumbnail_tag(attachment)
347 347
    thumbnail_size = Setting.thumbnails_size.to_i
348 348
    thumbnail_path = thumbnail_path(attachment, :size => thumbnail_size * 2)
349
    link_to(
350
      image_tag(
351
        thumbnail_path,
352
        :srcset => "#{thumbnail_path} 2x",
353
        :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;",
354
        :title => attachment.filename,
355
        :loading => "lazy"
356
      ),
357
      attachment_path(
358
        attachment
349
    tag.div class: 'thumbnail', title: attachment.filename do
350
      link_to(
351
        image_tag(
352
          thumbnail_path,
353
          :srcset => "#{thumbnail_path} 2x",
354
          :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;",
355
          :alt => attachment.filename,
356
          :loading => "lazy"
357
        ),
358
        attachment_path(attachment)
359 359
      )
360
    )
360
    end
361 361
  end
362 362

  
363 363
  def toggle_link(name, id, options={})
app/views/attachments/_links.html.erb
42 42
  <% if images.any? %>
43 43
  <div class="thumbnails">
44 44
    <% images.each do |attachment| %>
45
      <div><%= thumbnail_tag(attachment) %></div>
45
      <%= thumbnail_tag(attachment) %>
46 46
    <% end %>
47 47
  </div>
48 48
  <% end %>
app/views/issues/tabs/_history.html.erb
27 27
    <% if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments(journal)).any? %>
28 28
      <div class="thumbnails">
29 29
        <% thumbnail_attachments.each do |attachment| %>
30
          <div><%= thumbnail_tag(attachment) %></div>
30
          <%= thumbnail_tag(attachment) %>
31 31
        <% end %>
32 32
      </div>
33 33
    <% end %>
test/helpers/application_helper_test.rb
1918 1918
  end
1919 1919

  
1920 1920
  def test_thumbnail_tag
1921
    a = Attachment.find(3)
1922
    assert_select_in(
1923
      thumbnail_tag(a),
1924
      'a[href=?] img[title=?][src=?][loading="lazy"]',
1925
      "/attachments/3", "logo.gif", "/attachments/thumbnail/3/200")
1921
    attachment = Attachment.find(3)
1922
    assert_select_in thumbnail_tag(attachment), 'div.thumbnail[title=?]', 'logo.gif' do
1923
      assert_select 'a[href=?]', '/attachments/3' do
1924
        assert_select 'img[alt=?][src=?][loading="lazy"]', "logo.gif", "/attachments/thumbnail/3/200"
1925
      end
1926
    end
1926 1927
  end
1927 1928

  
1928 1929
  def test_link_to_project
(3-3/5)