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 for (i
=0 ; i
<this._barSizes
.length
- 1 ; i
++) {
150 if (this._barSizes
[i
] !== this._barSizes
[i
+1]) {
152 setTimeout(function(evt
){self
._checkSizeStability();}, 250);
156 clearInterval(this._checkSizeIntervalId
);
157 delete this._barSizes
;
158 delete this._checkSizeIntervalId
;
161 FilmSlider
.prototype.fitToScreen = function(evt
) {
163 var thisSlider
= this;
164 addListener(window
, 'resize', function(evt
){thisSlider
._fitToScreen();});
167 FilmSlider
.prototype._fitToScreen = function(evt
) {
168 var wh
= getWindowHeight();
169 if (!browser
.isMobile
) {
170 var rb
= getObjectTop(this.rail
) + getObjectHeight(this.rail
); // rail bottom
173 var rb
= getObjectTop(this.filmBar
) + getObjectHeight(this.filmBar
); // film bottom
176 var sh
= getObjectHeight(this.stretchable
);
177 var newSize
= sh
+ delta
;
178 this.stretchable
.style
.height
= newSize
+ 'px';
180 var ratio
= this.image
.height
/ this.image
.width
;
181 var bestFitSize
= this.getBestFitSize(ratio
);
182 var currentSize
= parseInt(imgRequestedSize
.exec(this.image
.src
)[1], 10);
183 if (currentSize
!== bestFitSize
) {
184 var src
= this.image
.src
.replace(imgRequestedSize
, 'size=' + bestFitSize
);
185 this.pendingImage
.src
= src
;
189 FilmSlider
.prototype.getBestFitSize = function(ratio
) {
190 var fw
= getObjectWidth(this.stretchable
) - 1;
191 var fh
= getObjectHeight(this.stretchable
) - 1;
195 for (i
=DEFAULT_IMAGE_SIZES
.length
-1 ; i
>0 ; i
--) {
196 irw
= DEFAULT_IMAGE_SIZES
[i
];
198 if (irw
<= fw
&& irh
<= fh
) { break; }
202 for (i
=DEFAULT_IMAGE_SIZES
.length
-1 ; i
>0 ; i
--) {
203 irh
= DEFAULT_IMAGE_SIZES
[i
];
205 if (irw
<= fw
&& irh
<= fh
) { break; }
208 return DEFAULT_IMAGE_SIZES
[i
];
211 if (!browser
.isMobile
) {
212 FilmSlider
.prototype.centerSlide = function(slideIndex
) {
213 if (this.sliderRatio
> 1) { return; }
214 var filmBarWidth
= getObjectWidth(this.filmBar
);
215 var x
= slideIndex
* this.slideSize
;
216 x
= x
- (filmBarWidth
- this.slideSize
) / 2.0;
217 x
= x
* this.sliderSpeedRatio
;
218 var p
= new Point( -x
, 0 );
219 this.setSliderPosition(p
);
223 FilmSlider
.prototype.centerSlide = function(slideIndex
) {
224 var filmBarWidth
= getObjectWidth(this.filmBar
);
225 var x
= slideIndex
* this.slideSize
;
226 x
= x
- (filmBarWidth
- this.slideSize
) / 2.0;
227 this.setFilmPosition(-x
);
231 FilmSlider
.prototype.setSliderPosition = function(point
) {
232 if(point
.x
< 0) { point
.x
= 0; }
233 if (point
.x
> this.maxRightPosition
) { point
.x
= this.maxRightPosition
; }
234 this.slider
.style
.left
= point
.x
+ 'px';
235 this.setFilmPosition(point
);
238 if (!browser
.isMobile
) {
239 FilmSlider
.prototype.setFilmPosition = function(point
) {
240 this.film
.style
.left
= point
.x
/ this.sliderSpeedRatio
+ 'px';
244 FilmSlider
.prototype.setFilmPosition = function(x
) {
246 x
= Math
.max(this.filmMaxX
, x
);
247 this.film
.style
.left
= String(x
) + 'px';
251 FilmSlider
.prototype.getSliderPosition = function() {
252 var x
= parseInt(this.slider
.style
.left
, 10);
253 var y
= parseInt(this.slider
.style
.top
, 10);
254 var p
= new Point(x
, y
);
258 FilmSlider
.prototype.getFilmPosition = function() {
259 var x
= parseInt(this.film
.style
.left
, 10);
260 var y
= parseInt(this.film
.style
.top
, 10);
261 var p
= new Point(x
, y
);
265 FilmSlider
.prototype.loadSibling = function(previous
) {
268 slide
= this.selectedSlide
.parentNode
.previousSibling
;
269 if (slide
&& slide
.nodeType
===3) { slide
= slide
.previousSibling
; }
272 slide
= this.selectedSlide
.parentNode
.nextSibling
;
273 if (slide
&& slide
.nodeType
===3) { slide
= slide
.nextSibling
; }
276 if (!slide
) { return; }
278 var target
= slide
.getElementsByTagName('a')[0];
279 raiseMouseEvent(target
, 'click');
280 var index
= parseInt(target
.getAttribute('portfolio:position'), 10);
281 this.centerSlide(index
);
285 FilmSlider
.prototype.addEventListeners = function() {
286 var thisSlider
= this;
287 addListener(window
, 'resize', function(evt
){thisSlider
.resizeSlider(evt
);});
288 addListener(this.filmBar
, 'click', function(evt
){thisSlider
.thumbnailClickHandler(evt
);});
289 addListener(this.toolbar
, 'click', function(evt
){thisSlider
.toolbarClickHandler(evt
);});
290 addListener(window
, 'load', function(evt
){thisSlider
.fitToScreen(evt
);});
291 addListener(window
, 'load', function(evt
){thisSlider
._checkSizeAfterLoad(evt
);});
294 addListener(this.slider
, 'mousedown', this.ddHandlers
.down
);
295 if(browser
.isDOM2Event
){
296 if (browser
.isAppleWebKit
) {
297 this.filmBar
.addEventListener('mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);}, false);
300 addListener(this.filmBar
, 'DOMMouseScroll', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
303 else if (browser
.isIE6up
) {
304 addListener(this.filmBar
, 'mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
306 if (browser
.isMobile
) {
307 this.filmBar
.addEventListener('touchstart', function(evt
){thisSlider
.touchStartHandler(evt
);}, false);
308 this.filmBar
.addEventListener('touchmove', function(evt
){thisSlider
.touchMoveHandler(evt
);}, false);
309 this.filmBar
.addEventListener('touchend', function(evt
){thisSlider
.touchEndHandler(evt
);}, false);
312 addListener(document
, 'keydown', function(evt
){thisSlider
.keyDownHandler(evt
);});
313 addListener(document
, 'keypress', function(evt
){thisSlider
.keyPressHandler(evt
);});
317 FilmSlider
.prototype.mouseDownHandler = function(evt
) {
318 this.initialClickPoint
= new Point(evt
.clientX
, evt
.clientY
);
319 this.initialPosition
= this.getSliderPosition();
320 this.dragInProgress
= true;
321 addListener(document
, 'mousemove', this.ddHandlers
.move);
322 addListener(document
, 'mouseup', this.ddHandlers
.up
);
323 addListener(document
.body
, 'mouseout', this.ddHandlers
.out
);
327 FilmSlider
.prototype.mouseMoveHandler = function(evt
) {
328 if(!this.dragInProgress
) { return; }
331 evt
= getEventObject(evt
);
332 var currentPoint
= new Point(evt
.clientX
, evt
.clientY
);
333 var displacement
= currentPoint
.diff(this.initialClickPoint
);
334 this.setSliderPosition(this.initialPosition
.add(displacement
));
337 FilmSlider
.prototype.mouseUpHandler = function(evt
) {
338 this.dragInProgress
= false;
339 evt
= getEventObject(evt
);
340 this.mouseMoveHandler(evt
);
344 FilmSlider
.prototype.mouseOutHandler = function(evt
) {
345 evt
= getEventObject(evt
);
349 x
> this.winSize
.width
||
351 y
> this.winSize
.height
353 this.mouseUpHandler(evt
);
357 FilmSlider
.prototype.thumbnailClickHandler = function(evt
) {
358 var target
= getTargetedObject(evt
);
359 while (target
.tagName
!== 'A' && target
!== this.filmBar
) { target
= target
.parentNode
; }
360 if (target
.tagName
!== 'A') { return; }
362 if (this.viewMode
=== 'full') {
363 this.mosaique
.unload();
364 this.mosaique
= null;
365 this.viewMode
= 'medium';
368 disablePropagation(evt
);
370 history
.pushState(target
.href
, '', target
.href
);
372 var imgBaseUrl
= target
.href
;
374 if (this.ctxUrlTranslation
[0]) {
375 canonicalImgUrl
= imgBaseUrl
.replace(this.ctxUrlTranslation
[0],
376 this.ctxUrlTranslation
[1]);
378 else { canonicalImgUrl
= imgBaseUrl
; }
380 var ajaxUrl
= imgBaseUrl
+ '/photo_view_ajax';
383 //this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=600';
384 var thumbnail
= target
.getElementsByTagName('IMG')[0];
385 var bestFitSize
= this.getBestFitSize(thumbnail
.height
/thumbnail
.width
);
386 this.pendingImage
.src
= canonicalImgUrl
+ '/getResizedImage?size=' + bestFitSize
;
389 var fullScreenLink
= this.buttons
.full_screen
.parentNode
;
390 fullScreenLink
.href
= canonicalImgUrl
+ '/zoom_view';
392 var toggleSelectionBtn
= this.buttons
.toggle_selection
;
393 var toggleSelectionLink
= toggleSelectionBtn
.parentNode
;
394 this.selectedSlideInSelection
= (target
.className
==='selected');
395 if (this.selectedSlideInSelection
) {
396 toggleSelectionBtn
.src
= portal_url() + '/unselect_flag_btn.gif';
397 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Retirer de la sélection';
398 toggleSelectionLink
.href
= canonicalImgUrl
+ '/remove_to_selection';
401 toggleSelectionBtn
.src
= portal_url() + '/select_flag_btn.gif';
402 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Ajouter à la sélection';
403 toggleSelectionLink
.href
= canonicalImgUrl
+ '/add_to_selection';
406 var showBuyableButtonLink
= this.buttons
.show_buyable
.parentNode
;
407 showBuyableButtonLink
.href
= canonicalImgUrl
+ '/get_slide_buyable_items';
408 this.cartSlide
.innerHTML
= '';
409 this.cartSlide
.style
.visibility
='hidden';
412 var metadataButton
= this.buttons
.edit_metadata
;
413 if (metadataButton
) {
414 var metadataEditLink
= metadataButton
.parentNode
;
415 metadataEditLink
.href
= canonicalImgUrl
+ '/photo_edit_form';
419 var req
= new XMLHttpRequest();
420 req
.onreadystatechange = function() {
421 switch (req
.readyState
) {
427 if (! isTextMime
.exec(req
.getResponseHeader('Content-Type'))) {
428 req
.onreadystatechange
= null;
431 window
.location
.href
= thisFS
._fallBackUrl
;
438 if (req
.status
=== 200) { thisFS
.populateViewer(req
); }
443 req
.open("GET", ajaxUrl
, true);
446 // update old displayed slide className
447 var className
= this.selectedSlide
.className
;
448 var classes
= className
.split(' ');
452 for (i
=0 ; i
<classes
.length
; i
++) {
454 if (name
!== 'displayed') {
455 newClasses
.push(name
);
459 this.selectedSlide
.className
= newClasses
.join(' ');
461 // hightlight new displayed slide
462 this.selectedSlide
= target
;
463 className
= this.selectedSlide
.className
;
464 classes
= className
.split(' ');
465 classes
.push('displayed');
466 this.selectedSlide
.className
= classes
.join(' ');
470 FilmSlider
.prototype.toolbarClickHandler = function(evt
) {
471 var target
= getTargetedObject(evt
);
472 var button
, link
, url
;
473 if(target
.tagName
=== 'IMG' && target
.getAttribute('name')) {
474 switch(target
.getAttribute('name')) {
477 disablePropagation(evt
);
479 link
= button
.parentNode
;
481 this.loadSibling(true);
485 disablePropagation(evt
);
487 link
= button
.parentNode
;
489 this.loadSibling(false);
493 disablePropagation(evt
);
494 target
.parentNode
.blur();
495 if (this.viewMode
=== 'full') {
496 this.mosaique
.unload();
497 this.mosaique
= null;
498 this.viewMode
= 'medium';
501 var main
= document
.getElementById('photo_viewer');
502 url
= target
.parentNode
.href
;
503 url
= url
.substring(0, url
.length
- '/zoom_view'.length
);
504 var margins
= {'top':0, 'right':-1, 'bottom':0, 'left':0};
505 this.mosaique
= new Mosaique(main
, url
, margins
);
506 this.viewMode
= 'full';
509 case 'toggle_selection':
511 disablePropagation(evt
);
513 link
= button
.parentNode
;
516 var req
= new XMLHttpRequest();
518 req
.open("POST", url
, true);
519 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
523 var parts
= url
.split('/');
524 var canonicalImgUrl
= parts
.slice(0, parts
.length
-1).join('/');
526 if (isAddToSelection
.test(url
)) {
527 button
.src
= portal_url() + '/unselect_flag_btn.gif';
528 button
.alt
= link
.title
= 'Retirer de la sélection';
529 link
.href
= canonicalImgUrl
+ '/remove_to_selection';
530 this.selectedSlide
.className
= 'selected displayed';
531 this.image
.parentNode
.className
= 'selected';
532 this.selectedSlideInSelection
= true;
535 button
.src
= portal_url() + '/select_flag_btn.gif';
536 button
.alt
= link
.title
= 'Ajouter à la sélection';
537 link
.href
= canonicalImgUrl
+ '/add_to_selection';
538 this.selectedSlide
.className
= 'displayed';
539 this.image
.parentNode
.className
= '';
540 this.selectedSlideInSelection
= false;
546 disablePropagation(evt
);
548 link
= button
.parentNode
;
550 var slide
= this.cartSlide
;
551 slide
.innerHTML
= '';
552 slide
.style
.visibility
= 'visible';
553 var cw
= new CartWidget(slide
, link
.href
);
554 cw
.onCancel = function() {
555 CartWidget
.prototype.onCancel
.apply(this);
556 slide
.style
.visibility
= 'hidden';
558 cw
.onAfterConfirm = function() {
559 slide
.style
.visibility
= 'hidden';
567 case 'edit_metadata' :
569 disablePropagation(evt);
571 if (this.viewMode === 'full') {
572 this.mosaique.unload();
573 this.mosaique = null;
574 this.viewMode = 'medium';
577 var fi = new FragmentImporter(absolute_url());
578 fi.useMacro('metadata_edit_form_macros', 'iptc', 'image_metadata');
586 if(browser
.isDOM2Event
) {
587 if (browser
.isAppleWebKit
) {
588 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
590 var pos
= this.getSliderPosition();
591 pos
.x
-= evt
.wheelDelta
/ 40;
592 this.setSliderPosition(pos
);
596 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
598 var pos
= this.getSliderPosition();
599 pos
.x
+= evt
.detail
* 3;
600 this.setSliderPosition(pos
);
604 else if (browser
.isIE6up
) {
605 FilmSlider
.prototype.mouseWheelHandler = function() {
606 var evt
= window
.event
;
607 evt
.returnValue
= false;
608 var pos
= this.getSliderPosition();
609 pos
.x
-= evt
.wheelDelta
/ 40;
610 this.setSliderPosition(pos
);
614 FilmSlider
.prototype.touchStartHandler = function(evt
) {
615 this.filmStartX
= parseInt(this.film
.style
.left
, 10);
616 this.touchStartX
= evt
.changedTouches
[0].screenX
;
617 this.touchStartTime
= (new Date()).getTime();
620 FilmSlider
.prototype.touchMoveHandler = function(evt
) {
622 var delta
= this.touchStartX
- evt
.changedTouches
[0].screenX
;
623 var posX
= this.filmStartX
- delta
;
624 this.setFilmPosition(posX
);
625 this.lastMoveTime
= (new Date()).getTime();
628 FilmSlider
.prototype.touchEndHandler = function(evt
) {
629 var x
= evt
.changedTouches
[0].screenX
;
630 var delta
= x
- this.touchStartX
;
633 var now
= (new Date()).getTime();
634 if (now
- this.lastMoveTime
< 100) {
635 // au delà de 100 ms de maintient, on annule l'inertie
636 var speed
= delta
/ (now
- this.touchStartTime
)
637 var x0
= parseInt(this.film
.style
.left
, 10);
638 var t0
= (new Date()).getTime();
639 var d
= 500; // milisecondes
646 var t
= (new Date()).getTime() - t0
;
648 setTimeout(animate
, dt
);
649 delta
= delta
+ (1-t
/d) * speed * dt; // d
écelleration lin
éaire
650 self
.setFilmPosition(x0
+ delta
);
656 this.touchStartX
= undefined;
660 FilmSlider
.prototype.keyDownHandler = function(evt
) {
661 evt
= getEventObject(evt
);
662 switch (evt
.keyCode
) {
664 this.loadSibling(true);
667 this.loadSibling(false);
675 FilmSlider
.prototype.keyPressHandler = function(evt
) {
676 var target
= getTargetedObject(evt
);
677 if (target
.tagName
=== 'INPUT' || target
.tagName
=== 'TEXTAREA') { return; }
678 evt
= getEventObject(evt
);
679 var charPress
= String
.fromCharCode((evt
.keyCode
) ? evt
.keyCode
: evt
.which
);
683 raiseMouseEvent(this.buttons
.full_screen
, 'click');
688 FilmSlider
.prototype.populateViewer = function(req
) {
689 var elements
= req
.responseXML
.documentElement
.childNodes
;
691 for(i
=0 ; i
< elements
.length
; i
++ ) {
692 element
= elements
[i
];
693 switch (element
.nodeName
) {
695 var dest
= document
.getElementById(element
.getAttribute('id'));
696 if (dest
) { dest
.innerHTML
= element
.firstChild
.nodeValue
; }
698 case 'imageattributes' :
699 var link
= this.buttons
.back_to_portfolio
.parentNode
;
700 link
.href
= element
.getAttribute('back_to_context_url');
701 link
= this.buttons
.show_buyable
.parentNode
;
702 var buyable
= element
.getAttribute('buyable');
703 if(buyable
=== 'True') { link
.className
= null; }
704 else if(buyable
=== 'False') { link
.className
= 'hidden'; }
705 this.image
.alt
= element
.getAttribute('alt');
706 this.updateBreadcrumbs(element
.getAttribute('last_bc_url'),
707 element
.getAttribute('img_id'));
713 FilmSlider
.prototype.refreshImage = function() {
714 this.image
.style
.visibility
= 'hidden';
715 this.image
.src
= this.pendingImage
.src
;
716 this.image
.width
= this.pendingImage
.width
;
717 this.image
.height
= this.pendingImage
.height
;
718 this.image
.style
.visibility
= 'visible';
719 if (this.selectedSlideInSelection
) { this.image
.parentNode
.className
= 'selected'; }
720 else { this.image
.parentNode
.className
= ''; }
723 FilmSlider
.prototype.updateBreadcrumbs = function(url
, title
) {
724 if (this.hasBreadcrumbs
) {
725 this.lastBCElement
.href
= element
.getAttribute('lastBcUrl');
726 this.lastBCElement
.innerHTML
= element
.getAttribute('img_id');
730 FilmSlider
.prototype.startSlideShow = function() {
731 this.slideShowSlide
= this.pendingSlideShowSlide
= this.selectedSlide
;
732 return this.slideShowSlide
.href
;
735 FilmSlider
.prototype.slideShowNext = function() {
736 var nextSlide
= this.slideShowSlide
.parentNode
.nextSibling
;
737 if (nextSlide
&& nextSlide
.nodeType
===3) { nextSlide
= nextSlide
.nextSibling
; }
740 nextSlide
= nextSlide
.getElementsByTagName('a')[0];
741 this.pendingSlideShowSlide
= nextSlide
;
742 return this.pendingSlideShowSlide
.href
;
745 var row
= this.slideShowSlide
.parentNode
.parentNode
;
746 var first
= row
.firstChild
;
747 if (first
.nodeType
===3) { first
= first
.nextSibling
; }
748 this.pendingSlideShowSlide
= first
.getElementsByTagName('a')[0];
749 return this.pendingSlideShowSlide
.href
;
753 FilmSlider
.prototype.slideShowPrevious = function() {
754 var previousSlide
= this.slideShowSlide
.parentNode
.previousSibling
;
755 if (previousSlide
&& previousSlide
.nodeType
===3) { previousSlide
= previousSlide
.previousSibling
; }
758 previousSlide
= previousSlide
.getElementsByTagName('a')[0];
759 this.pendingSlideShowSlide
= previousSlide
;
760 return this.pendingSlideShowSlide
.href
;
763 var row
= this.slideShowSlide
.parentNode
.parentNode
;
764 var last
= row
.lastChild
;
765 if (last
.nodeType
===3) { last
= last
.previousSibling
; }
766 this.pendingSlideShowSlide
= last
.getElementsByTagName('a')[0];
767 return this.pendingSlideShowSlide
.href
;
771 FilmSlider
.prototype.slideShowImageLoaded = function() {
772 this.slideShowSlide
= this.pendingSlideShowSlide
;
775 FilmSlider
.prototype.stopSlideShow = function() {
776 raiseMouseEvent(this.slideShowSlide
, 'click');
777 var index
= parseInt(this.selectedSlide
.getAttribute('portfolio:position'), 10);
778 this.centerSlide(index
);
783 function Point(x
, y
) {
784 this.x
= Math
.round(x
);
785 this.y
= Math
.round(y
);
787 Point
.prototype.diff = function(point
) { return new Point(this.x
- point
.x
, this.y
- point
.y
); };
788 Point
.prototype.add = function(point
) { return new Point(this.x
+ point
.x
, this.y
+ point
.y
); };
789 Point
.prototype.mul = function(k
) { return new Point(this.x
* k
, this.y
*k
); };
790 Point
.prototype.toString = function() { return "(" + String(this.x
) + ", " + String(this.y
) + ")"; };