mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
* Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations
415 lines
16 KiB
JavaScript
415 lines
16 KiB
JavaScript
/**
|
|
* @license
|
|
* Visual Blocks Editor
|
|
*
|
|
* Copyright 2011 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 Functions for injecting Blockly into a web page.
|
|
* @author fraser@google.com (Neil Fraser)
|
|
*/
|
|
'use strict';
|
|
|
|
goog.provide('Blockly.inject');
|
|
|
|
goog.require('Blockly.BlockDragSurfaceSvg');
|
|
goog.require('Blockly.Css');
|
|
goog.require('Blockly.Options');
|
|
goog.require('Blockly.WorkspaceSvg');
|
|
goog.require('Blockly.WorkspaceDragSurfaceSvg');
|
|
goog.require('goog.dom');
|
|
goog.require('goog.ui.Component');
|
|
goog.require('goog.userAgent');
|
|
|
|
|
|
/**
|
|
* Inject a Blockly editor into the specified container element (usually a div).
|
|
* @param {!Element|string} container Containing element, or its ID,
|
|
* or a CSS selector.
|
|
* @param {Object=} opt_options Optional dictionary of options.
|
|
* @return {!Blockly.Workspace} Newly created main workspace.
|
|
*/
|
|
Blockly.inject = function(container, opt_options) {
|
|
if (goog.isString(container)) {
|
|
container = document.getElementById(container) ||
|
|
document.querySelector(container);
|
|
}
|
|
// Verify that the container is in document.
|
|
if (!goog.dom.contains(document, container)) {
|
|
throw 'Error: container is not in current document.';
|
|
}
|
|
var options = new Blockly.Options(opt_options || {});
|
|
var subContainer = goog.dom.createDom('div', 'injectionDiv');
|
|
container.appendChild(subContainer);
|
|
var svg = Blockly.createDom_(subContainer, options);
|
|
|
|
// Create surfaces for dragging things. These are optimizations
|
|
// so that the broowser does not repaint during the drag.
|
|
var blockDragSurface = new Blockly.BlockDragSurfaceSvg(subContainer);
|
|
var workspaceDragSurface = new Blockly.WorkspaceDragSurfaceSvg(subContainer);
|
|
|
|
var workspace = Blockly.createMainWorkspace_(svg, options, blockDragSurface,
|
|
workspaceDragSurface);
|
|
Blockly.init_(workspace);
|
|
Blockly.mainWorkspace = workspace;
|
|
|
|
Blockly.svgResize(workspace);
|
|
return workspace;
|
|
};
|
|
|
|
/**
|
|
* Create the SVG image.
|
|
* @param {!Element} container Containing element.
|
|
* @param {!Blockly.Options} options Dictionary of options.
|
|
* @return {!Element} Newly created SVG image.
|
|
* @private
|
|
*/
|
|
Blockly.createDom_ = function(container, options) {
|
|
// Sadly browsers (Chrome vs Firefox) are currently inconsistent in laying
|
|
// out content in RTL mode. Therefore Blockly forces the use of LTR,
|
|
// then manually positions content in RTL as needed.
|
|
container.setAttribute('dir', 'LTR');
|
|
// Closure can be trusted to create HTML widgets with the proper direction.
|
|
goog.ui.Component.setDefaultRightToLeft(options.RTL);
|
|
|
|
// Load CSS.
|
|
Blockly.Css.inject(options.hasCss, options.pathToMedia);
|
|
|
|
// Build the SVG DOM.
|
|
/*
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
version="1.1"
|
|
class="blocklySvg">
|
|
...
|
|
</svg>
|
|
*/
|
|
var svg = Blockly.utils.createSvgElement('svg', {
|
|
'xmlns': 'http://www.w3.org/2000/svg',
|
|
'xmlns:html': 'http://www.w3.org/1999/xhtml',
|
|
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
|
'version': '1.1',
|
|
'class': 'blocklySvg'
|
|
}, container);
|
|
/*
|
|
<defs>
|
|
... filters go here ...
|
|
</defs>
|
|
*/
|
|
var defs = Blockly.utils.createSvgElement('defs', {}, svg);
|
|
// Each filter/pattern needs a unique ID for the case of multiple Blockly
|
|
// instances on a page. Browser behaviour becomes undefined otherwise.
|
|
// https://neil.fraser.name/news/2015/11/01/
|
|
var rnd = String(Math.random()).substring(2);
|
|
/*
|
|
<filter id="blocklyEmbossFilter837493">
|
|
<feGaussianBlur in="SourceAlpha" stdDeviation="1" result="blur" />
|
|
<feSpecularLighting in="blur" surfaceScale="1" specularConstant="0.5"
|
|
specularExponent="10" lighting-color="white"
|
|
result="specOut">
|
|
<fePointLight x="-5000" y="-10000" z="20000" />
|
|
</feSpecularLighting>
|
|
<feComposite in="specOut" in2="SourceAlpha" operator="in"
|
|
result="specOut" />
|
|
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic"
|
|
k1="0" k2="1" k3="1" k4="0" />
|
|
</filter>
|
|
*/
|
|
var embossFilter = Blockly.utils.createSvgElement('filter',
|
|
{'id': 'blocklyEmbossFilter' + rnd}, defs);
|
|
Blockly.utils.createSvgElement('feGaussianBlur',
|
|
{'in': 'SourceAlpha', 'stdDeviation': 1, 'result': 'blur'}, embossFilter);
|
|
var feSpecularLighting = Blockly.utils.createSvgElement('feSpecularLighting',
|
|
{'in': 'blur', 'surfaceScale': 1, 'specularConstant': 0.5,
|
|
'specularExponent': 10, 'lighting-color': 'white', 'result': 'specOut'},
|
|
embossFilter);
|
|
Blockly.utils.createSvgElement('fePointLight',
|
|
{'x': -5000, 'y': -10000, 'z': 20000}, feSpecularLighting);
|
|
Blockly.utils.createSvgElement('feComposite',
|
|
{'in': 'specOut', 'in2': 'SourceAlpha', 'operator': 'in',
|
|
'result': 'specOut'}, embossFilter);
|
|
Blockly.utils.createSvgElement('feComposite',
|
|
{'in': 'SourceGraphic', 'in2': 'specOut', 'operator': 'arithmetic',
|
|
'k1': 0, 'k2': 1, 'k3': 1, 'k4': 0}, embossFilter);
|
|
options.embossFilterId = embossFilter.id;
|
|
/*
|
|
<pattern id="blocklyDisabledPattern837493" patternUnits="userSpaceOnUse"
|
|
width="10" height="10">
|
|
<rect width="10" height="10" fill="#aaa" />
|
|
<path d="M 0 0 L 10 10 M 10 0 L 0 10" stroke="#cc0" />
|
|
</pattern>
|
|
*/
|
|
var disabledPattern = Blockly.utils.createSvgElement('pattern',
|
|
{'id': 'blocklyDisabledPattern' + rnd,
|
|
'patternUnits': 'userSpaceOnUse',
|
|
'width': 10, 'height': 10}, defs);
|
|
Blockly.utils.createSvgElement('rect',
|
|
{'width': 10, 'height': 10, 'fill': '#aaa'}, disabledPattern);
|
|
Blockly.utils.createSvgElement('path',
|
|
{'d': 'M 0 0 L 10 10 M 10 0 L 0 10', 'stroke': '#cc0'}, disabledPattern);
|
|
options.disabledPatternId = disabledPattern.id;
|
|
/*
|
|
<pattern id="blocklyGridPattern837493" patternUnits="userSpaceOnUse">
|
|
<rect stroke="#888" />
|
|
<rect stroke="#888" />
|
|
</pattern>
|
|
*/
|
|
var gridPattern = Blockly.utils.createSvgElement('pattern',
|
|
{'id': 'blocklyGridPattern' + rnd,
|
|
'patternUnits': 'userSpaceOnUse'}, defs);
|
|
if (options.gridOptions['length'] > 0 && options.gridOptions['spacing'] > 0) {
|
|
Blockly.utils.createSvgElement('line',
|
|
{'stroke': options.gridOptions['colour']},
|
|
gridPattern);
|
|
if (options.gridOptions['length'] > 1) {
|
|
Blockly.utils.createSvgElement('line',
|
|
{'stroke': options.gridOptions['colour']},
|
|
gridPattern);
|
|
}
|
|
// x1, y1, x1, x2 properties will be set later in updateGridPattern_.
|
|
}
|
|
options.gridPattern = gridPattern;
|
|
return svg;
|
|
};
|
|
|
|
/**
|
|
* Create a main workspace and add it to the SVG.
|
|
* @param {!Element} svg SVG element with pattern defined.
|
|
* @param {!Blockly.Options} options Dictionary of options.
|
|
* @param {!Blockly.BlockDragSurfaceSvg} blockDragSurface Drag surface SVG
|
|
* for the blocks.
|
|
* @param {!Blockly.WorkspaceDragSurfaceSvg} workspaceDragSurface Drag surface
|
|
* SVG for the workspace.
|
|
* @return {!Blockly.Workspace} Newly created main workspace.
|
|
* @private
|
|
*/
|
|
Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, workspaceDragSurface) {
|
|
options.parentWorkspace = null;
|
|
var mainWorkspace = new Blockly.WorkspaceSvg(options, blockDragSurface, workspaceDragSurface);
|
|
mainWorkspace.scale = options.zoomOptions.startScale;
|
|
svg.appendChild(mainWorkspace.createDom('blocklyMainBackground'));
|
|
|
|
if (!options.hasCategories && options.languageTree) {
|
|
// Add flyout as an <svg> that is a sibling of the workspace svg.
|
|
var flyout = mainWorkspace.addFlyout_('svg');
|
|
Blockly.utils.insertAfter_(flyout, svg);
|
|
}
|
|
|
|
// A null translation will also apply the correct initial scale.
|
|
mainWorkspace.translate(0, 0);
|
|
Blockly.mainWorkspace = mainWorkspace;
|
|
|
|
if (!options.readOnly && !options.hasScrollbars) {
|
|
var workspaceChanged = function() {
|
|
if (Blockly.dragMode_ == Blockly.DRAG_NONE) {
|
|
var metrics = mainWorkspace.getMetrics();
|
|
var edgeLeft = metrics.viewLeft + metrics.absoluteLeft;
|
|
var edgeTop = metrics.viewTop + metrics.absoluteTop;
|
|
if (metrics.contentTop < edgeTop ||
|
|
metrics.contentTop + metrics.contentHeight >
|
|
metrics.viewHeight + edgeTop ||
|
|
metrics.contentLeft <
|
|
(options.RTL ? metrics.viewLeft : edgeLeft) ||
|
|
metrics.contentLeft + metrics.contentWidth > (options.RTL ?
|
|
metrics.viewWidth : metrics.viewWidth + edgeLeft)) {
|
|
// One or more blocks may be out of bounds. Bump them back in.
|
|
var MARGIN = 25;
|
|
var blocks = mainWorkspace.getTopBlocks(false);
|
|
for (var b = 0, block; block = blocks[b]; b++) {
|
|
var blockXY = block.getRelativeToSurfaceXY();
|
|
var blockHW = block.getHeightWidth();
|
|
// Bump any block that's above the top back inside.
|
|
var overflowTop = edgeTop + MARGIN - blockHW.height - blockXY.y;
|
|
if (overflowTop > 0) {
|
|
block.moveBy(0, overflowTop);
|
|
}
|
|
// Bump any block that's below the bottom back inside.
|
|
var overflowBottom =
|
|
edgeTop + metrics.viewHeight - MARGIN - blockXY.y;
|
|
if (overflowBottom < 0) {
|
|
block.moveBy(0, overflowBottom);
|
|
}
|
|
// Bump any block that's off the left back inside.
|
|
var overflowLeft = MARGIN + edgeLeft -
|
|
blockXY.x - (options.RTL ? 0 : blockHW.width);
|
|
if (overflowLeft > 0) {
|
|
block.moveBy(overflowLeft, 0);
|
|
}
|
|
// Bump any block that's off the right back inside.
|
|
var overflowRight = edgeLeft + metrics.viewWidth - MARGIN -
|
|
blockXY.x + (options.RTL ? blockHW.width : 0);
|
|
if (overflowRight < 0) {
|
|
block.moveBy(overflowRight, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
mainWorkspace.addChangeListener(workspaceChanged);
|
|
}
|
|
// The SVG is now fully assembled.
|
|
Blockly.svgResize(mainWorkspace);
|
|
Blockly.WidgetDiv.createDom();
|
|
Blockly.Tooltip.createDom();
|
|
return mainWorkspace;
|
|
};
|
|
|
|
/**
|
|
* Initialize Blockly with various handlers.
|
|
* @param {!Blockly.Workspace} mainWorkspace Newly created main workspace.
|
|
* @private
|
|
*/
|
|
Blockly.init_ = function(mainWorkspace) {
|
|
var options = mainWorkspace.options;
|
|
var svg = mainWorkspace.getParentSvg();
|
|
|
|
// Suppress the browser's context menu.
|
|
Blockly.bindEventWithChecks_(svg.parentNode, 'contextmenu', null,
|
|
function(e) {
|
|
if (!Blockly.utils.isTargetInput(e)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
var workspaceResizeHandler = Blockly.bindEventWithChecks_(window, 'resize',
|
|
null,
|
|
function() {
|
|
Blockly.hideChaff(true);
|
|
Blockly.svgResize(mainWorkspace);
|
|
});
|
|
mainWorkspace.setResizeHandlerWrapper(workspaceResizeHandler);
|
|
|
|
Blockly.inject.bindDocumentEvents_();
|
|
|
|
if (options.languageTree) {
|
|
if (mainWorkspace.toolbox_) {
|
|
mainWorkspace.toolbox_.init(mainWorkspace);
|
|
} else if (mainWorkspace.flyout_) {
|
|
// Build a fixed flyout with the root blocks.
|
|
mainWorkspace.flyout_.init(mainWorkspace);
|
|
mainWorkspace.flyout_.show(options.languageTree.childNodes);
|
|
mainWorkspace.flyout_.scrollToStart();
|
|
// Translate the workspace sideways to avoid the fixed flyout.
|
|
mainWorkspace.scrollX = mainWorkspace.flyout_.width_;
|
|
if (options.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT) {
|
|
mainWorkspace.scrollX *= -1;
|
|
}
|
|
mainWorkspace.translate(mainWorkspace.scrollX, 0);
|
|
}
|
|
}
|
|
|
|
if (options.hasScrollbars) {
|
|
mainWorkspace.scrollbar = new Blockly.ScrollbarPair(mainWorkspace);
|
|
mainWorkspace.scrollbar.resize();
|
|
}
|
|
|
|
// Load the sounds.
|
|
if (options.hasSounds) {
|
|
Blockly.inject.loadSounds_(options.pathToMedia, mainWorkspace);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Bind document events, but only once. Destroying and reinjecting Blockly
|
|
* should not bind again.
|
|
* Bind events for scrolling the workspace.
|
|
* Most of these events should be bound to the SVG's surface.
|
|
* However, 'mouseup' has to be on the whole document so that a block dragged
|
|
* out of bounds and released will know that it has been released.
|
|
* Also, 'keydown' has to be on the whole document since the browser doesn't
|
|
* understand a concept of focus on the SVG image.
|
|
* @private
|
|
*/
|
|
Blockly.inject.bindDocumentEvents_ = function() {
|
|
if (!Blockly.documentEventsBound_) {
|
|
Blockly.bindEventWithChecks_(document, 'keydown', null, Blockly.onKeyDown_);
|
|
// longStop needs to run to stop the context menu from showing up. It
|
|
// should run regardless of what other touch event handlers have run.
|
|
Blockly.bindEvent_(document, 'touchend', null, Blockly.longStop_);
|
|
Blockly.bindEvent_(document, 'touchcancel', null, Blockly.longStop_);
|
|
// Don't use bindEvent_ for document's mouseup since that would create a
|
|
// corresponding touch handler that would squelch the ability to interact
|
|
// with non-Blockly elements.
|
|
document.addEventListener('mouseup', Blockly.onMouseUp_, false);
|
|
// Some iPad versions don't fire resize after portrait to landscape change.
|
|
if (goog.userAgent.IPAD) {
|
|
Blockly.bindEventWithChecks_(window, 'orientationchange', document,
|
|
function() {
|
|
// TODO(#397): Fix for multiple blockly workspaces.
|
|
Blockly.svgResize(Blockly.getMainWorkspace());
|
|
});
|
|
}
|
|
}
|
|
Blockly.documentEventsBound_ = true;
|
|
};
|
|
|
|
/**
|
|
* Load sounds for the given workspace.
|
|
* @param {string} pathToMedia The path to the media directory.
|
|
* @param {!Blockly.Workspace} workspace The workspace to load sounds for.
|
|
* @private
|
|
*/
|
|
Blockly.inject.loadSounds_ = function(pathToMedia, workspace) {
|
|
workspace.loadAudio_(
|
|
[pathToMedia + 'click.mp3',
|
|
pathToMedia + 'click.wav',
|
|
pathToMedia + 'click.ogg'], 'click');
|
|
workspace.loadAudio_(
|
|
[pathToMedia + 'disconnect.wav',
|
|
pathToMedia + 'disconnect.mp3',
|
|
pathToMedia + 'disconnect.ogg'], 'disconnect');
|
|
workspace.loadAudio_(
|
|
[pathToMedia + 'delete.mp3',
|
|
pathToMedia + 'delete.ogg',
|
|
pathToMedia + 'delete.wav'], 'delete');
|
|
|
|
// Bind temporary hooks that preload the sounds.
|
|
var soundBinds = [];
|
|
var unbindSounds = function() {
|
|
while (soundBinds.length) {
|
|
Blockly.unbindEvent_(soundBinds.pop());
|
|
}
|
|
workspace.preloadAudio_();
|
|
};
|
|
|
|
// These are bound on mouse/touch events with Blockly.bindEventWithChecks_, so
|
|
// they restrict the touch identifier that will be recognized. But this is
|
|
// really something that happens on a click, not a drag, so that's not
|
|
// necessary.
|
|
|
|
// Android ignores any sound not loaded as a result of a user action.
|
|
soundBinds.push(
|
|
Blockly.bindEventWithChecks_(document, 'mousemove', null, unbindSounds,
|
|
true));
|
|
soundBinds.push(
|
|
Blockly.bindEventWithChecks_(document, 'touchstart', null, unbindSounds,
|
|
true));
|
|
};
|
|
|
|
/**
|
|
* Modify the block tree on the existing toolbox.
|
|
* @param {Node|string} tree DOM tree of blocks, or text representation of same.
|
|
* @deprecated April 2015
|
|
*/
|
|
Blockly.updateToolbox = function(tree) {
|
|
console.warn('Deprecated call to Blockly.updateToolbox, ' +
|
|
'use workspace.updateToolbox instead.');
|
|
Blockly.getMainWorkspace().updateToolbox(tree);
|
|
};
|