3140763a4a8b8552f66fc5f7eaa44276b57249d4
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/
12 var keyLeft
= 37, keyRight
= 39;
13 var isTextMime
= /^text\/.+/i;
14 var isAddToSelection
= /.*\/add_to_selection$/;
15 var imgRequestedSize
= /size=(\d+)/;
16 var DEFAULT_IMAGE_SIZES
= [500, 600, 800];
18 FilmSlider = function(filmBar
, slider
, ctxInfos
, image
, toolbar
, breadcrumbs
) {
19 var thisSlider
= this;
21 this.filmBar
= filmBar
;
22 this.filmBarWidth
= getObjectWidth(this.filmBar
);
23 var film
= filmBar
.firstChild
;
24 if (film
.nodeType
=== 3) { film
= film
.nextSibling
; }
27 this.rail
= slider
.parentNode
;
28 this.sliderSpeedRatio
= undefined;
29 this.sliderRatio
= undefined;
30 this.selectedSlide
= undefined;
31 this.selectedSlideInSelection
= undefined;
32 this.cartSlide
= document
.getElementById('cart_slide');
34 this.stretchable
= image
.parentNode
;
35 this.viewMode
= 'medium';
38 this.toolbar
= toolbar
;
40 var bcElements
= breadcrumbs
.getElementsByTagName('a');
41 this.lastBCElement
= bcElements
[bcElements
.length
-1];
42 var imgSrcParts
= image
.src
.split('/');
43 this.lastBCElement
.innerHTML
= imgSrcParts
[imgSrcParts
.length
-2];
44 this.hasBreadcrumbs
= true;
47 this.hasBreadcrumbs
= false;
50 var buttons
= toolbar
.getElementsByTagName('img');
52 for (i
=0 ; i
<buttons
.length
; i
++) {
54 name
= b
.getAttribute('name');
55 if (name
) { this.buttons
[name
] = b
; }
58 this.pendingImage
= new Image();
59 this.pendingImage
.onload = function() {
60 thisSlider
.refreshImage();
62 this.initialized
= false;
64 this.film
.style
.left
='0';
65 this.film
.style
.top
='0';
67 this.filmLength
= ctxInfos
.filmLength
;
68 this.center
= ctxInfos
.center
;
69 this.slideSize
= ctxInfos
.slideSize
;
70 this.ctxUrlTranslation
= ctxInfos
.ctxUrlTranslation
;
72 this.ddHandlers
= {'down' : function(evt
){thisSlider
.mouseDownHandler(evt
);},
73 'move' : function(evt
){thisSlider
.mouseMoveHandler(evt
);},
74 'up' : function(evt
){thisSlider
.mouseUpHandler(evt
);},
75 'out' : function(evt
){thisSlider
.mouseOutHandler(evt
);}
78 if (browser
.isMobile
) {
79 this.rail
.className
= 'hidden';
84 this.addEventListeners();
87 if (!browser
.isMobile
) {
88 FilmSlider
.prototype.resizeSlider = function(evt
) {
89 var filmBarWidth
= this.filmBarWidth
;
90 if (!filmBarWidth
) { return; }
91 var filmWidth
= this.slideSize
* this.filmLength
;
92 var sliderRatio
= this.sliderRatio
= filmBarWidth
/ filmWidth
;
93 var sliderWidth
= filmBarWidth
* sliderRatio
;
94 this.rail
.style
.width
= filmBarWidth
+ 'px';
95 this.rail
.style
.display
= 'block';
96 this.rail
.style
.visibility
= 'visible';
97 if (sliderRatio
< 1) {
98 this.slider
.style
.width
= Math
.round(sliderWidth
) + 'px';
99 this.slider
.style
.visibility
= 'visible';
102 this.slider
.style
.visibility
= 'hidden';
105 this.winSize
= {'width' : getWindowWidth(),
106 'height' : getWindowHeight()};
107 this.maxRightPosition
= filmBarWidth
- sliderWidth
;
108 this.sliderSpeedRatio
= - (filmBarWidth
- sliderWidth
) / (filmWidth
- filmBarWidth
);
109 if (!this.initialized
) {
110 this.centerSlide(this.center
);
111 this.selectedSlide
= this.filmBar
.getElementsByTagName('img')[this.center
].parentNode
;
112 this.initialized
= true;
118 // pas de barre de scroll horizontal pour les tablettes
119 FilmSlider
.prototype.resizeSlider = function(evt
) {
120 this.filmMaxX
= - (getObjectWidth(this.film
) - this.filmBarWidth
);
121 if (!this.initialized
) {
122 this.centerSlide(this.center
);
123 this.selectedSlide
= this.filmBar
.getElementsByTagName('img')[this.center
].parentNode
;
124 this.initialized
= true;
129 FilmSlider
.prototype._checkSizeAfterLoad = function(evt
) {
131 this.filmBarWidth
= this._barSizes
[this._barSizes
.length
] = getObjectWidth(this.filmBar
);
134 this._checkSizeIntervalId
= setInterval(function(evt
){self
._checkSize(evt
);}, 25);
135 setTimeout(function(evt
){self
._checkSizeStability();}, 250);
138 FilmSlider
.prototype._checkSize = function(evt
) {
139 this._barSizes
[this._barSizes
.length
] = getObjectWidth(this.filmBar
);
140 if (this._barSizes
.length
>= 2 &&
141 this._barSizes
[this._barSizes
.length
-2] !== this._barSizes
[this._barSizes
.length
-1]) {
142 this.filmBarWidth
= this._barSizes
[this._barSizes
.length
-1];
143 this.initialized
= false;
148 FilmSlider
.prototype._checkSizeStability = function(evt
) {
151 for (i
=0 ; i
<this._barSizes
.length
- 1 ; i
++) {
152 if (this._barSizes
[i
] !== this._barSizes
[i
+1]) {
154 setTimeout(function(evt
){self
._checkSizeStability();}, 250);
158 clearInterval(this._checkSizeIntervalId
);
159 delete this._barSizes
;
160 delete this._checkSizeIntervalId
;
163 FilmSlider
.prototype.fitToScreen = function(evt
) {
165 var thisSlider
= this;
166 addListener(window
, 'resize', function(evt
){thisSlider
._fitToScreen();});
169 FilmSlider
.prototype._fitToScreen = function(evt
) {
170 var wh
= getWindowHeight();
171 if (!browser
.isMobile
) {
172 var rb
= getObjectTop(this.rail
) + getObjectHeight(this.rail
); // rail bottom
175 var 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.thumbnailClickHandler = function(evt
) {
361 var target
= getTargetedObject(evt
);
362 while (target
.tagName
!== 'A' && target
!== this.filmBar
) { target
= target
.parentNode
; }
363 if (target
.tagName
!== 'A') { return; }
365 if (this.viewMode
=== 'full') {
366 this.mosaique
.unload();
367 this.mosaique
= null;
368 this.viewMode
= 'medium';
371 disablePropagation(evt
);
373 history
.pushState(target
.href
, '', target
.href
);
375 var imgBaseUrl
= target
.href
;
377 if (this.ctxUrlTranslation
[0]) {
378 canonicalImgUrl
= imgBaseUrl
.replace(this.ctxUrlTranslation
[0],
379 this.ctxUrlTranslation
[1]);
381 else { canonicalImgUrl
= imgBaseUrl
; }
383 var ajaxUrl
= imgBaseUrl
+ '/photo_view_ajax';
386 //this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=600';
387 var thumbnail
= target
.getElementsByTagName('IMG')[0];
388 var bestFitSize
= this.getBestFitSize(thumbnail
.height
/thumbnail
.width
);
389 this.pendingImage
.src
= canonicalImgUrl
+ '/getResizedImage?size=' + bestFitSize
;
392 var fullScreenLink
= this.buttons
.full_screen
.parentNode
;
393 fullScreenLink
.href
= canonicalImgUrl
+ '/zoom_view';
395 var toggleSelectionBtn
= this.buttons
.toggle_selection
;
396 var toggleSelectionLink
= toggleSelectionBtn
.parentNode
;
397 this.selectedSlideInSelection
= (target
.className
==='selected');
398 if (this.selectedSlideInSelection
) {
399 toggleSelectionBtn
.src
= portal_url() + '/unselect_flag_btn.gif';
400 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Retirer de la sélection';
401 toggleSelectionLink
.href
= canonicalImgUrl
+ '/remove_to_selection';
404 toggleSelectionBtn
.src
= portal_url() + '/select_flag_btn.gif';
405 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Ajouter à la sélection';
406 toggleSelectionLink
.href
= canonicalImgUrl
+ '/add_to_selection';
409 var showBuyableButtonLink
= this.buttons
.show_buyable
.parentNode
;
410 showBuyableButtonLink
.href
= canonicalImgUrl
+ '/get_slide_buyable_items';
411 this.cartSlide
.innerHTML
= '';
412 this.cartSlide
.style
.visibility
='hidden';
415 var metadataButton
= this.buttons
.edit_metadata
;
416 if (metadataButton
) {
417 var metadataEditLink
= metadataButton
.parentNode
;
418 metadataEditLink
.href
= canonicalImgUrl
+ '/photo_edit_form';
422 var req
= new XMLHttpRequest();
423 req
.onreadystatechange = function() {
424 switch (req
.readyState
) {
430 if (! isTextMime
.exec(req
.getResponseHeader('Content-Type'))) {
431 req
.onreadystatechange
= null;
434 window
.location
.href
= thisFS
._fallBackUrl
;
441 if (req
.status
=== 200) { thisFS
.populateViewer(req
); }
446 req
.open("GET", ajaxUrl
, true);
449 // update old displayed slide className
450 var className
= this.selectedSlide
.className
;
451 var classes
= className
.split(' ');
455 for (i
=0 ; i
<classes
.length
; i
++) {
457 if (name
!== 'displayed') {
458 newClasses
.push(name
);
462 this.selectedSlide
.className
= newClasses
.join(' ');
464 // hightlight new displayed slide
465 this.selectedSlide
= target
;
466 className
= this.selectedSlide
.className
;
467 classes
= className
.split(' ');
468 classes
.push('displayed');
469 this.selectedSlide
.className
= classes
.join(' ');
473 FilmSlider
.prototype.toolbarClickHandler = function(evt
) {
474 var target
= getTargetedObject(evt
);
475 var button
, link
, url
;
476 if(target
.tagName
=== 'IMG' && target
.getAttribute('name')) {
477 switch(target
.getAttribute('name')) {
480 disablePropagation(evt
);
482 link
= button
.parentNode
;
484 this.loadSibling(true);
488 disablePropagation(evt
);
490 link
= button
.parentNode
;
492 this.loadSibling(false);
496 disablePropagation(evt
);
497 target
.parentNode
.blur();
498 if (this.viewMode
=== 'full') {
499 this.mosaique
.unload();
500 this.mosaique
= null;
501 this.viewMode
= 'medium';
504 var main
= document
.getElementById('photo_viewer');
505 url
= target
.parentNode
.href
;
506 url
= url
.substring(0, url
.length
- '/zoom_view'.length
);
507 var margins
= {'top':0, 'right':-1, 'bottom':0, 'left':0};
508 this.mosaique
= new Mosaique(main
, url
, margins
);
509 this.viewMode
= 'full';
512 case 'toggle_selection':
514 disablePropagation(evt
);
516 link
= button
.parentNode
;
519 var req
= new XMLHttpRequest();
521 req
.open("POST", url
, true);
522 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
526 var parts
= url
.split('/');
527 var canonicalImgUrl
= parts
.slice(0, parts
.length
-1).join('/');
529 if (isAddToSelection
.test(url
)) {
530 button
.src
= portal_url() + '/unselect_flag_btn.gif';
531 button
.alt
= link
.title
= 'Retirer de la sélection';
532 link
.href
= canonicalImgUrl
+ '/remove_to_selection';
533 this.selectedSlide
.className
= 'selected displayed';
534 this.image
.parentNode
.className
= 'selected';
535 this.selectedSlideInSelection
= true;
538 button
.src
= portal_url() + '/select_flag_btn.gif';
539 button
.alt
= link
.title
= 'Ajouter à la sélection';
540 link
.href
= canonicalImgUrl
+ '/add_to_selection';
541 this.selectedSlide
.className
= 'displayed';
542 this.image
.parentNode
.className
= '';
543 this.selectedSlideInSelection
= false;
549 disablePropagation(evt
);
551 link
= button
.parentNode
;
553 var slide
= this.cartSlide
;
554 slide
.innerHTML
= '';
555 slide
.style
.visibility
= 'visible';
556 var cw
= new CartWidget(slide
, link
.href
);
557 cw
.onCancel = function() {
558 CartWidget
.prototype.onCancel
.apply(this);
559 slide
.style
.visibility
= 'hidden';
561 cw
.onAfterConfirm = function() {
562 slide
.style
.visibility
= 'hidden';
570 case 'edit_metadata' :
572 disablePropagation(evt);
574 if (this.viewMode === 'full') {
575 this.mosaique.unload();
576 this.mosaique = null;
577 this.viewMode = 'medium';
580 var fi = new FragmentImporter(absolute_url());
581 fi.useMacro('metadata_edit_form_macros', 'iptc', 'image_metadata');
589 if(browser
.isDOM2Event
) {
590 if (browser
.isAppleWebKit
) {
591 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
593 var pos
= this.getSliderPosition();
594 pos
.x
-= evt
.wheelDelta
/ 40;
595 this.setSliderPosition(pos
);
599 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
601 var pos
= this.getSliderPosition();
602 pos
.x
+= evt
.detail
* 3;
603 this.setSliderPosition(pos
);
607 else if (browser
.isIE6up
) {
608 FilmSlider
.prototype.mouseWheelHandler = function() {
609 var evt
= window
.event
;
610 evt
.returnValue
= false;
611 var pos
= this.getSliderPosition();
612 pos
.x
-= evt
.wheelDelta
/ 40;
613 this.setSliderPosition(pos
);
617 FilmSlider
.prototype.touchStartHandler = function(evt
) {
618 this.filmStartX
= parseInt(this.film
.style
.left
, 10);
619 this.touchStartX
= evt
.changedTouches
[0].screenX
;
620 this.touchStartTime
= (new Date()).getTime();
623 FilmSlider
.prototype.touchMoveHandler = function(evt
) {
625 var delta
= this.touchStartX
- evt
.changedTouches
[0].screenX
;
626 var posX
= this.filmStartX
- delta
;
627 this.setFilmPosition(posX
);
628 this.lastMoveTime
= (new Date()).getTime();
631 FilmSlider
.prototype.touchEndHandler = function(evt
) {
632 var x
= evt
.changedTouches
[0].screenX
;
633 var delta
= x
- this.touchStartX
;
636 var now
= (new Date()).getTime();
637 if (now
- this.lastMoveTime
< 100) {
638 // au delà de 100 ms de maintient, on annule l'inertie
639 var speed
= delta
/ (now
- this.touchStartTime
)
640 var x0
= parseInt(this.film
.style
.left
, 10);
641 var t0
= (new Date()).getTime();
642 var d
= 500; // milisecondes
649 var t
= (new Date()).getTime() - t0
;
651 setTimeout(animate
, dt
);
652 delta
= delta
+ (1-t
/d) * speed * dt; // d
écelleration lin
éaire
653 self
.setFilmPosition(x0
+ delta
);
659 this.touchStartX
= undefined;
663 FilmSlider
.prototype.keyDownHandler = function(evt
) {
664 evt
= getEventObject(evt
);
665 switch (evt
.keyCode
) {
667 this.loadSibling(true);
670 this.loadSibling(false);
678 FilmSlider
.prototype.keyPressHandler = function(evt
) {
679 var target
= getTargetedObject(evt
);
680 if (target
.tagName
=== 'INPUT' || target
.tagName
=== 'TEXTAREA') { return; }
681 evt
= getEventObject(evt
);
682 var charPress
= String
.fromCharCode((evt
.keyCode
) ? evt
.keyCode
: evt
.which
);
686 raiseMouseEvent(this.buttons
.full_screen
, 'click');
691 FilmSlider
.prototype.populateViewer = function(req
) {
692 var elements
= req
.responseXML
.documentElement
.childNodes
;
694 for(i
=0 ; i
< elements
.length
; i
++ ) {
695 element
= elements
[i
];
696 switch (element
.nodeName
) {
698 var dest
= document
.getElementById(element
.getAttribute('id'));
699 if (dest
) { dest
.innerHTML
= element
.firstChild
.nodeValue
; }
701 case 'imageattributes' :
702 var link
= this.buttons
.back_to_portfolio
.parentNode
;
703 link
.href
= element
.getAttribute('back_to_context_url');
704 link
= this.buttons
.show_buyable
.parentNode
;
705 var buyable
= element
.getAttribute('buyable');
706 if(buyable
=== 'True') { link
.className
= null; }
707 else if(buyable
=== 'False') { link
.className
= 'hidden'; }
708 this.image
.alt
= element
.getAttribute('alt');
709 this.updateBreadcrumbs(element
.getAttribute('last_bc_url'),
710 element
.getAttribute('img_id'));
716 FilmSlider
.prototype.refreshImage = function() {
717 this.image
.style
.visibility
= 'hidden';
718 this.image
.src
= this.pendingImage
.src
;
719 this.image
.width
= this.pendingImage
.width
;
720 this.image
.height
= this.pendingImage
.height
;
721 this.image
.style
.visibility
= 'visible';
722 if (this.selectedSlideInSelection
) { this.image
.parentNode
.className
= 'selected'; }
723 else { this.image
.parentNode
.className
= ''; }
726 FilmSlider
.prototype.updateBreadcrumbs = function(url
, title
) {
727 if (this.hasBreadcrumbs
) {
728 this.lastBCElement
.href
= url
;
729 this.lastBCElement
.innerHTML
= title
;
733 FilmSlider
.prototype.startThumbnailsLoadQueue = function(evt
) {
734 var thumbnails
= this.film
.getElementsByTagName('img');
735 this.thumbnailsLoadingOrder
= [];
736 var leftSize
= this.center
;
737 var rightSize
= thumbnails
.length
- this.center
- 1;
739 for (i
=1 ; i
<=Math
.min(leftSize
, rightSize
) ; i
++) {
740 this.thumbnailsLoadingOrder
.push(thumbnails
[this.center
+ i
]);
741 this.thumbnailsLoadingOrder
.push(thumbnails
[this.center
- i
]);
743 if (leftSize
> rightSize
) {
744 for (i
= this.center
- rightSize
- 1 ; i
>= 0 ; i
--) {
746 this.thumbnailsLoadingOrder
.push(thumbnails
[i
]);
749 else if (leftSize
< rightSize
) {
750 for (i
= this.center
+ leftSize
; i
< thumbnails
.length
; i
++) {
751 this.thumbnailsLoadingOrder
.push(thumbnails
[i
]);
754 var next
= this.thumbnailsLoadingOrder
.shift();
756 addListener(next
, 'load', function(evt
){self
._loadNextThumb(evt
);});
757 next
.src
= next
.parentNode
.href
+ '/getThumbnail';
760 FilmSlider
.prototype._loadNextThumb = function(evt
) {
761 var next
= this.thumbnailsLoadingOrder
.shift();
764 addListener(next
, 'load', function(evt
){self
._loadNextThumb(evt
);});
765 next
.src
= next
.parentNode
.href
+ '/getThumbnail';
769 FilmSlider
.prototype.startSlideShow = function() {
770 this.slideShowSlide
= this.pendingSlideShowSlide
= this.selectedSlide
;
771 return this.slideShowSlide
.href
;
774 FilmSlider
.prototype.slideShowNext = function() {
775 var nextSlide
= this.slideShowSlide
.parentNode
.nextSibling
;
776 if (nextSlide
&& nextSlide
.nodeType
===3) { nextSlide
= nextSlide
.nextSibling
; }
779 nextSlide
= nextSlide
.getElementsByTagName('a')[0];
780 this.pendingSlideShowSlide
= nextSlide
;
781 return this.pendingSlideShowSlide
.href
;
784 var row
= this.slideShowSlide
.parentNode
.parentNode
;
785 var first
= row
.firstChild
;
786 if (first
.nodeType
===3) { first
= first
.nextSibling
; }
787 this.pendingSlideShowSlide
= first
.getElementsByTagName('a')[0];
788 return this.pendingSlideShowSlide
.href
;
792 FilmSlider
.prototype.slideShowPrevious = function() {
793 var previousSlide
= this.slideShowSlide
.parentNode
.previousSibling
;
794 if (previousSlide
&& previousSlide
.nodeType
===3) { previousSlide
= previousSlide
.previousSibling
; }
797 previousSlide
= previousSlide
.getElementsByTagName('a')[0];
798 this.pendingSlideShowSlide
= previousSlide
;
799 return this.pendingSlideShowSlide
.href
;
802 var row
= this.slideShowSlide
.parentNode
.parentNode
;
803 var last
= row
.lastChild
;
804 if (last
.nodeType
===3) { last
= last
.previousSibling
; }
805 this.pendingSlideShowSlide
= last
.getElementsByTagName('a')[0];
806 return this.pendingSlideShowSlide
.href
;
810 FilmSlider
.prototype.slideShowImageLoaded = function() {
811 this.slideShowSlide
= this.pendingSlideShowSlide
;
814 FilmSlider
.prototype.stopSlideShow = function() {
815 raiseMouseEvent(this.slideShowSlide
, 'click');
816 var index
= parseInt(this.selectedSlide
.getAttribute('portfolio:position'), 10);
817 this.centerSlide(index
);
822 function Point(x
, y
) {
823 this.x
= Math
.round(x
);
824 this.y
= Math
.round(y
);
826 Point
.prototype.diff = function(point
) { return new Point(this.x
- point
.x
, this.y
- point
.y
); };
827 Point
.prototype.add = function(point
) { return new Point(this.x
+ point
.x
, this.y
+ point
.y
); };
828 Point
.prototype.mul = function(k
) { return new Point(this.x
* k
, this.y
*k
); };
829 Point
.prototype.toString = function() { return "(" + String(this.x
) + ", " + String(this.y
) + ")"; };