| 1 |
// $Id: slideshow_creator\040developer.js,v 1.1.1.1 2007/08/01 14:26:36 brmassa Exp $
|
| 2 |
/*******************************************************************************
|
| 3 |
D R U P A L M O D U L E
|
| 4 |
********************************************************************************
|
| 5 |
Module Name : Slideshow Creator
|
| 6 |
Original Author : Bruno Massa http://drupal.org/user/67164
|
| 7 |
General Links
|
| 8 |
Project Page : http://drupal.org/project/slideshow_creator
|
| 9 |
Support Queue : http://drupal.org/project/issues/slideshow_creator
|
| 10 |
|
| 11 |
*******************************************************************************/
|
| 12 |
|
| 13 |
// Preload all images before start the slideshow
|
| 14 |
function ssc_preload(ss, j) {
|
| 15 |
var n = ssc[ss][j];
|
| 16 |
if(n) {
|
| 17 |
n.image = new Image();
|
| 18 |
n.image.src = n.src;
|
| 19 |
n.image.onload = function() {ssc_preload(ss, ++j);}
|
| 20 |
}
|
| 21 |
}
|
| 22 |
|
| 23 |
// Set the previous slide as the current slide
|
| 24 |
function ssc_previous(ss) {
|
| 25 |
if(!ssc[ss][--ssc[ss].current]) {ssc[ss].current=ssc[ss].total;}
|
| 26 |
ssc_update(ss);
|
| 27 |
}
|
| 28 |
|
| 29 |
// Set the next slide as the current slide
|
| 30 |
function ssc_next(ss) {
|
| 31 |
if(!ssc[ss][++ssc[ss].current]) {ssc[ss].current=1;}
|
| 32 |
ssc_update(ss);
|
| 33 |
}
|
| 34 |
|
| 35 |
// Update all slide attributes
|
| 36 |
function ssc_update(ss) {
|
| 37 |
if (ssc[ss].rotate > 0) {clearTimeout(ssc[ss].timeout);}
|
| 38 |
var obj = ssc[ss][ssc[ss].current];
|
| 39 |
if (obj.description) {$("#ssc-description-" + ss).html(obj.description)};
|
| 40 |
if (obj.title) {$("#ssc-title-" + ss).html(obj.title);}
|
| 41 |
$("#ssc-current-" + ss).html(ssc[ss].current);
|
| 42 |
$("#ssc-limage-" + ss).attr("href", obj.link).attr("target", obj.target);
|
| 43 |
$("#ssc-ltitle-" + ss).attr("href", obj.link);
|
| 44 |
$("#ssc-image-" + ss).attr("src", obj.src).attr("alt", obj.title);
|
| 45 |
if (ssc[ss].blend) {$("#ssc-limage-" + ss).fadeIn(ssc[ss].blend * 1000); $("#ssc-limage-" + ss).show();}
|
| 46 |
if (ssc[ss].rotate > 0) {ssc[ss].timeout = setTimeout("ssc_next('" + ss + "')", ssc[ss].rotate * 1000);}
|
| 47 |
}
|
| 48 |
|
| 49 |
// initialize all variables and make "previous" and "next" buttons call js functions
|
| 50 |
function ssc_init() {
|
| 51 |
ssc = Drupal.settings.ssc;
|
| 52 |
for (ss in ssc) {
|
| 53 |
ssc_preload(ss, 1);
|
| 54 |
$("#ssc-previous-" + ss).click(function() {ssc_previous(this.id.replace(/ssc-previous-/,"")); return false;});
|
| 55 |
$("#ssc-next-" + ss).click(function() {ssc_next(this.id.replace(/ssc-next-/,"")); return false;});
|
| 56 |
$("#ssc-image-" + ss).mouseover(function() {
|
| 57 |
ss = $(this).attr("id").replace(/ssc-image-/, "");
|
| 58 |
if (ssc[ss].rotate > 0) {clearTimeout(ssc[ss].timeout);}
|
| 59 |
}).mouseout(function() {
|
| 60 |
ss = $(this).attr("id").replace(/ssc-image-/, "");
|
| 61 |
if (ssc[ss].rotate > 0) {ssc[ss].timeout = setTimeout("ssc_next('" + ss + "')", ssc[ss].rotate * 1000);}
|
| 62 |
});
|
| 63 |
if (ssc[ss].blend > ssc[ss].rotate) {ssc[ss].blend = ssc[ss].rotate;}
|
| 64 |
if (ssc[ss].rotate > 0) {ssc[ss].timeout = setTimeout("ssc_next('" + ss + "')", ssc[ss].rotate * 1000);}
|
| 65 |
}
|
| 66 |
}
|
| 67 |
|
| 68 |
$(function() {ssc_init();})
|