884dac05f640983e7f170ab7ed31a9d8ef3ace5e
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
);});
292 addListener(window
, 'load', function(evt
){thisSlider
.startThumbnailsLoadQueue(evt
);});
295 addListener(this.slider
, 'mousedown', this.ddHandlers
.down
);
296 if(browser
.isDOM2Event
){
297 if (browser
.isAppleWebKit
) {
298 this.filmBar
.addEventListener('mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);}, false);
301 addListener(this.filmBar
, 'DOMMouseScroll', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
304 else if (browser
.isIE6up
) {
305 addListener(this.filmBar
, 'mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
307 if (browser
.isMobile
) {
308 this.filmBar
.addEventListener('touchstart', function(evt
){thisSlider
.touchStartHandler(evt
);}, false);
309 this.filmBar
.addEventListener('touchmove', function(evt
){thisSlider
.touchMoveHandler(evt
);}, false);
310 this.filmBar
.addEventListener('touchend', function(evt
){thisSlider
.touchEndHandler(evt
);}, false);
313 addListener(document
, 'keydown', function(evt
){thisSlider
.keyDownHandler(evt
);});
314 addListener(document
, 'keypress', function(evt
){thisSlider
.keyPressHandler(evt
);});
318 FilmSlider
.prototype.mouseDownHandler = function(evt
) {
319 this.initialClickPoint
= new Point(evt
.clientX
, evt
.clientY
);
320 this.initialPosition
= this.getSliderPosition();
321 this.dragInProgress
= true;
322 addListener(document
, 'mousemove', this.ddHandlers
.move);
323 addListener(document
, 'mouseup', this.ddHandlers
.up
);
324 addListener(document
.body
, 'mouseout', this.ddHandlers
.out
);
328 FilmSlider
.prototype.mouseMoveHandler = function(evt
) {
329 if(!this.dragInProgress
) { return; }
332 evt
= getEventObject(evt
);
333 var currentPoint
= new Point(evt
.clientX
, evt
.clientY
);
334 var displacement
= currentPoint
.diff(this.initialClickPoint
);
335 this.setSliderPosition(this.initialPosition
.add(displacement
));
338 FilmSlider
.prototype.mouseUpHandler = function(evt
) {
339 this.dragInProgress
= false;
340 evt
= getEventObject(evt
);
341 this.mouseMoveHandler(evt
);
345 FilmSlider
.prototype.mouseOutHandler = function(evt
) {
346 evt
= getEventObject(evt
);
350 x
> this.winSize
.width
||
352 y
> this.winSize
.height
354 this.mouseUpHandler(evt
);
358 FilmSlider
.prototype.translateImgUrl = function(url
) {
360 if (this.ctxUrlTranslation
[0]) {
361 canonicalImgUrl
= url
.replace(this.ctxUrlTranslation
[0],
362 this.ctxUrlTranslation
[1]);
365 canonicalImgUrl
= url
;
367 return canonicalImgUrl
;
370 FilmSlider
.prototype.thumbnailClickHandler = function(evt
) {
371 var target
= getTargetedObject(evt
);
372 while (target
.tagName
!== 'A' && target
!== this.filmBar
) { target
= target
.parentNode
; }
373 if (target
.tagName
!== 'A') { return; }
375 if (this.viewMode
=== 'full') {
376 this.mosaique
.unload();
377 this.mosaique
= null;
378 this.viewMode
= 'medium';
381 disablePropagation(evt
);
383 history
.pushState(target
.href
, '', target
.href
);
385 var imgBaseUrl
= target
.href
;
386 var canonicalImgUrl
= this.translateImgUrl(imgBaseUrl
);
388 var ajaxUrl
= imgBaseUrl
+ '/photo_view_ajax';
391 //this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=600';
392 var thumbnail
= target
.getElementsByTagName('IMG')[0];
393 var bestFitSize
= this.getBestFitSize(thumbnail
.height
/thumbnail
.width
);
394 this.pendingImage
.src
= canonicalImgUrl
+ '/getResizedImage?size=' + bestFitSize
;
397 var fullScreenLink
= this.buttons
.full_screen
.parentNode
;
398 fullScreenLink
.href
= canonicalImgUrl
+ '/zoom_view';
400 var toggleSelectionBtn
= this.buttons
.toggle_selection
;
401 var toggleSelectionLink
= toggleSelectionBtn
.parentNode
;
402 this.selectedSlideInSelection
= (target
.className
==='selected');
403 if (this.selectedSlideInSelection
) {
404 toggleSelectionBtn
.src
= portal_url() + '/unselect_flag_btn.gif';
405 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Retirer de la sélection';
406 toggleSelectionLink
.href
= canonicalImgUrl
+ '/remove_to_selection';
409 toggleSelectionBtn
.src
= portal_url() + '/select_flag_btn.gif';
410 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Ajouter à la sélection';
411 toggleSelectionLink
.href
= canonicalImgUrl
+ '/add_to_selection';
414 var showBuyableButtonLink
= this.buttons
.show_buyable
.parentNode
;
415 showBuyableButtonLink
.href
= canonicalImgUrl
+ '/get_slide_buyable_items';
416 this.cartSlide
.innerHTML
= '';
417 this.cartSlide
.style
.visibility
='hidden';
420 var metadataButton
= this.buttons
.edit_metadata
;
421 if (metadataButton
) {
422 var metadataEditLink
= metadataButton
.parentNode
;
423 metadataEditLink
.href
= canonicalImgUrl
+ '/photo_edit_form';
427 var req
= new XMLHttpRequest();
428 req
.onreadystatechange = function() {
429 switch (req
.readyState
) {
435 if (! isTextMime
.exec(req
.getResponseHeader('Content-Type'))) {
436 req
.onreadystatechange
= null;
439 window
.location
.href
= thisFS
._fallBackUrl
;
446 if (req
.status
=== 200) { thisFS
.populateViewer(req
); }
451 req
.open("GET", ajaxUrl
, true);
454 // update old displayed slide className
455 var className
= this.selectedSlide
.className
;
456 var classes
= className
.split(' ');
460 for (i
=0 ; i
<classes
.length
; i
++) {
462 if (name
!== 'displayed') {
463 newClasses
.push(name
);
467 this.selectedSlide
.className
= newClasses
.join(' ');
469 // hightlight new displayed slide
470 this.selectedSlide
= target
;
471 className
= this.selectedSlide
.className
;
472 classes
= className
.split(' ');
473 classes
.push('displayed');
474 this.selectedSlide
.className
= classes
.join(' ');
478 FilmSlider
.prototype.toolbarClickHandler = function(evt
) {
479 var target
= getTargetedObject(evt
);
480 var button
, link
, url
;
481 if(target
.tagName
=== 'IMG' && target
.getAttribute('name')) {
482 switch(target
.getAttribute('name')) {
485 disablePropagation(evt
);
487 link
= button
.parentNode
;
489 this.loadSibling(true);
493 disablePropagation(evt
);
495 link
= button
.parentNode
;
497 this.loadSibling(false);
501 disablePropagation(evt
);
502 target
.parentNode
.blur();
503 if (this.viewMode
=== 'full') {
504 this.mosaique
.unload();
505 this.mosaique
= null;
506 this.viewMode
= 'medium';
509 var main
= document
.getElementById('photo_viewer');
510 url
= target
.parentNode
.href
;
511 url
= url
.substring(0, url
.length
- '/zoom_view'.length
);
512 var margins
= {'top':0, 'right':-1, 'bottom':0, 'left':0};
513 this.mosaique
= new Mosaique(main
, url
, margins
);
514 this.viewMode
= 'full';
517 case 'toggle_selection':
519 disablePropagation(evt
);
521 link
= button
.parentNode
;
524 var req
= new XMLHttpRequest();
526 req
.open("POST", url
, true);
527 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
531 var parts
= url
.split('/');
532 var canonicalImgUrl
= parts
.slice(0, parts
.length
-1).join('/');
534 if (isAddToSelection
.test(url
)) {
535 button
.src
= portal_url() + '/unselect_flag_btn.gif';
536 button
.alt
= link
.title
= 'Retirer de la sélection';
537 link
.href
= canonicalImgUrl
+ '/remove_to_selection';
538 this.selectedSlide
.className
= 'selected displayed';
539 this.image
.parentNode
.className
= 'selected';
540 this.selectedSlideInSelection
= true;
543 button
.src
= portal_url() + '/select_flag_btn.gif';
544 button
.alt
= link
.title
= 'Ajouter à la sélection';
545 link
.href
= canonicalImgUrl
+ '/add_to_selection';
546 this.selectedSlide
.className
= 'displayed';
547 this.image
.parentNode
.className
= '';
548 this.selectedSlideInSelection
= false;
554 disablePropagation(evt
);
556 link
= button
.parentNode
;
558 var slide
= this.cartSlide
;
559 slide
.innerHTML
= '';
560 slide
.style
.visibility
= 'visible';
561 var cw
= new CartWidget(slide
, link
.href
);
562 cw
.onCancel = function() {
563 CartWidget
.prototype.onCancel
.apply(this);
564 slide
.style
.visibility
= 'hidden';
566 cw
.onAfterConfirm = function() {
567 slide
.style
.visibility
= 'hidden';
575 case 'edit_metadata' :
577 disablePropagation(evt);
579 if (this.viewMode === 'full') {
580 this.mosaique.unload();
581 this.mosaique = null;
582 this.viewMode = 'medium';
585 var fi = new FragmentImporter(absolute_url());
586 fi.useMacro('metadata_edit_form_macros', 'iptc', 'image_metadata');
594 if(browser
.isDOM2Event
) {
595 if (browser
.isAppleWebKit
) {
596 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
598 var pos
= this.getSliderPosition();
599 pos
.x
-= evt
.wheelDelta
/ 40;
600 this.setSliderPosition(pos
);
604 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
606 var pos
= this.getSliderPosition();
607 pos
.x
+= evt
.detail
* 3;
608 this.setSliderPosition(pos
);
612 else if (browser
.isIE6up
) {
613 FilmSlider
.prototype.mouseWheelHandler = function() {
614 var evt
= window
.event
;
615 evt
.returnValue
= false;
616 var pos
= this.getSliderPosition();
617 pos
.x
-= evt
.wheelDelta
/ 40;
618 this.setSliderPosition(pos
);
622 FilmSlider
.prototype.touchStartHandler = function(evt
) {
623 this.filmStartX
= parseInt(this.film
.style
.left
, 10);
624 this.touchStartX
= evt
.changedTouches
[0].screenX
;
625 this.touchStartTime
= (new Date()).getTime();
628 FilmSlider
.prototype.touchMoveHandler = function(evt
) {
630 var delta
= this.touchStartX
- evt
.changedTouches
[0].screenX
;
631 var posX
= this.filmStartX
- delta
;
632 this.setFilmPosition(posX
);
633 this.lastMoveTime
= (new Date()).getTime();
636 FilmSlider
.prototype.touchEndHandler = function(evt
) {
637 var x
= evt
.changedTouches
[0].screenX
;
638 var delta
= x
- this.touchStartX
;
641 var now
= (new Date()).getTime();
642 if (now
- this.lastMoveTime
< 100) {
643 // au delà de 100 ms de maintient, on annule l'inertie
644 var speed
= delta
/ (now
- this.touchStartTime
)
645 var x0
= parseInt(this.film
.style
.left
, 10);
646 var t0
= (new Date()).getTime();
647 var d
= 500; // milisecondes
654 var t
= (new Date()).getTime() - t0
;
656 setTimeout(animate
, dt
);
657 delta
= delta
+ (1-t
/d) * speed * dt; // d
écelleration lin
éaire
658 self
.setFilmPosition(x0
+ delta
);
664 this.touchStartX
= undefined;
668 FilmSlider
.prototype.keyDownHandler = function(evt
) {
669 evt
= getEventObject(evt
);
670 switch (evt
.keyCode
) {
672 this.loadSibling(true);
675 this.loadSibling(false);
683 FilmSlider
.prototype.keyPressHandler = function(evt
) {
684 var target
= getTargetedObject(evt
);
685 if (target
.tagName
=== 'INPUT' || target
.tagName
=== 'TEXTAREA') { return; }
686 evt
= getEventObject(evt
);
687 var charPress
= String
.fromCharCode((evt
.keyCode
) ? evt
.keyCode
: evt
.which
);
691 raiseMouseEvent(this.buttons
.full_screen
, 'click');
696 FilmSlider
.prototype.populateViewer = function(req
) {
697 var elements
= req
.responseXML
.documentElement
.childNodes
;
699 for(i
=0 ; i
< elements
.length
; i
++ ) {
700 element
= elements
[i
];
701 switch (element
.nodeName
) {
703 var dest
= document
.getElementById(element
.getAttribute('id'));
704 if (dest
) { dest
.innerHTML
= element
.firstChild
.nodeValue
; }
706 case 'imageattributes' :
707 var link
= this.buttons
.back_to_portfolio
.parentNode
;
708 link
.href
= element
.getAttribute('back_to_context_url');
709 link
= this.buttons
.show_buyable
.parentNode
;
710 var buyable
= element
.getAttribute('buyable');
711 if(buyable
=== 'True') { link
.className
= null; }
712 else if(buyable
=== 'False') { link
.className
= 'hidden'; }
713 this.image
.alt
= element
.getAttribute('alt');
714 this.updateBreadcrumbs(element
.getAttribute('last_bc_url'),
715 element
.getAttribute('img_id'));
721 FilmSlider
.prototype.refreshImage = function() {
722 this.image
.style
.visibility
= 'hidden';
723 this.image
.src
= this.pendingImage
.src
;
724 this.image
.width
= this.pendingImage
.width
;
725 this.image
.height
= this.pendingImage
.height
;
726 this.image
.style
.visibility
= 'visible';
727 if (this.selectedSlideInSelection
) { this.image
.parentNode
.className
= 'selected'; }
728 else { this.image
.parentNode
.className
= ''; }
731 FilmSlider
.prototype.updateBreadcrumbs = function(url
, title
) {
732 if (this.hasBreadcrumbs
) {
733 this.lastBCElement
.href
= url
;
734 this.lastBCElement
.innerHTML
= title
;
738 FilmSlider
.prototype.startThumbnailsLoadQueue = function(evt
) {
739 var thumbnails
= this.film
.getElementsByTagName('img');
740 if (thumbnails
.length
=== 1) { return; }
741 this.thumbnailsLoadingOrder
= [];
742 var leftSize
= this.center
;
743 var rightSize
= thumbnails
.length
- this.center
- 1;
745 for (i
=1 ; i
<=Math
.min(leftSize
, rightSize
) ; i
++) {
746 this.thumbnailsLoadingOrder
.push(thumbnails
[this.center
+ i
]);
747 this.thumbnailsLoadingOrder
.push(thumbnails
[this.center
- i
]);
749 if (leftSize
> rightSize
) {
750 for (i
= this.center
- rightSize
- 1 ; i
>= 0 ; i
--) {
752 this.thumbnailsLoadingOrder
.push(thumbnails
[i
]);
755 else if (leftSize
< rightSize
) {
756 for (i
= this.center
+ leftSize
; i
< thumbnails
.length
; i
++) {
757 this.thumbnailsLoadingOrder
.push(thumbnails
[i
]);
760 var next
= this.thumbnailsLoadingOrder
.shift();
762 addListener(next
, 'load', function(evt
){self
._loadNextThumb(evt
);});
763 next
.src
= this.translateImgUrl(next
.parentNode
.href
) + '/getThumbnail';
766 FilmSlider
.prototype._loadNextThumb = function(evt
) {
767 var next
= this.thumbnailsLoadingOrder
.shift();
770 addListener(next
, 'load', function(evt
){self
._loadNextThumb(evt
);});
771 next
.src
= this.translateImgUrl(next
.parentNode
.href
) + '/getThumbnail';
775 FilmSlider
.prototype.startSlideShow = function() {
776 this.slideShowSlide
= this.pendingSlideShowSlide
= this.selectedSlide
;
777 return this.slideShowSlide
.href
;
780 FilmSlider
.prototype.slideShowNext = function() {
781 var nextSlide
= this.slideShowSlide
.parentNode
.nextSibling
;
782 if (nextSlide
&& nextSlide
.nodeType
===3) { nextSlide
= nextSlide
.nextSibling
; }
785 nextSlide
= nextSlide
.getElementsByTagName('a')[0];
786 this.pendingSlideShowSlide
= nextSlide
;
787 return this.pendingSlideShowSlide
.href
;
790 var row
= this.slideShowSlide
.parentNode
.parentNode
;
791 var first
= row
.firstChild
;
792 if (first
.nodeType
===3) { first
= first
.nextSibling
; }
793 this.pendingSlideShowSlide
= first
.getElementsByTagName('a')[0];
794 return this.pendingSlideShowSlide
.href
;
798 FilmSlider
.prototype.slideShowPrevious = function() {
799 var previousSlide
= this.slideShowSlide
.parentNode
.previousSibling
;
800 if (previousSlide
&& previousSlide
.nodeType
===3) { previousSlide
= previousSlide
.previousSibling
; }
803 previousSlide
= previousSlide
.getElementsByTagName('a')[0];
804 this.pendingSlideShowSlide
= previousSlide
;
805 return this.pendingSlideShowSlide
.href
;
808 var row
= this.slideShowSlide
.parentNode
.parentNode
;
809 var last
= row
.lastChild
;
810 if (last
.nodeType
===3) { last
= last
.previousSibling
; }
811 this.pendingSlideShowSlide
= last
.getElementsByTagName('a')[0];
812 return this.pendingSlideShowSlide
.href
;
816 FilmSlider
.prototype.slideShowImageLoaded = function() {
817 this.slideShowSlide
= this.pendingSlideShowSlide
;
820 FilmSlider
.prototype.stopSlideShow = function() {
821 raiseMouseEvent(this.slideShowSlide
, 'click');
822 var index
= parseInt(this.selectedSlide
.getAttribute('portfolio:position'), 10);
823 this.centerSlide(index
);
828 function Point(x
, y
) {
829 this.x
= Math
.round(x
);
830 this.y
= Math
.round(y
);
832 Point
.prototype.diff = function(point
) { return new Point(this.x
- point
.x
, this.y
- point
.y
); };
833 Point
.prototype.add = function(point
) { return new Point(this.x
+ point
.x
, this.y
+ point
.y
); };
834 Point
.prototype.mul = function(k
) { return new Point(this.x
* k
, this.y
*k
); };
835 Point
.prototype.toString = function() { return "(" + String(this.x
) + ", " + String(this.y
) + ")"; };