PageSourceSearch

https://2000.ru/published/SC/html/scripts/js/widget_checkout.js

js 2000.ru collected 2026-10-02 05:09:18 UTC 14,495 bytes, 416 lines download raw bytes

1if(!sswgt_CartManager){
2
3var sswgt_CartManager = {
4	'prefix': 'my_',
5	'mode': 'frame',
6	'add2cart': function(objA){
7		this.shop_url = objA.getAttribute('rel');
8		sizes = getPageSize();
9		this.show(objA.href+'&widgets=1', sizes[2]*0.7, sizes[3]*0.7);
10		return false;
11	},
12	'go2cart': function(objA){
13		this.shop_url = objA.getAttribute('rel');
14		sizes = getPageSize();
15		this.show(objA.href, sizes[2]*0.7, sizes[3]*0.7);
16		return false;
17	},
18	'_show': function(width, height){
19	
20		this.hide(true);
21		hideSelectBoxes();
22		hideFlash();
23		this.div();
24		this.base();
25		
26		if(this.mode == 'frame'){
27			this.frame(this.params.url, width, height);
28		}else if(this.mode == 'layer'){
29			this.layer(this.params.layer_id, width, height);
30		}
31		
32		this.border(this.objMain);
33		this.closeButton(this.objBorder);
34		
35		var old_onresize= window.onresize;
36		window.onresize = function(){
37			
38			with(sswgt_CartManager){
39			
40				if(!(objOverlay && objDiv)){return;}
41
42				var arrayPageSize = getPageSize();
43				objOverlay.style.width = arrayPageSize[2]+'px';
44				objOverlay.style.height = arrayPageSize[3]+'px';
45				objBase.style.width = arrayPageSize[2]+'px';
46				objBase.style.height = arrayPageSize[3]+'px';
47				if(sswgt_CartManager.mode == 'frame'){
48					sswgt_CartManager.frame(null, frameWidth, frameHeight);
49				}else{ if(sswgt_CartManager.mode == 'layer'){
50					this.layer(sswgt_CartManager.params.layer_id, frameWidth, frameHeight);
51				}}
52				border(sswgt_CartManager.objMain);
53				closeButton(objBorder);
54			};
55			if(old_onresize){old_onresize();}
56		};
57		var old_onkeydown = document.onkeydown;
58		document.onkeydown = function (event){
59			
60			event = event?event:window.event;
61			if(event){
62			switch (event.keyCode ? event.keyCode : event.which ? event.which : null){
63				case 0x1B: sswgt_CartManager.hide(true);
64			}}
65			if(old_onkeydown){old_onkeydown();}
66		};
67	},
68	'showLayer': function(layer_id, width, height){
69		this.mode = 'layer';
70		this.params = {'layer_id': layer_id};
71		this._show(width, height);
72		showSelectBoxes();
73	},
74	'show': function(url, width, height){
75		this.mode = 'frame';
76		this.params = {'url': url};
77		this._show(width, height);
78	},
79	'resizeFrame': function(width, height){
80		if(width != null){this.frameWidth = width;}
81		if(height != null){this.frameHeight = height;}
82		
83		this.frame(null, this.frameWidth, this.frameHeight);
84		this.border(this.objFrame);
85		this.closeButton(this.objBorder);
86	},
87	'div': function(){
88	
89		this.objDiv = document.createElement('div');
90		setStyle(this.objDiv, 'zIndex:100; position: absolute; left:0; top: 0;');// background:url("n.gif") no-repeat; backgroundAttachment:fixed');
91		var objBody = document.getElementsByTagName("body").item(0);
92		objBody.appendChild(this.objDiv);
93		this.objDiv.style.backgroundAttachment = 'fixed';
94	},
95	'layer': function(layer_id, width, height){
96	
97		var objLayer = getLayer(layer_id);
98		setStyle(objLayer,'visibility:hidden; display: block');
99		if(!width){width = objLayer.offsetWidth;}
100		if(!height){height = objLayer.offsetHeight;}
101
102		this.frameWidth = width;
103		this.frameHeight = height;
104		var page = getPageSize();
105		var left = (page[2] - width)/2;
106		if(left<0){left=0;}
107		var top = (page[3] - height)/2;
108		if(top<10){top=10;}
109		
110		this.objBase.appendChild(objLayer);
111		setStyle(objLayer, 'top:'+top+'px; left:'+left+'px; width:'+width+'px; height:'+height+'px;overflow: auto;zIndex:121; position:absolute;visibility:visible');
112		
113		this.objBase.style.visibility = 'visible';		
114		this.objMain = objLayer;
115	},
116	'frame': function(url, width, height){
117		this.frameWidth = width;
118		this.frameHeight = height;
119		var page = getPageSize();
120		var left = parseInt((page[2] - width)/2);if(left<0){left=0;}
121		var top = parseInt((page[3] - height)/2);if(top<10){top=10;}
122		var objFrame = document.getElementById(this.prefix+'frame');
123		if(!objFrame){
124
125			var objT = document.createElement('div');
126			objT.style.display = 'none';
127			objT.innerHTML = '<iframe id="'+this.prefix+'frame" frameborder="0"></iframe>';
128			this.objBase.appendChild(objT);
129			objFrame = document.getElementById(this.prefix+'frame');
130			this.objBase.appendChild(objFrame);
131			this.objBase.removeChild(objT);
132			setStyle(objFrame, 'zIndex:120; position:absolute; backgroundColor:#ffffff');
133	
134			var objLoading = document.createElement('div');
135			this.objBase.appendChild(objLoading);
136			setStyle(objLoading, 'backgroundColor:#ffffff; zIndex:121; position:absolute; padding:20px; left:'+parseInt(page[2]/2-50+20)+'px; top:'+parseInt(page[3]/2-50)+'px;visibility: visible;');
137			var objImgLoading = document.createElement('img');
138//			objImgLoading.src = this.shop_url+'published/SC/html/scripts/images_common/loading.gif';
139			objImgLoading.src = ((window.CONF_ON_WEBASYST||(this.shop_url.search('webasyst.net')!=-1))?(this.shop_url.replace(/shop\//,'')+'shop/'):(this.shop_url+'published/SC/html/scripts/'))+'images_common/loading.gif';
140			objLoading.appendChild(objImgLoading);
141	
142			setTimeout(
143					function(){
144						objFrame.src = url;
145						}
146					,100);
147			var objBase = this.objBase;
148						
149			function objFrame_onload(){
150				if(objFrame.style.visibility != 'visible'){
151					var objLoading1 = objLoading;
152					var objBase1 = objBase;
153					setTimeout(function(){
154						if(objLoading1 && objLoading1.parentNode){
155							objLoading1.parentNode.removeChild(objLoading1);
156							objLoading1 = null;
157						}
158						objBase1.style.visibility = 'visible';}, 800);
159				}
160			};
161
162			if (objFrame.addEventListener) objFrame.addEventListener("load",objFrame_onload,false);
163			else if (objFrame.attachEvent) objFrame.attachEvent("onload", objFrame_onload);
164
165			this.objFrame = objFrame;
166			this.objMain = this.objFrame;	
167		}
168		setStyle(objFrame, 'top:'+top+'px; left:'+left+'px; width:'+width+'px; height:'+height+'px');
169	},
170	'base': function(){
171
172		if(!/MSIE/.test(navigator.userAgent)){
173			var objBase = document.createElement("div");
174			objBase.style.visibility = 'hidden';
175		}else{
176			this.objDiv.innerHTML += '<div'+' id="myBase" style=\'z-index:95; position:absolute; visibility:hidden; top: expression(parseInt(document.documentElement.scrollTop || document.body.scrollTop, 10)+"px"); left: expression(parseInt(document.documentElement.scrollLeft || document.body.scrollLeft, 10)+"px");\'></div>';
177			var objBase = document.getElementById('myBase');
178		}
179		
180		setStyle(objBase, 'zIndex:95');
181		if(!/MSIE/.test(navigator.userAgent)){setStyle(objBase, 'top:0; left:0; position: fixed');}
182	
183		var arrayPageSize = getPageSize();
184		objBase.style.width = arrayPageSize[2]+'px';
185		objBase.style.height = arrayPageSize[3]+'px';
186		
187		objBase.onclick = function(ev){if(getEventObject(ev).target.id && getEventObject(ev).target.id == this.id){sswgt_CartManager.hide(true);}};
188		
189		this.objDiv.insertBefore(objBase, this.objDiv.firstChild);
190		this.objBase = objBase;
191		this.overlay();
192	},
193	'overlay':function(){
194		var objOverlay = document.getElementById(this.prefix+'overlay');
195		if(!objOverlay){
196			objOverlay = document.createElement('div');
197			objOverlay.id = this.prefix+'overlay';
198			this.objBase.appendChild(objOverlay);
199		}
200 
201		var left = 0;
202		var top = 0;
203		var width = this.objBase.offsetWidth;
204		var height = this.objBase.offsetHeight;
205		setStyle(objOverlay, 'position:absolute; visibility: visible; top:'+top+'; left:'+left+'; width:'+width+'px; height:'+height+'px; backgroundColor:#000000');
206		setOpacity(objOverlay, 0.7);
207		objOverlay.onclick = function(ev){if(getEventObject(ev).target.id && getEventObject(ev).target.id == this.id){sswgt_CartManager.hide(true);}};
208
209		this.objOverlay = objOverlay;
210	},
211	'hide': function(remove){
212		if(this.objDiv && this.objDiv.parentNode){
213			if(this.objOverlay){
214				this.objDiv.appendChild(this.objOverlay);
215			}
216			this.objDiv.style.display = "none";
217			
218			if(remove){
219				if(this.mode == 'layer'){
220					setStyle(this.objMain, 'display:none');
221					setStyle(this.objMain, 'visibility:hidden');
222					document.body.appendChild(this.objMain);
223				}
224				this.objDiv.parentNode.removeChild(this.objDiv);
225				this.objDiv = null;
226				this.objOverlay = null;
227			}
228			showSelectBoxes();
229			showFlash();
230		}
231	},
232	'closeButton': function(parentObject){
233	
234		with(this){
235			var objCloseButton = document.getElementById(prefix+'closeButton');
236			if(!objCloseButton){
237				objCloseButton = document.createElement('img');
238				objCloseButton.id = prefix+'closeButton';
239			}
240			
241			var objFrame =  this.objFrame||document.getElementById(this.prefix+'frame');
242			//TODO check it
243/*
244			var left = parentObject.offsetLeft+parentObject.offsetWidth-22;
245			var top = parentObject.offsetTop-25;
246			*/
247			if(objFrame){
248				var left = objFrame.offsetLeft+this.objFrame.offsetWidth-22;
249	            var top = objFrame.offsetTop-25;
250	           	setStyle(objCloseButton, 'position:absolute; top:'+top+'px; left:'+left+'px; cursor:hand;');//cursor:pointer; 
251				//DEBUG:
252				//alert(this.shop_url);
253				//objCloseButton.src = ((window.CONF_ON_WEBASYST||(this.shop_url.search('webasyst.net')!=-1))?(this.shop_url.replace(/shop\//,'')):(this.shop_url+'published/SC/html/scripts/'))+'images_common/close.gif';
254				objCloseButton.src = ((window.CONF_ON_WEBASYST||(this.shop_url.search('webasyst.net')!=-1))?(this.shop_url.replace(/shop\//,'')+'shop/'):(this.shop_url+'published/SC/html/scripts/'))+'images_common/close.gif';
255	//			objCloseButton.src = this.shop_url+'published/SC/html/scripts/images_common/close.gif';
256				objCloseButton.onclick = function(){sswgt_CartManager.hide(true);return false;};
257				objBase.appendChild(objCloseButton);
258			}
259		};
260	},
261	'border': function(parentObj){
262		var objBorder = document.getElementById(this.prefix+'border');
263		if(!objBorder){
264			objBorder = document.createElement('div');
265			objBorder.id = this.prefix+'border';
266			this.objBase.appendChild(objBorder);
267		}
268
269		var border_width = 0;
270		var left = parseInt(parentObj.style.left,10)-border_width;
271		var top = parseInt(parentObj.style.top,10)-border_width;
272		var width = parentObj.offsetWidth;
273		var height = parentObj.offsetHeight;
274		if(/MSIE/.test(navigator.userAgent)){
275			width += border_width*2;
276			height += border_width*2;
277		}		
278		setStyle(objBorder, 'position:absolute; top:'+top+'; left:'+left+'; width:'+width+'px; height:'+height+'px; border: '+border_width+'px solid #efefef');
279		this.objBorder = objBorder;
280	}
281};
282
283function showSelectBoxes(){
284	var selects = document.getElementsByTagName("select");
285	for (i = 0; i != selects.length; i++) {
286		selects[i].style.visibility = "visible";
287	}
288}
289
290function hideSelectBoxes(){
291	var selects = document.getElementsByTagName("select");
292	for (i = 0; i != selects.length; i++) {
293		if(!selects[i].className.match(/div_fade_select/)){
294			selects[i].style.visibility = "hidden";
295		}
296	}
297}
298
299function showFlash(){
300	var flashObjects = document.getElementsByTagName("object");
301	for (i = 0; i < flashObjects.length; i++) {
302		flashObjects[i].style.visibility = "visible";
303	}
304	var flashEmbeds = document.getElementsByTagName("embed");
305	for (i = 0; i < flashEmbeds.length; i++) {
306		flashEmbeds[i].style.visibility = "visible";
307	}
308}
309
310function hideFlash(){
311	var flashObjects = document.getElementsByTagName("object");
312	for (i = 0; i < flashObjects.length; i++) {
313		flashObjects[i].style.visibility = "hidden";
314	}
315	var flashEmbeds = document.getElementsByTagName("embed");
316	for (i = 0; i < flashEmbeds.length; i++) {
317		flashEmbeds[i].style.visibility = "hidden";
318	}
319}
320
321function getPageSize(){
322	
323	var xScroll, yScroll;
324	
325	if (window.innerHeight && window.scrollMaxY) {	
326		xScroll = window.innerWidth + window.scrollMaxX;
327		yScroll = window.innerHeight + window.scrollMaxY;
328	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
329		xScroll = document.body.scrollWidth;
330		yScroll = document.body.scrollHeight;
331	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
332		xScroll = document.body.offsetWidth;
333		yScroll = document.body.offsetHeight;
334	}
335
336	var windowWidth, windowHeight;
337	
338	if (self.innerHeight) {	// all except Explorer
339		if(document.documentElement.clientWidth){
340			windowWidth = document.documentElement.clientWidth; 
341		} else {
342			windowWidth = self.innerWidth;
343		}
344		windowHeight = self.innerHeight;
345	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
346		windowWidth = document.documentElement.clientWidth;
347		windowHeight = document.documentElement.clientHeight;
348	} else if (document.body) { // other Explorers
349		windowWidth = document.body.clientWidth;
350		windowHeight = document.body.clientHeight;
351	}	
352	
353	// for small pages with total height less then height of the viewport
354	if(yScroll < windowHeight){
355		pageHeight = windowHeight;
356	} else { 
357		pageHeight = yScroll;
358	}
359
360	// for small pages with total width less then width of the viewport
361	if(xScroll < windowWidth){	
362		pageWidth = xScroll;		
363	} else {
364		pageWidth = windowWidth;
365	}
366
367	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
368	return arrayPageSize;
369}
370
371function setOpacity(element, value){  
372	
373  if (value == 1){
374  	element.style.opacity = (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : null;
375    if(/MSIE/.test(navigator.userAgent)){  
376      element.style.filter = element.style.filter.replace(/alpha\([^\)]*\)/gi, '');
377     }  
378  } else {  
379    if(value < 0.00001){ value = 0;}  
380  	element.style.opacity = value;
381    if(/MSIE/.test(navigator.userAgent)){  
382      element.style.filter = element.style.filter.replace(/alpha\([^\)]*\)/gi, '')+ 'alpha(opacity='+value*100+')';
383    }  
384  }   
385}
386
387function setStyle(obj, style_str){
388
389	var styles = style_str.split(";");
390	with(obj){
391		for(var k=styles.length-1; k>=0; k--){
392			var _style = styles[k].split(':', 2);
393			if(!_style[1]){continue;}
394			_style[0] = _style[0].replace(/^\s|\s$/, '');
395			_style[1] = _style[1].replace(/^\s|\s$/, '');
396			style[_style[0]] = _style[1];
397		}
398	};
399}
400
401function getEventObject(ev){
402	
403	var my_ev = {};
404	ev = ev?ev:window.event;
405	if(ev.srcElement){
406		my_ev.target = ev.srcElement;
407	}else{
408		my_ev.target = ev.target;
409	}
410	
411	my_ev.ev = ev;
412	return my_ev;
413}
414
415
416}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.