如何在fancybox.js上添加社交按钮?

时间:2015-01-02 10:01:48

标签: javascript jquery html5 facebook

大家好我想使用以下代码在我的fancybox上添加twitter和Facebook共享按钮。但是没有社交按钮。

JS

<script src="js/jquery.fancybox.js"></script>
<script type="js/widgets.js"></script>
<script>$(".fancybox")
    .attr('rel', 'gallery')
    .fancybox({
        beforeShow: function () {
            if (this.title) {
                // New line
                this.title += '<br />';

                // Add tweet button
                this.title += '<a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="' + this.href + '">Tweet</a> ';

                // Add FaceBook like button
                this.title += '<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:23px;" allowTransparency="true"></iframe>';
            }
        },
        afterShow: function() {
            // Render tweet button
            twttr.widgets.load();
        },
        helpers : {
            title : {
                type: 'inside'
            }
        }  
    });</script>

HTML

<a title="*" class="fancybox" href="{{doodle.carImageUrl}}"><img class="lazy carImage" ng-src='images/vote-loader.gif' width="{{$scope.imgWidth}}" height="{{$scope.imgHeight}}" data-original="{{doodle.carImageUrl}}" style="padding-right:10%;"></a>

解决

0 个答案:

没有答案