Project

General

Profile

« Previous | Next » 

Revision 83

Added by nicolasboyer 5 months ago

scimagemgr en external

View differences:

branches/sc50/model/sources/_common/wdt/scImageMgr.doss/scImageMgr.js
1
/**
2
 * LICENCE[[
3
 * Version: MPL 2.0/GPL 3.0/LGPL 3.0/CeCILL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 2.0 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
8
 *
9
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 * for the specific language governing rights and limitations under the
12
 * License.
13
 *
14
 * The Original Code is kelis.fr code.
15
 *
16
 * The Initial Developer of the Original Code is 
17
 * samuel.monsarrat@kelis.fr
18
 *
19
 * Portions created by the Initial Developer are Copyright (C) 2009-2020
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s): nicolas.boyer@kelis.fr
23
 *
24
 * Alternatively, the contents of this file may be used under the terms of
25
 * either of the GNU General Public License Version 3.0 or later (the "GPL"),
26
 * or the GNU Lesser General Public License Version 3.0 or later (the "LGPL"),
27
 * or the CeCILL Licence Version 2.1 (http://www.cecill.info/licences.en.html),
28
 * in which case the provisions of the GPL, the LGPL or the CeCILL are applicable
29
 * instead of those above. If you wish to allow use of your version of this file
30
 * only under the terms of either the GPL, the LGPL or the CeCILL, and not to allow
31
 * others to use your version of this file under the terms of the MPL, indicate
32
 * your decision by deleting the provisions above and replace them with the notice
33
 * and other provisions required by the GPL, the LGPL or the CeCILL. If you do not
34
 * delete the provisions above, a recipient may use your version of this file under
35
 * the terms of any one of the MPL, the GPL, the LGPL or the CeCILL.
36
 * ]]LICENCE
37
 */
38

  
39
/* === SCENARI Dynamic image manager ======================================== */
40
var scImageMgr = {
41
	fPathAnim : [],
42
	fPathGal : [],
43
	fPathSeq : [],
44
	fPathSlider : [],
45
	fPathZoom : [],
46
	fPathImg : [],
47
	fPathSvg : [],
48
	fAnims : null,
49
	fGals : null,
50
	fZooms : null,
51
	fPathPgeFra : "des:div",
52
	fPathFocusables : "des:a|input|button",
53
	fCurrItem : null,
54
	fOverAlpha : .6,
55
	fDefaultStep : 3 * 1000,
56
	fMinStep : 1 * 100,
57
	fMaxStep : 10 * 1000,
58
	fDeltaGalleryLeft : 125,
59
	fDeltaGalleryTop : 50,
60
	fTypAnm : "scImgAnm",
61
	fTypZm : "scImgZm",
62
	fTypGal : "scImgGal",
63
	fTypSeq : "scImgSeq",
64
	fTypSlider : "scImgSlider",
65
	fFocus : true,
66
	fSourceRoot : null,
67
	fDisplayRoot : null,
68
	fLocalize : true,
69
	fMarginStart : "marginLeft",
70
	fMarginEnd : "marginRight",
71
	fNavie8 : parseFloat(scCoLib.userAgent.substring(scCoLib.userAgent.indexOf("msie")+5)) < 9,
72
	fMaxDeviceWidth : Math.min(window.screen.width, window.screen.height),
73
	fListeners : {"onOverlayOpen":[],"onOverlayClose":[],"onAnimationOpen":[],"onAnimationClose":[],"onZoomOpen":[],"onZoomClose":[]}
74
}
75

  
76
/** SCENARI Dynamic image manager strings */
77
scImageMgr.fStrings = ["précédent","image précédente (flèche de gauche)",
78
/*02*/               "suivant","image suivante (flèche de droite)",
79
/*04*/               "fermer","fermer le diaporama (Echap)",
80
/*06*/               "lancer","lancer le diaporama (p)",
81
/*08*/               "arrêter","arrêter le diaporama (p)",
82
/*10*/               "Cette page est en cours de chargement. Veuillez patienter.","",
83
/*12*/               "précédent","image précédente",
84
/*14*/               "suivant","image suivante",
85
/*16*/               "lancer","lancer l\'animation",
86
/*18*/               "arrêter","arrêter l\'animation",
87
/*20*/               "début","aller au début de l\'animation",
88
/*22*/               "fin","aller à la fin de l\'animation",
89
/*24*/               "vitesse","changer la vitesse de l\'animation",
90
/*26*/               "image","Consulter le diaporama à partir de :",
91
/*28*/               "boucle","jouer en boucle continue",
92
/*30*/               "fermer","fermer le zoom (Echap)",
93
/*32*/               "zoomer sur cette image",""];
94
/** scImageMgr.init. */
95
scImageMgr.init = function() {
96
	// Init image animations...
97
	try{
98
		if (!("scDynUiMgr" in window)) throw "Library scDynUiMgr not found.";
99
		if(this.xReadStyle(document.body.parentNode, "direction") == "rtl") {
100
			this.fMarginStart = "marginRight";
101
			this.fMarginEnd = "marginLeft";
102
		}
103
		for(var i=0; i<this.fPathAnim.length; i++) {
104
			var vAnims = scPaLib.findNodes(this.fPathAnim[i].fPath);
105
			for(var j=0; j<vAnims.length; j++) {
106
				var vAnim = vAnims[j];
107
				try {
108
					var vImgs = scPaLib.findNodes("chi:",vAnim);
109
					for(var k=0; k<vImgs.length; k++) {
110
						if (k>0) {
111
							vImgs[k].style.visibility = "hidden";
112
							vImgs[k].style.position = "absolute";
113
							vImgs[k].style.left = "-2000px";
114
							vImgs[k].style.top = "-2000px";
115
						}
116
					}
117
				} catch(e){
118
					scCoLib.log("scImageMgr.init::Anim init Error"+e);
119
				}
120
			}
121
		}
122
		// Load images ...
123
		this.xInitImgs(this.fSourceRoot);
124
		// Mend svgs ...
125
		this.xInitSvgs(this.fSourceRoot);
126
		//Register listeners...
127
		scDynUiMgr.collBlk.addOpenListener(this.sCollBlkOpen);
128
		scDynUiMgr.collBlk.addCloseListener(this.sCollBlkClose);
129
		scOnLoads[scOnLoads.length] = this;
130
	} catch(e){scCoLib.log("ERROR - scImageMgr.init : "+e)}
131
}
132
/** scImageMgr.registerAnimation.
133
 * @param pPathAnim scPaLib path vers les animations.
134
 * @param pOpts options de l'animation.
135
 *           toolbar : 0 = pas de toolbar / 1 = toolbar flotant / 2 toolbar permanent
136
 *           auto : true = démarrage auto
137
 *           loop : true = lecture en boucle
138
 *           lpBtn : true = bouton ctrl lecture en boucle
139
 *           speed : vitesse de défilement en ms
140
 *           spdBtns : true = boutons de contrôle de la vitesse
141
 *           counter : true = compteur d'image
142
 *           soft : true = fondu entre images
143
 *           extBtns : true = boutons supplémentaires
144
 *           clsPre : préfix de classe CSS
145
 */
146
scImageMgr.registerAnimation = function(pPathAnim, pOpts) {
147
	var vAnim = new Object;
148
	vAnim.fPath = pPathAnim;
149
	vAnim.fOpts = (typeof pOpts == "undefined" ? {toolbar:1,auto:true,loop:true,lpBtn:false,speed:this.fDefaultStep,spdBtns:false,counter:false,soft:true,extBtns:false,clsPre:this.fTypAnm} : pOpts);
150
	vAnim.fOpts.toolbar = (typeof vAnim.fOpts.toolbar == "undefined" ? 1 : vAnim.fOpts.toolbar);
151
	vAnim.fOpts.auto = (typeof vAnim.fOpts.auto == "undefined" ? true : vAnim.fOpts.auto);
152
	vAnim.fOpts.loop = (typeof vAnim.fOpts.loop == "undefined" ? true : vAnim.fOpts.loop);
153
	vAnim.fOpts.lpBtn = (typeof vAnim.fOpts.lpBtn == "undefined" ? false : vAnim.fOpts.lpBtn);
154
	vAnim.fOpts.speed = (typeof vAnim.fOpts.speed == "undefined" ? this.fDefaultStep : vAnim.fOpts.speed);
155
	vAnim.fOpts.spdBtns = (typeof vAnim.fOpts.spdBtns == "undefined" ? false : vAnim.fOpts.spdBtns);
156
	vAnim.fOpts.counter = (typeof vAnim.fOpts.counter == "undefined" ? false : vAnim.fOpts.counter);
157
	vAnim.fOpts.soft = (typeof vAnim.fOpts.soft == "undefined" ? true : vAnim.fOpts.soft);
158
	vAnim.fOpts.extBtns = (typeof vAnim.fOpts.extBtns == "undefined" ? false : vAnim.fOpts.extBtns);
159
	vAnim.fOpts.clsPre = (typeof vAnim.fOpts.clsPre == "undefined" ? this.fTypAnm : vAnim.fOpts.clsPre);
160
	this.fPathAnim[this.fPathAnim.length] = vAnim;
161
}
162
/** scImageMgr.registerGallery.
163
 * @param pPathGal scPaLib path vers les zooms.
164
 * @param pOpts options de la gallerie.
165
 *           clsPre : préfix de classe CSS
166
 *           maxWidth : largeur max des images 
167
 *           maxHeight : hauteur max des images
168
 */
169
scImageMgr.registerGallery = function(pPathGal, pOpts) {
170
	var vGal = new Object;
171
	vGal.fPath = pPathGal;
172
	vGal.fOpts = (typeof pOpts == "undefined" ? {clsPre:this.fTypGal,maxWidth:700,maxHeight:500} : pOpts);
173
	vGal.fOpts.clsPre = (typeof vGal.fOpts.clsPre == "undefined" ? this.fTypGal : vGal.fOpts.clsPre);
174
	vGal.fOpts.maxWidth = (typeof vGal.fOpts.maxWidth == "undefined" ? 700 : vGal.fOpts.maxWidth);
175
	vGal.fOpts.maxHeight = (typeof vGal.fOpts.maxHeight == "undefined" ? 500 : vGal.fOpts.maxHeight);
176
	this.fPathGal[this.fPathGal.length] = vGal;
177
}
178
/** scImageMgr.registerGallery.
179
 * @param fPathSeq scPaLib path vers les zooms.
180
 * @param pOpts options de la gallerie.
181
 *           clsPre : préfix de classe CSS
182
 */
183
scImageMgr.registerSequence = function(pPathSeq, pOpts) {
184
	var vSeq = new Object;
185
	vSeq.fPath = pPathSeq;
186
	vSeq.fOpts = (typeof pOpts == "undefined" ? {clsPre:this.fTypSeq} : pOpts);
187
	vSeq.fOpts.clsPre = (typeof vSeq.fOpts.clsPre == "undefined" ? this.fTypSeq : vSeq.fOpts.clsPre);
188
	this.fPathSeq[this.fPathSeq.length] = vSeq;
189
}
190
/** scImageMgr.registerZoom.
191
 * @param pPathZoom scPaLib path vers les zooms.
192
 * @param pOpts options du zoom.
193
 *           toolbar : 0 = pas de toolbar / 1 = toolbar
194
 *           type : img = zoom d'image / svg = zoom de svg / iframe = zoom chargé dans une iframe
195
 *           mag : 0 = pas de loupe /  1 = ajouter une loupe si besoin
196
 *           magScale : relative size of the zoom area compared to the visible image
197
 *           magMax : 0 = pas de mode max /  1 = mode max sur click
198
 *           magPan : 0 = pas de pan en mode max /  1 = pan en mode max
199
 *           svgMax : 0 = svg affiché à sa taille standard / 1 = toujours maximiser les svg pour ateindre la taille du viewport
200
 *           titlePath : scPaLib path to a title relative to the anchor.
201
 *           clsPre : préfix de classe CSS
202
 */
