My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<script type="text/javascript" src="/site-media/jcarousel.galleria.js"></script>
<script type="text/javascript">

//<![CDATA[
var staMarker = 0;
var endMarker = 5;
var curMarker = 0;
function onImageGalleria(image, caption, thumb){ // let's add some image effects for demonstration purposes

// fade in the image & caption
image.css('display','none').fadeIn(200);
caption.css('display','none').fadeIn(200);

// fetch the thumbnail container
var _li = thumb.parents('li');

// fade out inactive thumbnail
_li.siblings().children('img.selected').fadeTo(100,0.6);

// fade in active thumbnail
thumb.fadeTo('fast',1).addClass('selected');

// add a title for the clickable image
image.attr('title','Next panel >>');

$('#main_image').trigger('img_change');



};
function onThumbGalleria(thumb){ // thumbnail effects goes here

// fetch the thumbnail container
var _li = thumb.parents('li');
// if thumbnail is active, fade all the way.
var _fadeTo = _li.is('.active') ? '1' : '0.6';

// fade in the thumbnail when finished loading
thumb.css({display:'none',opacity:_fadeTo}).fadeIn(500);

// hover effects
thumb.hover(
function() { thumb.fadeTo('fast',1); },
function() { _li.not('.active').children('img').fadeTo('fast',0.6); } // don't fade out if the parent is active
)
};


$(document).ready(function(){

$('.jcarousel-skin-tango').addClass('gallery_show'); // adds new class name to maintain degradability

$('ul.gallery_show').galleria({
history : true, // activates the history object for bookmarking, back-button etc.
clickNext : true, // helper for making the image clickable
insert : '#main_image', // the containing selector for our main image
onImage : function(image, caption, thumb) {
onImageGalleria(image, caption, thumb);
},
onThumb : function(thumb) {
onThumbGalleria(thumb);
}
});

jQuery('#mycarousel').jcarousel({
scroll: 6,
initCallback: mycarousel_initCallback
});

$.hotkeys.add('left', function(){$.galleria.prev();});
$.hotkeys.add('right', function(){$.galleria.next();});


$(function() {
//var slideshow = $("gallerytitle");

var active = false;
var gal = jQuery('#gallerytitle');
gal.find('.start').css("cursor", "pointer").click(function() {
if (!active) {
active = !active;
$.galleria.next();
gal.everyTime('5s', 'slideshow', function() {
$.galleria.next();
});
}
});
//}).end().find('.stop').css("cursor", "pointer").click(function() {
gal.find('.stop').css("cursor", "pointer").click(function() {
if (active) {
active = !active;
gal.stopTime('slideshow');
}
});
});

});

function processNewImage(){
var _container = $('.newImage'); //supposed to be an li element

// try to fetch an anchor
var _a = $('.newImage').find('a').is('a') ? $('.newImage').find('a') : false;
//alert(_a);
// reference the original image as a variable and hide it
var _img = $('.newImage').children('img').css('display','none');
//alert(_img);
// extract the original source
var _src = _a ? _a.attr('href') : _img.attr('src');
//alert(_src);
// find a title
//alert(_img.attr('title'));
//alert(_img.attr('title').indexOf(':'));
if (_img.attr('title').indexOf(':')==-1)
{var _title = _a ? i + ":" + _a.attr('title') : i + ":" + _img.attr('title');}
else
{var _title = _img.attr('title');}

// create loader image
var _loader = new Image();
// check url and activate container if match
//if (_o.history && (window.location.hash && window.location.hash.replace(/\#/,'') == _src)) {
// _container.siblings('.active').removeClass('active');
// _container.addClass('active');
//}

// begin loader

$(_loader).load(function () {

// try to bring the alt
$(this).attr('alt',_img.attr('alt'));

//-----------------------------------------------------------------
// the image is loaded, let's create the thumbnail

var _thumb = _a ?
_a.find('img').addClass('thumb noscale').css('display','none') :
_img.clone(true).addClass('thumb').css('display','none');

if (_a) { _a.replaceWith(_thumb); }

if (!_thumb.hasClass('noscale')) { // scaled tumbnails!
var w = Math.ceil( _img.width() / _img.height() * _container.height() );
var h = Math.ceil( _img.height() / _img.width() * _container.width() );
if (w < h) {
_thumb.css({ height: 'auto', width: _container.width(), marginTop: -(h-_container.height())/2 });
} else {
_thumb.css({ width: 'auto', height: _container.height(), marginLeft: -(w-_container.width())/2 });
}
} else { // Center thumbnails.
// a tiny timer fixed the width/height
window.setTimeout(function() {
_thumb.css({
marginLeft: -( _thumb.width() - _container.width() )/2,
marginTop: -( _thumb.height() - _container.height() )/2
});
}, 1);
}

// add the rel attribute
_thumb.attr('rel',_src);

// add the title attribute
_thumb.attr('title',_title);

// add the click functionality to the _thumb
_thumb.click(function() {
$.galleria.activate(_src);
});

// hover classes for IE6
_thumb.hover(
function() { $('.newImage').addClass('hover'); },
function() { $('.newImage').removeClass('hover'); }
);
_container.hover(
function() { _container.addClass('hover'); },
function() { _container.removeClass('hover'); }
);

// prepend the thumbnail in the container
_container.prepend(_thumb);

// show the thumbnail
_thumb.css('display','block');

// call the onThumb function
_o.onThumb(jQuery(_thumb));

// check active class and activate image if match
if (_container.hasClass('active')) {
$.galleria.activate(_src);
//_span.text(_title);
}

//-----------------------------------------------------------------

// finally delete the original image
_img.remove();

}).error(function () {

// Error handling
_container.html('<span class="error" style="color:red">Error loading image: '+_src+'</span>');

}).attr('src', _src);
};

function mycarousel_initCallback(carousel) {
jQuery('#main_image').bind('img_change',function() {
var num = parseInt((jQuery('.caption').text()).split(":",1)[0])-1;
var diff = (num-staMarker)
if (diff>=2){
staMarker = staMarker+1;
jQuery.get('/ajax/next-image/{{series_name}}/{{issue_name}}/'+endMarker+'/', function(data){
//$('#mycarousel').append(data);
//alert(carousel.size());

endMarker = endMarker+1;
carousel.add(endMarker+1, data);
carousel.size(carousel.size()+1);
$('.jcarousel-item-'+(endMarker+1)).addClass('newImage');
//$('.galleria_wrapper').remove();
//$('.caption').remove();
//$('ul.gallery_show').galleria({
// history : true, // activates the history object for bookmarking, back-button etc.
// clickNext : true, // helper for making the image clickable
// insert : '#main_image', // the containing selector for our main image
// onImage : function(image, caption, thumb) {
// onImageGalleria(image, caption, thumb);
// },
// onThumb : function(thumb) {
// onThumbGalleria(thumb);
// }
//});
processNewImage();
$('.jcarousel-item-'+(endMarker+1)).removeClass('newImage');
//alert(carousel.size());
});};
curMarker = num+1;

carousel.scroll(num);
return false;
});
};

//]]>
</script>

Change log

r15 by trinioler on May 18, 2008   Diff
update
Go to: 
Project members, sign in to write a code review

Older revisions

r11 by trinioler on May 15, 2008   Diff
update
All revisions of this file

File info

Size: 8087 bytes, 249 lines
Powered by Google Project Hosting