2 copyright 2008-2014 Benoit Pin - Centre de recherche en informatique - MINES ParisTech
4 Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/
11 var keyLeft
= 37, keyRight
= 39;
12 var isTextMime
= /^text\/.+/i;
13 var isAddToSelection
= /.*\/add_to_selection$/;
14 var imgRequestedSize
= /size=(\d+)/;
15 var DEFAULT_IMAGE_SIZES
= [500, 600, 800];
17 FilmSlider = function(filmBar
, slider
, ctxInfos
, image
, toolbar
, breadcrumbs
) {
18 var thisSlider
= this;
19 this.filmBar
= filmBar
;
20 this.filmBarWidth
= getObjectWidth(this.filmBar
);
21 var film
= filmBar
.firstChild
;
22 if (film
.nodeType
=== 3) { film
= film
.nextSibling
; }
25 this.rail
= slider
.parentNode
;
26 this.sliderSpeedRatio
= undefined;
27 this.sliderRatio
= undefined;
28 this.selectedSlide
= undefined;
29 this.selectedSlideInSelection
= undefined;
30 this.cartSlide
= document
.getElementById('cart_slide');
32 this.stretchable
= image
.parentNode
;
33 this.viewMode
= 'medium';
36 this.toolbar
= toolbar
;
38 var bcElements
= breadcrumbs
.getElementsByTagName('a');
39 this.lastBCElement
= bcElements
[bcElements
.length
-1];
40 var imgSrcParts
= image
.src
.split('/');
41 this.lastBCElement
.innerHTML
= imgSrcParts
[imgSrcParts
.length
-2];
42 this.hasBreadcrumbs
= true;
45 this.hasBreadcrumbs
= false;
48 var buttons
= toolbar
.getElementsByTagName('img');
50 for (i
=0 ; i
<buttons
.length
; i
++) {
52 name
= b
.getAttribute('name');
53 if (name
) { this.buttons
[name
] = b
; }
56 this.pendingImage
= new Image();
57 this.pendingImage
.onload = function() {
58 thisSlider
.refreshImage();
60 this.initialized
= false;
62 this.film
.style
.left
='0';
63 this.film
.style
.top
='0';
65 this.filmLength
= ctxInfos
.filmLength
;
66 this.center
= ctxInfos
.center
;
67 this.slideSize
= ctxInfos
.slideSize
;
68 this.ctxUrlTranslation
= ctxInfos
.ctxUrlTranslation
;
70 this.ddHandlers
= {'down' : function(evt
){thisSlider
.mouseDownHandler(evt
);},
71 'move' : function(evt
){thisSlider
.mouseMoveHandler(evt
);},
72 'up' : function(evt
){thisSlider
.mouseUpHandler(evt
);},
73 'out' : function(evt
){thisSlider
.mouseOutHandler(evt
);}
76 if (browser
.isMobile
) {
77 this.rail
.className
= 'hidden';
82 this.addEventListeners();
85 if (!browser
.isMobile
) {
86 FilmSlider
.prototype.resizeSlider = function(evt
) {
87 var filmBarWidth
= this.filmBarWidth
;
88 if (!filmBarWidth
) { return; }
89 var filmWidth
= this.slideSize
* this.filmLength
;
90 var sliderRatio
= this.sliderRatio
= filmBarWidth
/ filmWidth
;
91 var sliderWidth
= filmBarWidth
* sliderRatio
;
92 this.rail
.style
.width
= filmBarWidth
+ 'px';
93 this.rail
.style
.display
= 'block';
94 this.rail
.style
.visibility
= 'visible';
95 if (sliderRatio
< 1) {
96 this.slider
.style
.width
= Math
.round(sliderWidth
) + 'px';
97 this.slider
.style
.visibility
= 'visible';
100 this.slider
.style
.visibility
= 'hidden';
103 this.winSize
= {'width' : getWindowWidth(),
104 'height' : getWindowHeight()};
105 this.maxRightPosition
= filmBarWidth
- sliderWidth
;
106 this.sliderSpeedRatio
= - (filmBarWidth
- sliderWidth
) / (filmWidth
- filmBarWidth
);
107 if (!this.initialized
) {
108 this.centerSlide(this.center
);
109 this.selectedSlide
= this.filmBar
.getElementsByTagName('img')[this.center
].parentNode
;
110 this.initialized
= true;
116 // pas de barre de scroll horizontal pour les tablettes
117 FilmSlider
.prototype.resizeSlider = function(evt
) {
118 this.filmMaxX
= - (getObjectWidth(this.film
) - this.filmBarWidth
);
119 if (!this.initialized
) {
120 this.centerSlide(this.center
);
121 this.selectedSlide
= this.filmBar
.getElementsByTagName('img')[this.center
].parentNode
;
122 this.initialized
= true;
127 FilmSlider
.prototype._checkSizeAfterLoad = function(evt
) {
129 this.filmBarWidth
= this._barSizes
[this._barSizes
.length
] = getObjectWidth(this.filmBar
);
132 this._checkSizeIntervalId
= setInterval(function(evt
){self
._checkSize(evt
);}, 25);
133 setTimeout(function(evt
){self
._checkSizeStability();}, 250);
136 FilmSlider
.prototype._checkSize = function(evt
) {
137 this._barSizes
[this._barSizes
.length
] = getObjectWidth(this.filmBar
);
138 if (this._barSizes
.length
>= 2 &&
139 this._barSizes
[this._barSizes
.length
-2] !== this._barSizes
[this._barSizes
.length
-1]) {
140 this.filmBarWidth
= this._barSizes
[this._barSizes
.length
-1];
141 this.initialized
= false;
146 FilmSlider
.prototype._checkSizeStability = function(evt
) {
149 var checkAgain = function(evt
){self
._checkSizeStability();};
150 for (i
=0 ; i
<this._barSizes
.length
- 1 ; i
++) {
151 if (this._barSizes
[i
] !== this._barSizes
[i
+1]) {
153 setTimeout(checkAgain
, 250);
157 clearInterval(this._checkSizeIntervalId
);
158 delete this._barSizes
;
159 delete this._checkSizeIntervalId
;
162 FilmSlider
.prototype.fitToScreen = function(evt
) {
164 var thisSlider
= this;
165 addListener(window
, 'resize', function(evt
){thisSlider
._fitToScreen();});
168 FilmSlider
.prototype._fitToScreen = function(evt
) {
169 var wh
= getWindowHeight();
171 if (!browser
.isMobile
) {
172 rb
= getObjectTop(this.rail
) + getObjectHeight(this.rail
); // rail bottom
175 rb
= getObjectTop(this.filmBar
) + getObjectHeight(this.filmBar
); // film bottom
178 var sh
= getObjectHeight(this.stretchable
);
179 var newSize
= sh
+ delta
;
180 this.stretchable
.style
.height
= newSize
+ 'px';
182 var ratio
= this.image
.height
/ this.image
.width
;
183 var bestFitSize
= this.getBestFitSize(ratio
);
184 var currentSize
= parseInt(imgRequestedSize
.exec(this.image
.src
)[1], 10);
185 if (currentSize
!== bestFitSize
) {
186 var src
= this.image
.src
.replace(imgRequestedSize
, 'size=' + bestFitSize
);
187 this.pendingImage
.src
= src
;
191 FilmSlider
.prototype.getBestFitSize = function(ratio
) {
192 var fw
= getObjectWidth(this.stretchable
) - 1;
193 var fh
= getObjectHeight(this.stretchable
) - 1;
197 for (i
=DEFAULT_IMAGE_SIZES
.length
-1 ; i
>0 ; i
--) {
198 irw
= DEFAULT_IMAGE_SIZES
[i
];
200 if (irw
<= fw
&& irh
<= fh
) { break; }
204 for (i
=DEFAULT_IMAGE_SIZES
.length
-1 ; i
>0 ; i
--) {
205 irh
= DEFAULT_IMAGE_SIZES
[i
];
207 if (irw
<= fw
&& irh
<= fh
) { break; }
210 return DEFAULT_IMAGE_SIZES
[i
];
213 if (!browser
.isMobile
) {
214 FilmSlider
.prototype.centerSlide = function(slideIndex
) {
215 if (this.sliderRatio
> 1) { return; }
216 var filmBarWidth
= getObjectWidth(this.filmBar
);
217 var x
= slideIndex
* this.slideSize
;
218 x
= x
- (filmBarWidth
- this.slideSize
) / 2.0;
219 x
= x
* this.sliderSpeedRatio
;
220 var p
= new Point( -x
, 0 );
221 this.setSliderPosition(p
);
225 FilmSlider
.prototype.centerSlide = function(slideIndex
) {
226 var filmBarWidth
= getObjectWidth(this.filmBar
);
227 var x
= slideIndex
* this.slideSize
;
228 x
= x
- (filmBarWidth
- this.slideSize
) / 2.0;
229 this.setFilmPosition(-x
);
233 FilmSlider
.prototype.setSliderPosition = function(point
) {
234 if(point
.x
< 0) { point
.x
= 0; }
235 if (point
.x
> this.maxRightPosition
) { point
.x
= this.maxRightPosition
; }
236 this.slider
.style
.left
= point
.x
+ 'px';
237 this.setFilmPosition(point
);
240 if (!browser
.isMobile
) {
241 FilmSlider
.prototype.setFilmPosition = function(point
) {
242 this.film
.style
.left
= point
.x
/ this.sliderSpeedRatio
+ 'px';
246 FilmSlider
.prototype.setFilmPosition = function(x
) {
248 x
= Math
.max(this.filmMaxX
, x
);
249 this.film
.style
.left
= String(x
) + 'px';
253 FilmSlider
.prototype.getSliderPosition = function() {
254 var x
= parseInt(this.slider
.style
.left
, 10);
255 var y
= parseInt(this.slider
.style
.top
, 10);
256 var p
= new Point(x
, y
);
260 FilmSlider
.prototype.getFilmPosition = function() {
261 var x
= parseInt(this.film
.style
.left
, 10);
262 var y
= parseInt(this.film
.style
.top
, 10);
263 var p
= new Point(x
, y
);
267 FilmSlider
.prototype.loadSibling = function(previous
) {
270 slide
= this.selectedSlide
.parentNode
.previousSibling
;
271 if (slide
&& slide
.nodeType
===3) { slide
= slide
.previousSibling
; }
274 slide
= this.selectedSlide
.parentNode
.nextSibling
;
275 if (slide
&& slide
.nodeType
===3) { slide
= slide
.nextSibling
; }
278 if (!slide
) { return; }
280 var target
= slide
.getElementsByTagName('a')[0];
281 raiseMouseEvent(target
, 'click');
282 var index
= parseInt(target
.getAttribute('portfolio:position'), 10);
283 this.centerSlide(index
);
287 FilmSlider
.prototype.addEventListeners = function() {
288 var thisSlider
= this;
289 addListener(window
, 'resize', function(evt
){thisSlider
.resizeSlider(evt
);});
290 addListener(this.filmBar
, 'click', function(evt
){thisSlider
.thumbnailClickHandler(evt
);});
291 addListener(this.toolbar
, 'click', function(evt
){thisSlider
.toolbarClickHandler(evt
);});
292 addListener(window
, 'load', function(evt
){thisSlider
.fitToScreen(evt
);});
293 addListener(window
, 'load', function(evt
){thisSlider
._checkSizeAfterLoad(evt
);});
294 addListener(window
, 'load', function(evt
){thisSlider
.startThumbnailsLoadQueue(evt
);});
297 addListener(this.slider
, 'mousedown', this.ddHandlers
.down
);
298 if(browser
.isDOM2Event
){
299 if (browser
.isAppleWebKit
) {
300 this.filmBar
.addEventListener('mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);}, false);
303 addListener(this.filmBar
, 'DOMMouseScroll', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
306 else if (browser
.isIE6up
) {
307 addListener(this.filmBar
, 'mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
309 if (browser
.isMobile
) {
310 this.filmBar
.addEventListener('touchstart', function(evt
){thisSlider
.touchStartHandler(evt
);}, false);
311 this.filmBar
.addEventListener('touchmove', function(evt
){thisSlider
.touchMoveHandler(evt
);}, false);
312 this.filmBar
.addEventListener('touchend', function(evt
){thisSlider
.touchEndHandler(evt
);}, false);
315 addListener(document
, 'keydown', function(evt
){thisSlider
.keyDownHandler(evt
);});
316 addListener(document
, 'keypress', function(evt
){thisSlider
.keyPressHandler(evt
);});
320 FilmSlider
.prototype.mouseDownHandler = function(evt
) {
321 this.initialClickPoint
= new Point(evt
.clientX
, evt
.clientY
);
322 this.initialPosition
= this.getSliderPosition();
323 this.dragInProgress
= true;
324 addListener(document
, 'mousemove', this.ddHandlers
.move);
325 addListener(document
, 'mouseup', this.ddHandlers
.up
);
326 addListener(document
.body
, 'mouseout', this.ddHandlers
.out
);
330 FilmSlider
.prototype.mouseMoveHandler = function(evt
) {
331 if(!this.dragInProgress
) { return; }
334 evt
= getEventObject(evt
);
335 var currentPoint
= new Point(evt
.clientX
, evt
.clientY
);
336 var displacement
= currentPoint
.diff(this.initialClickPoint
);
337 this.setSliderPosition(this.initialPosition
.add(displacement
));
340 FilmSlider
.prototype.mouseUpHandler = function(evt
) {
341 this.dragInProgress
= false;
342 evt
= getEventObject(evt
);
343 this.mouseMoveHandler(evt
);
347 FilmSlider
.prototype.mouseOutHandler = function(evt
) {
348 evt
= getEventObject(evt
);
352 x
> this.winSize
.width
||
354 y
> this.winSize
.height
356 this.mouseUpHandler(evt
);
360 FilmSlider
.prototype.translateImgUrl = function(url
) {
362 if (this.ctxUrlTranslation
[0]) {
363 canonicalImgUrl
= url
.replace(this.ctxUrlTranslation
[0],
364 this.ctxUrlTranslation
[1]);
367 canonicalImgUrl
= url
;
369 return canonicalImgUrl
;
372 FilmSlider
.prototype.thumbnailClickHandler = function(evt
) {
373 var target
= getTargetedObject(evt
);
374 while (target
.tagName
!== 'A' && target
!== this.filmBar
) { target
= target
.parentNode
; }
375 if (target
.tagName
!== 'A') { return; }
377 if (this.viewMode
=== 'full') {
378 this.mosaique
.unload();
379 this.mosaique
= null;
380 this.viewMode
= 'medium';
383 disablePropagation(evt
);
385 history
.pushState(target
.href
, '', target
.href
);
387 var imgBaseUrl
= target
.href
;
388 var canonicalImgUrl
= this.translateImgUrl(imgBaseUrl
);
390 var ajaxUrl
= imgBaseUrl
+ '/photo_view_ajax';
393 //this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=600';
394 var thumbnail
= target
.getElementsByTagName('IMG')[0];
395 var bestFitSize
= this.getBestFitSize(thumbnail
.height
/thumbnail
.width
);
396 this.pendingImage
.src
= canonicalImgUrl
+ '/getResizedImage?size=' + bestFitSize
;
399 var fullScreenLink
= this.buttons
.full_screen
.parentNode
;
400 fullScreenLink
.href
= canonicalImgUrl
+ '/zoom_view';
402 var toggleSelectionBtn
= this.buttons
.toggle_selection
;
403 var toggleSelectionLink
= toggleSelectionBtn
.parentNode
;
404 this.selectedSlideInSelection
= (target
.className
==='selected');
405 if (this.selectedSlideInSelection
) {
406 toggleSelectionBtn
.src
= portal_url() + '/unselect_flag_btn.gif';
407 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Retirer de la sélection';
408 toggleSelectionLink
.href
= canonicalImgUrl
+ '/remove_to_selection';
411 toggleSelectionBtn
.src
= portal_url() + '/select_flag_btn.gif';
412 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Ajouter à la sélection';
413 toggleSelectionLink
.href
= canonicalImgUrl
+ '/add_to_selection';
416 var showBuyableButtonLink
= this.buttons
.show_buyable
.parentNode
;
417 showBuyableButtonLink
.href
= canonicalImgUrl
+ '/get_slide_buyable_items';
418 this.cartSlide
.innerHTML
= '';
419 this.cartSlide
.style
.visibility
='hidden';
422 var metadataButton
= this.buttons
.edit_metadata
;
423 if (metadataButton
) {
424 var metadataEditLink
= metadataButton
.parentNode
;
425 metadataEditLink
.href
= canonicalImgUrl
+ '/photo_edit_form';
429 var req
= new XMLHttpRequest();
430 req
.onreadystatechange = function() {
431 switch (req
.readyState
) {
437 if (! isTextMime
.exec(req
.getResponseHeader('Content-Type'))) {
438 req
.onreadystatechange
= null;
441 window
.location
.href
= thisFS
._fallBackUrl
;
448 if (req
.status
=== 200) { thisFS
.populateViewer(req
); }
453 req
.open("GET", ajaxUrl
, true);
456 // update old displayed slide className
457 var className
= this.selectedSlide
.className
;
458 var classes
= className
.split(' ');
462 for (i
=0 ; i
<classes
.length
; i
++) {
464 if (name
!== 'displayed') {
465 newClasses
.push(name
);
469 this.selectedSlide
.className
= newClasses
.join(' ');
471 // hightlight new displayed slide
472 this.selectedSlide
= target
;
473 className
= this.selectedSlide
.className
;
474 classes
= className
.split(' ');
475 classes
.push('displayed');
476 this.selectedSlide
.className
= classes
.join(' ');
480 FilmSlider
.prototype.toolbarClickHandler = function(evt
) {
481 var target
= getTargetedObject(evt
);
482 var button
, link
, url
;
483 if(target
.tagName
=== 'IMG' && target
.getAttribute('name')) {
484 switch(target
.getAttribute('name')) {
487 disablePropagation(evt
);
489 link
= button
.parentNode
;
491 this.loadSibling(true);
495 disablePropagation(evt
);
497 link
= button
.parentNode
;
499 this.loadSibling(false);
503 disablePropagation(evt
);
504 target
.parentNode
.blur();
505 if (this.viewMode
=== 'full') {
506 this.mosaique
.unload();
507 this.mosaique
= null;
508 this.viewMode
= 'medium';
511 var main
= document
.getElementById('photo_viewer');
512 url
= target
.parentNode
.href
;
513 url
= url
.substring(0, url
.length
- '/zoom_view'.length
);
514 var margins
= {'top':0, 'right':-1, 'bottom':0, 'left':0};
515 this.mosaique
= new Mosaique(main
, url
, margins
);
516 this.viewMode
= 'full';
519 case 'toggle_selection':
521 disablePropagation(evt
);
523 link
= button
.parentNode
;
526 var req
= new XMLHttpRequest();
528 req
.open("POST", url
, true);
529 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
533 var parts
= url
.split('/');
534 var canonicalImgUrl
= parts
.slice(0, parts
.length
-1).join('/');
536 if (isAddToSelection
.test(url
)) {
537 button
.src
= portal_url() + '/unselect_flag_btn.gif';
538 button
.alt
= link
.title
= 'Retirer de la sélection';
539 link
.href
= canonicalImgUrl
+ '/remove_to_selection';
540 this.selectedSlide
.className
= 'selected displayed';
541 this.image
.parentNode
.className
= 'selected';
542 this.selectedSlideInSelection
= true;
545 button
.src
= portal_url() + '/select_flag_btn.gif';
546 button
.alt
= link
.title
= 'Ajouter à la sélection';
547 link
.href
= canonicalImgUrl
+ '/add_to_selection';
548 this.selectedSlide
.className
= 'displayed';
549 this.image
.parentNode
.className
= '';
550 this.selectedSlideInSelection
= false;
556 disablePropagation(evt
);
558 link
= button
.parentNode
;
560 var slide
= this.cartSlide
;
561 slide
.innerHTML
= '';
562 slide
.style
.visibility
= 'visible';
563 var cw
= new CartWidget(slide
, link
.href
);
564 cw
.onCancel = function() {
565 CartWidget
.prototype.onCancel
.apply(this);
566 slide
.style
.visibility
= 'hidden';
568 cw
.onAfterConfirm = function() {
569 slide
.style
.visibility
= 'hidden';
577 case 'edit_metadata' :
579 disablePropagation(evt);
581 if (this.viewMode === 'full') {
582 this.mosaique.unload();
583 this.mosaique = null;
584 this.viewMode = 'medium';
587 var fi = new FragmentImporter(absolute_url());
588 fi.useMacro('metadata_edit_form_macros', 'iptc', 'image_metadata');
596 if(browser
.isDOM2Event
) {
597 if (browser
.isAppleWebKit
) {
598 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
600 var pos
= this.getSliderPosition();
601 pos
.x
-= evt
.wheelDelta
/ 40;
602 this.setSliderPosition(pos
);
606 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
608 var pos
= this.getSliderPosition();
609 pos
.x
+= evt
.detail
* 3;
610 this.setSliderPosition(pos
);
614 else if (browser
.isIE6up
) {
615 FilmSlider
.prototype.mouseWheelHandler = function() {
616 var evt
= window
.event
;
617 evt
.returnValue
= false;
618 var pos
= this.getSliderPosition();
619 pos
.x
-= evt
.wheelDelta
/ 40;
620 this.setSliderPosition(pos
);
624 FilmSlider
.prototype.touchStartHandler = function(evt
) {
625 this.filmStartX
= parseInt(this.film
.style
.left
, 10);
626 this.touchStartX
= evt
.changedTouches
[0].screenX
;
627 this.touchStartTime
= (new Date()).getTime();
630 FilmSlider
.prototype.touchMoveHandler = function(evt
) {
632 var delta
= this.touchStartX
- evt
.changedTouches
[0].screenX
;
633 var posX
= this.filmStartX
- delta
;
634 this.setFilmPosition(posX
);
635 this.lastMoveTime
= (new Date()).getTime();
638 FilmSlider
.prototype.touchEndHandler = function(evt
) {
639 var x
= evt
.changedTouches
[0].screenX
;
640 var delta
= x
- this.touchStartX
;
643 var now
= (new Date()).getTime();
644 if (now
- this.lastMoveTime
< 100) {
645 // au delà de 100 ms de maintient, on annule l'inertie
646 var speed
= delta
/ (now
- this.touchStartTime
);
647 var x0
= parseInt(this.film
.style
.left
, 10);
648 var t0
= (new Date()).getTime();
649 var d
= 500; // milisecondes
654 var animate = function() {
656 var t
= (new Date()).getTime() - t0
;
658 setTimeout(animate
, dt
);
659 delta
= delta
+ (1-t
/d) * speed * dt; // d
écelleration lin
éaire
660 self
.setFilmPosition(x0
+ delta
);
666 this.touchStartX
= undefined;
670 FilmSlider
.prototype.keyDownHandler = function(evt
) {
671 evt
= getEventObject(evt
);
672 switch (evt
.keyCode
) {
674 this.loadSibling(true);
677 this.loadSibling(false);
685 FilmSlider
.prototype.keyPressHandler = function(evt
) {
686 var target
= getTargetedObject(evt
);
687 if (target
.tagName
=== 'INPUT' || target
.tagName
=== 'TEXTAREA') { return; }
688 evt
= getEventObject(evt
);
689 var charPress
= String
.fromCharCode((evt
.keyCode
) ? evt
.keyCode
: evt
.which
);
693 raiseMouseEvent(this.buttons
.full_screen
, 'click');
698 FilmSlider
.prototype.populateViewer = function(req
) {
699 var elements
= req
.responseXML
.documentElement
.childNodes
;
701 for(i
=0 ; i
< elements
.length
; i
++ ) {
702 element
= elements
[i
];
703 switch (element
.nodeName
) {
705 var dest
= document
.getElementById(element
.getAttribute('id'));
706 if (dest
) { dest
.innerHTML
= element
.firstChild
.nodeValue
; }
708 case 'imageattributes' :
709 var link
= this.buttons
.back_to_portfolio
.parentNode
;
710 link
.href
= element
.getAttribute('back_to_context_url');
711 link
= this.buttons
.show_buyable
.parentNode
;
712 var buyable
= element
.getAttribute('buyable');
713 if(buyable
=== 'True') { link
.className
= null; }
714 else if(buyable
=== 'False') { link
.className
= 'hidden'; }
715 this.image
.alt
= element
.getAttribute('alt');
716 this.updateBreadcrumbs(element
.getAttribute('last_bc_url'),
717 element
.getAttribute('img_id'));
723 FilmSlider
.prototype.refreshImage = function() {
724 this.image
.style
.visibility
= 'hidden';
725 this.image
.src
= this.pendingImage
.src
;
726 this.image
.width
= this.pendingImage
.width
;
727 this.image
.height
= this.pendingImage
.height
;
728 this.image
.style
.visibility
= 'visible';
729 if (this.selectedSlideInSelection
) { this.image
.parentNode
.className
= 'selected'; }
730 else { this.image
.parentNode
.className
= ''; }
733 FilmSlider
.prototype.updateBreadcrumbs = function(url
, title
) {
734 if (this.hasBreadcrumbs
) {
735 this.lastBCElement
.href
= url
;
736 this.lastBCElement
.innerHTML
= title
;
740 FilmSlider
.prototype.startThumbnailsLoadQueue = function(evt
) {
741 var thumbnails
= this.film
.getElementsByTagName('img');
742 if (thumbnails
.length
=== 1) { return; }
743 this.thumbnailsLoadingOrder
= [];
744 var leftSize
= this.center
;
745 var rightSize
= thumbnails
.length
- this.center
- 1;
747 for (i
=1 ; i
<=Math
.min(leftSize
, rightSize
) ; i
++) {
748 this.thumbnailsLoadingOrder
.push(thumbnails
[this.center
+ i
]);
749 this.thumbnailsLoadingOrder
.push(thumbnails
[this.center
- i
]);
751 if (leftSize
> rightSize
) {
752 for (i
= this.center
- rightSize
- 1 ; i
>= 0 ; i
--) {
754 this.thumbnailsLoadingOrder
.push(thumbnails
[i
]);
757 else if (leftSize
< rightSize
) {
758 for (i
= this.center
+ leftSize
; i
< thumbnails
.length
; i
++) {
759 this.thumbnailsLoadingOrder
.push(thumbnails
[i
]);
762 var next
= this.thumbnailsLoadingOrder
.shift();
764 addListener(next
, 'load', function(evt
){self
._loadNextThumb(evt
);});
765 next
.src
= this.translateImgUrl(next
.parentNode
.href
) + '/getThumbnail';
768 FilmSlider
.prototype._loadNextThumb = function(evt
) {
769 var next
= this.thumbnailsLoadingOrder
.shift();
772 addListener(next
, 'load', function(evt
){self
._loadNextThumb(evt
);});
773 next
.src
= this.translateImgUrl(next
.parentNode
.href
) + '/getThumbnail';
777 FilmSlider
.prototype.startSlideShow = function() {
778 this.slideShowSlide
= this.pendingSlideShowSlide
= this.selectedSlide
;
779 return this.slideShowSlide
.href
;
782 FilmSlider
.prototype.slideShowNext = function() {
783 var nextSlide
= this.slideShowSlide
.parentNode
.nextSibling
;
784 if (nextSlide
&& nextSlide
.nodeType
===3) { nextSlide
= nextSlide
.nextSibling
; }
787 nextSlide
= nextSlide
.getElementsByTagName('a')[0];
788 this.pendingSlideShowSlide
= nextSlide
;
789 return this.pendingSlideShowSlide
.href
;
792 var row
= this.slideShowSlide
.parentNode
.parentNode
;
793 var first
= row
.firstChild
;
794 if (first
.nodeType
===3) { first
= first
.nextSibling
; }
795 this.pendingSlideShowSlide
= first
.getElementsByTagName('a')[0];
796 return this.pendingSlideShowSlide
.href
;
800 FilmSlider
.prototype.slideShowPrevious = function() {
801 var previousSlide
= this.slideShowSlide
.parentNode
.previousSibling
;
802 if (previousSlide
&& previousSlide
.nodeType
===3) { previousSlide
= previousSlide
.previousSibling
; }
805 previousSlide
= previousSlide
.getElementsByTagName('a')[0];
806 this.pendingSlideShowSlide
= previousSlide
;
807 return this.pendingSlideShowSlide
.href
;
810 var row
= this.slideShowSlide
.parentNode
.parentNode
;
811 var last
= row
.lastChild
;
812 if (last
.nodeType
===3) { last
= last
.previousSibling
; }
813 this.pendingSlideShowSlide
= last
.getElementsByTagName('a')[0];
814 return this.pendingSlideShowSlide
.href
;
818 FilmSlider
.prototype.slideShowImageLoaded = function() {
819 this.slideShowSlide
= this.pendingSlideShowSlide
;
822 FilmSlider
.prototype.stopSlideShow = function() {
823 raiseMouseEvent(this.slideShowSlide
, 'click');
824 var index
= parseInt(this.selectedSlide
.getAttribute('portfolio:position'), 10);
825 this.centerSlide(index
);
830 function Point(x
, y
) {
831 this.x
= Math
.round(x
);
832 this.y
= Math
.round(y
);
834 Point
.prototype.diff = function(point
) { return new Point(this.x
- point
.x
, this.y
- point
.y
); };
835 Point
.prototype.add = function(point
) { return new Point(this.x
+ point
.x
, this.y
+ point
.y
); };
836 Point
.prototype.mul = function(k
) { return new Point(this.x
* k
, this.y
*k
); };
837 Point
.prototype.toString = function() { return "(" + String(this.x
) + ", " + String(this.y
) + ")"; };