var eventsFilterSliderTimePrecision = 30; var eventsFilterSliderPricePrecision = 300; var eventsFilterThemesLastTime = []; var eventsFilterCatsLastTime = []; var filterDates = ['2018.09.21'] ; jQuery(function($) { if ($("#orgName").length) { $("#orgName").autocomplete('/ajax/org.filter/', { minChars: 1, maxItemsToShow: 6, mustMatch: 0, width: 305, cacheLength: 0, extraParams: { 'cats': '1042,1047,1054,1045,1044,1053,1046,1052,1051,1049,1048,1050,694,797,859,864,721,927,638,649,639,640,641,642,1194,1195,644,673,1197,643,673,682,764,927,581,585,590,593,822,859,865,871,901,902,903,904,1236,1237,954,582,581,585,735,743,745,821,831,839,855,873,874,896,841,617,764,537,541,542,655,728,923,590,593,822,31,901,902,903,904,954,982,969,629,874,588,619,655,671,685,695,804,805,924,938,939,1040' } }).result(function(event, item){ window.location = '/c/org/' + item[1]; }); } $("li.switch a").click(function(){ $(this).parent('li').parent('ul').find('li.switch').removeClass('active'); $(this).parent('li').addClass('active'); filterProcess(); return false; }); eventsFilterDate.init(); /* $(".dslider#dslider-time").slider({ range: true, step: 1, min: 0, max: eventsFilterSliderTimePrecision, values: [$("input[name='time_min_pos']").val(), $("input[name='time_max_pos']").val()], change: function(e, ui) { dsliderRedrawGauge($(this)); var trueValues = [0, 0]; var imgValues = [0, 0]; trueValues[0] = eventsFilterSliderTimeTrueValue(ui.values[0]); trueValues[1] = eventsFilterSliderTimeTrueValue(ui.values[1]); imgValues[0] = eventsFilterSliderTimeImaginaryValue(ui.values[0]); imgValues[1] = eventsFilterSliderTimeImaginaryValue(ui.values[1]); $("input[name='time_min']").val(imgValues[0]); $("input[name='time_max']").val(imgValues[1]); $("input[name='time_min_pos']").val(ui.values[0]); $("input[name='time_max_pos']").val(ui.values[1]); filterProcess(); } }); setTimeout(function(){ dsliderRedrawGauge($(".dslider#dslider-time")); }, 10); $("input[name='time_min'], input[name='time_max']").change(function(){ $(".dslider#dslider-time").slider("option", "values", [ eventsFilterSliderTimeImaginaryValue(parseInt($("input[name='time_min']").val())), eventsFilterSliderTimeImaginaryValue(parseInt($("input[name='time_max']").val())) ] ); }); $(".dslider#dslider-price").slider({ range: true, step: 1, min: 0, max: eventsFilterSliderPricePrecision * 3, values: [$("input[name='price_min_pos']").val(), $("input[name='price_max_pos']").val()], change: function(e, ui) { dsliderRedrawGauge($(this)); var trueValues = [0, 0]; trueValues[0] = eventsFilterSliderPriceTrueValue(ui.values[0]); trueValues[1] = eventsFilterSliderPriceTrueValue(ui.values[1]); $("input[name='price_min']").val(trueValues[0]); $("input[name='price_max']").val(trueValues[1]); $("input[name='price_min_pos']").val(ui.values[0]); $("input[name='price_max_pos']").val(ui.values[1]); filterProcess(); } }); setTimeout(function(){ dsliderRedrawGauge($(".dslider#dslider-price")); }, 10); $("input[name='price_min'], input[name='price_max']").change(function(){ $(".dslider#dslider-price").slider("option", "values", [ eventsFilterSliderPriceImaginaryValue(parseInt($("input[name='price_min']").val())), eventsFilterSliderPriceImaginaryValue(parseInt($("input[name='price_max']").val())) ] ); }); */ $(".events-filter-types .checklist li a.check").click(function(){ $(this).parent('li').toggleClass('active'); filterProcess(); return false; }); $(".events-filter-types .checklist li a.link").click(function(){ $(this).parent('li').toggleClass('active'); eventsFilterSubmit(); return false; }); $(".dslider").each(function(){ $(this).find(".ui-slider-handle:eq(0)").addClass('left'); $(this).find(".ui-slider-handle:eq(1)").addClass('right'); }); $(".events-filter-flags a").click(function(){ $(this).parent('li').toggleClass('active'); filterProcess(); return false; }); $(".weekler tr.switches td").unbind('click'); $(".weekler tr.switches td").click(function() { if ($(this).children('.day.other').length) { if ($(".weekler tr.switches td:first .day").hasClass('other')) { eventsFilterDate.monthPrev(); } else { eventsFilterDate.monthNext(); } } else { var index = $(".page-events-filter-week .weekler tr.switches td").index($(this)); var dateNow = new Date(); var day = eventsFilterDateCurrent.getDate() + index - eventsFilterDate.weekSkip; if ( $("#archive_flag").val() != '1' && ( eventsFilterDate.year < dateNow.getFullYear() || eventsFilterDate.year == dateNow.getFullYear() && eventsFilterDate.month - 1 < dateNow.getMonth() || eventsFilterDate.year == dateNow.getFullYear() && eventsFilterDate.month - 1 == dateNow.getMonth() && day < dateNow.getDate() ) ) { return false; } if ($("#filter-dates div").length == 0) { $("#filter-dates").html(''); } var date = eventsFilterDate.year + '.' + pad(eventsFilterDate.month, 2) + '.' + day; var date_reverse = day + '.' + pad(eventsFilterDate.month, 2) + '.' + eventsFilterDate.year; if (filterDates.indexOf(date) == -1) { $("#filter-dates").append('
' + date_reverse + '
'); $("#filter-dates").find("div:last").slideDown('fast'); filterDates.push(date); eventsFilterDate.highlight(filterDates); filterProcess(); } else { index = filterDates.indexOf(date); filterDates.splice(index, 1); eventsFilterDate.highlight(filterDates); $("#filter-dates div:eq("+index+")").slideUp('fast', function(){ $(this).remove(); if ($("#filter-dates div").length == 0) { $("#filter-dates").html('Выберите дату'); } }); filterProcess(); } } return false; }); $("#filter-dates .remove").live('click', function(){ var index = $("#filter-dates div").index($(this).parent('div')); filterDates.splice(index, 1); $(this).parent('div').slideUp('fast', function(){ $(this).remove(); if ($("#filter-dates div").length == 0) { $("#filter-dates").html('Выберите дату'); } }); eventsFilterDate.highlight(filterDates); filterProcess(); return false; }); $("#eventsFilterDatePrev, #eventsFilterDateNext, .chooser-month li a, .chooser-year li a").click(function(){ eventsFilterDate.highlight(filterDates); }); eventsFilterDate.init(false); eventsFilterDate.highlight(filterDates); filterProcess(); $("#events-filter-hide").click(function() { $(this).hide(); $("#events-filter-block").slideUp('fast', function() { $("#events-filter-show").show(); }); return false; }); $("#events-filter-show").click(function() { $(this).hide(); $("#events-filter-block").slideDown('fast', function() { $("#events-filter-hide").show(); }); return false; }); $("#events-filter-search-field input").autocomplete('/ajax/events.filter/', { minChars: 1, maxItemsToShow: 18, mustMatch: 0, width: 450, cacheLength: 0, extraParams: { 'r': Math.random() }, formatResult: function(data, pos, total) { return data[1]; } }) .result(function(event, item) { //eventsFilterDate.highlight(new Date()); window.location = item[2]; }); $("#events-filter-search-field input").focus(function() { var sender = $(this); if (sender.val() == sender.attr('title')) { sender.val('').removeClass('inactive'); } }) .blur(function() { var sender = $(this); if (sender.val() == '') { sender.val(sender.attr('title')).addClass('inactive'); } }); /* $("#events-filter-search-field input").change(function() { var sender = $(this); if (sender.val() == sender.title) { } }); */ }); function filterProcess() { var days = []; $(".page-events-filter-week .weekler tr.switches td").each(function(){ if ($(this).hasClass('active')) { var index = $(".page-events-filter-week .weekler tr.switches td").index($(this)); var day = eventsFilterDateCurrent.getDate() + index - eventsFilterDate.weekSkip; days.push(day); } }); var themes = []; $(".events-filter-types .event-type li a.check").each(function(){ if ($(this).parent('li').hasClass('active')) { themes.push($(this).attr('rel')); } }); var cats = []; $(".events-filter-types .events-filter-column2 .checklist li a.check").each(function(){ if ($(this).parent('li').hasClass('active')) { cats.push($(this).attr('rel')); } }); var organizations = $("input[name='organizations[]']").length ? $("input[name='organizations[]']").val() : ''; $("#events-filter-count, #filter-count").html('...'); $.getJSON("/ajax/events.filter.count", { 'locality': $(".events-filter-locality li").index($(".events-filter-locality li.active")), 'themes': themes, 'cats': cats, 'date-year': eventsFilterDate.year, 'date-month': eventsFilterDate.month, 'date-days': days, 'dates': filterDates.join(','), 'organizations': organizations, /* 'time_min': $("input[name='time_min_pos']").val(), 'time_max': $("input[name='time_max_pos']").val(), 'price_min': $("input[name='price_min']").val(), 'price_max': $("input[name='price_max']").val(), */ 'seats': $("#events-filter-flags-additional li:eq(0)").hasClass("active") ? '1' : '0', //'online': $("#events-filter-flags-additional li:eq(1)").hasClass("active") ? '1' : '0', 'recommend': $("#events-filter-flags-additional li:eq(2)").hasClass("active") ? '1' : '0', 'page-new': ($("#newID").length ? "1" : "0"), 'type': ($("#filterType").length ? $("#filterType").val() : '0') } , function(e) { sidebarMapUpdate('events', 0, e.ids); $("#events-filter-count, #filter-count").html(e.count); if (e.count == 0) { $("#filter-count").parent('.filter-count').addClass('zero'); } else { $("#filter-count").parent('.filter-count').removeClass('zero'); } }); } function eventsFilterSubmit() { var days_real = []; $(".page-events-filter-week .weekler tr.switches td").each(function(){ if ($(this).hasClass('active')) { var index = $(".page-events-filter-week .weekler tr.switches td").index($(this)); var day = eventsFilterDateCurrent.getDate() + index - eventsFilterDate.weekSkip; days_real.push(day); } }); var days = []; $(".page-events-filter-week .weekler tr.switches td").each(function(){ if ($(this).hasClass('active')) { var index = $(".page-events-filter-week .weekler tr.switches td").index($(this)); days.push(index); } }); var themes = []; $(".events-filter-types .event-type li a.check").each(function(){ if ($(this).parent('li').hasClass('active')) { themes.push($(this).attr('rel')); } }); var cats = []; $(".events-filter-types .events-filter-column2 .checklist li a.check").each(function(){ if ($(this).parent('li').hasClass('active')) { cats.push($(this).attr('rel')); } }); var organizations = $("input[name='organizations[]']").length ? $("input[name='organizations[]']").val() : ''; var url = //$("#params").val() + 'act=search' + '&archive=' + $("#archive_flag").val() + '&locality=' + $(".events-filter-locality li").index($(".events-filter-locality li.active")) + '&themes=' + themes + '&cats=' + cats + '&date-current=' + eventsFilterDateCurrent.format('Y,m,d') + '&date-year=' + eventsFilterDate.year + '&date-month=' + eventsFilterDate.month + '&date-days=' + days + '&date-days_real=' + days_real + '&dates=' + filterDates + '&organizations[]=' + organizations + /* '&time_min=' + $("input[name='time_min']").val() + '&time_max=' + $("input[name='time_max']").val() + '&time_min_pos=' + $("input[name='time_min_pos']").val() + '&time_max_pos=' + $("input[name='time_max_pos']").val() + '&price_min=' + $("input[name='price_min']").val() + '&price_max=' + $("input[name='price_max']").val() + '&price_min_pos=' + $("input[name='price_min_pos']").val() + '&price_max_pos=' + $("input[name='price_max_pos']").val() + */ '&seats=' + ($("#events-filter-flags-additional li:eq(0)").hasClass("active") ? '1' : '0') + //'&online=' + ($("#events-filter-flags-additional li:eq(1)").hasClass("active") ? '1' : '0') + '&recommend=' + ($("#events-filter-flags-additional li:eq(2)").hasClass("active") ? '1' : '0') + '&page-new=' + ($("#newID").length ? '1' : '0') + '&type=' + ($("#filterType").length ? $("#filterType").val() : '0') ; window.location = ($("#searchURL").length ? $("#searchURL").val() : '') + '?' + url + '#results'; } function eventsFilterSliderTimeTrueValue(val) { var retVal = 0 + val; return retVal; } function eventsFilterSliderTimeImaginaryValue(val) { if (val >= 24) return val - 24 else return val; } function eventsFilterSliderPriceTrueValue(val) { if (val < eventsFilterSliderPricePrecision) { return Math.floor((val / eventsFilterSliderPricePrecision) * 500); } else if (val < eventsFilterSliderPricePrecision * 2) { return Math.floor(((val - eventsFilterSliderPricePrecision) / eventsFilterSliderPricePrecision) * 1500) + 500; } else { var retVal = Math.floor(((val - eventsFilterSliderPricePrecision * 2) / eventsFilterSliderPricePrecision) * 3000) + 2000; if (retVal == 4955) return 5000 else return retVal; } } function eventsFilterSliderPriceImaginaryValue(val) { if (val < 500) { return Math.floor((val / 500) * eventsFilterSliderPricePrecision); } else if (val < 2000) { return Math.floor(((val - 500) / 1500) * eventsFilterSliderPricePrecision) + eventsFilterSliderPricePrecision; } else { var retVal = Math.floor(((val - 2000) / 3000) * eventsFilterSliderPricePrecision) + eventsFilterSliderPricePrecision * 2; if (retVal == 199) return 200 else return retVal; } } function dsliderRedrawGauge(sender) { var lineLeft = 0.0; sender.siblings('.line').each(function(){ $(this).css('left', (Math.round(lineLeft * 100) / 100) + '%'); lineLeft += 16.666; }); sender.children('.dslider-gauge').children('.dslider-gauge-fill').css({ 'left': sender.children('.ui-slider-handle.left').css('left'), 'width': parseFloat(sender.children('.ui-slider-handle.right').css('left')) - parseFloat(sender.children('.ui-slider-handle.left').css('left')) + '%' }); }