ISSportingEventEdit = { IsInitFirst: false, DataForForm: {}, SportingEventId: 0, Init: function () { $('#edit-sportingevent, .sportingevents-popup #edit-sportingevent').unbind('click'); $('#edit-sportingevent, .sportingevents-popup #edit-sportingevent').click(function () { var oId = parseInt($(this).data('sportingeventid')); ISSportingEventEdit.SportingEventId = isNaN(oId) ? 0 : oId; if (ISSportingEventEdit.IsInitFirst) { if (ISSportingEventEdit.OrganizationId > 0) ISSportingEventEdit.EditShow(ISSportingEventEdit.SportingEventId); else ISSportingEventEdit.SearchShow(); } else ISSportingEventEdit.InitFirst(); }); //$('#edit-organization').click(); }, 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 (ISSportingEventEdit.OrganizationId > 0) ISSportingEventEdit.EditShow(ISSportingEventEdit.SportingEventId); else ISSportingEventEdit.SearchShow(); ISSportingEventEdit.IsInitFirst = true; }); }); }); } }, SearchShow: function () { if ($('.edit-sportingevent-bg').length == 0) $('body').append($('
', { 'class': 'edit-sportingevent-bg' })); $('.edit-sportingevent-bg').show(); if ($('.search-sportingevent-popup').length == 0) { $.ajax({ url: "/ajax/searchsportingevent?v=" + ISCommon.GetV(), data: {}, cache: true, success: function (d) { $('body').append(d.View); ISSportingEventEdit.SearchShowInit(); catalogsFiltered.init({ url: "/ajax/searchsportingevent?type=ajax", history: false, filter: ["SportIds", "calendarType", "DateStart", "DateEnd"], parent: '.search-sportingevent-popup' }); catalogsFiltered.callback = function () { $('.search-sportingevent-popup .adminItems tbody a').unbind('click'); $('.search-sportingevent-popup .adminItems tbody a').click(function () { ISSportingEventEdit.EditShow($(this).data('sportingeventid')); return false; }); }; } }); } else ISSportingEventEdit.SearchShowInit(); }, SearchShowInit: function () { $('.search-sportingevent-popup').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.search-sportingevent-bg').css({ top: 0, height: $(document).outerHeight() }); $('.search-sportingevent-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $(".search-sportingevent-popup select").not(".ex").chosen(); $(".search-sportingevent-popup .close").unbind('click'); $(".search-sportingevent-popup .close").click(function () { ISSportingEventEdit.SearchHide(); return false; }); $('#createitem').unbind('click'); $('#createitem').click(function () { ISSportingEventEdit.SearchHide(); ISSportingEventEdit.EditShow(0); return false; }); $('.search-sportingevent-popup .adminItems tbody a').unbind('click'); $('.search-sportingevent-popup .adminItems tbody a').click(function () { ISSportingEventEdit.EditShow($(this).data('sportingeventid')); return false; }); $(".search-sportingevent-popup #DateStart, .search-sportingevent-popup #DateEnd") .datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy" }).on('changeDate', function (ev) { $(".search-sportingevent-popup #DateStart, .search-sportingevent-popup #DateEnd").data('datepicker').hide(); catalogsFiltered.getrun(); }).data('datepicker'); }, SearchHide: function () { $(".search-sportingevent-popup").hide(); $('.edit-sportingevent-bg').hide(); }, EditShow: function (Id) { $('.edit-sportingevent-form .form-messages').hide(); if ($('.edit-sportingevent-bg').length == 0) $('body').append($('
', { 'class': 'edit-sportingevent-bg' })); $('.edit-sportingevent-bg').show(); if ($('.edit-sportingevent-popup').length == 0) $('body').append($('
', { 'class': 'edit-sportingevent-popup' })); $.ajax({ url: "/ajax/editsportingevent?v=" + ISCommon.GetV(), data: { Id: Id }, cache: true, success: function (d) { $('.edit-sportingevent-popup').html(d.View); ISSportingEventEdit.EditShowInit(); } }); }, EditShowInit: function () { $('.search-sportingevent-popup').hide(); if ($('.edit-sportingevent-form #SportingEventId').val() != '0') $('.edit-sportingevent-popup .heading .messages p').text('Корректировка записи в базе МЕРОПРИЯТИЙ'); else $('.edit-sportingevent-popup .heading .messages p').text('Новая запись в базе МЕРОПРИЯТИЙ'); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.edit-sportingevent-bg').css({ top: 0, height: $(document).outerHeight() }); $('.edit-sportingevent-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-sportingevent-popup .heading a.close').unbind('click'); $('.edit-sportingevent-popup .heading a.close').click(function () { ISSportingEventEdit.EditHide(); return false; }); $(".edit-sportingevent-form select").not(".ex").chosen(); $(".edit-sportingevent-form #Text, .edit-sportingevent-form #Intro").ckeditor({ height: 140, width: 723, toolbar: [['Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList', 'Table'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink'], ["Maximize", "Image"]] }) .ckeditor(function () { ISSportingEventEdit.DataForForm = ISSportingEventEdit.GetDataFromForm(); $('.edit-sportingevent-popup').show(); }); $(".edit-sportingevent-form #DateStart").datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy", onRender: function (date) { return ''; } }).on('changeDate', function (ev) { var e2 = $(".edit-sportingevent-form #DateEnd").val() == ""; var dtDateEnd = $(".edit-sportingevent-form #DateEnd").datepicker('getDate'); if (dtDateEnd == 'Invalid Date') { dtDateEnd = new Date(); } if (ev.date.valueOf() > dtDateEnd.valueOf() || e2) { var newDate = new Date(ev.date) newDate.setDate(newDate.getDate()); $(".edit-sportingevent-form #DateEnd").datepicker('setDate', newDate); $(".edit-sportingevent-form #DateEnd").data('datepicker').setValue(newDate); } else { var newDate = new Date($(".edit-sportingevent-form #DateEnd").data('datepicker').date) $(".edit-sportingevent-form #DateEnd").data('datepicker').setValue(newDate); } if ("days" == ev.viewMode) $(".edit-sportingevent-form #DateStart").data('datepicker').hide(); if (e2) { var newDate = new Date(ev.date) newDate.setDate(newDate.getDate()); $(".edit-sportingevent-form #DateEnd").datepicker({ defaultDate: newDate }); $(".edit-sportingevent-form #DateEnd").val(''); } }).data('datepicker'); $(".edit-sportingevent-form #DateEnd").datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy", onRender: function (date) { return date.valueOf() < $(".edit-sportingevent-form #DateStart").datepicker('getDate').valueOf() ? 'disabled' : ''; //return date.valueOf() < $(".edit-sportingevent-form #DateStart").data('datepicker').date.valueOf() ? 'disabled' : ''; } }).on('changeDate', function (ev) { if ("days" == ev.viewMode) $(".edit-sportingevent-form #DateEnd").data('datepicker').hide(); }).data('datepicker'); /* $(".edit-sportingevent-form #DateStart, .edit-sportingevent-form #DateEnd") .datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy" }); */ $('.edit-sportingevent-form .form-actions a.button').unbind('click'); $('.edit-sportingevent-form .form-actions a.button').click(function () { ISSportingEventEdit.Save(); return false; }); $(".edit-sportingevent-form .control-group.upload-photo #fileupload").unbind('change'); $(".edit-sportingevent-form .control-group.upload-photo #fileupload").change(function () { $('.edit-sportingevent-form').ajaxSubmit({ url: '/ajax/uploadsportingevent', success: function (d) { if ('yes' == d.Result) { $('.control-group.upload-photo #Logo').val(d.FileNameGuid); $('.control-group.upload-photo #FileName').val(d.FileName); $(".control-group.upload-photo .controls.image").html(''); } else if (d.Message != null && d.Message != '') $(".edit-sportingevent-form .control-group.upload-photo .messages").text(d.Message); } }); }); $('.edit-sportingevent-popup .heading .messages a').unbind('click'); $('.edit-sportingevent-popup .heading .messages a').click(function () { $('.registration-sportingevent-popup').css({ top: $(window).scrollTop() }); $('.registration-sportingevent-popup').css({ 'z-index': '1200' }); $('.registration-sportingevent-popup').show(); $('.registration-sportingevent-popup .inside_popup').hide(); $('.registration-sportingevent-popup .mesageforremove').show(); return false; }); $('.edit-sportingevent-popup #SportsIdsList').change(function () { if ($(this).val()) { $.ajax({ url: "/ajax/filteredbysports?v=" + ISCommon.GetV(), data: { filter: JSON.stringify($(this).val()) }, success: function (d) { var selected = $("#DisciplinesIdsList").val(); $("#DisciplinesIdsList").empty(); $.each(d, function () { if ($.inArray(this.Id.toString(), selected) > -1) $("#DisciplinesIdsList").append($("

Данные успешно отправлены. Материал будет опубликован в БД после проверки модератором. ' + 'Обновления будут доступны в разделе ОТРАСЛЕВОЕ ТАБЛО

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