﻿var PostActionHelper = function(config) {
    var _config = config;

    var confirmBeforeDeletePost = function() {
        var yes = confirm(Resources.Post.Confirm);
        if (yes) {
            var url = new String(_config.deletePostUrl);
            window.location = url;
        }
    };

    var deletePost = function(url) {
        _config.deletePostUrl = url;
        confirmBeforeDeletePost();
    }

    return {

        Setup: function() {
            $.ajaxSetup({ cache: false });
            $(".ancPostDelete").click(function() {
                var url = $('#' + this.id).attr('deleteUrl');
                if (url)
                    deletePost(url);
            });
        }
    };
};