ISCalendarEdit = { IsInitFirst: false, DataForForm: {}, CalendarId: 0, Init: function () { $('#edit-calendar, .calendar-popup #edit-calendar').unbind('click'); $('#edit-calendar, .calendar-popup #edit-calendar').click(function () { var oId = parseInt($(this).data('calendarid')); ISCalendarEdit.CalendarId = isNaN(oId) ? 0 : oId; if (ISCalendarEdit.IsInitFirst) { if (ISCalendarEdit.CalendarId > 0) ISCalendarEdit.EditShow(ISCalendarEdit.CalendarId); else ISCalendarEdit.SearchShow(); } else ISCalendarEdit.InitFirst(); }); }, InitFirst: function () { if (!this.IsInitFirst) { $('head').append(' '); window.CKEDITOR_BASEPATH = '/scripts/ckeditor/'; $.when( $.getScript("/scripts/admin/chosen.jquery.js"), $.getScript("/scripts/ckeditor/ckeditor.js"), $.getScript("/scripts/admin/jquery.form.js"), $.getScript("/scripts/admin/catalogs.js?v=3"), $.Deferred(function (deferred) { $(deferred.resolve); }) ).done(function () { $.getScript('/scripts/ckeditor/adapters/jquery.js', function () { $.getScript('/scripts/admin/ckeditoruploadconfig.js', function () { if (ISCalendarEdit.OrganizationId > 0) ISCalendarEdit.EditShow(ISCalendarEdit.CalendarId); else ISCalendarEdit.SearchShow(); ISCalendarEdit.IsInitFirst = true; }); }); }); } }, SearchShow: function () { if ($('.edit-bg.calendar').length == 0) $('body').append($('
', { 'class': 'edit-bg calendar' })); $('.edit-bg.calendar').show(); if ($('.search-popup.calendar').length == 0) { $.ajax({ url: "/ajax/searchcalendar?v=" + ISCommon.GetV(), data: {}, cache: true, success: function (d) { $('body').append(d.View); ISCalendarEdit.SearchShowInit(); catalogsFiltered.init({ url: "/ajax/searchcalendar?type=ajax", history: false, filter: ["SportIds", "calendarType", "DateStart", "DateEnd"], parent: '.search-popup.calendar' }); catalogsFiltered.callback = function () { $('.search-popup.calendar .adminItems tbody a').unbind('click'); $('.search-popup.calendar .adminItems tbody a').click(function () { ISCalendarEdit.EditShow($(this).data('calendarid')); return false; }); }; } }); } else ISCalendarEdit.SearchShowInit(); }, SearchShowInit: function () { $('.search-popup.calendar').show(); var newWidth = ($("#container").width() < 900) ? $("#container").width() : 900; $('.search-calendar-bg').css({ top: 0, height: $(document).outerHeight() }); $('.search-popup.calendar').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $(".search-popup.calendar select").not(".ex").chosen(); $(".search-popup.calendar .close-icon").unbind('click'); $(".search-popup.calendar .close-icon").click(function () { ISCalendarEdit.SearchHide(); return false; }); $('#createitem').unbind('click'); $('#createitem').click(function () { ISCalendarEdit.SearchHide(); ISCalendarEdit.EditShow(0); return false; }); $('.search-popup.calendar .adminItems tbody a').unbind('click'); $('.search-popup.calendar .adminItems tbody a').click(function () { ISCalendarEdit.EditShow($(this).data('calendarid')); return false; }); $(".search-popup.calendar #DateStart, .search-popup.calendar #DateEnd") .datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy" }).on('changeDate', function (ev) { $(".search-popup.calendar #DateStart, .search-popup.calendar #DateEnd").data('datepicker').hide(); catalogsFiltered.getrun(); }).data('datepicker'); }, SearchHide: function () { $(".search-popup.calendar").hide(); $('.edit-bg.calendar').hide(); }, EditShow: function (Id) { $('.edit-calendar-form .form-messages').hide(); if ($('.edit-bg.calendar').length == 0) $('body').append($('
', { 'class': 'edit-bg calendar' })); $('.edit-bg.calendar').show(); if ($('.edit-popup.calendar').length == 0) $('body').append($('
', { 'class': 'edit-popup calendar' })); $.ajax({ url: "/ajax/editcalendar?v=" + ISCommon.GetV(), data: { Id: Id }, cache: true, success: function (d) { $('.edit-popup.calendar').html(d.View); ISCalendarEdit.EditShowInit(); } }); }, EditShowInit: function () { $('.search-popup.calendar').hide(); $('.edit-popup.calendar').show(); if ($('.edit-popup.calendar #CalendarId').val() != '0') $('.edit-popup.calendar .heading .messages p').text('Корректировка записи в базе МЕРОПРИЯТИЙ'); else $('.edit-popup.calendar .heading .messages p').text('Новая запись в базе МЕРОПРИЯТИЙ'); var newWidth = ($("#container").width() < 800) ? $("#container").width() : 800; $('.edit-bg.calendar').css({ top: 0, height: $(document).outerHeight() }); $('.edit-popup.calendar').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-popup.calendar .heading a.close-icon').unbind('click'); $('.edit-popup.calendar .heading a.close-icon').click(function () { ISCalendarEdit.EditHide(); return false; }); $(".edit-popup.calendar select").not(".ex").chosen(); $(".edit-popup.calendar select").unbind('change'); $(".edit-popup.calendar select").change(function () { ISCalendarEdit.CheckOnTheDuplicate(); }); $(".edit-popup.calendar #DateStart").datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy", onRender: function (date) { return ''; } }).on('changeDate', function (ev) { ISCalendarEdit.CheckOnTheDuplicate(); }).data('datepicker'); $(".edit-popup.calendar #DateEnd").datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy", onRender: function (date) { return date.valueOf() < $(".edit-popup.calendar #DateStart").datepicker('getDate').valueOf() ? 'disabled' : ''; } }).on('changeDate', function (ev) { if ("days" == ev.viewMode) { $(".edit-popup.calendar #DateEnd").data('datepicker').hide(); } ISCalendarEdit.CheckOnTheDuplicate(); }).data('datepicker'); $('.edit-popup.calendar .form-actions a.button').unbind('click'); $('.edit-popup.calendar .form-actions a.button').click(function () { ISCalendarEdit.Save(); return false; }); $('.edit-popup.calendar .heading .messages a').unbind('click'); $('.edit-popup.calendar .heading .messages a').click(function () { $('.registration-calendar-popup').css({ top: $(window).scrollTop() }); $('.registration-calendar-popup').css({ 'z-index': '1200' }); $('.registration-calendar-popup').show(); $('.registration-calendar-popup .inside_popup').hide(); $('.registration-calendar-popup .mesageforremove').show(); return false; }); $('.edit-popup.calendar #CountryId').change(function () { if ($(this).val() == 155) { $('.edit-popup.calendar #RegionId').prop('disabled', false).trigger("liszt:updated"); $('.edit-popup.calendar #CityId').prop('disabled', false).trigger("liszt:updated"); $('.edit-popup.calendar #addnewcity').show(); } else { $('.edit-popup.calendar #RegionId').val(0).prop('disabled', true).trigger("liszt:updated"); $('.edit-popup.calendar #CityId').prop('disabled', true).trigger("liszt:updated"); $('.edit-popup.calendar #addnewcity').hide(); } }); $('.edit-popup.calendar #CountryId').change(); $('.edit-popup.calendar #RegionId').change(function () { if ($(this).val() != '0') { $.ajax({ url: "/ajax/filteredcitiesbyregionid?v=" + ISCommon.GetV(), data: { RegionId: $(this).val(), hash: ISCommon.GetGuid() }, success: function (d) { var selected = $("#CityId").val(); $("#CityId").empty(); $("#CityId").append($("

Данные успешно отправлены. Мероприятие будет опубликовано после проверка модератором.' + ' Обновления будут доступны в разделе ОТКРЫТЫЙ КАЛЕНДАРЬ СПОРТИВНЫХ МЕРОПРИЯТИЙ

' ); } else $('.registration-person-popup .mesageforremove .messageemail').text('Ошибка.'); } }); return false; }); } };