◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“Widget:ProfileCard/total”的版本间的差异
(优化加载) |
(根据屏幕剩余空间及调整比例模板自动缩放) |
||
第1行: | 第1行: | ||
− | <includeonly><script type="text/javascript">(window.RLQ=window.RLQ||[]).push(function(){ | + | <includeonly><style> |
+ | #profilecardview { | ||
+ | position: fixed; | ||
+ | top: 0; | ||
+ | right: 0; | ||
+ | border: 1px solid grey; | ||
+ | text-align: center; | ||
+ | line-height: 50vh; | ||
+ | } | ||
+ | .profilecard img:hover { | ||
+ | box-shadow: 0 0 12px 2px #eaeaea; | ||
+ | } | ||
+ | </style> | ||
+ | <script type="text/javascript">(window.RLQ=window.RLQ||[]).push(function(){ | ||
var view = new Image(); | var view = new Image(); | ||
− | view. | + | view.id = "profilecardview"; |
− | + | view.alt = "加载中"; | |
− | |||
− | |||
− | view. | ||
view.style.visibility = "hidden"; | view.style.visibility = "hidden"; | ||
− | + | $("#bodyContent:first").append(view); | |
− | |||
− | var card = $(".profilecard | + | var card = $(".profilecard img"); |
− | card.mouseover(function(){ | + | card.mouseover(function() { |
− | + | var root = ""; | |
− | + | var path = this.src.replace(/((https?:)?(\/\/)?www\.gfwiki\.org)/, function(m) { | |
− | function | + | root = m; return ""; |
− | + | }).split("/").slice(3, 6).join("/"); | |
− | + | view.src = root + "/images/" + path; | |
− | var | + | var ratioString = $(this).parent()[0].getAttribute("data-aspect-ratio"); |
− | + | var box = this.getBoundingClientRect(); | |
− | + | if(ratioString && box) { | |
− | + | var ratio = ratioString.split(":"); | |
+ | var imgWidth = parseFloat(ratio[0]); | ||
+ | var imgHeight = parseFloat(ratio[1]); | ||
+ | var availWidth = $(document.body).width() - box.right; | ||
+ | var availHeight = $(document.body).height(); | ||
+ | var scale = Math.min(availWidth/imgWidth, availHeight/imgHeight) * 0.99; | ||
+ | var width = imgWidth * scale; | ||
+ | var height = imgHeight * scale; | ||
+ | view.width = width; | ||
+ | view.height = height; | ||
+ | view.style.width = width + "px"; | ||
+ | view.style.height = height + "px"; | ||
+ | view.style.top = (availHeight - height)/2 + "px"; | ||
+ | } | ||
view.style.visibility = "visible"; | view.style.visibility = "visible"; | ||
− | } | + | }); |
− | + | card.mouseout(function() { | |
− | |||
− | |||
view.style.visibility = "hidden"; | view.style.visibility = "hidden"; | ||
− | } | + | view.src = ""; |
+ | }); | ||
})</script></includeonly> | })</script></includeonly> |