Вход Регистрация
Файл: adultscript-2.0.3-pro/files/templates/defboot/js/model.js
Строк: 208
<?php
$(document).ready(function() {
    var 
model_id = $("input[name='model_id']").val();

    $(
"button[id='like'],button[id='dislike']").click(function(e) {
        
e.preventDefault();
        
        var 
rating 1;
        if ($(
this).attr('id') == 'dislike') {
            
rating 0;
        }

        $.
ajax({
            
urlbase_url '/ajax.php?s=model_rate',
            
cachefalse,
            
type"POST",
            
dataType"json",
            
data: {model_idmodel_idratingrating},
            
success: function(response) {
                if (
response.status == '1') {
                    var 
color 'text-success';
                    var 
id    'like-icon';
                    if (
rating == '0') {
                        
color 'text-muted';
                        
id    'dislike-icon';
                    }

                    $(
"i[id='" id "']").addClass(color);
                    $(
"button[id='rating']").html(response.code);
                    $(
"button[id='like'],button[id='dislike']").prop('disabled'true);
                } else {
                    $(
"#response").html(close response.msg);
                    $(
"#response").removeClass('alert-success').addClass('alert-danger');
                    $(
"#response").show();
                }
            }
        });

    });    
    
    $(
"button[id='favorite']").click(function(e) {
        
e.preventDefault();

        $.
ajax({
            
urlbase_url '/ajax.php?s=model_favorite',
            
cachefalse,
            
type"POST",
            
dataType"json",
            
data: {model_idmodel_id},
            
success: function(response) {
                if (
response.status == '1') {
                    $(
"i[id='favorite-icon']").addClass('text-danger');
                    $(
"#favorite-count").text(response.total);
                    $(
"button[id='favorite']").prop('disabled'true);
                } else {
                    $(
"#response").html(close response.msg);
                    $(
"#response").removeClass('alert-success').addClass('alert-danger');
                    $(
"#response").show();
                }
            }
        });
    });    

    $(
"span[id='subscribe-button']").on('click''button#subscribe, button#unsubscribe', function(e) {
        
e.preventDefault();
        
        var 
id 'subscribe';
        if ($(
this).attr('id') == 'unsubscribe') {
            
id 'unsubscribe';
        }
          
        $.
ajax({
            
urlbase_url '/ajax.php?s=model_' id,
            
cachefalse,
            
type"POST",
            
dataType"json",
            
data: {model_idmodel_id},
            
success: function(response) {
                if (
response.status == '1') {
                      $(
"#subscribe-button").html(response.code);
                } else {
                    $(
"#response").html(close response.msg);
                    $(
"#response").removeClass('alert-success').addClass('alert-danger');
                    $(
"#response").show();
                }
            }
        });
    });
    
    $(
"button[id='post-comment']").click(function(e) {
        
e.preventDefault();
                
        var 
comment  = $("textarea[name='comment']").val();
        var 
nickname = $("input[name='nickname']").val();
        var 
error    false;
        var 
message  'Your message has been posted!';
            
        if (
comment == '') {
            
message 'Please enter your comment!';
            
error   true;
        } else if (
comment.length 500) {
            
message 'Comment can contain maximum 500 characters!';
            
error   true;
        }
            
        if (
error) {
            $(
"#response-comment").html(message);
            $(
"#response-comment").removeClass('alert-succes').addClass('alert-danger');
            $(
"#response-comment").show();
        }
        
        $.
ajax({
            
urlbase_url '/ajax.php?s=model_comment',
            
cachefalse,
            
type"POST",
            
dataType"json",
            
data: { model_idmodel_idcommentcommentnicknamenickname },
            
success: function(response) {
                if (
response.status == '1') {
                    $(
"input[id='nickname']").val();
                    $(
"textarea[name='comment']").val('');
                    $(
"#total-comments").text(response.total);

                    $(
"#no-comments").hide();

                    $(
"#comments-container").prepend(response.code);
                    $(
"#response-comment").removeClass('alert-danger').addClass('alert-success');
                } else {
                    $(
"#response-comment").removeClass('alert-success').addClass('alert-danger');
                }
                
                $(
"#response-comment").html(close response.msg);
                $(
"#response-comment").show();
            }
        });
    });    
    
    $(
"#comments-container").on('click'"button[id^='comment-delete-']", function(e) {
        
e.preventDefault();
        var 
comment_id = $(this).attr('id').match(/comment-delete-(.*)/)[1];

        $.
ajax({
            
urlbase_url '/ajax.php?s=model_comment_delete',
            
cachefalse,
            
type"POST",
            
dataType"json",
            
data: { comment_idcomment_id },
            
success: function(response) {
                if (
response.status == '1') {
                    $(
"#comment-" comment_id).css('border''1px solid red');
                    $(
"#comment-" comment_id).fadeOut(1000);
                }
                
                if (!$(
".media:visible").length) {
                    $(
"#comments-container").html('<div id="no-comments" class="none">No comments yet!</div>');
                }
            }
        });
    });

    $(
"button[id='comment-pagination']").click(function(e) {
        
e.preventDefault();
        
        var 
page        = $("input[name='comment-page']").val();

        $.
ajax({
            
urlbase_url '/ajax.php?s=model_comment_pagination',
            
cachefalse,
            
type"POST",
            
dataType"json",
            
data: { model_idmodel_idpagepage },
            
success: function(response) {
                if (
response.status == '1') {
                    $(
"input[name='comment-page']").val(response.page);
                    $(
"#comments-container").append(response.code);

                    if (
response.end == '1') {
                        $(
"button[id='comment-pagination']").fadeOut();
                    }
                }
            }
        });
    });    
});
?>
Онлайн: 0
Реклама