shimmer 0.0.15 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 789f3862287d4a4e4ea0ea64429d5855d147853d25a85f896acde0f4a456f805
4
- data.tar.gz: 5fe592396ee46ae62468f4436835b1a3718fedfe60823287388bbe28cbb51f92
3
+ metadata.gz: de8e99f1e252a60ee4c57442fe9fe67ba7af78e626b55d7c1756eedf3a83e404
4
+ data.tar.gz: d28eeba9b1cdf8d9c1fc46151a334dc0993cacfbafe91223f14647e988a3ba23
5
5
  SHA512:
6
- metadata.gz: 3ca1e5c4a38b5b36da2b9cc20bae29c2a20df60550f8e9904db8de6cca92aea4c02f62cdb57d1c72cbfb0b4d660b2714ac3051e6c9eb8996914d954ba5ec14a4
7
- data.tar.gz: 50d5ffc3cac315ad169da4da82c621338b565598919930a3f3f72bd32f0321d2c781ba0598020762aaa5492b96a3988d6377ded829e4c650e4ebb3fb48361d5b
6
+ metadata.gz: e750c73c60fa769a97526a0eaeb13b0f497539d9ae5c5500c581e2b0aafa7dc922c61b6edf6c4514d8946e8526d5789b5e454ce5787f4850cb598bd9450c6f05
7
+ data.tar.gz: 62bcf6a9014420997d088bd41e9c491b4257456ec75f5881e252db5b7aea8b107c2d531ff2b10cba44e037d8eeb387a0edfbedcc09618da898dd3267bf84cad2
@@ -2,6 +2,16 @@
2
2
 
3
3
  module Shimmer
4
4
  module FileHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ ActiveSupport.on_load(:action_view) do
9
+ include Shimmer::FileAdditions
10
+ end
11
+ end
12
+ end
13
+
14
+ module FileAdditions
5
15
  def image_tag(source, **options)
6
16
  return nil if source.blank?
7
17
 
@@ -9,19 +19,27 @@ module Shimmer
9
19
  attachment = source
10
20
  width = options[:width]
11
21
  height = options[:height]
12
- source = image_file_url(source, width: width, height: height)
22
+ source = image_file_path(source, width: width, height: height)
13
23
  options[:loading] = :lazy
14
- options[:srcset] = "#{source} 1x, #{image_file_url(attachment, width: width.to_i * 2, height: height ? height.to_i * 2 : nil)} 2x" if options[:width].present?
24
+ options[:srcset] = "#{source} 1x, #{image_file_path(attachment, width: width.to_i * 2, height: height ? height.to_i * 2 : nil)} 2x" if options[:width].present?
15
25
  end
16
26
  super source, options
17
27
  end
18
28
 
29
+ def image_file_path(source, width: nil, height: nil)
30
+ image_file_proxy(source, width: width, height: height)&.path
31
+ end
32
+
19
33
  def image_file_url(source, width: nil, height: nil)
34
+ image_file_proxy(source, width: width, height: height)&.url
35
+ end
36
+
37
+ def image_file_proxy(source, width: nil, height: nil)
20
38
  return if source.blank?
21
39
  return source if source.is_a?(String)
22
40
 
23
41
  blob = source.try(:blob) || source
24
- Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height).url
42
+ Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height)
25
43
  end
26
44
  end
27
45
  end
@@ -22,8 +22,12 @@ module Shimmer
22
22
  end
23
23
 
24
24
  helper_method :close_modal_path
25
- def close_modal_path(id: nil)
26
- "javascript:ui.modal.close(#{{id: id}.to_json})"
25
+ def close_modal_path(id = nil)
26
+ if id.present?
27
+ "javascript:ui.modal.close(#{{id: id}.to_json})"
28
+ else
29
+ "javascript:ui.modal.close()"
30
+ end
27
31
  end
28
32
 
29
33
  helper_method :popover_path
@@ -87,7 +91,7 @@ module Shimmer
87
91
 
88
92
  def close_modal(id = nil)
89
93
  if id.present?
90
- run_javascript "ui.modal.close('#{id}')"
94
+ run_javascript "ui.modal.close(#{{id: id}.to_json})"
91
95
  else
92
96
  run_javascript "ui.modal.close()"
93
97
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.15"
4
+ VERSION = "0.0.18"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-27 00:00:00.000000000 Z
11
+ date: 2022-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake