-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix]ON OFF switch in Microsoft Edge #1049 #1066
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -785,11 +785,13 @@ function addSchedule(event) { | |
}); | ||
$(line).find(".button-del-schedule").on("click", delSchedule); | ||
$(line).find(".button-more-schedule").on("click", moreSchedule); | ||
$(line).find("input[name='schUTC']").prop("id", "schUTC" + (numSchedules + 1)) | ||
.next().prop("for", "schUTC" + (numSchedules + 1)); | ||
$(line).find("input[name='schEnabled']").prop("id", "schEnabled" + (numSchedules + 1)) | ||
.next().prop("for", "schEnabled" + (numSchedules + 1)); | ||
line.appendTo("#schedules"); | ||
$(line).find("input[type='checkbox']").prop("checked", false); | ||
|
||
initCheckboxes(); | ||
|
||
return line; | ||
|
||
} | ||
|
@@ -809,7 +811,15 @@ function initRelays(data) { | |
// Add relay fields | ||
var line = $(template).clone(); | ||
$(".id", line).html(i); | ||
$(":checkbox", line).prop('checked', data[i]).attr("data", i); | ||
$(":checkbox", line).prop('checked', data[i]).attr("data", i) | ||
.prop("id", "relay" + i) | ||
.on("change", function (event) { | ||
console.log("sending message"); | ||
var id = parseInt($(event.target).attr("data"), 10); | ||
var status = $(event.target).prop("checked"); | ||
doToggle(id, status); | ||
}); | ||
$("label.toggle", line).prop("for", "relay" + i) | ||
line.appendTo("#relays"); | ||
|
||
// Populate the relay SELECTs | ||
|
@@ -820,57 +830,13 @@ function initRelays(data) { | |
|
||
} | ||
|
||
function initCheckboxes() { | ||
|
||
var setCheckbox = function(element, value) { | ||
var container = $(".toggle-container", $(element)); | ||
if (value) { | ||
container.css("-webkit-clip-path", "inset(0 0 0 50%)"); | ||
container.css("clip-path", "inset(0 0 0 50%)"); | ||
container.css("backgroundColor", "#00c000"); | ||
} else { | ||
container.css("-webkit-clip-path", "inset(0 50% 0 0)"); | ||
container.css("clip-path", "inset(0 50% 0 0)"); | ||
container.css("backgroundColor", "#c00000"); | ||
} | ||
} | ||
|
||
$(".checkbox-container") | ||
|
||
.each(function() { | ||
var status = $(this).next().prop('checked'); | ||
setCheckbox(this, status); | ||
}) | ||
.off('click') | ||
.on('click', function() { | ||
|
||
var checkbox = $(this).next(); | ||
|
||
var status = checkbox.prop('checked'); | ||
status = !status; | ||
checkbox.prop('checked', status); | ||
setCheckbox(this, status); | ||
|
||
if ("relay" == checkbox.attr('name')) { | ||
var id = parseInt(checkbox.attr('data'), 10); | ||
doToggle(id, status); | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
function createCheckboxes() { | ||
|
||
$("input[type='checkbox']").each(function() { | ||
|
||
var text_on = $(this).attr("on") || "YES"; | ||
var text_off = $(this).attr("off") || "NO"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relay switch now has NO YES instead of OFF ON, maybe alternative version of this should be used? or check new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry dude, I'm not a huge fan of hacks and workarounds so no div + proxies ). I generally like keeping things as simple as they can be. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well... does it not work only because label does the proxy by itself internally?:) |
||
|
||
var toggles = "<div class=\"toggle\"><p>" + text_on + "</p></div><div class=\"toggle\"><p>" + text_off + "</p></div>"; | ||
var content = "<div class=\"checkbox-container\"><div class=\"inner-container\">" + toggles | ||
+ "</div><div class=\"inner-container toggle-container\">" + toggles + "</div></div>"; | ||
$(this).before(content).hide(); | ||
if($(this).prop("name"))$(this).prop("id", $(this).prop("name")); | ||
$(this).parent().addClass("toggleWrapper"); | ||
$(this).after('<label for="' + $(this).prop("name") + '" class="toggle"><span class="toggle__handler"></span></label>') | ||
|
||
}); | ||
|
||
|
@@ -1499,7 +1465,6 @@ function processData(data) { | |
} | ||
|
||
resetOriginals(); | ||
initCheckboxes(); | ||
|
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover logging?