ISRegions = { PopUpTitle: '', Step: 0, UrlPage: '', History: true, Init: function () { var thisclass = this; $(".responsive-block").click(function () { if ($(this).attr('id') != 'calendar') $.ajax({ type: "post", url: "/ajax/moduleclick?v=" + ISCommon.GetV(), data: { G: ISCommon.Guid, Id: $(this).data('moduleid'), v: '1' }, success: function (d) { if (d.result == 'yes' && ISCommon.Guid == '') ISCommon.SetGuid(d.guid); } }); }); $('.video-link.block.widget-video').click(function () { $.ajax({ type: "post", url: "/ajax/moduleclick?v=" + ISCommon.GetV(), data: { G: ISCommon.Guid, Id: $(this).parents(".responsive-block").eq(0).data('moduleid'), v: '2' }, success: function (d) { if (d.result == 'yes' && ISCommon.Guid == '') ISCommon.SetGuid(d.guid); } }); }); $('.block[name=opengames]').click(function () { $.ajax({ type: "post", url: "/ajax/moduleclick?v=" + ISCommon.GetV(), data: { G: ISCommon.Guid, Id: $(this).parents(".responsive-block").eq(0).data('moduleid'), v: '3' }, success: function (d) { if (d.result == 'yes' && ISCommon.Guid == '') ISCommon.SetGuid(d.guid); } }); }); thisclass.UrlPage = document.location + ''; $("#long-menu a").click(function () { if (thisclass.History) ISHistory.Push({ type: 'regions.long-menu', action: 'open', eventtype: $(this).data('eventtype') }, 'Региональная страница', thisclass.UrlPage); $(this).parents('#long-menu').find('.active').removeClass('active'); $(this).parent().addClass('active'); thisclass.PopUpTitle = $(this).text(); if (!$(this).hasClass('disabled')) $.ajax({ url: '/statistics/typeactions?eventtypeid=' + $(this).data('eventtype') + '®ion=' + $('#RegionId').val(), data: { LoadType: "ajax" }, success: function (d) { $('.region-popup .scroll-wrap').html(d); thisclass.PopUpShow(); } }); return false; }); $('#RegionId').selectik({ width: 227, heightContainer: 400, customScroll: 0, speedAnimation: 100, smartPosition: true }).change(function () { if ($(this).val() != "0") document.location = "/regions/" + $(this).val(); }); $('.responsiveBlock .col-10-5 a:odd').removeClass('banner-left').addClass('banner-right'); $("#long-slider .slide").mouseover(function () { $(this).find('.footing').stop().slideDown(250); }); $("#long-slider .slide").mouseout(function () { $(this).find('.footing').stop().slideUp(250); }); if ($("#long-slider").length) thisclass.LongSliderRun(); $.ajax({ url: '/ajax/typeactionschecked?region=' + $('#RegionId').val(), data: { LoadType: "ajax" }, success: function (d) { for (var i = 1; i < 13; i++) if (d.CountsByType["count" + i] > 0) $('#long-menu a[data-eventtype=' + i + ']').removeClass('disabled'); if (window.location.hash && window.location.hash.length > 2) { var hash = window.location.hash.substr(2); $('#long-menu a[data-eventtype=' + hash + ']:first').click(); } } }); $("#long-slider .left").hide(); if ($('.blocks-container .slide').length > 5) $("#long-slider .right").show(); else $("#long-slider .right").hide(); this.RegionActiveShow(); }, LongSliderRun: function () { var thisclass = this; var sliderWrap = $("#long-slider .blocks-container"); var slide = sliderWrap.find('.slide'); var slideWidth = slide.outerWidth(); var firstPosition = sliderWrap.position().left; var endPosition = slide.length * slideWidth - ($("#container").width()); $("#long-slider .left").click(function () { if ($('.blocks-container .slide').length > 5) $("#long-slider .right").show(); if (thisclass.Step > 0) thisclass.Step--; if (thisclass.Step == 0) $("#long-slider .left").hide(); sliderWrap.stop(true); sliderWrap.animate({ left: -slideWidth * thisclass.Step }); //var lft = sliderWrap.position().left; //if (lft < firstPosition) sliderWrap.animate({left:lft + slideWidth}); return false; }); $("#long-slider .right").click(function () { if ($('.blocks-container .slide').length > 5) $("#long-slider .left").show(); thisclass.Step = thisclass.Step + 5 < $('.blocks-container .slide').length ? thisclass.Step + 1 : thisclass.Step; if (thisclass.Step + 5 == $('.blocks-container .slide').length) $("#long-slider .right").hide(); sliderWrap.stop(true); sliderWrap.animate({ left: -slideWidth * thisclass.Step }); //var lft = sliderWrap.position().left; //if (Math.abs(lft) < endPosition || lft == firstPosition) sliderWrap.animate({left:lft - slideWidth}); return false; }); }, PopUpShow: function () { var thisclass = this; var popup = $(".region-popup"), bg = $(".region-popup-bg"), content = popup.find(".popup-content"); var offsetik = $("#long-menu").offset().top + $("#long-menu").height(); var newWidth = $("#container").width() * 0.78125; bg.css({ top: offsetik, height: $("#container").height() - offsetik }); popup.css({ top: offsetik, width: newWidth, maxHeight: $("#container").height() - offsetik - $(".footer").height(), marginLeft: 0 - (newWidth / 2) }); content.css({ maxHeight: popup.height() - 60 }); content.niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', zindex: 1000, railoffset: { left: -2.5, top: -2 } }); popup.find('.heading-title').text(thisclass.PopUpTitle); bg.show(); popup.show(); popup.find(".close").unbind('click'); popup.find(".close").click(function () { popup.hide(); bg.hide(); $("#long-menu .active").removeClass('active'); if (thisclass.History) ISHistory.Push({ type: 'regions.long-menu', action: 'close' }, 'Региональная страница', thisclass.UrlPage); return false; }); }, RegionActiveShow: function () { var maxPane = 0; var maxPaneObj; $(".activity-pane-wrap .value-label").each(function () { if (parseInt($(this).text()) > maxPane) { maxPane = parseInt($(this).text()); maxPaneObj = $(this); } }); maxPaneObj.parents('.pane').addClass('p100'); $(".activity-pane-wrap .pane").each(function () { if (!$(this).hasClass('p100')) { var percent = parseInt($(this).find('.value-label').text()) * 90 / maxPane; $(this).addClass('p' + (10 + Math.round(percent / 10) * 10)); } }); var i = 0; var j = 1000; $(".activity-pane-wrap .value").each(function () { var th = $(this); setTimeout(function () { th.animate({ top: '15px' }, { duration: j, easing: 'swing' }); i += 300; j += 500; }, i); }); var prevValue = 0; var intervalID = setInterval(function () { var randomValue = Math.floor(Math.random() * 5); while (randomValue == prevValue) { randomValue = Math.floor(Math.random() * 5); } var th = $(".activity-pane-wrap").find(".value").eq(randomValue); if (th.find('.value-label').length > 0 && parseInt(th.find('.value-label').text()) != 0) th.animate({ top: 15 }, { duration: 300, easing: 'swing', complete: function () { th.animate({ top: 5 }, { duration: 200, easing: 'swing', }); prevValue = randomValue; } }); }, 100); } };