Unified · Split
| @@ -28,12 +28,19 @@ withImage = (url, action) -> · 27 unmodified lines | |||
| 28 | currentSlug = doc.slug | 28 | currentSlug = doc.slug |
| 29 | return | 29 | return |
| 30 | 30 | ||
| 31 | styles = window.getComputedStyle($("._icon-#{doc.slug.split('~')[0]}"), ':before') | 31 | iconEl = $("._icon-#{doc.slug.split('~')[0]}") |
| 32 | return if iconEl == null | ||
| 33 | |||
| 34 | styles = window.getComputedStyle(iconEl, ':before') | ||
| 35 | |||
| 36 | backgroundPositionX = styles['background-position-x'] | ||
| 37 | backgroundPositionY = styles['background-position-y'] | ||
| 38 | return if backgroundPositionX == undefined || backgroundPositionY == undefined | ||
| 32 | 39 | ||
| 33 | bgUrl = app.config.favicon_spritesheet | 40 | bgUrl = app.config.favicon_spritesheet |
| 34 | sourceSize = 16 | 41 | sourceSize = 16 |
| 35 | sourceX = Math.abs(parseInt(styles['background-position-x'].slice(0, -2))) | 42 | sourceX = Math.abs(parseInt(backgroundPositionX.slice(0, -2))) |
| 36 | sourceY = Math.abs(parseInt(styles['background-position-y'].slice(0, -2))) | 43 | sourceY = Math.abs(parseInt(backgroundPositionY.slice(0, -2))) |
| 37 | 44 | ||
| 38 | withImage(bgUrl, (docImg) -> | 45 | withImage(bgUrl, (docImg) -> |
| 39 | withImage(defaultUrl, (defaultImg) -> | 46 | withImage(defaultUrl, (defaultImg) -> |