From 8540118fe0b370d7738e62244354f6656ad01f08 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 26 Aug 2015 14:27:30 +0100 Subject: [PATCH] Add optional class to FieldLabel. --- core/field_label.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/field_label.js b/core/field_label.js index fbf1ecb0b..45063bdeb 100644 --- a/core/field_label.js +++ b/core/field_label.js @@ -35,12 +35,14 @@ goog.require('goog.math.Size'); /** * Class for a non-editable field. * @param {string} text The initial content of the field. + * @param {string=} opt_class Optional CSS class for the field's text. * @extends {Blockly.Field} * @constructor */ -Blockly.FieldLabel = function(text) { +Blockly.FieldLabel = function(text, opt_class) { this.sourceBlock_ = null; this.size_ = new goog.math.Size(0, 25); + this.class_ = opt_class; this.setText(text); }; goog.inherits(Blockly.FieldLabel, Blockly.Field); @@ -64,6 +66,9 @@ Blockly.FieldLabel.prototype.init = function(block) { // Build the DOM. this.textElement_ = Blockly.createSvgElement('text', {'class': 'blocklyText'}, null); + if (this.class_) { + Blockly.addClass_(this.textElement_, this.class_); + } if (!this.visible_) { this.textElement_.style.display = 'none'; }