Skip to content
Snippets Groups Projects
Commit 6978639f authored by Denis's avatar Denis Committed by Denis
Browse files

#112 correct table cursor moving has done

parent e21313e6
Branches
Tags
No related merge requests found
...@@ -21,28 +21,26 @@ $(function() { ...@@ -21,28 +21,26 @@ $(function() {
$("div.main_content").ready(AdjustTable); $("div.main_content").ready(AdjustTable);
$(window).resize(AdjustTable); $(window).resize(AdjustTable);
function controlRowVisualization(jRow) {
var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck");
var semesterRate = parseInt(jRow.children(".semesterRateResultCell").text());
var absence = jRow.children(".absenceCell").children(".absenceCheck").is(":checked");
if ((semesterRate < 60) || (absence))
jAutoPassCheckBox.attr("disabled", true);
else
jAutoPassCheckBox.removeAttr("disabled");
}
function controlVisualization() {
function controlRowVisualization(jRow) { $(".autoPassCheck")
var jAutoPassCheckBox = jRow.children(".autoPass").children(".autoPassCheck");
var semesterRate = parseInt(jRow.children(".semesterRateResultCell").text());
var absence = jRow.children(".absenceCell").children(".absenceCheck").is(":checked");
if ((semesterRate < 60) || (absence))
jAutoPassCheckBox.attr("disabled", true);
else
jAutoPassCheckBox.removeAttr("disabled");
}
function controlVisualization() {
$(".autoPassCheck")
.each( function() { .each( function() {
controlRowVisualization($(this).parent().parent()); controlRowVisualization($(this).parent().parent());
}); });
} }
// on page loaded // on page loaded
controlVisualization(); //controlVisualization();
var g_col; var g_col;
var g_row; var g_row;
var g_isFocusCell = false; // Стоит фокус на ячейки или нет var g_isFocusCell = false; // Стоит фокус на ячейки или нет
...@@ -62,7 +60,6 @@ $(function() { ...@@ -62,7 +60,6 @@ $(function() {
// + ID - id дисциплины // + ID - id дисциплины
// + studyGroupID_Filter - studyGroupID для фильтра (Эффект памяти) // + studyGroupID_Filter - studyGroupID для фильтра (Эффект памяти)
var json_settings = $.parseJSON($("#hidden_div").html()); var json_settings = $.parseJSON($("#hidden_div").html());
//console.log(json_settings);
$("#hidden_div").remove(); $("#hidden_div").remove();
filterGroups(json_settings.GroupID_Filter); filterGroups(json_settings.GroupID_Filter);
$(".groupSelector [value='"+ json_settings.GroupID_Filter +"']").attr("selected", "selected"); $(".groupSelector [value='"+ json_settings.GroupID_Filter +"']").attr("selected", "selected");
...@@ -72,10 +69,10 @@ $(function() { ...@@ -72,10 +69,10 @@ $(function() {
function filterGroups(groupID) { function filterGroups(groupID) {
if (groupID == 0) { if (groupID == 0) {
$(".studentsRate tbody") $(".studentsRate tbody")
.children() .children()
.each( function() { .each( function() {
$(this).show(); $(this).show();
}); });
} else { } else {
$(".studentsRate tbody") $(".studentsRate tbody")
.children(":gt(2)") .children(":gt(2)")
...@@ -91,10 +88,10 @@ $(function() { ...@@ -91,10 +88,10 @@ $(function() {
// Ставим подстветку // Ставим подстветку
function TdFocus(jThis){ function TdFocus(jThis){
g_col = jThis.attr('id'); g_col = jThis.attr('id');
g_col = parseInt(g_col.substr(4)); g_col = parseInt(g_col.substr(4));
g_row = jThis.parent('tr').attr('id'); g_row = jThis.parent('tr').attr('id');
g_row = parseInt(g_row.substr(4)); g_row = parseInt(g_row.substr(4));
g_oldRateCell = jThis.children("input").val(); g_oldRateCell = jThis.children("input").val();
$("td#col_" + g_col + ".commonCell").each(function(){ $("td#col_" + g_col + ".commonCell").each(function(){
$(this).children('input').css("background-color", "#f1f1f1"); $(this).children('input').css("background-color", "#f1f1f1");
...@@ -112,7 +109,7 @@ $(function() { ...@@ -112,7 +109,7 @@ $(function() {
}); });
jThis.children('input').css("background-color", "#fff"); jThis.children('input').css("background-color", "#fff");
} }
// Убираем подстветку // Убираем подстветку
function TdUnFocus(){ function TdUnFocus(){
$("td#col_" + g_col + ".commonCell").each(function(){ $("td#col_" + g_col + ".commonCell").each(function(){
...@@ -130,39 +127,38 @@ $(function() { ...@@ -130,39 +127,38 @@ $(function() {
$(this).children('input').css("background-color", "#fff"); $(this).children('input').css("background-color", "#fff");
}); });
} }
function TdInfo(jThis) { function TdInfo(jThis) {
var disciplineType = json_settings.ExamType; var disciplineType = json_settings.ExamType;
var disciplinePassRate = 60; // credit pass rate var disciplinePassRate = 60; // credit pass rate
if (disciplineType === "exam") if (disciplineType === "exam")
disciplinePassRate = 38; disciplinePassRate = 38;
// Получаем подмодуль // Получаем подмодуль
var jCurSubmoduleInfo = $(".RatingTableSubmodulesInfo .col_"+g_col+":first"); var jCurSubmoduleInfo = $(".RatingTableSubmodulesInfo .col_"+g_col+":first");
var jCurSubmoduleHead = $(".RatingTableSubmodulesHead .col_"+g_col+":first"); var jCurSubmoduleHead = $(".RatingTableSubmodulesHead .col_"+g_col+":first");
g_submoduleID = parseInt(jCurSubmoduleInfo.attr("id")); g_submoduleID = parseInt(jCurSubmoduleInfo.attr("id"));
g_submoduleTitle = jCurSubmoduleHead.text(); g_submoduleTitle = jCurSubmoduleHead.text();
if (jCurSubmoduleHead.length < 1 && $(".RatingTableModulesHead .bonus").length > 0 ) if (jCurSubmoduleHead.length < 1 && $(".RatingTableModulesHead .bonus").length > 0 )
g_submoduleTitle = 'Бонусные баллы'; g_submoduleTitle = 'Бонусные баллы';
g_submoduleMaxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate .col_"+g_col).text()); g_submoduleMaxRate = parseInt($(".RatingTableSubmodulesHeadMaxRate .col_"+g_col).text());
console.log(g_col);
// Проверяем допустимое значение (только для добора)
// Проверяем допустимое значение (только для добора)
if (jThis.attr("class").indexOf("additionalCell") >= 0) if (jThis.attr("class").indexOf("additionalCell") >= 0)
{ {
var semesterRate = parseInt(jThis.siblings(".semesterRateResultCell").text()); var semesterRate = parseInt(jThis.siblings(".semesterRateResultCell").text());
if (semesterRate <= disciplinePassRate) if (semesterRate <= disciplinePassRate)
g_submoduleMaxRate = disciplinePassRate - semesterRate; g_submoduleMaxRate = disciplinePassRate - semesterRate;
else else
g_submoduleMaxRate = 0; g_submoduleMaxRate = 0;
} }
// Получаем студента // Получаем студента
g_studentID = jThis.siblings('.studentCell').attr("id"); g_studentID = jThis.siblings('.studentCell').attr("id");
g_studentID = g_studentID.substr(8); g_studentID = g_studentID.substr(8);
g_stdName = jThis.siblings('.studentCell').text(); g_stdName = jThis.siblings('.studentCell').text();
jTdInfo_wrap.show(); jTdInfo_wrap.show();
...@@ -186,83 +182,83 @@ $(function() { ...@@ -186,83 +182,83 @@ $(function() {
oldRate = parseInt(oldRate); oldRate = parseInt(oldRate);
// Здесь jThis - div rateCell, а не input, который является дочкой // Здесь jThis - div rateCell, а не input, который является дочкой
jThis.children("input").attr("disabled", true); jThis.children("input").attr("disabled", true);
var newRate = 0; var newRate = 0;
if (jThis.children("input").val() !== "") if (jThis.children("input").val() !== "")
newRate = parseInt(jThis.children("input").val()); newRate = parseInt(jThis.children("input").val());
var rateResult = newRate; var rateResult = newRate;
// считаем баллы по строке // считаем баллы по строке
if ($("#pageType").val() === "exam") //(jThis.attr("class").indexOf("attemptCell") >= 0) if ($("#pageType").val() === "exam") //(jThis.attr("class").indexOf("attemptCell") >= 0)
{ {
// страница сессии // страница сессии
rateResult += parseInt(jThis.siblings(".semesterRateResultCell").text()); rateResult += parseInt(jThis.siblings(".semesterRateResultCell").text());
jThis.siblings(".additionalCell").each(function(){ jThis.siblings(".additionalCell").each(function(){
if ($(this).children("input").val() !== "") if ($(this).children("input").val() !== "")
rateResult += parseInt($(this).children("input").val()); rateResult += parseInt($(this).children("input").val());
}); });
} }
else if ($("#pageType").val() === "rating") else if ($("#pageType").val() === "rating")
{ {
// страница оценивания // страница оценивания
jThis.siblings(".commonCell").each(function(){ // добавим сумму баллов в соседних ячейках jThis.siblings(".commonCell").each(function(){ // добавим сумму баллов в соседних ячейках
var rate = $(this).children("input").val(); var rate = $(this).children("input").val();
if (rate) if (rate)
rateResult += parseInt(rate); rateResult += parseInt(rate);
}); });
var examRateStr = jThis.siblings(".examCell").children("p").text(); var examRateStr = jThis.siblings(".examCell").children("p").text();
if (examRateStr) if (examRateStr)
rateResult += parseInt(examRateStr); rateResult += parseInt(examRateStr);
} }
if (newRate <= g_submoduleMaxRate) if (newRate <= g_submoduleMaxRate)
{ {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: URLdir + "handler/rating/setRate", url: URLdir + "handler/rating/setRate",
data: "student="+g_studentID+"&submodule="+g_submoduleID+"&rate="+newRate, data: "student="+g_studentID+"&submodule="+g_submoduleID+"&rate="+newRate,
statusCode: { statusCode: {
403: function() { 403: function() {
EventInspector_ShowMsg("Сессия истекла", "error"); EventInspector_ShowMsg("Сессия истекла", "error");
jThis.children("input").val(oldRate); jThis.children("input").val(oldRate);
jThis.children("input").removeAttr("disabled"); jThis.children("input").removeAttr("disabled");
window.location.replace(URLdir); window.location.replace(URLdir);
}, },
200: function(data) { 200: function(data) {
data = $.parseJSON(data); data = $.parseJSON(data);
if(data.success === true) { if(data.success === true) {
var correctRate = (rateResult > 100) ? '100+' : rateResult; var correctRate = (rateResult > 100) ? '100+' : rateResult;
jThis.siblings(".rateResultCell").text(correctRate); jThis.siblings(".rateResultCell").text(correctRate);
EventInspector_ShowMsg("Балл добавлен/изменен", "success"); EventInspector_ShowMsg("Балл добавлен/изменен", "success");
} }
else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error");
jThis.children("input").removeAttr("disabled"); jThis.children("input").removeAttr("disabled");
} }
} }
}); });
} }
else { else {
if (oldRate <= g_submoduleMaxRate) if (oldRate <= g_submoduleMaxRate)
jThis.children("input").val(oldRate); jThis.children("input").val(oldRate);
else else
jThis.children("input").val("0"); jThis.children("input").val("0");
EventInspector_ShowMsg("Текущий балл превышает максимальный для данного модуля", "error"); EventInspector_ShowMsg("Текущий балл превышает максимальный для данного модуля", "error");
jThis.children("input").removeAttr("disabled"); jThis.children("input").removeAttr("disabled");
} }
} }
$(".commonCell").mouseenter(function(){ $(".commonCell").mouseenter(function(){
if (g_isFocusCell === false) if (g_isFocusCell === false)
TdFocus($(this)); TdFocus($(this));
}); });
$(".commonCell").mouseleave(function(){ $(".commonCell").mouseleave(function(){
if (g_isFocusCell === false) if (g_isFocusCell === false)
TdUnFocus(); TdUnFocus();
}); });
var oldRate = 0; var oldRate = 0;
$(".commonCell").focusin(function(){ $(".commonCell").focusin(function(){
g_isFocusCell = true; g_isFocusCell = true;
...@@ -272,7 +268,7 @@ $(function() { ...@@ -272,7 +268,7 @@ $(function() {
oldRate = $(this).children("input").val(); oldRate = $(this).children("input").val();
else oldRate = 0; else oldRate = 0;
}); });
$(".commonCell").focusout(function(){ $(".commonCell").focusout(function(){
g_isFocusCell = false; g_isFocusCell = false;
var newRate = 0; var newRate = 0;
...@@ -282,77 +278,122 @@ $(function() { ...@@ -282,77 +278,122 @@ $(function() {
Rating($(this), oldRate); Rating($(this), oldRate);
TdUnFocus(); TdUnFocus();
UnsetTdInfo($(this)); UnsetTdInfo($(this));
controlRowVisualization($(this).parent()); controlRowVisualization($(this).parent());
}); });
$(".commonCell").keydown(function(e){
var jThis = $(this); var Direction = {
Up: 0,
Right: 1,
Down: 2,
Left: 3
};
/**
* @param direction Direction в каком направлении искать следующую ячейку для перемещения фокуса
* @return jQuery клетка, в которую надо переместиться или null, если в этом направлении нет подходящих ячеек
*/
function getDesiredCell(direction) {
/** Будем искать ячейку в направлении {@see direction} до тех пока не найдем её и пока не
* кончатся ячейки в этом направлении */
var row = g_row; var row = g_row;
var col = g_col; var col = g_col;
var currentCell;
switch (direction) {
case Direction.Up:
do {
row--;
currentCell = $("tr#row_" + row + " td#col_" + g_col + ".commonCell")
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
return currentCell;
case Direction.Right:
do {
col++;
currentCell = $("tr#row_" + g_row + " td#col_" + col + ".commonCell")
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
return currentCell;
case Direction.Down:
do {
row++;
currentCell = $("tr#row_" + row + " td#col_" + g_col + ".commonCell")
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
return currentCell;
case Direction.Left:
do {
col--;
currentCell = $("tr#row_" + g_row + " td#col_" + col + ".commonCell")
} while ((currentCell.length > 0) &&
(currentCell.children("input").attr("disabled") == "disabled"));
return currentCell;
}
return null;
}
// При нажатие Enter (переход к оцениванию след. студента, т.е. ниже) $(".commonCell").keydown(function(e){
if(e.keyCode==13) var row = g_row;
row = row + 1; var col = g_col;
var direction;
// Стрелка влево switch (e.keyCode) {
if(e.keyCode==37) case 13: // enter
col = col - 1; direction = Direction.Down;
break;
// Стрелка вверх case 38: // up arrow
if(e.keyCode==38) direction = Direction.Up;
row = row - 1; break;
case 39: // right arrow
// Стрелка вправо direction = Direction.Right;
if(e.keyCode==39) break;
col = col + 1; case 40: // down arrow
direction = Direction.Down;
// Стрелка вниз break;
if(e.keyCode==40) case 37: // left arrow
row = row + 1; direction = Direction.Left;
break;
default:
if ((e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 ) { return;
var jTempObj = $("tr#row_" + row + " td#col_" + col + ".commonCell");
if (jTempObj.length > 0) {
TdUnFocus();
g_row = row;
g_col = col;
jTempObj.children("input").focus();
}
} }
var whereToMoveFocus = getDesiredCell(direction);
if (whereToMoveFocus.length > 0) {
TdUnFocus();
g_row = row;
g_col = col;
whereToMoveFocus.children("input").focus();
} else
$(this).children("input").blur();
}); });
$(".commonCell input").focusin(function(){ $(".commonCell input").focusin(function(){
$(this).select(); $(this).select();
}); });
// При нажатии на элемент commonCell дочерный input получает фокус // При нажатии на элемент commonCell дочерный input получает фокус
$(".commonCell ").click(function(){ $(".commonCell ").click(function(){
$(this).children("input").focus(); $(this).children("input").focus();
} ); } );
// В inputCredit (где баллы вводить) разрешаем вводить только цифры // В inputCredit (где баллы вводить) разрешаем вводить только цифры
$(".commonCell").children("input").keydown(function(event) { $(".commonCell").children("input").keydown(function(event) {
KeyDownOnlyNumber(event); KeyDownOnlyNumber(event);
}); });
// Нажатие на чекбокс "Автомат" // Нажатие на чекбокс "Автомат"
$(".absenceCheck").click(function(event) { $(".absenceCheck").click(function(event) {
controlRowVisualization($(this).parent().parent()); controlRowVisualization($(this).parent().parent());
}); });
// Фильтр по группе // Фильтр по группе
$(".groupSelector").change(function() { $(".groupSelector").change(function() {
var group = $(this).val(); var group = $(this).val();
if (group >= 0) if (group >= 0)
{ {
filterGroups(group); filterGroups(group);
$.post( $.post(
URLdir + "handler/rating/SelectGroup", URLdir + "handler/rating/SelectGroup",
{ {
"disciplineID": g_disciplineID, "disciplineID": g_disciplineID,
"groupSelected": group "groupSelected": group
}, },
function(data){ function(data){
data = $.parseJSON(data); data = $.parseJSON(data);
...@@ -368,7 +409,7 @@ $(function() { ...@@ -368,7 +409,7 @@ $(function() {
$(".downloadExcel").click(function(){ $(".downloadExcel").click(function(){
$.fileDownload(URLdir + 'handler/FileCreator/GenerateExcelRatingTable', { $.fileDownload(URLdir + 'handler/FileCreator/GenerateExcelRatingTable', {
httpMethod: "POST", httpMethod: "POST",
data: data:
{ {
'disciplineID': g_disciplineID 'disciplineID': g_disciplineID
}, },
...@@ -382,10 +423,10 @@ $(function() { ...@@ -382,10 +423,10 @@ $(function() {
}); });
// Ведомость в формате excel // Ведомость в формате excel
$('body').on('click', '.downloadExcelStatement', function(){ $('body').on('click', '.downloadExcelStatement', function(){
$.fileDownload(URLdir + 'handler/FileCreator/GenerateFinalForm', { $.fileDownload(URLdir + 'handler/FileCreator/GenerateFinalForm', {
httpMethod: "POST", httpMethod: "POST",
data: data:
{ {
"disciplineID": g_disciplineID, "disciplineID": g_disciplineID,
"studyGroupID": parseInt($(this).attr("id").substr(6)) "studyGroupID": parseInt($(this).attr("id").substr(6))
...@@ -399,7 +440,7 @@ $(function() { ...@@ -399,7 +440,7 @@ $(function() {
}); });
}); });
}); });
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment