mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Simplify RTL handling of '<' and '>'. (#1823)
Tested in Playground and RTL demo.
This commit is contained in:
committed by
Andrew n marshall
parent
14e926a364
commit
6319cab317
@@ -133,10 +133,10 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
|
||||
"options": [
|
||||
["=", "EQ"],
|
||||
["\u2260", "NEQ"],
|
||||
["<", "LT"],
|
||||
["\u2264", "LTE"],
|
||||
[">", "GT"],
|
||||
["\u2265", "GTE"]
|
||||
["\u200F<", "LT"],
|
||||
["\u200F\u2264", "LTE"],
|
||||
["\u200F>", "GT"],
|
||||
["\u200F\u2265", "GTE"]
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -485,35 +485,8 @@ Blockly.Extensions.register('controls_if_tooltip',
|
||||
Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION);
|
||||
|
||||
/**
|
||||
* Corrects the logic_compare dropdown label with respect to language direction.
|
||||
* @this Blockly.Block
|
||||
* @package
|
||||
*/
|
||||
Blockly.Constants.Logic.fixLogicCompareRtlOpLabels =
|
||||
function() {
|
||||
var rtlOpLabels = {
|
||||
'LT': '\u200F<\u200F',
|
||||
'LTE': '\u200F\u2264\u200F',
|
||||
'GT': '\u200F>\u200F',
|
||||
'GTE': '\u200F\u2265\u200F'
|
||||
};
|
||||
var opDropdown = this.getField('OP');
|
||||
if (opDropdown) {
|
||||
var options = opDropdown.getOptions();
|
||||
for (var i = 0; i < options.length; ++i) {
|
||||
var tuple = options[i];
|
||||
var op = tuple[1];
|
||||
var rtlLabel = rtlOpLabels[op];
|
||||
if (goog.isString(tuple[0]) && rtlLabel) {
|
||||
// Replace LTR text label
|
||||
tuple[0] = rtlLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds dynamic type validation for the left and right sides of a logic_compare block.
|
||||
* Adds dynamic type validation for the left and right sides of a logic_compare
|
||||
* block.
|
||||
* @mixin
|
||||
* @augments Blockly.Block
|
||||
* @package
|
||||
@@ -564,19 +537,13 @@ Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN = {
|
||||
};
|
||||
|
||||
/**
|
||||
* "logic_compare" extension function. Corrects direction of operators in the
|
||||
* dropdown labels, and adds type left and right side type checking to
|
||||
* "logic_compare" blocks.
|
||||
* "logic_compare" extension function. Adds type left and right side type
|
||||
* checking to "logic_compare" blocks.
|
||||
* @this Blockly.Block
|
||||
* @package
|
||||
* @readonly
|
||||
*/
|
||||
Blockly.Constants.Logic.LOGIC_COMPARE_EXTENSION = function() {
|
||||
// Fix operator labels in RTL.
|
||||
if (this.RTL) {
|
||||
Blockly.Constants.Logic.fixLogicCompareRtlOpLabels.apply(this);
|
||||
}
|
||||
|
||||
// Add onchange handler to ensure types are compatible.
|
||||
this.mixin(Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user