//查看原始题卡模块
var sheet_view = function(option, success) {
	var object = new SheetView(option);
	success();
	return object;
}

function SheetView(option) {
	this.markControl = option.markControl;
	this.server = option.server;
	this.list = [];
	this.markControl.on('task.get.success', this, function(event, context, eventObject) {
		this.render(context.task.sheetUrls);
	});
	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();
	});
}

SheetView.prototype.render = function(urls) {
	if(urls != undefined && urls.length > 0) {
		for(var i = 0; i < urls.length; i++) {
			var url = urls[i];
			if(this.list.length > i) {
				var item = this.list[i];
				item.nav.show();
				this.renderContent(item.content, url);
			} else {
				var content = $(this.container_dom).appendTo(this.markControl.container.centerContent);
				this.renderContent(content, url);
				this.list.push({
				    nav: this.markControl.addNavGroup('原卷' + (i + 1), content),
				    content: content
				});
			} 
		}
	} else {
		for(var i = 0; i < this.list.length; i++) {
			var item = this.list[i];
			item.nav.hide();
			item.content.empty();
		}
	}
}

SheetView.prototype.renderContent = function(content, url) {
	content.width(this.markControl.container.centerContent.width());
	content.height(this.markControl.container.centerContent.height());
	content.empty();
	content.append($('<img src="'+this.server + url +'">'));
}

SheetView.prototype.container_dom = '<div style="display:none; overflow: scroll"></div>';