ISPersonEdit = { IsD: false, IsOpenCreate: false, DataForForm: {}, IsInitFirst: false, HistoryId: 0, PersonIdInit: 0, PersonId: 0, Init: function () { $('#edit-person, .atlet-popup #edit-person, #ReceivePrizeStart').unbind('click'); $('#edit-person, .atlet-popup #edit-person, #ReceivePrizeStart').click(function () { var pId = parseInt($(this).data('personid')); ISPersonEdit.PersonId = isNaN(pId) ? 0 : pId; if (ISPersonEdit.IsInitFirst) { if (ISPersonEdit.PersonId > 0) ISPersonEdit.EditShow(ISPersonEdit.PersonId); else ISPersonEdit.SearchShow(); } else ISPersonEdit.InitFirst(); }); if (this.IsD) { $('#edit-person').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"), $.Deferred(function (deferred) { $(deferred.resolve); }) ).done(function () { $.getScript('/scripts/ckeditor/adapters/jquery.js', function () { $.getScript('/scripts/admin/ckeditoruploadconfig.js', function () { //ISPersonEdit.SearchShow(); if (ISPersonEdit.PersonId > 0) ISPersonEdit.EditShow(ISPersonEdit.PersonId); else if (ISPersonEdit.IsD) ISPersonEdit.EditShow(0); else ISPersonEdit.SearchShow(); ISPersonEdit.IsInitFirst = true; }); }); }); } }, SearchShow: function () { if ($('.edit-person-bg').length == 0) $('body').append($('
', { 'class': 'edit-person-bg' })); $('.edit-person-bg').show(); if ($('.search-person-popup').length == 0) { $.ajax({ url: "/ajax/searchperson?v=" + ISCommon.GetV(), data: {}, cache: true, success: function (d) { $('body').append(d.View); ISPersonEdit.SearchShowInit(); catalogsFiltered.init({ url: "/ajax/searchperson?type=ajax", history: false, filter: ["day", "month", "year", "SportIds", "ChampionIds", "RankIds", "ProfessionIds", "TemplateType"], parent: '.search-person-popup' }); catalogsFiltered.callback = function () { $('.search-person-popup .adminItems tbody a').unbind('click'); $('.search-person-popup .adminItems tbody a').click(function () { ISPersonEdit.EditShow($(this).data('personid')); //ISPersonEdit.SearchHide(); return false; }); }; } }); } else ISPersonEdit.SearchShowInit(); }, SearchShowInit: function () { $('.search-person-popup').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.search-person-bg').css({ top: 0, height: $(document).outerHeight() }); $('.search-person-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $(".search-person-popup select").not(".ex").chosen(); $(".search-person-popup .close").unbind('click'); $(".search-person-popup .close").click(function () { ISPersonEdit.SearchHide(); return false; }); $('#createitem').unbind('click'); $('#createitem').click(function () { //ISPersonEdit.SearchHide(); ISPersonEdit.EditShow(0); return false; }); $('.search-person-popup .adminItems tbody a').unbind('click'); $('.search-person-popup .adminItems tbody a').click(function () { ISPersonEdit.EditShow($(this).data('personid')); //ISPersonEdit.SearchHide(); return false; }); }, SearchHide: function () { $(".search-person-popup").hide(); $('.edit-person-bg').hide(); }, EditShow: function (Id) { ISPersonEdit.SearchHide(); if ($('.edit-person-bg').length == 0) $('body').append($('
', { 'class': 'edit-person-bg' })); $('.edit-person-bg').show(); if ($('.edit-person-popup').length == 0) $('body').append($('
', { 'class': 'edit-person-popup' })); $.ajax({ url: "/ajax/editperson?v=" + ISCommon.GetV(), data: { Id: Id }, cache: true, success: function (d) { $('.edit-person-popup').html(d.View); ISPersonEdit.EditShowInit(); ISPersonEdit.HistoryId = d.HistoryId; } }); }, EditShowInit: function () { if ($('.edit-person-form #Id').val() != '0') $('.edit-person-popup .heading .messages p').text('Корректировка записи в базе ПЕРСОНАЛИЙ'); else $('.edit-person-popup .heading .messages p').text('Новая запись в базе ПЕРСОНАЛИЙ'); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.edit-person-bg').css({ top: 0, height: $(document).outerHeight() }); $('.edit-person-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-person-popup .heading a.close').unbind('click'); $('.edit-person-popup .heading a.close').click(function () { ISPersonEdit.EditHide(); return false; }); $(".edit-person-form select").not(".ex").chosen(); $(".edit-person-form #Text").ckeditor({ height: 180, 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 () { ISPersonEdit.DataForForm = ISPersonEdit.GetDataFromForm(); $('.edit-person-popup').show(); }); $(".edit-person-form #Coach, .edit-person-form #Coachs").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 () { ISPersonEdit.DataForForm = ISPersonEdit.GetDataFromForm(); $('.edit-person-popup').show(); }); $(".edit-person-form #BirthDate") .datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy" }) .on('changeDate', function (ev) { var BirthDate = new Date(ev.date); $('#BirthYear').val(BirthDate.getFullYear().toString()).trigger("liszt:updated"); }).data('datepicker'); $(".datepicker.datepicker-edit-person .datepicker-days th.prev").html('‹'); $(".datepicker.datepicker-edit-person .datepicker-days th.next").html('›'); $('.edit-person-form .form-actions a.button').unbind('click'); $('.edit-person-form .form-actions a.button').click(function () { ISPersonEdit.Save(); return false; }); $(".edit-person-form .control-group.upload-photo #fileupload").unbind('change'); $(".edit-person-form .control-group.upload-photo #fileupload").change(function () { $('.edit-person-form').ajaxSubmit({ url: '/ajax/uploadperson?v=' + ISCommon.GetV(), success: function (d) { if ('yes' == d.Result) { $(".edit-person-form .control-group.upload-photo .messages").text(''); $('.control-group.upload-photo #Photo').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-person-form .control-group.upload-photo .messages").text(d.Message); } }); }); $('.edit-person-form #SportsIdsList').unbind('change'); $('.edit-person-form #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('Ошибка.'); ISPersonEdit.RegistrationLock = false; } }); } else { ISPersonEdit.RegistrationLock = false; } } return false; }); } };