/[drupal]/contributions/modules/node_images/node_images.js
ViewVC logotype

Contents of /contributions/modules/node_images/node_images.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Sun Aug 17 21:19:11 2008 UTC (15 months, 1 week ago) by stefano73
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +9 -13 lines
File MIME type: text/javascript
Initial relase for 6.x
1 // $Id: node_images.js,v 1.0 2008/03/27 05:00:48 stefano73 Exp $
2
3 Drupal.behaviors.node_images_slideshow = function() {
4 for (var node in Drupal.settings.node_images_slideshow) {
5 var slideshow = Drupal.settings.node_images_slideshow[node], container = $('#slideshow-' + node);
6
7 function preloadImages(i) {
8 var n = slideshow.images[++i];
9 if (slideshow.current != i) {
10 if (n) {
11 n.image = $('<img>').attr('src', n.src).load(function() { preloadImages(i); });
12 } else preloadImages(0);
13 }
14 }
15
16 function updateSlideshow(previous) {
17 if (slideshow.current != previous) {
18 $('#thumb-' + previous).removeClass('active');
19 $('#thumb-' + slideshow.current).addClass('active');
20 }
21
22 var current = slideshow.images[slideshow.current];
23 current.title = current.title || '';
24 current.description = current.description || '';
25 current.href = current.href || '#';
26
27 container.
28 find('.polaroid').attr('src', current.src).css({ opacity: 0.8 }).animate({ opacity: 1, width: current.width, height: current.height }).end().
29 find('.title').html(current.title).end().find('.description').html(current.description).end().
30 find('.link').attr('href', current.href).end().find('.current').html(slideshow.current).end();
31 return false;
32 }
33
34 container.find('.previous').click(function() {
35 var current = slideshow.current;
36 if(!(slideshow.images[--slideshow.current])) slideshow.current = slideshow.total;
37 return updateSlideshow(current);
38 }).end().
39
40 find('.next').click(function() {
41 var current = slideshow.current;
42 if(!(slideshow.images[++slideshow.current])) slideshow.current = 1;
43 return updateSlideshow(current);
44 }).end();
45
46 $('.slideshow-thumb').each(function () {
47 $(this).click(function() {
48 var previous = slideshow.current;
49 slideshow.current = this.id.substr(6, this.id.length-6);
50 return updateSlideshow(previous);
51 });
52 });
53
54 preloadImages(slideshow.current);
55 $('#thumb-' + slideshow.current).addClass('active');
56 }
57 }

  ViewVC Help
Powered by ViewVC 1.1.2