203
scImageMgr.registerZoom = function(pPathZoom, pOpts) {
204
	var vZm = new Object;
205
	vZm.fPath = pPathZoom;
206
	vZm.fOpts = (typeof pOpts == "undefined" ? {toolbar:0,type:"img",clsPre:this.fTypZm} : pOpts);
207
	vZm.fOpts.type = (typeof vZm.fOpts.type == "undefined" ? "img" : vZm.fOpts.type);
208
	vZm.fOpts.toolbar = (typeof vZm.fOpts.toolbar == "undefined" ? 1 : vZm.fOpts.toolbar);
209
	vZm.fOpts.mag = (typeof vZm.fOpts.mag == "undefined" ? 0 : vZm.fOpts.mag);
210
	vZm.fOpts.magScale = (typeof vZm.fOpts.magScale == "undefined" ? 0.33 : vZm.fOpts.magScale);
211
	vZm.fOpts.magMax = (typeof vZm.fOpts.magMax == "undefined" ? 1 : vZm.fOpts.magMax);
212
	vZm.fOpts.magPan = (typeof vZm.fOpts.magPan == "undefined" ? 1 : vZm.fOpts.magPan);
213
	vZm.fOpts.svgMax = (typeof vZm.fOpts.svgMax == "undefined" ? 0 : vZm.fOpts.svgMax);
214
	vZm.fOpts.clsPre = (typeof vZm.fOpts.clsPre == "undefined" ? this.fTypZm : vZm.fOpts.clsPre);
215
	vZm.fOpts.titlePath = (typeof vZm.fOpts.titlePath == "undefined" ? null : vZm.fOpts.titlePath);
216
	if ((vZm.fOpts.mag > 0 || vZm.fOpts.titlePath) && vZm.fOpts.toolbar == 0) vZm.fOpts.toolbar = 1;
217
	this.fPathZoom[this.fPathZoom.length] = vZm;
218
}
219
/** scImageMgr.registerSlider.
220
 * @param pPathSlider scPaLib path vers les zooms.
221
 * @param pOpts options de la gallerie.
222
 *           clsPre : préfix de classe CSS
223
 *           maxWidth : largeur max des images 
224
 *           maxHeight : hauteur max des images
225
 */
226
scImageMgr.registerSlider = function(pPathSlider, pOpts) {
227
	var vSlider = new Object;
228
	vSlider.fPath = pPathSlider;
229
	vSlider.fOpts = (typeof pOpts == "undefined" ? {clsPre:this.fTypSlider} : pOpts);
230
	vSlider.fOpts.clsPre = (typeof vSlider.fOpts.clsPre == "undefined" ? this.fTypSlider : vSlider.fOpts.clsPre);
231
	this.fPathSlider[this.fPathSlider.length] = vSlider;
232
}
233
/** scImageMgr.registerAdaptedImage.
234
 * @param pPathImage scPaLib path vers les images.
235
 */
236
scImageMgr.registerAdaptedImage = function(pPathImage) {
237
	var vImg = new Object;
238
	vImg.fPath = pPathImage;
239
	this.fPathImg[this.fPathImg.length] = vImg;
240
}
241

  
242
/** scImageMgr.registerSvg.
243
 * @param pPathSvg scPaLib path vers les svgs.
244
 */
