mirror of
https://github.com/google/blockly.git
synced 2026-01-14 20:37:10 +01:00
Fixing review comments
This commit is contained in:
@@ -133,7 +133,7 @@ Blockly.Blocks['lists_create_with'] = {
|
||||
*/
|
||||
init: function() {
|
||||
this.setHelpUrl(Blockly.Msg['LISTS_CREATE_WITH_HELPURL']);
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.itemCount_ = 3;
|
||||
this.updateShape_();
|
||||
this.setOutput(true, 'Array');
|
||||
@@ -256,7 +256,7 @@ Blockly.Blocks['lists_create_with_container'] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg['LISTS_CREATE_WITH_CONTAINER_TITLE_ADD']);
|
||||
this.appendStatementInput('STACK');
|
||||
@@ -271,7 +271,7 @@ Blockly.Blocks['lists_create_with_item'] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg['LISTS_CREATE_WITH_ITEM_TITLE']);
|
||||
this.setPreviousStatement(true);
|
||||
@@ -293,7 +293,7 @@ Blockly.Blocks['lists_indexOf'] = {
|
||||
[Blockly.Msg['LISTS_INDEX_OF_LAST'], 'LAST']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['LISTS_INDEX_OF_HELPURL']);
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.setOutput(true, 'Number');
|
||||
this.appendValueInput('VALUE')
|
||||
.setCheck('Array')
|
||||
@@ -331,7 +331,7 @@ Blockly.Blocks['lists_getIndex'] = {
|
||||
[Blockly.Msg['LISTS_GET_INDEX_RANDOM'], 'RANDOM']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['LISTS_GET_INDEX_HELPURL']);
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
|
||||
var isStatement = (value == 'REMOVE');
|
||||
this.sourceBlock_.updateStatement_(isStatement);
|
||||
@@ -515,7 +515,7 @@ Blockly.Blocks['lists_setIndex'] = {
|
||||
[Blockly.Msg['LISTS_GET_INDEX_RANDOM'], 'RANDOM']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['LISTS_SET_INDEX_HELPURL']);
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.appendValueInput('LIST')
|
||||
.setCheck('Array')
|
||||
.appendField(Blockly.Msg['LISTS_SET_INDEX_INPUT_IN_LIST']);
|
||||
@@ -654,7 +654,7 @@ Blockly.Blocks['lists_getSublist'] = {
|
||||
[Blockly.Msg['LISTS_GET_SUBLIST_END_LAST'], 'LAST']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['LISTS_GET_SUBLIST_HELPURL']);
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.appendValueInput('LIST')
|
||||
.setCheck('Array')
|
||||
.appendField(Blockly.Msg['LISTS_GET_SUBLIST_INPUT_IN_LIST']);
|
||||
@@ -803,7 +803,7 @@ Blockly.Blocks['lists_split'] = {
|
||||
thisBlock.updateType_(newMode);
|
||||
});
|
||||
this.setHelpUrl(Blockly.Msg['LISTS_SPLIT_HELPURL']);
|
||||
this.setStyle("lists");
|
||||
this.setStyle('lists');
|
||||
this.appendValueInput('INPUT')
|
||||
.setCheck('String')
|
||||
.appendField(dropdown, 'MODE');
|
||||
|
||||
@@ -50,7 +50,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
|
||||
Blockly.Msg['PROCEDURES_DEFNORETURN_COMMENT']) {
|
||||
this.setCommentText(Blockly.Msg['PROCEDURES_DEFNORETURN_COMMENT']);
|
||||
}
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
this.setTooltip(Blockly.Msg['PROCEDURES_DEFNORETURN_TOOLTIP']);
|
||||
this.setHelpUrl(Blockly.Msg['PROCEDURES_DEFNORETURN_HELPURL']);
|
||||
this.arguments_ = [];
|
||||
@@ -416,7 +416,7 @@ Blockly.Blocks['procedures_defreturn'] = {
|
||||
Blockly.Msg['PROCEDURES_DEFRETURN_COMMENT']) {
|
||||
this.setCommentText(Blockly.Msg['PROCEDURES_DEFRETURN_COMMENT']);
|
||||
}
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
this.setTooltip(Blockly.Msg['PROCEDURES_DEFRETURN_TOOLTIP']);
|
||||
this.setHelpUrl(Blockly.Msg['PROCEDURES_DEFRETURN_HELPURL']);
|
||||
this.arguments_ = [];
|
||||
@@ -462,7 +462,7 @@ Blockly.Blocks['procedures_mutatorcontainer'] = {
|
||||
this.appendDummyInput('STATEMENT_INPUT')
|
||||
.appendField(Blockly.Msg['PROCEDURES_ALLOW_STATEMENTS'])
|
||||
.appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
this.setTooltip(Blockly.Msg['PROCEDURES_MUTATORCONTAINER_TOOLTIP']);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
@@ -489,7 +489,7 @@ Blockly.Blocks['procedures_mutatorarg'] = {
|
||||
.appendField(field, 'NAME');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
this.setTooltip(Blockly.Msg['PROCEDURES_MUTATORARG_TOOLTIP']);
|
||||
this.contextMenu = false;
|
||||
|
||||
@@ -562,7 +562,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
|
||||
.appendField(this.id, 'NAME');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
// Tooltip is set in renameProcedure.
|
||||
this.setHelpUrl(Blockly.Msg['PROCEDURES_CALLNORETURN_HELPURL']);
|
||||
this.arguments_ = [];
|
||||
@@ -903,7 +903,7 @@ Blockly.Blocks['procedures_callreturn'] = {
|
||||
this.appendDummyInput('TOPROW')
|
||||
.appendField('', 'NAME');
|
||||
this.setOutput(true);
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
// Tooltip is set in domToMutation.
|
||||
this.setHelpUrl(Blockly.Msg['PROCEDURES_CALLRETURN_HELPURL']);
|
||||
this.arguments_ = [];
|
||||
@@ -940,7 +940,7 @@ Blockly.Blocks['procedures_ifreturn'] = {
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setStyle("procedures");
|
||||
this.setStyle('procedures');
|
||||
this.setTooltip(Blockly.Msg['PROCEDURES_IFRETURN_TOOLTIP']);
|
||||
this.setHelpUrl(Blockly.Msg['PROCEDURES_IFRETURN_HELPURL']);
|
||||
this.hasReturnValue_ = true;
|
||||
|
||||
@@ -221,7 +221,7 @@ Blockly.Blocks['text_getSubstring'] = {
|
||||
[Blockly.Msg['TEXT_GET_SUBSTRING_END_LAST'], 'LAST']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['TEXT_GET_SUBSTRING_HELPURL']);
|
||||
this.setStyle("text");
|
||||
this.setStyle('text');
|
||||
this.appendValueInput('STRING')
|
||||
.setCheck('String')
|
||||
.appendField(Blockly.Msg['TEXT_GET_SUBSTRING_INPUT_IN_TEXT']);
|
||||
@@ -329,7 +329,7 @@ Blockly.Blocks['text_changeCase'] = {
|
||||
[Blockly.Msg['TEXT_CHANGECASE_OPERATOR_TITLECASE'], 'TITLECASE']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['TEXT_CHANGECASE_HELPURL']);
|
||||
this.setStyle("text");
|
||||
this.setStyle('text');
|
||||
this.appendValueInput('TEXT')
|
||||
.setCheck('String')
|
||||
.appendField(new Blockly.FieldDropdown(OPERATORS), 'CASE');
|
||||
@@ -350,7 +350,7 @@ Blockly.Blocks['text_trim'] = {
|
||||
[Blockly.Msg['TEXT_TRIM_OPERATOR_RIGHT'], 'RIGHT']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['TEXT_TRIM_HELPURL']);
|
||||
this.setStyle("text");
|
||||
this.setStyle('text');
|
||||
this.appendValueInput('TEXT')
|
||||
.setCheck('String')
|
||||
.appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE');
|
||||
@@ -393,7 +393,7 @@ Blockly.Blocks['text_prompt_ext'] = {
|
||||
[Blockly.Msg['TEXT_PROMPT_TYPE_NUMBER'], 'NUMBER']
|
||||
];
|
||||
this.setHelpUrl(Blockly.Msg['TEXT_PROMPT_HELPURL']);
|
||||
this.setStyle("text");
|
||||
this.setStyle('text');
|
||||
// Assign 'this' to a variable for use in the closures below.
|
||||
var thisBlock = this;
|
||||
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
|
||||
@@ -453,7 +453,7 @@ Blockly.Blocks['text_prompt'] = {
|
||||
// Assign 'this' to a variable for use in the closures below.
|
||||
var thisBlock = this;
|
||||
this.setHelpUrl(Blockly.Msg['TEXT_PROMPT_HELPURL']);
|
||||
this.setStyle("text");
|
||||
this.setStyle('text');
|
||||
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
|
||||
thisBlock.updateType_(newOp);
|
||||
});
|
||||
|
||||
@@ -928,13 +928,12 @@ Blockly.Block.prototype.setColour = function(colour) {
|
||||
* @throws {Error} if the block style does not exist.
|
||||
*/
|
||||
Blockly.Block.prototype.setStyle = function(blockStyleName) {
|
||||
var dereferenced = Blockly.utils.replaceMessageReferences(blockStyleName);
|
||||
var style = Blockly.getStyle();
|
||||
if (!style) {
|
||||
throw 'Trying to set block style before Blockly.setStyle() has been called';
|
||||
throw Error('Trying to set block style before Blockly.setStyle() has been called');
|
||||
}
|
||||
var blockStyle = style.getBlockStyle(dereferenced);
|
||||
this.styleName_ = dereferenced;
|
||||
var blockStyle = style.getBlockStyle(blockStyleName);
|
||||
this.styleName_ = blockStyleName;
|
||||
|
||||
if (blockStyle) {
|
||||
this.style_ = blockStyle;
|
||||
@@ -944,8 +943,7 @@ Blockly.Block.prototype.setStyle = function(blockStyleName) {
|
||||
this.setColour(blockStyle.primaryColour);
|
||||
}
|
||||
else {
|
||||
var errorMsg = 'Invalid style name: ' + blockStyleName;
|
||||
throw errorMsg;
|
||||
throw Error('Invalid style name: ' + blockStyleName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ Blockly.inject = function(container, opt_options) {
|
||||
Blockly.mainWorkspace = workspace;
|
||||
|
||||
Blockly.svgResize(workspace);
|
||||
|
||||
Blockly.setStyle(options.style);
|
||||
return workspace;
|
||||
};
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@ Blockly.Options = function(options) {
|
||||
} else {
|
||||
var oneBasedIndex = !!options['oneBasedIndex'];
|
||||
}
|
||||
var style = options['style'];
|
||||
if (style === undefined) {
|
||||
style = Blockly.Styles.Classic;
|
||||
}
|
||||
|
||||
this.RTL = rtl;
|
||||
this.oneBasedIndex = oneBasedIndex;
|
||||
@@ -140,6 +144,7 @@ Blockly.Options = function(options) {
|
||||
this.gridOptions = Blockly.Options.parseGridOptions_(options);
|
||||
this.zoomOptions = Blockly.Options.parseZoomOptions_(options);
|
||||
this.toolboxPosition = toolboxPosition;
|
||||
this.style = style;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2018 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview The class representing a style.
|
||||
* @author aschmiedt@google.com (Abby Schmiedt)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Style');
|
||||
@@ -45,8 +69,5 @@ Blockly.Style.prototype.getBlockStyle = function(blockStyleName) {
|
||||
* @param{Blockly.BlockStyle} blockStyle The block style
|
||||
*/
|
||||
Blockly.Style.prototype.setBlockStyle = function(blockStyleName, blockStyle) {
|
||||
var event = new Blockly.Events.Ui(null, 'blockStyleChanged',
|
||||
this.blockStyles_[blockStyleName], blockStyle);
|
||||
this.blockStyles_[blockStyleName] = blockStyle;
|
||||
Blockly.Events.fire(event);
|
||||
};
|
||||
|
||||
@@ -1,3 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2018 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Classic style.
|
||||
* Contains multi colored border to create shadow effect.
|
||||
* @author aschmiedt@google.com (Abby Schmiedt)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Styles.Classic');
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2018 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview High contrast style.
|
||||
* Darker colors to contrast the white block font.
|
||||
* @author aschmiedt@google.com (Abby Schmiedt)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Styles.HighContrast');
|
||||
@@ -52,6 +77,5 @@ var defaultBlockStyles = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//This style is still being fleshed out and may change.
|
||||
Blockly.Styles.HighContrast = new Blockly.Style(defaultBlockStyles);
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2018 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Modern style.
|
||||
* Same colors as classic, but single colored border.
|
||||
* @author aschmiedt@google.com (Abby Schmiedt)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Styles.Modern');
|
||||
@@ -52,4 +77,5 @@ var defaultBlockStyles = {
|
||||
}
|
||||
};
|
||||
|
||||
//This style is still being fleshed out and may change.
|
||||
Blockly.Styles.Modern = new Blockly.Style(defaultBlockStyles);
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2018 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
{
|
||||
"colour":"#A5745B",
|
||||
"lists":"260",
|
||||
|
||||
@@ -293,7 +293,7 @@ function test_set_style_throw_exception() {
|
||||
try {
|
||||
blockA.setStyle('styleOne');
|
||||
}catch(error) {
|
||||
assertEquals(error, "Invalid style name: styleOne");
|
||||
assertEquals(error.message, "Invalid style name: styleOne");
|
||||
}finally {
|
||||
blockTest_tearDown();
|
||||
}
|
||||
|
||||
@@ -139,8 +139,6 @@ function start() {
|
||||
logEvents(false);
|
||||
}
|
||||
taChange();
|
||||
changeStyle();
|
||||
|
||||
}
|
||||
|
||||
function changeStyle() {
|
||||
|
||||
Reference in New Issue
Block a user