|
@@ -8,7 +8,11 @@ var sheet_view = function(option, success) {
|
|
function SheetView(option) {
|
|
function SheetView(option) {
|
|
this.markControl = option.markControl;
|
|
this.markControl = option.markControl;
|
|
this.server = option.server;
|
|
this.server = option.server;
|
|
- this.sheetConfig = option.sheetConfig;
|
|
|
|
|
|
+ if (option.sheetConfig) {
|
|
|
|
+ this.sheetConfig = JSON.parse(option.sheetConfig);
|
|
|
|
+ } else {
|
|
|
|
+ this.sheetConfig = [];
|
|
|
|
+ }
|
|
this.init();
|
|
this.init();
|
|
this.markControl.on('task.get.success', this, function(event, context, eventObject) {
|
|
this.markControl.on('task.get.success', this, function(event, context, eventObject) {
|
|
this.render(context.task.sheetUrls);
|
|
this.render(context.task.sheetUrls);
|
|
@@ -98,15 +102,12 @@ SheetView.prototype.renderContent = function(content, sheetId) {
|
|
image.canvas = document.getElementById('sheet-canvas');
|
|
image.canvas = document.getElementById('sheet-canvas');
|
|
image.content = content;
|
|
image.content = content;
|
|
var self = this;
|
|
var self = this;
|
|
- if (self.sheetConfig) {
|
|
|
|
- self.sheetConfig = JSON.parse(self.sheetConfig);
|
|
|
|
- };
|
|
|
|
image.onload = function() {
|
|
image.onload = function() {
|
|
- var ctx = self.canvas.getContext("2d");
|
|
|
|
- self.canvas.width = Math.min(image.width, self.content.width());
|
|
|
|
- var scale = self.canvas.width / image.width;
|
|
|
|
- self.canvas.height = image.height * scale;
|
|
|
|
- ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, self.canvas.width, self.canvas.height);
|
|
|
|
|
|
+ var ctx = image.canvas.getContext("2d");
|
|
|
|
+ image.canvas.width = Math.min(image.width, image.content.width());
|
|
|
|
+ var scale = image.canvas.width / image.width;
|
|
|
|
+ image.canvas.height = image.height * scale;
|
|
|
|
+ ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, image.canvas.width, image.canvas.height);
|
|
ctx.fillStyle = "#FFFFFF";
|
|
ctx.fillStyle = "#FFFFFF";
|
|
// if(show){
|
|
// if(show){
|
|
// ctx.fillRect(0, 0, this.canvas.width/2, this.canvas.height*3.7/10);
|
|
// ctx.fillRect(0, 0, this.canvas.width/2, this.canvas.height*3.7/10);
|
|
@@ -114,7 +115,7 @@ SheetView.prototype.renderContent = function(content, sheetId) {
|
|
for (var j = 0; j < self.sheetConfig.length; j++) {
|
|
for (var j = 0; j < self.sheetConfig.length; j++) {
|
|
var config = self.sheetConfig[j];
|
|
var config = self.sheetConfig[j];
|
|
if (config.i == (i + 1)) {
|
|
if (config.i == (i + 1)) {
|
|
- ctx.fillRect(config.x * sacle, config.y * scale, config.w * scale, config.h * scale);
|
|
|
|
|
|
+ ctx.fillRect(config.x * scale, config.y * scale, config.w * scale, config.h * scale);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//this.canvas.toDataURL("image/jpeg");
|
|
//this.canvas.toDataURL("image/jpeg");
|