1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix select box handling in Safari

Fixes #928
This commit is contained in:
Nick O'Leary 2016-07-04 11:21:58 +01:00
parent b8f578862e
commit dc00870461
9 changed files with 42 additions and 43 deletions

View File

@ -251,7 +251,7 @@
$("#inject-time-type-select").change(function() { $("#inject-time-type-select").change(function() {
$("#node-input-crontab").val(''); $("#node-input-crontab").val('');
var id = $("#inject-time-type-select option:selected").val(); var id = $("#inject-time-type-select").val();
$(".inject-time-row").hide(); $(".inject-time-row").hide();
$("#inject-time-row-"+id).show(); $("#inject-time-row-"+id).show();
if ((id == "none") || (id == "interval")) { if ((id == "none") || (id == "interval")) {
@ -271,8 +271,8 @@
}); });
$("<option></option>").val(24).text("00:00").appendTo("#inject-time-interval-time-end"); $("<option></option>").val(24).text("00:00").appendTo("#inject-time-interval-time-end");
$("#inject-time-interval-time-start").change(function() { $("#inject-time-interval-time-start").change(function() {
var start = Number($("#inject-time-interval-time-start option:selected").val()); var start = Number($("#inject-time-interval-time-start").val());
var end = Number($("#inject-time-interval-time-end option:selected").val()); var end = Number($("#inject-time-interval-time-end").val());
$("#inject-time-interval-time-end option").remove(); $("#inject-time-interval-time-end option").remove();
for (var i=start+1;i<25;i++) { for (var i=start+1;i<25;i++) {
var l = (i<10?"0":"")+i+":00"; var l = (i<10?"0":"")+i+":00";
@ -291,10 +291,6 @@
min:1 min:1
}); });
$("#inject-time-interval-units").change(function() {
var units = $("#inject-time-interval-units option:selected").val();
});
$.widget( "ui.injecttimespinner", $.ui.spinner, { $.widget( "ui.injecttimespinner", $.ui.spinner, {
options: { options: {
// seconds // seconds
@ -342,7 +338,7 @@
// Fixed time // Fixed time
var time = cronparts[1]+":"+cronparts[0]; var time = cronparts[1]+":"+cronparts[0];
$("#inject-time-time").val(time); $("#inject-time-time").val(time);
$("#inject-time-type-select option").filter(function() {return $(this).val() == "s";}).attr('selected',true); $("#inject-time-type-select").val("s");
if (days == "*") { if (days == "*") {
$("#inject-time-time-days input[type=checkbox]").prop("checked",true); $("#inject-time-time-days input[type=checkbox]").prop("checked",true);
} else { } else {
@ -397,16 +393,16 @@
end = Number(endparts[1])+1; end = Number(endparts[1])+1;
} }
} }
$("#inject-time-interval-time-end option").filter(function() {return $(this).val() == end;}).attr('selected',true); $("#inject-time-interval-time-end").val(end);
$("#inject-time-interval-time-start option").filter(function() {return $(this).val() == start;}).attr('selected',true); $("#inject-time-interval-time-start").val(start);
} }
} else { } else {
$("#inject-time-type-select option").filter(function() {return $(this).val() == "none";}).attr('selected',true); $("#inject-time-type-select").val("none");
} }
$(".inject-time-row").hide(); $(".inject-time-row").hide();
$("#inject-time-type-select option").filter(function() {return $(this).val() == repeattype;}).attr('selected',true); $("#inject-time-type-select").val(repeattype);
$("#inject-time-row-"+repeattype).show(); $("#inject-time-row-"+repeattype).show();
$("#node-input-payload").typedInput('type',this.payloadType); $("#node-input-payload").typedInput('type',this.payloadType);
@ -418,12 +414,12 @@
oneditsave: function() { oneditsave: function() {
var repeat = ""; var repeat = "";
var crontab = ""; var crontab = "";
var type = $("#inject-time-type-select option:selected").val(); var type = $("#inject-time-type-select").val();
if (type == "none") { if (type == "none") {
// nothing // nothing
} else if (type == "interval") { } else if (type == "interval") {
var count = $("#inject-time-interval-count").val(); var count = $("#inject-time-interval-count").val();
var units = $("#inject-time-interval-units option:selected").val(); var units = $("#inject-time-interval-units").val();
if (units == "s") { if (units == "s") {
repeat = count; repeat = count;
} else { } else {
@ -438,8 +434,8 @@
} else if (type == "interval-time") { } else if (type == "interval-time") {
repeat = ""; repeat = "";
var count = $("#inject-time-interval-time-units").val(); var count = $("#inject-time-interval-time-units").val();
var startTime = Number($("#inject-time-interval-time-start option:selected").val()); var startTime = Number($("#inject-time-interval-time-start").val());
var endTime = Number($("#inject-time-interval-time-end option:selected").val()); var endTime = Number($("#inject-time-interval-time-end").val());
var days = $('#inject-time-interval-time-days input[type=checkbox]:checked').map(function(_, el) { var days = $('#inject-time-interval-time-days input[type=checkbox]:checked').map(function(_, el) {
return $(el).val() return $(el).val()
}).get(); }).get();

View File

@ -242,7 +242,7 @@
$("#node-input-scope-select").change(function(e) { $("#node-input-scope-select").change(function(e) {
var scope = $(this).children("option:selected").val(); var scope = $(this).val();
if (scope === "target") { if (scope === "target") {
createNodeList(); createNodeList();
$(".node-input-target-row").show(); $(".node-input-target-row").show();
@ -259,7 +259,7 @@
$("#node-input-scope-select").change(); $("#node-input-scope-select").change();
}, },
oneditsave: function() { oneditsave: function() {
var scope = $("#node-input-scope-select").children("option:selected").val(); var scope = $("#node-input-scope-select").val();
if (scope === 'all') { if (scope === 'all') {
this.scope = null; this.scope = null;
} else { } else {

View File

@ -231,7 +231,7 @@
}) })
$("#node-input-scope-select").change(function(e) { $("#node-input-scope-select").change(function(e) {
var scope = $(this).children("option:selected").val(); var scope = $(this).val();
if (scope === "target") { if (scope === "target") {
createNodeList(); createNodeList();
$(".node-input-target-row").show(); $(".node-input-target-row").show();
@ -248,7 +248,7 @@
$("#node-input-scope-select").change(); $("#node-input-scope-select").change();
}, },
oneditsave: function() { oneditsave: function() {
var scope = $("#node-input-scope-select").children("option:selected").val(); var scope = $("#node-input-scope-select").val();
if (scope === 'all') { if (scope === 'all') {
this.scope = null; this.scope = null;
} else { } else {

View File

@ -140,7 +140,7 @@
}); });
$("#node-input-intype").change(function() { $("#node-input-intype").change(function() {
var newtype = $("#node-input-intype option:selected").val(); var newtype = $("#node-input-intype").val();
if ((pinsInUse.hasOwnProperty(pinnow)) && (pinsInUse[pinnow] !== newtype)) { if ((pinsInUse.hasOwnProperty(pinnow)) && (pinsInUse[pinnow] !== newtype)) {
RED.notify(pinname+" "+pinnow+" "+alreadyset+" "+pinsInUse[pinnow],"error"); RED.notify(pinname+" "+pinnow+" "+alreadyset+" "+pinsInUse[pinnow],"error");
} }
@ -286,7 +286,7 @@
}); });
$("#node-input-out").change(function() { $("#node-input-out").change(function() {
var newtype = $("#node-input-out option:selected").val(); var newtype = $("#node-input-out").val();
if ((pinsInUse.hasOwnProperty(pinnow)) && (pinsInUse[pinnow] !== newtype)) { if ((pinsInUse.hasOwnProperty(pinnow)) && (pinsInUse[pinnow] !== newtype)) {
RED.notify(pinname+" "+pinnow+" "+alreadyset+" "+pinsInUse[pinnow],"error"); RED.notify(pinname+" "+pinnow+" "+alreadyset+" "+pinsInUse[pinnow],"error");
} }

View File

@ -86,14 +86,14 @@
}, },
oneditprepare: function() { oneditprepare: function() {
var updateOptions = function() { var updateOptions = function() {
var sockettype = $("#node-input-server option:selected").val(); var sockettype = $("#node-input-server").val();
if (sockettype == "client") { if (sockettype == "client") {
$("#node-input-host-row").show(); $("#node-input-host-row").show();
} else { } else {
$("#node-input-host-row").hide(); $("#node-input-host-row").hide();
} }
var datamode = $("#node-input-datamode option:selected").val(); var datamode = $("#node-input-datamode").val();
var datatype = $("#node-input-datatype option:selected").val(); var datatype = $("#node-input-datatype").val();
if (datamode == "stream") { if (datamode == "stream") {
if (datatype == "utf8") { if (datatype == "utf8") {
$("#node-row-newline").show(); $("#node-row-newline").show();
@ -181,7 +181,7 @@
}, },
oneditprepare: function() { oneditprepare: function() {
var updateOptions = function() { var updateOptions = function() {
var sockettype = $("#node-input-beserver option:selected").val(); var sockettype = $("#node-input-beserver").val();
if (sockettype == "reply") { if (sockettype == "reply") {
$("#node-input-port-row").hide(); $("#node-input-port-row").hide();
$("#node-input-host-row").hide(); $("#node-input-host-row").hide();

View File

@ -90,7 +90,7 @@
}, },
oneditprepare: function() { oneditprepare: function() {
$("#node-input-multicast").change(function() { $("#node-input-multicast").change(function() {
var id = $("#node-input-multicast option:selected").val(); var id = $("#node-input-multicast").val();
if (id == "false") { if (id == "false") {
$(".node-input-group").hide(); $(".node-input-group").hide();
$(".node-input-iface").hide(); $(".node-input-iface").hide();
@ -202,12 +202,10 @@
var bindtarget = this._("udp.bind.target"); var bindtarget = this._("udp.bind.target");
var type = this.outport==""?"random":"fixed"; var type = this.outport==""?"random":"fixed";
$("#node-input-outport-type option").filter(function() { $("#node-input-outport-type").val(type);
return $(this).val() == type;
}).attr('selected',true);
$("#node-input-outport-type").change(function() { $("#node-input-outport-type").change(function() {
var type = $(this).children("option:selected").val(); var type = $(this).val();
if (type == "random") { if (type == "random") {
$("#node-input-outport").val("").hide(); $("#node-input-outport").val("").hide();
} else { } else {
@ -217,7 +215,7 @@
$("#node-input-outport-type").change(); $("#node-input-outport-type").change();
$("#node-input-multicast").change(function() { $("#node-input-multicast").change(function() {
var id = $("#node-input-multicast option:selected").val(); var id = $("#node-input-multicast").val();
if (id === "multi") { if (id === "multi") {
$(".node-input-iface").show(); $(".node-input-iface").show();
$("#node-input-addr-label").html('<i class="fa fa-list"></i> ' + grouplabel); $("#node-input-addr-label").html('<i class="fa fa-list"></i> ' + grouplabel);
@ -233,7 +231,7 @@
$("#node-input-addr-label").html('<i class="fa fa-list"></i> ' + addresslabel); $("#node-input-addr-label").html('<i class="fa fa-list"></i> ' + addresslabel);
$("#node-input-addr")[0].placeholder = addressph; $("#node-input-addr")[0].placeholder = addressph;
} }
var type = $(this).children("option:selected").val(); var type = $(this).val();
if (type == "false") { if (type == "false") {
$("#node-input-outport-type-random").html(bindrandom); $("#node-input-outport-type-random").html(bindrandom);
} else { } else {

View File

@ -88,7 +88,7 @@
function resizeRule(rule) { function resizeRule(rule) {
var newWidth = rule.width(); var newWidth = rule.width();
var selectField = rule.find("select"); var selectField = rule.find("select");
var type = selectField.children("option:selected").val()||""; var type = selectField.val()||"";
var valueField = rule.find(".node-input-rule-value"); var valueField = rule.find(".node-input-rule-value");
var btwnField1 = rule.find(".node-input-rule-btwn-value"); var btwnField1 = rule.find(".node-input-rule-btwn-value");
var btwnField2 = rule.find(".node-input-rule-btwn-value2"); var btwnField2 = rule.find(".node-input-rule-btwn-value2");
@ -115,7 +115,10 @@
$("#node-input-rule-container").css('min-height','250px').css('min-width','450px').editableList({ $("#node-input-rule-container").css('min-height','250px').css('min-width','450px').editableList({
addItem: function(container,i,opt) { addItem: function(container,i,opt) {
var rule = opt||{t:"",v:"",v2:""}; var rule = opt;
if (!rule.hasOwnProperty('t')) {
rule.t = 'eq';
}
var row = $('<div/>').appendTo(container); var row = $('<div/>').appendTo(container);
var row2 = $('<div/>',{style:"padding-top: 5px; padding-left: 175px;"}).appendTo(container); var row2 = $('<div/>',{style:"padding-top: 5px; padding-left: 175px;"}).appendTo(container);
var row3 = $('<div/>',{style:"padding-top: 5px; padding-left: 102px;"}).appendTo(container); var row3 = $('<div/>',{style:"padding-top: 5px; padding-left: 102px;"}).appendTo(container);
@ -133,8 +136,7 @@
$('<label/>',{for:"node-input-rule-case-"+i,style:"margin-left: 3px;"}).text(caseLabel).appendTo(row2); $('<label/>',{for:"node-input-rule-case-"+i,style:"margin-left: 3px;"}).text(caseLabel).appendTo(row2);
selectField.change(function() { selectField.change(function() {
resizeRule(container); resizeRule(container);
var type = selectField.children("option:selected").val(); var type = selectField.val();
if (type === "btwn") { if (type === "btwn") {
valueField.typedInput('hide'); valueField.typedInput('hide');
btwnValueField.typedInput('show'); btwnValueField.typedInput('show');
@ -157,7 +159,7 @@
row3.hide(); row3.hide();
} }
}); });
selectField.find("option").filter(function() {return $(this).val() == rule.t;}).attr('selected',true); selectField.val(rule.t);
if (rule.t == "btwn") { if (rule.t == "btwn") {
btwnValueField.typedInput('value',rule.v); btwnValueField.typedInput('value',rule.v);
btwnValueField.typedInput('type',rule.vt||'num'); btwnValueField.typedInput('type',rule.vt||'num');
@ -199,7 +201,7 @@
node.rules= []; node.rules= [];
rules.each(function(i) { rules.each(function(i) {
var rule = $(this); var rule = $(this);
var type = rule.find("select option:selected").val(); var type = rule.find("select").val();
var r = {t:type}; var r = {t:type};
if (!(type === "true" || type === "false" || type === "null" || type === "nnull" || type === "else")) { if (!(type === "true" || type === "false" || type === "null" || type === "nnull" || type === "else")) {
if (type === "btwn") { if (type === "btwn") {

View File

@ -108,7 +108,10 @@
} }
$('#node-input-rule-container').css('min-height','300px').css('min-width','450px').editableList({ $('#node-input-rule-container').css('min-height','300px').css('min-width','450px').editableList({
addItem: function(container,i,opt) { addItem: function(container,i,opt) {
var rule = opt||{t:"replace",p:"payload"}; var rule = opt;
if (!rule.hasOwnProperty('t')) {
rule = {t:"set",p:"payload",to:"",tot:"str"};
}
if (rule.t === "change" && rule.re) { if (rule.t === "change" && rule.re) {
rule.fromt = 're'; rule.fromt = 're';
delete rule.re; delete rule.re;
@ -193,7 +196,7 @@
resizeRule(container); resizeRule(container);
}); });
selectField.find("option").filter(function() {return $(this).val() == rule.t;}).attr('selected',true); selectField.val(rule.t);
propertyName.typedInput('value',rule.p); propertyName.typedInput('value',rule.p);
propertyName.typedInput('type',rule.pt); propertyName.typedInput('type',rule.pt);
propertyValue.typedInput('value',rule.to); propertyValue.typedInput('value',rule.to);
@ -250,7 +253,7 @@
node.rules= []; node.rules= [];
rules.each(function(i) { rules.each(function(i) {
var rule = $(this); var rule = $(this);
var type = rule.find(".node-input-rule-type option:selected").val(); var type = rule.find(".node-input-rule-type").val();
var r = { var r = {
t:type, t:type,
p:rule.find(".node-input-rule-property-name").typedInput('value'), p:rule.find(".node-input-rule-property-name").typedInput('value'),

View File

@ -113,7 +113,7 @@
$("#node-input-sep").show(); $("#node-input-sep").show();
} }
$("#node-input-select-sep").change(function() { $("#node-input-select-sep").change(function() {
var v = $("#node-input-select-sep option:selected").val(); var v = $("#node-input-select-sep").val();
$("#node-input-sep").val(v); $("#node-input-sep").val(v);
if (v == "") { if (v == "") {
$("#node-input-sep").val(""); $("#node-input-sep").val("");