//查看答案模块
var answer_view = function(option, success) {
    var object = new AnswerView(option);
    success();
    return object;
}

function AnswerView(option) {
    this.markControl = option.markControl;
    this.server = option.server;
    this.init();
    this.markControl.on('task.get.success', this, function(event, context, eventObject) {
        this.render(this.server + context.task.answerUrl);
    });
    this.markControl.on('task.get.none', this, function(event, context, eventObject) {
        this.render();
    });
    this.markControl.on('task.get.before', this, function(event, context, eventObject) {
        this.render();
    });
}

AnswerView.prototype.init = function() {
    this.markControl.initMarkFunction();
    this.toggleButton = getDom(this.toggle_button_dom, this.markControl).appendTo(this.markControl.container.assistant.functionList);
}

AnswerView.prototype.render = function(url) {
    if (url != undefined && url.length > 0) {
        this.toggleButton.attr('href', url);
        this.toggleButton.show();
    } else {
        this.toggleButton.attr('href', '##');
        this.toggleButton.hide();
    }
}

AnswerView.prototype.toggle_button_dom = '<a href="#" target="_blank">标答</a>';