Lint and style tweaks.

This commit is contained in:
Neil Fraser 2016-11-02 17:11:41 -07:00
parent 52ffc64f6a
commit 917b8ff542
4 changed files with 20 additions and 12 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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;
}

View file

@ -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_;