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

Move initInputEvents to prepareInput

This commit is contained in:
Nick O'Leary 2016-08-26 12:50:18 +01:00
parent c60fb3bc25
commit 4b462eaae9
3 changed files with 14 additions and 11 deletions

View File

@ -64,16 +64,19 @@ RED.text.bidi = (function() {
}
function onInputChange() {
console.log("ic");
$(this).attr("dir", resolveBaseTextDir($(this).val()));
}
/**
* Listens to keyup, paste and cut events of a given input field. Upon one
* of these events the text direction is computed again
* Adds event listeners to the Input to ensure its text-direction attribute
* is properly set based on its content.
* @param input - the input field
*/
function initInputEvents(input) {
function prepareInput(input) {
input.on("keyup",onInputChange).on("paste",onInputChange).on("cut",onInputChange);
// Set the initial text direction
onInputChange.call(input);
}
/**
@ -123,6 +126,6 @@ RED.text.bidi = (function() {
setTextDirection: setTextDirection,
enforceTextDirectionWithUCC: enforceTextDirectionWithUCC,
resolveBaseTextDir: resolveBaseTextDir,
initInputEvents: initInputEvents
prepareInput: prepareInput
}
})();

View File

@ -307,12 +307,12 @@ RED.editor = (function() {
if (val == null) {
val = "";
}
if (definition[property].hasOwnProperty("format") && definition[property].format !== "" && input[0].nodeName === "DIV") {
if (definition !== undefined && definition[property].hasOwnProperty("format") && definition[property].format !== "" && input[0].nodeName === "DIV") {
input.html(RED.text.format.getHtml(val, definition[property].format, {}, false, "en"));
RED.text.format.attach(input[0], definition[property].format, {}, false, "en");
} else {
input.val(val).attr("dir", RED.text.bidi.resolveBaseTextDir(val));
RED.text.bidi.initInputEvents(input);
input.val(val);
RED.text.bidi.prepareInput(input);
}
}
}
@ -1297,8 +1297,8 @@ RED.editor = (function() {
value: ""
});
$("#subflow-input-name").val(subflow.name).attr("dir", RED.text.bidi.resolveBaseTextDir(subflow.name));
RED.text.bidi.initInputEvents($("#subflow-input-name"));
$("#subflow-input-name").val(subflow.name);
RED.text.bidi.prepareInput($("#subflow-input-name"));
subflowEditor.getSession().setValue(subflow.info||"",-1);
var userCount = 0;
var subflowType = "subflow:"+editing_node.id;

View File

@ -109,8 +109,8 @@ RED.workspaces = (function() {
'</div>').appendTo(dialogForm);
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
dialogForm.submit(function(e) { e.preventDefault();});
$("#node-input-name").val(workspace.label).attr("dir", RED.text.bidi.resolveBaseTextDir(workspace.label));
RED.text.bidi.initInputEvents($("#node-input-name"));
$("#node-input-name").val(workspace.label);
RED.text.bidi.prepareInput($("#node-input-name"))
dialogForm.i18n();
},
close: function() {