ISNewsEdit = { IsInitFirst: false, DataForForm: {}, Init: function () { $('#edit-news').unbind('click'); $('#edit-news').click(function () { ISNewsEdit.InitFirst(); if ($('.edit-news-bg').length == 0) $('body').append($('
', { 'class': 'edit-news-bg' })); $('.edit-news-bg').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.edit-news-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-news-popup').show(); $(".edit-news-popup input[type='radio']").prop('checked', false); $('.edit-news-popup .voting-blocks .toggleR').removeClass('checked'); IShelp.Init(); return false; }); }, 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=6"), $.Deferred(function (deferred) { $(deferred.resolve); }) ).done(function () { $.getScript('/scripts/ckeditor/adapters/jquery.js', function () { $.getScript('/scripts/admin/ckeditoruploadconfig.js', function () { ISNewsEdit.IsInitFirst = true; ISNewsEdit.Show(); }); }); }); } }, Show: function () { $('.edit-news-popup a.close-icon').unbind('click'); $('.edit-news-popup a.close-icon').click(function () { $('.edit-news-popup,.edit-news-bg').hide(); return false; }); if ($(".edit-news-popup input[type='radio']").length) $(".edit-news-popup input[type='radio']").kalypto({ toggleClass: "toggleR", }); $(".edit-news-popup input[type='radio']").click(function () { if (1 == $(this).val()) ISNewsEdit.Authors(); else if (2 == $(this).val()) ISNewsEdit.Sources(); }); }, Authors: function () { if ($('.search-popup.authors-popup').length == 0) { $.ajax({ url: "/ajax/searchauthors?v=" + ISCommon.GetV(), data: {}, cache: true, success: function (d) { $('body').append(d.View); $('.search-popup.authors-popup #RegionId').not(".ex").chosen(); ISNewsEdit.AuthorsShow(); } }); } else ISNewsEdit.AuthorsShow(); }, AuthorsShow: function () { if ($('.search-news-bg').length == 0) $('body').append($('
', { 'class': 'search-news-bg' })); $('.search-news-bg').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.search-popup.authors-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.search-popup.authors-popup').show(); $('.search-popup.authors-popup .close-icon').unbind('click'); $('.search-popup.authors-popup .close-icon').click(function () { $('.search-popup.authors-popup').hide(); return false; }); catalogsFiltered.init({ url: "/ajax/searchauthors?type=ajax", history: false, filter: ["RegionId"], parent: '.search-popup.authors-popup' }); catalogsFiltered.callback = function () { $('.search-popup.authors-popup .adminItems tbody a').unbind('click'); $('.search-popup.authors-popup .adminItems tbody a').click(function () { //ISNewsEdit.NewsEdit($(this).data('authorid'), 0, $(this).data('regionid')); ISNewsEdit.Verification($(this).data('authorid'), 0, $(this).text()); return false; }); }; $('.search-popup.authors-popup .adminItems tbody a').unbind('click'); $('.search-popup.authors-popup .adminItems tbody a').click(function () { //ISNewsEdit.NewsEdit($(this).data('authorid'), 0, $(this).data('regionid')); ISNewsEdit.Verification($(this).data('authorid'), 0, $(this).text()); return false; }); $('.search-popup.authors-popup #createitem').unbind('click'); $('.search-popup.authors-popup #createitem').click(function () { ISNewsEdit.AuthorsEdit(0); return false; }); IShelp.Init(); }, AuthorsEdit: function (Id, action) { if ($('.edit-popup.edit-author-popup').length == 0) $('body').append($('
', { 'class': 'edit-popup edit-author-popup' })); if (action == 'editnews') $('.edit-author-popup').addClass('addauthor'); $.ajax({ url: "/ajax/editauthor?v=" + ISCommon.GetV(), data: { Id: Id }, cache: true, success: function (d) { $('.edit-author-popup').html(d.View); ISNewsEdit.AuthorsEditInit(); } }); }, AuthorsEditInit: function () { $('.edit-author-popup').show(); var newWidth = ($("#container").width() < 700) ? $("#container").width() : 700; $('.edit-author-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-author-popup').show(); $('.edit-author-popup .close-icon').unbind('click'); $('.edit-author-popup .close-icon').click(function () { $('.edit-author-popup').hide(); return false; }); $('.edit-author-popup select').not(".ex").chosen(); $('.edit-author-popup a.button').unbind('click'); $('.edit-author-popup a.button').click(function () { ISNewsEdit.AuthorsSave(); return false; }); $("body").on('change', "#AuthorRegionId", function () { $.ajax({ url: "/ajax/filteredcitiesbyregionid", data: { regionid: $(this).val() }, success: function (d) { var selected = $("#AuthorCityId").val(); $("#AuthorCityId").empty(); if (0 == selected) $("#AuthorCityId").append($('
', { 'class': 'search-news-bg' })); $('.search-news-bg').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.search-popup.sources-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.search-popup.sources-popup').show(); $('.search-popup.sources-popup .close-icon').unbind('click'); $('.search-popup.sources-popup .close-icon').click(function () { $('.search-popup.sources-popup').hide(); return false; }); $('.search-popup.sources-popup #RegionsId,.search-popup.sources-popup #SourcesTypesId').not(".ex").chosen(); catalogsFiltered.init({ url: "/ajax/searchsources?type=ajax", history: false, filter: ['RegionsId', 'SourcesTypesId'], parent: '.search-popup.sources-popup' }); catalogsFiltered.callback = function () { $('.search-popup.sources-popup .adminItems tbody a').unbind('click'); $('.search-popup.sources-popup .adminItems tbody a').click(function () { //ISNewsEdit.NewsEdit(0, $(this).data('sourceid'), $(this).data('regionid')); ISNewsEdit.Verification(0, $(this).data('sourceid'), $(this).text()); return false; }); }; $('.search-popup.sources-popup .adminItems tbody a').unbind('click'); $('.search-popup.sources-popup .adminItems tbody a').click(function () { //ISNewsEdit.NewsEdit(0, $(this).data('sourceid'), $(this).data('regionid')); ISNewsEdit.Verification(0, $(this).data('sourceid'), $(this).text()); return false; }); $('.search-popup.sources-popup #createitem').unbind('click'); $('.search-popup.sources-popup #createitem').click(function () { ISNewsEdit.SourcesEdit(0); return false; }); IShelp.Init(); }, SourcesEdit: function (Id, action) { if ($('.edit-popup.edit-source-popup').length == 0) $('body').append($('
', { 'class': 'edit-popup edit-source-popup' })); if (action == 'editnews') $('.edit-popup.edit-source-popup').addClass('addsource'); $.ajax({ url: "/ajax/editsource?v=" + ISCommon.GetV(), data: { Id: Id }, cache: true, success: function (d) { $('.edit-source-popup').html(d.View); ISNewsEdit.SourcesEditInit(); } }); }, SourcesEditInit: function () { $('.edit-source-popup').show(); var newWidth = ($("#container").width() < 700) ? $("#container").width() : 700; $('.edit-source-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-source-popup').show(); $('.edit-source-popup .close-icon').unbind('click'); $('.edit-source-popup .close-icon').click(function () { $('.edit-source-popup').hide(); return false; }); $('.edit-source-popup select').not(".ex").chosen(); $('.edit-source-popup a.button').unbind('click'); $('.edit-source-popup a.button').click(function () { ISNewsEdit.SourcesSave(); return false; }); $("body").on('change', "#SourceRegionId", function () { $.ajax({ url: "/ajax/filteredcitiesbyregionid", data: { regionid: $(this).val() }, success: function (d) { var selected = $("#SourceCitiesId").val(); $("#SourceCitiesId").empty(); if (0 == selected) $("#SourceCitiesId").append($('
'; mess += '
'; if (AId != 0) mess += 'Подтвердить'; else mess += 'Подтвердить'; mess += '
'; if ($('.registration-person-popup').length == 0) $('body').append('
' + '' + '
' + mess + '
' + '
'); else $('.registration-person-popup .mesageforremove').html(mess); $('.registration-person-popup .verification a').unbind('click'); $('.registration-person-popup .verification a').click(function () { $.ajax({ type: "post", url: "/ajax/verificationnews?v=" + ISCommon.GetV(), data: { AId: AId, SId: SId, A: $(this).data('a'), Email: $('.registration-person-popup .verification #vemail').val() }, cache: true, success: function (d) { if (d.Result == 'yes') { ISNewsEdit.NewsEdit(d.AId, d.SId, d.RegionsId, d.Email); $('.registration-person-popup').hide(); } else { if (d.SId > 0) { $('.registration-person-popup .verification .message') .text('Данный адрес не зарегистрирован в карточке организации. Вы уверены в правильности заполнения данных?'); $('.registration-person-popup .verification a').text('Да, уверен'); $('.registration-person-popup .verification a').data('a', 'add'); } else $('.registration-person-popup .verification .message') .text('Вы ввели неправильный электронный адрес. Повторите попытку или добавьте нового автора'); } } }); return false; }); $('.registration-person-popup').css({ top: $(window).scrollTop() }); $('.registration-person-popup').show(); $('.registration-person-popup .close-icon').unbind('click'); $('.registration-person-popup .close-icon').click(function () { $('.registration-person-popup').hide(); return false; }); }, NewsEdit: function (AId, SId, RId, Email) { if ($('.edit-popup.edit-newsitem-popup').length == 0) $('body').append($('
', { 'class': 'edit-popup edit-newsitem-popup' })); $.ajax({ url: "/ajax/editnews?v=" + ISCommon.GetV(), data: { AId: AId, SId: SId, RId: RId, Email: Email }, cache: true, success: function (d) { $('.edit-newsitem-popup').html(d.View); ISNewsEdit.NewsEditInit(); } }); }, NewsEditInit: function () { $('.edit-newsitem-popup').show(); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.edit-newsitem-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2), 'z-index': 2005 }); $('.edit-newsitem-popup').show(); $('.edit-newsitem-popup .close-icon').unbind('click'); $('.edit-newsitem-popup .close-icon').click(function () { $('.edit-newsitem-popup').hide(); return false; }); $('.edit-newsitem-popup #PublishDate').datepicker({ addClass: 'edit-person', language: "ru", format: "dd.mm.yyyy" }).on('changeDate', function (ev) { $('.edit-newsitem-popup #PublishDate').data('datepicker').hide(); $('.edit-newsitem-popup #PublishDate').val($('.edit-newsitem-popup #PublishDate').val() + " " + $('.edit-newsitem-popup #hiddenPublishDate').val().substr(11)); $('.edit-newsitem-popup #hiddenPublishDate').val($('.edit-newsitem-popup #PublishDate').val()); }).data('datepicker'); $('.edit-newsitem-popup select').not(".ex").chosen(); $(".edit-newsitem-popup textarea#Intro").ckeditor({ height: 100, toolbar: [['Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList', 'Table'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink'], ["Maximize", "Image"]] }); $(".edit-newsitem-popup textarea#Text").ckeditor({ height: 300, toolbar: [['Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList', 'Table'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink'], ["Maximize", "Image"]] }); $('.edit-newsitem-popup a.button').unbind('click'); $('.edit-newsitem-popup a.button').click(function () { ISNewsEdit.NewsSave(); return false; }); $('.edit-newsitem-popup .control-group.upload-photo #fileupload').unbind('change'); $('.edit-newsitem-popup .control-group.upload-photo #fileupload').change(function () { $('.edit-newsitem-popup .edit-form').ajaxSubmit({ url: '/ajax/uploadnewsphoto?v=' + ISCommon.GetV(), success: function (d) { if ('yes' == d.Result) { $('.edit-newsitem-popup .control-group.upload-photo .messages').text(''); $('.edit-newsitem-popup .control-group.upload-photo #PhotoName').val(d.PhotoName); $('.edit-newsitem-popup .control-group.upload-photo #PhotoExtension').val(d.PhotoExtension); $('.edit-newsitem-popup .control-group.upload-photo #FileName').val(d.FileName); $('.edit-newsitem-popup .control-group.upload-photo .image').html( '' ); } else if (d.Message != null && d.Message != '') $('.edit-newsitem-popup .control-group.upload-photo .messages').text(d.Message); } }); }); $('.edit-newsitem-popup #addnewauthor').unbind('click'); $('.edit-newsitem-popup #addnewauthor').click(function () { ISNewsEdit.AuthorsEdit(0, 'editnews'); return false; }); $('.edit-newsitem-popup #addnewsource').unbind('click'); $('.edit-newsitem-popup #addnewsource').click(function () { ISNewsEdit.SourcesEdit(0, 'editnews'); return false; }); $('.edit-newsitem-popup #CategoriesIdsInt').unbind('change'); $('.edit-newsitem-popup #CategoriesIdsInt').change(function () { if ($.inArray("8", $('.edit-newsitem-popup #CategoriesIdsInt').val()) > -1) { $('.edit-newsitem-popup #SportsIdsInt').parent().parent().hide(); $('.edit-newsitem-popup #SportsTypesAdaptiveForChildrenIdsInt').parent().parent().show(); } else { $('.edit-newsitem-popup #SportsIdsInt').parent().parent().show(); $('.edit-newsitem-popup #SportsTypesAdaptiveForChildrenIdsInt').parent().parent().hide(); } }); IShelp.Init(); }, NewsSaveLock: false, NewsSave: function () { if (!ISNewsEdit.NewsSaveLock) { if (ISNewsEdit.NewsValidate()) { ISNewsEdit.NewsSaveLock = true; $.ajax({ type: "post", url: "/ajax/savenews?v=" + ISCommon.GetV() + '&g=' + ISCommon.GetGuid(), data: $(".edit-newsitem-popup form.edit-form").serialize(), cache: true, success: function (d) { ISNewsEdit.NewsSaveLock = false; if (d.Result == 'yes') { if (ISCommon.Guid == '') ISCommon.SetGuid(d.guid); $('.edit-newsitem-popup,.sources-popup,.edit-news-popup,.edit-news-bg').hide(); var mess = (d.Email && d.Email != '') ? '

Ваш материал будет проверен модератором. В случае положительного решения о публикации, на вашу почту ' + d.Email + ' поступит соответствующее сообщение!

' : '

Ваш материал принят и будет опубликован после проверки модератором

'; if ($('.registration-person-popup').length == 0) $('body').append('
' + '' + '
' + mess + '
' + '
'); else $('.registration-person-popup .mesageforremove').html(mess); $('.registration-person-popup').css({ top: $(window).scrollTop() }); $('.registration-person-popup').show(); $('.registration-person-popup .close-icon').unbind('click'); $('.registration-person-popup .close-icon').click(function () { $('.registration-person-popup').hide(); return false; }); } } }); } else { var m = ''; if (this.FieldsError.length) m = this.FieldsError.join(', '); if (m != '') $('.edit-newsitem-popup .form-messages').html('Для сохранения записи необходимо заполнить следующие данные:
' + m).show(); } } }, NewsValidate: function () { this.FieldsError = []; if ($('.edit-newsitem-popup #Title').val() == null || $.trim($('.edit-newsitem-popup #Title').val()) == '') { $('.edit-newsitem-popup #Title').parents('.control-group').addClass('error'); this.FieldsError.push('Название'); } else $('.edit-newsitem-popup #Title').parents('.control-group').removeClass('error'); $('.edit-newsitem-popup .form-messages').html(''); return this.FieldsError.length == 0; } };