245
scImageMgr.registerSvg = function(pPathSvg) {
246
	var vSvg = new Object;
247
	vSvg.fPath = pPathSvg;
248
	this.fPathSvg[this.fPathSvg.length] = vSvg;
249
}
250

  
251
/** register a listener. */
252
scImageMgr.registerListener = function(pType, pFunc) {
253
	this.fListeners[pType].push(pFunc);
254
}
255
/** scImageMgr.setSourceRoot. */
256
scImageMgr.setSourceRoot = function(pRoot) {
257
	this.fSourceRoot = pRoot;
258
}
259
/** scImageMgr.setDisplayRoot. */
260
scImageMgr.setDisplayRoot = function(pRoot) {
261
	this.fDisplayRoot = pRoot;
262
}
263
/** scImageMgr.setPathPgeFra. */
264
scImageMgr.setPathPgeFra = function(pPathPgeFra) {
265
	this.fPathPgeFra = pPathPgeFra;
266
}
267
/** scImageMgr.setFocus. */
268
scImageMgr.setFocus = function(pFocus) {
269
	this.fFocus = pFocus;
270
}
271
/** scImageMgr.setLocalize. */
272
scImageMgr.setLocalize = function(pLocalize) {
273
	this.fLocalize = pLocalize;
274
}
275

  
276
/** scImageMgr.onLoad - called by the scenari framework, inits the manager. */
277
scImageMgr.onLoad = function() {
278
	this.fPgeFra = scPaLib.findNode(scImageMgr.fPathPgeFra, this.fDisplayRoot);
279
	if (!this.fSourceRoot) this.fSourceRoot = document.body;
280
	if (!this.fDisplayRoot) this.fDisplayRoot = document.body;
281
	if (this.xMobileCheck()) document.body.classList.add("isMobile_true");
282

  
283
	// Load image galleries...
284
	this.xInitSss(this.fSourceRoot);
285
	// Load image zooms...
286
	this.xInitZms(this.fSourceRoot);
287
	// Load image animations...
288
	this.xInitAnims(this.fSourceRoot);
289
	// Load image Sliders...
290
	this.xInitSliders(this.fSourceRoot);
291
	// Load image Sequences...
292
	this.xInitSqs(this.fSourceRoot);
293
}
294

  
295
/** scImageMgr.loading. */
296
scImageMgr.loading = function() {
297
	alert(scImageMgr.xGetStr(10));
298
}
299
/** scImageMgr.sCollBlkOpen - scDynUiMgr collapsable block callback function */
300
scImageMgr.sCollBlkOpen = function(pCo) {
301
	// Reinit image animations...
302
	if (!pCo.fAnimInitDone){
303
		scImageMgr.xInitAnims(pCo);
304
		pCo.fAnimInitDone = true;
305
	}
306
}
307
/** scImageMgr.sCollBlkClose - scDynUiMgr collapsable block callback function */
308
scImageMgr.sCollBlkClose = function(pCo) {
309
}
310

  
311
/* === Global managers ====================================================== */
312
/** scImageMgr.xBtnMgr - centralized button manager */
313
scImageMgr.xBtnMgr = function(pBtn) {
314
	var vObj = pBtn.fObj;
315
	switch(pBtn.fName){
316
		case this.fTypZm+"Zm":
317
		case this.fTypSeq+"Zm":
318
			scImageMgr.xOpenZm(pBtn);break;
319
		case this.fTypZm+"BtnCls":
320
		case this.fTypZm+"BtnImgCls":
321
			scImageMgr.xClsZm(vObj);break;
322
			
323
		case this.fTypGal+"Pv":
324
			scImageMgr.xOpenSs(vObj,pBtn);break;
325
		case this.fTypGal+"BtnPrv":
326
			if (scImageMgr.fCurrItem.fSsAutoPly) scImageMgr.xPseSs(vObj);
327
			scImageMgr.xPrvSs(vObj);break;
328
		case this.fTypGal+"BtnNxt":
329
			if (scImageMgr.fCurrItem.fSsAutoPly) scImageMgr.xPseSs(vObj);
330
			scImageMgr.xNxtSs(vObj);break;
331
		case this.fTypGal+"BtnCls":
332
			scImageMgr.xClsSs(vObj);break;
333
		case this.fTypGal+"BtnPly":
334
			scImageMgr.xPlySs(vObj);break;
335
		case this.fTypGal+"BtnPse":
336
			scImageMgr.xPseSs(vObj);break;
337
			
338
		case this.fTypAnm+"BtnPrv":
339
			scImageMgr.xAnimCtrlOn(vObj);
340
			if (vObj.fAutoPly) scImageMgr.xPseAnm(vObj);
341
			scImageMgr.xPrvAnm(vObj);break;
342
		case this.fTypAnm+"BtnNxt":
343
			scImageMgr.xAnimCtrlOn(vObj);
344
			if (vObj.fAutoPly) scImageMgr.xPseAnm(vObj);
345
			scImageMgr.xNxtAnm(vObj);break;
346
		case this.fTypAnm+"BtnSrt":
347
			scImageMgr.xAnimCtrlOn(vObj);
348
			if (vObj.fAutoPly) scImageMgr.xPseAnm(vObj);
349
			scImageMgr.xSrtAnm(vObj);break;
350
		case this.fTypAnm+"BtnEnd":
351
			scImageMgr.xAnimCtrlOn(vObj);
352
			if (vObj.fAutoPly) scImageMgr.xPseAnm(vObj);
353
			scImageMgr.xEndAnm(vObj);break;
354
		case this.fTypAnm+"BtnPly":
355
		case this.fTypAnm+"BtnInitPly":
356
			scImageMgr.xAnimCtrlOn(vObj);
357
			scImageMgr.xPlyAnm(vObj);break;
358
		case this.fTypAnm+"BtnPse":
359
			scImageMgr.xAnimCtrlOn(vObj);
360
			scImageMgr.xPseAnm(vObj);break;
361
		case this.fTypAnm+"BtnSpdDwn":
362
			scImageMgr.xAnimCtrlOn(vObj);
363
			scImageMgr.xSetAnmSpd(vObj,+200);break;
364
		case this.fTypAnm+"BtnSpdUp":
365
			scImageMgr.xAnimCtrlOn(vObj);
366
			scImageMgr.xSetAnmSpd(vObj,-200);break;
367
		case this.fTypAnm+"BtnLp":
368
			scImageMgr.xAnimCtrlOn(vObj);
369
			scImageMgr.xSetAnmLp(vObj,pBtn.checked);return true;
370
		case this.fTypSlider+"BtnPause":
371
			scImageMgr.xPauseSlider(vObj);break;
372
		case this.fTypSlider+"BtnPlay":
373
			scImageMgr.xPlaySlider(vObj);break;
374
		case this.fTypSlider+"BtnPrv":
375
			scImageMgr.xSliderPrv(vObj);break;
376
		case this.fTypSlider+"BtnNxt":
377
			scImageMgr.xSliderNxt(vObj);break;
378
		case this.fTypSeq+"BtnPause":
379
			scImageMgr.xPauseSeq(vObj);break;
380
		case this.fTypSeq+"BtnPlay":
381
			scImageMgr.xPlaySeq(vObj);break;
382
		case this.fTypSeq+"BtnPrv":
383
			scImageMgr.xSeqPrv(vObj);break;
384
		case this.fTypSeq+"BtnNxt":
385
			scImageMgr.xSeqNxt(vObj);break;
386
	}
387
	return false;
388
}
389
/** scImageMgr.xKeyMgr - centralized keyboard manager */
390
scImageMgr.xKeyMgr = function(pEvent){
391
	var vEvent = pEvent || window.event;
392
	var vCharCode = vEvent.which || vEvent.keyCode;
393
	if (!scImageMgr.fCurrItem) return;
394
	switch(vCharCode){
395
		case 34://pg_dwn
396
		case 39://left
397
			if (scImageMgr.fCurrItem.fName == "gal") {
398
				if (scImageMgr.fCurrItem.fSsAutoPly) scImageMgr.xPseSs(scImageMgr.fCurrItem);
399
				scImageMgr.xNxtSs(scImageMgr.fCurrItem);
400
			}
401
			return false;
402
		case 8://bksp
403
		case 33://pg_up
404
		case 37://right
405
			if (scImageMgr.fCurrItem.fName == "gal") {
406
				if (scImageMgr.fCurrItem.fSsAutoPly) scImageMgr.xPseSs(scImageMgr.fCurrItem);
407
				scImageMgr.xPrvSs(scImageMgr.fCurrItem);
408
			}
409
			return false;
410
		case 27://escape
411
			if (scImageMgr.fCurrItem.fName == "gal") {
412
				scImageMgr.xClsSs(scImageMgr.fCurrItem);
413
			} else {
414
				scImageMgr.xClsZm(scImageMgr.fCurrItem);
415
			}
416
			return false;
417
		case 80:// p
418
			if (scImageMgr.fCurrItem.fName == "gal") {
419
				if(scImageMgr.fCurrItem.fSsAutoPly) scImageMgr.xPseSs(scImageMgr.fCurrItem);
420
				else scImageMgr.xPlySs(scImageMgr.fCurrItem);
421
			}
422
			return false;
423
	}
424
}
425
/* === Image size manager =================================================== */
426
scImageMgr.xInitImgs = function(pCo) {
427
	for(var i=0; i<this.fPathImg.length; i++) {
428
		var vImgs = scPaLib.findNodes(this.fPathImg[i].fPath, pCo);
429
		for(var j=0; j<vImgs.length; j++) this.xInitImg(vImgs[j]);
430
	}
431
}
432
scImageMgr.xInitImg = function(pImg) {
433
	pImg.fWidth = pImg.width;
434
	pImg.setAttribute("width", "");
435
	pImg.setAttribute("height", "");
436
	pImg.style.width = "100%";
437
	pImg.style.maxWidth = pImg.fWidth+"px";
438
	pImg.style.height = "auto";
439
	pImg.fIsAdapted = true;
440
	
441
/*	if (pImg.width>this.fMaxDeviceWidth){
442
		pImg.fIsAdapted = true;
443
	}*/
444
}
445
/* === SVG manager ========================================================== */
446
scImageMgr.xInitSvgs = function(pCo) {
447
	for(var i=0; i<this.fPathSvg.length; i++) {
448
		var vSvgs = scPaLib.findNodes(this.fPathSvg[i].fPath, pCo);
449
		for(var j=0; j<vSvgs.length; j++) this.xInitSvg(vSvgs[j]);
450
	}
451
}
452
scImageMgr.xInitSvg = function(pSvg) {
453
	if (!pSvg.getAttribute("viewBox")) pSvg.setAttribute("viewBox", "0 0 " + pSvg.width.baseVal.value + " " + pSvg.height.baseVal.value);
454
}
455
/* === Animation manager ==================================================== */
456
scImageMgr.xInitAnims = function(pCo) {
457
	for(var i=0; i<this.fPathAnim.length; i++) {
458
		var vAnims = scPaLib.findNodes(this.fPathAnim[i].fPath, pCo);
459
		for(var j=0; j<vAnims.length; j++) this.xInitAnim(vAnims[j],this.fPathAnim[i].fOpts,this.fTypAnm+i+j);
460
	}
461
}
462
scImageMgr.xInitAnim = function(pAnim,pOpts,pId) {
463
	try {
464
		if (this.xIsVisible(pAnim)){
465
			pAnim.fImgs = scPaLib.findNodes("chi:",pAnim);
466
			pAnim.fOpts = pOpts;
467
			var vMaxHeight = 0;
468
			var vMaxWidth = 0;
469
			for(var i=0; i<pAnim.fImgs.length; i++) {
470
				var vImg = pAnim.fImgs[i];
471
				vImg.style.position = "absolute";
472
				vImg.fHeight = vImg.clientHeight;
473
				vImg.fWidth = scPaLib.findNode("des:img",vImg).width;
474
				vMaxHeight = Math.max(vMaxHeight,vImg.fHeight);
475
				vMaxWidth = Math.max(vMaxWidth,vImg.fWidth);
476
				vImg.style.visibility = "hidden";
477
				vImg.style.top = "0";
478
				vImg.style.left = "0";
479
				vImg.style.width = "100%";
480
			}
481
			pAnim.style.height = vMaxHeight+0.01*vMaxHeight + "px";
482
			pAnim.style.width = vMaxWidth+0.01*vMaxWidth + "px";
483
			for(var i=0; i<pAnim.fImgs.length; i++) {
484
				var vImg = pAnim.fImgs[i];
485
				vImg.style.marginTop = (vMaxHeight - vImg.fHeight)/2 + "px";
486
			}
487
			if (!pOpts.auto && pOpts.toolbar<2) {
488
				pAnim.fBtnInitPly = scImageMgr.xAddBtn(pAnim,pAnim,this.fTypAnm,"BtnInitPly",scImageMgr.xGetStr(16),scImageMgr.xGetStr(17));
489
			}
490
			if (pOpts.toolbar > 0){
491
				if(pOpts.toolbar == 1) pAnim.fCtrl = scDynUiMgr.addElement("div",pAnim,pOpts.clsPre + "Ctrl");
492
				else pAnim.fCtrl = scDynUiMgr.addElement("div",pAnim.parentNode,pOpts.clsPre + "Ctrl",pAnim.nextSibling);
493
				if (pOpts.extBtns) {
494
					pAnim.fBtnSrt = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnSrt",scImageMgr.xGetStr(20),scImageMgr.xGetStr(21));
495
					scImageMgr.xAddSep(pAnim.fCtrl);
496
				}
497
				pAnim.fBtnPrv = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnPrv",scImageMgr.xGetStr(12),scImageMgr.xGetStr(13));
498
				scImageMgr.xAddSep(pAnim.fCtrl);
499
				pAnim.fBtnPly = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnPly",scImageMgr.xGetStr(16),scImageMgr.xGetStr(17));
500
				pAnim.fBtnPly.style.display = (pOpts.auto ? "none" : "");
501
				pAnim.fBtnPse = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnPse",scImageMgr.xGetStr(18),scImageMgr.xGetStr(19));
502
				pAnim.fBtnPse.style.display = (pOpts.auto ? "" : "none");
503
				scImageMgr.xAddSep(pAnim.fCtrl);
504
				pAnim.fBtnNxt = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnNxt",scImageMgr.xGetStr(14),scImageMgr.xGetStr(15));
505
				if (pOpts.extBtns) {
506
					scImageMgr.xAddSep(pAnim.fCtrl);
507
					pAnim.fBtnEnd = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnEnd",scImageMgr.xGetStr(22),scImageMgr.xGetStr(23));
508
				}
509
				if (pOpts.spdBtns) {
510
					scImageMgr.xAddSep(pAnim.fCtrl);
511
					pAnim.fBtnSpdDwn = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnSpdDwn","-",scImageMgr.xGetStr(25));
512
					scDynUiMgr.addElement("span",pAnim.fCtrl,pOpts.clsPre + "Spd").innerHTML = " "+scImageMgr.xGetStr(24)+" ";
513
					pAnim.fBtnSpdUp = scImageMgr.xAddBtn(pAnim.fCtrl,pAnim,this.fTypAnm,"BtnSpdUp","+",scImageMgr.xGetStr(25));
514
				}
515
				if (pOpts.lpBtn) {
516
					scImageMgr.xAddSep(pAnim.fCtrl);
517
					pAnim.fBtnLp = scDynUiMgr.addElement("input",pAnim.fCtrl,pOpts.clsPre + "BtnLp");
518
					pAnim.fBtnLp.setAttribute("type","checkbox");
519
					pAnim.fBtnLp.fName = this.fTypAnm + "BtnLp";
520
					pAnim.fBtnLp.setAttribute("id",pId);
521
					pAnim.fBtnLp.setAttribute("title",scImageMgr.xGetStr(29));
522
					if (pOpts.loop){
523
						var vAttChk = document.createAttribute("checked"); // For IE the attr checked must be created
524
						vAttChk.nodeValue = "true";
525
						pAnim.fBtnLp.setAttributeNode(vAttChk);
526
					}
527
					pAnim.fBtnLp.fObj = pAnim;
528
					pAnim.fBtnLp.onclick = function(){return scImageMgr.xBtnMgr(this);}
529
					var vLblLp = scDynUiMgr.addElement("label",pAnim.fCtrl,pOpts.clsPre + "LpLbl");
530
					vLblLp.innerHTML = scImageMgr.xGetStr(28);
531
					vLblLp.setAttribute("for",pId);
532
					vLblLp.setAttribute("title",scImageMgr.xGetStr(29));
533
				}
534
				if (pOpts.counter) {
535
					scImageMgr.xAddSep(pAnim.fCtrl);
536
					scDynUiMgr.addElement("span",pAnim.fCtrl,pOpts.clsPre + "CtrLbl").innerHTML = scImageMgr.xGetStr(26) + " ";
537
					pAnim.fCtrIdx = scDynUiMgr.addElement("span",pAnim.fCtrl,pOpts.clsPre + "CtrIdx");
538
					pAnim.fCtrIdx.innerHTML = "1";
539
					scDynUiMgr.addElement("span",pAnim.fCtrl,pOpts.clsPre + "CtrSep").innerHTML = "/";
540
					scDynUiMgr.addElement("span",pAnim.fCtrl,pOpts.clsPre + "CtrCnt").innerHTML = pAnim.fImgs.length;
541
				}
542
				if (pOpts.toolbar == 1) {
543
					pAnim.onmouseover = function () {scImageMgr.xAnimCtrlOn(pAnim);}
544
					pAnim.fCtrl.style.visibility = "hidden";
545
					pAnim.fCtrl.fOn = false;
546
				}
547
			}
548
			pAnim.fImgs[0].style.visibility = "";
549
			pAnim.fCurrImgIdx = 0;
550
			pAnim.fStep = pOpts.speed;
551
			pAnim.fAutoPly = pOpts.auto;
552
			pAnim.fSoft = pOpts.soft;
553
			pAnim.fLoop = pOpts.loop;
554
			if (pAnim.fAutoPly && pAnim.fImgs.length > 1) pAnim.fNxtImgProc = window.setTimeout(function(){scImageMgr.xAutoAnim(pAnim)}, pAnim.fStep);
555
			//Reinit zooms under pAnim
556
			this.xInitZms(pAnim);
557
		}
558
	} catch(e){
559
		scCoLib.log("scImageMgr.xInitAnim::Error : "+e);
560
	}
561
}
562
scImageMgr.xAutoAnim = function(pAnim) {
563
	if (pAnim && pAnim.fAutoPly){
564
		if (!pAnim.fLoop && pAnim.fCurrImgIdx == pAnim.fImgs.length - 1) {
565
			scImageMgr.xPseAnm(pAnim);
566
		} else {
567
			scImageMgr.xNxtAnm(pAnim);
568
			pAnim.fNxtImgProc = window.setTimeout(function(){scImageMgr.xAutoAnim(pAnim)}, pAnim.fStep);
569
		}
570
	}
571
}
572
scImageMgr.xAnimCtrlOn = function(pAnim) {
573
	if (!pAnim.fCtrl || typeof pAnim.fCtrl.fOn == "undefined") return;
574
	if (pAnim.fOffProc) window.clearTimeout(pAnim.fOffProc);
575
	if (!pAnim.fCtrl.fOn){
576
		new scImageMgr.FadeEltTask(pAnim.fCtrl, 1);
577
		pAnim.fCtrl.fOn = true;
578
	}
579
	pAnim.fOffProc = window.setTimeout(function(){scImageMgr.xAnimCtrlOff(pAnim)}, 3000);
580
}
581
scImageMgr.xAnimCtrlOff = function(pAnim) {
582
	if (pAnim.fCtrl.fOn){
583
		new scImageMgr.FadeEltTask(pAnim.fCtrl, 0);
584
		pAnim.fCtrl.fOn = false;
585
		pAnim.fOffProc = null;
586
	}
587
}
588
scImageMgr.xSrtAnm = function(pAnim) {
589
	new scImageMgr.switchAnimTask(pAnim, 0);
590
}
591
scImageMgr.xEndAnm = function(pAnim) {
592
	new scImageMgr.switchAnimTask(pAnim, pAnim.fImgs.length - 1);
593
}
594
scImageMgr.xPrvAnm = function(pAnim) {
595
	new scImageMgr.switchAnimTask(pAnim, pAnim.fCurrImgIdx == 0 ? pAnim.fImgs.length - 1 : pAnim.fCurrImgIdx - 1);
596
}
597
scImageMgr.xNxtAnm = function(pAnim) {
598
	new scImageMgr.switchAnimTask(pAnim, pAnim.fCurrImgIdx < pAnim.fImgs.length - 1 ? pAnim.fCurrImgIdx + 1 : 0);
599
}
600
scImageMgr.xPlyAnm = function(pAnim) {
601
	pAnim.fAutoPly = true;
602
	pAnim.fBtnPly.style.display="none";
603
	pAnim.fBtnPse.style.display="";
604
	scImageMgr.xNxtAnm(pAnim);
605
	pAnim.fNxtImgProc = window.setTimeout(function(){scImageMgr.xAutoAnim(pAnim)}, pAnim.fStep);
606
}
607
scImageMgr.xPseAnm = function(pAnim) {
608
	pAnim.fAutoPly = false;
609
	pAnim.fBtnPly.style.display="";
610
	pAnim.fBtnPse.style.display="none";
611
	window.clearTimeout(pAnim.fNxtImgProc);
612
}
613
scImageMgr.xSetAnmSpd = function(pAnim,pDelta) {
614
	pAnim.fStep += pDelta;
615
	pAnim.fStep = Math.min(Math.max(pAnim.fStep,scImageMgr.fMinStep),scImageMgr.fMaxStep);
616
}
617
scImageMgr.xSetAnmLp = function(pAnim,pLp) {
618
	pAnim.fLoop = pLp;
619
}
620
scImageMgr.switchAnimTask = function(pAnim,pNewIdx){
621
	this.fIdx = -1;
622
	this.fRateOld = [.9, .8, .7, .6, .5, .4, .3, .2, .1];
623
	this.fRateNew = [.1, .2, .3, .4, .5, .6, .7, .8, .9];
624
	try{
625
		if (pAnim.fBtnInitPly) pAnim.fBtnInitPly.style.display="none";
626
		this.fAnim = pAnim;
627
		if (this.fIsRunning) this.terminate();
628
		this.fNewIdx = pNewIdx;
629
		this.fOldImg = this.fAnim.fImgs[this.fAnim.fCurrImgIdx];
630
		this.fNewImg = this.fAnim.fImgs[this.fNewIdx];
631
		scImageMgr.xStartOpacityEffect(this.fOldImg, 1);
632
		scImageMgr.xStartOpacityEffect(this.fNewImg, 0);
633
		if (!this.fAnim.fSoft) {
634
			this.terminate();
635
			return;
636
		}
637
		this.fEndTime = ( Date.now  ? Date.now() : new Date().getTime() ) + 100;
638
		this.fIdx = -1;
639
		this.fIsRunning = true;
640
		scTiLib.addTaskNow(this);
641
	}catch(e){scCoLib.log("ERROR scImageMgr.switchAnimTask : "+e);}
642
}
643
scImageMgr.switchAnimTask.prototype.execTask = function(){
644
	while(this.fEndTime < (Date.now ? Date.now() : new Date().getTime()) && this.fIdx < this.fRateOld.length) {
645
		this.fIdx++;
646
		this.fEndTime += 100;
647
	}
648
	this.fIdx++;
649
	this.fEndTime += 100;
650
	if(this.fIdx >= this.fRateOld.length) {
651
		scImageMgr.xEndOpacityEffect(this.fOldImg, 0);
652
		scImageMgr.xEndOpacityEffect(this.fNewImg, 1);
653
		this.fAnim.fCurrImgIdx = this.fNewIdx;
654
		if (this.fAnim.fCtrIdx) this.fAnim.fCtrIdx.innerHTML = this.fNewIdx + 1;
655
		this.fIsRunning = false;
656
		return false;
657
	}
658
	scImageMgr.xSetOpacity(this.fOldImg, this.fRateOld[this.fIdx]);
659
	scImageMgr.xSetOpacity(this.fNewImg, this.fRateNew[this.fIdx]);
660
	return true;
661
}
662
scImageMgr.switchAnimTask.prototype.terminate = function(){
663
	this.fIdx = this.fRateOld.length;
664
	this.execTask();
665
}
666

  
667
/* === Zoom manager ========================================================= */
668
scImageMgr.xInitZms = function(pCo) {
669
	for(var i=0; i<this.fPathZoom.length; i++) {
670
		var vZooms = scPaLib.findNodes(this.fPathZoom[i].fPath, pCo);
671
		for(var j=0; j<vZooms.length; j++) {
672
			var vAnc = vZooms[j];
673
			try {
674
				vAnc.fImg = scPaLib.findNode("des:img", vAnc);
675
				vAnc.fZmUri = vAnc.href;
676
				vAnc.fOpts = this.fPathZoom[i].fOpts;
677
				vAnc.fName=this.fTypZm+"Zm";
678
				vAnc.fObj=vAnc;
679
				vAnc.setAttribute("role", "button");
680
				vAnc.title = this.xGetStr(32);
681
				vAnc.onclick=function(){
682
					if (this.fImg && this.fImg.fIsAdapted && this.fImg.fWidth > window.innerWidth) {
683
							this.target = "_blank";
684
						return true;
685
					} else {
686
							this.target = "_self";
687
						return scImageMgr.xBtnMgr(this);
688
					}
689
				}
690
				vAnc.onkeydown=function(pEvent){scDynUiMgr.handleBtnKeyDwn(pEvent);}
691
				vAnc.onkeyup=function(pEvent){scDynUiMgr.handleBtnKeyUp(pEvent);}
692
			} catch(e){
693
				scCoLib.log("scImageMgr.xInitZms::Error : "+e);
694
			}
695
		}
696
	}
697
}
698
scImageMgr.xInitZm = function(pAnc) {
699
	var vOpts = pAnc.fOpts;
700
	pAnc.fImg = scPaLib.findNode("des:img", pAnc);
701
	pAnc.fCvs = scDynUiMgr.addElement("div", this.fDisplayRoot,vOpts.clsPre+"Cvs", null, {display:"none"});
702
	pAnc.fCvs.fAnc = pAnc;
703
	pAnc.fCvs.setAttribute("role", "dialog");
704
	pAnc.fCvs.onclick=function(){return scImageMgr.xClsZm(this.fAnc);}
705
	pAnc.fOver = scDynUiMgr.addElement("div", pAnc.fCvs,vOpts.clsPre+"Over");
706
	pAnc.fOver.fAnc = pAnc;
707
	pAnc.fOver.onclick=function(){return scImageMgr.xClsZm(this.fAnc);}
708
	pAnc.fFra = scDynUiMgr.addElement("div", pAnc.fCvs,vOpts.clsPre+"Fra", null, {visibility:vOpts.type == "svg" ? "" : "hidden"});
709
	pAnc.fFra.onclick=function(pEvt){
710
		var vEvt = scImageMgr.xGetEvt(pEvt);
711
		vEvt.cancelBubble = true;
712
		if (vEvt.stopPropagation) vEvt.stopPropagation();
713
	}
714
	var vCo = pAnc.fCo = scDynUiMgr.addElement("div",pAnc.fFra,vOpts.clsPre+"Co");
715
	vCo.style.position = "relative";
716
	var vImgBtn = null;
717
	var vImg = null;
718
	if (vOpts.type == "iframe"){
719
		vImg = vCo.fImg = scDynUiMgr.addElement("iframe",vCo,null);
720
		vImg.fAnc = pAnc;
721
		vCo.fOvr = scDynUiMgr.addElement("div",vCo,null);
722
		vCo.fOvr.fAnc = pAnc;
723
		vCo.fOvr.onclick=function(){return scImageMgr.xClsZm(this.fAnc);}
724
		vCo.fOvr.style.cursor = "pointer";
725
	} else if (vOpts.type == "svg"){
726
		vImg = vCo.fImg = scPaLib.findNode("des:svg", pAnc).cloneNode(true);
727
		vCo.appendChild(vImg);
728
		vImg.fAnc = pAnc;
729
		pAnc.fDefHeight = vImg.height.baseVal.value * (vOpts.svgMax==1 ? 1000 : 0);
730
		pAnc.fDefWidth = vImg.width.baseVal.value * (vOpts.svgMax==1 ? 1000 : 0);
731
		if (!vImg.getAttribute("viewBox")) vImg.setAttribute("viewBox", "0 0 " + vImg.width.baseVal.value + " " + vImg.height.baseVal.value);
732
		pAnc.fRatio = pAnc.fDefWidth/pAnc.fDefHeight;
733
		pAnc.fDeltaHeight = scImageMgr.xGetEltHeight(pAnc.fFra) - scImageMgr.xGetEltHeight(pAnc.fCo) + scCoLib.toInt(scImageMgr.xReadStyle(pAnc.fCvs,"paddingTop")) + scCoLib.toInt(scImageMgr.xReadStyle(pAnc.fCvs,"paddingBottom"));
734
		pAnc.fDeltaWidth = scImageMgr.xGetEltWidth(pAnc.fFra) - scImageMgr.xGetEltWidth(pAnc.fCo) + scCoLib.toInt(scImageMgr.xReadStyle(pAnc.fCvs,"paddingLeft")) + scCoLib.toInt(scImageMgr.xReadStyle(pAnc.fCvs,"paddingRight"));
735
	} else {
736
		var vAddMag = vOpts.mag > 0;
737
		if (!vAddMag){
738
			vImgBtn = scImageMgr.xAddBtn(vCo,pAnc,scImageMgr.fTypZm,"BtnImgCls","",this.xGetStr(31));
739
			vImgBtn.innerHTML = "";
740
			vImgBtn.style.display = "inline-block";
741
		}
742
		vImg = vCo.fImg = scDynUiMgr.addElement("img",(vAddMag ? vCo : vImgBtn),null);
743
		vImg.fAnc = pAnc;
744
//		vImg.style.cursor = "pointer";
745
		vImg.setAttribute("alt",pAnc.fImg && pAnc.fImg.alt ? pAnc.fImg.alt : "");
746
		vImg.onload = scImageMgr.sLoadZmImg;
747
		if (vAddMag){
748
			vImg.onmouseover = this.sZmMagShow;
749
			vImg.onmousemove = this.sZmImgMove;
750
			var vMag = vCo.fImg.fMag = scDynUiMgr.addElement("div", vCo, vOpts.clsPre+"Mag", null, {display:"none"});
751
			vMag.fClass = vOpts.clsPre+"Mag";
752
			vMag.fClassMax = vOpts.clsPre+"MagMax";
753
			vMag.style.position="absolute";
754
			vMag.fAnc = pAnc;
755
			vMag.style.backgroundColor = "white";
756
			vMag.style.backgroundImage = 'url("'+pAnc.fZmUri+'")';
757
			vMag.style.zIndex = "100";
758
			vMag.onmousemove = this.sZmMagMove;
759
			vMag.onmouseout = this.sZmMagHide;
760
			if (vOpts.magMax > 0) vMag.onclick = this.sZmMagClick;
761
		}
762
	}
763
	if (vOpts.toolbar == 1){
764
		pAnc.fTlb = scDynUiMgr.addElement("div",pAnc.fFra,vOpts.clsPre+"Tlb");
765
		pAnc.fClsBtn = scImageMgr.xAddBtn((this.xMobileCheck() ? pAnc.fFra : pAnc.fTlb),pAnc,scImageMgr.fTypZm,"BtnCls",this.xGetStr(30),this.xGetStr(31));
766
		if (vOpts.titlePath){
767
			var vTiSrc =scPaLib.findNode(vOpts.titlePath, pAnc);
768
			if (vTiSrc){
769
				var vTiElt = scDynUiMgr.addElement("div",pAnc.fTlb,vOpts.clsPre+"Ti");
770
				vTiElt.appendChild(vTiSrc.cloneNode(true));
771
			}
772
		}
773
	} else pAnc.fClsBtn = vImgBtn;
774
	var vResizer = {
775
		onResizedDes : function(pOwnerNode, pEvent) {},
776
		onResizedAnc : function(pOwnerNode, pEvent) {
777
			if(pEvent.phase==1) {
778
				if(scImageMgr.fCurrItem == pOwnerNode.fAnc) scImageMgr.xRedrawZm(pOwnerNode.fAnc);
779
			}
780
		}
781
	}
782
	scSiLib.addRule(vCo.fImg, vResizer);
783
}
784
scImageMgr.xOpenZm = function(pAnc) {
785
	if ("scDragMgr" in window) { // do not open the zoom if the image is in a scDragMgr label that has just been dropped.
786
		var vAncs = scPaLib.findNodes("anc:",pAnc);
787
		for(var i=0; i<vAncs.length; i++) if (vAncs[i].fGroup && vAncs[i].fGroup._isThresholdExceeded) return;
788
	}
789
	document.body.classList.add("imgLoading");
790
	if(!pAnc.fCo) scImageMgr.xInitZm(pAnc);
791
	if(this.xReadStyle(pAnc.fCvs,"position") == "absolute") window.scroll(0,0); // if position:absolute, we must scroll the SS into view.
792
	scImageMgr.fadeInTask.initTask(pAnc);
793
	scTiLib.addTaskNow(scImageMgr.fadeInTask);
794
	if(pAnc.fCo && !pAnc.fCo.fImg.src && pAnc.fOpts.type!="svg") pAnc.fCo.fImg.setAttribute("src", pAnc.fZmUri);
795
	else scImageMgr.xRedrawZm(pAnc);
796
	scImageMgr.fCurrItem = pAnc;
797
	pAnc.fKeyUpOld = document.onkeyup;
798
	document.onkeyup = scImageMgr.xKeyMgr;
799
	this.xNotifyListeners("onZoomOpen", pAnc);
800
	this.xNotifyListeners("onOverlayOpen", pAnc);
801
	this.xToggleFocusables();
802
	this.xFocus(pAnc.fClsBtn);
803
}
804
scImageMgr.xClsZm = function(pAnc) {
805
	scImageMgr.fadeOutTask.initTask(pAnc,function(){
806
		scImageMgr.xNotifyListeners("onZoomClose", pAnc);
807
		scImageMgr.xNotifyListeners("onOverlayClose", pAnc);
808
	});
809
	scTiLib.addTaskNow(scImageMgr.fadeOutTask);
810
	document.onkeyup = pAnc.fKeyUpOld;
811
	scImageMgr.fCurrItem = null;
812
	scImageMgr.xToggleFocusables();
813
	scImageMgr.xFocus(pAnc);
814
}
815
scImageMgr.sLoadZmImg = function() {
816
	var vAnc = this.fAnc;
817
	vAnc.fDefHeight = this.height;
818
	vAnc.fDefWidth = this.width;
819
	vAnc.fRatio = vAnc.fDefWidth/vAnc.fDefHeight;
820
	vAnc.fDeltaHeight = scImageMgr.xGetEltHeight(vAnc.fFra) - scImageMgr.xGetEltHeight(vAnc.fCo) + scCoLib.toInt(scImageMgr.xReadStyle(vAnc.fCvs,"paddingTop")) + scCoLib.toInt(scImageMgr.xReadStyle(vAnc.fCvs,"paddingBottom"));
821
	vAnc.fDeltaWidth = scImageMgr.xGetEltWidth(vAnc.fFra) - scImageMgr.xGetEltWidth(vAnc.fCo) + scCoLib.toInt(scImageMgr.xReadStyle(vAnc.fCvs,"paddingLeft")) + scCoLib.toInt(scImageMgr.xReadStyle(vAnc.fCvs,"paddingRight"));
822
	vAnc.fFra.style.position="absolute";
823
	scImageMgr.xRedrawZm(vAnc);
824
	vAnc.fFra.style.visibility="";
825
}
826
scImageMgr.sZmMagShow = function(pEvt) {
827
	var vEvt = scImageMgr.xGetEvt(pEvt);
828
	var vImg = vEvt.target;
829
	try {
830
		var vMag = vImg.fMag;
831
		var vAnc = vImg.fAnc
832
		if (!vMag.fEnabled) return;
833
		vMag.fAct = true;
834
		var vX = vEvt.offsetX || vEvt.layerX;
835
		var vY = vEvt.offsetY || vEvt.layerY;
836
		if (vMag.fMaxDefault) scImageMgr.xZmMagMax(vMag,true);
837
		else scImageMgr.xZmMagUpdate(vAnc, vMag, vX, vY,true);
838
		vMag.style.display = "";
839
	} catch(e){
840
		scCoLib.log("scImageMgr.sZmMagShow::Error : "+e);
841
	}
842
}
843
scImageMgr.sZmImgMove = function(pEvt) {
844
	var vEvt = scImageMgr.xGetEvt(pEvt);
845
	var vImg = vEvt.target;
846
	try {
847
		var vMag = vImg.fMag;
848
		if (!vMag.fEnabled) return;
849
		if (!vMag.fAct) scImageMgr.sZmMagShow(pEvt);
850
	} catch(e){
851
		scCoLib.log("scImageMgr.sZmImgMove::Error : "+e);
852
	}
853
}
854
scImageMgr.sZmMagHide = function(pEvt) {
855
	var vEvt = scImageMgr.xGetEvt(pEvt);
856
	var vMag = vEvt.target;
857
	try {
858
		vMag.fAct = false;
859
		scImageMgr.xZmMagMax(vMag,false);
860
		vMag.style.display = "none";
861
	} catch(e){
862
		scCoLib.log("scImageMgr.sZmMagHide::Error : "+e);
863
	}
864
}
865
scImageMgr.sZmMagMove = function(pEvt) {
866
	var vEvt = scImageMgr.xGetEvt(pEvt);
867
	var vMag = vEvt.target;
868
	var vAnc = vMag.fAnc
869
	var vX = vMag.offsetLeft + (vEvt.offsetX || vEvt.layerX);
870
	var vY = vMag.offsetTop + (vEvt.offsetY || vEvt.layerY);
871
	try {
872
		if (!vMag.fMax) {
873
			scImageMgr.xZmMagUpdate(vAnc,vMag,vX,vY,true);
874
		} else if (vMag.fMaxDefault || vAnc.fOpts.magPan == 1) {
875
			scImageMgr.xZmMagUpdate(vAnc,vMag,vX,vY,false);
876
		}
877
	} catch(e){
878
		scCoLib.log("scImageMgr.sZmMagMove::Error : "+e);
879
	}
880
}
881
scImageMgr.sZmMagClick = function(pEvt) {
882
	var vEvt = scImageMgr.xGetEvt(pEvt);
883
	var vMag = vEvt.target;
884
	if (!vMag.fMaxDefault) {
885
		scImageMgr.xZmMagMax(vMag,!vMag.fMax);
886
		if (!vMag.fMax) scImageMgr.sZmMagMove(vEvt);
887
	}
888
}
889
scImageMgr.xZmMagUpdate = function(pAnc, pMag, pX, pY, pUpdtPos) {
890
	try {
891
		var vTop = Math.round(Math.min(pAnc.fCurrHeight-pMag.fHeight, Math.max(0,pY - pMag.fHeight/2)));
892
		var vLeft = Math.round(Math.min(pAnc.fCurrWidth-pMag.fWidth, Math.max(0,pX - pMag.fWidth/2)));
893
		if (pUpdtPos) {
894
			pMag.style.left = (vLeft)+"px";
895
			pMag.style.top = (vTop)+"px";
896
		}
897
		pMag.style.backgroundPosition = Math.round(Math.min(vLeft/(pAnc.fCurrWidth-pMag.fWidth)*100,100))+"% "+Math.round(Math.min(vTop/(pAnc.fCurrHeight-pMag.fHeight)*100,100))+"%";
898
	} catch(e){
899
		scCoLib.log("scImageMgr.xZmMagUpdate::Error : "+e);
900
	}
901
}
902
scImageMgr.xZmMagMax = function(pMag, pMax) {
903
	try {
904
		var vAnc = pMag.fAnc;
905
		if (pMax){
906
			pMag.fMax = true;
907
			pMag.style.top = "0px";
908
			pMag.style.left = "0px";
909
			pMag.style.width = vAnc.fCurrWidth+"px";
910
			pMag.style.height = vAnc.fCurrHeight+"px";
911
			scImageMgr.xSwitchClass(pMag, pMag.fClass, pMag.fClassMax);
912
		} else {
913
			pMag.fMax = false;
914
			pMag.style.width = pMag.fWidth+"px";
915
			pMag.style.height = pMag.fHeight+"px";
916
			scImageMgr.xSwitchClass(pMag, pMag.fClassMax, pMag.fClass);
917
		}
918
	} catch(e){
919
		scCoLib.log("scImageMgr.xZmMagMax::Error : "+e);
920
	}
921
}
922
scImageMgr.xRedrawZm = function(pAnc) {
923
	try {
924
		if (pAnc.fOpts.type == "iframe") return;
925
		var vCoHeight = pAnc.fCvs.clientHeight - pAnc.fDeltaHeight - (scImageMgr.xMobileCheck() ? 0 : scImageMgr.fDeltaGalleryTop);
926
		var vCoWidth = pAnc.fCvs.clientWidth - pAnc.fDeltaWidth - (scImageMgr.xMobileCheck() ? 0 : scImageMgr.fDeltaGalleryLeft);
927
		if (vCoHeight == 0 || vCoWidth == 0) return;
928
		var vCoRatio = vCoWidth/vCoHeight;
929
		var vFra = pAnc.fFra;
930
		var vCo = pAnc.fCo;
931
		var vImg = vCo.fImg;
932
		var vNewHeight = 0;
933
		var vNewWidth = 0;
934
		if (pAnc.fRatio <= vCoRatio && vCoHeight < pAnc.fDefHeight) vNewHeight = vCoHeight;
935
		if (pAnc.fRatio >= vCoRatio && vCoWidth < pAnc.fDefWidth) vNewWidth = vCoWidth;
936
		vImg.style.width = (vNewWidth>0 ? scCoLib.toInt(vNewWidth)+"px" : "auto");
937
		vImg.style.height = (vNewHeight>0 ? scCoLib.toInt(vNewHeight)+"px" : "auto");
938
		var vImgHeight = pAnc.fCurrHeight = scCoLib.toInt(vNewHeight > 0 ? vNewHeight : vNewWidth > 0 ? vNewWidth/pAnc.fRatio : pAnc.fDefHeight);
939
		var vImgWidth = pAnc.fCurrWidth = scCoLib.toInt(vNewWidth > 0 ? vNewWidth : vNewHeight > 0 ? vNewHeight*pAnc.fRatio : pAnc.fDefWidth);
940
		vCo.style.width = vImgWidth+"px";
941
		vCo.style.height = vImgHeight+"px";
942
		if (pAnc.fOpts.mag){
943
			var vMag = vImg.fMag;
944
			vMag.fEnabled = vImgWidth < pAnc.fDefWidth;
945
			vMag.fWidth = scCoLib.toInt(vImgWidth * pAnc.fOpts.magScale);
946
			vMag.fHeight = scCoLib.toInt(vImgHeight * pAnc.fOpts.magScale);
947
			vMag.style.width = vMag.fWidth+"px";
948
			vMag.style.height = vMag.fHeight+"px";
949
		}
950
		vFra.style.marginTop = scCoLib.toInt((vCoHeight - vImgHeight) / 2 + (scImageMgr.xMobileCheck() ? 0 : scImageMgr.fDeltaGalleryTop) / 2) + "px";
951
		vFra.style[this.fMarginStart] = scCoLib.toInt((vCoWidth - vImgWidth) / 2 + (scImageMgr.xMobileCheck() ? 0 : scImageMgr.fDeltaGalleryLeft) / 2) + "px";
952
		document.body.classList.remove("imgLoading");
953
	} catch(e){
954
		scCoLib.log("scImageMgr.xRedrawZm::Error : "+e);
955
	}
956
}
957

  
958
/* === Slider manager =================================================== */
959
scImageMgr.xInitSliders = function(pCo) {
960
	document.body.classList.add("sliderLoading");
961
	for(var i=0; i<this.fPathSlider.length; i++) {
962
		var vSliders = scPaLib.findNodes(this.fPathSlider[i].fPath,pCo);
963
		for(var j=0; j<vSliders.length; j++) {
964
			var vSlider = vSliders[j];
965
			vSlider.fOpts = this.fPathSlider[i].fOpts;
966
			vSlider.fOrigHeight = scCoLib.toInt(this.xReadStyle(vSlider, "height"));
967
			vSlider.fSliderWidth = this.xGetEltWidth(vSlider);	
968
			vSlider.fSliderHeight = this.xGetEltHeight(vSlider);
969
			try {
970
				vSlider.fResizeTimer = 0;
971
				vSlider.fImgs = scPaLib.findNodes("des:img", vSlider);
972
				for (var k=0; k<vSlider.fImgs.length; k++) {
973
					var vImg = vSlider.fImgs[k];
974
					vImg.fNaturalWidth = Number(vImg.getAttribute("data-width"));
975
					vImg.fNaturalHeight = Number(vImg.getAttribute("data-height"));
976
					vImg.style.visibility = "hidden";
977
					vImg.fOrigWidth = vImg.fNaturalHeight > vSlider.fOrigHeight ? vImg.fNaturalWidth * (vSlider.fOrigHeight / vImg.fNaturalHeight) : vImg.fNaturalWidth;
978
					vImg.fOrigHeight = vImg.fNaturalHeight * vImg.fOrigWidth / vImg.fNaturalWidth;
979
					vImg.style.position = "absolute";
980
					this.xSliderSetImageSize(vImg, vSlider);
981
					vImg.onload = function() {
982
						this.style.top = vSlider.fMaxHeight / 2 -  this.height / 2 + "px";
983
						if (this === vSlider.fImgs[0]) scImageMgr.xRunSlider(vSlider);
984
					}
985
				}
986
				vSlider.fMaxHeight = this.xSliderGetMaxHeigth(vSlider);
987
				vSlider.style.height = vSlider.fMaxHeight + "px";
988
				var vTools = scDynUiMgr.addElement("div", vSlider, vSlider.fOpts.clsPre+"Tools", vSlider.firstChild);
989
				vSlider.fToolsOver = scDynUiMgr.addElement("div", vTools, vSlider.fOpts.clsPre+"ToolsOver");
990
				vSlider.fToolsOver.style.height = vSlider.fMaxHeight + "px";
991
				vSlider.fToolsOver.style.position = "absolute";
992
				vSlider.fToolsOver.style.top = "0";
993
				vSlider.fToolsExt = scDynUiMgr.addElement("div", vTools, vSlider.fOpts.clsPre+"ToolsOver");
994
				vSlider.fPauseBtn = scImageMgr.xAddBtn(vSlider.fToolsOver,vSlider,this.fTypSlider,"BtnPause",scImageMgr.xGetStr(18),scImageMgr.xGetStr(19));
995
				vSlider.fPauseBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
996
				vSlider.fPauseBtn.fObj = vSlider;
997
				vSlider.fPlayBtn = scImageMgr.xAddBtn(vSlider.fToolsOver,vSlider,this.fTypSlider,"BtnPlay",scImageMgr.xGetStr(16),scImageMgr.xGetStr(17));
998
				vSlider.fPlayBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
999
				vSlider.fPlayBtn.fObj = vSlider;
1000
				vSlider.fPlayBtn.style.display = "none";
1001
				if (vSlider.fImgs.length > 1) {
1002
					vSlider.fPrvBtn = scImageMgr.xAddBtn(vSlider.fToolsExt,vSlider,this.fTypSlider,"BtnPrv",scImageMgr.xGetStr(0),scImageMgr.xGetStr(1));
1003
					vSlider.fPrvBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
1004
					vSlider.fPrvBtn.fObj = vSlider;
1005
					vSlider.fPrvBtn.style.display = "none";
1006
					vSlider.fNxtBtn = scImageMgr.xAddBtn(vSlider.fToolsExt,vSlider,this.fTypSlider,"BtnNxt",scImageMgr.xGetStr(2),scImageMgr.xGetStr(3));
1007
					vSlider.fNxtBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
1008
					vSlider.fNxtBtn.fObj = vSlider;
1009
				}
1010
				vSlider.fTimer = scDynUiMgr.addElement("div", vSlider.fToolsOver, vSlider.fOpts.clsPre+"Timer");
1011
				vSlider.fTimerNb = scDynUiMgr.addElement("div", vSlider.fTimer, vSlider.fOpts.clsPre+"TimerNb");
1012
				vSlider.fTimerProgressBar = scDynUiMgr.addElement("div", vSlider.fTimer, vSlider.fOpts.clsPre+"TimerProgressBar");
1013
				vSlider.fTimerProgressBarSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1014
				vSlider.fTimerProgressBarSvg.classList.add(vSlider.fOpts.clsPre+"TimerProgressBarSvg")
1015
				vSlider.fTimerProgressBarSvg.setAttribute("width", "120");
1016
				vSlider.fTimerProgressBarSvg.setAttribute("height", "120");
1017
				vSlider.fTimerProgressBarSvg.setAttribute("viewBox", "0 0 120 120");
1018
				vSlider.fTimerProgressBarSvg.style.display = "none";
1019
				vSlider.fTimerProgressBar.appendChild(vSlider.fTimerProgressBarSvg);
1020
				vSlider.fTimerProgressBarCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
1021
				vSlider.fTimerProgressBarCircle.setAttribute("cx", "60");
1022
				vSlider.fTimerProgressBarCircle.setAttribute("cy", "60");
1023
				vSlider.fTimerProgressBarCircle.setAttribute("r", "54");
1024
				vSlider.fTimerProgressBarSvg.appendChild(vSlider.fTimerProgressBarCircle);
1025
				vSlider.fCurrentImageIndex = 0;
1026
				// On charge la première image
1027
				vSlider.fImgs[0].src = vSlider.fImgs[0].getAttribute("data-src");
1028
				var vResizer = {
1029
					onResizedDes : function(pOwnerNode, pEvent) {},
1030
					onResizedAnc : function(pOwnerNode, pEvent) {
1031
						clearTimeout(pOwnerNode.fResizeTimer);
1032
						pOwnerNode.fResizeTimer = setTimeout(function() {
1033
							pOwnerNode.classList.remove("isResized");
1034
						}, 250);
1035
						pOwnerNode.classList.add("isResized");
1036
						var vCurrentImage = pOwnerNode.fImgs[pOwnerNode.fCurrentImageIndex];
1037
						pOwnerNode.fSliderWidth = scImageMgr.xGetEltWidth(pOwnerNode);
1038
						for (var k=0; k<pOwnerNode.fImgs.length; k++) {
1039
							scImageMgr.xSliderSetImageSize(pOwnerNode.fImgs[k], pOwnerNode);
1040
						}
1041
						vCurrentImage.style.left = pOwnerNode.fSliderWidth / 2 - vCurrentImage.width / 2 + "px";
1042
						pOwnerNode.fMaxHeight = scImageMgr.xSliderGetMaxHeigth(pOwnerNode);
1043
						for (var k=0; k<pOwnerNode.fImgs.length; k++) {
1044
							var vImg = pOwnerNode.fImgs[k];
1045
							if (vImg.src) vImg.style.top = pOwnerNode.fMaxHeight / 2 -  vImg.height / 2 + "px";
1046
						}
1047
						pOwnerNode.style.height = pOwnerNode.fMaxHeight + "px";
1048
						pOwnerNode.fToolsOver.style.left = pOwnerNode.fSliderWidth / 2 - vCurrentImage.width / 2  + "px";
1049
						pOwnerNode.fToolsOver.style.width = vCurrentImage.width + "px";
1050
						pOwnerNode.fToolsOver.style.height = pOwnerNode.fMaxHeight + "px";
1051
					}
1052
				}
1053
				scSiLib.addRule(vSlider, vResizer);
1054
			} catch(e){
1055
				scCoLib.log("scImageMgr.onLoad::Slider init Error : "+e);
1056
			}
1057
		}
1058
	}
1059
}
1060

  
1061
scImageMgr.xSliderGetMaxHeigth = function(pSlider) {
1062
	return Math.max.apply(Math, pSlider.fImgs.map(function(pImg) { return pImg.height; }));
1063
}
1064

  
1065
scImageMgr.xSliderSetImageSize = function(pImg, pSlider) {
1066
	pImg.width = Math.round(pSlider.fSliderWidth < pImg.fOrigWidth ? pSlider.fSliderWidth : pImg.fNaturalHeight > pSlider.fOrigHeight ? pImg.fNaturalWidth * (pSlider.fSliderHeight / pImg.fNaturalHeight) : pImg.fOrigWidth);
1067
	pImg.height = Math.round(pImg.width * pImg.fNaturalHeight / pImg.fNaturalWidth);
1068
	pImg.style.left = pSlider.fSliderWidth + "px";
1069
}
1070

  
1071
scImageMgr.xRunSlider = function(pSlider) {
1072
	document.body.classList.remove("sliderLoading");
1073
	// On charge l'image suivante  et précédente si elles ne sont pas chargée
1074
	var vNextIndex = pSlider.fCurrentImageIndex + 1;
1075
	if (pSlider.fImgs[vNextIndex] && !pSlider.fImgs[vNextIndex].src) pSlider.fImgs[vNextIndex].src = pSlider.fImgs[vNextIndex].getAttribute("data-src");
1076
	var vPrevIndex = pSlider.fCurrentImageIndex - 1;
1077
	if (pSlider.fImgs[vPrevIndex] && !pSlider.fImgs[vPrevIndex].src) pSlider.fImgs[vPrevIndex].src = pSlider.fImgs[vPrevIndex].getAttribute("data-src");
1078
	var vLastIndex = pSlider.fImgs.length - 1;
1079
	if (!pSlider.fImgs[vLastIndex].src) pSlider.fImgs[vLastIndex].src = pSlider.fImgs[vLastIndex].getAttribute("data-src");
1080
	var vCurrentImageWidth = pSlider.fImgs[pSlider.fCurrentImageIndex].width;
1081
	pSlider.fToolsOver.style.width = vCurrentImageWidth + "px";
1082
	pSlider.fToolsOver.style.left = pSlider.fSliderWidth / 2 - vCurrentImageWidth / 2  + "px";
1083
	if (!scImageMgr.isSliderPaused) {
1084
		var vDuration = scImageMgr.fSliderImageDuration || 6000;
1085
		var vImgTime = 0;
1086
		pSlider.fImgTimeInterval = setInterval(function () {
1087
			vImgTime++
1088
			pSlider.fTimerProgressBarSvg.style.display = "";
1089
			if (vImgTime === 12) pSlider.fToolsOver.style.display = "";
1090
			if (vImgTime === 12) pSlider.fToolsExt.style.display = "";
1091
			pSlider.fTimerNb.setAttribute("data-progress", vImgTime);
1092
			pSlider.fTimerProgressBar.setAttribute("data-progress", vImgTime);
1093
			if (vImgTime === 98) pSlider.fToolsOver.style.display = "none";
1094
			if (vImgTime === 98) pSlider.fToolsExt.style.display = "none";
1095
			pSlider.fTimerProgressBarCircle.setAttribute("stroke-dasharray", (339.292 * (vImgTime/100)) + " 339.292");
1096
		}, vDuration / 100);
1097
	}
1098
	pSlider.fImgs[pSlider.fCurrentImageIndex].style.visibility = "visible";
1099
	pSlider.fImgs[pSlider.fCurrentImageIndex].style.left = pSlider.fSliderWidth < pSlider.fImgs[pSlider.fCurrentImageIndex].fOrigWidth ? 0 : pSlider.fSliderWidth / 2 - vCurrentImageWidth / 2  + "px";
1100
	if (!scImageMgr.isSliderPaused) {
1101
		pSlider.fSliderTimer = setTimeout(function() {
1102
			scImageMgr.xSliderNxt(pSlider);
1103
		}, vDuration);
1104
	}
1105
}
1106

  
1107
scImageMgr.xSliderNxt = function(pSlider) {
1108
	clearTimeout(pSlider.fSliderTimer);
1109
	clearInterval(pSlider.fImgTimeInterval);
1110
	if (pSlider.fPrevImageIndex !== undefined) {
1111
		pSlider.fImgs[pSlider.fPrevImageIndex].style.visibility = "hidden";
1112
		pSlider.fImgs[pSlider.fPrevImageIndex].style.left = pSlider.fSliderWidth  + "px";
1113
	}
1114
	pSlider.fPrevImageIndex = pSlider.fCurrentImageIndex;
1115
	if (pSlider.fCurrentImageIndex < pSlider.fImgs.length - 1) pSlider.fCurrentImageIndex++;
1116
	else pSlider.fCurrentImageIndex = 0;
1117
	if (pSlider.fImgs[pSlider.fPrevImageIndex]) pSlider.fImgs[pSlider.fPrevImageIndex].style.left = -pSlider.fImgs[pSlider.fPrevImageIndex].width + "px";
1118
	pSlider.fPrvBtn.style.display = "";
1119
	scImageMgr.xRunSlider(pSlider);
1120
}
1121

  
1122
scImageMgr.xSliderPrv = function(pSlider) {
1123
	clearTimeout(pSlider.fSliderTimer);
1124
	clearInterval(pSlider.fImgTimeInterval);
1125
	pSlider.fImgs[pSlider.fCurrentImageIndex].style.left = pSlider.fSliderWidth + "px";
1126
	if (pSlider.fCurrentImageIndex === 0) pSlider.fCurrentImageIndex = pSlider.fImgs.length - 1;
1127
	else pSlider.fCurrentImageIndex--;
1128

  
1129
	// TODO voir si possible d'avoir la fleche gauche dès le départ
1130
	// if (pSlider.fPrevImageIndex === undefined) pSlider.fImgs[pSlider.fImgs.length - 1].style.left = -pSlider.fImgs[pSlider.fImgs.length - 1].width + "px";
1131

  
1132
	pSlider.fPrevImageIndex = pSlider.fCurrentImageIndex !== 0 ? pSlider.fCurrentImageIndex - 1 : pSlider.fImgs.length - 1;	
1133
	pSlider.fImgs[pSlider.fPrevImageIndex].style.left = -pSlider.fImgs[pSlider.fPrevImageIndex].width + "px";
1134
	scImageMgr.xRunSlider(pSlider);
1135
}
1136

  
1137
scImageMgr.xPauseSlider = function(pSlider) {
1138
	scImageMgr.isSliderPaused = true;
1139
	pSlider.fPauseBtn.style.display = "none";
1140
	pSlider.fTimer.style.display = "none";
1141
	pSlider.fPlayBtn.style.display = "";
1142
	clearTimeout(pSlider.fSliderTimer);
1143
	clearInterval(pSlider.fImgTimeInterval);
1144
}
1145

  
1146
scImageMgr.xPlaySlider = function(pSlider) {
1147
	scImageMgr.isSliderPaused = false;
1148
	pSlider.fPlayBtn.style.display = "none";
1149
	pSlider.fTimer.style.display = "";
1150
	pSlider.fPauseBtn.style.display = "";
1151
	scImageMgr.xRunSlider(pSlider);
1152
}
1153

  
1154
/* === Sequence manager =================================================== */
1155
scImageMgr.xInitSqs = function(pCo) {
1156
	scImageMgr.registerListener("onZoomOpen", function(pAnc) {scImageMgr.xPauseSeq(pAnc.fObj);});
1157
	for(var i=0; i<this.fPathSeq.length; i++) {
1158
		var vSeqs = scPaLib.findNodes(this.fPathSeq[i].fPath,pCo);
1159
		for(var j=0; j<vSeqs.length; j++) {
1160
			var vSeq = vSeqs[j];
1161
			vSeq.fOpts = this.fPathSeq[i].fOpts;
1162
			try {
1163
				// Init player
1164
				vSeq.fAncs = scPaLib.findNodes("des:a.galPvLnk", vSeq);
1165
				vSeq.fToolsOver = scDynUiMgr.addElement("div", vSeq, vSeq.fOpts.clsPre+"ToolsOver");
1166
				vSeq.fToolsOver.style.position = "absolute";
1167
				vSeq.fPauseBtn = scImageMgr.xAddBtn(vSeq.fToolsOver,vSeq,this.fTypSeq,"BtnPause",scImageMgr.xGetStr(18),scImageMgr.xGetStr(19));
1168
				vSeq.fPauseBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
1169
				vSeq.fPauseBtn.fObj = vSeq;
1170
				vSeq.fPauseBtn.style.display = "none";
1171
				vSeq.fPlayBtn = scImageMgr.xAddBtn(vSeq.fToolsOver,vSeq,this.fTypSeq,"BtnPlay",scImageMgr.xGetStr(16),scImageMgr.xGetStr(17));
1172
				vSeq.fPlayBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
1173
				vSeq.fPlayBtn.fObj = vSeq;
1174
				if (vSeq.fAncs.length > 1) {
1175
					vSeq.fPrvBtn = scImageMgr.xAddBtn(vSeq.fToolsOver,vSeq,this.fTypSeq,"BtnPrv",scImageMgr.xGetStr(0),scImageMgr.xGetStr(1));
1176
					vSeq.fPrvBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
1177
					vSeq.fPrvBtn.fObj = vSeq;
1178
					// vSeq.fPrvBtn.style.display = "none";
1179
					vSeq.fNxtBtn = scImageMgr.xAddBtn(vSeq.fToolsOver,vSeq,this.fTypSeq,"BtnNxt",scImageMgr.xGetStr(2),scImageMgr.xGetStr(3));
1180
					vSeq.fNxtBtn.onclick = function(){return scImageMgr.xBtnMgr(this);}
1181
					vSeq.fNxtBtn.fObj = vSeq;
1182
				}
1183
				// Init anchors & images
1184
				for(var k=0; k<vSeq.fAncs.length; k++) {
1185
					var vAnc = vSeq.fAncs[k];
1186
					vAnc.parentNode.style.position = "absolute";
1187
					vAnc.parentNode.style.top = scImageMgr.xGetEltHeight(vSeq.fToolsOver) + "px";
1188
					vAnc.parentNode.style.opacity = 0;
1189
					vAnc.parentNode.style.transition = "opacity 1s ease-out";
1190
					vAnc.fZmUri = vAnc.href;
1191
					vAnc.href = "#";
1192
					vAnc.target = "_self";
1193
					vAnc.fName=this.fTypSeq+"Zm";
1194
					if (vAnc.title && vAnc.title.length>0) vAnc.fTitle=vAnc.title;
1195
					vAnc.onclick=function(){
1196
						if (this.fImg && this.fImg.fIsAdapted && this.fImg.fWidth > window.innerWidth) {
1197
							this.target = "_blank";
1198
							return true;
1199
						} else {
1200
							this.target = "_self";
1201
							return scImageMgr.xBtnMgr(this);
1202
						}
1203
					}
1204
					vAnc.onkeydown=function(pEvent){scDynUiMgr.handleBtnKeyDwn(pEvent);}
1205
					vAnc.onkeyup=function(pEvent){scDynUiMgr.handleBtnKeyUp(pEvent);}
1206
					vAnc.fImg = scPaLib.findNode("des:img.imgPv", vAnc);
1207
					vAnc.fObj = vSeq;
1208
					vAnc.fOpts = vSeq.fOpts;
1209
					vSeq.height = scImageMgr.xGetEltHeight(vAnc.parentNode);
1210
				}
1211
				vSeq.fAncs[0].parentNode.style.opacity = 1;
1212
				vSeq.fAncs[0].parentNode.style.visibility = "visible";
1213
				vSeq.style.height = vSeq.height + scImageMgr.xGetEltHeight(vSeq.fToolsOver) + "px";
1214
				vSeq.fCurrentImageIndex = 0;
1215
				vSeq.fName="seq";
1216
			} catch(e){
1217
				scCoLib.log("scImageMgr.onLoad::Sequence init Error : "+e);
1218
			}
1219
		}
1220
	}
1221
}
1222

  
1223
scImageMgr.xRunSeq = function(pSeq) {	
1224
	pSeq.fAncs[pSeq.fCurrentImageIndex].parentNode.style.visibility = "visible";
1225
	pSeq.fAncs[pSeq.fCurrentImageIndex].parentNode.style.opacity = 1;	
1226
	if (!scImageMgr.isSeqPaused) {
1227
		pSeq.fSeqTimer = setTimeout(function() {
1228
			scImageMgr.xSeqNxt(pSeq);
1229
		}, 3000);
1230
	}
1231
}
1232

  
1233
scImageMgr.xSeqNxt = function(pSeq) {
1234
	clearTimeout(pSeq.fSeqTimer);
1235
	pSeq.fPrevImageIndex = pSeq.fCurrentImageIndex;
1236
	if (pSeq.fCurrentImageIndex < pSeq.fAncs.length - 1) pSeq.fCurrentImageIndex++;
1237
	else pSeq.fCurrentImageIndex = 0;
1238
	if (pSeq.fAncs[pSeq.fPrevImageIndex]) {
1239
		pSeq.fAncs[pSeq.fPrevImageIndex].parentNode.style.opacity = 0;
1240
		setTimeout(function() {
1241
			pSeq.fAncs[pSeq.fPrevImageIndex].parentNode.style.visibility = "hidden";
1242
		}, 1000);
1243
	}
1244
	scImageMgr.xRunSeq(pSeq);
1245
}
1246

  
1247
scImageMgr.xSeqPrv = function(pSeq) {
1248
	clearTimeout(pSeq.fSeqTimer);
1249
	pSeq.fPrevImageIndex = pSeq.fCurrentImageIndex;
1250
	if (pSeq.fCurrentImageIndex === 0) pSeq.fCurrentImageIndex = pSeq.fAncs.length - 1;
1251
	else pSeq.fCurrentImageIndex--;
1252
	pSeq.fAncs[pSeq.fPrevImageIndex].parentNode.style.opacity = 0;
1253
	setTimeout(function() {
1254
		pSeq.fAncs[pSeq.fPrevImageIndex].parentNode.style.visibility = "hidden";
1255
	}, 1000);
1256
	scImageMgr.xRunSeq(pSeq);
1257
}
1258

  
1259
scImageMgr.xPauseSeq = function(pSeq) {
1260
	scImageMgr.isSeqPaused = true;
1261
	pSeq.fPauseBtn.style.display = "none";
1262
	pSeq.fPlayBtn.style.display = "";
1263
	clearTimeout(pSeq.fSeqTimer);
1264
}
1265

  
1266
scImageMgr.xPlaySeq = function(pSeq) {
1267
	scImageMgr.isSeqPaused = false;
1268
	pSeq.fPlayBtn.style.display = "none";
1269
	pSeq.fPauseBtn.style.display = "";
1270
	scImageMgr.xRunSeq(pSeq);
1271
}
1272

  
1273
/* === Slide-show manager =================================================== */
1274
scImageMgr.xInitSss = function(pCo) {
1275
	for(var i=0; i<this.fPathGal.length; i++) {
1276
		var vGals = scPaLib.findNodes(this.fPathGal[i].fPath,pCo);
1277
		for(var j=0; j<vGals.length; j++) {
1278
			var vGal = vGals[j];
1279
			vGal.fOpts = this.fPathGal[i].fOpts;
1280
			try {
1281
				vGal.fAncs = scPaLib.findNodes("des:a.galPvLnk", vGal);
1282
				if (vGal.getAttribute("data-mode") === "adapted") {
1283
					vGal.style.display = "block";
1284
					vGal.fImgs = scPaLib.findNodes("des:img.imgPv", vGal);
1285
					for (var k=0; k<vGal.fImgs.length; k++) {
1286
						var vImg = vGal.fImgs[k];
1287
						vImg.fPaddingWidth = scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'padding-left')) + scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'padding-right'));
1288
						vImg.fMarginWidth = scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'margin-left')) + scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'margin-right'));
