|
@@ -18,6 +18,8 @@ function MarkControl(option) {
|
|
this.initTriggers(option);
|
|
this.initTriggers(option);
|
|
//初始化功能模块
|
|
//初始化功能模块
|
|
this.initModules(option);
|
|
this.initModules(option);
|
|
|
|
+ //初始化评卷配置
|
|
|
|
+ this.initSetting(option);
|
|
//初始化成功回调方法
|
|
//初始化成功回调方法
|
|
//console.log('MarkControl init success!');
|
|
//console.log('MarkControl init success!');
|
|
//if (option.success != undefined && typeof(option.success) == 'function') {
|
|
//if (option.success != undefined && typeof(option.success) == 'function') {
|
|
@@ -39,10 +41,10 @@ MarkControl.prototype.initContainer = function() {
|
|
}
|
|
}
|
|
this.container.center = getDom(this.center_dom, this).appendTo(this.container);
|
|
this.container.center = getDom(this.center_dom, this).appendTo(this.container);
|
|
this.container.header = getDom(this.center_header_dom, this).appendTo(this.container.center).find('.header');
|
|
this.container.header = getDom(this.center_header_dom, this).appendTo(this.container.center).find('.header');
|
|
- if(this.option.switchTrackUrl!=undefined && this.option.switchTrackUrl.length>0){
|
|
|
|
- var switchButton = this.container.header.find('#switch-track-button');
|
|
|
|
- switchButton.attr('href', this.option.switchTrackUrl);
|
|
|
|
- switchButton.show();
|
|
|
|
|
|
+ if (this.option.switchTrackUrl != undefined && this.option.switchTrackUrl.length > 0) {
|
|
|
|
+ var switchButton = this.container.header.find('#switch-track-button');
|
|
|
|
+ switchButton.attr('href', this.option.switchTrackUrl);
|
|
|
|
+ switchButton.show();
|
|
}
|
|
}
|
|
this.container.centerContent = getDom(this.center_content_dom, this).appendTo(this.container.center);
|
|
this.container.centerContent = getDom(this.center_content_dom, this).appendTo(this.container.center);
|
|
this.container.imageContent = getDom(this.image_content_dom, this).appendTo(this.container.centerContent);
|
|
this.container.imageContent = getDom(this.image_content_dom, this).appendTo(this.container.centerContent);
|
|
@@ -51,8 +53,8 @@ MarkControl.prototype.initContainer = function() {
|
|
this.container.centerContent.css('height', height - this.container.header.parent().height());
|
|
this.container.centerContent.css('height', height - this.container.header.parent().height());
|
|
|
|
|
|
this.initHeaderAndAssistant();
|
|
this.initHeaderAndAssistant();
|
|
-
|
|
|
|
- this.container.centerList = [];
|
|
|
|
|
|
+
|
|
|
|
+ this.container.centerList = [];
|
|
this.navNumber = 0;
|
|
this.navNumber = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -92,6 +94,50 @@ MarkControl.prototype.initMarkFunction = function() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+MarkControl.prototype.initSetting = function(option) {
|
|
|
|
+ this.userId = option.userId;
|
|
|
|
+ this.settingSyncUrl = option.settingSyncUrl;
|
|
|
|
+ this.localStore = window.localStorage;
|
|
|
|
+ this.setting = {};
|
|
|
|
+
|
|
|
|
+ if (option.defaultSetting != undefined) {
|
|
|
|
+ //读取外部初始化配置
|
|
|
|
+ this.setting = JSON.parse(option.defaultSetting);
|
|
|
|
+ } else if (this.localStore != undefined) {
|
|
|
|
+ //读取本地存储并判断用户标识
|
|
|
|
+ var store = JSON.parse(this.localStore.getItem('mark.setting'));
|
|
|
|
+ if (store != undefined && store.userId != undefined && store.userId == this.userId) {
|
|
|
|
+ this.setting = store.setting;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //强制刷新本地存储
|
|
|
|
+ this.localSettingSave();
|
|
|
|
+ //广播通知所有模块初始化设置
|
|
|
|
+ this.trigger('mark.setting.init', this.setting);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+MarkControl.prototype.localSettingSave = function() {
|
|
|
|
+ if (this.localStore != undefined) {
|
|
|
|
+ this.localStore.setItem('mark.setting', JSON.stringify({
|
|
|
|
+ userId: this.userId,
|
|
|
|
+ setting: this.setting
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+MarkControl.prototype.updateSetting = function(item) {
|
|
|
|
+ if (item == undefined) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (var key in item) {
|
|
|
|
+ this.setting[key] = item[key];
|
|
|
|
+ }
|
|
|
|
+ this.localSettingSave();
|
|
|
|
+ if (this.syncUrl != undefined) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
//增加某个事件的监听方法
|
|
//增加某个事件的监听方法
|
|
MarkControl.prototype.on = function(eventName, caller, callback, async) {
|
|
MarkControl.prototype.on = function(eventName, caller, callback, async) {
|
|
if (eventName && callback && eventName.length > 0 && typeof(callback) == 'function') {
|
|
if (eventName && callback && eventName.length > 0 && typeof(callback) == 'function') {
|
|
@@ -184,12 +230,11 @@ MarkControl.prototype.initTriggers = function(option) {
|
|
this.trigger('center.width.change');
|
|
this.trigger('center.width.change');
|
|
});
|
|
});
|
|
this.on('task.load.finish', this, function(event, context, eventObject) {
|
|
this.on('task.load.finish', this, function(event, context, eventObject) {
|
|
- if(context.task!=undefined){
|
|
|
|
- context.task.spent = new Date().getTime();
|
|
|
|
|
|
+ if (context.task != undefined) {
|
|
|
|
+ context.task.spent = new Date().getTime();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- this.on('mark.focus.change', this, function(event, context, eventObject) {
|
|
|
|
- });
|
|
|
|
|
|
+ this.on('mark.focus.change', this, function(event, context, eventObject) {});
|
|
this.on('task.get.finish', this, function(event, context, eventObject) {
|
|
this.on('task.get.finish', this, function(event, context, eventObject) {
|
|
context.prefetchCallback = undefined;
|
|
context.prefetchCallback = undefined;
|
|
});
|
|
});
|
|
@@ -251,6 +296,9 @@ MarkControl.prototype.initTriggers = function(option) {
|
|
context.task = undefined;
|
|
context.task = undefined;
|
|
self.getTask();
|
|
self.getTask();
|
|
});
|
|
});
|
|
|
|
+ this.on('mark.setting.change', this, function(event, context, eventObject) {
|
|
|
|
+ self.updateSetting(eventObject);
|
|
|
|
+ });
|
|
|
|
|
|
$(document).keypress(this, function(event) {
|
|
$(document).keypress(this, function(event) {
|
|
if (self.context.listenKeyboard != false) {
|
|
if (self.context.listenKeyboard != false) {
|
|
@@ -505,26 +553,26 @@ MarkControl.prototype.submitTask = function(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;
|
|
|
|
- }
|
|
|
|
|
|
+ if (this.option.forceSpecialTag === true) {
|
|
|
|
+ if (task.tagList == undefined || task.tagList == null || task.tagList.length <= 0) {
|
|
|
|
+ markControl.trigger('task.submit.forceSpecialTag');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var submitObj = {
|
|
var submitObj = {
|
|
- statusValue: task.statusValue,
|
|
|
|
- studentId: task.studentId,
|
|
|
|
- libraryId: task.libraryId,
|
|
|
|
- totalScore: task.totalScore,
|
|
|
|
- scoreList: task.scoreList,
|
|
|
|
- trackList: task.trackList,
|
|
|
|
- tagList: task.tagList,
|
|
|
|
- spent: new Date().getTime() - task.spent
|
|
|
|
|
|
+ statusValue: task.statusValue,
|
|
|
|
+ studentId: task.studentId,
|
|
|
|
+ libraryId: task.libraryId,
|
|
|
|
+ totalScore: task.totalScore,
|
|
|
|
+ scoreList: task.scoreList,
|
|
|
|
+ trackList: task.trackList,
|
|
|
|
+ tagList: task.tagList,
|
|
|
|
+ spent: new Date().getTime() - task.spent
|
|
}
|
|
}
|
|
|
|
|
|
this.trigger('task.submit.before');
|
|
this.trigger('task.submit.before');
|
|
-
|
|
|
|
|
|
+
|
|
if (this.taskControl != undefined) {
|
|
if (this.taskControl != undefined) {
|
|
//已定义任务引擎
|
|
//已定义任务引擎
|
|
this.taskControl.submit(submitObj, function(status) {
|
|
this.taskControl.submit(submitObj, function(status) {
|
|
@@ -541,9 +589,9 @@ MarkControl.prototype.submitTask = function(submitUrl) {
|
|
$.ajax({
|
|
$.ajax({
|
|
url: submitUrl,
|
|
url: submitUrl,
|
|
type: 'POST',
|
|
type: 'POST',
|
|
- data: JSON.stringify(submitObj),
|
|
|
|
- dataType: "json",
|
|
|
|
- contentType : 'application/json;charset=utf-8',
|
|
|
|
|
|
+ data: JSON.stringify(submitObj),
|
|
|
|
+ dataType: "json",
|
|
|
|
+ contentType: 'application/json;charset=utf-8',
|
|
success: function(result) {
|
|
success: function(result) {
|
|
if (result.success == true) {
|
|
if (result.success == true) {
|
|
markControl.trigger('task.submit.success');
|
|
markControl.trigger('task.submit.success');
|
|
@@ -560,23 +608,23 @@ MarkControl.prototype.submitTask = function(submitUrl) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-MarkControl.prototype.addNavGroup = function(title, content){
|
|
|
|
|
|
+MarkControl.prototype.addNavGroup = function(title, content) {
|
|
var self = this;
|
|
var self = this;
|
|
self.navNumber++;
|
|
self.navNumber++;
|
|
- var nav = $('<a href="#"><span>'+title+'</span></a>').appendTo(self.container.centerNavbar);
|
|
|
|
|
|
+ var nav = $('<a href="#"><span>' + title + '</span></a>').appendTo(self.container.centerNavbar);
|
|
nav.attr('data-number', self.navNumber);
|
|
nav.attr('data-number', self.navNumber);
|
|
content.attr('data-number', self.navNumber);
|
|
content.attr('data-number', self.navNumber);
|
|
- nav.click(function(){
|
|
|
|
|
|
+ nav.click(function() {
|
|
self.container.centerNavbar.find('a').removeClass('selected');
|
|
self.container.centerNavbar.find('a').removeClass('selected');
|
|
$(this).addClass('selected');
|
|
$(this).addClass('selected');
|
|
-
|
|
|
|
- for(var i in self.container.centerList){
|
|
|
|
- var dom = self.container.centerList[i];
|
|
|
|
- if(dom.attr('data-number')==$(this).attr('data-number')){
|
|
|
|
- dom.show();
|
|
|
|
- }else{
|
|
|
|
- dom.hide();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ for (var i in self.container.centerList) {
|
|
|
|
+ var dom = self.container.centerList[i];
|
|
|
|
+ if (dom.attr('data-number') == $(this).attr('data-number')) {
|
|
|
|
+ dom.show();
|
|
|
|
+ } else {
|
|
|
|
+ dom.hide();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
self.container.centerList.push(content);
|
|
self.container.centerList.push(content);
|