Browse Source

重构特殊标记

ting.yin 6 years ago
parent
commit
6abbaa3326

+ 1 - 1
stmms-web/src/main/webapp/WEB-INF/views/modules/mark/markTrack.jsp

@@ -27,7 +27,7 @@
 <script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/change-name.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/change-name.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/tag-process.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/tag-process.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/view-sidebar.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/view-sidebar.js"></script>
-<script type="text/javascript" src="${ctxStatic}/mark-track/js/modules/specialTag.js"></script>
+<script type="text/javascript" src="${ctxStatic}/mark-new/js/modules/specialTag.js"></script>
 </head>
 </head>
 <body>
 <body>
 	<div class="container-fluid" id="container"></div>
 	<div class="container-fluid" id="container"></div>

+ 8 - 8
stmms-web/src/main/webapp/static/mark-new/js/mark-control.js

@@ -496,6 +496,14 @@ MarkControl.prototype.submitTask = function(submitUrl) {
     var submitUrl = submitUrl != undefined && submitUrl.length > 0 ? submitUrl : this.option.submitUrl;
     var submitUrl = submitUrl != undefined && submitUrl.length > 0 ? submitUrl : this.option.submitUrl;
 
 
     if (task != undefined && this.context.submitting != true) {
     if (task != undefined && this.context.submitting != true) {
+        //开启强制标记
+        if(this.option.forceSpecialTag===true){
+        	if(task.tagList==undefined ||task.tagList==null ||task.tagList.length <= 0){
+        		markControl.trigger('task.submit.forceSpecialTag');
+        		return;
+        	}
+        }
+        
         task.markStepList = undefined;
         task.markStepList = undefined;
         task.pictureUrls = undefined;
         task.pictureUrls = undefined;
         task.sheetUrls = undefined;
         task.sheetUrls = undefined;
@@ -507,13 +515,6 @@ MarkControl.prototype.submitTask = function(submitUrl) {
         	
         	
         this.trigger('task.submit.before');
         this.trigger('task.submit.before');
         
         
-        //开启强制标记
-        if(this.option.forceSpecialTag===true){
-        	console.log(task);
-        	if(task.tagList==undefined ||task.tagList==null ||task.tagList.length <= 0){
-        		return;
-        	}
-        }
         if (this.taskControl != undefined) {
         if (this.taskControl != undefined) {
             //已定义任务引擎
             //已定义任务引擎
             this.taskControl.submit(task, function(status) {
             this.taskControl.submit(task, function(status) {
@@ -523,7 +524,6 @@ MarkControl.prototype.submitTask = function(submitUrl) {
                 }
                 }
                 //markControl.context.task = undefined;
                 //markControl.context.task = undefined;
                 markControl.trigger('task.submit.success');
                 markControl.trigger('task.submit.success');
-                markControl.trigger('mark.specialTag.success');
                 //markControl.getTask();
                 //markControl.getTask();
             }, function(message) {
             }, function(message) {
                 markControl.trigger('task.submit.error', message);
                 markControl.trigger('task.submit.error', message);

+ 1 - 3
stmms-web/src/main/webapp/static/mark-new/js/modules/mark-board.js

@@ -4,7 +4,6 @@ var mark_board = function(option, success) {
     success();
     success();
     return object;
     return object;
 }
 }
-
 function MarkBoard(option) {
 function MarkBoard(option) {
     this.markControl = option.markControl;
     this.markControl = option.markControl;
     this.needConfirm = option.needConfirm === true ? true : false;
     this.needConfirm = option.needConfirm === true ? true : false;
@@ -13,7 +12,7 @@ function MarkBoard(option) {
     this.enableSkip = option.enableSkip === true ? true : false;
     this.enableSkip = option.enableSkip === true ? true : false;
     //显分板上是否显示合分样式
     //显分板上是否显示合分样式
     this.showObjectScoreAndSubjectScore = option.showTotalScore === true ? true : false;
     this.showObjectScoreAndSubjectScore = option.showTotalScore === true ? true : false;
-
+    
     this.init();
     this.init();
     this.markControl.on('task.get.before', this, function(event, context, eventObject) {
     this.markControl.on('task.get.before', this, function(event, context, eventObject) {
         this.task = undefined;
         this.task = undefined;
@@ -103,7 +102,6 @@ function MarkBoard(option) {
             }
             }
         }
         }
     });
     });
-
 }
 }
 
 
 MarkBoard.prototype.init = function() {
 MarkBoard.prototype.init = function() {

+ 3 - 2
stmms-web/src/main/webapp/static/mark-new/js/modules/mark-history.js

@@ -84,10 +84,11 @@ MarkHistory.prototype.init = function() {
     this.container.paginator = getDom(this.paginator_dom, this.markControl).appendTo(this.container);
     this.container.paginator = getDom(this.paginator_dom, this.markControl).appendTo(this.container);
     this.container.list = getDom(this.history_list_dom, this.markControl).appendTo(this.container).find('#history-list');
     this.container.list = getDom(this.history_list_dom, this.markControl).appendTo(this.container).find('#history-list');
 
 
+	var self = this;
     this.container.header.find('#close-history-button').click(this, function(event) {
     this.container.header.find('#close-history-button').click(this, function(event) {
         event.data.toggle(false);
         event.data.toggle(false);
-        this.markControl.context.task = undefined;
-        this.markControl.getTask();
+        self.markControl.context.task = undefined;
+        self.markControl.getTask();
     })
     })
     this.container.paginator.find('#last-page-button').click(this, function(event) {
     this.container.paginator.find('#last-page-button').click(this, function(event) {
         var markHistory = event.data;
         var markHistory = event.data;

+ 250 - 0
stmms-web/src/main/webapp/static/mark-new/js/modules/simple-image-view.js

@@ -0,0 +1,250 @@
+//简单多张图片排列显示模块
+var simple_image_view = function(option, success) {
+    var object = new SimpleImageView(option);
+    success();
+    return object;
+}
+
+function SimpleImageView(option) {
+    this.markControl = option.markControl;
+    this.defaultZoom = 100;
+    this.loading = false;
+    this.init();
+    this.markControl.on('step.board.show', this, function(event, context, eventObject) {
+        this.container.removeClass('span12');
+        this.container.addClass('span10');
+
+        this.container.perfectScrollbar('update');
+        if (this.iviewer != undefined) {
+            this.iviewer.iviewer('update');
+        }
+    });
+    this.markControl.on('step.board.hide', this, function(event, context, eventObject) {
+        this.container.removeClass('span10');
+        this.container.addClass('span12');
+
+        this.container.perfectScrollbar('update');
+        if (this.iviewer != undefined) {
+            this.iviewer.iviewer('update');
+        }
+    });
+    this.markControl.on('center.width.change', this, function(event, context, eventObject) {
+        this.container.perfectScrollbar('update');
+        if (this.iviewer != undefined) {
+            this.iviewer.iviewer('update');
+            this.iviewer.iviewer('fit');
+        }
+    });
+    this.markControl.on('view.sidebar.open', this, function(event, context, eventObject) {
+        this.imageControl.hide();
+    });
+    this.markControl.on('view.sidebar.close', this, function(event, context, eventObject) {
+        this.imageControl.show();
+    });
+    this.markControl.on('task.get.before', this, function(event, context, eventObject) {
+        this.task = undefined;
+        this.render();
+    });
+    this.markControl.on('task.get.success', this, function(event, context, eventObject) {
+        this.task = context.task;
+        this.render();
+    });
+    this.markControl.on('task.get.none', this, function(event, context, eventObject) {
+        this.task = undefined;
+        this.render();
+    });
+    this.markControl.on('image.position.change', this, function(event, context, topPercent) {
+        if (this.task != undefined && this.loading == false) {
+            this.updateScrollTop(topPercent);
+        }
+    });
+}
+
+SimpleImageView.prototype.init = function() {
+    this.configCache = {};
+
+    //this.container = getDom(this.container_dom).appendTo(this.markControl.container.imageContent);
+    this.container = this.markControl.container.imageContent;
+    this.container.height(this.markControl.container.centerContent.height());
+    this.container.perfectScrollbar({
+        wheelSpeed: 20
+    });
+
+    this.imageHolder = getDom(this.image_holder_dom, this.markControl).appendTo(this.container);
+    this.imageHolder.width('100%');
+
+    this.imageControl = getDom(this.image_control_dom, this.markControl).insertBefore(this.markControl.container.assistantButton.parent());
+    this.imageControl.find('.zoom-out-button').click(this, function(event) {
+        var iviewer = event.data.iviewer;
+        if (iviewer != undefined) {
+            iviewer.iviewer('zoom_by', 1);
+        }
+    });
+    this.imageControl.find('.zoom-in-button').click(this, function(event) {
+        var iviewer = event.data.iviewer;
+        if (iviewer != undefined) {
+            iviewer.iviewer('zoom_by', -1);
+        }
+    });
+    this.imageControl.find('.zoom-fit-button').click(this, function(event) {
+        var iviewer = event.data.iviewer;
+        if (iviewer != undefined) {
+            iviewer.iviewer('fit');
+        }
+    });
+    this.imageControl.find('.zoom-origin-button').click(this, function(event) {
+        var iviewer = event.data.iviewer;
+        if (iviewer != undefined) {
+            iviewer.iviewer('set_zoom', 100);
+        }
+    });
+    this.imageControl.find('.rotate-button').click(this, function(event) {
+        var iviewer = event.data.iviewer;
+        if (iviewer != undefined) {
+            iviewer.iviewer('angle', 90);
+        }
+    });
+    var self = this;
+    this.container.scroll(function() {
+        if (self.currentConfig != undefined) {
+            self.currentConfig.scrollTop = self.container.scrollTop() / self.imageHolder.height();
+            self.currentConfig.scrollLeft = self.container.scrollLeft() / self.imageHolder.width();
+        }
+    });
+}
+
+SimpleImageView.prototype.render = function() {
+    if (this.task != undefined) {
+        var config = this.configCache[this.task.blockId];
+        if (config == undefined) {
+            config = {
+                zoom: this.defaultZoom
+            };
+            this.configCache[this.task.blockId] = config;
+        }
+        this.currentConfig = config;
+
+        this.loadImage();
+        // this.imageControl.show();
+        // this.imageHolder.show();
+        // this.imageHolder.trigger('mouseenter');
+    } else {
+        this.imageControl.hide();
+        this.imageHolder.hide();
+        this.currentConfig = undefined;
+    }
+}
+
+SimpleImageView.prototype.loadImage = function() {
+    if (this.task.imageData != undefined && this.loading == false) {
+        this.loading = true;
+        if (this.iviewer == undefined) {
+            var self = this;
+            this.iviewer = this.imageHolder.iviewer({
+                src: self.task.imageData,
+                zoom_delta: 1.2,
+                zoom: 100,
+                zoom_min: 10,
+                ui_disabled: true,
+                mousewheel: false,
+                zoom_animation: false,
+                onAfterZoom: function(ev, new_zoom) {
+                    self.onZoomSet(new_zoom);
+                },
+                onStopDrag: function(ev, point) {
+                    self.onStopDrag(point);
+                },
+                onFinishLoad: function(ev, url) {
+                    self.onImageLoad();
+                },
+                angle: function(ev, info) {
+                    self.onRotate(info.angle);
+                }
+            });
+            this.imageHolder.css('overflow', '');
+        } else {
+            this.iviewer.iviewer('loadImage', this.task.imageData);
+        }
+    }
+}
+
+SimpleImageView.prototype.onImageLoad = function() {
+    this.loading = false;
+    this.container.scrollTop(0);
+    if (this.currentConfig != undefined && this.currentConfig.zoom != undefined && this.currentConfig.zoom != this.defaultZoom) {
+        if (this.currentConfig.rotate != undefined && this.currentConfig.rotate > 0) {
+            this.iviewer.iviewer('angle', this.currentConfig.rotate);
+        }
+        if (this.currentConfig.zoom != undefined && this.currentConfig.zoom != this.defaultZoom) {
+            this.iviewer.iviewer('set_zoom', this.currentConfig.zoom);
+        }
+
+    }
+    //this.imageHolder.find('img').css('border', '2px solid');
+
+    // if (this.currentConfig.dx != undefined && this.currentConfig.dy != undefined) {
+    //     this.iviewer.iviewer('moveTo', this.currentConfig.dx, this.currentConfig.dy);
+    // }
+    this.imageControl.show();
+    this.imageHolder.show();
+    this.imageHolder.trigger('mouseenter');
+
+    this.markControl.trigger('task.load.finish');
+}
+
+SimpleImageView.prototype.onZoomSet = function(zoom) {
+    if (this.loading == false && this.currentConfig != undefined) {
+        this.currentConfig.zoom = zoom;
+        this.updateScrollTop(this.currentConfig.scrollTop);
+        this.updateScrollLeft(this.currentConfig.scrollLeft);
+    }
+}
+
+SimpleImageView.prototype.onStopDrag = function(point) {
+    if (this.loading == false) {
+        this.currentConfig.dx = point.x;
+        this.currentConfig.dy = point.y;
+    }
+}
+
+SimpleImageView.prototype.onRotate = function(angle) {
+    if (this.loading == false) {
+        this.currentConfig.rotate = angle;
+    }
+}
+
+SimpleImageView.prototype.updateScrollTop = function(scrollTopPercent) {
+    var height = this.imageHolder.height();
+    var minHeight = this.container.height();
+    if (scrollTopPercent != undefined && scrollTopPercent >= 0 && scrollTopPercent <= 1 && height > minHeight) {
+        var left = height * (1 - scrollTopPercent);
+        var scrollTop = left > minHeight ? (height - left) : (height - minHeight);
+        this.container.scrollTop(scrollTop);
+    } else {
+        this.container.scrollTop(0);
+    }
+}
+
+SimpleImageView.prototype.updateScrollLeft = function(scrollLeftPercent) {
+    var width = this.imageHolder.width();
+    var minWidth = this.container.width();
+    if (scrollLeftPercent != undefined && scrollLeftPercent >= 0 && scrollLeftPercent <= 1 && width > minWidth) {
+        var left = width * (1 - scrollLeftPercent);
+        var scrollLeft = left > minWidth ? (width - left) : (width - minWidth);
+        this.container.scrollLeft(scrollLeft);
+    } else {
+        this.container.scrollLeft(0);
+    }
+}
+
+SimpleImageView.prototype.container_dom = '<div class="image-content"></div>';
+
+SimpleImageView.prototype.image_control_dom = '<em>\
+<a href="#" class="btn zoom-out-button">放大</a>\
+<a href="#" class="btn zoom-in-button">缩小</a>\
+<a href="#" class="btn zoom-fit-button">适应</a>\
+<a href="#" class="btn zoom-origin-button">原始</a>\
+<a href="#" class="btn rotate-button">旋转</a>\
+</em>';
+
+SimpleImageView.prototype.image_holder_dom = '<div style="position: relative;"></div>';

+ 59 - 187
stmms-web/src/main/webapp/static/mark-new/js/modules/single-image-view.js

@@ -7,214 +7,110 @@ var single_image_view = function(option, success) {
 
 
 function SingleImageView(option) {
 function SingleImageView(option) {
     this.markControl = option.markControl;
     this.markControl = option.markControl;
-    this.defaultZoom = 100;
-    this.loading = false;
     this.init();
     this.init();
+    this.markControl.on('center.width.change', this, function(event, context, eventObject) {
+        this.reloadImage();
+        this.markControl.trigger('image.reload.event');
+    });
     this.markControl.on('step.board.show', this, function(event, context, eventObject) {
     this.markControl.on('step.board.show', this, function(event, context, eventObject) {
         this.container.removeClass('span12');
         this.container.removeClass('span12');
         this.container.addClass('span10');
         this.container.addClass('span10');
-
-        this.container.perfectScrollbar('update');
-        if (this.iviewer != undefined) {
-            this.iviewer.iviewer('update');
-        }
+        this.reloadImage();
+        this.markControl.trigger('image.reload.event');
     });
     });
     this.markControl.on('step.board.hide', this, function(event, context, eventObject) {
     this.markControl.on('step.board.hide', this, function(event, context, eventObject) {
         this.container.removeClass('span10');
         this.container.removeClass('span10');
         this.container.addClass('span12');
         this.container.addClass('span12');
-
-        this.container.perfectScrollbar('update');
-        if (this.iviewer != undefined) {
-            this.iviewer.iviewer('update');
-        }
-    });
-    this.markControl.on('center.width.change', this, function(event, context, eventObject) {
-        this.container.perfectScrollbar('update');
-        if (this.iviewer != undefined) {
-            this.iviewer.iviewer('update');
-            this.iviewer.iviewer('fit');
-        }
-    });
-    this.markControl.on('view.sidebar.open', this, function(event, context, eventObject) {
-        this.imageControl.hide();
-    });
-    this.markControl.on('view.sidebar.close', this, function(event, context, eventObject) {
-        this.imageControl.show();
+        this.reloadImage();
+        this.markControl.trigger('image.reload.event');
     });
     });
     this.markControl.on('task.get.before', this, function(event, context, eventObject) {
     this.markControl.on('task.get.before', this, function(event, context, eventObject) {
         this.task = undefined;
         this.task = undefined;
+        this.image = undefined;
         this.render();
         this.render();
     });
     });
     this.markControl.on('task.get.success', this, function(event, context, eventObject) {
     this.markControl.on('task.get.success', this, function(event, context, eventObject) {
         this.task = context.task;
         this.task = context.task;
+        this.image = undefined;
         this.render();
         this.render();
     });
     });
     this.markControl.on('task.get.none', this, function(event, context, eventObject) {
     this.markControl.on('task.get.none', this, function(event, context, eventObject) {
         this.task = undefined;
         this.task = undefined;
+        this.image = undefined;
         this.render();
         this.render();
     });
     });
+    this.markControl.on('mark.tag.show', this, function(event, context, tag){
+        if(this.task != undefined && tag != undefined){
+        	this.drawTag(tag);
+        }
+    });
+    this.markControl.on('mark.tag.clear', this, function(event, context, track){
+        this.reloadImage();
+        this.markControl.trigger('image.reload.event');
+    });
     this.markControl.on('image.position.change', this, function(event, context, topPercent) {
     this.markControl.on('image.position.change', this, function(event, context, topPercent) {
-        if (this.task != undefined && this.loading == false) {
+        if (this.task != undefined) {
             this.updateScrollTop(topPercent);
             this.updateScrollTop(topPercent);
         }
         }
     });
     });
 }
 }
 
 
 SingleImageView.prototype.init = function() {
 SingleImageView.prototype.init = function() {
-    this.configCache = {};
-
-    //this.container = getDom(this.container_dom).appendTo(this.markControl.container.imageContent);
+    var self = this;
     this.container = this.markControl.container.imageContent;
     this.container = this.markControl.container.imageContent;
     this.container.height(this.markControl.container.centerContent.height());
     this.container.height(this.markControl.container.centerContent.height());
-    this.container.perfectScrollbar({
-        wheelSpeed: 20
-    });
-
-    this.imageHolder = getDom(this.image_holder_dom, this.markControl).appendTo(this.container);
-    this.imageHolder.width('100%');
-
-    this.imageControl = getDom(this.image_control_dom, this.markControl).insertBefore(this.markControl.container.assistantButton.parent());
-    this.imageControl.find('.zoom-out-button').click(this, function(event) {
-        var iviewer = event.data.iviewer;
-        if (iviewer != undefined) {
-            iviewer.iviewer('zoom_by', 1);
-        }
-    });
-    this.imageControl.find('.zoom-in-button').click(this, function(event) {
-        var iviewer = event.data.iviewer;
-        if (iviewer != undefined) {
-            iviewer.iviewer('zoom_by', -1);
-        }
-    });
-    this.imageControl.find('.zoom-fit-button').click(this, function(event) {
-        var iviewer = event.data.iviewer;
-        if (iviewer != undefined) {
-            iviewer.iviewer('fit');
-        }
-    });
-    this.imageControl.find('.zoom-origin-button').click(this, function(event) {
-        var iviewer = event.data.iviewer;
-        if (iviewer != undefined) {
-            iviewer.iviewer('set_zoom', 100);
-        }
-    });
-    this.imageControl.find('.rotate-button').click(this, function(event) {
-        var iviewer = event.data.iviewer;
-        if (iviewer != undefined) {
-            iviewer.iviewer('angle', 90);
-        }
-    });
-    var self = this;
-    this.container.scroll(function() {
-        if (self.currentConfig != undefined) {
-            self.currentConfig.scrollTop = self.container.scrollTop() / self.imageHolder.height();
-            self.currentConfig.scrollLeft = self.container.scrollLeft() / self.imageHolder.width();
+    this.container.css('overflow','scroll');
+    
+    this.canvas = $('<canvas></canvas>').appendTo(this.container)[0];
+    this.ctx = this.canvas.getContext("2d");
+    
+    $(this.canvas).click(function(event){
+        if(self.task != undefined){
+        	self.markControl.trigger('image.click.event', {
+        		positionX: ((event.pageX - $(self.canvas).offset().left)/$(self.canvas).width()).toFixed(3),
+                positionY: ((event.pageY - $(self.canvas).offset().top)/$(self.canvas).height()).toFixed(3)
+        	});
         }
         }
     });
     });
 }
 }
 
 
 SingleImageView.prototype.render = function() {
 SingleImageView.prototype.render = function() {
-    if (this.task != undefined) {
-        var config = this.configCache[this.task.blockId];
-        if (config == undefined) {
-            config = {
-                zoom: this.defaultZoom
-            };
-            this.configCache[this.task.blockId] = config;
-        }
-        this.currentConfig = config;
-
-        this.loadImage();
-        // this.imageControl.show();
-        // this.imageHolder.show();
-        // this.imageHolder.trigger('mouseenter');
-    } else {
-        this.imageControl.hide();
-        this.imageHolder.hide();
-        this.currentConfig = undefined;
-    }
-}
-
-SingleImageView.prototype.loadImage = function() {
-    if (this.task.imageData != undefined && this.loading == false) {
-        this.loading = true;
-        if (this.iviewer == undefined) {
-            var self = this;
-            this.iviewer = this.imageHolder.iviewer({
-                src: self.task.imageData,
-                zoom_delta: 1.2,
-                zoom: 100,
-                zoom_min: 10,
-                ui_disabled: true,
-                mousewheel: false,
-                zoom_animation: false,
-                onAfterZoom: function(ev, new_zoom) {
-                    self.onZoomSet(new_zoom);
-                },
-                onStopDrag: function(ev, point) {
-                    self.onStopDrag(point);
-                },
-                onFinishLoad: function(ev, url) {
-                    self.onImageLoad();
-                },
-                angle: function(ev, info) {
-                    self.onRotate(info.angle);
-                }
-            });
-            this.imageHolder.css('overflow', '');
-        } else {
-            this.iviewer.iviewer('loadImage', this.task.imageData);
-        }
-    }
-}
-
-SingleImageView.prototype.onImageLoad = function() {
-    this.loading = false;
-    this.container.scrollTop(0);
-    if (this.currentConfig != undefined && this.currentConfig.zoom != undefined && this.currentConfig.zoom != this.defaultZoom) {
-        if (this.currentConfig.rotate != undefined && this.currentConfig.rotate > 0) {
-            this.iviewer.iviewer('angle', this.currentConfig.rotate);
-        }
-        if (this.currentConfig.zoom != undefined && this.currentConfig.zoom != this.defaultZoom) {
-            this.iviewer.iviewer('set_zoom', this.currentConfig.zoom);
+    var self = this;
+    $(this.canvas).hide();
+    if (this.task != undefined && this.task.imageData != undefined) {
+        //设置画布大小及背景颜色
+        this.image = new Image();
+        this.image.src = this.task.imageData;
+        this.image.onload = function(){
+            self.canvas.width = Math.min(self.container.width(), self.image.width);
+            self.canvas.height = self.canvas.width * self.image.height / self.image.width;
+            self.ctx.fillStyle = "#FFFFFF";
+            self.ctx.drawImage(self.image, 0, 0, self.image.width, self.image.height, 0, 0, self.canvas.width, self.canvas.height);
+            $(self.canvas).show();
+            
+            self.markControl.trigger('task.load.finish');
         }
         }
-
     }
     }
-    //this.imageHolder.find('img').css('border', '2px solid');
-
-    // if (this.currentConfig.dx != undefined && this.currentConfig.dy != undefined) {
-    //     this.iviewer.iviewer('moveTo', this.currentConfig.dx, this.currentConfig.dy);
-    // }
-    this.imageControl.show();
-    this.imageHolder.show();
-    this.imageHolder.trigger('mouseenter');
-
-    this.markControl.trigger('task.load.finish');
 }
 }
 
 
-SingleImageView.prototype.onZoomSet = function(zoom) {
-    if (this.loading == false && this.currentConfig != undefined) {
-        this.currentConfig.zoom = zoom;
-        this.updateScrollTop(this.currentConfig.scrollTop);
-        this.updateScrollLeft(this.currentConfig.scrollLeft);
+SingleImageView.prototype.reloadImage = function() {
+    if(this.image != undefined){
+    	this.canvas.width = Math.min(this.container.width(), this.image.width);
+        this.canvas.height = this.canvas.width * this.image.height / this.image.width;
+        this.ctx.drawImage(this.image, 0, 0, this.image.width, this.image.height, 0, 0, this.canvas.width, this.canvas.height);
     }
     }
 }
 }
 
 
-SingleImageView.prototype.onStopDrag = function(point) {
-    if (this.loading == false) {
-        this.currentConfig.dx = point.x;
-        this.currentConfig.dy = point.y;
-    }
-}
-
-SingleImageView.prototype.onRotate = function(angle) {
-    if (this.loading == false) {
-        this.currentConfig.rotate = angle;
+SingleImageView.prototype.drawTag = function(tag){
+    if(tag!=undefined && tag.positionX>0 && tag.positionY>0){
+        this.ctx.font ="60px Arial";
+        this.ctx.fillStyle = 'red';
+        this.ctx.fillText(tag.content, tag.positionX*this.canvas.width, tag.positionY*this.canvas.height);
     }
     }
 }
 }
 
 
 SingleImageView.prototype.updateScrollTop = function(scrollTopPercent) {
 SingleImageView.prototype.updateScrollTop = function(scrollTopPercent) {
-    var height = this.imageHolder.height();
+    var height = this.canvas.height;
     var minHeight = this.container.height();
     var minHeight = this.container.height();
     if (scrollTopPercent != undefined && scrollTopPercent >= 0 && scrollTopPercent <= 1 && height > minHeight) {
     if (scrollTopPercent != undefined && scrollTopPercent >= 0 && scrollTopPercent <= 1 && height > minHeight) {
         var left = height * (1 - scrollTopPercent);
         var left = height * (1 - scrollTopPercent);
@@ -223,28 +119,4 @@ SingleImageView.prototype.updateScrollTop = function(scrollTopPercent) {
     } else {
     } else {
         this.container.scrollTop(0);
         this.container.scrollTop(0);
     }
     }
-}
-
-SingleImageView.prototype.updateScrollLeft = function(scrollLeftPercent) {
-    var width = this.imageHolder.width();
-    var minWidth = this.container.width();
-    if (scrollLeftPercent != undefined && scrollLeftPercent >= 0 && scrollLeftPercent <= 1 && width > minWidth) {
-        var left = width * (1 - scrollLeftPercent);
-        var scrollLeft = left > minWidth ? (width - left) : (width - minWidth);
-        this.container.scrollLeft(scrollLeft);
-    } else {
-        this.container.scrollLeft(0);
-    }
-}
-
-SingleImageView.prototype.container_dom = '<div class="image-content"></div>';
-
-SingleImageView.prototype.image_control_dom = '<em>\
-<a href="#" class="btn zoom-out-button">放大</a>\
-<a href="#" class="btn zoom-in-button">缩小</a>\
-<a href="#" class="btn zoom-fit-button">适应</a>\
-<a href="#" class="btn zoom-origin-button">原始</a>\
-<a href="#" class="btn rotate-button">旋转</a>\
-</em>';
-
-SingleImageView.prototype.image_holder_dom = '<div style="position: relative;"></div>';
+}

+ 38 - 39
stmms-web/src/main/webapp/static/mark-track/js/modules/mark-board.js

@@ -7,14 +7,13 @@ var mark_board = function(option, success) {
 
 
 function MarkBoard(option) {
 function MarkBoard(option) {
 	this.markControl = option.markControl;
 	this.markControl = option.markControl;
-	this.timeoutSecond = 0.2;
+	this.timeoutSecond = 0.4;
 	this.needConfirm = option.needConfirm === true ? true : false;
 	this.needConfirm = option.needConfirm === true ? true : false;
 	this.autoSubmit = option.autoSubmit === false ? false : true;
 	this.autoSubmit = option.autoSubmit === false ? false : true;
 	this.enableSkip = option.enableSkip === true ? true : false;
 	this.enableSkip = option.enableSkip === true ? true : false;
-  //显分板上是否显示合分样式
-  this.showObjectScoreAndSubjectScore = option.showTotalScore === true ? true : false;
-
-	this.init();
+	//显分板上是否显示合分样式
+	this.showObjectScoreAndSubjectScore = option.showTotalScore === true ? true : false;
+	this.init(this.markControl.option.forceSpecialTag);
 	this.markControl.on('task.get.before', this, function(event, context, eventObject) {
 	this.markControl.on('task.get.before', this, function(event, context, eventObject) {
 		this.task = undefined;
 		this.task = undefined;
 		this.stepList = undefined;
 		this.stepList = undefined;
@@ -25,8 +24,16 @@ function MarkBoard(option) {
 	this.markControl.on('task.load.finish', this, function(event, context, eventObject) {
 	this.markControl.on('task.load.finish', this, function(event, context, eventObject) {
 		this.initByTask(context.task);
 		this.initByTask(context.task);
 	});
 	});
-	this.markControl.on('mark.track.set', this, function(event, context, track) {
-		if(track != undefined && this.currentStep != undefined && this.currentStep.currentScore != undefined) {
+	this.markControl.on('special.tag.enable', this, function(event, context, eventObject) {
+		this.specialTag=true;
+	});
+	this.markControl.on('special.tag.disable', this, function(event, context, eventObject) {
+		this.specialTag=false;
+	});
+	this.markControl.on('image.click.event', this, function(event, context, track) {
+		if(track != undefined && this.currentStep != undefined 
+			&& this.currentStep.currentScore != undefined
+			&& this.specialTag!=true) {
 			track.score = this.currentStep.currentScore;
 			track.score = this.currentStep.currentScore;
 			track.questionNumber = this.currentStep.questionNumber;
 			track.questionNumber = this.currentStep.questionNumber;
 			track.number = this.currentStep.trackList.length + 1;
 			track.number = this.currentStep.trackList.length + 1;
@@ -34,9 +41,26 @@ function MarkBoard(option) {
 			this.resetScore();
 			this.resetScore();
 			this.updateStepScore();
 			this.updateStepScore();
 			this.trySetScore(track.score);
 			this.trySetScore(track.score);
-			this.markControl.trigger('mark.track.show', track);
+			this.markControl.trigger('mark.tag.show', {
+				content: track.score,
+				positionX: track.positionX,
+				positionY: track.positionY
+			});
 		}
 		}
 	});
 	});
+	//图片重新加载后,恢复显示所有标记
+    this.markControl.on('image.reload.event', this, function(event, context, eventObject) {
+		for(var i = 0; i < this.stepList.length; i++) {
+			var step = this.stepList[i];
+			for(var j = 0; j < step.trackList.length; j++) {
+				this.markControl.trigger('mark.tag.show', {
+					content: step.trackList[j].score,
+					positionX: step.trackList[j].positionX,
+					positionY: step.trackList[j].positionY
+				});
+			}
+		}
+    });
 	this.markControl.on('key.press', this, function(e, context, event) {
 	this.markControl.on('key.press', this, function(e, context, event) {
         var code = event.keyCode;
         var code = event.keyCode;
         //console.log('key press:' + code);
         //console.log('key press:' + code);
@@ -57,24 +81,9 @@ function MarkBoard(option) {
             }
             }
         }
         }
     });
     });
-
-    this.markControl.on('click.specialTag.before', this, function(event, context, eventObject) {
-        this.resetScore();
-    });
-    this.markControl.on('show.track.event',this ,function(event,context,eventObject){
-        if(this.stepList == undefined) {
-            return;
-        }
-        for(var i = 0; i < this.stepList.length; i++) {
-            var step = this.stepList[i];
-            for(var j = 0; j < step.trackList.length; j++) {
-                this.markControl.trigger('mark.track.show', step.trackList[j]);
-            }
-        }
-    });
 }
 }
 
 
-MarkBoard.prototype.init = function() {
+MarkBoard.prototype.init = function(forceSpecialTag) {
 	var self = this;
 	var self = this;
 	this.stepBoard = getDom(this.step_board_dom, this.markControl).appendTo(this.markControl.container.centerContainer);
 	this.stepBoard = getDom(this.step_board_dom, this.markControl).appendTo(this.markControl.container.centerContainer);
 	this.stepBoard.height(this.markControl.container.centerContent.height());
 	this.stepBoard.height(this.markControl.container.centerContent.height());
@@ -90,30 +99,29 @@ MarkBoard.prototype.init = function() {
 	this.stepBoard.find('.task-submit-button').click(this, function(event) {
 	this.stepBoard.find('.task-submit-button').click(this, function(event) {
 		self.onTaskSubmit();
 		self.onTaskSubmit();
 	});
 	});
+	//给分板上是否显示全零分
+	if(forceSpecialTag===true){
+		this.stepBoard.find('.all-zero-button').attr("type","hidden");
+	}
 	this.stepBoard.find('.all-zero-button').click(this, function(event) {
 	this.stepBoard.find('.all-zero-button').click(this, function(event) {
 		self.allZeroSubmit();
 		self.allZeroSubmit();
 	});
 	});
 	this.stepBoard.find('.undo-last-track-button').click(this, function() {
 	this.stepBoard.find('.undo-last-track-button').click(this, function() {
-        self.markControl.trigger('click.track.before');
 		if(self.currentStep != undefined && self.currentStep.trackList.length>0) {
 		if(self.currentStep != undefined && self.currentStep.trackList.length>0) {
 			self.currentStep.trackList.pop();
 			self.currentStep.trackList.pop();
 			self.updateStepScore();
 			self.updateStepScore();
 			self.refreshTrack();
 			self.refreshTrack();
-			//self.markControl.trigger('mark.track.clear');
 		}
 		}
 	});
 	});
 	this.stepBoard.find('.clear-current-track-button').click(this, function() {
 	this.stepBoard.find('.clear-current-track-button').click(this, function() {
-        self.markControl.trigger('click.track.before');
 		if(self.currentStep != undefined) {
 		if(self.currentStep != undefined) {
 			self.currentStep.currentScore = undefined;
 			self.currentStep.currentScore = undefined;
 			self.currentStep.trackList = [];
 			self.currentStep.trackList = [];
 			self.updateStepScore();
 			self.updateStepScore();
 			self.refreshTrack();
 			self.refreshTrack();
-			//self.markControl.trigger('mark.track.clear');
 		}
 		}
 	});
 	});
 	this.stepBoard.find('.clear-all-track-button').click(this, function() {
 	this.stepBoard.find('.clear-all-track-button').click(this, function() {
-        self.markControl.trigger('click.track.before');
 		if(self.stepList != undefined) {
 		if(self.stepList != undefined) {
 			for(var i = 0; i < self.stepList.length; i++) {
 			for(var i = 0; i < self.stepList.length; i++) {
 				self.stepList[i].currentScore = undefined;
 				self.stepList[i].currentScore = undefined;
@@ -121,7 +129,6 @@ MarkBoard.prototype.init = function() {
 				self.updateStepScore(self.stepList[i]);
 				self.updateStepScore(self.stepList[i]);
 			}
 			}
 			self.refreshTrack();
 			self.refreshTrack();
-			//self.markControl.trigger('mark.track.clear');
 		}
 		}
 	});
 	});
     var dom5 = this.stepBoard.find(".sublist");
     var dom5 = this.stepBoard.find(".sublist");
@@ -276,8 +283,6 @@ MarkBoard.prototype.inputTimeout = function() {
 }
 }
 
 
 MarkBoard.prototype.onScoreClick = function(scoreNumber) {
 MarkBoard.prototype.onScoreClick = function(scoreNumber) {
-    //禁止 特殊标识的使用
-    this.markControl.trigger('click.track.before');
 	if(this.task == undefined || this.currentStep == undefined) {
 	if(this.task == undefined || this.currentStep == undefined) {
 		return;
 		return;
 	}
 	}
@@ -326,13 +331,7 @@ MarkBoard.prototype.refreshTrack = function() {
 	if(this.stepList == undefined) {
 	if(this.stepList == undefined) {
 		return;
 		return;
 	}
 	}
-	this.markControl.trigger('mark.track.clear');
-	for(var i = 0; i < this.stepList.length; i++) {
-		var step = this.stepList[i];
-		for(var j = 0; j < step.trackList.length; j++) {
-			this.markControl.trigger('mark.track.show', step.trackList[j]);
-		}
-	}
+	this.markControl.trigger('mark.tag.clear');
 }
 }
 
 
 MarkBoard.prototype.updateStepScore = function(step) {
 MarkBoard.prototype.updateStepScore = function(step) {

+ 9 - 33
stmms-web/src/main/webapp/static/mark-track/js/modules/single-image-view.js

@@ -26,25 +26,14 @@ function SingleImageView(option) {
         this.image = undefined;
         this.image = undefined;
         this.render();
         this.render();
     });
     });
-    this.markControl.on('mark.track.show', this, function(event, context, track){
-        if(this.task != undefined && track != undefined){
-        	this.drawScore(track);
+    this.markControl.on('mark.tag.show', this, function(event, context, tag){
+        if(this.task != undefined && tag != undefined){
+        	this.drawTag(tag);
         }
         }
     });
     });
-
-    this.markControl.on('mark.specialTag.show', this, function(event, context, specialTag){
-        if(this.task != undefined && specialTag != undefined){
-        	this.drawTag(specialTag);
-        }
-    });
-    this.markControl.on('mark.track.clear', this, function(event, context, track){
+    this.markControl.on('mark.tag.clear', this, function(event, context, track){
         this.reloadImage();
         this.reloadImage();
-        //显示特殊标记的历史痕迹
-        this.markControl.trigger('show.specialTag.event');
-    });
-    this.markControl.on('mark.specialTag.clear', this, function(event, context, track){
-        this.reloadImage();
-        this.markControl.trigger('show.track.event');
+        this.markControl.trigger('image.reload.event');
     });
     });
 }
 }
 
 
@@ -62,12 +51,7 @@ SingleImageView.prototype.init = function() {
     
     
     $(this.canvas).click(function(event){
     $(this.canvas).click(function(event){
         if(self.task != undefined){
         if(self.task != undefined){
-        	self.markControl.trigger('mark.track.set', {
-        		positionX: ((event.pageX - $(self.canvas).offset().left)/$(self.canvas).width()).toFixed(3),
-                positionY: ((event.pageY - $(self.canvas).offset().top)/$(self.canvas).height()).toFixed(3)
-        	});
-
-        	self.markControl.trigger('mark.specialTag.set', {
+        	self.markControl.trigger('image.click.event', {
         		positionX: ((event.pageX - $(self.canvas).offset().left)/$(self.canvas).width()).toFixed(3),
         		positionX: ((event.pageX - $(self.canvas).offset().left)/$(self.canvas).width()).toFixed(3),
                 positionY: ((event.pageY - $(self.canvas).offset().top)/$(self.canvas).height()).toFixed(3)
                 positionY: ((event.pageY - $(self.canvas).offset().top)/$(self.canvas).height()).toFixed(3)
         	});
         	});
@@ -100,19 +84,11 @@ SingleImageView.prototype.reloadImage = function() {
     }
     }
 }
 }
 
 
-SingleImageView.prototype.drawScore = function(track){
-    if(track != undefined && track.positionX > 0 && track.positionY > 0){
-        this.ctx.font ="60px Arial";
-        this.ctx.fillStyle = 'red';
-        this.ctx.fillText(track.score, track.positionX*this.canvas.width, track.positionY*this.canvas.height);
-    }
-}
-
-SingleImageView.prototype.drawTag = function(specialTag){
-    if(specialTag != undefined && specialTag.positionX > 0 && specialTag.positionY > 0){
+SingleImageView.prototype.drawTag = function(tag){
+    if(tag != undefined && tag.positionX > 0 && tag.positionY > 0){
         this.ctx.font ="60px Arial";
         this.ctx.font ="60px Arial";
         this.ctx.fillStyle = 'red';
         this.ctx.fillStyle = 'red';
-        this.ctx.fillText(specialTag.tagName, specialTag.positionX*this.canvas.width, specialTag.positionY*this.canvas.height);
+        this.ctx.fillText(tag.content, tag.positionX*this.canvas.width, tag.positionY*this.canvas.height);
     }
     }
 }
 }
 
 

+ 0 - 165
stmms-web/src/main/webapp/static/mark-track/js/modules/specialTag.js

@@ -1,165 +0,0 @@
-//特殊标识模块
-var specialTag = function(option, success) {
-    var object = new SpecialTag(option);
-    success();
-    return object;
-}
-
-function SpecialTag(option) {
-    this.markControl = option.markControl;
-    this.maxWidth = option.width != undefined ? option.width : 200;
-    this.show = false;
-    this.tagList = [];
-    this.specialTag = undefined;
-    this.init();
-    this.markControl.on('mark.specialTag.set', this, function(event, context, specialTag) {
-        if(this.specialTag != undefined && this.tagList != undefined){
-            specialTag.tagName = this.specialTag;
-            this.tagList.push(specialTag);
-            this.markControl.trigger('mark.specialTag.show', specialTag);
-        }
-    })
-    //提交保存之前
-    this.markControl.on('mark.specialTag.before', this, function(event, context, eventObject) {
-        this.task = context.task;
-        if (this.tagList.length > 0) {
-            this.task.tagList = this.tagList;
-        } else {
-            this.task.tagList = undefined;
-        }
-    });
-    //提交保存成功后
-    this.markControl.on('mark.specialTag.success', this, function(event, context, eventObject) {
-        this.markControl.trigger('clear.specialTag.click');
-        this.specialTag = undefined;
-        this.tagList = [];
-    });
-
-    //禁止 特殊标识使用
-    this.markControl.on('click.track.before', this, function(event, context, eventObject) {
-        this.specialTag = undefined;
-        this.markControl.trigger('clear.specialTag.click');
-    });
-
-    //显示痕迹
-    this.markControl.on('show.specialTag.event', this, function(event, context, eventObject) {
-        this.task = context.task;
-        if(this.task != undefined ){
-            if(this.tagList.length == 0 && this.task.tagList != null && this.task.tagList.length>0){
-                this.tagList = this.task.tagList;
-            }
-            for(var j = 0; j <this.tagList.length; j++) {
-                this.markControl.trigger('mark.specialTag.show', this.tagList[j]);
-            }
-        }
-    });
-
-    //清除按钮选中
-    this.markControl.on('clear.specialTag.click', this, function(event, context, eventObject) {
-        this.specialTag = undefined;
-        var aList = this.onclickList.find('a');
-        for(var i =0 ;i < aList.length;i++){
-                $(aList[i]).removeClass('selected');
-        }
-    })
-}
-
-SpecialTag.prototype.init = function() {
-    var self = this;
-    this.container = getDom(this.container_dom, this.markControl).appendTo(this.markControl.container);
-    this.container.width(this.maxWidth);
-    this.container.offset({
-        top: 100,
-        left:800
-    });
-
-    this.container.header = getDom(this.container_header_dom, this.markControl).appendTo(this.container);
-    this.container.header.width('100%');
-
-    this.container.content = getDom(this.container_content_dom, this.markControl).appendTo(this.container);
-    this.container.content.width('100%');
-
-    this.onclickList = this.container.content.find('#problem-list');
-
-    this.clearList = this.container.content.find('#clear');
-
-    this.container.draggable({
-        containment: "window"
-    });
-
-    this.onclickList.find('a').click(function () {
-        self.specialTag = undefined;
-        self.markControl.trigger('click.specialTag.before');
-        if($(this).hasClass('selected')){
-            $(this).removeClass('selected');
-        }else {
-            self.specialTag = $(this).attr('value');
-            $(this).addClass('selected');
-            var aList = self.onclickList.find('a');
-            for(var i =0 ;i < aList.length;i++){
-                if($(aList[i]).attr('value') != $(this).attr('value')){
-                    $(aList[i]).removeClass('selected');
-                }
-            }
-        }
-    });
-
-    this.clearList.find('a').click(function () {
-        self.markControl.trigger('clear.specialTag.click');
-        self.markControl.trigger('click.specialTag.before');
-        if(self.tagList != undefined && self.tagList.length>0){
-            self.markControl.trigger('mark.specialTag.clear');
-            if($(this).attr('class') == 'goBack'){
-                    self.tagList.pop();
-                    self.markControl.trigger('show.specialTag.event');
-                }else if($(this).attr('class') == 'clearAll'){
-                    self.tagList = [];
-                    self.task.tagList = [];
-            }
-        }
-    });
-
-    this.container.header.find('#close-button').click(function() {
-        self.toggle(false);
-    });
-
-    this.control = getDom(this.control_dom, this.markControl).appendTo(this.markControl.container.assistant);
-    this.control.find('#show-SpecialTag-button').click(function() {
-        self.markControl.container.assistant.hide();
-        self.toggle(true);
-    });
-    this.control.find('#hide-SpecialTag-button').click(function() {
-        self.markControl.container.assistant.hide();
-        self.toggle(false);
-    });
-}
-
-SpecialTag.prototype.toggle = function(show) {
-    this.specialTag = undefined;
-    if (show == true) {
-        this.show = true;
-        this.container.show();
-    } else {
-        this.show = false;
-        this.container.hide();
-    }
-}
-
-SpecialTag.prototype.container_dom = '<div class="score-board score-board-popover" style="display:none"></div>';
-
-SpecialTag.prototype.container_header_dom = '<div class="header" style="border-radius: 15px 15px 0px 0px;">\
-<p class="fl" id="header">特殊标记</p>\
-<a class="header-close" id="close-button" href="#"><img src="{staticServer}/images/close.png"></a>\
-</div>';
-
-SpecialTag.prototype.container_content_dom = '<div class="content popover-content" style="padding:4px;border-radius: 0px 0px 15px 15px;">\
-<p id="problem-list" class="popover-list buttonCss">\
-    <a href="#" value="√">√</a>\
-    <a href="#" value="X">×</a>\
-    <a href="#" value="乄">乄</a>\
-    </p><p id="clear"><a href="#" class="goBack" style="margin-left: 20px;">回&nbsp;&nbsp;&nbsp;退</a><a href="#" class="clearAll">全部清除</a></p></div>';
-
-SpecialTag.prototype.control_dom = '<h3 class="popover-title">特殊标记</h3>\
-<div class="popover-content"><p id="problem-list" class="popover-list">\
-<a href="#" id="show-SpecialTag-button">打开</a><a href="#" id="hide-SpecialTag-button">关闭</a>\
-</p></div>';

+ 3 - 0
stmms-web/src/main/webapp/static/mark-track/js/modules/warning-info.js

@@ -45,6 +45,9 @@ function WarningInfo(option) {
     this.markControl.on('task.submit.error', this, function(event, context, eventObject) {
     this.markControl.on('task.submit.error', this, function(event, context, eventObject) {
         this.toggle(true, '网络异常,任务提交失败', '关闭');
         this.toggle(true, '网络异常,任务提交失败', '关闭');
     });
     });
+    this.markControl.on('task.submit.forceSpecialTag', this, function(event, context, eventObject) {
+        this.toggle(true, '强制标记已开启,至少使用一个标记', '关闭');
+    });
 }
 }
 
 
 WarningInfo.prototype.init = function() {
 WarningInfo.prototype.init = function() {