【问题标题】:Use differents types of titles in one Fancybox gallery在一个 Fancybox 画廊中使用不同类型的标题
【发布时间】:2013-11-11 10:43:07
【问题描述】:

我今天做一个话题,因为我的插件 Fancybox 2.0 (http://fancyapps.com/fancybox/) 有问题。

事实上,我想根据当前fancybox中的媒体设置不同类型的标题。如果我的 Fancybox 中有 iFrame,则标题必须为“外部”。否则,如果是其他媒体,标题必须是“结束”。

$(".fancybox").fancybox({openEffect: 'elastic',closeEffect: 'elastic',beforeShow: function() {
        share_buttons_fancybox = '<div class="center" style="margin-top:10px;"><div class="bouton_social"><div class="fb-like" data-href="' + $(this.element).attr('href') + '" data-width="90" data-layout="button_count" data-show-faces="false" data-send="false"></div></div><div class="bouton_social"><a href="https://twitter.com/share" data-url="' + $(this.element).attr('href') + '" class="twitter-share-button" data-via="playeronetv" data-lang="fr">Tweeter</a></div><div class="bouton_social"><div class="addthis_toolbox addthis_default_style" addthis:url="' + $(this.element).attr('href') + '"><a class="addthis_counter addthis_pill_style"></a></div><script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-52248d25116616ca"></script></div></div>';
        if (this.title) {
            this.title += share_buttons_fancybox;
        } else {
            this.title = share_buttons_fancybox;
        }
    },afterShow: function() {
        twttr.widgets.load();
        FB.XFBML.parse();
        addthis.toolbox();
        addthis.toolbox(".addthis_toolbox");
        addthis.counter(".addthis_counter");
    },helpers: {thumbs: {width: 80,height: 45},title: {type: 'over'}},padding: 0})

有什么想法吗? iFrame 和其他媒体必须在同一个 Fancybox 库中。 :)

提前谢谢,对不起我的英语(我是法国人):)

【问题讨论】:

    标签: jquery fancybox fancybox-2


    【解决方案1】:

    您可以使用helpers 选项将所有元素的title 位置设置为over,并仅使用jQuery 的@ 将iframe 元素的title 位置设置为outside afterLoad 回调中的 987654327@ 方法是这样的:

    $(".fancybox").fancybox({
        padding: 0,
        openEffect: 'elastic',
        closeEffect: 'elastic',
        helpers: {
            thumbs: {
                width: 80,
                height: 45
            },
            title: {
                type: 'over' // all media
            }
        },
        afterLoad: function () {
            if (this.type == "iframe") {
                $.extend(this, {
                    helpers: {
                        title: {
                            type: 'outside' // iframe only
                        },
                        overlay: {
                            locked: false // needed to fix a bug while closing (can be true or false)
                        }
                    }
                });
            }
        }
    });
    

    注意,我在 $.extend() 方法中设置了 overlay locked 选项以解决关闭fancybox时出现的错误:

    overlay: {
        locked: false 
    }
    

    没有这个,覆盖将不会关闭(需要第二个click 才能关闭)

    JSFIDDLE

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多