').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; }); */ } }