var user_area = "engine/modules/faq/user_area/"; var q_cache = new Array(); var r_cache = new Array(); function faq_MenuQuestBuild( m_id){ var menu=new Array(); menu[0]='' + faq_menu_reply + ''; menu[1]='' + faq_menu_short + ''; menu[2]='' + faq_menu_full + ''; menu[3]='' + faq_del + ''; return menu; }; function faq_quest_delete( m_id ){ DLEconfirm( dle_del_agree, dle_confirm, function () { document.location= dle_root + dle_admin + '?mod=faq&do=questions&action=delete&id=' + m_id + '&user_hash=' + dle_login_hash; } ); }; function faq_cancel_for_edit( quest_id, event){ if(event=='quest'){ if (q_cache[quest_id] != "" && q_cache[quest_id] != undefined){ $("#quest-id-"+quest_id).html(q_cache[ quest_id ]); } }else{ if (r_cache[ quest_id ] != "" && r_cache[quest_id] != undefined){ $("#reply-id-"+quest_id).html(r_cache[ quest_id ]); } } return false; }; function faq_quest_reply_edit_save( quest_id, event ){ var reply_txt = ''; reply_txt = $('#dleeditnews'+quest_id).html(); var approve = 2; if(document.getElementById('approve')){ approve = (document.getElementById('approve').checked) ? 1 : 0; } var quest_view_edit = 0; if(document.getElementById('quest_view_edit')){ quest_view_edit = (document.getElementById('quest_view_edit').checked) ? 1 : 0; } var quest_editor_reason = ''; if(document.getElementById('quest_editor_reason')){ quest_editor_reason = $('#quest_editor_reason').val(); } var change_author_reply = 0; if(document.getElementById('change_author_reply')){ change_author_reply = (document.getElementById('change_author_reply').checked) ? 1 : 0; } ShowLoading(''); $.post(dle_root + user_area + "ajax/editquest.php", { reply_txt: reply_txt, quest_id: quest_id, quest_view_edit: quest_view_edit, quest_editor_reason: quest_editor_reason, change_author_reply: change_author_reply, approve: approve, field: event, action: "save" }, function(data){ HideLoading(''); r_cache[ quest_id ] = ''; if(event == 'quest'){ $("#quest-id-"+quest_id).html(data); q_cache[ quest_id ] = ''; }else{ $("#reply-id-"+quest_id).html(data); r_cache[ quest_id ] = ''; } if(approve !=2){ if(approve){ $(".quest-approve-"+quest_id).show(); $(".quest-not-approve-"+quest_id).hide(); }else{ $(".quest-not-approve-"+quest_id).show(); $(".quest-approve-"+quest_id).hide(); } } }); return false; }; function faq_quest_reply_edit( quest_id, event ) { if(event == 'quest'){ if ( !q_cache[ quest_id ] || q_cache[ quest_id ] == '' ){ q_cache[ quest_id ] = $('#quest-id-'+quest_id).html(); } faq_cancel_for_edit( quest_id, 'reply' ); }else{ if ( !r_cache[ quest_id ] || r_cache[ quest_id ] == '' ){ r_cache[ quest_id ] = $('#reply-id-'+quest_id).html(); } faq_cancel_for_edit( quest_id, 'quest' ); } ShowLoading(''); $.get(dle_root + user_area + "ajax/editquest.php", { quest_id: quest_id, field: event, action: "edit" }, function(data){ HideLoading(''); div_id = (event == 'quest') ? 'quest-id-'+quest_id : 'reply-id-'+quest_id; RunAjaxJS(div_id, data); setTimeout(function() {$("html:not(:animated)"+( ! $.browser.opera ? ",body:not(:animated)" : "")).animate({scrollTop: $("#" + div_id).position().top - 70}, 700);}, 100); }); return false; }; function faqRate( rate, id, full) { ShowLoading(''); if(full != 1){ var mode = "short"; }else{ var mode = ""; } $.get(dle_root + user_area + "ajax/rating.php", { go_rate: rate, quest_id: id, mode: mode, skin: dle_skin }, function(data){ HideLoading(''); $("#ratig-layer-" + id).html(data); }); return false; }; function faq_comm_rate(rate, com_id){ ShowLoading(''); $.post(dle_root + user_area + "ajax/comments_rating.php", { rate: rate, com_id: com_id }, function(data){ HideLoading(''); $('#rate-down-' + com_id).hide(); $('#rate-up-' + com_id).hide(); $("#rate-id-" + com_id).html(data); }); return false; } // Функции работы с комментариями var c_cache = new Array(); var p_id; function faq_quote_copy(qname){ dle_txt= ''; if (window.getSelection){ dle_txt=window.getSelection(); }else if (document.selection){ dle_txt=document.selection.createRange().text; } if (dle_txt != ""){ dle_txt='[quote='+qname+']'+dle_txt+'[/quote]\n'; } }; function faq_quote_ins(name){ if ( !document.getElementById('dle-comments-form') ) return false; var input=document.getElementById('dle-comments-form').comments; var finalhtml = ""; if (dle_txt!= "") { finalhtml = dle_txt; } else { finalhtml = ""+name+","+"
"; } tinyMCE.execInstanceCommand('comments', 'mceInsertContent', false, finalhtml, true) } function faq_doAddComments(){ var form = document.getElementById('dle-comments-form'); var parent_id = parseInt(form.parent_id.value); var editor_mode = 'wysiwyg'; document.getElementById('comments').value = $('#comments').html(); if (form.comments.value == '' || form.name.value == ''){ DLEalert ( dle_req_field, dle_info ); return false; } if(parent_id > 0){ tinyMCE.execCommand('mceRemoveControl',false,'comments'); $('#faq-comments-form').html($('#form-comm-id-' + parent_id).html()); $('#form-comm-id-' + parent_id).html(''); tinyMCE.execCommand('mceAddControl',false,'comments'); $('#parent_id').val(0); $('#faq-add-anwer').hide(); $('#faq-add-comm').show(); $('#faq-close-button').hide(); $('#next-comm-id-' + parent_id).show(); } if ( form.sec_code ) {var sec_code = form.sec_code.value; } else { var sec_code = ''; } ShowLoading(''); $.post(dle_root + user_area + "ajax/addcomments.php", { editor_mode: editor_mode, post_id: form.post_id.value, name: form.name.value, mail: form.mail.value, comments: form.comments.value, sec_code: sec_code, skin: dle_skin, parent_id: parent_id }, function(data){ HideLoading(''); if (form.sec_code ) { form.sec_code.value = ''; reload(); } var div_id = (parent_id > 0) ? 'next-comm-id-' + parent_id : 'dle-ajax-comments'; RunAjaxJS(div_id, data); if (data != 'error' && document.getElementById('blind-animation')) { $("html"+( ! $.browser.opera ? ",body" : "")).animate({scrollTop: $("#"+div_id).position().top - 70}, 1100); setTimeout(function() { $('#blind-animation').show('blind',{},1500)}, 1100); } }); return false; }; function faq_answer( parent_id ){ if ( !p_id ){ p_id = parent_id; } tinyMCE.execCommand('mceRemoveControl',false,'comments'); form_comm = $('#faq-comments-form').html(); if(form_comm != ""){ $('#faq-comments-form').html(''); $('#form-comm-id-' + parent_id).html(form_comm); tinyMCE.execCommand('mceAddControl',false,'comments'); $('#parent_id').val(parent_id); $('#faq-add-anwer').show(); $('#faq-add-comm').hide(); $('#faq-close-button').show(); $("html"+( ! $.browser.opera ? ",body" : "")).animate({scrollTop: $("#form-comm-id-"+parent_id).position().top - 70}, 1400); }else{ if(p_id == parent_id){ $('#faq-comments-form').html($('#form-comm-id-' + parent_id).html()); $('#form-comm-id-' + parent_id).html(''); tinyMCE.execCommand('mceAddControl',false,'comments'); $('#parent_id').val(0); $('#faq-add-anwer').hide(); $('#faq-add-comm').show(); $('#faq-close-button').hide(); $("html"+( ! $.browser.opera ? ",body" : "")).animate({scrollTop: $("#faq-comments-form").position().top - 70}, 1400); }else{ $('#form-comm-id-' + parent_id).html($('#form-comm-id-' + p_id).html()); $('#form-comm-id-' + p_id).html(''); tinyMCE.execCommand('mceAddControl',false,'comments'); $('#parent_id').val(parent_id); $('#faq-add-anwer').show(); $('#faq-add-comm').hide(); $('#faq-close-button').show(); $("html"+( ! $.browser.opera ? ",body" : "")).animate({scrollTop: $("#form-comm-id-"+parent_id).position().top - 70}, 1400); } } p_id = parent_id; } function faq_close_answer(){ if(p_id){ tinyMCE.execCommand('mceRemoveControl',false,'comments'); $('#faq-comments-form').html($('#form-comm-id-' + p_id).html()); $('#form-comm-id-' + p_id).html(''); tinyMCE.execCommand('mceAddControl',false,'comments'); $('#parent_id').val(0); $('#faq-add-anwer').hide(); $('#faq-add-comm').show(); $('#faq-close-button').hide(); $("html"+( ! $.browser.opera ? ",body" : "")).animate({scrollTop: $("#faq-comments-form").position().top - 70}, 1400); } } function faq_MenuCommBuild( m_id, area){ var menu=new Array(); menu[0]='' + menu_short + ''; return menu; }; function faq_ajax_comm_edit( c_id, area){ if (!c_cache[ c_id ] || c_cache[ c_id ] == '' ){ c_cache[ c_id ] = $('#comm-id-'+c_id).html(); } ShowLoading(''); $.get(dle_root + user_area + "ajax/editcomments.php", { id: c_id, area: area, action: "edit" }, function(data){ HideLoading(''); RunAjaxJS('comm-id-'+c_id, data); setTimeout(function() { $("html:not(:animated)"+( ! $.browser.opera ? ",body:not(:animated)" : "")).animate({scrollTop: $("#comm-id-" + c_id).position().top - 70}, 700); }, 100); }); }; function faq_ajax_cancel_comm_edit( c_id ){ if ( c_cache[ c_id ] != "" ){ $("#comm-id-"+c_id).html(c_cache[ c_id ]); } return false; }; function faq_ajax_save_comm_edit( c_id, area){ var comm_txt = ''; comm_txt = $('#dleeditcomments'+c_id).html(); ShowLoading(''); $.post(dle_root + user_area + "ajax/editcomments.php", { id: c_id, comm_txt: comm_txt, area: area, action: "save" }, function(data){ HideLoading(''); c_cache[ c_id ] = ''; $("#comm-id-"+c_id).html(data); }); return false; }; ///////////////////////////////////////////////////////////////////////////