Вход Регистрация
Файл: components/comments/js/comments.js
Строк: 150
<?php
function addComment(targettarget_idparent_id){
    $(
'.cm_addentry').remove();
    $(
'.cm_add_link').show();
    
$link_span  = $('#cm_add_link'+parent_id);
    
old_html    $link_span.html();
    
loading_img '<img src="/images/ajax-loader.gif"/>';
    
$link_span.html(loading_img);
    $.
post('/components/comments/addform.php', {targettargettarget_idtarget_idparent_idparent_id}, function(data) {
        if(
data){
            $(
"#cm_addentry"+parent_id).html(data).fadeIn();
            $(
'#content').focus();
            
$link_span.html(old_html).hide();
            $(
'#submit_cmm').click(function() {
                $(
'#submit_cmm').attr('disabled''disabled');
                $(
'#cancel_cmm').hide();
                $(
'.submit_cmm').append(loading_img);
                var 
options = {
                    
successshowResponseAdd,
                    
dataType'json'
                
};
                $(
'#msgform').ajaxSubmit(options);
            });
        }
    });
}
function 
showResponseAdd(resultstatusTextxhr$form){

    $(
'.sess_messages').fadeOut();

    if(
statusText == 'success'){
        if(
result.error == true){
            $(
'#error_mess').html(result.text);
            $(
'.sess_messages').fadeIn();
            if(
result.is_captcha){
                
reloadCaptcha('kcaptcha1');
            }
            $(
'#submit_cmm').attr('disabled''');
            $(
'.submit_cmm img').remove();
            $(
'#cancel_cmm').show();
        } else {
            if(
result.is_premod){
                
core.alert(result.is_premod'Внимание!');
                $(
'.cm_addentry').remove();
                $(
'.cm_add_link').show();
            } else {
                $(
'.cm_addentry').remove();
                $(
'.cm_add_link').show();
                
loadComments(result.targetresult.target_idfalse);
                
total_page Number($('#comments_count').html());
                $(
'#comments_count').html(total_page+1);
            }
        }
    } else {
        
core.alert(statusText'Ошибка');
    }

}

function 
showResponseEdit(resultstatusTextxhr$form){

    $(
'#popup_progress').hide();
    $(
'.sess_messages').fadeOut();

    if(
statusText == 'success'){
        if(
result.error == true){
            $(
'#error_mess').html(result.text);
            $(
'.sess_messages').fadeIn();
            $(
'#popup_ok').attr('disabled''');
        } else {
            
core.box_close();
            $(
'#cm_msg_'+result.comment_id).html(result.text);
        }
    } else {
        
core.alert(statusText'Ошибка');
    }

}

function 
editComment(comment_idcsrf_token){
    
core.message('Редактировать комментарий');
    $.
post('/components/comments/addform.php', {action'edit'idcomment_idcsrf_tokencsrf_token}, function(data) {
        if(
data) {
          $(
'#popup_ok').val(core.send).show();
          $(
'#popup_message').html(data);
          $(
'#popup_progress').hide();
        }
    });
    $(
'#popup_ok').click(function(){
        $(
'#popup_ok').attr('disabled''disabled');
        $(
'#popup_progress').show();
        var 
options = {
            
successshowResponseEdit,
            
dataType'json'
        
};
        $(
'#msgform').ajaxSubmit(options);
    });
}

function 
deleteComment(comment_idcsrf_tokenis_delete_tree) {
    
core.confirm('Удалить комментарий?'null, function() {
        $.
post('/comments/delete/'+comment_id, {csrf_tokencsrf_token}, function(result){
            if(
result.error == false){
                if(
is_delete_tree != 1){
                    $(
'#cm_addentry'+comment_id).parent().css('background''#FFAEAE').fadeOut();
                    
total_page Number($('#comments_count').html());
                    $(
'#comments_count').html(total_page-1);
                }
                
loadComments(result.targetresult.target_idfalse);
            }
        }, 
'json');
    });
}

function 
expandComment(id){
    $(
'a#expandlink'+id).hide();
    $(
'div#expandblock'+id).show();
}

function 
loadComments(targettarget_idanchor){

    $(
'div.component').css({opacity:0.4filter:'alpha(opacity=40)'});

    $.
ajax({
            
type"POST",
            
url"/components/comments/comments.php",
            
data"target="+target+"&target_id="+target_id,
            
success: function(data){
                $(
'div.cm_ajax_list').html(data);
                $(
'td.loading').html('');
                if (
anchor){
                    
window.location.hash anchor.substr(1100);
                    $(
'a[href='+anchor+']').css('color''red').attr('title''Вы пришли на страницу по этой ссылке');
                }
                $(
'div.component').css({opacity:1.0filter:'alpha(opacity=100)'});
            }
    });

}

function 
goPage(dirfieldtargettarget_id){

    var 
Number($('#'+field).attr('value')) + dir;
    
loadComments(targettarget_idp);

}

function 
voteComment(comment_idvote){

    $(
'span#votes'+comment_id).html('<img src="/images/ajax-loader.gif" border="0"/>');
    $.
ajax({
            
type"POST",
            
url"/components/comments/vote.php",
            
data"comment_id="+comment_id+"&vote="+vote,
            
success: function(data){
                $(
'span#votes'+comment_id).html(data);
            }
    });

}
?>
Онлайн: 1
Реклама