ISCatalogs = { IsSportDownload: false, IsSportDownloaded: false, Sport: [], SportCallback: [], SportDownload: function (Callback) { if (this.IsSportDownloaded) { if (Callback != null) Callback(); return; } if (Callback != null) this.SportCallback.push(Callback); if (this.IsSportDownload) return; this.IsSportDownload = true; var t = this; $.ajax({ url: "/ajax/getsport", data: {}, cache: true, success: function (d) { t.Sport = d.Sport; t.IsSportDownloaded = true; for (var i = 0; i < t.SportCallback.length; i++) if (t.SportCallback[i] != null) { t.SportCallback[i](); } } }); }, SportGet: function (Id) { for (var i = 0; i < this.Sport.length; i++) if (this.Sport[i].Id === Id) return this.Sport[i]; return null; }, IsRegionsDownload: false, IsRegionsDownloaded: false, Regions: [], RegionsCallback: [], RegionsDownload: function (Callback) { if (this.IsRegionsDownloaded) { if (Callback != null) Callback(); return; } if (Callback != null) this.RegionsCallback.push(Callback); if (this.IsRegionsDownload) return; this.IsRegionsDownload = true; var t = this; $.ajax({ url: "/ajax/getregions", data: {}, cache: true, success: function (d) { t.Regions = d.Regions; t.IsRegionsDownloaded = true; for (var i = 0; i < t.RegionsCallback.length; i++) if (t.RegionsCallback[i] != null) { t.RegionsCallback[i](); } } }); }, RegionsGet: function (Id) { for (var i = 0; i < this.Regions.length; i++) if (this.Regions[i].Id === Id) return this.Regions[i]; return null; }, IsRanksDownload: false, IsRanksDownloaded: false, Ranks: [], RanksById: {} }; ISHistory = { Step: 0, DataPrev: {}, Init: function () { $(window).on('popstate', function (e) { var state = e.originalEvent.state; ISHistory.PopState(state); }); this.Step = $.cookie('ISHistory.Step') != null && $.cookie('ISHistory.Step') != '' && !isNaN($.cookie('ISHistory.Step')) ? parseInt($.cookie('ISHistory.Step')) : 0; }, PopState: function (state) { var th = this; if (state) { var step = state ? state.historystep : this.Step; var next = step >= this.Step; if (state.type == 'map') { ISWidgetMap.History = false; if (state.action == 'open') { $("#openMap").click(); } else if (state.action == 'close') $(".map .close").click(); else if (state.action == 'changeregion') { $("#region").data("selectik").changeCS({ value: state.region }); } else if (state.action == 'changetematic') { $("#tematic_layer").data("selectik").changeCS({ value: state.tematic }); $("#region").data("selectik").changeCS({ value: state.region }); } if ($('.atlet-popup').is(':visible')) $(".atlet-popup .close").click(); if ($('.org-popup').is(':visible')) $(".org-popup .close").click(); if (!next && this.DataPrev) { if (this.DataPrev.action == 'open') $(".map .close").click(); else if (this.DataPrev.action == 'close') $("#openMap").click(); } ISWidgetMap.History = true; } else if (state.type == 'person') { ISPerson.History = false; if (next) { if (state.action == 'open') ISPerson.AtletPopupToggle({ data: function (str) { return '' + state.id; } }); else if (state.action == 'close') $(".atlet-popup .close").click(); } else if (this.DataPrev) { if (this.DataPrev.action == 'open') $(".atlet-popup .close").click(); else if (this.DataPrev.action == 'close') ISPerson.AtletPopupToggle({ data: function (str) { return '' + th.DataPrev.id; } }); } ISPerson.History = true; } else if (state.type == 'organizations') { if (typeof state.id != "undefined") { ISOrganizations.History = false; if (next) { if (state.action == 'open') ISOrganizations.OrgPopupToggle({ data: function (str) { return '' + state.id; } }); else if (state.action == 'close') $(".org-popup .close").click(); } else if (this.DataPrev) { if (this.DataPrev.action == 'open') $(".org-popup .close").click(); else if (this.DataPrev.action == 'close') ISOrganizations.OrgPopupToggle({ data: function (str) { return '' + th.DataPrev.id; } }); } ISOrganizations.History = true; } } else if (state.type == 'olympicgames') { ISWidgetOlympicGames.History = false; if (state.action == 'open') $("#games").click(); else if (state.action == 'close') $(".olympic-games-list .games-list a.close ").click(); if (!next && this.DataPrev) { if (this.DataPrev.action == 'open' && state.action != 'close') $(".olympic-games-list .games-list a.close ").click(); else if (this.DataPrev.action == 'close' && state.action != 'open') $("#games").click(); } ISWidgetOlympicGames.History = true; } else if (state.type == 'calendarsport') { ISWidgetCalendarSport.History = false; if (state.action == 'open') $("#calendar a.calendar-toggle").click(); else if (state.action == 'close') $("#calendar a.calendar-toggle").click(); if (!next && this.DataPrev) { if (this.DataPrev.action == 'open' && state.action != 'close') $("#calendar a.calendar-toggle").click(); else if (this.DataPrev.action == 'close' && state.action != 'open') $("#calendar a.calendar-toggle").click(); } ISWidgetCalendarSport.History = true; } else if (state.type == 'olympicgames.page') { ISWidgetOlympicGames.History = false; if (state.action == 'open') $('a.og-constructor').click(); else if (state.action == 'close') $('a.og-constructor').click(); if (!next && this.DataPrev) { if (this.DataPrev.action == 'open' && state.action != 'close') $('a.og-constructor').click(); else if (this.DataPrev.action == 'close' && state.action != 'open') $('a.og-constructor').click(); } ISWidgetOlympicGames.History = true; } else if (state.type == 'regions.long-menu') { ISRegions.History = false; if (state.action == 'open') $("#long-menu a[data-eventtype=" + state.eventtype + "]").click(); else if (state.action == 'close') $(".region-popup .close").click(); if (!next && this.DataPrev) { if (this.DataPrev.action == 'open' && state.action != 'close') $(".region-popup .close").click(); else if (this.DataPrev.action == 'close' && state.action != 'open') $("#long-menu a[data-eventtype=" + state.eventtype + "]").click(); } ISRegions.History = true; } else if (state.type == 'constructor') { ISWidgetConstructor.History = false; if (state.action == 'open') $("#constructor").click(); else if (state.action == 'close') $(".constructor-popup .close").click(); if (!next && this.DataPrev) { if (this.DataPrev.action == 'open' && state.action != 'close') $(".constructor-popup .close").click(); else if (this.DataPrev.action == 'close' && state.action != 'open') $("#constructor").click(); } ISWidgetConstructor.History = true; } this.Step = step; this.SaveStep(); this.DataPrev = state; } else { if (this.DataPrev) { if (this.DataPrev.type == 'map') { ISWidgetMap.History = false; if (this.DataPrev.action == 'open') $(".map .close").click(); else if (this.DataPrev.action == 'close') $("#openMap").click(); ISWidgetMap.History = true; } else if (this.DataPrev.type == 'olympicgames') { ISWidgetOlympicGames.History = false; if (this.DataPrev.action == 'open') $(".olympic-games-list .games-list a.close ").click(); else if (this.DataPrev.action == 'close') $("#games").click(); ISWidgetOlympicGames.History = true; } else if (this.DataPrev.type == 'calendarsport') { ISWidgetCalendarSport.History = false; if (this.DataPrev.action == 'open') $("#calendar a.calendar-toggle").click(); else if (this.DataPrev.action == 'close') $("#calendar a.calendar-toggle").click(); ISWidgetCalendarSport.History = true; } else if (this.DataPrev.type == 'olympicgames.page') { ISWidgetOlympicGames.History = false; if (this.DataPrev.action == 'open') $('a.og-constructor').click(); else if (this.DataPrev.action == 'close') $('a.og-constructor').click(); ISWidgetOlympicGames.History = true; } else if (this.DataPrev.type == 'constructor') { ISWidgetConstructor.History = false; if (this.DataPrev.action == 'open') $(".constructor-popup .close").click(); else if (this.DataPrev.action == 'close') $("#constructor").click(); ISWidgetConstructor.History = true; } else if (this.DataPrev.type == 'person') { ISPerson.History = false; if (this.DataPrev) { if (this.DataPrev.action == 'open') $(".atlet-popup .close").click(); else if (this.DataPrev.action == 'close') ISPerson.AtletPopupToggle({ data: function (str) { return '' + th.DataPrev.id; } }); } ISPerson.History = true; } else if (this.DataPrev.type == 'organizations') { ISOrganizations.History = false; if (this.DataPrev) { if (this.DataPrev.action == 'open') $(".org-popup .close").click(); else if (this.DataPrev.action == 'close') ISOrganizations.OrgPopupToggle({ data: function (str) { return '' + th.DataPrev.id; } }); } ISOrganizations.History = true; } } this.DataPrev = null; } }, Push: function (data, title, url, hash) { data = data || {}; hash = hash ? '#' + hash : ''; this.Step++; localStorage.historystep = this.Step; data.historystep = localStorage.historystep; window.history.pushState(data, title, url + hash); this.DataPrev = data; this.SaveStep(); }, SaveStep: function () { $.cookie('ISHistory.Step', this.Step); } }; ISWidgetMap = { MapData: {}, //thematic layer RegionsByThematicLayer: {}, RegionsByEventTypes: null, Regions: {}, RegionsOrder: [], Params: { Show: false, UrlPage: '', OpenCount: 0 }, PersonsIdsByThematicLayer: { }, //PersonsByIdsTheme: {}, PersonsById: {}, Step: 0, SliderContext: null, SliderFirst: true, IsPersonView: false, IsMapSelected: false, History: true, Init: function () { if (!ISPerson.IsInit) ISPerson.Init(); var thisclass = this; thisclass.Params.UrlPage = document.location + ''; thisclass.InitLoadData(); $(".moduleopenmap").click(function () { thisclass.History = false; $("#openMap").click(); return true; }); $("#openMap").unbind('click'); $("#openMap").click(function () { $('body').addClass('open-map'); var h = thisclass.History; thisclass.History = false; $("#canvasLayer").unbind('mouseover'); thisclass.SliderFirst = true; thisclass.Close(false); thisclass.Open(); thisclass.History = h; if (thisclass.History) ISHistory.Push({ type: 'map', action: 'open' }, 'Российские спортсмены и специалисты', thisclass.Params.UrlPage); $(window).scrollTop(150); $.ajax({ url: "/ajax/visit?v=" + ISCommon.GetV(), data: { G: ISCommon.Guid, Url: this.Url, MId: -11 }, success: function (d) { if (d.result == 'yes' && ISCommon.Guid == '') ISCommon.SetGuid(d.guid); } }); return false; }); $(".map .close").unbind('click'); $(".map .close").click(function () { $('body').removeClass('open-map'); thisclass.Close(true); if (thisclass.History) ISHistory.Push({ type: 'map', action: 'close' }, 'Российские спортсмены и специалисты', thisclass.Params.UrlPage); return false; }); if ($('#region-small').length) $('#region-small').selectik({ width: 227, heightContainer: 400, customScroll: 0, speedAnimation: 100, smartPosition: true, }); $('#imageMap').click(function () { $("#map #region").data("selectik").changeCS({ value: 0 }); $('.tooltipadditional').remove(); }); $('map#mapWrap area').click(function () { if (true || $('#tematic_layer').val() > 0) { if ($("#map #region").val() == $(this).data('key')) { //document.location = '/regions/' + $(this).data('key'); } else { $("#map #region").data("selectik").changeCS({ value: $(this).data('key') }); } if ($.inArray($(this).attr('data-key'), thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) == -1) { $("#map #region").data("selectik").changeCS({ value: 0 }); $('.tooltipadditional').remove(); } } else if ($(this).data('key') > 0 && ($('#tematic_layer').val() == 0 || $.inArray($(this).attr('data-key'), thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1)) { //document.location = '/regions/' + $(this).data('key') + '#t' + $('#tematic_layer').val(); } return false; }); $('div.map-area').on('mouseout', function (e) { if ($(e.relatedTarget).is('#map area') && $.inArray($(e.relatedTarget).attr('data-key'), thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) { } else { if ($('.big-slide').is(':visible')) if (/*$('#tematic_layer').val() > 0 &&*/ $("#map #region").val() > 0) { if ($('.big-slide').data('eq') > 0) thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(thisclass.Step)); } else { thisclass.SliderHide(); } if ($('.tooltipadditional').is(':visible')) { if (/*$('#tematic_layer').val() == '0' ||*/ $("#map #region").val() == 0) { $('.tooltipadditional').remove(); } } } }); $('#canvasLayer').unbind('click'); $('#canvasLayer').click(function () { $("#map #region").data("selectik").changeCS({ value: '0' }); }); $('#canvasLayer').on('mouseover mousemove', function (e) { if ($('.big-slide').is(':visible')) if (/*$('#tematic_layer').val() > 0 &&*/ $("#map #region").val() > 0) { if ($('.big-slide').data('eq') > 0) thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(thisclass.Step)); } else { thisclass.SliderHide(); } if ($('.tooltipadditional').is(':visible')) { if (/*$('#tematic_layer').val() == 0 ||*/ $("#map #region").val() == 0) { $('.tooltipadditional').remove(); } } }); //thisclass.InitCities(); //thisclass.InitSlider(); var canvas = document.getElementById('canvasLine'); thisclass.SliderContext = canvas.getContext('2d'); $('#help-view').hover( function () { console.log('hover'); $('.theme-help').addClass('view'); }, function () { console.log('end'); $('.theme-help').removeClass('view'); } ); }, InitLoadData: function () { var thisclass = this; ISCatalogs.SportDownload(); $('#map #region option').each(function () { thisclass.RegionsOrder.push($(this).val()); }); $.ajax({ url: "/ajax/regionsformaprussia", data: {}, success: function (d) { thisclass.Regions = d.Regions; thisclass.InitFilter(); if (thisclass.Params.Show || window.location.hash == '#openmap') $("#openMap").click(); } }); }, InitFilter: function () { var thisclass = this; if ($('#map #tematic_layer').length) { $('#map #tematic_layer').selectik({ width: 572, heightContainer: 400, customScroll: 0, speedAnimation: 100, smartPosition: true, wrapperObject: $("#map") }); $('#map #tematic_layer').change(function () { var ThematicLayerId = $('#map #tematic_layer').val(); if ( //ThematicLayerId == 0 || ( thisclass.RegionsByThematicLayer && typeof thisclass.RegionsByThematicLayer[ThematicLayerId] != "undefined" && thisclass.RegionsByThematicLayer[ThematicLayerId].length > 0 ) ) { //console.log('556 - ISWidgetMap.ChangeTematicLayer();'); ISWidgetMap.ChangeTematicLayer(); } else { ISWidgetMap.LoadTematicLayer(ThematicLayerId); } }); $('#map #region').selectik({ width: 205, heightContainer: 400, customScroll: 0, speedAnimation: 100, smartPosition: true, wrapperObject: $("#map"), }); $('#map #region').change(function () { $('#imageMap').mapster('set', true, $(this).val()); thisclass.ViewPersonsByTheme(); $('#mapWrap area').mapster('deselect'); if ($(this).val() > 0) thisclass.SelectAreas([$(this).val()]); else thisclass.SelectAreas(thisclass.RegionsByThematicLayer[$('#map #tematic_layer').val()]); if (thisclass.History) ISHistory.Push( { type: 'map', action: 'changeregion', region: $('#map #region').val(), tematic: $('#tematic_layer').val() }, 'Российские спортсмены и специалисты', thisclass.Params.UrlPage ); }); $('#map #region').parent().hide(); //$("#tematic_layer").data("selectik").changeCS({ value: '2' }); } }, InitCities: function () { var thisclass = this; // тултип город Москва $(".moscow-star").on('mouseover', function () { var area = $('#mapWrap').find('area[data-state="Moscow"]'); if ($('#tematic_layer').val() == 0 || $.inArray(area.attr('data-key'), thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) == -1) area.mapster('deselect'); if ($('#tematic_layer').val() == 0 || $.inArray('77', thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) { thisclass.ShowTooltip('moscow-city', $(this).offset().left + $('#imageMap').position().left, $(this).offset().top + $('#imageMap').position().top, thisclass.Regions['77'].Name, thisclass.Regions['77'].Description ); $("a.moscow-star").removeClass('notactive'); //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') if ($('#tematic_layer').val() > 0) thisclass.ViewPersonsByTheme('77'); } else $("a.moscow-star").addClass('notactive'); }); $(".moscow-star").click(function () { //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') { if ($('#tematic_layer').val() > 0) { if ($("#map #region").val() == $(this).data('key')) return true; else $("#map #region").data("selectik").changeCS({ value: $(this).data('key') }); } else if ($('#tematic_layer').val() == 0 || $.inArray('77', thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) return true; return false; }); $(".moscow-star").on('mouseout', function () { thisclass.CloseTooltip('moscow-city'); //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') if ($('#tematic_layer').val() > 0) thisclass.ViewPersonsByTheme(); }); // тултип Севастополь $(".sevastopol").on('mouseover', function () { var area = $('#mapWrap').find('area[data-state="Krym"]'); if ($('#tematic_layer').val() == 0 || $.inArray(area.attr('data-key'), thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) == -1) area.mapster('deselect'); if ($('#tematic_layer').val() == 0 || $.inArray('103', thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) { thisclass.ShowTooltip( 'sevastopol', $(this).offset().left + $('#imageMap').position().left - 7, $(this).offset().top + $('#imageMap').position().top - 20, thisclass.Regions['103'].Name, thisclass.Regions['103'].Description ); $("a.city-dot.sevastopol").removeClass('notactive'); //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') if ($('#tematic_layer').val() > 0) thisclass.ViewPersonsByTheme('103'); } else $("a.city-dot.sevastopol").addClass('notactive'); }); $(".sevastopol").on('mouseout', function () { thisclass.CloseTooltip('sevastopol'); if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') thisclass.ViewPersonsByTheme(); }); $(".sevastopol").click(function () { //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') { if ($('#tematic_layer').val() > 0) { if ($("#map #region").val() == $(this).data('key')) return true; else $("#map #region").data("selectik").changeCS({ value: $(this).data('key') }); } else if ($('#tematic_layer').val() == 0 || $.inArray('103', thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) return true; return false; }); //тултип Питер $(".piter").on('mouseover', function () { var area = $('#mapWrap').find('area[data-state="Leningrad"]'); if ($('#tematic_layer').val() == 0 || $.inArray(area.attr('data-key'), thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) == -1) area.mapster('deselect'); if ($('#tematic_layer').val() == 0 || $.inArray('78', thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) { thisclass.ShowTooltip( 'piter', $(this).offset().left + $('#imageMap').position().left - 7, $(this).offset().top + $('#imageMap').position().top - 20, thisclass.Regions['78'].Name, thisclass.Regions['78'].Description ); $("a.piter").removeClass('notactive'); //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') if ($('#tematic_layer').val() > 0) thisclass.ViewPersonsByTheme('78'); } else $("a.piter").addClass('notactive'); }); $(".piter").on('mouseout', function () { thisclass.CloseTooltip('piter'); if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') thisclass.ViewPersonsByTheme(); }); $(".piter").click(function () { //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') { if ($('#tematic_layer').val() > 0) { if ($("#map #region").val() == $(this).data('key')) return true; else $("#map #region").data("selectik").changeCS({ value: $(this).data('key') }); } else if ($('#tematic_layer').val() == 0 || $.inArray('78', thisclass.RegionsByThematicLayer[$('#tematic_layer').val()]) > -1) return true; return false; }); }, InitSlider: function (Step) { var thisclass = this; var sliderWrap = $(".slider .slider-wrap-autowidth"); if (sliderWrap.length) { var slide = sliderWrap.find('.slide'); var slideWidth = slide.outerWidth() + 6; var firstPosition = sliderWrap.position().left; var endPosition = slide.length * slideWidth - ($("#container").width() - 35); thisclass.Step = Step; sliderWrap.animate({ left: -slideWidth * thisclass.Step }); $(".slider a.left").css({ opacity: 0 }); if ($('#map .slider-wrap-autowidth .slide').length > 11) $(".slider a.right").css({ opacity: 1 }); else $(".slider a.right").css({ opacity: 0 }); $(".slider a.left").unbind('click'); $(".slider a.left").click(function () { if ($('#map .slider-wrap-autowidth .slide').length > 11) $(".slider a.right").animate({ opacity: 1 }); if (thisclass.Step > 0) thisclass.Step--; if (thisclass.Step == 0) $(this).animate({ opacity: 0 }); sliderWrap.stop(true); sliderWrap.animate({ left: -slideWidth * thisclass.Step, complete: function () { if ($('#tematic_layer').val() > 0 && $("#map #region").val() > 0 && $('.big-slide').data('eq') > 0) thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(thisclass.Step + 1)); } }); return false; }); $(".slider a.right").unbind('click'); $(".slider a.right").click(function () { if ($('#map .slider-wrap-autowidth .slide').length > 11) $(".slider a.left").animate({ opacity: 1 }); thisclass.Step = thisclass.Step + 11 < $('#map .slider-wrap-autowidth .slide').length ? thisclass.Step + 1 : thisclass.Step; if (thisclass.Step + 11 == $('#map .slider-wrap-autowidth .slide').length) $(this).animate({ opacity: 0 }); sliderWrap.stop(true); sliderWrap.animate({ left: -slideWidth * thisclass.Step, complete: function () { if ($('#tematic_layer').val() > 0 && $("#map #region").val() > 0 && $('.big-slide').data('eq') > 0) thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(thisclass.Step + 1)); } }); return false; }); var cLayer = $("#canvasLayer"); cLayer.css({ 'top': (-$('#map').offset().top) + 'px', 'left': (-$('#map').offset().left) + 'px' }); var cLayerHeight = $(document).height(); cLayer.width($(document).width()); cLayer.height(cLayerHeight); $("#canvasLine").height(cLayerHeight); $("#canvasLine").width($(document).width()); $("#canvasLine").attr('width', cLayer.width()); $("#canvasLine").attr('height', cLayerHeight); //var canvas = document.getElementById('canvasLine'); //thisclass.SliderContext = canvas.getContext('2d'); thisclass.SliderContext.lineWidth = 2; thisclass.SliderContext.strokeStyle = '#fff'; var bigSlide = $(".big-slide"); var bigSlideDescription = bigSlide.find('.description'); var bigSlideImage = bigSlide.find('.image'); bigSlide.hide(); thisclass.IsPersonView = false; var endX = 0; var endY = 0; sliderWrap.find("a.slide").unbind('mouseover'); sliderWrap.find("a.slide").on('mouseover', function () { thisclass.SliderShow($(this)); }); bigSlide.unbind('mouseout'); bigSlide.on('mouseout', function (e) { if ($(e.relatedTarget).is('.big-slide,.big-slide div,.big-slide div img, .big-slide div span, .atlet-popup-bg')) return false; $(this).hide(); cLayer.hide(); thisclass.SliderContext.clearRect(0, 0, 2000, 2000); $('.tooltipadditional').remove(); if ($('#map #region').val() > 0 && $('#map .slider-wrap-autowidth a.slide').length) //thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(0)); thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(thisclass.Step)); return; }); } }, LoadTematicLayer: function (ThematicLayerId) { var thisclass = this; $.ajax({ url: "/ajax/thematiclayerformaprussia", data: { ThematicLayerId: ThematicLayerId }, success: function (d) { thisclass.RegionsByThematicLayer[d.ThematicLayerId] = []; for (var i = 0; i < d.PersonsSearchMini.length; i++) { if (typeof thisclass.PersonsIdsByThematicLayer[d.ThematicLayerId] == "undefined") thisclass.PersonsIdsByThematicLayer[d.ThematicLayerId] = [d.PersonsSearchMini[i].Id]; else if ($.inArray(d.PersonsSearchMini[i].Id, thisclass.PersonsIdsByThematicLayer[d.ThematicLayerId]) == -1) thisclass.PersonsIdsByThematicLayer[d.ThematicLayerId].push([d.PersonsSearchMini[i].Id]); thisclass.PersonsById[d.PersonsSearchMini[i].Id] = d.PersonsSearchMini[i]; if (d.PersonsSearchMini[i].RegionsIds.length > 0) { for (var js = 0; js < d.PersonsSearchMini[i].RegionsIds.length; js++) if ($.inArray(d.PersonsSearchMini[i].RegionsIds[js] + '', thisclass.RegionsByThematicLayer[d.ThematicLayerId]) == -1) thisclass.RegionsByThematicLayer[d.ThematicLayerId].push(d.PersonsSearchMini[i].RegionsIds[js] + ''); if (d.PersonsSearchMini[i].BRegionId > 0 && $.inArray(d.PersonsSearchMini[i].BRegionId + '', thisclass.RegionsByThematicLayer[d.ThematicLayerId]) == -1) thisclass.RegionsByThematicLayer[d.ThematicLayerId].push(d.PersonsSearchMini[i].BRegionId + ''); if (d.PersonsSearchMini[i].RegionId > 0 && $.inArray(d.PersonsSearchMini[i].RegionId + '', thisclass.RegionsByThematicLayer[d.ThematicLayerId]) == -1) thisclass.RegionsByThematicLayer[d.ThematicLayerId].push(d.PersonsSearchMini[i].RegionId + ''); } } //console.log(thisclass.RegionsByThematicLayer[d.ThematicLayerId]); ISWidgetMap.ChangeTematicLayer(); } }); }, ChangeTematicLayer: function () { var thisclass = this; var ThematicLayerId = $('#map #tematic_layer').val(); $('#mapWrap area').mapster('deselect'); $("#map #region").empty(); $("#map #region").append(" "); if (true || ThematicLayerId > 0) { if (thisclass.RegionsByThematicLayer[ThematicLayerId] != undefined && thisclass.RegionsByThematicLayer[ThematicLayerId].length > 0) { thisclass.SelectAreas(thisclass.RegionsByThematicLayer[ThematicLayerId]); for (var i = 0; i < thisclass.RegionsOrder.length; i++) { if ($.inArray(thisclass.RegionsOrder[i], thisclass.RegionsByThematicLayer[ThematicLayerId]) > -1) $("#map #region").append(" "); } } } else { var regionsId = []; for (var i = 0; i < thisclass.RegionsOrder.length; i++) { if (i == 0) { //$("#map #region").append(" "); } else $("#map #region").append(" "); } thisclass.Close(false); } $('#map #region').parent().show(); var H = thisclass.History; thisclass.History = false; $("#map #region").data("selectik").refreshCS(); $("#map #region").data("selectik").changeCS({ value: '0' }); thisclass.History = H; if (thisclass.RegionsByThematicLayer[ThematicLayerId] != undefined && $.inArray('77', thisclass.RegionsByThematicLayer[ThematicLayerId]) > -1) $("a.moscow-star").addClass('active'); else $("a.moscow-star").removeClass('active'); if (thisclass.RegionsByThematicLayer[ThematicLayerId] != undefined && $.inArray('78', thisclass.RegionsByThematicLayer[ThematicLayerId]) > -1) $("a.piter").addClass('active'); else $("a.piter").removeClass('active'); if (thisclass.RegionsByThematicLayer[ThematicLayerId] != undefined && $.inArray('103', thisclass.RegionsByThematicLayer[ThematicLayerId]) > -1) $("a.sevastopol").addClass('active'); else $("a.sevastopol").removeClass('active'); $("#map .layers .select-list ul").each(function () { var th = $(this); $(this).parents('.custom-select').find('.custom-text').click(function () { th.getNiceScroll().resize(); }); $(this).niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', railoffset: { top: -3 } }); }); //thisclass.ViewPersonsByTheme(); if (thisclass.History) ISHistory.Push({ type: 'map', action: 'changetematic', region: $('#map #region').val(), tematic: $('#tematic_layer').val() }, 'Российские спортсмены и специалисты', thisclass.Params.UrlPage ); }, SliderShow: function (el) { if ($(".big-slide").length) $(".big-slide").css('top', $(".map .slider").offset().top - 165); var thisclass = this; var scale = $('#imageMap').width() / 1001; thisclass.SliderContext.clearRect(0, 0, 2000, 2000); var cLayer = $("#canvasLayer"); var bigSlide = $(".big-slide"); var bigSlideDescription = bigSlide.find('.description'); var bigSlideImage = bigSlide.find('.image'); var description = el.find('.description').html(); var bigPhoto = el.find('.photo').attr('big-photo-src'); bigSlideDescription.html(description); bigSlideImage.html(el.data('isnotallowed') == 1 ? '
' : ''); bigSlide.css({ left: el.offset().left - $('#map').offset().left - 44 }); bigSlide.attr('data-personid', el.data('personid')); bigSlide.data('personid', el.data('personid')); var eqnumber = $('#map .slider-wrap-autowidth a.slide').index(el); bigSlide.attr('data-eq', eqnumber); bigSlide.data('eq', eqnumber); bigSlide.show(); thisclass.IsPersonView = true; $("a.big-slide").unbind('click'); $("a.big-slide").click(function () { ISPerson.AtletPopupToggle($(this)); ISPerson.PersonClick($(this).data('personid')); return false; }); var startX = bigSlide.offset().left + 90; var startY = bigSlide.offset().top + 90; var rstr = el.data('regionid') ? el.data('regionid') + '' : ''; var endX = []; var endY = []; var endR = []; if (rstr != '' && rstr.split(',').length > 0) { for (i = 0; i < rstr.split(',').length; i++) { var rid = parseInt(rstr.split(',')[i]); if (rid == 78) { endX.push($('a.piter').offset().left + ($('a.piter').width() / 2)); endY.push($('a.piter').offset().top + ($('a.piter').height() / 2)); endR.push(rid); } else if (rid == 77) { endX.push($('a.moscow-star').offset().left + ($('a.moscow-star').width() / 2)); endY.push($('a.moscow-star').offset().top + ($('a.moscow-star').height() / 2)); endR.push(rid); } else if (rid == 103) { endX.push($('a.sevastopol').offset().left + ($('a.sevastopol').width() / 2)); endY.push($('a.sevastopol').offset().top + ($('a.sevastopol').height() / 2)); endR.push(rid); } else if (rid > 0) { var area = $(".map-area area[data-key=" + rid + "]"); var position = []; if (area.data('centrexy') != '' && area.data('centrexy').split(',').length == 2) position = area.data('centrexy').split(','); else position = area.attr('coords').split(','); endX.push($(".map-area").offset().left + parseInt(position[0] * scale)); endY.push($(".map-area").offset().top + parseInt(position[1] * scale)); endR.push(rid); } } } cLayer.show(); thisclass.SliderContext.beginPath(); $('.tooltipadditional').remove(); if (endX.length > 0) { for (var i = 0; i < endX.length; i++) { thisclass.SliderContext.moveTo(startX, startY); thisclass.SliderContext.lineTo(endX[i], endY[i]); if (!thisclass.IsMapSelected || ($.inArray(50, endR) > -1 && $('#maptooltipr50').length == 0)) { thisclass.ShowTooltip('maptooltipr' + endR[i], endX[i], endY[i], thisclass.Regions[endR[i]].Name, thisclass.Regions[endR[i]].Description ); } } } thisclass.SliderContext.stroke(); return; }, SliderHide: function () { $("a.big-slide").hide(); $('.tooltipadditional').remove(); this.SliderContext.clearRect(0, 0, 2000, 2000); }, Open: function () { var thisclass = this; //if (thisclass.RegionsByEventTypes == null || thisclass.PersonsById == null) {} $(".big-slide").hide(); thisclass.SliderContext.clearRect(0, 0, 2000, 2000); $("#tematic_layer").data("selectik").changeCS({ value: $('#map.map').data('maxyear') + '' }); return false; }, ViewPersonsByThemeLock: 123456, ViewPersonsByThemeStep:10, ViewPersonsByTheme: function (regionid) { var thisclass = this; thisclass.Step = 0; regionid = regionid ? regionid : $('#map #region').val(); regionid = regionid ? regionid : 0; if (/*$('#tematic_layer').val() > 0 && */ typeof thisclass.PersonsIdsByThematicLayer[$('#tematic_layer').val()] != "undefined") { $('#map .slider').show(); $('#map .slider-wrap-autowidth').html('').css('left', '0px'); if (2 == $('#tematic_layer').val()) $('.asterisk-legend').show(); else $('.asterisk-legend').hide(); if (regionid > 0) { var countr = 0; for(var i=0;i 0 && $.inArray(parseInt(regionid), p.RegionsIds) > -1) || p.BRegionId == regionid || p.RegionId == regionid) countr++; } } $('#map .slider .count span').html(countr + ' человек'); } else $('#map .slider .count span').html(thisclass.PersonsIdsByThematicLayer[$('#tematic_layer').val()].length + ' человек'); thisclass.ViewPersonsByThemeLock = Math.random(); thisclass.ViewPersonsByThemeAdd(regionid, 0, thisclass.ViewPersonsByThemeStep, thisclass.ViewPersonsByThemeLock); } else { $('#map a.big-slide').hide(); $('#map .slider').hide(); $("#canvasLayer").hide(); $('.tooltipadditional').remove(); } }, ViewPersonsByThemeAdd: function (regionid, min, max, lock) { var thisclass = this; if (thisclass.ViewPersonsByThemeLock != lock) return false; var regionidint = parseInt(regionid); var pLength = thisclass.PersonsIdsByThematicLayer[$('#tematic_layer').val()].length; if (min < pLength) { if (max > pLength) max = pLength; if (regionidint > 0 && regionidint != 77 && regionidint != 50 && regionidint != 78 && min == 0 && max == thisclass.ViewPersonsByThemeStep) { min = 0; max = thisclass.PersonsIdsByThematicLayer[$('#tematic_layer').val()].length; } for (var i = min; i < max; i++) if (thisclass.PersonsById[thisclass.PersonsIdsByThematicLayer[$('#tematic_layer').val()][i]] != undefined) { var p = thisclass.PersonsById[thisclass.PersonsIdsByThematicLayer[$('#tematic_layer').val()][i]]; if ("0" == regionid || (p.RegionsIds.length > 0 && $.inArray(parseInt(regionid), p.RegionsIds) > -1) || regionid == p.RegionId || regionid == p.BRegionId) { var regions = regionidint > 0 ? regionidint : p.RegionsIds.join() + ',' + p.RegionId + ',' + p.BRegionId; var photocolor = p.Photo ? '/content/uploads/personalities/133xAny/' + p.Photo : ( p.PicFile != null && p.PicFile != '' ? '/content/uploads/personalities/original/' + p.PicFile : '/content/images/person_no_photo.jpg' ); var sport = p.SportIds.length > 0 && ISCatalogs.SportGet(p.SportIds[0]) ? ISCatalogs.SportGet(p.SportIds[0]).Name : ''; var a = $('', { 'class': 'slide', href: '#', 'data-personid': p.Id, 'data-regionid': regions, 'data-isnotallowed': p.IsNotAllowed && 2 == $('#tematic_layer').val() ? '1' : '0' }) .append( $('
', { 'class': 'photo', 'big-photo-src': photocolor, 'style': 'width:88px;height:99px;overflow:hidden;' }) .append(p.IsNotAllowed && 2 == $('#tematic_layer').val() ? $('
') : '') .append($('', { 'src': photocolor, width: '100%', height: 'auto' })) ) .append( $('
', { 'class': 'description' }) .append($('', { 'class': 'fio', text: p.FName + ' ' + p.LName })) .append($('', { 'class': 'sport', text: sport })) .append($('
', { 'class': 'clear' })) ); if (thisclass.ViewPersonsByThemeLock == lock) $('#map .slider-wrap-autowidth').append(a); } } if ((regionidint == 0 || 77 == regionidint || 50 == regionidint || 78 == regionidint) && thisclass.ViewPersonsByThemeLock == lock && max < 300) setTimeout( function () { thisclass.ViewPersonsByThemeAdd(regionid, min + thisclass.ViewPersonsByThemeStep, max + thisclass.ViewPersonsByThemeStep, lock); }, 1 ); if (max == pLength || max == 20 || max == 50 || max == 100 || max == 200 || max == 300) { thisclass.InitSlider(thisclass.Step); thisclass.InitCities(); if (regionid > 0 && $('#map .slider-wrap-autowidth a.slide').length) thisclass.SliderShow($('#map .slider-wrap-autowidth a.slide').eq(0)); } } }, ShowTooltip: function (id, x, y, title, data) { if ($(this).is(':visible')) return false; var html = this.BuildToolTipAreaForPerson(id, title, data, true); html = '
' + html + '
'; html = $(html); if (html.find('p:first').length > 0) html.find('p:first').remove(); if (html.find('p:first').length > 0) html.find('p:first').remove(); $('#map').append(html); if ('moscow-city' == id || 'piter' == id || 'sevastopol' == id) html.css({ 'top': y - html.outerHeight() - 106, 'left': x - $('#map').offset().left - 40 }); else { html.css({ 'left': x - $('#map').offset().left - 51 }); html.css({ 'top': y - $('#' + id).outerHeight() - 149 }); } }, CloseTooltip: function (id) { $("#" + id).remove(); }, BuildAreas: function () { var thisclass = this; var items = $('#mapWrap').find('area'); var areaArray = []; if (thisclass.Regions != null) { items.each(function () { var areaName = $(this).attr('data-key'); var fullName = (thisclass.Regions[areaName]) ? thisclass.Regions[areaName].Name : ''; fullName = fullName || 'Нет данных'; var fullData = (thisclass.Regions[areaName]) ? thisclass.Regions[areaName].Description : ''; fullData = fullData || 'Нет данных'; areaArray.push({ key: areaName, toolTip: thisclass.BuildToolTipArea(areaName, fullName, fullData) }); }); } return areaArray; }, BuildToolTipAreaForPerson: function (name, fullName, fullData, htmlOnly) { if (htmlOnly) return '
' + fullName + '
' + fullData + '
'; else return $('
' + fullName + '
' + fullData + '
'); }, BuildToolTipArea: function (name, fullName, fullData, htmlOnly) { //if ($('#tematic_layer').val() == '1000' || $('#tematic_layer').val() == '2000' || $('#tematic_layer').val() == '3000') return ''; /* if (htmlOnly) { return '
' + fullName + '
' + fullData + '
'; } else { return $('
' + fullName + '
' + fullData + '
'); } */ }, OnMouseover: function (area) { var thisclass = ISWidgetMap; if (area.selected) { thisclass.ViewPersonsByTheme(area.key); thisclass.IsMapSelected = true; } }, OnMouseout: function (area) { var thisclass = ISWidgetMap; thisclass.IsMapSelected = false; if (area.selected) { thisclass.ViewPersonsByTheme(); } }, SelectAreas: function (areas) { var thisclass = this; if (areas.length) { var toRebind = []; $('#mapWrap').find('area').each(function () { var areaName = $(this).attr('data-key'); var fullName = (thisclass.Regions[areaName]) ? thisclass.Regions[areaName].Name : ''; fullName = fullName || 'Нет данных'; var fullData = (thisclass.Regions[areaName]) ? thisclass.Regions[areaName].Description : ''; fullData = fullData || 'Нет данных'; var highlight = ($.inArray(areaName, areas) > -1) ? true : false; if ($('#map #region').val() > 0) highlight = $('#region').val() == areaName ? true : false; $('#mapWrap area[data-key=' + areaName + ']').css('cursor', highlight ? 'pointer' : 'default'); if (highlight) { toRebind.push({ key: areaName, toolTip: thisclass.BuildToolTipArea(areaName, fullName, fullData) //,onMouseout: thisclass.BuildToolTipAreaClose(areaName, fullName, fullData) }); } else { // обработка зон которые выделять нельзя toRebind.push({ key: areaName, highlight: false }); } }); // переопределение карты $('#imageMap').mapster('rebind', { fillColor: '2c95e6', mapKey: 'data-key', mapValue: 'data-full', fillOpacity: 1, stroke: true, strokeColor: '2c95e6', strokeOpacity: 1, strokeWidth: 4, isSelectable: false, showToolTip: true, toolTipClose: ['area-mouseout', 'tooltip-click'], toolTipContainer: '
', //onMouseout: thisclass.BuildToolTipAreaClose, onMouseover: thisclass.OnMouseover, onMouseout: thisclass.OnMouseout, areas: toRebind }).mapster('set', true, areas); } return; }, Close: function (close) { var thisclass = this; close = (close == undefined) ? false : close; if (close) { $(".map").hide(); $(".map-bg").hide(); $("#openMap").show(); $(".logo").html(''); $('.header-wrap input.submit-search').css({ 'background': '#314c83', color: '#e5e5e3' }); thisclass.Params.Show = false; } else { $("#openMap").hide(); thisclass.Params.Show = true; $(".map").show(); $(".map-bg").show(); $('#imageMap').mapster({ fillColor: '2c95e6', mapKey: 'data-key', mapValue: 'data-full', fillOpacity: 1, stroke: true, strokeColor: '2c95e6', strokeOpacity: 1, strokeWidth: 4, isSelectable: false, showToolTip: true, toolTipClose: ['area-mouseout', 'tooltip-click'], toolTipContainer: '
', areas: thisclass.BuildAreas(), }).mapster( 'set', true, //'KALININGRAD,SMOLENSK,KALUGA,NE,NA,JAMNE,KRASNOYARSK,YAKUTIYA,HABAROVSK,SAHALIN,CHUKOTKA,KAMCHATKA'); 'NA').mapster('resize', $("#content").width()); $(".logo").html(''); $('.header-wrap input.submit-search').css({ 'background': '#939395', color: '#fff' }); ISWidgetMap.Resize(); $(window).on('resize', function () { ISWidgetMap.Resize(); }); $("#map .layers .select-list ul").each(function () { var th = $(this); $(this).parents('.custom-select').find('.custom-text').click(function () { th.getNiceScroll().resize(); }); $(this).niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', railoffset: { top: -3 } }); }); } if (!close) { if (ISWidgetCalendarSport.Run) ISWidgetCalendarSport.Toggle(true); ISWidgetOlympicGames.Close(true); ISWidgetConstructor.Close(true); } }, Message: function (a) { $('#canvasLayer .message').click(function () { $(this).html(''); }); $('#canvasLayer .message').html($('#canvasLayer .message').html() + ' | ' + a); }, Resize: function () { if ($(".map-area").length && $(".map-area").width() < 1000) $('#imageMap').mapster('resize', $(".map-area").width() - 20); else $('#imageMap').mapster('resize', $(".map-area").width()); var newWidth = $(".map").width() - 78; var rest = newWidth - Math.round(newWidth / 110) * 110; $(".map .slider-wrap").width(newWidth - rest).css('marginLeft', rest); if ($(".big-slide").length) $(".big-slide").css('top', $(".map .slider").offset().top - 165); this.IsMapSelected = true; this.ViewPersonsByTheme(); } } ISWidgetOlympicGames = { TotalWidth: 0, OneSlide: 204, StartPosition: 0, Id: 0, Type: '', UrlPage: '', History: true, Init: function () { var thisclass = this; thisclass.UrlPage = document.location + ''; if ($('#olympic-games-list').length > 0) { var sliderParent = $('#olympic-games-list'); var slider = sliderParent.find('.list'); thisclass.StartPosition = slider.position().left; var leftBtn = sliderParent.find('.left'); var rightBtn = sliderParent.find('.right'); slider.find('.list-element').each(function () { thisclass.TotalWidth += thisclass.OneSlide;//$(this).outerWidth(true); }); leftBtn.unbind('click'); leftBtn.click(function () { if (!slider.hasClass('active')) { var pos = slider.position().left; var th = $(this); if (pos < thisclass.StartPosition) { if (pos + thisclass.OneSlide >= thisclass.StartPosition) { $(this).addClass('inactive'); } rightBtn.removeClass('inactive'); slider.addClass('active'); slider.animate({ left: pos + thisclass.OneSlide }, function () { slider.removeClass('active'); }); } } return false; }); rightBtn.unbind('click'); rightBtn.click(function () { if (!slider.hasClass('active')) { var pos = slider.position().left; if ((pos + thisclass.TotalWidth - thisclass.OneSlide) > ($(".content").width() - leftBtn.outerWidth() - rightBtn.outerWidth())) { if ((pos + thisclass.TotalWidth - thisclass.OneSlide * 2) <= ($(".content").width() - leftBtn.outerWidth() - rightBtn.outerWidth())) { rightBtn.addClass('inactive'); } leftBtn.removeClass('inactive'); slider.addClass('active'); slider.animate({ left: pos - thisclass.OneSlide }, function () { slider.removeClass('active'); }); } } return false; }); $('#olympic-games-list, #olympic-games-list *').hammer().bind('swipeleft', function () { rightBtn.click(); }).bind('swiperight', function () { leftBtn.click(); }); var ch = 0; var chall = $("#olympic-games-list .list-element img").length; $("#olympic-games-list .list-element img").each(function () { var percent = 21; // разница между уменьшенным и увеличенным лого, относительно большого var origWidth = 151; var newWidth = origWidth - ((origWidth / 100) * percent); var th = $(this); var parent = th.parent(); var parPar = parent.parent(); var link = parPar.parent(); $(this).width(newWidth); var isDown = link.hasClass('down'); var parentWidth = parent.width(); var newParentWidth = parentWidth - ((parentWidth / 100) * percent); var parentMarginLeft = (((parentWidth / 100) * percent) / 2); var parentHeight = parent.height(); var newParentHeight = parentHeight - ((parentHeight / 100) * percent); var parentMarginTop = 0 - (((parentHeight / 100) * percent)); var origParparTop = (isDown) ? parseInt(parPar.css('bottom')) : parseInt(parPar.css('top')); parent.css({ width: newParentWidth, marginLeft: parentMarginLeft, height: newParentHeight, lineHeight: newParentHeight + 'px' }); if (isDown) { parPar.css({ bottom: origParparTop - parentMarginTop, position: 'absolute' }); } else { //parent.css({width: newParentWidth, marginLeft: parentMarginLeft, height:newParentHeight, lineHeight: newParentHeight + 'px'}); parPar.css({ top: origParparTop - parentMarginTop, position: 'absolute' }); } link.hover(function () { th.stop().animate({ width: origWidth }); parent.stop().animate({ width: parentWidth, height: parentHeight, lineHeight: parentHeight + 'px', marginLeft: 0, marginTop: 0 }) if (isDown) { parPar.stop().animate({ 'bottom': origParparTop }); } else { parPar.stop().animate({ 'top': origParparTop }); } }, function () { th.stop().animate({ width: newWidth }); parent.stop().animate({ width: newParentWidth, height: newParentHeight, lineHeight: newParentHeight + 'px', marginLeft: parentMarginLeft }); if (isDown) { parPar.stop().animate({ 'bottom': origParparTop - parentMarginTop }); } else { parPar.stop().animate({ 'top': origParparTop - parentMarginTop }); } }); link.click(function () { //return false; }); ch++; if (thisclass.Id > 0 && thisclass.Id == link.data('olympicdageid')) { var left = 0; if (ch < 5) { left = ch; } else if (ch + 2 < chall) { left = ch - 2; leftBtn.removeClass('inactive'); } else { left = ch - 4 + (chall - ch); leftBtn.removeClass('inactive'); rightBtn.addClass('inactive'); } slider.animate({ left: 105 - (left - 1) * thisclass.OneSlide }, function () { }); th.stop().animate({ width: origWidth }); parent.stop().animate({ width: parentWidth, height: parentHeight, lineHeight: parentHeight + 'px', marginLeft: 0, marginTop: 0 }) if (isDown) { parPar.stop().animate({ 'bottom': origParparTop }); } else { parPar.stop().animate({ 'top': origParparTop }); } } }); $("#games").unbind('click'); $("#games").click(function () { thisclass.Close(); if (thisclass.History) ISHistory.Push({ type: 'olympicgames', action: 'open' }, 'Хронологическая лента Олимпийских игр', thisclass.UrlPage); return false; }); $(".olympic-games-list .games-list a.close ").unbind('click'); $(".olympic-games-list .games-list a.close ").click(function () { thisclass.Close(true); if (thisclass.History) ISHistory.Push({ type: 'olympicgames', action: 'close' }, 'Хронологическая лента Олимпийских игр', thisclass.UrlPage); return false; }); $('#olympic-games-list a.list-element').unbind('click'); $('#olympic-games-list a.list-element').click(function () { return true; }); if (window.location.hash == '#opengames') thisclass.Close(); if ('olympicgames' == this.Type) $('a.og-constructor').click(function () { if (!$(this).parent().hasClass('active')) { ISWidgetOlympicGames.Close(); if (thisclass.History) ISHistory.Push({ type: 'olympicgames.page', action: 'open' }, 'Хронологическая лента Олимпийских игр', thisclass.UrlPage); } else { ISWidgetOlympicGames.Close(true); if (thisclass.History) ISHistory.Push({ type: 'olympicgames.page', action: 'close' }, 'Хронологическая лента Олимпийских игр', thisclass.UrlPage); } return false; }); else if ('scoreboard' == this.Type) { $("#olympic-games-list").show(); $('.box-for-scoreboard.olympic-games .games-list .close').hide(); } else if ('search' == this.Type) { $('#olympic-games-list').show(); $('#olympic-games-list a.close').hide(); $('#olympic-games-list').css('margin', 0); } } }, Close: function (close) { close = (close == undefined) ? false : close; var th = $("#games"); var visible = false; if (close) { $("#olympic-games-list").hide(); } else { if ($("#olympic-games-list").is(':visible')) { $("#olympic-games-list").hide(); visible = false; } else { $("#olympic-games-list").css({ top: th.position().top, maxWidth: $(".content").width() }).show(); visible = true; } } if ('olympicgames' == this.Type) { $('a.og-constructor').parent().toggleClass('active'); } else if (!close || visible) { ISWidgetCalendarSport.Toggle(true); ISWidgetMap.Close(true); ISWidgetConstructor.Close(true); } } } ISWidgetCalendarSport = { RegionId: 0, Sport: [{ Id: 0, Name: "" }], SportId: 0, SId: 0, Hash: '', SearchSportLine: -1, Run: false, UrlPage: '', History: true, Init: function () { //console.log('ISWidgetCalendarSport.Init()'); var thisclass = this; if ($('#calendar').length > 0) { thisclass.UrlPage = document.location + ''; thisclass.Run = true; var dtPicker = $("#datepicker"); if (dtPicker.length) { dtPicker.datepicker({ language: "ru", todayHighlight: true }).on('changeMonth', function (e) { thisclass.SetSmallDate(e.date); }).on('changeYear', function (e) { thisclass.SetSmallDate(e.date); }).on('changeDate', function (e) { thisclass.SetSmallDate(e.date); if (dtPicker.is(':visible')) { thisclass.GetCalendarEvents(); ISWidgetCalendarSport.SetSport(); } }).on('setDate', function (e) { thisclass.SetSmallDate(e.date); }); $(".calendar-heading").unbind('click'); $(".calendar-heading").click(function () { thisclass.GetCalendarEvents(); ISWidgetCalendarSport.SetSport(); return false; }); var dt = new Date(); dtPicker.datepicker('setDate', dt); dt = dtPicker.datepicker('getDate'); if (dt == 'Invalid Date') { dt = new Date(); } thisclass.SetSmallDate(dt); $('.events-calendar .textsearch a').unbind('click'); $('.events-calendar .textsearch a').click(function () { $('.events-calendar .datepicker-switch').html(''); $('#regionforcalendar').focus(); $('.events-calendar .datepicker-switch').append($('
').append($('
'))); $("body").on("input", "input#regionforcalendar", function () { thisclass.SearchSportLine = -1; thisclass.SearchSport(); }); $("input#regionforcalendar").keydown(function (eventObject) { if (38 == eventObject.which || 40 == eventObject.which) { $('.events-calendar .datepicker-switch div div span').removeClass('selected'); if (40 == eventObject.which) thisclass.SearchSportLine++; else thisclass.SearchSportLine--; if (thisclass.SearchSportLine < 0) thisclass.SearchSportLine = 0; if (thisclass.SearchSportLine >= $('.events-calendar .datepicker-switch div div span').length) thisclass.SearchSportLine = $('.events-calendar .datepicker-switch div div span').length - 1; $('.events-calendar .datepicker-switch div div span').eq(thisclass.SearchSportLine).addClass('selected'); return false; } else if (13 == eventObject.which) { if ($('.events-calendar .datepicker-switch div div span.selected').length > 0) { thisclass.SportId = $('.events-calendar .datepicker-switch div div span.selected').data('sportid'); thisclass.GetCalendarEvents(); } } }); return false; }); } $(".date-checker").find('th').unbind('click'); $(".date-checker").find('th').bind('click', function () { var DTP = $("#datepicker"); var DT = DTP.datepicker('getDate'); if ($(this).hasClass('next')) { thisclass.SportId++; thisclass.GetCalendarEvents(); } else if ($(this).hasClass('prev')) { thisclass.SportId--; thisclass.GetCalendarEvents(); } else { //$("#events").hide(); } return false; }); $(".heading-change, .calendar-heading-wrap .calendar-heading").unbind('click'); $(".heading-change, .calendar-heading-wrap .calendar-heading").click(function () { if ('Russian' == $(".heading-change").data('calendartype')) $(".heading-change").data('calendartype', 'International'); else $(".heading-change").data('calendartype', 'Russian'); $(".calendar-heading").toggle(); thisclass.GetCalendarEvents(); ISWidgetCalendarSport.SetSport(); return false; }); $(".heading-change").data('calendartype', 'International'); $(".calendar-heading").toggle(); //console.log('calendartype=' + $(".heading-change").data('calendartype')); $(".buttons a.left").unbind('click'); $(".buttons a.left").click(function () { var par = $(this).parents('.field'); var d = dtPicker.datepicker('getDate'); if (par.hasClass('year')) { d.setFullYear(d.getFullYear() - 1); } else if (par.hasClass('month')) { d.setMonth(d.getMonth() - 1); } else if (par.hasClass('day')) { d.setDate(d.getDate() - 1); } thisclass.SetSmallDate(d); dtPicker.datepicker('setDate', d); return false; }); $(".buttons a.right").unbind('click'); $(".buttons a.right").click(function () { var par = $(this).parents('.field'); var d = dtPicker.datepicker('getDate'); if (par.hasClass('year')) { d.setFullYear(d.getFullYear() + 1); } else if (par.hasClass('month')) { d.setMonth(d.getMonth() + 1); } else if (par.hasClass('day')) { d.setDate(d.getDate() + 1); } thisclass.SetSmallDate(d); dtPicker.datepicker('setDate', d); return false; }); $("#calendar a.calendar-toggle").unbind('click'); $("#calendar a.calendar-toggle").bind('click', function () { thisclass.Toggle(); if (thisclass.History) ISHistory.Push({ type: 'calendarsport', action: $("#calendar-widget").is(':visible') ? 'open' : 'close' }, 'Календарь спортивных мероприятий', thisclass.UrlPage); return false; }); ISCatalogs.SportDownload(ISWidgetCalendarSport.SetSport); //ISWidgetCalendarSport.SetSport(); } }, SetSport: function () { var year = null, month = null; var DT = $("#datepicker").datepicker('getDate'); if (DT == 'Invalid Date') { var d = new Date() year = d.getFullYear(); month = d.getMonth() + 1; } else { year = DT.getFullYear(); month = DT.getMonth() + 1; } console.log('ISWidgetCalendarSport.SId=' + ISWidgetCalendarSport.SId); $.ajax({ url: '/ajax/getsportforcalendar', type: "POST", data: { year, month, type: $(".heading-change").data('calendartype') }, context: ISWidgetCalendarSport.SId, success: function (d) { ISWidgetCalendarSport.Sport = [{ Id: 0, Name: "Выберите вид спорта" }]; if(d && d.Sport) for (var i = 0; i < ISCatalogs.Sport.length; i++) { if ($.inArray(ISCatalogs.Sport[i].Id, d.Sport) > -1 || ISCatalogs.Sport[i].Id == this) ISWidgetCalendarSport.Sport.push(ISCatalogs.Sport[i]); if (ISCatalogs.Sport[i].Id == this) { ISWidgetCalendarSport.SportId = ISWidgetCalendarSport.Sport.length - 1; console.log('ISWidgetCalendarSport.SportId=' + ISWidgetCalendarSport.SportId); console.log('ISCatalogs.Sport[i].Id == this | ' + this + ' | '); } } //console.log(ISWidgetCalendarSport.Sport); } }); }, SetSmallDate: function (dt) { if (dt == 'Invalid Date') { dt = new Date(); } if (typeof dt != "undefined") { var year = dt.getFullYear(); var month = dt.getMonth(); var day = dt.getDate(); $(".footing-calendar .year .value").text(year); $(".footing-calendar .month .value").text(month + 1); $(".footing-calendar .day .value").text(day); } }, GetCalendarEvents: function () { //ISWidgetCalendarSport.SetSport(); var thisclass = this; // изменить дату в оранжевой полосе, добавить ивенты переключения даты var month_names = new Array("Января", "Февраля", "Марта", "Апреля", "Мая", "Июня", "Июля", "Августа", "Сентября", "Октября", "Ноября", "Декабря"); var DTP = $("#datepicker"); var DT = DTP.datepicker('getDate'); if (DT == 'Invalid Date') return false; var year = DT.getFullYear(); var month = DT.getMonth(); var day = DT.getDate(); var today = day + ' ' + month_names[month] + ', ' + year; var dtch = $(".date-checker"); if (thisclass.SportId >= thisclass.Sport.length) thisclass.SportId = 0 if (thisclass.SportId < 0) thisclass.SportId = thisclass.Sport.length - 1; ISWidgetCalendarSport.SId = thisclass.Sport[thisclass.SportId].Id; console.log('!!!ISWidgetCalendarSport.SId=' + ISWidgetCalendarSport.SId); if (thisclass.Sport.length > 0) { if (thisclass.Sport[thisclass.SportId].Name.length > 20) dtch.find(".datepicker-switch").addClass('compact'); else dtch.find(".datepicker-switch").removeClass('compact'); dtch.find(".datepicker-switch").text(thisclass.Sport[thisclass.SportId].Name); } $(".events-calendar .scroll-container").mCustomScrollbar('destroy'); $('#calendar-widget #events .scroll-container').html(''); thisclass.Hash = thisclass.SportId + '_' + thisclass.RegionId + '_' + $(".heading-change").data('calendartype') + '_' + (day < 10 ? "0" : "") + day + '.' + (month < 9 ? "0" : "") + (month + 1) + '.' + year; $.ajax({ url: '/ajax/getcalendar?v=' + ISCommon.GetV(), type: "POST", data: { Hash: thisclass.Hash, SportId: thisclass.Sport[thisclass.SportId].Id, RegionId: thisclass.RegionId, type: $(".heading-change").data('calendartype'), date: (day < 10 ? "0" : "") + day + '.' + (month < 9 ? "0" : "") + (month + 1) + '.' + year }, success: function (d) { if ("yes" == d.Result && thisclass.Hash == d.Hash) { $(".events-calendar .scroll-container").mCustomScrollbar('destroy'); $('#calendar-widget #events .scroll-container').html(d.Calendar); $(".events-calendar .scroll-container").mCustomScrollbar({ theme: "my-theme", scrollButtons: { enable: true, scrollAmount: 50, }, }); if (d.Count == 0) { $("#events .scroll-wrapper").hide(); $('#events').css({ 'height': '54px' }); thisclass.SetCalendarEmptyDays(d.DaysThisMonth, d.DaysPrevMonth, d.DaysNextMonth); } else { $("#events .scroll-wrapper").show(); $('#events').css({ 'height': 'auto' }); } } } }); //$("#events").toggle(); $("#events").show(); }, SetCalendarEmptyDays: function (DaysThisMonth, DaysPrevMonth, DaysNextMonth) { $('.datepicker-days td.day').addClass('empty'); $('.datepicker-days td.day').each(function () { var day = parseInt($(this).find('a').text()); if ($(this).hasClass('old')) { if ($.inArray(day, DaysPrevMonth) > -1) $(this).removeClass('empty'); } else if ($(this).hasClass('new')) { if ($.inArray(day, DaysNextMonth) > -1) $(this).removeClass('empty'); } else { if ($.inArray(day, DaysThisMonth) > -1) $(this).removeClass('empty'); } }); }, SearchSport: function () { if ($('#regionforcalendar').length > 0 && $('#regionforcalendar').val() != '') { var thisclass = this; var n = 0; $('.events-calendar .datepicker-switch div div').text(''); for (var i = 1; i < this.Sport.length; i++) if (this.Sport[i].Name.toLowerCase().indexOf($('#regionforcalendar').val().toLowerCase()) > -1 && n < 9) { n++; $('.events-calendar .datepicker-switch div div').append($('', { text: this.Sport[i].Name, 'data-sportid': i })); } $('.events-calendar .datepicker-switch div div span').click(function () { thisclass.SportId = $(this).data('sportid'); thisclass.GetCalendarEvents(); }); } }, Toggle: function (close) { var thisclass = this; close = (close == undefined) ? false : close; var width = $("#calendar").width() * 2; var widget = $("#calendar-widget"); if (widget.is(':visible') || close) { widget.hide(); $('.big-calendar-title').removeClass('open-calendar'); thisclass.SportId = 0; var dtclear = new Date(); $("#datepicker").datepicker('setDate', dtclear); dtclear = $("#datepicker").datepicker('getDate'); if (dtclear == 'Invalid Date') dtclear = new Date(); thisclass.SetSmallDate(dtclear); //$(".footing-calendar").show(); } else { $.ajax({ type: "post", url: "/ajax/moduleclick?v=" + ISCommon.GetV(), data: { G: ISCommon.Guid, Id: $(".responsive-block#calendar").data('moduleid'), v: '4' }, success: function (d) { if (d.result == 'yes' && ISCommon.Guid == '') ISCommon.SetGuid(d.guid); } }); $("#events").mCustomScrollbar('destroy'); $("#events").show(); thisclass.GetCalendarEvents(); if (($("#calendar").position().left + width) < $("#container").width()) { widget.css({ position: 'absolute', top: $("#calendar").position().top, left: ($("#calendar").position().left + $("#calendar").width()), width: width, zIndex: 999 }).show(); } else if (($("#calendar").position().left - width) >= $("#container").position().left) { widget.css({ position: 'absolute', top: $("#calendar").position().top, left: ($("#calendar").position().left - 2 * $("#calendar").width()), width: width, zIndex: 999 }).show(); } else { widget.css({ position: 'absolute', top: ($("#calendar").position().top + $("#calendar").height()), left: ($("#calendar").position().left - $("#calendar").width()), width: width, zIndex: 999 }).show(); } $('.big-calendar-title').addClass('open-calendar'); //$(".footing-calendar").hide(); } if (!close) { ISWidgetOlympicGames.Close(true); ISWidgetMap.Close(true); ISWidgetConstructor.Close(true); } } } ISWidgetConstructor = { InitFirst: true, UrlPage: '', History: true, Init: function () { var thisclass = this; //$("a.outer-link, a.block, #constructor").unbind('click'); $("a.outer-link, a.block, #constructor").click(function () { console.log('click'); if ($(this).hasClass("video-link")) return false; if ($(this).parent().parent().attr('id') == "news2") return true; if ( !$(this).hasClass('statistics-regions') && $(this).parent().attr('id') != 'games' && !$(this).hasClass("static-block") && !$(this).hasClass("static-block-withcolor") && !$(this).hasClass("banner_click") ) { ISWidgetOlympicGames.Close(true); ISWidgetCalendarSport.Toggle(true); return false; } console.log('click end'); return true; }); $("#constructor").unbind('click'); $("#constructor").click(function () { $(this).parent().toggleClass('active'); $(".nicescroll").niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', }); if ($(this).parent().hasClass('active')) { $(".nicescroll").getNiceScroll().show(); if (thisclass.History) ISHistory.Push({ type: 'constructor', action: 'open' }, 'Конструктор интерфейса', thisclass.UrlPage); } else { $(".nicescroll").getNiceScroll().hide(); if (thisclass.History) ISHistory.Push({ type: 'constructor', action: 'close' }, 'Конструктор интерфейса', thisclass.UrlPage); } return false; }); $(".constructor-popup .close").unbind('click'); $(".constructor-popup .close").click(function () { $(this).parent().removeClass('active'); $(".nicescroll").getNiceScroll().hide(); if (thisclass.History) ISHistory.Push({ type: 'constructor', action: 'close' }, 'Конструктор интерфейса', thisclass.UrlPage); return false; }); if (this.InitFirst) { $(".constructor-popup input").change(function () { var idVal = $(this).data("moduleid"); if ($(this).is(':checked')) $('.responsiveBlock div.responsive-block[data-moduleid=' + idVal + ']:first').show(); else $('.responsiveBlock div.responsive-block[data-moduleid=' + idVal + ']:first').hide(); thisclass.Save(); ISWidgets.Resize(); }); if ($(".constructor-elements input[type=checkbox]").length) $(".constructor-elements input[type=checkbox]").kalypto(); } thisclass.Get(); this.InitFirst = false; }, Get: function () { var data = $.cookie('DeleteWidgets'); if (data != null && data != "" && data.indexOf('|') > -1) { var strIds = data.split("|"); for (var i = 0; i < strIds.length; i++) if (strIds[i] != "") { $('.responsiveBlock div[data-moduleid=' + strIds[i] + ']').hide(); $('.constructor-popup input[data-moduleid=' + strIds[i] + ']').prop('checked', false); $('.constructor-popup input[data-moduleid=' + strIds[i] + ']').parent().find('a.toggle').removeClass('checked'); } } }, Save: function () { var data = ""; $(".constructor-popup input").each(function () { if (!$(this).is(':checked')) data += $(this).data("moduleid") + '|'; }); if (data != "") $.cookie('DeleteWidgets', data, { expires: 366 }); else $.cookie('DeleteWidgets', null); }, Close: function (close) { close = close || false; if (close) { $('#constructor').parent().removeClass('active'); $(".nicescroll").getNiceScroll().hide(); } else { $('#constructor').parent().toggleClass('active'); $(".nicescroll").niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', }); $(".nicescroll").getNiceScroll().show(); } } } var responsiveArray = []; var prevWidth = 0; ISWidgets = { OriginalOrderIds: [], BannerAfterId: null, PrevWidth: null, WidthMap: { "w1280": 5, "w1060": 4, 'w822': 3, 'w640': 2, 'w360': 2 }, WidthCount: 5, 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); } }); }); $(".responsive-block").each(function () { //if ($(this).attr('id') == undefined) $(this).attr('id', 'id' + $(this).attr('data-moduleid')); responsiveArray.push($(this).attr('data-moduleid')); }); var thereBanner = false; $(".responsive-block").each(function (index, el) { thisclass.OriginalOrderIds.push($(this).data('moduleid')); if (!thereBanner && !$(this).hasClass('col-10-5') && $(this).data('moduleid')) thisclass.BannerAfterId = $(this).data('moduleid'); if ($(this).hasClass('col-10-5')) thereBanner = true; }); thisclass.PrevWidth = $(".content").width(); /* $(window).on('resize', function () { if (thisclass.PrevWidth != $(".content").width()) thisclass.Resize(); }); */ ISWidgetConstructor.Init(); //ISWidgetCalendarSport.Init(); ISWidgetBlockStatic.Init(); thisclass.Resize(); ISWidgetOlympicGames.Init(); prevWidth = $(".content").width(); $(window).on('resize', function () { var superWidth = $(".content").width(); if (superWidth == 1279) { $(".content").width(1280); superWidth = 1280; } if (prevWidth != superWidth) { thisclass.Resize(); } }); }, OriginalOrder: function () { var elLast = $(".responsive-block").eq(-1); $('.col-10-5.responsive-block').each(function (index, el) { elLast.after($(this)); }); }, Resize: function () { var thisclass = this; var superWidth = $(".content").width(), bfr = responsiveArray.slice(), resultArray = [], columns = 0, longBlock = 0, col1 = [], // .col-10-2 col2 = [], // .col-10-4 col3 = []; // .col-10-* if (superWidth > 1060) { columns = 5; longBlock = 2.5; } else if (superWidth <= 1060 && superWidth > 1006) { columns = 4; longBlock = 2; } else if (superWidth <= 1006 && superWidth > 805) { columns = 3; longBlock = 3; } else { columns = 2; longBlock = 2; } var bfrclear = []; $.each(bfr, function (index, val) { var el = $('.responsiveBlock div.responsive-block[data-moduleid=' + val + ']:first'); if (el.is(':visible')) { var cls = el.attr('class'); if (cls.indexOf('col-10-2') >= 0) { col1.push(val); } else if (cls.indexOf('col-10-4') >= 0) { col2.push(val); } else { col3.push(val); } bfrclear.push(val); } else { //bfr.splice(index, 1); } }); bfr = bfrclear; var cols = 0, index = 0, sh = function (vl, arr, ind, inc) { resultArray.push(vl); bfr.splice(ind, 1); index--; arr.shift(); cols += inc; }; while (index < bfr.length) { var val = bfr[index]; if ($.inArray(val, col1) >= 0) { sh(val, col1, index, 1); } else if ($.inArray(val, col2) >= 0) { if (cols + 2 <= columns) { sh(val, col2, index, 2); } else { if (col1.length > 0) sh(col1[0], col1, $.inArray(col1[0], bfr), 1); else sh(val, col2, index, 2); } } else { if (cols + longBlock <= columns) { sh(val, col3, index, longBlock); } else if (cols + 2 <= columns) { sh(col2[0], col2, $.inArray(col2[0], bfr), 2); } else { sh(col1[0], col1, $.inArray(col1[0], bfr), 1); } } if (cols >= columns) cols = 0; index++; }; thisclass.Response(resultArray); prevWidth = superWidth; //mapResize(); // ресайз карты на лету $("#olympic-games-list").css({ maxWidth: $(".content").width() }); // пересчет ширины блока ОИ //ISWidgetConstructor.Init(); //ISWidgetBlockStatic.Init(); //ISWidgetCalendarSport.Init(); //ISWidgetOlympicGames.Init(); }, Response: function (idsArray) { $.each(idsArray, function (index, val) { var el = $('.responsiveBlock div.responsive-block[data-moduleid=' + val + ']:first'); //el.remove(); $(el).appendTo('.responsiveBlock'); }); } } ISBanners = { Init: function () { /* $('.banner_click').click(function () { $.ajax({ url: "/ajax/bannerclick", data: { Id: $(this).data("bannerid") }, async: false, success: function (d) { } }); return true; }); */ } }