diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index d8539aea6d68c82460daf59f5d05f9590195625c..05a8297c117dc63b64bdaefabf4e96ba3af2ef7b 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -1,6 +1,7 @@ var $ = jQuery; $(function() { + var cancelFlag = false; function AdjustTable() { var jWrap = $('div.main_layer'); @@ -182,15 +183,26 @@ $(function() { function Rating(jThis, oldRate) { oldRate = parseInt(oldRate); + // Здесь jThis - div rateCell, а не input, который является дочкой - jThis.children("input").attr("disabled", true); + if (cancelFlag) { + var str = "" + if (oldRate != -1) + str = oldRate; + jThis.children("input").val(str); + cancelFlag = false; + return; + } var newRate = 0; if (jThis.children("input").val() !== "") newRate = parseInt(jThis.children("input").val()); + if (newRate == oldRate) return; + jThis.children("input").attr("disabled", true); + var rateResult = newRate; // считаем баллы по строке @@ -230,39 +242,39 @@ $(function() { data: "student="+g_studentID+"&submodule="+g_submoduleID+"&rate="+newRate, complete: function(jqXHR, textStatus) { switch(jqXHR.status) { - case 403: - EventInspector_ShowMsg("Сессия истекла", "error"); - jThis.children("input").val(oldRate); - jThis.children("input").removeAttr("disabled"); - window.location.replace(URLdir); - break; - case 200: - data = $.parseJSON(jqXHR.responseText); - if(data.success === true) { - var correctRate = (rateResult > 100) ? '100+' : rateResult; - jThis.siblings(".rateResultCell").text(correctRate); - - // Открываем доступ к след. ячейке добора баллов - if (jThis.hasClass("additionalCell")) { - nextAdditionalCell = $("#col_" + (g_col + 1) + "_row_" + g_row); - placeholder_max = (rateResult <= 60) ? (60 - rateResult) : (60 - oldRate); - - if (placeholder_max > 0 && nextAdditionalCell.hasClass("additionalCell")) { - nextAdditionalCell.find("input").attr("placeholder", "макс. " + (placeholder_max)); - nextAdditionalCell.find("input").removeAttr("disabled"); + case 403: + EventInspector_ShowMsg("Сессия истекла", "error"); + jThis.children("input").val(oldRate); + jThis.children("input").removeAttr("disabled"); + window.location.replace(URLdir); + break; + case 200: + data = $.parseJSON(jqXHR.responseText); + if(data.success === true) { + var correctRate = (rateResult > 100) ? '100+' : rateResult; + jThis.siblings(".rateResultCell").text(correctRate); + + // Открываем доступ к след. ячейке добора баллов + if (jThis.hasClass("additionalCell")) { + nextAdditionalCell = $("#col_" + (g_col + 1) + "_row_" + g_row); + placeholder_max = (rateResult <= 60) ? (60 - rateResult) : (60 - oldRate); + + if (placeholder_max > 0 && nextAdditionalCell.hasClass("additionalCell")) { + nextAdditionalCell.find("input").attr("placeholder", "макс. " + (placeholder_max)); + nextAdditionalCell.find("input").removeAttr("disabled"); + } } - } - EventInspector_ShowMsg("Балл добавлен/изменен", "success"); - } - else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); - jThis.children("input").removeAttr("disabled"); - break; - default: - EventInspector_ShowMsg(" "+statusCode, "success"); + EventInspector_ShowMsg("Балл добавлен/изменен", "success"); + } + else EventInspector_ShowMsg("Не удалось добавить/изменить балл", "error"); + jThis.children("input").removeAttr("disabled"); + break; + default: + EventInspector_ShowMsg(" "+statusCode, "success"); } - } + } //statusCode: { // 403: function() { // EventInspector_ShowMsg("Сессия истекла", "error"); @@ -325,7 +337,7 @@ $(function() { $(".commonCell").focusout(function(){ g_isFocusCell = false; Rating($(this), oldRate); - + TdUnFocus(); UnsetTdInfo($(this)); controlRowVisualization($(this).parent()); @@ -386,7 +398,9 @@ $(function() { var col = g_col; var direction; switch (e.keyCode) { + case 27: cancelFlag = true; // esc case 13: // enter + case 40: // down arrow direction = Direction.Down; break; case 38: // up arrow @@ -395,9 +409,6 @@ $(function() { case 39: // right arrow direction = Direction.Right; break; - case 40: // down arrow - direction = Direction.Down; - break; case 37: // left arrow direction = Direction.Left; break; @@ -430,6 +441,7 @@ $(function() { // Нажатие на чекбокс "Неявка" $(".absenceCheck").click(function(event) { + controlRowVisualization($(this).parent().parent()); }); @@ -492,5 +504,3 @@ $(function() { }); - -