From 5dafb02cbfa795c9fbffde8dd95930805c1332f0 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 14 Mar 2018 23:58:26 +0300 Subject: [PATCH 1/3] Resize checkboxes only when they are visible --- code/html/custom.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/html/custom.js b/code/html/custom.js index d423a801..577b4029 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -559,9 +559,9 @@ function toggleMenu() { function showPanel() { $(".panel").hide(); - $("#" + $(this).attr("data")).show(); if ($("#layout").hasClass("active")) { toggleMenu(); } - $("input[type='checkbox']"). + $("#" + $(this).attr("data")).show(). + find("input[type='checkbox']"). iphoneStyle("calculateDimensions"). iphoneStyle("refresh"); } @@ -674,9 +674,13 @@ function addSchedule(event) { }); $(line).find(".button-del-schedule").on("click", delSchedule); $(line).find(".button-more-schedule").on("click", moreSchedule); - var ena = $(line).find(":checkbox"); - ena.prop("checked", false).iphoneStyle("refresh"); line.appendTo("#schedules"); + + $(line).find("input[type='checkbox']"). + prop("checked", false). + iphoneStyle("calculateDimensions"). + iphoneStyle("refresh"); + return line; } From 04fa014bdef5d554d2717970bc17ba6fb07d3d16 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 15 Mar 2018 11:43:17 +0300 Subject: [PATCH 2/3] use native selectors for checkboxes --- code/html/custom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/html/custom.js b/code/html/custom.js index 577b4029..655e257c 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -701,7 +701,7 @@ function initRelays(data) { $(".id", line).html(i); $("input", line).attr("data", i); line.appendTo("#relays"); - $(":checkbox", line).iphoneStyle({ + $("input[type='checkbox']", line).iphoneStyle({ onChange: doToggle, resizeContainer: true, resizeHandle: true, @@ -1083,7 +1083,7 @@ function processData(data) { var sch_value = schedule[key]; $("input[name='" + key + "']", sch_line).val(sch_value); $("select[name='" + key + "']", sch_line).prop("value", sch_value); - $(":checkbox[name='" + key + "']", sch_line). + $("input[type='checkbox'][name='" + key + "']", sch_line). prop("checked", sch_value). iphoneStyle("refresh"); }); From e7f7df54b34ca4a8ee8b9b7960b8a0bc1cee6d26 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 15 Mar 2018 11:48:13 +0300 Subject: [PATCH 3/3] using faster "prop" method to find checked element --- code/html/custom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/html/custom.js b/code/html/custom.js index 655e257c..b2e90172 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -161,9 +161,9 @@ function validateForm(form) { function getValue(element) { if ($(element).attr("type") === "checkbox") { - return $(element).is(":checked") ? 1 : 0; + return $(element).prop("checked") ? 1 : 0; } else if ($(element).attr("type") === "radio") { - if (!$(element).is(":checked")) { + if (!$(element).prop("checked")) { return null; } }