diff --git a/editor/js/text/bidi.js b/editor/js/text/bidi.js index 91393d955..747b3dec6 100644 --- a/editor/js/text/bidi.js +++ b/editor/js/text/bidi.js @@ -21,11 +21,12 @@ RED.text.bidi = (function() { PDF = "\u202C"; function isRTLValue(stringValue) { - for (var ch in stringValue) { - if (isBidiChar(stringValue.charCodeAt(ch))) { + var length = stringValue.length; + for (var i=0;i= 0x05d0 && c <= 0x05ff) { - return true; - } - else if (c >= 0x0600 && c <= 0x065f) { - return true; - } - else if (c >= 0x066a && c <= 0x06ef) { - return true; - } - else if (c >= 0x06fa && c <= 0x07ff) { - return true; - } - else if (c >= 0xfb1d && c <= 0xfdff) { - return true; - } - else if (c >= 0xfe70 && c <= 0xfefc) { - return true; - } - else { - return false; - } + return (c >= 0x05d0 && c <= 0x05ff)|| + (c >= 0x0600 && c <= 0x065f)|| + (c >= 0x066a && c <= 0x06ef)|| + (c >= 0x06fa && c <= 0x07ff)|| + (c >= 0xfb1d && c <= 0xfdff)|| + (c >= 0xfe70 && c <= 0xfefc); } function isLatinChar(c){ - if((c > 64 && c < 91)||(c > 96 && c < 123)) { - return true; - } - else { - return false; - } + return (c > 64 && c < 91)||(c > 96 && c < 123) } /** @@ -87,7 +68,8 @@ RED.text.bidi = (function() { } /** - * Listens to keyup, paste and cut events of a given input field. Upon one of these events the text direction is computed again + * Listens to keyup, paste and cut events of a given input field. Upon one + * of these events the text direction is computed again * @param input - the input field */ function initInputEvents(input) { @@ -95,7 +77,8 @@ RED.text.bidi = (function() { } /** - * Enforces the text direction of a given string by adding UCC (Unicode Control Characters) + * Enforces the text direction of a given string by adding + * UCC (Unicode Control Characters) * @param value - the string */ function enforceTextDirectionWithUCC(value) { @@ -112,7 +95,8 @@ RED.text.bidi = (function() { } /** - * Enforces the text direction for all the spans with style bidiAware under workpsace or sidebar div + * Enforces the text direction for all the spans with style bidiAware under + * workspace or sidebar div */ function enforceTextDirectionOnPage() { $("#workspace").find('span.bidiAware').each(function() { diff --git a/editor/js/text/format.js b/editor/js/text/format.js index f32ed6ec0..cfbc92142 100644 --- a/editor/js/text/format.js +++ b/editor/js/text/format.js @@ -475,7 +475,7 @@ RED.text.format = (function() { // handler: main handler (default - dbidi/stt/handlers/common) // guiDir: GUI direction (default - "ltr") // dir: main stt direction (default - guiDir) - // subDir: direction of subsegments + // subDir: direction of subsegments // points: array of delimiters (default - []) // bounds: array of definitions of bounds in which handler works // subs: object defines special handling for some substring if found diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 82bb63e16..57967777d 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -295,7 +295,7 @@ RED.editor = (function() { * @param node - the node being edited * @param property - the name of the field * @param prefix - the prefix to use in the input element ids (node-input|node-config-input) - * @param definition - the definition of the field + * @param definition - the definition of the field */ function preparePropertyEditor(node,property,prefix,definition) { var input = $("#"+prefix+"-"+property); @@ -1298,7 +1298,7 @@ RED.editor = (function() { }); $("#subflow-input-name").val(subflow.name).attr("dir", RED.text.bidi.resolveBaseTextDir(subflow.name)); - RED.text.bidi.initInputEvents($("#subflow-input-name")); + RED.text.bidi.initInputEvents($("#subflow-input-name")); subflowEditor.getSession().setValue(subflow.info||"",-1); var userCount = 0; var subflowType = "subflow:"+editing_node.id; diff --git a/editor/js/ui/tabs.js b/editor/js/ui/tabs.js index e0ba8ef88..5712ef15a 100644 --- a/editor/js/ui/tabs.js +++ b/editor/js/ui/tabs.js @@ -127,7 +127,7 @@ RED.tabs = (function() { $('').appendTo(link); } var span = $('',{class:"bidiAware"}).text(tab.label).appendTo(link); - span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label)); + span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label)); link.on("click",onTabClick); link.on("dblclick",onTabDblClick); diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index a56b082d0..54836a875 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -1792,7 +1792,7 @@ RED.view = (function() { l = d._def.label; try { l = (typeof l === "function" ? l.call(d) : l)||""; - l = RED.text.bidi.enforceTextDirectionWithUCC(l); + l = RED.text.bidi.enforceTextDirectionWithUCC(l); } catch(err) { console.log("Definition error: "+d.type+".label",err); l = d.type; @@ -2155,8 +2155,8 @@ RED.view = (function() { ).classed("link_selected", false); } - RED.text.bidi.enforceTextDirectionOnPage(); - + RED.text.bidi.enforceTextDirectionOnPage(); + if (d3.event) { d3.event.preventDefault(); } @@ -2360,11 +2360,11 @@ RED.view = (function() { snapGrid = state; redraw(); }, - toggleTextDir: function(value) { + toggleTextDir: function(value) { RED.text.bidi.setTextDirection(value); RED.nodes.eachNode(function(n) { n.dirty = true;}); redraw(); - RED.palette.refresh(); + RED.palette.refresh(); }, scale: function() { return scaleFactor; diff --git a/editor/js/ui/workspaces.js b/editor/js/ui/workspaces.js index a1cc00355..ec641c217 100644 --- a/editor/js/ui/workspaces.js +++ b/editor/js/ui/workspaces.js @@ -110,7 +110,7 @@ RED.workspaces = (function() { $('').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")); + RED.text.bidi.initInputEvents($("#node-input-name")); dialogForm.i18n(); }, close: function() {