|
| 1 | +var hoverZoomPlugins = hoverZoomPlugins || []; |
| 2 | +hoverZoomPlugins.push({ |
| 3 | + name:'jike', |
| 4 | + version:'0.1', |
| 5 | + prepareImgLinks:function (callback) { |
| 6 | + var pluginName = this.name; |
| 7 | + var res = []; |
| 8 | + |
| 9 | + // https://imgjike.ui.cn/data/singles/9382d37a6bf01fa9f68fc952ae55e60c.png?imageView/1/w/230/h/498 |
| 10 | + // => https://imgjike.ui.cn/data/singles/9382d37a6bf01fa9f68fc952ae55e60c.png |
| 11 | + // https://imgavater.ui.cn/avatar/1/5/8/3/1903851.jpg?imageMogr2/auto-orient/crop/!840x840a54a3/thumbnail/60x60 |
| 12 | + // => https://imgavater.ui.cn/avatar/1/5/8/3/1903851.jpg |
| 13 | + |
| 14 | + $('img[src*="/data/"], img[src*="/avatar/"]').one('mouseover', function() { |
| 15 | + const link = $(this); |
| 16 | + if (link.data().hoverZoomMouseOver) return; |
| 17 | + link.data().hoverZoomMouseOver = true; |
| 18 | + const src = this.src; |
| 19 | + const fullsizeUrl = src.replace(/(.*)\?.*/, '$1'); |
| 20 | + |
| 21 | + if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] } |
| 22 | + if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) { |
| 23 | + link.data().hoverZoomSrc.unshift(fullsizeUrl); |
| 24 | + link.data().hoverZoomJikeImgUrl = fullsizeUrl; |
| 25 | + } |
| 26 | + |
| 27 | + callback(link, pluginName); |
| 28 | + // Image or video is displayed iff the cursor is still over the link |
| 29 | + if (link.data().hoverZoomMouseOver) |
| 30 | + hoverZoom.displayPicFromElement(link); |
| 31 | + |
| 32 | + }).one('mouseleave', function() { |
| 33 | + const link = $(this); |
| 34 | + link.data().hoverZoomMouseOver = false; |
| 35 | + }); |
| 36 | + |
| 37 | + callback($(res), this.name); |
| 38 | + } |
| 39 | +}); |
0 commit comments