dc2547e45c73f2adc826be82e4032bf7d842d33a
2 * 2008-2014 Benoit Pin - MINES ParisTech
4 * Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/
12 var reSelected
= /.*selected.*/;
14 Lightbox = function(grid
) {
17 addListener(this.grid
, 'click', function(evt
){thisLightbox
.mouseClickHandler(evt
);});
18 if (!browser
.isGecko
){
19 addListener(this.grid
, 'mouseover', function(evt
){thisLightbox
.mouseOverHandler(evt
);});
20 addListener(this.grid
, 'mouseout', function(evt
){thisLightbox
.mouseOutHandler(evt
);});
24 Lightbox
.prototype.mouseClickHandler = function(evt
) {
25 var target
= getTargetedObject(evt
);
26 if (target
.tagName
=== 'IMG') {
28 var link
= target
.parentNode
;
29 var button
= link
.parentNode
;
30 var slide
= button
.parentNode
;
32 if (link
.tagName
=== 'A') {
33 switch(link
.getAttribute('name')) {
34 case 'add_to_selection':
37 req
= new XMLHttpRequest();
39 req
.open("POST", url
, true);
40 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
43 slide
.className
= 'selected';
45 link
.setAttribute('name', 'remove_to_selection');
46 link
.href
= url
.replace(/(.*\/)add_to_selection$/, '$1remove_to_selection');
47 link
.title
= img
.alt
= 'Retirer de la sélection';
48 button
.className
= "button slide-deselect";
51 case 'remove_to_selection':
54 req
= new XMLHttpRequest();
56 req
.open("POST", url
, true);
57 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
59 slide
.className
= null;
60 link
.setAttribute('name', 'add_to_selection');
61 link
.href
= url
.replace(/(.*\/)remove_to_selection$/, '$1add_to_selection');
62 link
.title
= img
.alt
= 'Ajouter à la sélection';
63 button
.className
= "button slide-select";
68 slide
.widget
= new CartWidget(slide
, link
.href
);
71 case 'hide_for_anonymous':
74 req
= new XMLHttpRequest();
76 req
.open("POST", url
, true);
77 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
79 slide
.className
= 'hidden-slide';
80 link
.setAttribute('name', 'show_for_anonymous');
81 link
.href
= url
.replace(/(.*\/)hideForAnonymous$/, '$1resetHide');
82 link
.title
= img
.alt
= 'Montrer au anonymes';
83 button
.className
= "button slide-show";
86 case 'show_for_anonymous':
89 req
= new XMLHttpRequest();
91 req
.open("POST", url
, true);
92 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
94 slide
.className
= null;
95 link
.setAttribute('name', 'hide_for_anonymous');
96 link
.href
= url
.replace(/(.*\/)resetHide$/, '$1hideForAnonymous');
97 link
.title
= img
.alt
= 'Masquer pour les anonymes';
98 button
.className
= "button slide-hide";
105 Lightbox
.prototype.mouseOverHandler = function(evt
) {
106 var target
= getTargetedObject(evt
);
107 if (target
.tagName
==='AREA') {
108 var slide
= target
.parentNode
.parentNode
;
109 if(reSelected
.test(slide
.className
)) {
110 slide
.className
= 'slide_over_selected';}
112 slide
.className
= 'slide_over';}
116 Lightbox
.prototype.mouseOutHandler = function(evt
) {
117 var target
= getTargetedObject(evt
);
118 if (target
.tagName
==='AREA') {
119 var slide
= target
.parentNode
.parentNode
;
120 if(reSelected
.test(slide
.className
)) {
121 slide
.className
= 'selected';}
123 slide
.className
= undefined;}
127 var _outlineSelectedSlide
;
128 if (browser
.isGecko
) {
129 _outlineSelectedSlide = function(slide
) {
130 slide
.className
= 'selected';
134 _outlineSelectedSlide = function(slide
) {
135 if (slide
.className
&&
136 !reSelected
.test(slide
.className
)) {
137 slide
.className
= slide
.className
+ ' selected';