') .append($(' ISCalendar = { CalendarSearch: [], CalendarSearchById: {}, Settings: { SearchCount: 0, Type: null, UrlPage: '', History: true }, DateStartShow: false, DateEndShow: false, Init: function () { ISCatalogs.SportDownload(); thisclass = this; thisclass.UrlPage = document.location + ''; $('#button-clear').click(function () { thisclass.FilterClear(); }); $('.results-list #button-open').click(function () { $(this).hide(); $(this).attr('disabled', 'disabled'); var data = { SearchSkip: thisclass.Settings.SearchCount, SportId: $('.sportingevents-filter #SportId').val(), Name: $('.sportingevents-filter #Name').val(), DateStart: $('#DateStart').val(), DateEnd: $('#DateEnd').val(), CalendarType: $('#CalendarType').val() }; $.ajax({ url: "/ajax/calendarforsearchform?v=" + ISCommon.GetV(), data: data, success: function (d) { thisclass.OCalendarSearchCount = d.CalendarSearchCount; for (var i = 0; i < d.CalendarForAjaxList.length; i++) { thisclass.CalendarSearchById[d.CalendarForAjaxList[i].Id] = thisclass.CalendarSearch.length; thisclass.CalendarSearch.push(d.CalendarForAjaxList[i]); var o = d.CalendarForAjaxList[i]; var div = ""; var href = "/sportingevents/" + o.Id; var location = o.Country && o.Country != '' ? o.Country : ''; if (o.Regions && o.Regions != '') location += (location != '' ? '
' : '') + o.Regions; if (o.Cities && o.Cities != '' && o.Cities != 'Москва') location += (location != '' ? '
' : '') + o.Cities; if (o.Place && o.Place != '') location += (location != '' ? '
' : '') + o.Place; var tr = $(' ', { html: o.Name })) .append($(' ', { html: o.SportsName })) .append($(' ', { html: location })) .append($(' ', { text: o.DateStart })) .append($(' ', { text: o.DateEnd })); $('div.results-list .results-table tbody').append(tr); } thisclass.Settings.SearchCount += d.CalendarForAjaxList.length; if (d.CalendarSearchCount > thisclass.Settings.SearchCount) $('#button-open').show(); else $('.results-list').attr('style', 'padding-bottom: 10px !important;'); } }); return false; }); $("#DateStart") .datepicker({ addClass: 'edit-calendar', language: "ru", format: "dd.mm.yyyy" }) .on('show', function (e) { //console.log('show'); if (!thisclass.DateStartShow) thisclass.GetCalendarEvents($("#DateStart"), new Date(e.timeStamp)); thisclass.DateStartShow = true; }) .on('changeMonth', function (e) { //console.log('changeMonth'); thisclass.GetCalendarEvents($("#DateStart"), e.date); }).on('changeYear', function (e) { //console.log('changeYear'); thisclass.GetCalendarEvents($("#DateStart"), e.date); }).on('changeDate', function (e) { //console.log('changeDate'); thisclass.GetCalendarEvents($("#DateStart"), e.date); }).on('setDate', function (e) { //console.log('setDate'); thisclass.GetCalendarEvents($("#DateStart"), e.date); }); $("#DateEnd") .datepicker({ addClass: 'edit-calendar', language: "ru", format: "dd.mm.yyyy" }) .on('show', function (e) { //console.log('show'); if (!thisclass.DateEndShow) thisclass.GetCalendarEvents($("#DateEnd"), new Date(e.timeStamp)); thisclass.DateEndShow = true; }) .on('changeMonth', function (e) { thisclass.GetCalendarEvents($("#DateEnd"), e.date); }).on('changeYear', function (e) { thisclass.GetCalendarEvents($("#DateEnd"), e.date); }).on('changeDate', function (e) { thisclass.GetCalendarEvents($("#DateEnd"), e.date); }).on('setDate', function (e) { thisclass.GetCalendarEvents($("#DateEnd"), e.date); }); this.FiltersInit(); ISCalendarEdit.Init(); }, GetCalendarEvents: function (el, date) { var thisclass = this; var month_names = new Array("Января", "Февраля", "Марта", "Апреля", "Мая", "Июня", "Июля", "Августа", "Сентября", "Октября", "Ноября", "Декабря"); var DTP = el;//$("#DateStart"); var DT = DTP.datepicker('getDate'); //console.log(date); if (date && date instanceof Date) DT = date; else if (DT == 'Invalid Date') { DT = new Date(); } var year = DT.getFullYear(); var month = DT.getMonth(); var day = DT.getDate(); var today = day + ' ' + month_names[month] + ', ' + year; var dtch = $(".date-checker"); thisclass.Hash = $('#SportId').val() + '_' + $('#CalendarType').val() + '_' + (day < 10 ? "0" : "") + day + '.' + (month < 9 ? "0" : "") + (month + 1) + '.' + year; //console.log('CalendarType=' + $('#CalendarType').val()); $.ajax({ url: '/ajax/getcalendar?v=' + ISCommon.GetV(), type: "POST", data: { NamePage: 'calendarpage', Hash: thisclass.Hash, SportId: $('#SportId').val(), RegionId: 0, type: $('#CalendarType').val(), 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, }, }); thisclass.SetCalendarEmptyDays(d.DaysThisMonth, d.DaysPrevMonth, d.DaysNextMonth); } } }); //$("#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'); } }); }, FiltersInit: function () { var thisclass = this; $(".filter-wrap select").each(function () { var th = $(this); $(this).selectik({ width: th.width(), heightContainer: 400, customScroll: 0, speedAnimation: 100, smartPosition: true, isfilter: $(this).attr('id') != 'CalendarType' }); $(this).parent().find('ul').niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', railoffset: { top: -3 } }); $(this).parent().find('.custom-text').click(function () { $(this).parent().find('ul').getNiceScroll().resize(); }); }); if ($('#SportId').length > 0 && $('#SportId option').length < 2) $('#SportId').data('selectik').disableCS(); }, FilterClear: function () { var thisclass = this; $(".filter-wrap #SportId, .filter-wrap #CalendarType").each(function () { $(this).val("0"); $(this).data("selectik").refreshCS(); $(this).parent().find('.custom-text').text('Не выбран'); $(this).data('selectik').enableCS(); var th = $(this); $(this).selectik({ width: th.width(), heightContainer: 400, customScroll: 0, speedAnimation: 100, smartPosition: true }); $(this).parent().find('ul').niceScroll({ cursorcolor: '#314c83', background: '#c8c8ca', autohidemode: false, cursorborder: 'none', railoffset: { top: -3 } }); $(this).parent().find('.custom-text').click(function () { $(this).parent().find('ul').getNiceScroll().resize(); }); }); $('#Name').val(''); $('#DateStart').val(''); $('#DateEnd').val(''); } };