name : jquery.arround-slider.js
/* **** slider V2 **** */
$.fn.arroundSlider = function(settings) {
    settings = $.extend({
        sliderWrapperSize: 807,
        imageSizeWidth: 807,
        imageSizeHeight: 540,
        descOpacity: 0.7,
        thumbnailimageSizeWidth: 70,
        thumbnailimageSizeHeight: 33,
        startImageMarginLeft: 0,
        dynamicArrows: true,
        arrowThumbnail: false,
        dynamicThumbnail: false,
        showDesc: false,
        showDescOnHover: false
    }, settings);

    return this.each(function(){
        //alert("Testing preloader");
        var slider = $(this);
        slider.parent().width(settings.sliderWrapperSize);
        var imageCount = slider.find("img").size();
        var panelContainerWidth = settings.imageSizeWidth*imageCount;
        var navClicks = 0; // Used if autoSlideStopWhenClicked = true
        // Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end)
        $('.panel', slider).wrapAll('<div class="panel-container"></div>');
        $(".panel-container", slider).css({
            width: panelContainerWidth
        });
        // Specify the current panel.
        var currentPanel = 1;
        /////////////////////////////////////////////////////////////////////
        // Left arrow click
        $("#coda-nav-left a").click(function(){
            removerThumbnailCurrent();
            navClicks++;
            if (currentPanel == 1) {
                offset = calculateOffset(imageCount-1);
                currentPanel = imageCount;
                slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('li:last a').addClass('current');
            } else {
                currentPanel -= 1;
                offset = calculateOffset(currentPanel-1);
                slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().prev().find('a').addClass('current');
            }
            $('.panel-container', slider).stop().animate({
                marginLeft: offset
            }, settings.slideEaseDuration, settings.slideEaseFunction);
            return false;
        });

        // Right arrow click
        $("#coda-nav-right a").click(function(){
            removerThumbnailCurrent();
            navClicks++;
            if (currentPanel == imageCount) {
                offset = 0;
                currentPanel = 1;
                slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('a:eq(0)').addClass('current');
            } else {
                offset = calculateOffset(currentPanel);
                currentPanel += 1;
                slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().next().find('a').addClass('current');
            };
            $('.panel-container', slider).stop().animate({
                marginLeft: offset+settings.startImageMarginLeft
            }, settings.slideEaseDuration, settings.slideEaseFunction);
            return false;
        });
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // If we need a dynamic menu
        
        var startThumbnailContainerWidth = 0;
        var endThumbnailContainerWidth;
        if (settings.dynamicThumbnail) {
            var dynamicTabs = '<div class="thumbnail-nav-wrapper"><div class="thumbnail-nav" id="thumbnail-nav"><ul></ul></div></div>';

            ul = $('#thumbnail-nav ul');
            // Create the nav items
            $('.panel', slider).each(function(n) {
                ul.append('<li class="tab' + (n+1) + '"><a href="#' + (n+1) + '"><img src="' + $(this).find("img").attr("src") + '" width="'+settings.thumbnailimageSizeWidth+'" height="'+settings.thumbnailimageSizeHeight+'"/></a></li>');
            });
            var thumnailSlider = $('#thumbnail-nav');
            var thumbnailWidth = thumnailSlider.find("li").width();
            var thumbnailPadding = thumnailSlider.find("li").css("padding-right").replace("px","");
            var thumbnailCount = thumnailSlider.find("li").size();
            var thumbnailContainerWidth = (thumbnailWidth+parseInt(thumbnailPadding))*thumbnailCount;
            endThumbnailContainerWidth = thumbnailContainerWidth-parseInt($(".thumbnail-nav-wrapper").width());
            //            ul.find('img').eq(0).addClass('current');
            //alert(endThumbnailContainerWidth);
            ul.width(thumbnailContainerWidth);
            if(settings.arrowThumbnail){
                thumnailSlider.before('<p class="thumbnail-arrow-left"></p>');
                thumnailSlider.after('<p class="thumbnail-arrow-right"></p>');
            }else{
                $('.thumbnail-nav-wrapper').width(thumbnailContainerWidth);
            }
        };
		
        // If we need a tabbed nav
        $('#thumbnail-nav a').each(function(z) {
            $(this).bind("click", function() {
                $(".showimage-desc").hide();
                navClicks++;
                $(this).find('img').addClass('current').parents('ul').find('img').not($(this).find('img')).removeClass('current');
                offset = calculateOffset(z)+settings.startImageMarginLeft;
                //alterPanelHeight(z);
                currentPanel = z + 1;
                $('.panel:eq(' + (currentPanel-1) + ') img').fadeTo(100,1).parent().find(".showimage-desc").showDesc();
                $('.panel-container', slider).animate({
                    marginLeft: offset
                }, settings.slideEaseDuration, settings.slideEaseFunction);
            });
        });
        function removerThumbnailCurrent(){
            $('.thumbnail-nav img').removeClass('current');
        }

        function calculateOffset(currentPanel){
            var returnVar = 0;
            slider.find('img').each(function(n){
                if(n < currentPanel){
                    returnVar -= $(this).width()
                }
            });
            return returnVar;
        }
    });
};

© 2024 UnknownSec