Small fixes

This commit is contained in:
alschmiedt
2019-01-09 15:38:30 -08:00
parent 55a46f8299
commit caf664db04
6 changed files with 18 additions and 17 deletions

View File

@@ -239,7 +239,7 @@ Blockly.Block.prototype.colour_ = '#000000';
/**
* Secondary colour of the block.
* Colour of the block if it is a shadow
* Colour of shadow blocks.
* @type {?string}
* @private
*/
@@ -247,7 +247,7 @@ Blockly.Block.prototype.secondaryColour_ = null;
/**
* Tertiary colour of the block.
* Colour of the border on the block.
* Colour of the block's border.
* @type {?string}
* @private
*/
@@ -935,12 +935,12 @@ Blockly.Block.prototype.setColour = function(colour) {
* @throws {Error} if the block style does not exist.
*/
Blockly.Block.prototype.setStyle = function(blockStyleName) {
var style = Blockly.getTheme();
if (!style) {
var theme = Blockly.getTheme();
if (!theme) {
throw Error('Trying to set block style to ' + blockStyleName +
' before style was defined via Blockly.setStyle().');
' before theme was defined via Blockly.setTheme().');
}
var blockStyle = style.getBlockStyle(blockStyleName);
var blockStyle = theme.getBlockStyle(blockStyleName);
this.styleName_ = blockStyleName;
if (blockStyle) {

View File

@@ -114,7 +114,7 @@ Blockly.cache3dSupported_ = null;
/**
* Holds all Blockly style attributes.
* @type {?Blockly.Style}
* @type {?Blockly.Theme}
* @private
*/
Blockly.theme_ = null;

View File

@@ -402,13 +402,16 @@ Blockly.Mutator.prototype.dispose = function() {
* @public
*/
Blockly.Mutator.prototype.updateBlockStyle = function() {
if (this.workspace_ && this.workspace_.getAllBlocks()){
var workspaceBlocks = this.workspace_.getAllBlocks();
var ws = this.workspace_;
if (ws && ws.getAllBlocks()){
var workspaceBlocks = ws.getAllBlocks();
for (var i = 0; i < workspaceBlocks.length; i++) {
var block = workspaceBlocks[i];
block.setStyle(block.getStyleName());
}
var flyoutBlocks = this.workspace_.flyout_.workspace_.getAllBlocks();
var flyoutBlocks = ws.flyout_.workspace_.getAllBlocks();
for (var i = 0; i < flyoutBlocks.length; i++) {
var block = flyoutBlocks[i];
block.setStyle(block.getStyleName());

View File

@@ -20,16 +20,15 @@
/**
* @fileoverview The class representing a theme.
* @author aschmiedt@google.com (Abby Schmiedt)
*/
'use strict';
goog.provide('Blockly.Theme');
/**
* Class for a theme.
* @param {Object.<string, Blockly.BlockStyle>} blockStyles A map from style
* @param {?Object.<string, Blockly.BlockStyle>} blockStyles A map from style
* names (strings) to objects with style attributes relating to blocks.
* @param {Object.<string, Blockly.CategoryStyle>} categoryStyles A map from style
* @param {?Object.<string, Blockly.CategoryStyle>} categoryStyles A map from style
* names (strings) to objects with style attributes relating to categories.
* @constructor
*/

View File

@@ -91,7 +91,6 @@ function start() {
zoom: {controls: true, wheel: true}
});
changeIndex();
Blockly.setTheme(Blockly.Themes.Classic);
}
/*

View File

@@ -91,7 +91,7 @@ function test_getAllBlockStyles() {
function test_getBlockStyles() {
var theme = new Blockly.Theme(createBlockStyles());
var blockStyle = theme.getBlockStyle("styleOne");
var blockStyle = theme.getBlockStyle('styleOne');
stringifyAndCompare(blockStyle, createBlockStyles().styleOne);
}
@@ -99,7 +99,7 @@ function test_getBlockStyles() {
function test_setBlockStyleUpdate() {
var theme = new Blockly.Theme(createBlockStyles());
var blockStyle = createBlockStyles();
blockStyle.styleOne.primaryColour = "somethingElse";
blockStyle.styleOne.primaryColour = 'somethingElse';
theme.setBlockStyle('styleOne', blockStyle.styleOne);
@@ -142,7 +142,7 @@ function test_setTheme() {
//check that the toolbox refreshed method was called
assertEquals(workspace.refreshToolboxSelection(), 3);
assertEquals(Blockly.Events.FIRE_QUEUE_.pop().element, "themeChanged");
assertEquals(Blockly.Events.FIRE_QUEUE_.pop().element, 'themeChanged');
undefineThemeTestBlocks();
}