宏弹出窗口中的共享按钮 [英] Sharing buttons in Magnific Popup

查看:75
本文介绍了宏弹出窗口中的共享按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望为图库中的每个图像添加共享按钮(开始使用Pinterest),而不必进入并手动为每个单独的图像/条目添加URL等.要为其他灯箱包含此功能,需要做大量的指示-最值得注意的是与特定的CMS结合使用;并且我一直在仔细阅读这些说明以及w3资源和其他stackoverflow.com条目-希望我能把一些东西放在一起.............................................................................................我想用共享按钮代替柜台.到目前为止,我失败了.我确实尝试过一次尝试,结果显示了该按钮,但是脚本没有为成功的图钉"确认图像的路径.后来尝试包含"Pin It"按钮,只是破坏了Magnific.

I'm hoping to add sharing buttons (Pinterest to start) to each image within a gallery without having to go in and manually include URLs etc. for each individual image/entry. There is plenty of instruction to be had when it comes to including this functionality for other lightboxes--most notably in conjunction with a specific CMS; and I have been reviewing those instructions, as well as w3 resources and other stackoverflow.com entries--with the hope that I could put something together. I'd like to place the share buttons en lieu of the counter. Thus far I've failed. I did have one attempt that resulted in the button being displayed, however the script did not acknowledge the path for the image for a successful "pin." Subsequent attempts at including a "Pin It" button have simply broken 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>'}

任何提示将不胜感激!

谢谢!

推荐答案

添加按钮有很多种方法,其中一种最简单:

There are many ways of adding a button, one of the easiest:

$('.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 + ' &middot; <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');
      }
    }

});

http://codepen.io/dimsemenov/pen/hutrb

这篇关于宏弹出窗口中的共享按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