mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Lint and style tweaks.
This commit is contained in:
parent
52ffc64f6a
commit
917b8ff542
4 changed files with 20 additions and 12 deletions
|
@ -403,8 +403,6 @@ Blockly.Field.prototype.updateTextNode_ = function() {
|
|||
// Truncate displayed string and add an ellipsis ('...').
|
||||
text = text.substring(0, this.maxDisplayLength - 2) + '\u2026';
|
||||
}
|
||||
// Empty the text element.
|
||||
goog.dom.removeChildren(/** @type {!Element} */ (this.textElement_));
|
||||
// Replace whitespace with non-breaking spaces so the text doesn't collapse.
|
||||
text = text.replace(/\s/g, Blockly.Field.NBSP);
|
||||
if (this.sourceBlock_.RTL && text) {
|
||||
|
@ -415,6 +413,9 @@ Blockly.Field.prototype.updateTextNode_ = function() {
|
|||
// Prevent the field from disappearing if empty.
|
||||
text = Blockly.Field.NBSP;
|
||||
}
|
||||
|
||||
// Replace the text.
|
||||
goog.dom.removeChildren(/** @type {!Element} */ (this.textElement_));
|
||||
var textNode = document.createTextNode(text);
|
||||
this.textElement_.appendChild(textNode);
|
||||
|
||||
|
|
|
@ -75,6 +75,13 @@ Blockly.FieldDropdown.ARROW_CHAR = goog.userAgent.ANDROID ? '\u25BC' : '\u25BE';
|
|||
*/
|
||||
Blockly.FieldDropdown.prototype.CURSOR = 'default';
|
||||
|
||||
/**
|
||||
* Language-neutral currently selected string.
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.value_ = '';
|
||||
|
||||
/**
|
||||
* Install this dropdown on a block.
|
||||
*/
|
||||
|
@ -85,9 +92,9 @@ Blockly.FieldDropdown.prototype.init = function() {
|
|||
}
|
||||
// Add dropdown arrow: "option ▾" (LTR) or "▾ אופציה" (RTL)
|
||||
this.arrow_ = Blockly.createSvgElement('tspan', {}, null);
|
||||
this.arrow_.appendChild(document.createTextNode(
|
||||
this.sourceBlock_.RTL ? Blockly.FieldDropdown.ARROW_CHAR + ' ' :
|
||||
' ' + Blockly.FieldDropdown.ARROW_CHAR));
|
||||
this.arrow_.appendChild(document.createTextNode(this.sourceBlock_.RTL ?
|
||||
Blockly.FieldDropdown.ARROW_CHAR + ' ' :
|
||||
' ' + Blockly.FieldDropdown.ARROW_CHAR));
|
||||
|
||||
Blockly.FieldDropdown.superClass_.init.call(this);
|
||||
// Force a reset of the text to add the arrow.
|
||||
|
@ -188,8 +195,8 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
|||
|
||||
/**
|
||||
* Handle the selection of an item in the dropdown menu.
|
||||
* @param {goog.ui.Menu} menu The Menu component clicked.
|
||||
* @param {goog.ui.MenuItem} menuItem The MenuItem selected within menu.
|
||||
* @param {!goog.ui.Menu} menu The Menu component clicked.
|
||||
* @param {!goog.ui.MenuItem} menuItem The MenuItem selected within menu.
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.onItemSelected = function(menu, menuItem) {
|
||||
var value = menuItem.getValue();
|
||||
|
|
|
@ -147,8 +147,8 @@ Blockly.FieldVariable.dropdownCreate = function() {
|
|||
* Handle the selection of an item in the variable dropdown menu.
|
||||
* Special case the 'Rename variable...' and 'Delete variable...' options.
|
||||
* In the rename case, prompt the user for a new name.
|
||||
* @param {goog.ui.Menu} menu The Menu component clicked.
|
||||
* @param {goog.ui.MenuItem} menuItem The MenuItem selected within menu.
|
||||
* @param {!goog.ui.Menu} menu The Menu component clicked.
|
||||
* @param {!goog.ui.MenuItem} menuItem The MenuItem selected within menu.
|
||||
*/
|
||||
Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) {
|
||||
var menuLength = menu.getChildCount();
|
||||
|
@ -157,7 +157,7 @@ Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) {
|
|||
var workspace = this.sourceBlock_.workspace;
|
||||
if (this.renameVarItemIndex_ >= 0 &&
|
||||
menu.getChildAt(this.renameVarItemIndex_) === menuItem) {
|
||||
// Rename variable
|
||||
// Rename variable.
|
||||
var oldName = this.getText();
|
||||
Blockly.hideChaff();
|
||||
Blockly.Variables.promptName(
|
||||
|
@ -170,7 +170,7 @@ Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) {
|
|||
return;
|
||||
} else if (this.deleteVarItemIndex_ >= 0 &&
|
||||
menu.getChildAt(this.deleteVarItemIndex_) === menuItem) {
|
||||
// Delete variable
|
||||
// Delete variable.
|
||||
workspace.deleteVariable(this.getText());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ Blockly.FlyoutButton.prototype.createDom = function() {
|
|||
this.svgGroup_);
|
||||
|
||||
var svgText = Blockly.createSvgElement('text',
|
||||
{'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText',
|
||||
{'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText',
|
||||
'x': 0, 'y': 0,
|
||||
'text-anchor': 'middle'}, this.svgGroup_);
|
||||
svgText.textContent = this.text_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue