How To Add jQuery Slide Show to blogger

Posted by Lasantha Bandara on August 20th, 2009 File Under : jquery4 Comments

1.Login to your blogger dashboard--> layout- -> Edit HTML

2.Don't Click on "Expand Widget Templates"

3.Scroll down to where you see </head> tag:

4.Copy below code and paste it just before the </head> tag.

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js' type='text/javascript'></script>

<script type='text/javascript'>
//<![CDATA[

/* ------------------------------------------------------------------------
	s3Slider

	Developped By: Boban Kari�¡ik -> http://www.serie3.info/
        CSS Help: M�©sz�¡ros R�³bert -> http://www.perspectived.com/
	Version: 1.0

	Copyright: Feel free to redistribute the script/modify it, as
			   long as you leave my infos at the top.
------------------------------------------------------------------------- */

(function($){  

    $.fn.s3Slider = function(vars) {       

        var element     = this;
        var timeOut     = (vars.timeOut != undefined) ? vars.timeOut : 4000;
        var current     = null;
        var timeOutFn   = null;
        var faderStat   = true;
        var mOver       = false;
        var items       = $("#" + element[0].id + "Content ." + element[0].id + "Image");
        var itemsSpan   = $("#" + element[0].id + "Content ." + element[0].id + "Image span");

        items.each(function(i) {

            $(items[i]).mouseover(function() {
               mOver = true;
            });

            $(items[i]).mouseout(function() {
                mOver   = false;
                fadeElement(true);
            });

        });

        var fadeElement = function(isMouseOut) {
            var thisTimeOut = (isMouseOut) ? (timeOut/2) : timeOut;
            thisTimeOut = (faderStat) ? 10 : thisTimeOut;
            if(items.length > 0) {
                timeOutFn = setTimeout(makeSlider, thisTimeOut);
            } else {
                console.log("Poof..");
            }
        }

        var makeSlider = function() {
            current = (current != null) ? current : items[(items.length-1)];
            var currNo      = jQuery.inArray(current, items) + 1
            currNo = (currNo == items.length) ? 0 : (currNo - 1);
            var newMargin   = $(element).width() * currNo;
            if(faderStat == true) {
                if(!mOver) {
                    $(items[currNo]).fadeIn((timeOut/6), function() {
                        if($(itemsSpan[currNo]).css('bottom') == 0) {
                            $(itemsSpan[currNo]).slideUp((timeOut/6), function() {
                                faderStat = false;
                                current = items[currNo];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        } else {
                            $(itemsSpan[currNo]).slideDown((timeOut/6), function() {
                                faderStat = false;
                                current = items[currNo];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        }
                    });
                }
            } else {
                if(!mOver) {
                    if($(itemsSpan[currNo]).css('bottom') == 0) {
                        $(itemsSpan[currNo]).slideDown((timeOut/6), function() {
                            $(items[currNo]).fadeOut((timeOut/6), function() {
                                faderStat = true;
                                current = items[(currNo+1)];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        });
                    } else {
                        $(itemsSpan[currNo]).slideUp((timeOut/6), function() {
                        $(items[currNo]).fadeOut((timeOut/6), function() {
                                faderStat = true;
                                current = items[(currNo+1)];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        });
                    }
                }
            }
        }

        makeSlider();

    };  

})(jQuery);  

//]]>
</script>

<script type='text/javascript'>
$(document).ready(function() {
   $('#s3slider').s3Slider({
      timeOut: 4000
   });
});
</script>

<style type="text/css">
/* s3Slider jQuery plugin */
#s3slider {
border:5px solid #000;
width:250px; /* important to be same as image width */
height:190px; /* important to be same as image height */
position: relative; /* important */
overflow: hidden; /* important */
}

#s3sliderContent {
margin: 0px; padding:0px;
width:250px; /* important to be same as image width or wider */
position: absolute; /* important */
top: 0; /* important */
margin-left: 0; /* important */
}

.s3sliderImage {
float: left; /* important */
position: relative; /* important */
display: none; /* important */
}

.s3sliderImage span {
position: absolute; /* important */
left: 0;
text-indent: 0px; /* reset blogger */
font: 10px Arial, Helvetica, sans-serif;
padding: 10px 13px;
margin: 0;
width:225px; /* need edit to be same as image width or wider */
background-color: #000;
filter: alpha(opacity=70); /* here you can set the opacity of box with text */
-moz-opacity: 0.7; /* here you can set the opacity of box with text */
-khtml-opacity: 0.7; /* here you can set the opacity of box with text */
opacity: 0.7; /* here you can set the opacity of box with text */
color: #fff;
display: block; /* important */
top: 0;

/*
if you put
top: 0; -> the box with text will be shown at the top of the image
if you put
bottom: 0; -> the box with text will be shown at the bottom of the image
*/
}

.clear {
clear: both;
}
</style>

5.Now Click on "Save Templates"

6.Now go to Layout-->page elements and click on 'add a gadget'.

7.Now select html/java script.Add the code given below and click save.

<div id="s3slider">
<ul id="s3sliderContent">
<li class="s3sliderImage">
<a href="http://www.000webhost.com/173265.html" target="_blank" rel="nofollow"><img border="0" alt="Free Website Hosting" width="250" src="http://www.000webhost.com/images/banners/120x120/banner1.gif" height="190"/></a>
<span>Free Website Hosting</span>
</li>
<li class="s3sliderImage">
<a href="http://tinyurl.com/nlqnby" target="_blank" rel="nofollow"><img border="0" alt="Free Domain name" width="250" src="https://2.bp.blogspot.com/_ar9PeTUrwMY/SnGhdlHYuuI/AAAAAAAAAuU/SEP2BlhGyYs/untitled2222.png" height="190"/></a>
<span>Get Free Domain</span>
</li>
<li class="s3sliderImage">
<a href="http://revtwt.com/index.php?id=18676" target="_blank" rel="nofollow"><img width="250" height="190" src="http://revtwt.com/images/TwtAd_referral02.jpg"/></a>
<span>Earn money from twitter</span>
</li>
<div class="clear s3sliderImage"></div>
</ul>
</div>

Now you are done.

File Under : jquery

Related Posts

4 Responses to “How To Add jQuery Slide Show to blogger”

  1. varun says:

    I tried it on my blog http://royalcitrus.blogspot.com/
    It works wonderfully.
    Thanks.

  2. Yasin says:

    Thanks 🙂

  3. fabir says:

    great.thanks for sharing

  4. beton says:

    great.thanks for sharing

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.