lazy_images-rails 1.1.1 → 1.2.0
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32743667e6924942ba8ddcec2783d963de1c87db
|
4
|
+
data.tar.gz: b4b3c6e7618906ecba0b61a8e563978f88a56c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be533d06e7faba168df5e585999ed70f87efb8da5053da4fd677f5063170af3d75470dd45b70774e4fb73a37bd4b47adb3c5fa750b182ef5efd3bd297b065fe2
|
7
|
+
data.tar.gz: b2654552eaace63a247e280b3eea92b90244d17598b0478ef9252a285d1590727320ee06a2ffe48f0e73d2b014da4d780c2e0b3c5440b42d88ad9bace5e72b8e
|
@@ -1,24 +1,21 @@
|
|
1
1
|
class @LazyImagesRails
|
2
2
|
@init: (all_replaced) ->
|
3
3
|
replace_with_image = (placeholder) =>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
height = svg.attributes.height
|
8
|
-
img = null
|
9
|
-
|
10
|
-
if width? && height?
|
11
|
-
img = new Image(parseInt(width.value, 10), parseInt(height.value, 10))
|
12
|
-
else
|
13
|
-
img = new Image()
|
4
|
+
noscript = placeholder.querySelector('noscript')
|
5
|
+
method = if 'innerText' in noscript then 'innerText' else 'textContent'
|
6
|
+
content = noscript[method]
|
14
7
|
|
8
|
+
tmp = document.createElement('div')
|
9
|
+
tmp.innerHTML = content # will trigger download of image
|
10
|
+
img = tmp.querySelector('img')
|
11
|
+
# Race condition:
|
12
|
+
# Event attachment happens after the download triggers above.
|
13
|
+
# If image loads before getting here, the callback never runs.
|
15
14
|
img.onload = =>
|
16
15
|
placeholder.parentNode.replaceChild(img, placeholder)
|
17
16
|
if all_replaced? && --@placeholder_count == 0
|
18
17
|
all_replaced.call()
|
19
18
|
|
20
|
-
img.src = placeholder.dataset.rliImageSrc
|
21
|
-
|
22
19
|
placeholders = document.querySelectorAll('div[data-rli-placeholder]')
|
23
20
|
@placeholder_count = placeholders.length
|
24
21
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_images-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Hansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|