Μια και εχουμε καλοκαιρι και φυσικα μερικοι θα θελαμε να δειξουμε τις εικονες μας σε ενα SlideShow για να μπορουν να τις και επισκεπτες μας με ανεση και ευκολια. Γι αυτο και σημερα θα δουμε ενα ωραιο SlideShow οπου μπορουμε να βαλουμε μεσα τις εικονες μας. (Για το Demo οπως και στις αλλες αναρτησεις μου θα το βρειτε στο τελος της αναρτησης).
1) Πρώτα από όλα, συνδεθείτε στο λογαριασμό σας Blogger.
2) Κάντε κλικ στο Σχεδίαση. και επιλέξτε Επεξεργασία HTML.
Προσοχή:
- Πρέπει να είστε προσεκτικοί κατά την αλλαγή του προτύπου σας.
4) Παμε τωρα να ψαξουμε τον παρακατω κωδικα(Ctl+F):
</b:skin>
5) Και επικολουμε ακριβως απο πανω τον παρακατω κωδικα:
.msg_slideshow{
width:400px;
height:400px;
padding:10px;
position:relative;
overflow:hidden;
background:#101010 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzbW3MV12QE7SfJamZm5b-YtcuwizaeHXBhMpInA-ne3P_uRQFGE8Qsf4shLoDq_eU4cmgGeoAfvClb6FU5XUmWGEwoNshd3gVZVQvWGJl0n9fb7N5nnVnHq9nvnWJ8Hm51-6WY_1MckZn/s1600/loading.gif rel="prettyphoto") no-repeat center center;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
}
.msg_slideshow a{
outline:none;
}
.msg_slideshow a img{
border:none;
}
.msg_wrapper{
width:400px;
height:400px;
position:relative;
margin:0;
padding:0;
display:table-cell;
text-align:center;
vertical-align:middle;
overflow:hidden;
}
.msg_wrapper img{
display: inline-block!important;
vertical-align:middle;
-moz-box-shadow:0px 0px 10px #000;
-webkit-box-shadow:0px 0px 10px #000;
box-shadow:0px 0px 10px #000;
}
.msg_controls{
position:absolute;
bottom:15px;
right:-110px;
width:104px;
height:26px;
z-index: 20;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
background-color:#000;
opacity:0.8;
}
.msg_controls a{
float:left;
background-color:#000;
width:20px;
height:20px;
margin:3px 3px;
opacity:0.5;
background-repeat:no-repeat;
background-position: center center;
}
.msg_controls a:hover{
opacity:1.0;
}
.msg_controls a.msg_grid{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKhiCTe_3gsdEUvlLoZPB0O9KeecdoPyTGuboUjfRnlZeKaXZ20hgy2tO0E6ZahEYiQ3YFkkIgtBWSqGbOgYcEHgo7hHqnrp8Ivv-B85TrOa-wK2HRfceltiaOU4FpXlvnUWb9sDXfX-ed/s1600/grid.png);
}
.msg_controls a.msg_prev{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglP_EHFvRDNCAt40WyqJIKUS9jONQQpDlCSTGNRintFWLM14Fwhm7DC3PTjsvd-ECBg2Edv9O2rSgnigvXN2LkFUqdQN5GcIWA2fFlGsQslgz4hyphenhyphen81-oH6ebZWr2bQiH5bygWy6vDwvZ4R/s1600/prev.png);
}
.msg_controls a.msg_next{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH-BD5H8nhgo_4uolNZ7W98x0gL5Da6pvRQMqdMbjLC7xs9LgIFTnKcMBv8eGe5ZpAQ7tbDcKkbw7Xa3anD7Y8WFm7rJ4MltQtbcrVit3lU5h1ogotl6AGSad37ThgJgblGx3cY8PjtI48/s1600/next.png);
}
.msg_controls a.msg_pause{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAdF7vSQSKXCi1gpTBaZr1N67PGW5x0O69qk2KPhNIwbwuDFlXGMEhUFN7OUQcXGTojhYTLiQ73v7BziPv17yg8il4Y3wctY9xXlPl5YsjQbabBhL4pvtyv3_51xHLjFgMd8_GEX1oLda/s1600/pause.png);
}
.msg_controls a.msg_play{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDHd-62Isymrgcq6RcVJukxdYCniE3UzBLabO0yP9EfWcdcJzJNP8m0mApDl71zDTQ0ED5_x0pM9l6hGC4JT8SH5yVmhij14i26ldeYxfoFmaS8kssrjlaHkRdtC6AOdVEUyldHXQlW2ux/s1600/play.png);
}
.msg_thumbs{
background:#000;
position:absolute;
width:250px;
height:166px;
top:-230px;
left:50%;
padding:30px;
margin:0 0 0 -155px;
-moz-border-radius:0px 0px 10px 10px;
-webkit-border-bottom-left-radius:10px;
-webkit-border-bottom-right-radius:10px;
border-bottom-left-radius:10px;
border-bottom-right-radius:10px;
-moz-box-shadow:1px 1px 5px #000;
-webkit-box-shadow:1px 1px 5px #000;
box-shadow:1px 1px 5px #000;
opacity:0.9;
overflow:hidden;
}
.msg_thumb_wrapper{
position:absolute;
width:250px;
height:166px;
top:30px;
left:30px;
z-index:30;
}
.msg_thumb_wrapper a{
display:block;
width:75px;
height:75px;
float:left;
margin:4px;
opacity:0.8;
}
.msg_thumbs a.msg_thumb_next,
.msg_thumbs a.msg_thumb_prev{
width:18px;
height:20px;
background-repeat:no-repeat;
background-position: center center;
position:absolute;
top:50%;
margin-top:-10px;
opacity:0.5;
}
.msg_thumbs a.msg_thumb_next:hover,
.msg_thumbs a.msg_thumb_prev:hover{
opacity:1.0;
}
.msg_thumbs a.msg_thumb_next{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAgVTj_QpIZc8ThCRKE1MK525PYOnjBhER6q8g3rfjyls2MTnxCJ4zqFHs2eWKjXT2aQDFsl19PXcsnwyLSzt0icTnp39bpvmiDQpPcDT4Roq6FGQamI-6nrRga-pZHIbqxI8LZxipRyjw/s1600/next_thumb.png);
right:5px;
}
.msg_thumbs a.msg_thumb_prev{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyQ5I48rTWAo7PsjViMFXtPS_Rvs0trxwhGeMouUF6HQD5h4QVfKsGbt0jYD3EFa9OB5OCq1hcVD5BPM4nEwYB5ogtrs_ajApQx0eQYHGVTMD6vBx7q4jxAYzOzFRW9CV0jcLgyZgQJ7WR/s1600/prev_thumb.png);
left:5px;
}
.msg_thumbs a.msg_thumb_close{
position:absolute;
bottom:0px;
width:50px;
left:50%;
margin:0 0 0 -25px;
background:#202020 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD5um5pn1udVX8afe2t8kWkTg5uRW5EBhzEfAX5t3pnyWdk1kY4rycbRz9YFhDE4Vt6s-l8tr9gfrCQrtJU0ZkgPVYiVxEX3GGIOpfuucNFiSHotZDE2hk1g8r7qD6TbHNz8YtoEuekjdD/s1600/up.png) no-repeat center center;
height:16px;
opacity:0.7;
-moz-border-radius:5px 5px 0 0;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:5px;
border-top-left-radius:5px;
border-top-right-radius:5px;
}
.msg_thumbs a.msg_thumb_close:hover{
opacity:1.0;
}
.msg_loading{
position:absolute;
background:transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzbW3MV12QE7SfJamZm5b-YtcuwizaeHXBhMpInA-ne3P_uRQFGE8Qsf4shLoDq_eU4cmgGeoAfvClb6FU5XUmWGEwoNshd3gVZVQvWGJl0n9fb7N5nnVnHq9nvnWJ8Hm51-6WY_1MckZn/s1600/loading.gif) no-repeat center center;
top:50%;
left:50%;
width:50px;
height:50px;
margin:-25px 0 0 -25px;
z-index:25;
display:none;
}
width:400px;
height:400px;
padding:10px;
position:relative;
overflow:hidden;
background:#101010 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzbW3MV12QE7SfJamZm5b-YtcuwizaeHXBhMpInA-ne3P_uRQFGE8Qsf4shLoDq_eU4cmgGeoAfvClb6FU5XUmWGEwoNshd3gVZVQvWGJl0n9fb7N5nnVnHq9nvnWJ8Hm51-6WY_1MckZn/s1600/loading.gif rel="prettyphoto") no-repeat center center;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
}
.msg_slideshow a{
outline:none;
}
.msg_slideshow a img{
border:none;
}
.msg_wrapper{
width:400px;
height:400px;
position:relative;
margin:0;
padding:0;
display:table-cell;
text-align:center;
vertical-align:middle;
overflow:hidden;
}
.msg_wrapper img{
display: inline-block!important;
vertical-align:middle;
-moz-box-shadow:0px 0px 10px #000;
-webkit-box-shadow:0px 0px 10px #000;
box-shadow:0px 0px 10px #000;
}
.msg_controls{
position:absolute;
bottom:15px;
right:-110px;
width:104px;
height:26px;
z-index: 20;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
background-color:#000;
opacity:0.8;
}
.msg_controls a{
float:left;
background-color:#000;
width:20px;
height:20px;
margin:3px 3px;
opacity:0.5;
background-repeat:no-repeat;
background-position: center center;
}
.msg_controls a:hover{
opacity:1.0;
}
.msg_controls a.msg_grid{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKhiCTe_3gsdEUvlLoZPB0O9KeecdoPyTGuboUjfRnlZeKaXZ20hgy2tO0E6ZahEYiQ3YFkkIgtBWSqGbOgYcEHgo7hHqnrp8Ivv-B85TrOa-wK2HRfceltiaOU4FpXlvnUWb9sDXfX-ed/s1600/grid.png);
}
.msg_controls a.msg_prev{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglP_EHFvRDNCAt40WyqJIKUS9jONQQpDlCSTGNRintFWLM14Fwhm7DC3PTjsvd-ECBg2Edv9O2rSgnigvXN2LkFUqdQN5GcIWA2fFlGsQslgz4hyphenhyphen81-oH6ebZWr2bQiH5bygWy6vDwvZ4R/s1600/prev.png);
}
.msg_controls a.msg_next{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH-BD5H8nhgo_4uolNZ7W98x0gL5Da6pvRQMqdMbjLC7xs9LgIFTnKcMBv8eGe5ZpAQ7tbDcKkbw7Xa3anD7Y8WFm7rJ4MltQtbcrVit3lU5h1ogotl6AGSad37ThgJgblGx3cY8PjtI48/s1600/next.png);
}
.msg_controls a.msg_pause{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAdF7vSQSKXCi1gpTBaZr1N67PGW5x0O69qk2KPhNIwbwuDFlXGMEhUFN7OUQcXGTojhYTLiQ73v7BziPv17yg8il4Y3wctY9xXlPl5YsjQbabBhL4pvtyv3_51xHLjFgMd8_GEX1oLda/s1600/pause.png);
}
.msg_controls a.msg_play{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDHd-62Isymrgcq6RcVJukxdYCniE3UzBLabO0yP9EfWcdcJzJNP8m0mApDl71zDTQ0ED5_x0pM9l6hGC4JT8SH5yVmhij14i26ldeYxfoFmaS8kssrjlaHkRdtC6AOdVEUyldHXQlW2ux/s1600/play.png);
}
.msg_thumbs{
background:#000;
position:absolute;
width:250px;
height:166px;
top:-230px;
left:50%;
padding:30px;
margin:0 0 0 -155px;
-moz-border-radius:0px 0px 10px 10px;
-webkit-border-bottom-left-radius:10px;
-webkit-border-bottom-right-radius:10px;
border-bottom-left-radius:10px;
border-bottom-right-radius:10px;
-moz-box-shadow:1px 1px 5px #000;
-webkit-box-shadow:1px 1px 5px #000;
box-shadow:1px 1px 5px #000;
opacity:0.9;
overflow:hidden;
}
.msg_thumb_wrapper{
position:absolute;
width:250px;
height:166px;
top:30px;
left:30px;
z-index:30;
}
.msg_thumb_wrapper a{
display:block;
width:75px;
height:75px;
float:left;
margin:4px;
opacity:0.8;
}
.msg_thumbs a.msg_thumb_next,
.msg_thumbs a.msg_thumb_prev{
width:18px;
height:20px;
background-repeat:no-repeat;
background-position: center center;
position:absolute;
top:50%;
margin-top:-10px;
opacity:0.5;
}
.msg_thumbs a.msg_thumb_next:hover,
.msg_thumbs a.msg_thumb_prev:hover{
opacity:1.0;
}
.msg_thumbs a.msg_thumb_next{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAgVTj_QpIZc8ThCRKE1MK525PYOnjBhER6q8g3rfjyls2MTnxCJ4zqFHs2eWKjXT2aQDFsl19PXcsnwyLSzt0icTnp39bpvmiDQpPcDT4Roq6FGQamI-6nrRga-pZHIbqxI8LZxipRyjw/s1600/next_thumb.png);
right:5px;
}
.msg_thumbs a.msg_thumb_prev{
background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyQ5I48rTWAo7PsjViMFXtPS_Rvs0trxwhGeMouUF6HQD5h4QVfKsGbt0jYD3EFa9OB5OCq1hcVD5BPM4nEwYB5ogtrs_ajApQx0eQYHGVTMD6vBx7q4jxAYzOzFRW9CV0jcLgyZgQJ7WR/s1600/prev_thumb.png);
left:5px;
}
.msg_thumbs a.msg_thumb_close{
position:absolute;
bottom:0px;
width:50px;
left:50%;
margin:0 0 0 -25px;
background:#202020 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD5um5pn1udVX8afe2t8kWkTg5uRW5EBhzEfAX5t3pnyWdk1kY4rycbRz9YFhDE4Vt6s-l8tr9gfrCQrtJU0ZkgPVYiVxEX3GGIOpfuucNFiSHotZDE2hk1g8r7qD6TbHNz8YtoEuekjdD/s1600/up.png) no-repeat center center;
height:16px;
opacity:0.7;
-moz-border-radius:5px 5px 0 0;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:5px;
border-top-left-radius:5px;
border-top-right-radius:5px;
}
.msg_thumbs a.msg_thumb_close:hover{
opacity:1.0;
}
.msg_loading{
position:absolute;
background:transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzbW3MV12QE7SfJamZm5b-YtcuwizaeHXBhMpInA-ne3P_uRQFGE8Qsf4shLoDq_eU4cmgGeoAfvClb6FU5XUmWGEwoNshd3gVZVQvWGJl0n9fb7N5nnVnHq9nvnWJ8Hm51-6WY_1MckZn/s1600/loading.gif) no-repeat center center;
top:50%;
left:50%;
width:50px;
height:50px;
margin:-25px 0 0 -25px;
z-index:25;
display:none;
}
-Παταμε αποθηκευση προτυπου.
6) Και παμε τωρα στο Στοιχεια Σελιδας και παμε Προσθηκη Gadget-Html/javascript και επικοληστε τον παρακατω κωδικα:
<div id="msg_slideshow" class="msg_slideshow">
<div id="msg_wrapper" class="msg_wrapper"></div>
<div id="msg_controls" class="msg_controls">
<a href="#" id="msg_grid" class="msg_grid"></a>
<a href="#" id="msg_prev" class="msg_prev"></a>
<a href="#" id="msg_pause_play" class="msg_pause"></a>
<a href="#" id="msg_next" class="msg_next"></a>
</div>
<div id="msg_thumbs" class="msg_thumbs">
<div class="msg_thumb_wrapper">
<a href="#">
<img src="images/thumbs/1.jpg" alt="images/1.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/2.jpg" alt="images/2.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/3.jpg" alt="images/3.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/4.jpg" alt="images/4.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/5.jpg" alt="images/5.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/6.jpg" alt="images/6.jpg"/>
</a>
</div>
<div class="msg_thumb_wrapper" style="display:none;">
<a href="#">
<img src="images/thumbs/1.jpg" alt="images/7.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/2.jpg" alt="images/8.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/3.jpg" alt="images/9.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/4.jpg" alt="images/10.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/5.jpg" alt="images/11.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/6.jpg" alt="images/12.jpg"/>
</a>
</div>
<a href="#" id="msg_thumb_next" class="msg_thumb_next"></a>
<a href="#" id="msg_thumb_prev" class="msg_thumb_prev"></a>
<a href="#" id="msg_thumb_close" class="msg_thumb_close"></a>
<span class="msg_loading"></span>
</div>
</div>
<!-- The JavaScript -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
/**
* interval : time between the display of images
* playtime : the timeout for the setInterval function
* current : number to control the current image
* current_thumb : the index of the current thumbs wrapper
* nmb_thumb_wrappers : total number of thumbs wrappers
* nmb_images_wrapper : the number of images inside of each wrapper
*/
var interval = 4000;
var playtime;
var current = 0;
var current_thumb = 0;
var nmb_thumb_wrappers = $('#msg_thumbs .msg_thumb_wrapper').length;
var nmb_images_wrapper = 6;
/**
* start the slideshow
*/
play();
/**
* show the controls when
* mouseover the main container
*/
slideshowMouseEvent();
function slideshowMouseEvent(){
$('#msg_slideshow').unbind('mouseenter')
.bind('mouseenter',showControls)
.andSelf()
.unbind('mouseleave')
.bind('mouseleave',hideControls);
}
/**
* clicking the grid icon,
* shows the thumbs view, pauses the slideshow, and hides the controls
*/
$('#msg_grid').bind('click',function(e){
hideControls();
$('#msg_slideshow').unbind('mouseenter').unbind('mouseleave');
pause();
$('#msg_thumbs').stop().animate({'top':'0px'},500);
e.preventDefault();
});
/**
* closing the thumbs view,
* shows the controls
*/
$('#msg_thumb_close').bind('click',function(e){
showControls();
slideshowMouseEvent();
$('#msg_thumbs').stop().animate({'top':'-230px'},500);
e.preventDefault();
});
/**
* pause or play icons
*/
$('#msg_pause_play').bind('click',function(e){
var $this = $(this);
if($this.hasClass('msg_play'))
play();
else
pause();
e.preventDefault(); });
/**
* click controls next or prev,
* pauses the slideshow,
* and displays the next or prevoius image
*/
$('#msg_next').bind('click',function(e){
pause();
next();
e.preventDefault();
});
$('#msg_prev').bind('click',function(e){
pause();
prev();
e.preventDefault();
});
/**
* show and hide controls functions
*/
function showControls(){
$('#msg_controls').stop().animate({'right':'15px'},500);
}
function hideControls(){
$('#msg_controls').stop().animate({'right':'-110px'},500);
}
/**
* start the slideshow
*/
function play(){
next();
$('#msg_pause_play').addClass('msg_pause').removeClass('msg_play');
playtime = setInterval(next,interval)
}
/**
* stops the slideshow
*/
function pause(){
$('#msg_pause_play').addClass('msg_play').removeClass('msg_pause');
clearTimeout(playtime);
}
/**
* show the next image
*/
function next(){
++current;
showImage('r');
}
/**
* shows the previous image
*/
function prev(){
--current;
showImage('l');
}
/**
* shows an image
* dir : right or left
*/
function showImage(dir){
/**
* the thumbs wrapper being shown, is always
* the one containing the current image
*/
alternateThumbs();
/**
* the thumb that will be displayed in full mode
*/
var $thumb = $('#msg_thumbs .msg_thumb_wrapper:nth-child('+current_thumb+')')
.find('a:nth-child('+ parseInt(current - nmb_images_wrapper*(current_thumb -1)) +')')
.find('img');
if($thumb.length){
var source = $thumb.attr('alt');
var $currentImage = $('#msg_wrapper').find('img');
if($currentImage.length){
$currentImage.fadeOut(function(){
$(this).remove();
$('<img />').load(function(){
var $image = $(this);
resize($image);
$image.hide();
$('#msg_wrapper').empty().append($image.fadeIn());
}).attr('src',source);
});
}
else{
$('<img />').load(function(){
var $image = $(this);
resize($image);
$image.hide();
$('#msg_wrapper').empty().append($image.fadeIn());
}).attr('src',source);
}
}
else{ //this is actually not necessary since we have a circular slideshow
if(dir == 'r')
--current;
else if(dir == 'l')
++current; alternateThumbs();
return;
}
}
/**
* the thumbs wrapper being shown, is always
* the one containing the current image
*/
function alternateThumbs(){
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.hide();
current_thumb = Math.ceil(current/nmb_images_wrapper);
/**
* if we reach the end, start from the beggining
*/
if(current_thumb > nmb_thumb_wrappers){
current_thumb = 1;
current = 1;
} /**
* if we are at the beggining, go to the end
*/ else if(current_thumb == 0){
current_thumb = nmb_thumb_wrappers;
current = current_thumb*nmb_images_wrapper;
}
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.show(); }
/**
* click next or previous on the thumbs wrapper
*/
$('#msg_thumb_next').bind('click',function(e){
next_thumb();
e.preventDefault();
});
$('#msg_thumb_prev').bind('click',function(e){
prev_thumb();
e.preventDefault();
});
function next_thumb(){
var $next_wrapper = $('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+parseInt(current_thumb+1)+')');
if($next_wrapper.length){
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.fadeOut(function(){
++current_thumb;
$next_wrapper.fadeIn(); });
}
}
function prev_thumb(){
var $prev_wrapper = $('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+parseInt(current_thumb-1)+')');
if($prev_wrapper.length){
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.fadeOut(function(){
--current_thumb;
$prev_wrapper.fadeIn(); });
} }
/**
* clicking on a thumb, displays the image (alt attribute of the thumb)
*/
$('#msg_thumbs .msg_thumb_wrapper > a').bind('click',function(e){
var $this = $(this);
$('#msg_thumb_close').trigger('click');
var idx = $this.index();
var p_idx = $this.parent().index();
current = parseInt(p_idx*nmb_images_wrapper + idx + 1);
showImage();
e.preventDefault();
}).bind('mouseenter',function(){
var $this = $(this);
$this.stop().animate({'opacity':1});
}).bind('mouseleave',function(){
var $this = $(this); $this.stop().animate({'opacity':0.5});
});
/**
* resize the image to fit in the container (400 x 400)
*/
function resize($image){
var theImage = new Image();
theImage.src = $image.attr("src");
var imgwidth = theImage.width;
var imgheight = theImage.height;
var containerwidth = 400;
var containerheight = 400;
if(imgwidth > containerwidth){
var newwidth = containerwidth;
var ratio = imgwidth / containerwidth;
var newheight = imgheight / ratio;
if(newheight > containerheight){
var newnewheight = containerheight;
var newratio = newheight/containerheight;
var newnewwidth =newwidth/newratio;
theImage.width = newnewwidth;
theImage.height= newnewheight;
}
else{
theImage.width = newwidth;
theImage.height= newheight;
}
}
else if(imgheight > containerheight){
var newheight = containerheight;
var ratio = imgheight / containerheight;
var newwidth = imgwidth / ratio;
if(newwidth > containerwidth){
var newnewwidth = containerwidth;
var newratio = newwidth/containerwidth;
var newnewheight =newheight/newratio;
theImage.height = newnewheight;
theImage.width= newnewwidth;
}
else{
theImage.width = newwidth;
theImage.height= newheight;
}
}
$image.css({
'width' :theImage.width,
'height':theImage.height
});
}
});
</script>
</div>
<div id="msg_wrapper" class="msg_wrapper"></div>
<div id="msg_controls" class="msg_controls">
<a href="#" id="msg_grid" class="msg_grid"></a>
<a href="#" id="msg_prev" class="msg_prev"></a>
<a href="#" id="msg_pause_play" class="msg_pause"></a>
<a href="#" id="msg_next" class="msg_next"></a>
</div>
<div id="msg_thumbs" class="msg_thumbs">
<div class="msg_thumb_wrapper">
<a href="#">
<img src="images/thumbs/1.jpg" alt="images/1.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/2.jpg" alt="images/2.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/3.jpg" alt="images/3.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/4.jpg" alt="images/4.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/5.jpg" alt="images/5.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/6.jpg" alt="images/6.jpg"/>
</a>
</div>
<div class="msg_thumb_wrapper" style="display:none;">
<a href="#">
<img src="images/thumbs/1.jpg" alt="images/7.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/2.jpg" alt="images/8.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/3.jpg" alt="images/9.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/4.jpg" alt="images/10.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/5.jpg" alt="images/11.jpg"/>
</a>
<a href="#">
<img src="images/thumbs/6.jpg" alt="images/12.jpg"/>
</a>
</div>
<a href="#" id="msg_thumb_next" class="msg_thumb_next"></a>
<a href="#" id="msg_thumb_prev" class="msg_thumb_prev"></a>
<a href="#" id="msg_thumb_close" class="msg_thumb_close"></a>
<span class="msg_loading"></span>
</div>
</div>
<!-- The JavaScript -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
/**
* interval : time between the display of images
* playtime : the timeout for the setInterval function
* current : number to control the current image
* current_thumb : the index of the current thumbs wrapper
* nmb_thumb_wrappers : total number of thumbs wrappers
* nmb_images_wrapper : the number of images inside of each wrapper
*/
var interval = 4000;
var playtime;
var current = 0;
var current_thumb = 0;
var nmb_thumb_wrappers = $('#msg_thumbs .msg_thumb_wrapper').length;
var nmb_images_wrapper = 6;
/**
* start the slideshow
*/
play();
/**
* show the controls when
* mouseover the main container
*/
slideshowMouseEvent();
function slideshowMouseEvent(){
$('#msg_slideshow').unbind('mouseenter')
.bind('mouseenter',showControls)
.andSelf()
.unbind('mouseleave')
.bind('mouseleave',hideControls);
}
/**
* clicking the grid icon,
* shows the thumbs view, pauses the slideshow, and hides the controls
*/
$('#msg_grid').bind('click',function(e){
hideControls();
$('#msg_slideshow').unbind('mouseenter').unbind('mouseleave');
pause();
$('#msg_thumbs').stop().animate({'top':'0px'},500);
e.preventDefault();
});
/**
* closing the thumbs view,
* shows the controls
*/
$('#msg_thumb_close').bind('click',function(e){
showControls();
slideshowMouseEvent();
$('#msg_thumbs').stop().animate({'top':'-230px'},500);
e.preventDefault();
});
/**
* pause or play icons
*/
$('#msg_pause_play').bind('click',function(e){
var $this = $(this);
if($this.hasClass('msg_play'))
play();
else
pause();
e.preventDefault(); });
/**
* click controls next or prev,
* pauses the slideshow,
* and displays the next or prevoius image
*/
$('#msg_next').bind('click',function(e){
pause();
next();
e.preventDefault();
});
$('#msg_prev').bind('click',function(e){
pause();
prev();
e.preventDefault();
});
/**
* show and hide controls functions
*/
function showControls(){
$('#msg_controls').stop().animate({'right':'15px'},500);
}
function hideControls(){
$('#msg_controls').stop().animate({'right':'-110px'},500);
}
/**
* start the slideshow
*/
function play(){
next();
$('#msg_pause_play').addClass('msg_pause').removeClass('msg_play');
playtime = setInterval(next,interval)
}
/**
* stops the slideshow
*/
function pause(){
$('#msg_pause_play').addClass('msg_play').removeClass('msg_pause');
clearTimeout(playtime);
}
/**
* show the next image
*/
function next(){
++current;
showImage('r');
}
/**
* shows the previous image
*/
function prev(){
--current;
showImage('l');
}
/**
* shows an image
* dir : right or left
*/
function showImage(dir){
/**
* the thumbs wrapper being shown, is always
* the one containing the current image
*/
alternateThumbs();
/**
* the thumb that will be displayed in full mode
*/
var $thumb = $('#msg_thumbs .msg_thumb_wrapper:nth-child('+current_thumb+')')
.find('a:nth-child('+ parseInt(current - nmb_images_wrapper*(current_thumb -1)) +')')
.find('img');
if($thumb.length){
var source = $thumb.attr('alt');
var $currentImage = $('#msg_wrapper').find('img');
if($currentImage.length){
$currentImage.fadeOut(function(){
$(this).remove();
$('<img />').load(function(){
var $image = $(this);
resize($image);
$image.hide();
$('#msg_wrapper').empty().append($image.fadeIn());
}).attr('src',source);
});
}
else{
$('<img />').load(function(){
var $image = $(this);
resize($image);
$image.hide();
$('#msg_wrapper').empty().append($image.fadeIn());
}).attr('src',source);
}
}
else{ //this is actually not necessary since we have a circular slideshow
if(dir == 'r')
--current;
else if(dir == 'l')
++current; alternateThumbs();
return;
}
}
/**
* the thumbs wrapper being shown, is always
* the one containing the current image
*/
function alternateThumbs(){
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.hide();
current_thumb = Math.ceil(current/nmb_images_wrapper);
/**
* if we reach the end, start from the beggining
*/
if(current_thumb > nmb_thumb_wrappers){
current_thumb = 1;
current = 1;
} /**
* if we are at the beggining, go to the end
*/ else if(current_thumb == 0){
current_thumb = nmb_thumb_wrappers;
current = current_thumb*nmb_images_wrapper;
}
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.show(); }
/**
* click next or previous on the thumbs wrapper
*/
$('#msg_thumb_next').bind('click',function(e){
next_thumb();
e.preventDefault();
});
$('#msg_thumb_prev').bind('click',function(e){
prev_thumb();
e.preventDefault();
});
function next_thumb(){
var $next_wrapper = $('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+parseInt(current_thumb+1)+')');
if($next_wrapper.length){
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.fadeOut(function(){
++current_thumb;
$next_wrapper.fadeIn(); });
}
}
function prev_thumb(){
var $prev_wrapper = $('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+parseInt(current_thumb-1)+')');
if($prev_wrapper.length){
$('#msg_thumbs').find('.msg_thumb_wrapper:nth-child('+current_thumb+')')
.fadeOut(function(){
--current_thumb;
$prev_wrapper.fadeIn(); });
} }
/**
* clicking on a thumb, displays the image (alt attribute of the thumb)
*/
$('#msg_thumbs .msg_thumb_wrapper > a').bind('click',function(e){
var $this = $(this);
$('#msg_thumb_close').trigger('click');
var idx = $this.index();
var p_idx = $this.parent().index();
current = parseInt(p_idx*nmb_images_wrapper + idx + 1);
showImage();
e.preventDefault();
}).bind('mouseenter',function(){
var $this = $(this);
$this.stop().animate({'opacity':1});
}).bind('mouseleave',function(){
var $this = $(this); $this.stop().animate({'opacity':0.5});
});
/**
* resize the image to fit in the container (400 x 400)
*/
function resize($image){
var theImage = new Image();
theImage.src = $image.attr("src");
var imgwidth = theImage.width;
var imgheight = theImage.height;
var containerwidth = 400;
var containerheight = 400;
if(imgwidth > containerwidth){
var newwidth = containerwidth;
var ratio = imgwidth / containerwidth;
var newheight = imgheight / ratio;
if(newheight > containerheight){
var newnewheight = containerheight;
var newratio = newheight/containerheight;
var newnewwidth =newwidth/newratio;
theImage.width = newnewwidth;
theImage.height= newnewheight;
}
else{
theImage.width = newwidth;
theImage.height= newheight;
}
}
else if(imgheight > containerheight){
var newheight = containerheight;
var ratio = imgheight / containerheight;
var newwidth = imgwidth / ratio;
if(newwidth > containerwidth){
var newnewwidth = containerwidth;
var newratio = newwidth/containerwidth;
var newnewheight =newheight/newratio;
theImage.height = newnewheight;
theImage.width= newnewwidth;
}
else{
theImage.width = newwidth;
theImage.height= newheight;
}
}
$image.css({
'width' :theImage.width,
'height':theImage.height
});
}
});
</script>
</div>
Σημιωσεις:
Απλα αλλαζουμε τα κοκκινα γραμματα με τις δικες σας εικονες.
- Για το Demo απλα πατηστε την παρακατω εικονα.
- Για ότι πρόβλημα υπάρξει μην διστάσετε να επικοινωνήστε μαζί μας μεσώ του
κουμπιού "Επικοινωνία" που θα βρείτε πάνω πάνω.
- Αμα σας αρεσε παρακαλω προωθηστε το Blog μας ή πατηστε παρακολουθηση.
- Αμα σας αρεσε παρακαλω προωθηστε το Blog μας ή πατηστε παρακολουθηση.
Ευχαριστω.
Πηγη κωδικα: paulsantosh
kalispera!
ΑπάντησηΔιαγραφήpoli oreo to blog su!!!
mia erotisi: afto an thelo boro na to valo san anrtisi?
malon ohi e?
Γεια σου φιλε μου, πρωτον ευχαριστουμε για τα καλα σου λογια και δευτερον ποιο ενοεις να βαλεις σαν αναρτηση το παραπανω gadget?
ΑπάντησηΔιαγραφήne.
ΑπάντησηΔιαγραφήan boro na to anevaso san ansrtisi
Οχι φιλε, αυτο δεν γινεται στα Blog.
ΑπάντησηΔιαγραφή