我希望为图库中的每个图像添加共享按钮(从 Pinterest 开始),而无需进入并手动为每个单独的图像/条目添加 URL 等。当涉及到为其他灯箱添加此功能时,需要有大量的说明——尤其是与特定的 CMS 结合使用;我一直在审查这些说明,以及 w3 资源和其他 stackoverflow.com 条目 - 希望我可以将一些东西放在一起。我想将共享按钮放在柜台的位置。到目前为止我失败了。我确实进行了一次尝试,结果显示了该按钮,但是脚本没有确认成功“固定”的图像路径。随后尝试添加“固定它”按钮的尝试只是破坏了 Magnific。
目前,我有:
tCounter:
'<a href="//pinterest.com/pin/create/button/?url=http%3A%2F
%2Fgeraldmurai.com&media=http%3A%2F%2Fwindow.location.href&
description=Aloha!%20Thank%20you%20for%20Pinning!" data-pin-do="buttonPin" data-pin-
config="none" >
<img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" />
</a>'}
任何提示将不胜感激!
谢谢!
最佳答案
添加按钮的方法有很多种,最简单的一种是:
$('.image-link').magnificPopup({
type: 'image',
closeBtnInside: false,
mainClass: 'mfp-with-zoom mfp-img-mobile',
image: {
verticalFit: true,
titleSrc: function(item) {
var caption = item.el.attr('title');
var pinItURL = "http://pinterest.com/pin/create/button/";
// Refer to http://developers.pinterest.com/pin_it/
pinItURL += '?url=' + 'http://dimsemenov.com/plugins/magnific-popup/';
pinItURL += '&media=' + item.el.attr('href');
pinItURL += '&description=' + caption;
return caption + ' · <a class="pin-it" href="'+pinItURL+'" target="_blank"><img src="http://assets.pinterest.com/images/pidgets/pin_it_button.png" /></a>';
}
},
gallery: {
enabled: true
},
callbacks: {
open: function() {
this.wrap.on('click.pinhandler', '.pin-it', function(e) {
window.open(e.currentTarget.href, "intent", "scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,left=" + (window.screen ? Math.round(screen.width / 2 - 275) : 50) + ",top=" + 100);
return false;
});
},
beforeClose: function() {
this.wrap.off('click.pinhandler');
}
}
});
关于jquery - 放大弹出窗口中的共享按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18095803/