|
@@ -1,110 +1,139 @@
|
|
|
//给分板模块
|
|
|
-var thumbnail = function (option, success) {
|
|
|
- var object = new Thumbnail(option);
|
|
|
- success();
|
|
|
- return object;
|
|
|
+var thumbnail = function(option, success) {
|
|
|
+ var object = new Thumbnail(option);
|
|
|
+ success();
|
|
|
+ return object;
|
|
|
}
|
|
|
|
|
|
function Thumbnail(option) {
|
|
|
- this.markControl = option.markControl;
|
|
|
- this.maxWidth = option.width != undefined ? option.width : 100;
|
|
|
- this.show = false;
|
|
|
- this.loading = false;
|
|
|
- this.imageHeight = undefined;
|
|
|
- this.mousePosition = undefined;
|
|
|
+ var self = this;
|
|
|
|
|
|
- this.init();
|
|
|
- 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 = option.markControl;
|
|
|
+ this.maxWidth = option.width != undefined ? option.width : 100;
|
|
|
+ this.show = false;
|
|
|
+ this.loading = false;
|
|
|
+ this.imageHeight = undefined;
|
|
|
+ this.mousePosition = undefined;
|
|
|
+
|
|
|
+ this.init();
|
|
|
+ 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('mark.setting.init', this, function(event, context,
|
|
|
+ setting) {
|
|
|
+ var show = setting['thumbnail.show'];
|
|
|
+ if (show != undefined && show == true) {
|
|
|
+ self.toggle(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-Thumbnail.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: 60,
|
|
|
- left: 0
|
|
|
- });
|
|
|
+Thumbnail.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 : 60,
|
|
|
+ left : 0
|
|
|
+ });
|
|
|
|
|
|
- this.container.header = getDom(this.container_header_dom, this.markControl).appendTo(this.container);
|
|
|
- this.container.header.width('100%');
|
|
|
+ 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.imageObject = this.container.content.find('img');
|
|
|
- this.imageObject.width('100%');
|
|
|
- this.imageObject.bind('mouseover', function (e) {
|
|
|
- self.updatePosition(e);
|
|
|
- }).bind('mousemove', function (e) {
|
|
|
- self.updatePosition(e);
|
|
|
- }).bind('mouseout', function (e) {
|
|
|
- self.updatePosition();
|
|
|
- }).bind('click', function () {
|
|
|
- if (self.show == true && self.task != undefined && self.mousePosition != undefined) {
|
|
|
- self.markControl.trigger('image.position.change', self.mousePosition.y / self.imageObject.height())
|
|
|
- }
|
|
|
- });
|
|
|
+ this.container.content = getDom(this.container_content_dom,
|
|
|
+ this.markControl).appendTo(this.container);
|
|
|
+ this.container.content.width('100%');
|
|
|
+ this.imageObject = this.container.content.find('img');
|
|
|
+ this.imageObject.width('100%');
|
|
|
+ this.imageObject.bind('mouseover', function(e) {
|
|
|
+ self.updatePosition(e);
|
|
|
+ }).bind('mousemove', function(e) {
|
|
|
+ self.updatePosition(e);
|
|
|
+ }).bind('mouseout', function(e) {
|
|
|
+ self.updatePosition();
|
|
|
+ }).bind(
|
|
|
+ 'click',
|
|
|
+ function() {
|
|
|
+ if (self.show == true && self.task != undefined
|
|
|
+ && self.mousePosition != undefined) {
|
|
|
+ self.markControl.trigger('image.position.change',
|
|
|
+ self.mousePosition.y / self.imageObject.height())
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- this.container.draggable({
|
|
|
- containment: "window"
|
|
|
- });
|
|
|
- this.container.header.find('#close-button').click(function () {
|
|
|
- self.toggle(false);
|
|
|
- });
|
|
|
+ this.container.draggable({
|
|
|
+ containment : "window"
|
|
|
+ });
|
|
|
+ this.container.header.find('#close-button').click(function() {
|
|
|
+ self.toggle(false);
|
|
|
+ self.markControl.trigger('mark.setting.change', {
|
|
|
+ 'thumbnail.show': false
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- this.control = getDom(this.control_dom, this.markControl).appendTo(this.markControl.container.assistant);
|
|
|
- this.control.find('#show-thumbnail-button').click(function () {
|
|
|
- self.markControl.container.assistant.hide();
|
|
|
- self.toggle(true);
|
|
|
- });
|
|
|
- this.control.find('#hide-thumbnail-button').click(function () {
|
|
|
- self.markControl.container.assistant.hide();
|
|
|
- self.toggle(false);
|
|
|
- });
|
|
|
+ this.control = getDom(this.control_dom, this.markControl).appendTo(
|
|
|
+ this.markControl.container.assistant);
|
|
|
+ this.control.find('#show-thumbnail-button').click(function() {
|
|
|
+ self.markControl.container.assistant.hide();
|
|
|
+ self.toggle(true);
|
|
|
+ self.markControl.trigger('mark.setting.change', {
|
|
|
+ 'thumbnail.show' : true
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.control.find('#hide-thumbnail-button').click(function() {
|
|
|
+ self.markControl.container.assistant.hide();
|
|
|
+ self.toggle(false);
|
|
|
+ self.markControl.trigger('mark.setting.change', {
|
|
|
+ 'thumbnail.show' : false
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-Thumbnail.prototype.render = function () {
|
|
|
- var self = this;
|
|
|
- var imageObject = this.imageObject;
|
|
|
- if (this.task != undefined) {
|
|
|
- imageObject[0].src = this.task.imageData;
|
|
|
- imageObject[0].onload = function () {
|
|
|
- if (imageObject[0].height > (self.markControl.container.height() * 0.8)) {
|
|
|
- self.container.content.height(self.markControl.container.height() * 0.8);
|
|
|
- } else {
|
|
|
- self.container.content.height(imageObject[0].height);
|
|
|
- }
|
|
|
- imageObject.show();
|
|
|
- }
|
|
|
- } else {
|
|
|
- imageObject[0].src = '';
|
|
|
- imageObject.hide();
|
|
|
- }
|
|
|
+Thumbnail.prototype.render = function() {
|
|
|
+ var self = this;
|
|
|
+ var imageObject = this.imageObject;
|
|
|
+ if (this.task != undefined) {
|
|
|
+ imageObject[0].src = this.task.imageData;
|
|
|
+ imageObject[0].onload = function() {
|
|
|
+ if (imageObject[0].height > (self.markControl.container.height() * 0.8)) {
|
|
|
+ self.container.content.height(self.markControl.container
|
|
|
+ .height() * 0.8);
|
|
|
+ } else {
|
|
|
+ self.container.content.height(imageObject[0].height);
|
|
|
+ }
|
|
|
+ imageObject.show();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ imageObject[0].src = '';
|
|
|
+ imageObject.hide();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-Thumbnail.prototype.toggle = function (show) {
|
|
|
- if (show == true) {
|
|
|
- this.show = true;
|
|
|
- this.container.show();
|
|
|
- } else {
|
|
|
- this.show = false;
|
|
|
- this.container.hide();
|
|
|
- }
|
|
|
+Thumbnail.prototype.toggle = function(show) {
|
|
|
+ if (show == true) {
|
|
|
+ this.show = true;
|
|
|
+ this.container.show();
|
|
|
+ } else {
|
|
|
+ this.show = false;
|
|
|
+ this.container.hide();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-Thumbnail.prototype.updatePosition = function (e) {
|
|
|
- var position = this.imageObject.offset();
|
|
|
- this.mousePosition = e != undefined ? {
|
|
|
- x: e.pageX - position.left,
|
|
|
- y: e.pageY - position.top
|
|
|
- } : undefined;
|
|
|
+Thumbnail.prototype.updatePosition = function(e) {
|
|
|
+ var position = this.imageObject.offset();
|
|
|
+ this.mousePosition = e != undefined ? {
|
|
|
+ x : e.pageX - position.left,
|
|
|
+ y : e.pageY - position.top
|
|
|
+ } : undefined;
|
|
|
}
|
|
|
|
|
|
Thumbnail.prototype.container_dom = '<div class="score-board score-board-popover" style="display:none"></div>';
|