JS如果有滑块显示它

时间:2013-03-27 20:44:46

标签: javascript

我不是JS专家,但我正在尝试改变这一点,以便如果有一个royalslider显示它...如果没有显示静态图像和标题和描述。关于为什么这不起作用的任何想法?我的脑袋正在旋转...我在试图添加到//皇家滑块修复下的代码的部分周围留下了一些空间,目前它只显示了if语句中的标题和描述。但是,标记显示滑块div并输出代码。

任何帮助都将非常感谢!您可以预览此代码以及我在此处尝试执行的操作... http://bvh.delineamultimedia.com/?page_id=2

;(function($) {

$.fn.SuperBox = function(options) {

    var superbox      = $('<div class="superbox-show"></div>');
    var superboximg   = $('<img src="" class="superbox-current-img">');
    var superboxclose = $('<div class="superbox-close"></div>');

    superbox.append(superboximg).append(superboxclose);

    return this.each(function() {

        $('.superbox').on('click', '.superbox-list', function() {

            //allows for superbox to work inside of quicksand
            $('ul.filterable-grid').css({overflow: 'visible'});

            var currentimg = $(this).find('.superbox-img');
            superbox.find('.title').remove(); 
            superbox.find('.description').remove(); 

            var imgData = currentimg.data();
            superboximg.attr('src', imgData.img);
            if (imgData.title) { superbox.append('<h3 class="title">'+imgData.title+'</h3>'); }
            if (imgData.description) { superbox.append('<div class="description">' + imgData.description + '</div>'); }









//royal slider fix              
superbox.find('.royalSlider').remove(); // remove the slider from previous events
var imgData = currentimg.data();
var sliderData = currentimg.next('.royalSlider'); // grab the slider html that we want to insert

superboximg.attr('src', imgData.img); 

if (sliderData) { // show the slider if there is one
    superbox.clone().append(sliderData); // clone the element so we don't loose it for the next time the user clicks
} else { // if there is no slider proceed as before
    if (imgData.img) {
        superbox.append(imgData.img);
    }
    if (imgData.title) {
        superbox.append('<h3 class="title">' + imgData.title + '</h3>');
    }
    if (imgData.description) {
        superbox.append('<div class="description">' + imgData.description + '</div>');
    }
}












            if($('.superbox-current-img').css('opacity') == 0) {
                $('.superbox-current-img').animate({opacity: 1});
            }

            if ($(this).next().hasClass('superbox-show')) {
                superbox.toggle();
            } else {
                superbox.insertAfter(this).css('display', 'block');
            }

            $('html, body').animate({
                scrollTop:superbox.position().top - currentimg.width()
            }, 'medium');

        });


        $('.superbox').on('hover', '.superbox-list', function(e) {
            $(this).find('.overlay').stop()[(e.type == 'mouseenter') ? 'fadeIn' : 'fadeOut']('slow');
        });


        $('.superbox').on('click', '.superbox-close', function() {
            $('.superbox-current-img').animate({opacity: 100}, 200, function() {
                $('.superbox-show').slideUp();
            });
        });

    });
};

})(jQuery);

1 个答案:

答案 0 :(得分:0)

这只是提示,而非尝试解决整个问题。

试试这个:

var superbox      = $('<div class="superbox-show"/>');
var superboximg   = $('<img src="" class="superbox-current-img"/>');
var superboxclose = $('<div class="superbox-close"/>');

if (sliderData.length > 0)

imgData.img在哪里获得它的价值?