ddd73e18d2766e74a4e2212faa4c42651068e133
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
);}
77 this.addEventListeners();
81 FilmSlider
.prototype.resizeSlider = function(evt
) {
82 var filmBarWidth
= this.filmBarWidth
;
83 if (!filmBarWidth
) { return; }
84 var filmWidth
= this.slideSize
* this.filmLength
;
85 var sliderRatio
= this.sliderRatio
= filmBarWidth
/ filmWidth
;
86 var sliderWidth
= filmBarWidth
* sliderRatio
;
87 this.rail
.style
.width
= filmBarWidth
+ 'px';
88 this.rail
.style
.display
= 'block';
89 this.rail
.style
.visibility
= 'visible';
90 if (sliderRatio
< 1) {
91 this.slider
.style
.width
= Math
.round(sliderWidth
) + 'px';
92 this.slider
.style
.visibility
= 'visible';
95 this.slider
.style
.visibility
= 'hidden';
98 this.winSize
= {'width' : getWindowWidth(),
99 'height' : getWindowHeight()};
100 this.maxRightPosition
= filmBarWidth
- sliderWidth
;
101 this.sliderSpeedRatio
= - (filmBarWidth
- sliderWidth
) / (filmWidth
- filmBarWidth
);
102 if (!this.initialized
) {
103 this.centerSlide(this.center
);
104 this.selectedSlide
= this.filmBar
.getElementsByTagName('img')[this.center
].parentNode
;
105 this.initialized
= true;
109 FilmSlider
.prototype._checkSizeAfterLoad = function(evt
) {
111 this.filmBarWidth
= this._barSizes
[this._barSizes
.length
] = getObjectWidth(this.filmBar
);
114 this._checkSizeIntervalId
= setInterval(function(evt
){self
._checkSize(evt
);}, 25);
115 setTimeout(function(evt
){self
._checkSizeStability();}, 250);
118 FilmSlider
.prototype._checkSize = function(evt
) {
119 this._barSizes
[this._barSizes
.length
] = getObjectWidth(this.filmBar
);
120 if (this._barSizes
.length
>= 2 &&
121 this._barSizes
[this._barSizes
.length
-2] !== this._barSizes
[this._barSizes
.length
-1]) {
122 this.filmBarWidth
= this._barSizes
[this._barSizes
.length
-1];
123 this.initialized
= false;
128 FilmSlider
.prototype._checkSizeStability = function(evt
) {
131 for (i
=0 ; i
<this._barSizes
.length
- 1 ; i
++) {
132 if (this._barSizes
[i
] !== this._barSizes
[i
+1]) {
134 setTimeout(function(evt
){self
._checkSizeStability();}, 250);
138 clearInterval(this._checkSizeIntervalId
);
139 delete this._barSizes
;
140 delete this._checkSizeIntervalId
;
143 FilmSlider
.prototype.fitToScreen = function(evt
) {
145 var thisSlider
= this;
146 addListener(window
, 'resize', function(evt
){thisSlider
._fitToScreen();});
149 FilmSlider
.prototype._fitToScreen = function(evt
) {
150 var wh
= getWindowHeight();
151 var rb
= getObjectTop(this.rail
) + getObjectHeight(this.rail
); // rail bottom
153 var sh
= getObjectHeight(this.stretchable
);
154 var newSize
= sh
+ delta
;
155 this.stretchable
.style
.height
= newSize
+ 'px';
157 var ratio
= this.image
.height
/ this.image
.width
;
158 var bestFitSize
= this.getBestFitSize(ratio
);
159 var currentSize
= parseInt(imgRequestedSize
.exec(this.image
.src
)[1], 10);
160 if (currentSize
!== bestFitSize
) {
161 var src
= this.image
.src
.replace(imgRequestedSize
, 'size=' + bestFitSize
);
162 this.pendingImage
.src
= src
;
166 FilmSlider
.prototype.getBestFitSize = function(ratio
) {
167 var fw
= getObjectWidth(this.stretchable
) - 1;
168 var fh
= getObjectHeight(this.stretchable
) - 1;
172 for (i
=DEFAULT_IMAGE_SIZES
.length
-1 ; i
>0 ; i
--) {
173 irw
= DEFAULT_IMAGE_SIZES
[i
];
175 if (irw
<= fw
&& irh
<= fh
) { break; }
179 for (i
=DEFAULT_IMAGE_SIZES
.length
-1 ; i
>0 ; i
--) {
180 irh
= DEFAULT_IMAGE_SIZES
[i
];
182 if (irw
<= fw
&& irh
<= fh
) { break; }
185 return DEFAULT_IMAGE_SIZES
[i
];
188 FilmSlider
.prototype.centerSlide = function(slideIndex
) {
189 if (this.sliderRatio
> 1) { return; }
190 var filmBarWidth
= getObjectWidth(this.filmBar
);
191 var x
= slideIndex
* this.slideSize
;
192 x
= x
- (filmBarWidth
- this.slideSize
) / 2.0;
193 x
= x
* this.sliderSpeedRatio
;
194 var p
= new Point( -x
, 0 );
195 this.setSliderPosition(p
);
198 FilmSlider
.prototype.setSliderPosition = function(point
) {
199 if(point
.x
< 0) { point
.x
= 0; }
200 if (point
.x
> this.maxRightPosition
) { point
.x
= this.maxRightPosition
; }
201 this.slider
.style
.left
= point
.x
+ 'px';
202 this.setFilmPosition(point
);
205 FilmSlider
.prototype.setFilmPosition = function(point
) {
206 this.film
.style
.left
= point
.x
/ this.sliderSpeedRatio
+ 'px';
209 FilmSlider
.prototype.getSliderPosition = function() {
210 var x
= parseInt(this.slider
.style
.left
, 10);
211 var y
= parseInt(this.slider
.style
.top
, 10);
212 var p
= new Point(x
, y
);
216 FilmSlider
.prototype.getFilmPosition = function() {
217 var x
= parseInt(this.film
.style
.left
, 10);
218 var y
= parseInt(this.film
.style
.top
, 10);
219 var p
= new Point(x
, y
);
223 FilmSlider
.prototype.loadSibling = function(previous
) {
226 slide
= this.selectedSlide
.parentNode
.previousSibling
;
227 if (slide
&& slide
.nodeType
===3) { slide
= slide
.previousSibling
; }
230 slide
= this.selectedSlide
.parentNode
.nextSibling
;
231 if (slide
&& slide
.nodeType
===3) { slide
= slide
.nextSibling
; }
234 if (!slide
) { return; }
236 var target
= slide
.getElementsByTagName('a')[0];
237 raiseMouseEvent(target
, 'click');
238 var index
= parseInt(target
.getAttribute('portfolio:position'), 10);
239 this.centerSlide(index
);
243 FilmSlider
.prototype.addEventListeners = function() {
244 var thisSlider
= this;
245 addListener(window
, 'resize', function(evt
){thisSlider
.resizeSlider(evt
);});
246 addListener(this.filmBar
, 'click', function(evt
){thisSlider
.thumbnailClickHandler(evt
);});
247 addListener(this.toolbar
, 'click', function(evt
){thisSlider
.toolbarClickHandler(evt
);});
248 addListener(window
, 'load', function(evt
){thisSlider
.fitToScreen(evt
);});
249 addListener(window
, 'load', function(evt
){thisSlider
._checkSizeAfterLoad(evt
);});
252 addListener(this.slider
, 'mousedown', this.ddHandlers
.down
);
253 if(browser
.isDOM2Event
){
254 if (browser
.isAppleWebKit
) {
255 this.filmBar
.addEventListener('mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);}, false);
258 addListener(this.filmBar
, 'DOMMouseScroll', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
261 else if (browser
.isIE6up
) {
262 addListener(this.filmBar
, 'mousewheel', function(evt
){thisSlider
.mouseWheelHandler(evt
);});
265 addListener(document
, 'keydown', function(evt
){thisSlider
.keyDownHandler(evt
);});
266 addListener(document
, 'keypress', function(evt
){thisSlider
.keyPressHandler(evt
);});
270 FilmSlider
.prototype.mouseDownHandler = function(evt
) {
271 this.initialClickPoint
= new Point(evt
.clientX
, evt
.clientY
);
272 this.initialPosition
= this.getSliderPosition();
273 this.dragInProgress
= true;
274 addListener(document
, 'mousemove', this.ddHandlers
.move);
275 addListener(document
, 'mouseup', this.ddHandlers
.up
);
276 addListener(document
.body
, 'mouseout', this.ddHandlers
.out
);
280 FilmSlider
.prototype.mouseMoveHandler = function(evt
) {
281 if(!this.dragInProgress
) { return; }
284 evt
= getEventObject(evt
);
285 var currentPoint
= new Point(evt
.clientX
, evt
.clientY
);
286 var displacement
= currentPoint
.diff(this.initialClickPoint
);
287 this.setSliderPosition(this.initialPosition
.add(displacement
));
290 FilmSlider
.prototype.mouseUpHandler = function(evt
) {
291 this.dragInProgress
= false;
292 evt
= getEventObject(evt
);
293 this.mouseMoveHandler(evt
);
297 FilmSlider
.prototype.mouseOutHandler = function(evt
) {
298 evt
= getEventObject(evt
);
302 x
> this.winSize
.width
||
304 y
> this.winSize
.height
306 this.mouseUpHandler(evt
);
310 FilmSlider
.prototype.thumbnailClickHandler = function(evt
) {
311 var target
= getTargetedObject(evt
);
312 while (target
.tagName
!== 'A' && target
!== this.filmBar
) { target
= target
.parentNode
; }
313 if (target
.tagName
!== 'A') { return; }
315 if (this.viewMode
=== 'full') {
316 this.mosaique
.unload();
317 this.mosaique
= null;
318 this.viewMode
= 'medium';
321 disablePropagation(evt
);
323 history
.pushState(target
.href
, '', target
.href
);
325 var imgBaseUrl
= target
.href
;
327 if (this.ctxUrlTranslation
[0]) {
328 canonicalImgUrl
= imgBaseUrl
.replace(this.ctxUrlTranslation
[0],
329 this.ctxUrlTranslation
[1]);
331 else { canonicalImgUrl
= imgBaseUrl
; }
333 var ajaxUrl
= imgBaseUrl
+ '/photo_view_ajax';
336 //this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=600';
337 var thumbnail
= target
.getElementsByTagName('IMG')[0];
338 var bestFitSize
= this.getBestFitSize(thumbnail
.height
/thumbnail
.width
);
339 this.pendingImage
.src
= canonicalImgUrl
+ '/getResizedImage?size=' + bestFitSize
;
342 var fullScreenLink
= this.buttons
.full_screen
.parentNode
;
343 fullScreenLink
.href
= canonicalImgUrl
+ '/zoom_view';
345 var toggleSelectionBtn
= this.buttons
.toggle_selection
;
346 var toggleSelectionLink
= toggleSelectionBtn
.parentNode
;
347 this.selectedSlideInSelection
= (target
.className
==='selected');
348 if (this.selectedSlideInSelection
) {
349 toggleSelectionBtn
.src
= portal_url() + '/unselect_flag_btn.gif';
350 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Retirer de la sélection';
351 toggleSelectionLink
.href
= canonicalImgUrl
+ '/remove_to_selection';
354 toggleSelectionBtn
.src
= portal_url() + '/select_flag_btn.gif';
355 toggleSelectionBtn
.alt
= toggleSelectionLink
.title
= 'Ajouter à la sélection';
356 toggleSelectionLink
.href
= canonicalImgUrl
+ '/add_to_selection';
359 var showBuyableButtonLink
= this.buttons
.show_buyable
.parentNode
;
360 showBuyableButtonLink
.href
= canonicalImgUrl
+ '/get_slide_buyable_items';
361 this.cartSlide
.innerHTML
= '';
362 this.cartSlide
.style
.visibility
='hidden';
365 var metadataButton
= this.buttons
.edit_metadata
;
366 if (metadataButton
) {
367 var metadataEditLink
= metadataButton
.parentNode
;
368 metadataEditLink
.href
= canonicalImgUrl
+ '/photo_edit_form';
372 var req
= new XMLHttpRequest();
373 req
.onreadystatechange = function() {
374 switch (req
.readyState
) {
380 if (! isTextMime
.exec(req
.getResponseHeader('Content-Type'))) {
381 req
.onreadystatechange
= null;
384 window
.location
.href
= thisFS
._fallBackUrl
;
391 if (req
.status
=== 200) { thisFS
.populateViewer(req
); }
396 req
.open("GET", ajaxUrl
, true);
399 // update old displayed slide className
400 var className
= this.selectedSlide
.className
;
401 var classes
= className
.split(' ');
405 for (i
=0 ; i
<classes
.length
; i
++) {
407 if (name
!== 'displayed') {
408 newClasses
.push(name
);
412 this.selectedSlide
.className
= newClasses
.join(' ');
414 // hightlight new displayed slide
415 this.selectedSlide
= target
;
416 className
= this.selectedSlide
.className
;
417 classes
= className
.split(' ');
418 classes
.push('displayed');
419 this.selectedSlide
.className
= classes
.join(' ');
423 FilmSlider
.prototype.toolbarClickHandler = function(evt
) {
424 var target
= getTargetedObject(evt
);
425 var button
, link
, url
;
426 if(target
.tagName
=== 'IMG' && target
.getAttribute('name')) {
427 switch(target
.getAttribute('name')) {
430 disablePropagation(evt
);
432 link
= button
.parentNode
;
434 this.loadSibling(true);
438 disablePropagation(evt
);
440 link
= button
.parentNode
;
442 this.loadSibling(false);
446 disablePropagation(evt
);
447 target
.parentNode
.blur();
448 if (this.viewMode
=== 'full') {
449 this.mosaique
.unload();
450 this.mosaique
= null;
451 this.viewMode
= 'medium';
454 var main
= document
.getElementById('photo_viewer');
455 url
= target
.parentNode
.href
;
456 url
= url
.substring(0, url
.length
- '/zoom_view'.length
);
457 var margins
= {'top':0, 'right':-1, 'bottom':0, 'left':0};
458 this.mosaique
= new Mosaique(main
, url
, margins
);
459 this.viewMode
= 'full';
462 case 'toggle_selection':
464 disablePropagation(evt
);
466 link
= button
.parentNode
;
469 var req
= new XMLHttpRequest();
471 req
.open("POST", url
, true);
472 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
476 var parts
= url
.split('/');
477 var canonicalImgUrl
= parts
.slice(0, parts
.length
-1).join('/');
479 if (isAddToSelection
.test(url
)) {
480 button
.src
= portal_url() + '/unselect_flag_btn.gif';
481 button
.alt
= link
.title
= 'Retirer de la sélection';
482 link
.href
= canonicalImgUrl
+ '/remove_to_selection';
483 this.selectedSlide
.className
= 'selected displayed';
484 this.image
.parentNode
.className
= 'selected';
485 this.selectedSlideInSelection
= true;
488 button
.src
= portal_url() + '/select_flag_btn.gif';
489 button
.alt
= link
.title
= 'Ajouter à la sélection';
490 link
.href
= canonicalImgUrl
+ '/add_to_selection';
491 this.selectedSlide
.className
= 'displayed';
492 this.image
.parentNode
.className
= '';
493 this.selectedSlideInSelection
= false;
499 disablePropagation(evt
);
501 link
= button
.parentNode
;
503 var slide
= this.cartSlide
;
504 slide
.innerHTML
= '';
505 slide
.style
.visibility
= 'visible';
506 var cw
= new CartWidget(slide
, link
.href
);
507 cw
.onCancel = function() {
508 CartWidget
.prototype.onCancel
.apply(this);
509 slide
.style
.visibility
= 'hidden';
511 cw
.onAfterConfirm = function() {
512 slide
.style
.visibility
= 'hidden';
520 case 'edit_metadata' :
522 disablePropagation(evt);
524 if (this.viewMode === 'full') {
525 this.mosaique.unload();
526 this.mosaique = null;
527 this.viewMode = 'medium';
530 var fi = new FragmentImporter(absolute_url());
531 fi.useMacro('metadata_edit_form_macros', 'iptc', 'image_metadata');
539 if(browser
.isDOM2Event
) {
540 if (browser
.isAppleWebKit
) {
541 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
543 var pos
= this.getSliderPosition();
544 pos
.x
-= evt
.wheelDelta
/ 40;
545 this.setSliderPosition(pos
);
549 FilmSlider
.prototype.mouseWheelHandler = function(evt
) {
551 var pos
= this.getSliderPosition();
552 pos
.x
+= evt
.detail
* 3;
553 this.setSliderPosition(pos
);
557 else if (browser
.isIE6up
) {
558 FilmSlider
.prototype.mouseWheelHandler = function() {
559 var evt
= window
.event
;
560 evt
.returnValue
= false;
561 var pos
= this.getSliderPosition();
562 pos
.x
-= evt
.wheelDelta
/ 40;
563 this.setSliderPosition(pos
);
567 FilmSlider
.prototype.keyDownHandler = function(evt
) {
568 evt
= getEventObject(evt
);
569 switch (evt
.keyCode
) {
571 this.loadSibling(true);
574 this.loadSibling(false);
582 FilmSlider
.prototype.keyPressHandler = function(evt
) {
583 var target
= getTargetedObject(evt
);
584 if (target
.tagName
=== 'INPUT' || target
.tagName
=== 'TEXTAREA') { return; }
585 evt
= getEventObject(evt
);
586 var charPress
= String
.fromCharCode((evt
.keyCode
) ? evt
.keyCode
: evt
.which
);
590 raiseMouseEvent(this.buttons
.full_screen
, 'click');
595 FilmSlider
.prototype.populateViewer = function(req
) {
596 var elements
= req
.responseXML
.documentElement
.childNodes
;
598 for(i
=0 ; i
< elements
.length
; i
++ ) {
599 element
= elements
[i
];
600 switch (element
.nodeName
) {
602 var dest
= document
.getElementById(element
.getAttribute('id'));
603 if (dest
) { dest
.innerHTML
= element
.firstChild
.nodeValue
; }
605 case 'imageattributes' :
606 var link
= this.buttons
.back_to_portfolio
.parentNode
;
607 link
.href
= element
.getAttribute('backToContextUrl');
608 link
= this.buttons
.show_buyable
.parentNode
;
609 var buyable
= element
.getAttribute('buyable');
610 if(buyable
=== 'True') { link
.className
= null; }
611 else if(buyable
=== 'False') { link
.className
= 'hidden'; }
612 this.image
.alt
= element
.getAttribute('alt');
613 this.updateBreadcrumbs(element
.getAttribute('lastBcUrl'),
614 element
.getAttribute('img_id'));
620 FilmSlider
.prototype.refreshImage = function() {
621 this.image
.style
.visibility
= 'hidden';
622 this.image
.src
= this.pendingImage
.src
;
623 this.image
.width
= this.pendingImage
.width
;
624 this.image
.height
= this.pendingImage
.height
;
625 this.image
.style
.visibility
= 'visible';
626 if (this.selectedSlideInSelection
) { this.image
.parentNode
.className
= 'selected'; }
627 else { this.image
.parentNode
.className
= ''; }
630 FilmSlider
.prototype.updateBreadcrumbs = function(url
, title
) {
631 if (this.hasBreadcrumbs
) {
632 this.lastBCElement
.href
= element
.getAttribute('lastBcUrl');
633 this.lastBCElement
.innerHTML
= element
.getAttribute('img_id');
637 FilmSlider
.prototype.startSlideShow = function() {
638 this.slideShowSlide
= this.pendingSlideShowSlide
= this.selectedSlide
;
639 return this.slideShowSlide
.href
;
642 FilmSlider
.prototype.slideShowNext = function() {
643 var nextSlide
= this.slideShowSlide
.parentNode
.nextSibling
;
644 if (nextSlide
&& nextSlide
.nodeType
===3) { nextSlide
= nextSlide
.nextSibling
; }
647 nextSlide
= nextSlide
.getElementsByTagName('a')[0];
648 this.pendingSlideShowSlide
= nextSlide
;
649 return this.pendingSlideShowSlide
.href
;
652 var row
= this.slideShowSlide
.parentNode
.parentNode
;
653 var first
= row
.firstChild
;
654 if (first
.nodeType
===3) { first
= first
.nextSibling
; }
655 this.pendingSlideShowSlide
= first
.getElementsByTagName('a')[0];
656 return this.pendingSlideShowSlide
.href
;
660 FilmSlider
.prototype.slideShowPrevious = function() {
661 var previousSlide
= this.slideShowSlide
.parentNode
.previousSibling
;
662 if (previousSlide
&& previousSlide
.nodeType
===3) { previousSlide
= previousSlide
.previousSibling
; }
665 previousSlide
= previousSlide
.getElementsByTagName('a')[0];
666 this.pendingSlideShowSlide
= previousSlide
;
667 return this.pendingSlideShowSlide
.href
;
670 var row
= this.slideShowSlide
.parentNode
.parentNode
;
671 var last
= row
.lastChild
;
672 if (last
.nodeType
===3) { last
= last
.previousSibling
; }
673 this.pendingSlideShowSlide
= last
.getElementsByTagName('a')[0];
674 return this.pendingSlideShowSlide
.href
;
678 FilmSlider
.prototype.slideShowImageLoaded = function() {
679 this.slideShowSlide
= this.pendingSlideShowSlide
;
682 FilmSlider
.prototype.stopSlideShow = function() {
683 raiseMouseEvent(this.slideShowSlide
, 'click');
684 var index
= parseInt(this.selectedSlide
.getAttribute('portfolio:position'), 10);
685 this.centerSlide(index
);
690 function Point(x
, y
) {
691 this.x
= Math
.round(x
);
692 this.y
= Math
.round(y
);
694 Point
.prototype.diff = function(point
) { return new Point(this.x
- point
.x
, this.y
- point
.y
); };
695 Point
.prototype.add = function(point
) { return new Point(this.x
+ point
.x
, this.y
+ point
.y
); };
696 Point
.prototype.mul = function(k
) { return new Point(this.x
* k
, this.y
*k
); };
697 Point
.prototype.toString = function() { return "(" + String(this.x
) + ", " + String(this.y
) + ")"; };