From f67c6fe200fbb92f1ea1e17d744529c8b6012ad5 Mon Sep 17 00:00:00 2001 From: xamgore <xamgore@ya.ru> Date: Fri, 19 Jun 2015 10:30:16 +0300 Subject: [PATCH] Reuse of the same jQuery element --- ~dev_rating/media/js/rating.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index 3f88220c9..50d973b0c 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -36,6 +36,8 @@ $(function () { var g_submoduleTitle = ""; var g_submoduleMaxRate = 0; var g_stdName = ""; + + var jCommonCell = $('.commonCell'); var jTdInfo_wrap = $("#tdInfo_wrap"); var jTdInfo = jTdInfo_wrap.children('#tdInfo'); var g_URL = (window.location.href).split("/"); @@ -356,18 +358,18 @@ $(function () { jThis.children("input").removeAttr("disabled"); } - $(".commonCell").mouseenter(function () { + jCommonCell.mouseenter(function () { if (g_isFocusCell === false) TdFocus($(this)); }); - $(".commonCell").mouseleave(function () { + jCommonCell.mouseleave(function () { if (g_isFocusCell === false) TdUnFocus(); }); var oldRate = 0; - $(".commonCell").focusin(function () { + jCommonCell.focusin(function () { g_isFocusCell = true; TdFocus($(this)); TdInfo($(this)); @@ -378,7 +380,7 @@ $(function () { else oldRate = -1; }); - $(".commonCell").focusout(function () { + jCommonCell.focusout(function () { g_isFocusCell = false; Rating($(this), oldRate); @@ -437,7 +439,7 @@ $(function () { return null; } - $(".commonCell").keydown(function (e) { + jCommonCell.keydown(function (e) { var row = g_row; var col = g_col; var direction; @@ -475,12 +477,12 @@ $(function () { }); // При нажатии на элемент commonCell дочерный input получает фокус - $(".commonCell ").click(function () { + jCommonCell.click(function () { $(this).children("input").focus(); }); // В inputCredit (где баллы вводить) разрешаем вводить только цифры - $(".commonCell").children("input").keydown(function (event) { + jCommonCell.children("input").keydown(function (event) { KeyDownOnlyNumber(event); }); -- GitLab