jquery gallery

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
(function($){
var settings;
$.fn.photomatic = function(callerSettings) {
settings = $.extend({
photoElement: '#photomaticPhoto',
transformer: function(name) {
return name.replace(/thumbnail/,'photo');
},
nextControl: null,
previousControl: null,
firstControl: null,
lastControl: null
},callerSettings||{});
settings.photoElement = $(settings.photoElement);
settings.thumbnails = this.filter('img');
settings.thumbnails.each(function(n){this.index = n;});
settings.current = 0;
settings.thumbnails.click(function(){ showPhoto(this.index); });
settings.photoElement.click(function(){
showPhoto((settings.current+1) % settings.thumbnails.length);
});
$(settings.nextControl).click(function(){
showPhoto((settings.current+1) % settings.thumbnails.length);
});
$(settings.previousControl).click(function(){
showPhoto((settings.thumbnails.length+settings.current-1) %
settings.thumbnails.length);
});
$(settings.firstControl).click(function(){
showPhoto(0);
});
$(settings.lastControl).click(function(){
showPhoto(settings.thumbnails.length-1);
});
showPhoto(0);
return this;
};
var showPhoto = function(index) {
settings.photoElement
.attr('src',
settings.transformer(settings.thumbnails[index].src));
settings.current = index;
};
})(jQuery);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Photomatic Test</title>
<link rel="stylesheet" type="text/css" href="../../common.css">
<link rel="stylesheet" type="text/css" href="photomatic.css">
<script type="text/javascript"
src="../../scripts/jquery-1.2.1.js"></script>
<script type="text/javascript"
src="jquery.jqia.photomatic.js"></script>
<script type="text/javascript">
$(function(){
$('#thumbnails img').photomatic({
photoElement: '#photo',
previousControl: '#previousButton',
nextControl: '#nextButton',
firstControl: '#firstButton',
lastControl: '#lastButton'
});
});
</script>
</head>
<body>
<h1>Photomatic Tester</h1>
<div id="thumbnails">
<img src="thumbnails/IMG_2212.jpg"/>
<img src="thumbnails/IMG_2222.jpg"/>
<img src="thumbnails/IMG_2227.jpg"/>
<img src="thumbnails/IMG_2235.jpg"/>
<img src="thumbnails/IMG_2259.jpg"/>
<img src="thumbnails/IMG_2269.jpg"/>
<img src="thumbnails/IMG_2273.jpg"/>
<img src="thumbnails/IMG_2287.jpg"/>
<img src="thumbnails/IMG_2292.jpg"/>
<img src="thumbnails/IMG_2296.jpg"/>
<img src="thumbnails/IMG_2298.jpg"/>
<img src="thumbnails/IMG_2302.jpg"/>
<img src="thumbnails/IMG_2310.jpg"/>
<img src="thumbnails/IMG_2319.jpg"/>
<img src="thumbnails/IMG_2331.jpg"/>
<img src="thumbnails/IMG_2335.jpg"/>
</div>
<div id="photoContainer">
<img id="photo" src=""/>
</div>
<div id="buttonBar">
<button type="button" id="firstButton">First</button>
<button type="button" id="previousButton">Previous</button>
<button type="button" id="nextButton">Next</button>
<button type="button" id="lastButton">Last</button>
</div>
</body>
</html>