ISOrganizationEdit = { IsInitFirst: false, HistoryId: 0, DataForForm: {}, OrganizationId: 0, OrganizationsClassId: 0, Init: function () { $('#edit-organization, .org-popup #edit-organization').unbind('click'); $('#edit-organization, .org-popup #edit-organization').click(function () { var oId = parseInt($(this).data('organizationid')); ISOrganizationEdit.OrganizationId = isNaN(oId) ? 0 : oId; if (ISOrganizationEdit.IsInitFirst) { if (ISOrganizationEdit.OrganizationId > 0) ISOrganizationEdit.EditShow(ISOrganizationEdit.OrganizationId); else ISOrganizationEdit.SearchShow(); } else ISOrganizationEdit.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 (ISOrganizationEdit.OrganizationId > 0) ISOrganizationEdit.EditShow(ISOrganizationEdit.OrganizationId); else ISOrganizationEdit.SearchShow(); ISOrganizationEdit.IsInitFirst = true; }); }); }); } }, SearchShow: function () { if ($('.edit-organization-bg').length == 0) $('body').append($('
', { 'class': 'edit-organization-bg' })); $('.edit-organization-bg').show(); if ($('.search-organization-popup').length == 0) { $.ajax({ url: "/ajax/searchorganization?v=" + ISCommon.GetV(), data: { OrganizationsClassId: this.OrganizationsClassId }, cache: true, success: function (d) { $('body').append(d.View); ISOrganizationEdit.SearchShowInit(); catalogsFiltered.init({ url: "/ajax/searchorganization?type=ajax", history: false, filter: ["SportIds", "SportIdsTypesAdaptive", "OrganizationsClassId", "OrganizationsTypesId"], parent: '.search-organization-popup' }); catalogsFiltered.callback = function () { $('.search-organization-popup .adminItems tbody a').unbind('click'); $('.search-organization-popup .adminItems tbody a').click(function () { ISOrganizationEdit.EditShow($(this).data('organizationid')); return false; }); }; } }); } else ISOrganizationEdit.SearchShowInit(); }, SearchShowInit: function () { $('.search-organization-popup').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.search-organization-bg').css({ top: 0, height: $(document).outerHeight() }); $('.search-organization-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $(".search-organization-popup select").not(".ex").chosen(); $(".search-organization-popup .close").unbind('click'); $(".search-organization-popup .close").click(function () { ISOrganizationEdit.SearchHide(); return false; }); $('#createitem').unbind('click'); $('#createitem').click(function () { ISOrganizationEdit.SearchHide(); ISOrganizationEdit.EditShow(0); return false; }); $('.search-organization-popup .adminItems tbody a').unbind('click'); $('.search-organization-popup .adminItems tbody a').click(function () { ISOrganizationEdit.EditShow($(this).data('organizationid')); return false; }); $('.search-organization-popup #OrganizationsClassId').unbind('change'); $('.search-organization-popup #OrganizationsClassId').change(function () { if ($(this).val()) { $.ajax({ url: "/ajax/filteredorganizationstypesbyorganizationsclass?v=" + ISCommon.GetV(), data: { OrganizationsClassId: $(this).val() }, success: function (d) { var selected = $(".search-organization-popup #OrganizationsTypesId").val(); $(".search-organization-popup #OrganizationsTypesId").empty(); $(".search-organization-popup #OrganizationsTypesId").append($("
', { 'class': 'edit-organization-bg' })); $('.edit-organization-bg').show(); if ($('.edit-organization-popup').length == 0) $('body').append($('
', { 'class': 'edit-organization-popup' })); $.ajax({ url: "/ajax/editorganization?v=" + ISCommon.GetV(), data: { Id: Id, OrganizationsClassId: ISOrganizationEdit.OrganizationsClassId }, cache: true, success: function (d) { $('.edit-organization-popup').html(d.View); ISOrganizationEdit.HistoryId = d.HistoryId; ISOrganizationEdit.EditShowInit(); } }); }, EditShowInit: function () { $('.search-organization-popup').hide(); if ($('.edit-organization-form #Id').val() != '0') $('.edit-organization-popup .heading .messages p').text('Корректировка записи в базе ОРГАНИЗАЦИЙ'); else $('.edit-organization-popup .heading .messages p').text('Новая запись в базе ОРГАНИЗАЦИЙ'); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.edit-organization-bg').css({ top: 0, height: $(document).outerHeight() }); $('.edit-organization-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-organization-popup .heading a.close').unbind('click'); $('.edit-organization-popup .heading a.close').click(function () { ISOrganizationEdit.EditHide(); return false; }); $(".edit-organization-form select").not(".ex").chosen(); $(".edit-organization-form #Text").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 () { ISOrganizationEdit.DataForForm = ISOrganizationEdit.GetDataFromForm(); $('.edit-organization-popup').show(); }); $(".edit-organization-form #President,.edit-organization-form #Address").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 () { ISOrganizationEdit.DataForForm = ISOrganizationEdit.GetDataFromForm(); $('.edit-organization-popup').show(); }); $(".edit-organization-form #BirthDate") .datepicker({ addClass: 'edit-organization', 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'); $('.edit-organization-form .form-actions a.button').unbind('click'); $('.edit-organization-form .form-actions a.button').click(function () { ISOrganizationEdit.Save(); return false; }); $(".edit-organization-form .control-group.upload-photo #fileupload").unbind('change'); $(".edit-organization-form .control-group.upload-photo #fileupload").change(function () { $('.edit-organization-form').ajaxSubmit({ url: '/ajax/uploadorganization?v=' + ISCommon.GetV(), 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-organization-form .control-group.upload-photo .messages").text(d.Message); } }); }); $('.edit-organization-form #Name, .edit-organization-form #NameMini').unbind('change'); $('.edit-organization-form #Name, .edit-organization-form #NameMini').change(function () { if (($('.edit-organization-form #Name').val() != '' || $('.edit-organization-form #NameMini').val() != '') && $('.edit-organization-form #Id').val() == '0') { $.ajax({ url: "/ajax/checkorganizations?v=" + ISCommon.GetV(), data: { N: $('.edit-organization-form #Name').val(), NM: $('.edit-organization-form #NameMini').val(), OrganizationsClassId: ISOrganizationEdit.OrganizationsClassId }, cache: true, success: function (d) { if ('yes' == d.Result) { $('.edit-organization-popup .heading .messages a').text(''); if (d.Organizations.length > 0) { var message = "Найдено 0 организации:"; if (d.Organizations.length == 1 || (d.Organizations.length > 20 && d.Organizations.length % 10 == 1)) message = "Найдена " + d.Organizations.length + " организация:"; else if ((d.Organizations.length > 4 && d.Organizations.length < 21) || (d.Organizations.length > 20 && (d.Organizations.length % 10 > 4 || d.Organizations.length % 10 == 0))) message = "Найдено " + d.Organizations.length + " организации:"; else if ((d.Organizations.length > 1 && d.Organizations.length < 5) || (d.Organizations.length > 20 && d.Organizations.length % 10 > 1 && d.Organizations.length % 10 < 5)) message = "Найдено " + d.Organizations.length + " организации:"; for (var i = 0; i < d.Organizations.length; i++) message += '
' + d.Organizations[i].Name + ''; $('.edit-organization-popup .heading .messages a').html(message); $('.edit-organization-popup .heading .messages a').show(); $('.edit-organization-popup .heading .messages a span').unbind('click'); $('.edit-organization-popup .heading .messages a span').click(function () { ISOrganizationEdit.EditShow($(this).data('organizationid')); return false; }); } else $('.edit-organization-popup .heading .messages a').hide(); } else $('.edit-organization-popup .heading .messages a').hide(); } }); } }); $('.edit-organization-popup .heading .messages a').unbind('click'); $('.edit-organization-popup .heading .messages a').click(function () { $('.registration-organization-popup').css({ top: $(window).scrollTop() }); $('.registration-organization-popup').css({ 'z-index': '1200' }); $('.registration-organization-popup').show(); $('.registration-organization-popup .inside_popup').hide(); $('.registration-organization-popup .mesageforremove').show(); return false; }); $('.edit-organization-popup #EOrganizationsClassId').unbind('change'); $('.edit-organization-popup #EOrganizationsClassId').change(function () { if ($(this).val()) { $.ajax({ url: "/ajax/filteredorganizationstypesbyorganizationsclass?v=" + ISCommon.GetV(), data: { OrganizationsClassId: $(this).val() }, success: function (d) { var selected = $(".edit-organization-popup #EOrganizationsTypesId").val(); $(".edit-organization-popup #EOrganizationsTypesId").empty(); $(".edit-organization-popup #EOrganizationsTypesId").append($("

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

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