1289
						vImg.fOrigWidth = scImageMgr.xGetEltWidth(vImg) - vImg.fPaddingWidth;
1290
						vImg.fPaddingHeight = scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'padding-top')) + scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'padding-bottom'));
1291
						vImg.fMarginHeight = scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'margin-top')) + scCoLib.toInt(scImageMgr.xReadStyle(vImg, 'margin-bottom'));
1292
						vImg.fOrigHeight = scImageMgr.xGetEltHeight(vImg) - vImg.fPaddingHeight;
1293
					}
1294
					scImageMgr.xResizeThumbsSs(vGal);
1295
					var vResizer = {
1296
						onResizedDes : function(pOwnerNode, pEvent) {},
1297
						onResizedAnc : function(pOwnerNode, pEvent) {
1298
							scImageMgr.xResizeThumbsSs(pOwnerNode);
1299
						}
1300
					}
1301
					scSiLib.addRule(vGal, vResizer);
1302
				}
1303
				// Init anchors & images
1304
				for(var k=0; k<vGal.fAncs.length; k++) {
1305
					var vAnc = vGal.fAncs[k];
1306
					vAnc.fSsUri = vAnc.href;
1307
					vAnc.fIdx = k;
1308
					vAnc.href = "#";
1309
					vAnc.target = "_self";
1310
					vAnc.fName=this.fTypGal+"Pv";
1311
					if (vAnc.title && vAnc.title.length>0){
1312
						vAnc.fTitle=vAnc.title;
1313
						vAnc.title = scImageMgr.xGetStr(27) + " " + vAnc.fTitle;
1314
					}
1315
					vAnc.onclick=function(){return scImageMgr.xBtnMgr(this);}
1316
					vAnc.fImg = scPaLib.findNode("des:img.imgPv", vAnc);
1317
					vAnc.fObj = vGal;
1318
				}				
