PageSourceSearch

https://photowebexpo.ru/tpl/js/main.js?v=28

js photowebexpo.ru collected 2026-10-02 11:41:54 UTC 16,289 bytes, 691 lines download raw bytes

1var app = window.app || {};
2window.lazyLoadInstance = new LazyLoad({});
3
4(function($) {
5
6	app.filterBlock = (function() {
7
8		var __init = function() {
9
10			$(document).on('click', '.filter__title', _toggle);
11		};
12
13		var _toggle = function() {
14
15			if (this.getAttribute('data-process')) {
16				return;
17			}
18
19			var _this = this,
20				$filter = $(this).closest('.filter');
21
22			this.setAttribute('data-process', true);
23
24			var closed = $filter.attr('data-opened') && ['0','false'].includes($filter.attr('data-opened'));
25			$filter.attr('data-opened', closed);
26			setTimeout(function() {_this.removeAttribute('data-process')}, 250);
27		};
28
29		__init();
30	})();
31
32	app.contentPhotos = (function() {
33
34		var $container = $('[itemprop="articleBody"]'),
35			$photos = $container.find('img');
36
37		var __init = function() {
38
39			$photos.each(_initZoom);
40			$container.find('td img').each(_setTablePhotoSize);
41		};	
42
43		var _setTablePhotoSize = function(i, image) {
44
45			if (image.getAttribute('width')) {
46				image.style.width = image.getAttribute('width') + 'px';
47			}
48		};
49
50		var _initZoom = function() {
51
52			if (this.offsetParent === null) {
53				return;
54			};
55
56			var $this = $(this);
57
58			if ($this.closest('a').length > 0) {
59				return;
60			}
61
62			$this.wrap(function() {
63				return '<a href="'+ this.src +'" class="zoom '+ this.classList.value +'" title="'+ (this.alt || this.title) +'" />';
64			});
65		};
66
67		!($photos.length > 0) || __init();
68		window.lazyLoadInstance = new LazyLoad({});
69	})();
70
71
72	app.linePhotos = (function() {
73
74		var lines = '.linePhotos';
75
76		var __init = function() {
77
78			$(lines).each(_initSlider);
79			$(lines).each(_uniqueGallery);
80		};	
81
82		var _initSlider = function() {
83
84			var $this = $(this);
85
86			if ($this.find('.zoom').length < 6) {
87				return;
88			};
89
90			var $photos = '<div class="linePhotos glider-contain"><div class="linePhotos__wrap"><div class="linePhotos__photos glider">';
91			$photos += $this[0].innerHTML +'</div>';
92			$photos += '<button role="button" aria-label="Prev" class="linePhotos__arrow linePhotos__arrow_prev glider-prev"></button>';
93			$photos += '<button role="button" aria-label="Next" class="linePhotos__arrow linePhotos__arrow_next glider-next"></button>';
94			$photos += '<div class="linePhotos__dots dots" role="tablist"></div>';
95			$photos += '</div></div>';
96
97			$this.after($photos);
98			var $insert = $this.next('.linePhotos');
99			$this.remove();
100
101			var glider = new Glider($insert.find('.linePhotos__photos')[0], {
102                slidesToShow: 5,
103				slidesToScroll: 5,
104				draggable: true,
105				dots: $insert.find('.linePhotos__dots')[0],
106				arrows: {
107					prev: $insert.find('.linePhotos__arrow_prev')[0],
108					next: $insert.find('.linePhotos__arrow_next')[0]
109				}
110			});
111			window.lazyLoadInstance = new LazyLoad({});
112		};
113
114		var _uniqueGallery = function() {
115
116			var id = 'gallery' + makeid(10),
117				photos = this.querySelectorAll('.zoom');
118				
119			for (var i = 0; i < photos.length; i++) {
120				photos[i].rel = id;
121			};
122
123			if (photos.length < 6) {
124				this.setAttribute('data-static', true);
125			}
126			window.lazyLoadInstance = new LazyLoad({});
127		};
128
129		function makeid(length) {
130		   var result           = '';
131		   var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
132		   var charactersLength = characters.length;
133		   for ( var i = 0; i < length; i++ ) {
134		      result += characters.charAt(Math.floor(Math.random() * charactersLength));
135		   }
136		   return result;
137		}
138
139		!($(lines).length > 0) || __init();
140	})();
141
142	app.inputMask = (function() {
143
144
145		var init = function() {
146
147			Inputmask().mask(document.querySelectorAll("input"));
148		};
149
150
151		init();
152	})();
153
154	app.grid= (function(){
155		var $grid=$('.grid');
156
157		var init = function(){
158			console.log('asdads');
159			_checkBanners();
160		};
161
162		var _checkBanners = function(){
163			var tpl,$insert;
164
165			$grid.find('.grid__insert')
166				.each(function(){
167					tpl = this.innerHTML;
168					$insert = $(tpl).hide()
169						.insertAfter(
170							$grid.find('.grid__cell').eq(this.getAttribute('data-after')||3)
171						);
172
173					$insert.slideDown();
174					$(this).remove();
175				});
176		};
177
178		!$grid.length||init();
179	})();
180
181
182	app.calendar = (function() {
183
184		var $calendar = $('.ui-calendar'),
185			$inputs = $('[data-calendar-input]');
186
187		var __init = function() {
188
189			$calendar.each(initOne);
190			$inputs.each(initOneInputCalendar);
191		};
192
193
194		var initOneInputCalendar = function() {
195
196			var $this = $(this),
197				type = this.getAttribute('data-calendar-input') || 'date';
198
199			$this.datepicker({
200
201			});
202		};
203
204
205		var initOne = function() {
206
207			var $this = $(this),
208				activeDates = JSON.parse($this.attr('data-dates')) || [];
209
210			$this.datepicker({
211				dateFormat: "dd.mm.yy",
212				beforeShowDay: function(date) {
213					var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
214	                if (activeDates[format(d)+'.'+format(m+1)+'.'+y]) {
215	                	var future = activeDates[format(d)+'.'+format(m+1)+'.'+y]['future'] ? '' : ' in-past';
216	                	console.log(future);
217	                    return [true, 'ui-state-active' + future, ''];
218	                }
219		            return [true];
220				},
221				onSelect: function(selectedDate,v) {
222					window.location = '/affiche?date='+selectedDate;
223				}
224			});
225		};
226
227		var format = function(value) {
228			return (value > 9 ? value : ('0'+value));
229		}
230
231		!$calendar.length || __init();
232	})();
233
234
235	app.uploads = (function() {
236
237		var init = function() {
238
239			$(document).on('change', '.uploads__input', _upload)
240						.on('click', '.uploads__error', _remove)
241						.on('click', '.upload__item', _remove)
242						.on('click', '.uploads__preview-remove', _removePreview);
243		};
244
245
246		var load = function(data, callback, error_callback) {
247
248			var xhr = new XMLHttpRequest(),
249				file = data.file || false,
250				url = data.url || false;
251
252			if (!window.File 
253				|| !window.FileList 
254				|| !window.FileReader 
255				|| !xhr
256				|| !file
257				|| !url)
258				return false;
259
260
261			// file received/failed
262			xhr.onreadystatechange = function(e) {
263				if (xhr.readyState == 4)
264					if (xhr.status === 200) {
265						if (typeof callback === 'function') {
266							return callback(xhr.response ? JSON.parse(xhr.response) : {}, file);
267						}
268					} else {
269						return (typeof error_callback == 'function' ? error_callback(xhr.response) : xhr);
270					}
271						
272							
273			};
274
275			// start upload
276			xhr.open("put", url, true);
277			xhr.setRequestHeader("Content-Type", "multipart/form-data");
278			xhr.setRequestHeader("X-File-Name", encodeURIComponent(file.name));
279			xhr.setRequestHeader("X-File-Size", file.size);
280			xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
281			xhr.setRequestHeader("Cache-Control", "no-cache");
282			xhr.send(file);
283		};
284
285
286		var _upload = function(e) {
287
288			var $this = $(e.target),
289				files = $this[0].files || {},
290				$block = $this.closest('.uploads'),
291				maxsize = parseInt($block.data('maxsize') || 999999999);
292
293			$block.find('.uploads__error').remove();
294
295			for (var i = 0; i < files.length; i++) {
296
297				var file = files[i],
298					imageType = /image.*/;
299
300				if(!file.type.match(imageType))
301					_showError($block, 'type', file);
302				else if (file.size > maxsize)
303					_showError($block, 'size', file);
304				else
305					_uploadOne($block, file);
306			};
307		};
308
309		var _remove = function(e) {
310
311			e.stopPropagation();
312
313			var $this = $(e.target),
314				$block = $this.closest('.uploads');
315			$this.remove();
316
317			//кидаем триггер, только в случае удаления загруженного файла
318			//if ($this.is(this._getElemClass('item')))
319			_checkCount($block);
320			$this.closest('.uploads').trigger('uploads:change', null, {
321				'action' : 'remove'
322			});
323		};
324
325
326		var _removePreview = function(e) {
327
328			e.stopPropagation();
329
330			var $this = $(e.target),
331				$block = $this.closest('.uploads');
332			$this.closest('.uploads__preview').remove();
333
334			//кидаем триггер, только в случае удаления загруженного файла
335			//if ($this.is(this._getElemClass('item')))
336			$this.closest('.uploads').trigger('uploads:change', null, {
337				'action' : 'remove',
338				'item' : 'preview'
339			});
340			_checkCount($block);
341		};
342
343
344		var _checkCount = function($block) {
345
346			var total = $block.find('.uploads__preview').length;
347
348			if ($block.attr('data-count') && total >= $block.attr('data-count')) {
349				$block.find('.uploads__button').attr('data-disabled', true);
350			} else {
351				$block.find('.uploads__button').removeAttr('data-disabled');
352			}
353		};
354
355
356		var _uploadOne = function($block, file) {
357
358			$block.find('.uploads__button').addClass('uploads__button_loading');
359			$block.attr('data-uploads', parseInt($block.attr('data-uploads') || 0)+1);
360
361			load({
362				file: file,
363				url: $block.attr('data-upload')
364			}, function(response) {
365				_finishUpload($block, response, file);
366			});
367		};
368
369
370		var _showError = function($block, type, file) {
371
372			var message = false,
373				errors = {
374					size: 'Превышен максимальный размер файла',
375					type: 'Неверный тип файла',
376					common: 'Ошибка загрузки файла'
377				};
378
379			if (!type)
380				return false;
381
382			switch (type) {
383
384				case 'type':
385				case 'size':
386				case 'common':
387					message = errors[type];
388				break;
389
390				default:
391					message = type || errors.common;
392				break;
393			}
394
395			if (file && file.name)
396				message += ' ('+ file.name +')';
397
398			var $error = $('<span>').addClass('uploads__error')
399									.text(message);
400
401			$block.append($error);
402		};
403
404
405		var _finishUpload = function($block, response, file) {
406
407			if (response.result)
408				_showUploaded($block, file, response.result);
409			else
410				_showError($block, response.error, file);
411
412			$block.attr('data-uploads', parseInt($block.attr('data-uploads') || 1)-1);
413
414			if ($block.attr('data-uploads') < 1)
415				$block.find('.uploads__button').removeClass('uploads__button_loading');
416
417			if (response.result)
418				$block.trigger('uploads:change', null, {
419					'name' : file.name,
420					'value': file,
421					'path' : response.result,
422					'action' : 'add',
423					'result' : response
424				});
425		};
426
427		var _showUploaded = function($block, file, value) {
428
429			if (!file || !file.name || !value)
430				return false;
431
432			var $item,
433				type = $block.data('type') || 'previews';
434
435			switch (type) {
436				case 'previews':
437					var reader = new FileReader();
438					reader.onload = function(e, tpl) {
439
440						$item = $('<div>').addClass('uploads__preview')
441									.html($('<span>').addClass('uploads__preview-remove'))
442									.append($('<img>').prop('src', e.target.result))
443									.append($('<input>').prop('type', 'hidden')
444														.prop('name', $block.find('.uploads__input').data('name'))
445														.prop('value', value)
446														);
447						$block.find('.uploads__previews').append($item);
448						_checkCount($block);
449					};
450					reader.readAsDataURL(file);
451				break;
452				default:
453					$item = $('<div>').addClass('uploads__item')
454							.html(
455								$('<span>').addClass('uploads__file')
456											.text(file.name)
457								)
458							.append($('<input>').prop('type', 'hidden')
459												.prop('name', $block.find('.uploads__input').data('name'))
460												.prop('value', value)
461												);
462					$block.append($item);
463				break;
464			}
465		};
466
467		init();
468
469		return {
470
471		};
472	})();
473
474
475	app.index = (function() {
476
477		var $main = $('.index'),
478			_w = {};
479
480		var init = function() {
481
482			_setPoints();
483			_w.$overlay = $main.find('.index__overlay');
484
485			$(document).on('mouseenter', '.index__point', _overPoint)
486						.on('mouseleave', '.index__point', _leavePoint);
487
488			$(window).on('resize', resize);
489		};
490
491		var _overPoint = function(e) {
492
493			var $point = $(e.target).closest('.index__point'),
494				css = {left: $point.css('left'), top: $point.offset()['top']};
495
496			_w.$overlay.css(css);
497			$main.addClass('index_point_active');
498		};
499
500		var _leavePoint = function() {
501
502			$main.removeClass('index_point_active');
503		};
504
505
506		var _setPoints = function() {
507
508			var width = Math.max(window.innerWidth, 980),
509				commonMargin = 1.57*(1-1280/width),
510				center = $main.find('.index__wrap')[0].clientHeight/2,
511				delta,
512				t;
513
514			$main.find('.index__point').each(function() {
515
516				delta = parseInt($(this).position().top) - center;
517				$(this).css({'margin-top': delta*commonMargin});
518			});		
519		};
520
521		var resize = function() {
522
523			if (_w.resizeTimeout)
524				clearTimeout(_w.resizeTimeout);
525
526			_w.resizeTimeout = setTimeout(_setPoints, 500);
527		};
528
529		!$main.length || init();
530	})();
531
532
533	app.search = (function() {
534
535		var $main = $('.search');
536
537		var init = function() {
538
539			$(document).on('click', '.search__button', _button)
540						.on('keyup', '.search__field', _toggleButton)
541						.on('focus', '.search__field', _focus)
542						.on('blur', '.search__field', _blur);
543		};
544
545		var _button = function(e) {
546
547			console.log($main.is('.search_active'));
548			if (!$main.hasClass('search_active')) {
549
550				$main.addClass('search_active');
551				$main.find('.search__field').focus();
552				return false;
553			}
554
555			if ($main.find('.search__field').val().length < 2)
556				return false;
557		};
558
559		var _toggleButton = function() {
560
561			var state = $main.find('.search__field').val().length > 0 ? '' : 'disabled';
562		};
563
564		var _focus = function() {
565
566			$main.addClass('search_active');
567		};
568
569		var _blur = function() {
570
571			var active = $main.find('.search__field').val().length > 0;
572
573			if (active)
574				$main.addClass('search_active');
575			else
576				$main.removeClass('search_active');
577		}
578
579		!$main.length || init();
580	})();
581
582
583	app.mobileNav = (function() {
584
585		var $main = $('.mobile-nav'),
586			$holder = $main.find('.mobile-nav__holder'),
587			$wrap = $main.find('.mobile-nav__wrap');
588
589		var init = function() {
590
591			$holder.on('click', _toggleNav);
592			$main.on('click', '.mobile-nav__link_parent', _toggleSubNav);
593		};
594
595
596		var _toggleNav = function(e) {
597
598			e.preventDefault();
599			e.stopPropagation();
600
601			if ($wrap.attr('data-process'))
602				return false;
603
604			$wrap.attr('data-process', true);
605			$wrap.slideToggle(300, function() {
606				$(this).removeAttr('data-process');
607			});
608		};
609
610
611		var _toggleSubNav = function(e) {
612
613
614			var $item = $(this).closest('.mobile-nav__item'),
615				$list = $item.find('.mobile-nav__sublist');
616
617			if ($list[0].style.display == 'block') {
618				return;
619			}	
620			
621			e.preventDefault();
622			e.stopPropagation();
623
624			if ($list.attr('data-process'))
625				return false;
626
627			$list.attr('data-process', true);
628			$list.slideToggle(300, function() {
629				$(this).removeAttr('data-process');
630			});
631		};	
632
633
634		init();
635	})();
636
637	
638	app.scroll = (function() {
639
640		var init = function() {
641
642			$('.i-scroll').on('click', _scrollTo);
643			$(document).on('click', 'a[href *=scroll-to_]', _scrollHashSelf);
644		};
645
646		var _scrollTo = function(e) {
647
648			e.preventDefault();
649			e.stopPropagation();
650
651			var $this = $(e.target).closest('a,span').first()
652				offset = $($this.data('rel')).offset() || 0,
653				scrollTo = offset.top || 0,
654				speed = $this.data('speed') || 300;
655
656
657			$('html,body').animate({scrollTop: scrollTo}, speed);
658		};
659
660		var scrollToElement = function($el,time,amendment) {
661
662			var offset = $el.offset() || 0,
663				scrollTo = (offset.top || 0) + (amendment || 0),
664				speed = time || 300;
665
666			scroll = $('html,body').animate({scrollTop: scrollTo}, speed);
667		};
668
669
670		var _scrollHashSelf = function(e) {
671
672			var $this = $(e.target),
673				hash = $this.attr('href').split('#') || [];
674
675			if (!hash[1])
676				return;
677
678			var to = hash[1].replace('scroll-to_',''),
679				$to = $('[data-scroll-to="'+to+'"]');
680
681			if ($to.length)
682				scrollToElement($to, 500);
683		}
684
685		init();
686
687		return {
688			'to' : scrollToElement
689		}
690	})();
691})(jQuery);

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.