Commit ddcf1ac9 authored by Neil Fraser's avatar Neil Fraser

Factor out hues into constants.

parent 816aa869
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.colour');
goog.require('Blockly.Blocks');
Blockly.Blocks.colour.HUE = 20;
Blockly.Blocks['colour_picker'] = {
/**
* Block for colour picker.
......@@ -36,7 +38,7 @@ Blockly.Blocks['colour_picker'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.COLOUR_PICKER_HELPURL);
this.setColour(20);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldColour('#ff0000'), 'COLOUR');
this.setOutput(true, 'Colour');
......@@ -51,7 +53,7 @@ Blockly.Blocks['colour_random'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.COLOUR_RANDOM_HELPURL);
this.setColour(20);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.COLOUR_RANDOM_TITLE);
this.setOutput(true, 'Colour');
......@@ -66,7 +68,7 @@ Blockly.Blocks['colour_rgb'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL);
this.setColour(20);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendValueInput('RED')
.setCheck('Number')
.setAlign(Blockly.ALIGN_RIGHT)
......@@ -92,7 +94,7 @@ Blockly.Blocks['colour_blend'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL);
this.setColour(20);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendValueInput('COLOUR1')
.setCheck('Colour')
.setAlign(Blockly.ALIGN_RIGHT)
......
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.lists');
goog.require('Blockly.Blocks');
Blockly.Blocks.lists.HUE = 260;
Blockly.Blocks['lists_create_empty'] = {
/**
* Block for creating an empty list.
......@@ -36,7 +38,7 @@ Blockly.Blocks['lists_create_empty'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.setOutput(true, 'Array');
this.appendDummyInput()
.appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);
......@@ -51,7 +53,7 @@ Blockly.Blocks['lists_create_with'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.itemCount_ = 3;
this.updateShape_();
this.setOutput(true, 'Array');
......@@ -174,7 +176,7 @@ Blockly.Blocks['lists_create_with_container'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);
this.appendStatementInput('STACK');
......@@ -189,7 +191,7 @@ Blockly.Blocks['lists_create_with_item'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);
this.setPreviousStatement(true);
......@@ -206,7 +208,7 @@ Blockly.Blocks['lists_repeat'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LISTS_REPEAT_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.setOutput(true, 'Array');
this.interpolateMsg(Blockly.Msg.LISTS_REPEAT_TITLE,
['ITEM', null, Blockly.ALIGN_RIGHT],
......@@ -223,7 +225,7 @@ Blockly.Blocks['lists_length'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LISTS_LENGTH_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.interpolateMsg(Blockly.Msg.LISTS_LENGTH_TITLE,
['VALUE', ['Array', 'String'], Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
......@@ -239,7 +241,7 @@ Blockly.Blocks['lists_isEmpty'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LISTS_IS_EMPTY_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.interpolateMsg(Blockly.Msg.LISTS_IS_EMPTY_TITLE,
['VALUE', ['Array', 'String'], Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
......@@ -259,7 +261,7 @@ Blockly.Blocks['lists_indexOf'] = {
[[Blockly.Msg.LISTS_INDEX_OF_FIRST, 'FIRST'],
[Blockly.Msg.LISTS_INDEX_OF_LAST, 'LAST']];
this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.setOutput(true, 'Number');
this.appendValueInput('VALUE')
.setCheck('Array')
......@@ -288,7 +290,7 @@ Blockly.Blocks['lists_getIndex'] = {
[Blockly.Msg.LISTS_GET_INDEX_LAST, 'LAST'],
[Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']];
this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
var isStatement = (value == 'REMOVE');
this.sourceBlock_.updateStatement_(isStatement);
......@@ -419,7 +421,7 @@ Blockly.Blocks['lists_setIndex'] = {
[Blockly.Msg.LISTS_GET_INDEX_LAST, 'LAST'],
[Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']];
this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.appendValueInput('LIST')
.setCheck('Array')
.appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);
......@@ -520,7 +522,7 @@ Blockly.Blocks['lists_getSublist'] = {
[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END, 'FROM_END'],
[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST, 'LAST']];
this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.appendValueInput('LIST')
.setCheck('Array')
.appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);
......@@ -631,7 +633,7 @@ Blockly.Blocks['lists_split'] = {
}
});
this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);
this.setColour(260);
this.setColour(Blockly.Blocks.lists.HUE);
this.appendValueInput('INPUT')
.setCheck('String')
.appendField(dropdown, 'MODE');
......
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.logic');
goog.require('Blockly.Blocks');
Blockly.Blocks.logic.HUE = 210;
Blockly.Blocks['controls_if'] = {
/**
* Block for if/elseif/else condition.
......@@ -36,7 +38,7 @@ Blockly.Blocks['controls_if'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.appendValueInput('IF0')
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
......@@ -215,7 +217,7 @@ Blockly.Blocks['controls_if_if'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);
this.appendStatementInput('STACK');
......@@ -230,7 +232,7 @@ Blockly.Blocks['controls_if_elseif'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF);
this.setPreviousStatement(true);
......@@ -246,7 +248,7 @@ Blockly.Blocks['controls_if_else'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE);
this.setPreviousStatement(true);
......@@ -277,7 +279,7 @@ Blockly.Blocks['logic_compare'] = {
['\u2265', 'GTE']
];
this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.setOutput(true, 'Boolean');
this.appendValueInput('A');
this.appendValueInput('B')
......@@ -310,7 +312,7 @@ Blockly.Blocks['logic_operation'] = {
[[Blockly.Msg.LOGIC_OPERATION_AND, 'AND'],
[Blockly.Msg.LOGIC_OPERATION_OR, 'OR']];
this.setHelpUrl(Blockly.Msg.LOGIC_OPERATION_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.setOutput(true, 'Boolean');
this.appendValueInput('A')
.setCheck('Boolean');
......@@ -338,7 +340,7 @@ Blockly.Blocks['logic_negate'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LOGIC_NEGATE_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.setOutput(true, 'Boolean');
this.interpolateMsg(Blockly.Msg.LOGIC_NEGATE_TITLE,
['BOOL', 'Boolean', Blockly.ALIGN_RIGHT],
......@@ -357,7 +359,7 @@ Blockly.Blocks['logic_boolean'] = {
[[Blockly.Msg.LOGIC_BOOLEAN_TRUE, 'TRUE'],
[Blockly.Msg.LOGIC_BOOLEAN_FALSE, 'FALSE']];
this.setHelpUrl(Blockly.Msg.LOGIC_BOOLEAN_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.setOutput(true, 'Boolean');
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(BOOLEANS), 'BOOL');
......@@ -372,7 +374,7 @@ Blockly.Blocks['logic_null'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LOGIC_NULL_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.setOutput(true);
this.appendDummyInput()
.appendField(Blockly.Msg.LOGIC_NULL);
......@@ -387,7 +389,7 @@ Blockly.Blocks['logic_ternary'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL);
this.setColour(210);
this.setColour(Blockly.Blocks.logic.HUE);
this.appendValueInput('IF')
.setCheck('Boolean')
.appendField(Blockly.Msg.LOGIC_TERNARY_CONDITION);
......
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.loops');
goog.require('Blockly.Blocks');
Blockly.Blocks.loops.HUE = 120;
Blockly.Blocks['controls_repeat'] = {
/**
* Block for repeat n times (internal number).
......@@ -36,7 +38,7 @@ Blockly.Blocks['controls_repeat'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.CONTROLS_REPEAT_HELPURL);
this.setColour(120);
this.setColour(Blockly.Blocks.loops.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.CONTROLS_REPEAT_TITLE_REPEAT)
.appendField(new Blockly.FieldTextInput('10',
......@@ -57,7 +59,7 @@ Blockly.Blocks['controls_repeat_ext'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.CONTROLS_REPEAT_HELPURL);
this.setColour(120);
this.setColour(Blockly.Blocks.loops.HUE);
this.interpolateMsg(Blockly.Msg.CONTROLS_REPEAT_TITLE,
['TIMES', 'Number', Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
......@@ -80,7 +82,7 @@ Blockly.Blocks['controls_whileUntil'] = {
[[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE, 'WHILE'],
[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL, 'UNTIL']];
this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);
this.setColour(120);
this.setColour(Blockly.Blocks.loops.HUE);
this.appendValueInput('BOOL')
.setCheck('Boolean')
.appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE');
......@@ -108,7 +110,7 @@ Blockly.Blocks['controls_for'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.CONTROLS_FOR_HELPURL);
this.setColour(120);
this.setColour(Blockly.Blocks.loops.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH)
.appendField(new Blockly.FieldVariable(null), 'VAR');
......@@ -176,7 +178,7 @@ Blockly.Blocks['controls_forEach'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.CONTROLS_FOREACH_HELPURL);
this.setColour(120);
this.setColour(Blockly.Blocks.loops.HUE);
this.appendValueInput('LIST')
.setCheck('Array')
.appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_ITEM)
......@@ -231,7 +233,7 @@ Blockly.Blocks['controls_flow_statements'] = {
[[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK, 'BREAK'],
[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE, 'CONTINUE']];
this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL);
this.setColour(120);
this.setColour(Blockly.Blocks.loops.HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(OPERATORS), 'FLOW');
this.setPreviousStatement(true);
......
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.math');
goog.require('Blockly.Blocks');
Blockly.Blocks.math.HUE = 230;
Blockly.Blocks['math_number'] = {
/**
* Block for numeric value.
......@@ -36,7 +38,7 @@ Blockly.Blocks['math_number'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput('0',
Blockly.FieldTextInput.numberValidator), 'NUM');
......@@ -58,7 +60,7 @@ Blockly.Blocks['math_arithmetic'] = {
[Blockly.Msg.MATH_DIVISION_SYMBOL, 'DIVIDE'],
[Blockly.Msg.MATH_POWER_SYMBOL, 'POWER']];
this.setHelpUrl(Blockly.Msg.MATH_ARITHMETIC_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.appendValueInput('A')
.setCheck('Number');
......@@ -97,7 +99,7 @@ Blockly.Blocks['math_single'] = {
['e^', 'EXP'],
['10^', 'POW10']];
this.setHelpUrl(Blockly.Msg.MATH_SINGLE_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.interpolateMsg('%1 %2',
['OP', new Blockly.FieldDropdown(OPERATORS)],
......@@ -135,7 +137,7 @@ Blockly.Blocks['math_trig'] = {
[Blockly.Msg.MATH_TRIG_ACOS, 'ACOS'],
[Blockly.Msg.MATH_TRIG_ATAN, 'ATAN']];
this.setHelpUrl(Blockly.Msg.MATH_TRIG_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.appendValueInput('NUM')
.setCheck('Number')
......@@ -171,7 +173,7 @@ Blockly.Blocks['math_constant'] = {
['sqrt(\u00bd)', 'SQRT1_2'],
['\u221e', 'INFINITY']];
this.setHelpUrl(Blockly.Msg.MATH_CONSTANT_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(CONSTANTS), 'CONSTANT');
......@@ -194,7 +196,7 @@ Blockly.Blocks['math_number_property'] = {
[Blockly.Msg.MATH_IS_POSITIVE, 'POSITIVE'],
[Blockly.Msg.MATH_IS_NEGATIVE, 'NEGATIVE'],
[Blockly.Msg.MATH_IS_DIVISIBLE_BY, 'DIVISIBLE_BY']];
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.appendValueInput('NUMBER_TO_CHECK')
.setCheck('Number');
var dropdown = new Blockly.FieldDropdown(PROPERTIES, function(option) {
......@@ -254,7 +256,7 @@ Blockly.Blocks['math_change'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.MATH_CHANGE_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.interpolateMsg(
// TODO: Combine these messages instead of using concatenation.
Blockly.Msg.MATH_CHANGE_TITLE_CHANGE + ' %1 ' +
......@@ -304,7 +306,7 @@ Blockly.Blocks['math_round'] = {
[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP, 'ROUNDUP'],
[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN, 'ROUNDDOWN']];
this.setHelpUrl(Blockly.Msg.MATH_ROUND_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.appendValueInput('NUM')
.setCheck('Number')
......@@ -332,7 +334,7 @@ Blockly.Blocks['math_on_list'] = {
// Assign 'this' to a variable for use in the closures below.
var thisBlock = this;
this.setHelpUrl(Blockly.Msg.MATH_ONLIST_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
var dropdown = new Blockly.FieldDropdown(OPERATORS, function(newOp) {
if (newOp == 'MODE') {
......@@ -368,7 +370,7 @@ Blockly.Blocks['math_modulo'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.MATH_MODULO_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.interpolateMsg(Blockly.Msg.MATH_MODULO_TITLE,
['DIVIDEND', 'Number', Blockly.ALIGN_RIGHT],
......@@ -386,7 +388,7 @@ Blockly.Blocks['math_constrain'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.MATH_CONSTRAIN_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.interpolateMsg(Blockly.Msg.MATH_CONSTRAIN_TITLE,
['VALUE', 'Number', Blockly.ALIGN_RIGHT],
......@@ -405,7 +407,7 @@ Blockly.Blocks['math_random_int'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.MATH_RANDOM_INT_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.interpolateMsg(Blockly.Msg.MATH_RANDOM_INT_TITLE,
['FROM', 'Number', Blockly.ALIGN_RIGHT],
......@@ -423,7 +425,7 @@ Blockly.Blocks['math_random_float'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL);
this.setColour(230);
this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(true, 'Number');
this.appendDummyInput()
.appendField(Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM);
......
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.procedures');
goog.require('Blockly.Blocks');
Blockly.Blocks.procedures.HUE = 290;
Blockly.Blocks['procedures_defnoreturn'] = {
/**
* Block for defining a procedure with no return value.
......@@ -36,7 +38,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
var name = Blockly.Procedures.findLegalName(
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE, this);
this.appendDummyInput()
......@@ -329,7 +331,7 @@ Blockly.Blocks['procedures_defreturn'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
var name = Blockly.Procedures.findLegalName(
Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE, this);
this.appendDummyInput()
......@@ -376,7 +378,7 @@ Blockly.Blocks['procedures_mutatorcontainer'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
this.appendStatementInput('STACK');
......@@ -394,7 +396,7 @@ Blockly.Blocks['procedures_mutatorarg'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE)
.appendField(new Blockly.FieldTextInput('x', this.validator_), 'NAME');
......@@ -425,7 +427,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL)
.appendField('', 'NAME')
......@@ -628,7 +630,7 @@ Blockly.Blocks['procedures_callreturn'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_CALLRETURN_CALL)
.appendField('', 'NAME')
......@@ -656,7 +658,7 @@ Blockly.Blocks['procedures_ifreturn'] = {
*/
init: function() {
this.setHelpUrl('http://c2.com/cgi/wiki?GuardClause');
this.setColour(290);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendValueInput('CONDITION')
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
......
......@@ -24,11 +24,13 @@
*/
'use strict';
goog.provide('Blockly.Blocks.text');
goog.provide('Blockly.Blocks.texts');
goog.require('Blockly.Blocks');
Blockly.Blocks.texts.HUE = 160;
Blockly.Blocks['text'] = {
/**
* Block for text value.
......@@ -36,7 +38,7 @@ Blockly.Blocks['text'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendDummyInput()
.appendField(this.newQuote_(true))
.appendField(new Blockly.FieldTextInput(''), 'TEXT')
......@@ -67,7 +69,7 @@ Blockly.Blocks['text_join'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.TEXT_JOIN_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.itemCount_ = 2;
this.updateShape_();
this.setOutput(true, 'String');
......@@ -193,7 +195,7 @@ Blockly.Blocks['text_create_join_container'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN);
this.appendStatementInput('STACK');
......@@ -208,7 +210,7 @@ Blockly.Blocks['text_create_join_item'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM);
this.setPreviousStatement(true);
......@@ -225,7 +227,7 @@ Blockly.Blocks['text_append'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.TEXT_APPEND_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendValueInput('TEXT')
.appendField(Blockly.Msg.TEXT_APPEND_TO)
.appendField(new Blockly.FieldVariable(
......@@ -269,7 +271,7 @@ Blockly.Blocks['text_length'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.TEXT_LENGTH_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.interpolateMsg(Blockly.Msg.TEXT_LENGTH_TITLE,
['VALUE', ['String', 'Array'], Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
......@@ -285,7 +287,7 @@ Blockly.Blocks['text_isEmpty'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.TEXT_ISEMPTY_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.interpolateMsg(Blockly.Msg.TEXT_ISEMPTY_TITLE,
['VALUE', ['String', 'Array'], Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
......@@ -304,7 +306,7 @@ Blockly.Blocks['text_indexOf'] = {
[[Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST, 'FIRST'],
[Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST, 'LAST']];
this.setHelpUrl(Blockly.Msg.TEXT_INDEXOF_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.setOutput(true, 'Number');
this.appendValueInput('VALUE')
.setCheck('String')
......@@ -333,7 +335,7 @@ Blockly.Blocks['text_charAt'] = {
[Blockly.Msg.TEXT_CHARAT_LAST, 'LAST'],
[Blockly.Msg.TEXT_CHARAT_RANDOM, 'RANDOM']];
this.setHelpUrl(Blockly.Msg.TEXT_CHARAT_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.setOutput(true, 'String');
this.appendValueInput('VALUE')
.setCheck('String')
......@@ -421,7 +423,7 @@ Blockly.Blocks['text_getSubstring'] = {
[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END, 'FROM_END'],
[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST, 'LAST']];
this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendValueInput('STRING')
.setCheck('String')
.appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);
......@@ -522,7 +524,7 @@ Blockly.Blocks['text_changeCase'] = {
[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE, 'LOWERCASE'],
[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE, 'TITLECASE']];
this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendValueInput('TEXT')
.setCheck('String')
.appendField(new Blockly.FieldDropdown(OPERATORS), 'CASE');
......@@ -542,7 +544,7 @@ Blockly.Blocks['text_trim'] = {
[Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT, 'LEFT'],
[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT, 'RIGHT']];
this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.appendValueInput('TEXT')
.setCheck('String')
.appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE');
......@@ -558,7 +560,7 @@ Blockly.Blocks['text_print'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.TEXT_PRINT_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
this.interpolateMsg(Blockly.Msg.TEXT_PRINT_TITLE,
['TEXT', null, Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
......@@ -580,7 +582,7 @@ Blockly.Blocks['text_prompt'] = {
// Assign 'this' to a variable for use in the closure below.
var thisBlock = this;
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
if (newOp == 'NUMBER') {
thisBlock.changeOutput('Number');
......@@ -617,7 +619,7 @@ Blockly.Blocks['text_prompt_ext'] = {
// Assign 'this' to a variable for use in the closure below.
var thisBlock = this;
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
this.setColour(160);
this.setColour(Blockly.Blocks.texts.HUE);
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
if (newOp == 'NUMBER') {
thisBlock.changeOutput('Number');
......
......@@ -29,6 +29,8 @@ goog.provide('Blockly.Blocks.variables');
goog.require('Blockly.Blocks');
Blockly.Blocks.variables.HUE = 330;
Blockly.Blocks['variables_get'] = {
/**
* Block for variable getter.
......@@ -36,7 +38,7 @@ Blockly.Blocks['variables_get'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
this.setColour(330);
this.setColour(Blockly.Blocks.variables.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.VARIABLES_GET_TITLE)
.appendField(new Blockly.FieldVariable(
......@@ -92,7 +94,7 @@ Blockly.Blocks['variables_set'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL);
this.setColour(330);
this.setColour(Blockly.Blocks.variables.HUE);
this.interpolateMsg(
// TODO: Combine these messages instead of using concatenation.
Blockly.Msg.VARIABLES_SET_TITLE + ' %1 ' +
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment