6c8674df70eaea5a6e8875dc3be16ba9cc84a4ab
2 * © 2008 Benoît Pin – Centre de recherche en informatique – École des mines de Paris
4 * Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/
14 var reSelected
= /.*selected.*/;
16 Lightbox = function(grid
) {
19 addListener(this.grid
, 'click', function(evt
){thisLightbox
.mouseClickHandler(evt
);});
20 if (!browser
.isGecko
){
21 addListener(this.grid
, 'mouseover', function(evt
){thisLightbox
.mouseOverHandler(evt
);});
22 addListener(this.grid
, 'mouseout', function(evt
){thisLightbox
.mouseOutHandler(evt
);});
26 Lightbox
.prototype.mouseClickHandler = function(evt
) {
27 var target
= getTargetedObject(evt
);
28 if (target
.tagName
== 'IMG') {
30 var link
= target
.parentNode
;
31 var button
= link
.parentNode
;
32 var slide
= button
.parentNode
;
33 if (link
.tagName
== 'A') {
34 switch(link
.getAttribute('name')) {
35 case 'add_to_selection':
38 var req
= new XMLHttpRequest();
40 req
.open("POST", url
, true);
41 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
44 slide
.className
= 'selected';
46 link
.setAttribute('name', 'remove_to_selection');
47 link
.href
= url
.replace(/(.*\/)add_to_selection$/, '$1remove_to_selection');
48 link
.title
= img
.alt
= 'Retirer de la sélection';
49 button
.className
= "button slide-deselect";
52 case 'remove_to_selection':
55 var req
= new XMLHttpRequest();
57 req
.open("POST", url
, true);
58 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
60 slide
.className
= null;
61 link
.setAttribute('name', 'add_to_selection');
62 link
.href
= url
.replace(/(.*\/)remove_to_selection$/, '$1add_to_selection');
63 link
.title
= img
.alt
= 'Ajouter à la sélection';
64 button
.className
= "button slide-select";
69 slide
.widget
= new CartWidget(slide
, link
.href
);
72 case 'hide_for_anonymous':
75 var req
= new XMLHttpRequest();
77 req
.open("POST", url
, true);
78 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
80 slide
.className
= 'hidden-slide';
81 link
.setAttribute('name', 'show_for_anonymous');
82 link
.href
= url
.replace(/(.*\/)hideForAnonymous$/, '$1resetHide');
83 link
.title
= img
.alt
= 'Montrer au anonymes';
84 button
.className
= "button slide-show";
87 case 'show_for_anonymous':
90 var req
= new XMLHttpRequest();
92 req
.open("POST", url
, true);
93 req
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
95 slide
.className
= null;
96 link
.setAttribute('name', 'hide_for_anonymous');
97 link
.href
= url
.replace(/(.*\/)resetHide$/, '$1hideForAnonymous');
98 link
.title
= img
.alt
= 'Masquer pour les anonymes';
99 button
.className
= "button slide-hide";
106 Lightbox
.prototype.mouseOverHandler = function(evt
) {
107 var target
= getTargetedObject(evt
);
108 if (target
.tagName
=='AREA') {
109 var slide
= target
.parentNode
.parentNode
;
110 if(reSelected
.test(slide
.className
))
111 slide
.className
= 'slide_over_selected';
113 slide
.className
= 'slide_over';
117 Lightbox
.prototype.mouseOutHandler = function(evt
) {
118 var target
= getTargetedObject(evt
);
119 if (target
.tagName
=='AREA') {
120 var slide
= target
.parentNode
.parentNode
;
121 if(reSelected
.test(slide
.className
))
122 slide
.className
= 'selected';
124 slide
.className
= undefined;
128 var _outlineSelectedSlide
;
129 if (browser
.isGecko
) {
130 _outlineSelectedSlide = function(slide
) {
131 slide
.className
= 'selected';
135 _outlineSelectedSlide = function(slide
) {
137 if (!reSelected
.test(slide
.className
))
138 slide
.className
= slide
.className
+ ' selected';