mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
Small fixes
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -114,7 +114,7 @@ Blockly.cache3dSupported_ = null;
|
||||
|
||||
/**
|
||||
* Holds all Blockly style attributes.
|
||||
* @type {?Blockly.Style}
|
||||
* @type {?Blockly.Theme}
|
||||
* @private
|
||||
*/
|
||||
Blockly.theme_ = null;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -91,7 +91,6 @@ function start() {
|
||||
zoom: {controls: true, wheel: true}
|
||||
});
|
||||
changeIndex();
|
||||
Blockly.setTheme(Blockly.Themes.Classic);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user