%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.17.187.119 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/templates/artlot24/assets/js/ |
Upload File : |
// const sticky = document.querySelector('#price-block-f'); // const stickyContainer = document.querySelector('.content.lot'); // const offsetTop = stickyContainer.offset().top; // const offsetBottom = offsetTop + stickyContainer.offsetHeight - sticky.offsetHeight; // window.addEventListener('scroll', function () { // const scrollPosition = window.scrollY; // console.log("scrollPosition"); // if (scrollPosition >= offsetTop && scrollPosition <= offsetBottom) { // sticky.classList.add('fixed'); // sticky.classList.remove('bottom'); // } else if (scrollPosition > offsetBottom) { // sticky.classList.remove('fixed'); // sticky.classList.add('bottom'); // } else { // sticky.classList.remove('fixed'); // sticky.classList.remove('bottom'); // } // }); $(function(){ var LocationHash = location.hash.slice(1), $document = $(document), $window = $(window), SubMenu = (function() { var $_menus = $('[data-menu]'), $_submenus = $('.menu-content[data-submenu]'), _current = $_menus.filter('.active').data('menu'); return { init: function () { $_menus.on('mouseenter', 'span', function() { var name = $(this).closest('[data-menu]').data('menu'); SubMenu.open(name); }); $('header').on('mouseleave', function() { SubMenu.close(); }); }, open: function(name) { // $_menus.removeClass('active') // .filter('[data-menu=' + name + ']').addClass('active'); // // $_submenus.addClass('d-none'); var $submenu = $_submenus.filter('[data-submenu=' + name + ']'); if (!$submenu.length) $submenu = $_submenus.first(); // $submenu.removeClass('d-none'); }, close: function() { SubMenu.open(_current); } } }()), Search = (function() { var $_search = $('#search'); _input = '[name="query"]', $m_input = $('#mob-search [name="query"]'), _over_search = false, $_result = $('.Search-result', $_search); return { init: function() { if (!$_search.length) return false; $_search.hover(function() { _over_search = true; }, function() { _over_search = false; }); $m_input.on('input', function () { Search.update(function() { Search.show(); }, $m_input); }); $_search .on('focus', _input, function() { Search.show(); }) .on('keyup', _input, function(e) { if ($(this).val().trim() == '') { return ; } if (typeof (_searchTimeout) == 'undefined') { _searchTimeout = null; } clearTimeout(_searchTimeout) _searchTimeout = setTimeout(function () { Search.update(function() { Search.show(); }); }, 1000); }); $document.on('click', function() { Search.hide(); }); }, show: function() { $(_input, $_search).addClass('focus'); $_result.removeClass('d-none'); }, hide: function() { if (!_over_search) { $(_input, $_search).removeClass('focus'); $_result.addClass('d-none'); } }, update: function(callback) { if (arguments.length == 2 && arguments[1] instanceof Object) { $_search = arguments[1].closest('form'); $_result = $_search.find('.Search-result'); } $.ajax({ url: $_search.attr('action') + '?' + Math.random(), type: $_search.attr('method'), data: $_search.serialize(), success: function(response){ if (response.length) { $_result.html(response); if (callback instanceof Function) callback(); } } }); } } }()), Forms = (function() { var _pushSubmit = function(e, $form, proccess) { e.preventDefault(); var $input = $('<input />').attr({name: 'input', type: 'hidden'}).val(Math.random()).appendTo($form); // Forms.clear($form); r = $.ajax({ url: $form.attr('action'), type: $form.attr('method'), data: $form.serialize(), beforeSend: function() { Forms.hold($form); $input.remove(); }, success: function(response) { if (response.success) { if (proccess) { proccess(response, $form); } else if (response.refresh) { location.reload(); } else if (response.link) { location.href = response.link; } else { Forms.success($form, response.message); Forms.reset($form); } } else if (response.errors) { Forms.errors($form, response.errors); } }, complete: function() { Forms.unhold($form); } }); console.log(r) }; $document.on('click', 'label[data-for]', function(e) { var $this = $(this), name = $this.data('for'); $input = $this.closest('form').find('[name="' + name + '"]'), $input.trigger($input.is(':radio, :checkbox') ? 'click' : 'focus'); }); return { add: function(selector, proccess) { if (selector instanceof jQuery) { selector.on('submit', function(e) { _pushSubmit(e, selector, proccess); }); } else { $document.on('submit', selector, function(e) { _pushSubmit(e, $(this), proccess); }); } }, clear: function($form) { $form.find('.form_result').remove(); $form.find('[name].error').removeClass('error'); }, reset: function($form) { $form.trigger('reset'); }, hold: function($form) { $form.css('opacity', '.3') .find(':submit').prop('disabled', true); }, unhold: function($form) { $form.css('opacity', '') .find(':submit').prop('disabled', false); }, success: function($form, message) { var $success = $('<p />').addClass('form_result success').html(message); $success.prependTo($form); if ($form.data('as')) { $form.find('button,input,div.heading').remove(); } }, errors: function($form, errors) { $.each(errors, function(name, text) { var $input = $form.find('[name="' + name + '"]'), $label = $input.next('label').length ? $input.next('label') : $input, $error = $('<p />').addClass('form_result error').html(text); $input.addClass('error'); $label.after($error); }); } } }()), Steps = (function() { var $_steps = $('section.steps'); return { init: function() { if (!$_steps.length) return false; $document.on('scroll', function() { Steps.scroll(); }).trigger('scroll'); }, scroll: function() { var pos = $document.scrollTop(), start = $('.dot-top', $_steps).offset().top, end = $('.dot-bottom', $_steps).offset().top; if(pos >= (start / 2) && pos <= end - (start / 2 - 20)) { var margin = pos - start / 2; $('.indicator', $_steps).css('margin-top', margin); $('.icon[data-index]', $_steps).each(function() { var $this = $(this), thisPos = $this.offset().top - start / 2; $this[pos > thisPos ? 'addClass' : 'removeClass']('done'); }); } } } }()), StreetViewTour = (function() { var $_container = $('#tour3d'); return { init: function() { if (!$_container.length) return false; $.getScript('//maps.google.com/maps/api/js?sensor=false', function(){ var panoramaOptions = { position: new google.maps.LatLng(59.9408566,30.3453627), pov: { heading: 75, pitch: 0, zoom: 0 }, disableDefaultUI: true }; $_container.on('click', 'a.tour_3d', function(e){ e.preventDefault(); new google.maps.StreetViewPanorama(document.getElementById($_container.attr('id')), panoramaOptions); }); }); } } }()) AjaxPaginate = (function() { var _proccess = false; return { init: function() { $document.on('scroll', function() { var $block = $('[data-ajax-more]', $document); if (!$block.length) return false; var scroll = $document.scrollTop() + $window.height(), position = $block.offset().top + $block.height() - 500; if (scroll >= position) { AjaxPaginate.more($block); } }).trigger('scroll'); }, more: function($block) { if (_proccess) return false; var url = $block.data('ajax-more'); if (!url) { $block.removeAttr('data-ajax-more'); return false; } $.ajax({ url: url, type: 'get', beforeSend: function() { _proccess = true; }, success: function(response) { var $response = $(response), $more = $('[data-ajax-more]', $response); $block.removeAttr('data-ajax-more').after($more) }, complete: function() { _proccess = false; } }) } } }()), Auction = (function() { var $_auction = $('#auction'), _show_bids = false, _send = false, _getNoun = function(number, one, two, five) { number = Math.abs(number); number %= 100; if (number >= 5 && number <= 20) { return five; } number %= 10; if (number == 1) { return one; } if (number >= 2 && number <= 4) { return two; } return five; }, _leadZero = function(num) { return (num < 10 ? '0' + num : num); }, _times = { days: {name: 'd', noun1: 'день', noun2: 'дня', noun5: 'дней'}, hours: {name: 'h', noun1: 'час', noun2: 'часа', noun5: 'часов'}, minutes: {name: 'm', noun1: 'минуту', noun2: 'минуты', noun5: 'минут'}, seconds: {name: 's', noun1: 'секунду', noun2: 'секунды', noun5: 'секунд'}, }; return { init: function() { Auction.updateTimer(); setInterval(Auction.updateTimer, 1000); setInterval(function() { Auction.updateAuction(); }, 30000); $_auction.on('click', '.more a', function(e) { e.preventDefault(); var $this = $(this); if (_show_bids) { _show_bids = false; $this.html('Показать все'); $('.bid.hidden', $_auction).css('display', 'none'); } else { _show_bids = true; $this.html('Свернуть'); $('.bid.hidden', $_auction).css('display', 'block'); } }); $(document).on('click', '.currency button', function(e) { e.preventDefault(); var $this = $(this); $this.addClass('active').siblings().removeClass('active'); var $wrapper = $this.closest('.controls'); $wrapper.find('[data-type="price"]') .html($this.data('price') + ($this.data('text') ? ' <span>' + $this.data('text') + '</span>' : '')); $wrapper.find('[data-type="old-price"]') .html($this.data('old-price') + ($this.data('text') ? ' <span>' + $this.data('text') + '</span>' : '')); }); $_auction.on('click', 'a.postbuy-button', function(e) { $('.postbuy .form_result', $_auction).remove(); /// e.preventDefault(); var a = $(this); $.post(a.data('h'), {'_type': 'post', 'i': a.data('i')}, function (r) { if (typeof (r) == 'object') { if (r.l) { $('.modal_auth').trigger('click'); } else if (r.e) { var $error = $('<p />').addClass('form_result error').html(r.e); $('.postbuy', $_auction).prepend($error); } else if (r.u) { var $success = $('<p />').addClass('form_result success').html(r.s); $('.postbuy', $_auction).prepend($success); } } }, 'json'); /// }); }, updateTimer: function() { // absolute time $('[data-overtime]').each(function(){ var $this = $(this), overtime = parseInt($this.data('overtime')) - 1; if (overtime <= 0) { Auction.updateAuction(); return false; } var timers = { s: (overtime % 60), m: Math.floor((overtime / 60) % 60), h: Math.floor((overtime / (60 * 60)) % 24), d: Math.floor(overtime / (60 * 60 * 24)) }, next = -2; $('[data-type]', $this).each(function() { if (!next) return false; var $this = $(this), type = $this.data('type') value = timers[_times[type].name]; $this.addClass('d-none').text($this.data('zero') ? _leadZero(value) : value) .next().addClass('d-none').text( _getNoun(value, _times[type].noun1, _times[type].noun2, _times[type].noun5) ) $this.parent().prev('.separator').addClass('d-none'); if (value || $this.data('zero')) { $this.add($this.next()).removeClass('d-none'); if ($this.data('zero')) { $this.parent().prev('.separator').removeClass('d-none'); } next++; } }); $this.data('overtime', overtime); }); }, updateAuction: function() { if (_send) return false; _send = true; var value = $('[name="bid"]', $_auction).val(); $('.reload', $_auction).load($_auction.data('url') + ' #auction .reload>*', {showallbids: _show_bids}, function() { $('[name="bid"]', $_auction).val(value); $(this).find('a.btn-modal').on('click', function (e) { e.preventDefault(); $('#' + $(this).data('target')).modal(); }); _send = false; }); } } }()) ; Search.init(); SubMenu.init(); Steps.init(); Forms.add('.Forms-simple'); Forms.add('form.login', function(response) { $(response.html).on('click', '.close', function() { location.reload(); }).appendTo('body'); }); Forms.add('.Forms-notification', function(response, $form) { Forms.success($form, response.message); }); StreetViewTour.init(); AjaxPaginate.init(); Auction.init(); $document.on('click', '[data-favorite]', function(e){ e.preventDefault(); var $this = $(this), id = $this.data('favorite'); $.post('/items/favorite', {id: id}, function(){ $this.toggleClass('active'); }); }).on('submit', '#cp-form,#cd-form', function (e) { e.preventDefault(); var f = $(this); $.post(f.attr('action'), f.serialize(), function (response) { f.replaceWith($('#' + f.attr('id'), response)); }, 'html'); }); $('.mob-search-btn').on('click', function(e) { e.preventDefault(); $('#mob-search').fadeIn(); }); $(document).mouseup(function (e){ // событие клика по веб-документу var div = $(".mob-searchBlock"); // тут указываем ID элемента if (!div.is(e.target) // если клик был не по нашему блоку && div.has(e.target).length === 0) { // и не по его дочерним элементам $('#mob-search').fadeOut(); // скрываем его } }); /// $('.modal_buy').on('click', function(e) { e.preventDefault(); var id = $(this).data('id'), $modal = $('.modal-overlay.buy'); $('a[data-url]', $modal).each(function(){ var $this = $(this); $this.attr('href', $this.data('url') + id); }); $modal.addClass('show'); $('body').css('overflow-y', 'hidden'); }); if ($('.modal-overlay.auth').length) { var ShowAuth = function() { $('.modal-overlay.auth').addClass('show'); $('body').css('overflow-y', 'hidden'); } if (LocationHash == 'auth') { ShowAuth(); } $(document).on('focus', '[data-check-auth]', function() { ShowAuth(); }); } // $('a[data-fancybox="gallery"]').fancybox({ // thumbs: { // autoStart : true, // axis: 'x' // } // }); /*$('.fancybox-media').fancybox({ helpers : { media: true } });*/ });