/* ==================================================================== ОБЕРТКА ДЛЯ ОЖИДАНИЯ JQUERY ==================================================================== */ (function waitForJQuery() { if (typeof jQuery === 'undefined') { // jQuery еще не загружен. Ждем 10 мс и проверяем снова. setTimeout(waitForJQuery, 10); } else { // JQuery загружен, можно запускать основной код. (function($){ // ==================================================================== // КОРРЕКЦИЯ: ПРИНУДИТЕЛЬНАЯ ФИКСАЦИЯ HTTPS // ==================================================================== if (typeof aveabspath !== 'undefined') { aveabspath = 'https://bag.local/'; } // ==================================================================== /*Limit symbols*/ (function($){$.fn.extend({limit:function(limit,element){var interval,f;var self=$(this);$(this).focus(function(){interval=window.setInterval(substring,100)});$(this).blur(function(){clearInterval(interval);substring()});substringFunction="function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";if(typeof element!='undefined')substringFunction+="if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}";substringFunction+="}";eval(substringFunction);substring()}})})(jQuery); function getCaptha(){ now = new Date(); $('#captcha img').attr('src', aveabspath+'inc/captcha.php?cd=' + now); }; // ИСПРАВЛЕННАЯ ФУНКЦИЯ cAction function cAction(obj,action){ var cid; // --- Логика для действий с документом (open/close) --- if (action === 'open' || action === 'close') { cid = DOC_ID; } else { // 1. Пытаемся найти ссылку и взять ID из атрибута rel var $link = $(obj).closest('a.mod_comment_answer'); cid = $link.attr('rel'); // 2. Если rel не найден, берем ID из родительского блока if (typeof cid === 'undefined' || cid === false || cid === '') { cid = $(obj).parents('.mod_comment_box').attr('id'); } } if (typeof cid === 'undefined' || cid === false || cid === '') { console.error("Comment ID not found for action: " + action); return; } if (action=='answer'){ $('#parent_id').val(cid); // --- ИСПРАВЛЕНИЕ: Добавлено .show() для отображения формы после перемещения --- $('#mod_comment_new').insertBefore('#end'+cid).show(); return; } // ... (остальной код для admin actions: delete, lock, open/close) if (UGROUP==1){ $.get(aveabspath+'index.php',{ module: 'comment', action: action, docid: DOC_ID, Id: cid },function(){ if (action=='delete'){ $(obj).parents('.mod_comment_comment').eq(0).remove(); } if (action=='open'){ $('#mod_comment_open').attr('id', 'mod_comment_close').html(COMMENT_SITE_CLOSE); } if (action=='close'){ $('#mod_comment_close').attr('id', 'mod_comment_open').html(COMMENT_SITE_OPEN); } // ==================================================================== // ИСПРАВЛЕНИЕ: ДИНАМИЧЕСКАЯ СМЕНА ИКОНКИ ЗАМКА (Font Awesome) // ==================================================================== if (action=='unlock'){ // Меняем классы: mod_comment_unlock (открыт) -> mod_comment_lock (закрыт) // Меняем цвет: text-success (зеленый) -> text-dark (темный) $(obj).removeClass('mod_comment_unlock text-success') .addClass('mod_comment_lock text-dark') .attr('title',COMMENT_LOCK_LINK) .find('i.fa') // Ищем иконку FA .removeClass('fa-unlock').addClass('fa-lock'); // Меняем иконку } if (action=='lock'){ // Меняем классы: mod_comment_lock (закрыт) -> mod_comment_unlock (открыт) // Меняем цвет: text-dark (темный) -> text-success (зеленый) $(obj).removeClass('mod_comment_lock text-dark') .addClass('mod_comment_unlock text-success') .attr('title',COMMENT_UNLOCK_LINK) .find('i.fa') // Ищем иконку FA .removeClass('fa-lock').addClass('fa-unlock'); // Меняем иконку } // ==================================================================== }); } }; // ИСПРАВЛЕННАЯ ФУНКЦИЯ VALIDATE: Устойчива к отсутствию полей function validate(formData,jqForm,options){ $('.alert').remove(); var form = jqForm ? jqForm[0] : $('#mod_comment_new form')[0]; if (form.comment_author_name && !form.comment_author_name.value){ alert(COMMENT_ERROR_AUTHOR); $(form.comment_author_name).focus(); return false; } if (form.comment_author_email && !form.comment_author_email.value){ alert(COMMENT_ERROR_EMAIL); $(form.comment_author_email).focus(); return false; } if (!form.comment_text || !form.comment_text.value){ alert(COMMENT_ERROR_TEXT); if (form.comment_text) $(form.comment_text).focus(); return false; } if (IS_IM && form.securecode && !form.securecode.value){ alert(COMMENT_ERROR_CAPTCHA); $(form.securecode).focus(); return false; } return true; }; function setClickable(){ $('.editable_text').click(function(){ var cid = $(this).parents('.mod_comment_box').attr('id'); var revert = $(this).html(); var textarea = '
'; var charsLeft = ''+COMMENT_CHARS_LEFT+'
'; var buttonSave = ' '; var buttonReset = ''; $(this).after(''+COMMENT_CHARS_LEFT+'
'; var buttonSave = ' '; var buttonReset = ''; commentTextBlock.after( '