1319
				// Init SlideShow elements
1320
				this.xInitSs(vGal);
1321
				vGal.fSsStep = scImageMgr.fDefaultStep;
1322
				vGal.fName="gal";
1323
			} catch(e){
1324
				scCoLib.log("scImageMgr.onLoad::Gallery init Error : "+e);
1325
			}
1326
		}
1327
	}
1328
}
1329
scImageMgr.xResizeThumbsSs = function(pGal) {
1330
	var vRatio = 0;
1331
	var vGalleryAvailableWidth = scImageMgr.xGetEltWidth(pGal) - 1;
1332
	var vMaxImgsPerRow = 0;
1333
	var vRowWidth = 0;
1334
	if (pGal.fImgs) {
1335
		for (var k=0; k<pGal.fImgs.length; k++) {
1336
			var vImg = pGal.fImgs[k];
1337
			vImg.fHeight = null
1338
			vRatio += vImg.fOrigWidth / (vImg.fOrigHeight);
1339
			vRowWidth += vImg.fOrigWidth;
1340
			vMaxImgsPerRow++;
1341
			if (vRowWidth >= vGalleryAvailableWidth) {
1342
				for(var l = k - (vMaxImgsPerRow - 1); l <= k; l++) {
1343
					var vImage = pGal.fImgs[l];
1344
					vImage.fHeight = (vGalleryAvailableWidth - (vImage.fPaddingWidth + vImage.fMarginWidth) * vMaxImgsPerRow) / vRatio;
1345
				}
1346
				vRatio = 0;
1347
				vRowWidth = 0;
1348
				vMaxImgsPerRow = 0;
1349
			}
1350
		}
1351
		for (var k=0; k<pGal.fImgs.length; k++) {
1352
			var vImg = pGal.fImgs[k];
1353
			if (vImg.fHeight) {
1354
				vImg.style.height = vImg.fHeight + "px";
1355
				vImg.style.width = "auto";
1356
			} else {
1357
				vImg.style.height = "auto";
1358
			}
1359
		}
1360
	}
1361
}
1362
scImageMgr.xInitSs = function(pAlbFra) {
1363
	var vOpts = pAlbFra.fOpts;
1364
	pAlbFra.fCvs = scDynUiMgr.addElement("div",this.fDisplayRoot,vOpts.clsPre+"Cvs", null, {display:"none"});
1365
	pAlbFra.fCvs.setAttribute("role", "dialog");
1366
	pAlbFra.fOver = scDynUiMgr.addElement("div",pAlbFra.fCvs,vOpts.clsPre+"Over");
1367
	pAlbFra.fOver.fAlbFra = pAlbFra;
1368
	pAlbFra.fOver.onclick=function(){return scImageMgr.xClsSs(this.fAlbFra);}
1369
	pAlbFra.fFraRoot = scDynUiMgr.addElement("div",pAlbFra.fCvs,vOpts.clsPre+"Fra");
1370
	pAlbFra.fSsCo = scDynUiMgr.addElement("ul",pAlbFra.fFraRoot,vOpts.clsPre+"Co");
1371
	pAlbFra.fSsImgFras = [];
1372
	for(var i=0; i<pAlbFra.fAncs.length; i++) {
1373
		pAlbFra.fSsImgFras[i] = scDynUiMgr.addElement("li",pAlbFra.fSsCo,vOpts.clsPre+"ImgFra", null, {visibility:"hidden"});
1374
		pAlbFra.fSsImgFras[i].fCo = scDynUiMgr.addElement("div",pAlbFra.fSsImgFras[i],vOpts.clsPre+"ImgCo");
1375
		pAlbFra.fSsImgFras[i].fImg = scDynUiMgr.addElement("img",pAlbFra.fSsImgFras[i].fCo,null);
1376
		pAlbFra.fSsImgFras[i].fImg.setAttribute("alt",pAlbFra.fAncs[i].fImg.alt ? pAlbFra.fAncs[i].fImg.alt : "");
1377
		pAlbFra.fAncs[i].fCvs = pAlbFra.fCvs;
1378
		pAlbFra.fSsImgFras[i].fImg.fAnc = pAlbFra.fAncs[i];
1379
		pAlbFra.fSsImgFras[i].fImg.fAnc.fFraRoot = pAlbFra.fFraRoot;
1380
		pAlbFra.fSsImgFras[i].fImg.fAnc.fFra = pAlbFra.fSsImgFras[i];
1381
		pAlbFra.fSsImgFras[i].fImg.fAnc.fCo = pAlbFra.fSsImgFras[i].fCo;
1382
		pAlbFra.fSsImgFras[i].fImg.fAnc.fOpts = vOpts;
1383
		pAlbFra.fSsImgFras[i].fImg.fAnc.fImg = pAlbFra.fSsImgFras[i].fImg;
1384
		pAlbFra.fSsImgFras[i].fImg.onload = scImageMgr.sLoadSsImg;
1385
		var vResizer = {
1386
			onResizedDes : function(pOwnerNode, pEvent) {},
1387
			onResizedAnc : function(pOwnerNode, pEvent) {
1388
				if(pEvent.phase==1) {
1389
					if(scImageMgr.fCurrItem.fCurrAnc == pOwnerNode.fAnc) {
1390
						scImageMgr.xRedrawSs(pOwnerNode.fAnc);
1391
					}
1392
				}
1393
			}
1394
		}
1395
		scSiLib.addRule(pAlbFra.fSsImgFras[i].fImg, vResizer);
1396
	}
1397
	pAlbFra.fSsTbr = scDynUiMgr.addElement("div",pAlbFra.fFraRoot,vOpts.clsPre+"Tbr");
1398
	pAlbFra.fSsTi = scDynUiMgr.addElement("div",pAlbFra.fSsTbr,vOpts.clsPre+"Ti");
1399
	pAlbFra.fSsTi.setAttribute("aria-live", "polite");
1400
	var vBtns = scDynUiMgr.addElement("div",pAlbFra.fSsTbr,vOpts.clsPre+"Btns");
1401
	scImageMgr.xAddSep(vBtns);
1402
	if (pAlbFra.fAncs.length>1){
1403
		pAlbFra.fSsBtnPrv = scImageMgr.xAddBtn(vBtns,pAlbFra,this.fTypGal,"BtnPrv",scImageMgr.xGetStr(0),scImageMgr.xGetStr(1));
1404
		scImageMgr.xAddSep(vBtns);
1405
		pAlbFra.fSsBtnPly = scImageMgr.xAddBtn(vBtns,pAlbFra,this.fTypGal,"BtnPly",scImageMgr.xGetStr(6),scImageMgr.xGetStr(7));
1406
		pAlbFra.fSsBtnPse = scImageMgr.xAddBtn(vBtns,pAlbFra,this.fTypGal,"BtnPse",scImageMgr.xGetStr(8),scImageMgr.xGetStr(9));
1407
		pAlbFra.fSsBtnPse.style.display = "none";
1408
		scImageMgr.xAddSep(vBtns);
1409
		pAlbFra.fSsBtnNxt = scImageMgr.xAddBtn(vBtns,pAlbFra,this.fTypGal,"BtnNxt",scImageMgr.xGetStr(2),scImageMgr.xGetStr(3));
1410
		scImageMgr.xAddSep(vBtns);
1411
	}
1412
	pAlbFra.fSsBtnCls = scImageMgr.xAddBtn((this.xMobileCheck() ? vBtns : pAlbFra.fCvs),pAlbFra,this.fTypGal,"BtnCls",scImageMgr.xGetStr(4),scImageMgr.xGetStr(5));
1413
	pAlbFra.fSsCount = scDynUiMgr.addElement("span",pAlbFra.fSsTbr,vOpts.clsPre+"Count")
1414
}
1415
scImageMgr.xSsStart = function(pAlbFra) {
1416
	scImageMgr.xOpenSs(pAlbFra,pAlbFra.fAncs[0]);
1417
	scImageMgr.xPlySs(pAlbFra);
1418
}
1419
scImageMgr.xOpenSs = function(pAlbFra,pAnc) {
1420
	if(this.xReadStyle(pAlbFra.fCvs,"position") == "absolute") window.scroll(0,0); // if position:absolute, we must scroll the SS into view.
1421
	document.body.classList.add("noScroll");
1422
	scImageMgr.fadeInTask.initTask(pAlbFra);
1423
	scTiLib.addTaskNow(scImageMgr.fadeInTask);
1424
	scImageMgr.xUdtSs(pAlbFra,pAnc);
1425
	scImageMgr.fCurrItem = pAlbFra;
1426
	pAlbFra.fInitAnc = pAnc;
1427
	pAlbFra.fKeyUpOld = document.onkeyup;
1428
	document.onkeyup = scImageMgr.xKeyMgr;
1429
	this.xNotifyListeners("onAnimationOpen", pAlbFra);
1430
	this.xNotifyListeners("onOverlayOpen", pAlbFra);
1431
	this.xToggleFocusables();
1432
	this.xFocus(pAlbFra.fSsBtnPly);
1433
}
1434
scImageMgr.xUdtSs = function(pAlbFra,pNewAnc) {
1435
	document.body.classList.add("imgLoading");
1436
	pAlbFra.fCurrAnc = pNewAnc;
1437
	if(!pAlbFra.fSsImgFras[pNewAnc.fIdx].fImg.src) pAlbFra.fSsImgFras[pNewAnc.fIdx].fImg.setAttribute("src", pNewAnc.fSsUri);
1438
	else scImageMgr.xRedrawSs(pNewAnc);	
1439
	var vOpts = pAlbFra.fOpts;
1440
	pAlbFra.fSsHasPrv = pNewAnc.fIdx != 0;
1441
	pAlbFra.fSsHasNxt = pNewAnc.fIdx != pAlbFra.fAncs.length - 1;
1442
	if (pAlbFra.fSsHasNxt){
1443
		pAlbFra.fNxtSsAnc = pAlbFra.fAncs[Math.min(pNewAnc.fIdx + 1,pAlbFra.fAncs.length - 1)];
1444
		if(!pAlbFra.fSsImgFras[pAlbFra.fNxtSsAnc.fIdx].fImg.src) pAlbFra.fSsImgFras[pAlbFra.fNxtSsAnc.fIdx].fImg.setAttribute("src", pAlbFra.fNxtSsAnc.fSsUri);
1445
	} else if(pAlbFra.fSsAutoPly) scImageMgr.xPseSs(pAlbFra);
1446
	if (pAlbFra.fSsHasPrv){
1447
		pAlbFra.fPrvSsAnc = pAlbFra.fAncs[Math.max(pNewAnc.fIdx - 1,0)];
1448
		if(!pAlbFra.fSsImgFras[pAlbFra.fPrvSsAnc.fIdx].fImg.src) pAlbFra.fSsImgFras[pAlbFra.fPrvSsAnc.fIdx].fImg.setAttribute("src", pAlbFra.fPrvSsAnc.fSsUri);
1449
	}
1450
	pAlbFra.fSsTi.innerHTML = (pNewAnc.fTitle ? pNewAnc.fTitle : "");
1451
	pAlbFra.fSsCount.innerHTML = (pNewAnc.fIdx+1)+"/"+pAlbFra.fAncs.length;
1452
	if (pAlbFra.fSsBtnPrv) {
1453
		scImageMgr.xSwitchClass(pAlbFra.fSsBtnPrv,(pAlbFra.fSsHasPrv?vOpts.clsPre+"BtnNoPrv":vOpts.clsPre+"BtnPrv"),(pAlbFra.fSsHasPrv?vOpts.clsPre+"BtnPrv":vOpts.clsPre+"BtnNoPrv"));
1454
		if (pAlbFra.fSsHasPrv) pAlbFra.fSsBtnPrv.removeAttribute("aria-disabled");
1455
		else pAlbFra.fSsBtnPrv.setAttribute("aria-disabled", "true");
1456
	}
1457
	if (pAlbFra.fSsBtnNxt) {
1458
		scImageMgr.xSwitchClass(pAlbFra.fSsBtnNxt,(pAlbFra.fSsHasNxt?vOpts.clsPre+"BtnNoNxt":vOpts.clsPre+"BtnNxt"),(pAlbFra.fSsHasNxt?vOpts.clsPre+"BtnNxt":vOpts.clsPre+"BtnNoNxt"));
1459
		if (pAlbFra.fSsHasNxt) pAlbFra.fSsBtnNxt.removeAttribute("aria-disabled");
1460
		else pAlbFra.fSsBtnNxt.setAttribute("aria-disabled", "true");
1461
	}
1462

  
1463
	scImageMgr.switchSsTask.initTask(pAlbFra,pNewAnc);
1464
	scTiLib.addTaskNow(scImageMgr.switchSsTask);
1465
}
1466
scImageMgr.xNxtSs = function(pAlbFra) {
1467
	if (!pAlbFra.fSsHasNxt) return false;
1468
	scImageMgr.xUdtSs(pAlbFra,pAlbFra.fNxtSsAnc);
1469
	return true;
1470
}
1471
scImageMgr.xPrvSs = function(pAlbFra) {
1472
	if (!pAlbFra.fSsHasPrv) return false;
1473
	scImageMgr.xUdtSs(pAlbFra,pAlbFra.fPrvSsAnc);
1474
	return true;
1475
}
1476
scImageMgr.xClsSs = function(pAlbFra) {
1477
	scImageMgr.fadeOutTask.initTask(pAlbFra,function(){
1478
		scImageMgr.xNotifyListeners("onAnimationClose", pAlbFra);
1479
		scImageMgr.xNotifyListeners("onOverlayClose", pAlbFra);
1480
	});
1481
	scTiLib.addTaskNow(scImageMgr.fadeOutTask);
1482
	document.onkeyup = pAlbFra.fKeyUpOld;
1483
	pAlbFra.fSsAutoPly = false;
1484
	scImageMgr.fCurrItem = null;
1485
	scImageMgr.xToggleFocusables();
1486
	scImageMgr.xFocus(pAlbFra.fInitAnc);
1487
	document.body.classList.remove("noScroll");
1488
	scImageMgr.xResizeThumbsSs(pAlbFra);
1489
}
1490
scImageMgr.xPlySs = function(pAlbFra) {
1491
	if (pAlbFra.fAncs.length<=1) return;
1492
	pAlbFra.fSsAutoPly = true;
1493
	pAlbFra.fSsBtnPly.style.display="none";
1494
	pAlbFra.fSsBtnPse.style.display="";
1495
	scImageMgr.xFocus(pAlbFra.fSsBtnPse);
1496
	if (! scImageMgr.xNxtSs(pAlbFra)) scImageMgr.xUdtSs(pAlbFra,pAlbFra.fAncs[0]);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff