diff --git a/blockly_uncompressed.js b/blockly_uncompressed.js index 5fe4ac6e5..9b82fb1fe 100644 --- a/blockly_uncompressed.js +++ b/blockly_uncompressed.js @@ -85,7 +85,7 @@ goog.addDependency("../../../" + dir + "/core/options.js", ['Blockly.Options'], goog.addDependency("../../../" + dir + "/core/procedures.js", ['Blockly.Procedures'], ['Blockly.Blocks', 'Blockly.constants', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Names', 'Blockly.Workspace', 'Blockly.Xml', 'Blockly.Xml.utils']); goog.addDependency("../../../" + dir + "/core/rendered_connection.js", ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.utils', 'goog.math.Coordinate']); goog.addDependency("../../../" + dir + "/core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['Blockly.utils', 'goog.events.BrowserFeature', 'goog.math.Coordinate']); -goog.addDependency("../../../" + dir + "/core/style.js", ['Blockly.Style'], []); +goog.addDependency("../../../" + dir + "/core/theme.js", ['Blockly.Theme'], []); goog.addDependency("../../../" + dir + "/core/toolbox.js", ['Blockly.Toolbox'], ['Blockly.Events.Ui', 'Blockly.Flyout', 'Blockly.HorizontalFlyout', 'Blockly.Touch', 'Blockly.utils', 'Blockly.VerticalFlyout', 'goog.events', 'goog.events.BrowserFeature', 'goog.html.SafeHtml', 'goog.html.SafeStyle', 'goog.math.Rect', 'goog.style', 'goog.ui.tree.TreeControl', 'goog.ui.tree.TreeNode']); goog.addDependency("../../../" + dir + "/core/tooltip.js", ['Blockly.Tooltip'], ['Blockly.utils', 'goog.dom']); goog.addDependency("../../../" + dir + "/core/touch.js", ['Blockly.Touch'], ['Blockly.utils', 'goog.events.BrowserFeature']); @@ -1797,7 +1797,7 @@ goog.require('Blockly.Procedures'); goog.require('Blockly.RenderedConnection'); goog.require('Blockly.Scrollbar'); goog.require('Blockly.ScrollbarPair'); -goog.require('Blockly.Style'); +goog.require('Blockly.Theme'); goog.require('Blockly.Toolbox'); goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); diff --git a/core/block.js b/core/block.js index 9238959d1..426551bb2 100644 --- a/core/block.js +++ b/core/block.js @@ -929,7 +929,7 @@ Blockly.Block.prototype.setColour = function(colour) { * @throws {Error} if the block style does not exist. */ Blockly.Block.prototype.setStyle = function(blockStyleName) { - var style = Blockly.getStyle(); + var style = Blockly.getTheme(); if (!style) { throw Error('Trying to set block style to ' + blockStyleName + ' before style was defined via Blockly.setStyle().'); diff --git a/core/blockly.js b/core/blockly.js index 5cd4192c4..ec1829833 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -117,7 +117,7 @@ Blockly.cache3dSupported_ = null; * @type {?Blockly.Style} * @private */ -Blockly.style_ = null; +Blockly.theme_ = null; /** * Convert a hue (HSV model) into an RGB hex triplet. @@ -682,11 +682,11 @@ Blockly.checkBlockColourConstant_ = function( /** - * Sets the style for blockly and refreshes all blocks in toolbox and workspace. - * @param {Blockly.Style} style Style for blockly. + * Sets the theme for blockly and refreshes all blocks in the toolbox and workspace. + * @param {Blockly.Theme} theme Theme for blockly. */ -Blockly.setStyle = function(style) { - this.style_ = style; +Blockly.setTheme = function(theme) { + this.theme_ = theme; var ws = Blockly.getMainWorkspace(); this.updateBlockStyles_(ws.getAllBlocks()); @@ -698,7 +698,7 @@ Blockly.setStyle = function(style) { ws.refreshToolboxSelection(); } - var event = new Blockly.Events.Ui(null, 'styleChanged'); + var event = new Blockly.Events.Ui(null, 'themeChanged'); event.workspaceId = ws.id; Blockly.Events.fire(event); }; @@ -721,11 +721,11 @@ Blockly.updateBlockStyles_ = function(blocks) { }; /** - * Gets the style for blockly. - * @return {?Blockly.Style} style Style for blockly. + * Gets the theme. + * @return {?Blockly.Theme} theme Theme for blockly. */ -Blockly.getStyle = function() { - return this.style_; +Blockly.getTheme = function() { + return this.theme_; }; // IE9 does not have a console. Create a stub to stop errors. diff --git a/core/inject.js b/core/inject.js index 7c41ed087..c123f6e01 100644 --- a/core/inject.js +++ b/core/inject.js @@ -69,7 +69,7 @@ Blockly.inject = function(container, opt_options) { var workspace = Blockly.createMainWorkspace_(svg, options, blockDragSurface, workspaceDragSurface); - Blockly.setStyle(options.style); + Blockly.setTheme(options.theme); Blockly.init_(workspace); Blockly.mainWorkspace = workspace; diff --git a/core/options.js b/core/options.js index 29355941b..9dd209a02 100644 --- a/core/options.js +++ b/core/options.js @@ -119,9 +119,9 @@ Blockly.Options = function(options) { } else { var oneBasedIndex = !!options['oneBasedIndex']; } - var style = options['style']; - if (style === undefined) { - style = Blockly.Styles.Classic; + var theme = options['theme']; + if (theme === undefined) { + theme = Blockly.Themes.Classic; } this.RTL = rtl; @@ -144,7 +144,7 @@ Blockly.Options = function(options) { this.gridOptions = Blockly.Options.parseGridOptions_(options); this.zoomOptions = Blockly.Options.parseZoomOptions_(options); this.toolboxPosition = toolboxPosition; - this.style = style; + this.theme = theme; }; /** diff --git a/core/style.js b/core/theme.js similarity index 76% rename from core/style.js rename to core/theme.js index d0f60f90f..cdc495f19 100644 --- a/core/style.js +++ b/core/theme.js @@ -19,28 +19,28 @@ */ /** - * @fileoverview The class representing a style. + * @fileoverview The class representing a theme. * @author aschmiedt@google.com (Abby Schmiedt) */ 'use strict'; -goog.provide('Blockly.Style'); +goog.provide('Blockly.Theme'); /** - * Class for a style. + * Class for a theme. * @param {Object.} blockStyles A map from style - * names (strings) to objects with color attributes. + * names (strings) to objects with style attributes. * @constructor */ -Blockly.Style = function(blockStyles) { +Blockly.Theme = function(blockStyles) { this.blockStyles_ = blockStyles; }; /** * Overrides or adds all values from blockStyles to blockStyles_ - * @param {Object.} blockStyles List of a + * @param {Object.} blockStyles List of * block styles. */ -Blockly.Style.prototype.setAllBlockStyles = function(blockStyles) { +Blockly.Theme.prototype.setAllBlockStyles = function(blockStyles) { for (var key in blockStyles) { this.setBlockStyle(key, blockStyles[key]); } @@ -50,16 +50,16 @@ Blockly.Style.prototype.setAllBlockStyles = function(blockStyles) { * Gets a list of all the block style names. * @return{Array.} styleName List of blockstyle names. */ -Blockly.Style.prototype.getAllBlockStyles = function() { +Blockly.Theme.prototype.getAllBlockStyles = function() { return this.blockStyles_; }; /** * Gets the BlockStyle for the given block style name. * @param{String} blockStyleName The name of the block style. - * @return {Blockly.Style} The style with the block style name. + * @return {Blockly.BlockStyle} The style with the block style name. */ -Blockly.Style.prototype.getBlockStyle = function(blockStyleName) { +Blockly.Theme.prototype.getBlockStyle = function(blockStyleName) { return this.blockStyles_[blockStyleName]; }; @@ -68,6 +68,6 @@ Blockly.Style.prototype.getBlockStyle = function(blockStyleName) { * @param{String} blockStyleName The name of the block style. * @param{Blockly.BlockStyle} blockStyle The block style */ -Blockly.Style.prototype.setBlockStyle = function(blockStyleName, blockStyle) { +Blockly.Theme.prototype.setBlockStyle = function(blockStyleName, blockStyle) { this.blockStyles_[blockStyleName] = blockStyle; }; diff --git a/tests/generators/index.html b/tests/generators/index.html index 63c4461d8..be72c7675 100644 --- a/tests/generators/index.html +++ b/tests/generators/index.html @@ -59,7 +59,7 @@ - + @@ -91,7 +91,7 @@ function start() { zoom: {controls: true, wheel: true} }); changeIndex(); - Blockly.setStyle(Blockly.Styles.Classic); + Blockly.setTheme(Blockly.Themes.Classic); } /* diff --git a/tests/jsunit/block_test.js b/tests/jsunit/block_test.js index 5c26893c1..28d85281c 100644 --- a/tests/jsunit/block_test.js +++ b/tests/jsunit/block_test.js @@ -270,7 +270,7 @@ function test_set_style() { } } }; - setUpMockMethod(mockControl_, Blockly, 'getStyle', null, [styleStub]); + setUpMockMethod(mockControl_, Blockly, 'getTheme', null, [styleStub]); var blockA = workspace.newBlock('row_block'); blockA.setStyle('styleOne'); @@ -288,7 +288,7 @@ function test_set_style_throw_exception() { return null; } }; - setUpMockMethod(mockControl_, Blockly, 'getStyle', null, [styleStub]); + setUpMockMethod(mockControl_, Blockly, 'getTheme', null, [styleStub]); var blockA = workspace.newBlock('row_block'); try { blockA.setStyle('styleOne'); diff --git a/tests/jsunit/index.html b/tests/jsunit/index.html index a54339b26..18ee34d32 100644 --- a/tests/jsunit/index.html +++ b/tests/jsunit/index.html @@ -29,7 +29,7 @@ - + diff --git a/tests/jsunit/style_test.js b/tests/jsunit/theme_test.js similarity index 70% rename from tests/jsunit/style_test.js rename to tests/jsunit/theme_test.js index 1f1d8427f..07e3cfdb3 100644 --- a/tests/jsunit/style_test.js +++ b/tests/jsunit/theme_test.js @@ -24,7 +24,7 @@ */ 'use strict'; -function defineStyleTestBlocks() { +function defineThemeTestBlocks() { Blockly.defineBlocksWithJsonArray([{ "type": "stack_block", "message0": "", @@ -44,7 +44,7 @@ function defineStyleTestBlocks() { }]); }; -function undefineStyleTestBlocks() { +function undefineThemeTestBlocks() { delete Blockly.Blocks['stack_block']; delete Blockly.Blocks['row_block']; } @@ -76,47 +76,47 @@ function createMultipleBlockStyles() { } function test_setAllBlockStyles() { - var style = new Blockly.Style(createBlockStyles()); - stringifyAndCompare(createBlockStyles(), style.blockStyles_); - style.setAllBlockStyles(createMultipleBlockStyles()); - stringifyAndCompare(createMultipleBlockStyles(), style.blockStyles_); + var theme = new Blockly.Theme(createBlockStyles()); + stringifyAndCompare(createBlockStyles(), theme.blockStyles_); + theme.setAllBlockStyles(createMultipleBlockStyles()); + stringifyAndCompare(createMultipleBlockStyles(), theme.blockStyles_); } function test_getAllBlockStyles() { - var style = new Blockly.Style(createMultipleBlockStyles()); - var allBlocks = style.getAllBlockStyles(); + var theme = new Blockly.Theme(createMultipleBlockStyles()); + var allBlocks = theme.getAllBlockStyles(); stringifyAndCompare(createMultipleBlockStyles(), allBlocks); } function test_getBlockStyles() { - var style = new Blockly.Style(createBlockStyles()); - var blockStyle = style.getBlockStyle("styleOne"); + var theme = new Blockly.Theme(createBlockStyles()); + var blockStyle = theme.getBlockStyle("styleOne"); stringifyAndCompare(blockStyle, createBlockStyles().styleOne); } function test_setBlockStyleUpdate() { - var style = new Blockly.Style(createBlockStyles()); + var theme = new Blockly.Theme(createBlockStyles()); var blockStyle = createBlockStyles(); blockStyle.styleOne.primaryColour = "somethingElse"; - style.setBlockStyle('styleOne', blockStyle.styleOne); + theme.setBlockStyle('styleOne', blockStyle.styleOne); - stringifyAndCompare(style.blockStyles_, blockStyle); + stringifyAndCompare(theme.blockStyles_, blockStyle); } function test_setBlockStyleAdd() { - var style = new Blockly.Style(createBlockStyles()); + var theme = new Blockly.Theme(createBlockStyles()); var blockStyle = createMultipleBlockStyles(); - style.setBlockStyle('styleTwo', blockStyle.styleTwo); + theme.setBlockStyle('styleTwo', blockStyle.styleTwo); - stringifyAndCompare(style.blockStyles_, blockStyle); + stringifyAndCompare(theme.blockStyles_, blockStyle); } -function test_setStyleForBlockly() { - defineStyleTestBlocks(); +function test_setTheme() { + defineThemeTestBlocks(); var blockStyles = createBlockStyles(); var workspace = new Blockly.WorkspaceSvg({}); var blockA = workspace.newBlock('stack_block'); @@ -131,20 +131,20 @@ function test_setStyleForBlockly() { setUpMockMethod(mockControl_, Blockly, 'getMainWorkspace', null, [workspace]); - Blockly.setStyle(blockStyles); + Blockly.setTheme(blockStyles); - //Checks that the style set correctly on Blockly namespace - stringifyAndCompare(Blockly.getStyle(), blockStyles); + //Checks that the theme was set correctly on Blockly namespace + stringifyAndCompare(Blockly.getTheme(), blockStyles); - //Checks that the setStyle function was called on the block + //Checks that the setTheme function was called on the block assertEquals(blockA.getStyleName(), 'styleTwo'); //check that the toolbox refreshed method was called assertEquals(workspace.refreshToolboxSelection(), 3); - assertEquals(Blockly.Events.FIRE_QUEUE_.pop().element, "styleChanged"); + assertEquals(Blockly.Events.FIRE_QUEUE_.pop().element, "themeChanged"); - undefineStyleTestBlocks(); + undefineThemeTestBlocks(); } function stringifyAndCompare(val1, val2) { diff --git a/tests/multi_playground.html b/tests/multi_playground.html index cc48d80fe..f6a74f589 100644 --- a/tests/multi_playground.html +++ b/tests/multi_playground.html @@ -13,7 +13,7 @@ - + - - - + + +