2013-10-30 14:46:03 -07:00
|
|
|
/**
|
2014-01-28 03:00:09 -08:00
|
|
|
* @license
|
2013-10-30 14:46:03 -07:00
|
|
|
* Visual Blocks Editor
|
|
|
|
*
|
|
|
|
* Copyright 2011 Google Inc.
|
2014-10-07 13:09:55 -07:00
|
|
|
* https://developers.google.com/blockly/
|
2013-10-30 14:46:03 -07:00
|
|
|
*
|
|
|
|
* 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 Toolbox from whence to create blocks.
|
|
|
|
* @author fraser@google.com (Neil Fraser)
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
goog.provide('Blockly.Toolbox');
|
|
|
|
|
2018-05-09 13:34:21 -07:00
|
|
|
goog.require('Blockly.Events.Ui');
|
2016-09-08 16:54:10 -07:00
|
|
|
goog.require('Blockly.HorizontalFlyout');
|
2016-09-07 18:10:25 -07:00
|
|
|
goog.require('Blockly.Touch');
|
2016-10-04 14:40:10 -07:00
|
|
|
goog.require('Blockly.VerticalFlyout');
|
2015-02-06 15:27:25 -08:00
|
|
|
goog.require('goog.dom');
|
2016-08-19 12:55:45 +02:00
|
|
|
goog.require('goog.dom.TagName');
|
2015-02-06 15:27:25 -08:00
|
|
|
goog.require('goog.events');
|
2013-10-30 14:46:03 -07:00
|
|
|
goog.require('goog.events.BrowserFeature');
|
2014-09-08 14:26:52 -07:00
|
|
|
goog.require('goog.html.SafeHtml');
|
2016-01-26 12:35:50 -08:00
|
|
|
goog.require('goog.html.SafeStyle');
|
2015-01-22 15:58:10 -08:00
|
|
|
goog.require('goog.math.Rect');
|
2013-10-30 14:46:03 -07:00
|
|
|
goog.require('goog.style');
|
|
|
|
goog.require('goog.ui.tree.TreeControl');
|
|
|
|
goog.require('goog.ui.tree.TreeNode');
|
|
|
|
|
|
|
|
|
2014-11-29 15:41:27 -08:00
|
|
|
/**
|
|
|
|
* Class for a Toolbox.
|
2015-04-28 13:51:25 -07:00
|
|
|
* Creates the toolbox's DOM.
|
|
|
|
* @param {!Blockly.Workspace} workspace The workspace in which to create new
|
|
|
|
* blocks.
|
2014-11-29 15:41:27 -08:00
|
|
|
* @constructor
|
|
|
|
*/
|
2015-04-28 13:51:25 -07:00
|
|
|
Blockly.Toolbox = function(workspace) {
|
2014-11-29 15:41:27 -08:00
|
|
|
/**
|
2015-04-28 13:51:25 -07:00
|
|
|
* @type {!Blockly.Workspace}
|
2014-11-29 15:41:27 -08:00
|
|
|
* @private
|
|
|
|
*/
|
2015-04-28 13:51:25 -07:00
|
|
|
this.workspace_ = workspace;
|
2016-01-26 12:35:50 -08:00
|
|
|
|
2016-02-08 17:20:28 -08:00
|
|
|
/**
|
|
|
|
* Whether toolbox categories should be represented by icons instead of text.
|
|
|
|
* @type {boolean}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this.iconic_ = false;
|
|
|
|
|
2016-02-17 16:19:40 -08:00
|
|
|
/**
|
|
|
|
* Is RTL vs LTR.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
this.RTL = workspace.options.RTL;
|
|
|
|
|
2016-01-26 12:35:50 -08:00
|
|
|
/**
|
|
|
|
* Whether the toolbox should be laid out horizontally.
|
|
|
|
* @type {boolean}
|
|
|
|
* @private
|
|
|
|
*/
|
2016-02-11 14:46:51 -08:00
|
|
|
this.horizontalLayout_ = workspace.options.horizontalLayout;
|
2016-02-08 13:56:57 -08:00
|
|
|
|
2016-02-17 16:19:40 -08:00
|
|
|
/**
|
|
|
|
* Position of the toolbox and flyout relative to the workspace.
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
this.toolboxPosition = workspace.options.toolboxPosition;
|
2016-02-12 10:57:33 -08:00
|
|
|
|
2014-11-29 15:41:27 -08:00
|
|
|
};
|
|
|
|
|
2013-10-30 14:46:03 -07:00
|
|
|
/**
|
2016-03-17 15:46:22 -07:00
|
|
|
* Width of the toolbox, which changes only in vertical layout.
|
2018-07-16 08:14:30 -04:00
|
|
|
* This is the sum of the width of the flyout (250) and the category menu (60).
|
2013-10-30 14:46:03 -07:00
|
|
|
* @type {number}
|
|
|
|
*/
|
2018-07-16 08:14:30 -04:00
|
|
|
Blockly.Toolbox.prototype.width = 310;
|
2013-10-30 14:46:03 -07:00
|
|
|
|
2016-01-26 12:35:50 -08:00
|
|
|
/**
|
2016-03-17 15:46:22 -07:00
|
|
|
* Height of the toolbox, which changes only in horizontal layout.
|
2016-01-26 12:35:50 -08:00
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.height = 0;
|
|
|
|
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.prototype.selectedItem_ = null;
|
2015-02-27 17:01:24 -08:00
|
|
|
|
2013-10-30 14:46:03 -07:00
|
|
|
/**
|
|
|
|
* Initializes the toolbox.
|
|
|
|
*/
|
2015-04-28 13:51:25 -07:00
|
|
|
Blockly.Toolbox.prototype.init = function() {
|
|
|
|
var workspace = this.workspace_;
|
2016-07-31 05:36:35 +02:00
|
|
|
var svg = this.workspace_.getParentSvg();
|
2015-04-28 13:51:25 -07:00
|
|
|
|
2016-09-30 16:26:44 -05:00
|
|
|
/**
|
|
|
|
* HTML container for the Toolbox menu.
|
|
|
|
* @type {Element}
|
|
|
|
*/
|
2016-08-19 12:55:45 +02:00
|
|
|
this.HtmlDiv =
|
|
|
|
goog.dom.createDom(goog.dom.TagName.DIV, 'blocklyToolboxDiv');
|
2015-10-12 16:14:03 -07:00
|
|
|
this.HtmlDiv.setAttribute('dir', workspace.RTL ? 'RTL' : 'LTR');
|
2016-07-31 05:36:35 +02:00
|
|
|
svg.parentNode.insertBefore(this.HtmlDiv, svg);
|
2015-04-28 13:51:25 -07:00
|
|
|
|
2016-05-04 14:49:00 -07:00
|
|
|
// Clicking on toolbox closes popups.
|
2016-09-23 13:46:11 -07:00
|
|
|
Blockly.bindEventWithChecks_(this.HtmlDiv, 'mousedown', this,
|
2015-04-28 13:51:25 -07:00
|
|
|
function(e) {
|
2017-11-28 10:28:35 -05:00
|
|
|
// Cancel any gestures in progress.
|
|
|
|
this.workspace_.cancelCurrentGesture();
|
2017-02-02 14:17:43 -05:00
|
|
|
if (Blockly.utils.isRightButton(e) || e.target == this.HtmlDiv) {
|
2015-04-28 13:51:25 -07:00
|
|
|
// Close flyout.
|
|
|
|
Blockly.hideChaff(false);
|
|
|
|
} else {
|
|
|
|
// Just close popups.
|
|
|
|
Blockly.hideChaff(true);
|
|
|
|
}
|
2016-09-21 16:25:44 -07:00
|
|
|
Blockly.Touch.clearTouchIdentifier(); // Don't block future drags.
|
2017-09-18 12:44:48 -07:00
|
|
|
}, /*opt_noCaptureIdentifier*/ false, /*opt_noPreventDefault*/ true);
|
2016-10-06 14:49:15 -07:00
|
|
|
|
|
|
|
this.createFlyout_();
|
|
|
|
this.categoryMenu_ = new Blockly.Toolbox.CategoryMenu(this, this.HtmlDiv);
|
|
|
|
this.populate_(workspace.options.languageTree);
|
|
|
|
this.position();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispose of this toolbox.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.dispose = function() {
|
|
|
|
this.flyout_.dispose();
|
|
|
|
this.categoryMenu_.dispose();
|
|
|
|
this.categoryMenu_ = null;
|
|
|
|
goog.dom.removeNode(this.HtmlDiv);
|
|
|
|
this.workspace_ = null;
|
|
|
|
this.lastCategory_ = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and configure a flyout based on the main workspace's options.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.createFlyout_ = function() {
|
|
|
|
var workspace = this.workspace_;
|
|
|
|
|
|
|
|
var options = {
|
2015-10-21 15:21:51 -07:00
|
|
|
disabledPatternId: workspace.options.disabledPatternId,
|
2015-04-28 13:51:25 -07:00
|
|
|
parentWorkspace: workspace,
|
2016-02-11 14:46:51 -08:00
|
|
|
RTL: workspace.RTL,
|
2016-10-06 17:54:43 -07:00
|
|
|
oneBasedIndex: workspace.options.oneBasedIndex,
|
2016-02-12 10:57:33 -08:00
|
|
|
horizontalLayout: workspace.horizontalLayout,
|
2018-06-01 10:13:37 -04:00
|
|
|
toolboxPosition: workspace.options.toolboxPosition,
|
|
|
|
stackGlowFilterId: workspace.options.stackGlowFilterId
|
2015-04-28 13:51:25 -07:00
|
|
|
};
|
2016-01-26 12:35:50 -08:00
|
|
|
|
2016-09-08 16:54:10 -07:00
|
|
|
if (workspace.horizontalLayout) {
|
2016-10-06 14:49:15 -07:00
|
|
|
this.flyout_ = new Blockly.HorizontalFlyout(options);
|
2016-09-08 16:54:10 -07:00
|
|
|
} else {
|
2016-10-06 14:49:15 -07:00
|
|
|
this.flyout_ = new Blockly.VerticalFlyout(options);
|
2016-09-08 16:54:10 -07:00
|
|
|
}
|
|
|
|
this.flyout_.setParentToolbox(this);
|
2015-04-28 13:51:25 -07:00
|
|
|
|
2018-05-02 11:05:43 -07:00
|
|
|
goog.dom.insertSiblingAfter(
|
|
|
|
this.flyout_.createDom('svg'), this.workspace_.getParentSvg());
|
2015-04-28 13:51:25 -07:00
|
|
|
this.flyout_.init(workspace);
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2015-06-04 12:04:43 -07:00
|
|
|
/**
|
2016-10-06 14:49:15 -07:00
|
|
|
* Fill the toolbox with categories and blocks.
|
|
|
|
* @param {!Node} newTree DOM tree of blocks.
|
|
|
|
* @private
|
2015-06-04 12:04:43 -07:00
|
|
|
*/
|
2016-10-06 14:49:15 -07:00
|
|
|
Blockly.Toolbox.prototype.populate_ = function(newTree) {
|
|
|
|
this.categoryMenu_.populate(newTree);
|
2017-09-20 14:00:42 -04:00
|
|
|
this.showAll_();
|
2018-03-12 16:43:13 -04:00
|
|
|
this.setSelectedItem(this.categoryMenu_.categories_[0], false);
|
2015-06-04 12:04:43 -07:00
|
|
|
};
|
|
|
|
|
2017-08-23 13:23:20 -04:00
|
|
|
/**
|
|
|
|
* Show all blocks for all categories in the flyout
|
2017-09-18 16:50:01 -04:00
|
|
|
* @private
|
2017-08-23 13:23:20 -04:00
|
|
|
*/
|
2017-09-20 14:00:42 -04:00
|
|
|
Blockly.Toolbox.prototype.showAll_ = function() {
|
2017-08-23 13:23:20 -04:00
|
|
|
var allContents = [];
|
2017-09-13 15:25:11 -04:00
|
|
|
for (var i = 0; i < this.categoryMenu_.categories_.length; i++) {
|
2017-08-23 13:23:20 -04:00
|
|
|
var category = this.categoryMenu_.categories_[i];
|
2017-08-23 18:29:28 -04:00
|
|
|
|
|
|
|
// create a label node to go at the top of the category
|
2017-09-13 15:19:06 -04:00
|
|
|
var labelString = '<xml><label text="' + category.name_ + '"' +
|
2018-06-25 13:16:42 -04:00
|
|
|
' id="' + category.id_ + '"' +
|
2017-09-13 15:19:06 -04:00
|
|
|
' category-label="true"' +
|
2018-06-25 13:16:42 -04:00
|
|
|
' showStatusButton="' + category.showStatusButton_ + '"' +
|
2017-09-13 15:19:06 -04:00
|
|
|
' web-class="categoryLabel">' +
|
|
|
|
'</label></xml>';
|
2017-09-07 11:32:13 -04:00
|
|
|
var labelXML = Blockly.Xml.textToDom(labelString);
|
2018-06-25 13:16:42 -04:00
|
|
|
|
2017-09-07 11:32:13 -04:00
|
|
|
allContents.push(labelXML.firstChild);
|
2017-08-23 18:29:28 -04:00
|
|
|
|
2017-08-23 13:23:20 -04:00
|
|
|
allContents = allContents.concat(category.getContents());
|
|
|
|
}
|
|
|
|
this.flyout_.show(allContents);
|
|
|
|
};
|
|
|
|
|
2016-04-13 15:30:11 -07:00
|
|
|
/**
|
|
|
|
* Get the width of the toolbox.
|
2016-05-13 15:30:47 -07:00
|
|
|
* @return {number} The width of the toolbox.
|
2016-04-13 15:30:11 -07:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getWidth = function() {
|
|
|
|
return this.width;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-10-06 14:49:15 -07:00
|
|
|
* Get the height of the toolbox, not including the block menu.
|
|
|
|
* @return {number} The height of the toolbox.
|
2016-04-13 15:30:11 -07:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getHeight = function() {
|
2016-09-08 16:54:10 -07:00
|
|
|
return this.categoryMenu_ ? this.categoryMenu_.getHeight() : 0;
|
2016-04-13 15:30:11 -07:00
|
|
|
};
|
|
|
|
|
2013-10-30 14:46:03 -07:00
|
|
|
/**
|
|
|
|
* Move the toolbox to the edge.
|
|
|
|
*/
|
2015-04-28 17:55:45 -07:00
|
|
|
Blockly.Toolbox.prototype.position = function() {
|
2014-11-29 15:41:27 -08:00
|
|
|
var treeDiv = this.HtmlDiv;
|
2015-04-28 17:55:45 -07:00
|
|
|
if (!treeDiv) {
|
|
|
|
// Not initialized yet.
|
|
|
|
return;
|
|
|
|
}
|
2016-01-07 17:01:01 -08:00
|
|
|
var svg = this.workspace_.getParentSvg();
|
2015-04-28 13:51:25 -07:00
|
|
|
var svgSize = Blockly.svgSize(svg);
|
2016-02-17 11:02:26 -08:00
|
|
|
if (this.horizontalLayout_) {
|
2016-07-31 05:36:35 +02:00
|
|
|
treeDiv.style.left = '0';
|
2016-02-17 11:02:26 -08:00
|
|
|
treeDiv.style.height = 'auto';
|
|
|
|
treeDiv.style.width = svgSize.width + 'px';
|
|
|
|
this.height = treeDiv.offsetHeight;
|
2016-02-17 16:19:40 -08:00
|
|
|
if (this.toolboxPosition == Blockly.TOOLBOX_AT_TOP) { // Top
|
2016-07-31 05:36:35 +02:00
|
|
|
treeDiv.style.top = '0';
|
2016-02-17 11:02:26 -08:00
|
|
|
} else { // Bottom
|
2016-07-31 05:36:35 +02:00
|
|
|
treeDiv.style.bottom = '0';
|
2016-02-17 11:02:26 -08:00
|
|
|
}
|
|
|
|
} else {
|
2016-02-17 16:19:40 -08:00
|
|
|
if (this.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT) { // Right
|
2016-07-31 05:36:35 +02:00
|
|
|
treeDiv.style.right = '0';
|
2016-05-13 15:30:47 -07:00
|
|
|
} else { // Left
|
2016-07-31 05:36:35 +02:00
|
|
|
treeDiv.style.left = '0';
|
2016-01-26 12:35:50 -08:00
|
|
|
}
|
2017-07-11 10:50:08 -04:00
|
|
|
treeDiv.style.height = '100%';
|
2013-10-30 14:46:03 -07:00
|
|
|
}
|
2015-04-28 17:55:45 -07:00
|
|
|
this.flyout_.position();
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unhighlight any previously specified option.
|
|
|
|
*/
|
2014-11-29 15:41:27 -08:00
|
|
|
Blockly.Toolbox.prototype.clearSelection = function() {
|
2016-08-26 18:29:34 -07:00
|
|
|
this.setSelectedItem(null);
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2014-12-02 15:00:10 -08:00
|
|
|
/**
|
2018-05-11 16:35:31 -07:00
|
|
|
* Adds a style on the toolbox. Usually used to change the cursor.
|
|
|
|
* @param {string} style The name of the class to add.
|
Merge google/blockly, May 2017 (#881)
* Move createDom call into the constructor of block drag surface. (#790)
* Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805)
* Don't connect to blocks under the flyout.
* recompile again. (#806)
* Fix german translation
* Option for moving one block from stack.
See thread in support group before merging.
* Fix german translation of 'delete x blocks'
* Adding unit tests for ifelse block.
* Improvements to the generator test framework.
* <field>, <value> reorder due to load/save.
* Expand stack-drag modifier key to include alt and ctrl.
* Use the npm closure library instead of the same library installed at a parallel directory
* Fix undo/redo for FieldCheckbox
Thanks to PR #813 by ademenev
* Localisation updates from https://translatewiki.net.
* PR #818: Adding support for string table lookups in dropdown field labels
Adding support for string table lookups in dropdown field labels specified in JSON.
Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option.
Replaces the direct JavaScript references (not pure JSON, and thus not portable).
Demonstrating this behavior in the logic_boolean dropdown.
* Integrating qqq.json changes into messages.json. (#820)
From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85
* Naming changes in mirror demo
* Adding support for untranslated messages. (#819)
This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms.
Template details: https://translatewiki.net/wiki/Template:Notranslate
* JSON support for message lookup in colour, tooltip, and help URL. (#825)
String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks.
Demonstrated in logic_boolean.
* Fixes as per code review on PR.
* Localisation updates from https://translatewiki.net.
* Reduce number of Closure files in App Engine upload.
* Python false is False. Issue #828.
* Replace 'const' with 'var'.
This unbreaks IE10 and advanced compiled apps such as Blockly Games.
* Fix bug in audioService where attached event callbacks were not being cleared properly.
* Rename workspace-tree to workspace-block.
* Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.).
* FieldNumber & FieldAngle: Default value "0" (#832)
FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests.
* Remove unnecessary check when attaching a new block to a marked connection.
* Remove debug info.
* Refactor and simplify field-segment.component.js.
* Replace single quotes with double. (#836)
Fixes commits in #832.
* Adding extensions for JSON support of dynamic blocks. (#834)
Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators.
Rewrote math_number as an example pure JSON block.
* Add ability to add a class to a scrollbar so that different types of … (#837)
* Add ability to add a class to a scrollbar so that different types of scrollbars can
be distinguished from each other. You used to be able to do this by looking at the parent
element but now all the scrollbars are siblings in the dom.
Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars
are done correctly.
* JSON definitions for colour blocks (#838)
Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions.
Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests.
* Rewrite tree.service.js.
- Remove unnecessary code and functions.
- Add documentation where needed.
- Fix a bug arising when a block on the workspace is attached to an existing link.
* Use setValue in fieldTextInput so that procedure renaming works
* Further cleanup and removal of unnecessary functions. Pull some strings out for i18n.
* Use bindEvent_ instead of bindEventWithChecks_ for longStop
* Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly.
* Unit tests for JSON block definitions (just the start) (#850)
* Beginnings of a JSON block definition unit test set.
* Dispose of unit test workspaces and blocks in finally blocks.
* Clarify JSON error message by echoing arg notation.
* New blocks text_count, text_replace, and text_reverse (#830)
Includes generators for all languages and units tests on those generators.
* Fixing combo boxes getting out-of-sync with NVDA.
Combo boxes need to be special cased like text input. Also, Escape is
a reserved button in NVDA, so I added Enter as a way to "submit and
move up a level" in addition to escape, so these boxes can be edited
while NVDA is on.
* Temporary fix for broken text field validation.
* rebuild
* Add a block to reverse a list (#844)
* Localisation updates from https://translatewiki.net.
* Porting math.js blocks to JSON (#846)
Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips.
Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown.
Now warn on raw string in JSON 'extensions'.
* Fixing JSON support for images in dropdowns. Adding tests. (#851)
Fixes #848.
* Update README.md
Add a link to our forum.
* Correcting math_change color
* Enable custom flyout categories.
* Add some safety
* Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861)
* Localisation updates from https://translatewiki.net.
* .getOptions_() to .getOptions() (#869)
Fixes #867.
* Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870)
Defer tooltip message string check until after load, when all Blockly.Msg should be loaded.
Avoids validation in headless mode, due to lack of document.readyState.
* annotation updates
* annotation updates
* jsdoc corrections (#874)
* Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876.
* Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue.
* Change CSS transforms to work with older browsers (#879)
* Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg
* Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform".
* Don't try to get block position in a headless workspace
* Stop bumping neighbours in headless blockly
* Place context menu correctly on touch
* Clear all active desc ids when the 'Erase Workspace' button is pressed.
* Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus.
* Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case.
* Localisation updates from https://translatewiki.net.
* Use the empty field placeholder for dropdowns that do not have a value selected.
* Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895)
* Adding @namespace annotations for JSDoc. (#900)
* Fix typo causing TypeError (#901)
* Pinning the angular2 dependency, and including licenses. (#893)
* Add skeleton for tests on rendered workspaces
* Fix some lint errors
* Localisation updates from https://translatewiki.net.
* Correct changedState in setWarningText() (#908)
When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_).
* Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907)
Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin().
This adds support for a common use pattern in extensions, and adds
error checking to avoid future incompatibilities.
* Porting Logic blocks to JSON (#913)
Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic.
* Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911)
* Add isEditable to field, and add tests
* Separate tests
* Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916)
Also, correcting quotes in logic.js.
* Correction to logic_ternary type check (#920)
* Porting Loop blocks to JSON (#919)
* Improved documentation on `Blockly.Extensions.buildTooltipForDropdown`
* Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`.
* Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper.
* Workspace isDraggable
* JSONify simple list blocks
* JSONify variable blocks
* Initial text block, with a mixin to generate quote image fields. (#923)
Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes.
* Add no-op stub .neighbors() for headless Connection.
* Adding tests for logic_ternary block in a new jsunit test framework.
* Correcting output of the logic_null block.
* Potential bug fix for issue #661
* extension controls_if => controls_if_mutator.
* Renamed extension function constant, and moved variables into the mixin.
* Dereference string table references when loading variable fields from JSON.
* Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen.
Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions.
* Addressing comments.
* .utils.replaceMessageReferences(..) now gracefully returns non-string arguments.
* Clarification update.
Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_()
* Code correction from previous commit. Moved style to css.js and set ROUNDING=15;
* Fixing Enter so it properly propogates to dropdown selection. (#934)
Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes.
* Localisation updates from https://translatewiki.net.
* Make variable add set/get block in context menu obey block limits
* Localisation updates from https://translatewiki.net.
* Use mutator extension for controls_if block
* Fix #946. Don't check for presence of constants.js
* Fix #945 (annotations) and an eslint issue (constant condition)
* Localisation updates from https://translatewiki.net.
* Fix #950: BlockFactory typo and copypasta
* Add safety checks for mutators and non-mutator extensions
* Handle mutations with both mixins and functions
* Adding warning on duplicate JSON block definition.
* period
* Make some functions private and add tests
* Localisation updates from https://translatewiki.net.
* Update help URL per #937.
Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.)
Added missing semicolon in build.py.
* Typo in comment.
* Make it easier to read the code that creates the variable category in the tolbox
* Adding Blockly.Xml.appendDomToWorkspace() (#962)
This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review.
* Annotation fixes
* Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964)
* Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899)
* Adding new minimap demo
* Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener.
* `unction` to `function` corrects #962 (#970)
* Cross browser friendly fix for #904. This calls blur and focus from … (#972)
* Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us.
* Localisation updates from https://translatewiki.net.
* Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974)
* Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged.
* set background color to lilac if opening the playground from file:
* Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document.
* Localisation updates from https://translatewiki.net.
* Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979)
* Fix #969
* Localisation updates from https://translatewiki.net.
* Fix #986. Looks like the original PR just forgot this block. (#992)
* rebuild develop (#996)
* Added the variable modal and component and implemented basic renaming functionality. (#991)
* Fixing commenting from the last commit. (#1000)
* Localisation updates from https://translatewiki.net.
* RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead.
* 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
* use goog.string.startswith instead of string.startswith (#1065)
* New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001)
Refactor of interpreter demo
* Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html.
* Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs.
* Fix #1069 (#1073)
* Fix cursor and mistaken css from merge
* Comment out broken field angle merge
* Fix broken merge with borders
* Add back original package json (woops)
* Remove render function for field angle, may not be the right way but it was broken...
* Revert merge blocking variable shadow blocks
* Add changes from built lang files
* Add back travis and readme
* Revert broken cleanup additions
* Add notes for scratch-block specific functions
* Revert change to css so blocks stay under the toolbox
* Add back accidentally removed files
* Use getFlyout_ instead of getFlyout everywhere
* Satisfy the linter
* Re-remove deprecated function
* Remove duplicated code in block_svg
* Add back flip_rtl option for images
* Remove more duplicated functions from past merges
* Fix flip_rtl code
* Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
|
|
|
* @package
|
|
|
|
*/
|
2018-05-11 16:35:31 -07:00
|
|
|
Blockly.Toolbox.prototype.addStyle = function(style) {
|
|
|
|
Blockly.utils.addClass(/** @type {!Element} */ (this.HtmlDiv), style);
|
Merge google/blockly, May 2017 (#881)
* Move createDom call into the constructor of block drag surface. (#790)
* Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805)
* Don't connect to blocks under the flyout.
* recompile again. (#806)
* Fix german translation
* Option for moving one block from stack.
See thread in support group before merging.
* Fix german translation of 'delete x blocks'
* Adding unit tests for ifelse block.
* Improvements to the generator test framework.
* <field>, <value> reorder due to load/save.
* Expand stack-drag modifier key to include alt and ctrl.
* Use the npm closure library instead of the same library installed at a parallel directory
* Fix undo/redo for FieldCheckbox
Thanks to PR #813 by ademenev
* Localisation updates from https://translatewiki.net.
* PR #818: Adding support for string table lookups in dropdown field labels
Adding support for string table lookups in dropdown field labels specified in JSON.
Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option.
Replaces the direct JavaScript references (not pure JSON, and thus not portable).
Demonstrating this behavior in the logic_boolean dropdown.
* Integrating qqq.json changes into messages.json. (#820)
From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85
* Naming changes in mirror demo
* Adding support for untranslated messages. (#819)
This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms.
Template details: https://translatewiki.net/wiki/Template:Notranslate
* JSON support for message lookup in colour, tooltip, and help URL. (#825)
String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks.
Demonstrated in logic_boolean.
* Fixes as per code review on PR.
* Localisation updates from https://translatewiki.net.
* Reduce number of Closure files in App Engine upload.
* Python false is False. Issue #828.
* Replace 'const' with 'var'.
This unbreaks IE10 and advanced compiled apps such as Blockly Games.
* Fix bug in audioService where attached event callbacks were not being cleared properly.
* Rename workspace-tree to workspace-block.
* Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.).
* FieldNumber & FieldAngle: Default value "0" (#832)
FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests.
* Remove unnecessary check when attaching a new block to a marked connection.
* Remove debug info.
* Refactor and simplify field-segment.component.js.
* Replace single quotes with double. (#836)
Fixes commits in #832.
* Adding extensions for JSON support of dynamic blocks. (#834)
Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators.
Rewrote math_number as an example pure JSON block.
* Add ability to add a class to a scrollbar so that different types of … (#837)
* Add ability to add a class to a scrollbar so that different types of scrollbars can
be distinguished from each other. You used to be able to do this by looking at the parent
element but now all the scrollbars are siblings in the dom.
Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars
are done correctly.
* JSON definitions for colour blocks (#838)
Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions.
Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests.
* Rewrite tree.service.js.
- Remove unnecessary code and functions.
- Add documentation where needed.
- Fix a bug arising when a block on the workspace is attached to an existing link.
* Use setValue in fieldTextInput so that procedure renaming works
* Further cleanup and removal of unnecessary functions. Pull some strings out for i18n.
* Use bindEvent_ instead of bindEventWithChecks_ for longStop
* Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly.
* Unit tests for JSON block definitions (just the start) (#850)
* Beginnings of a JSON block definition unit test set.
* Dispose of unit test workspaces and blocks in finally blocks.
* Clarify JSON error message by echoing arg notation.
* New blocks text_count, text_replace, and text_reverse (#830)
Includes generators for all languages and units tests on those generators.
* Fixing combo boxes getting out-of-sync with NVDA.
Combo boxes need to be special cased like text input. Also, Escape is
a reserved button in NVDA, so I added Enter as a way to "submit and
move up a level" in addition to escape, so these boxes can be edited
while NVDA is on.
* Temporary fix for broken text field validation.
* rebuild
* Add a block to reverse a list (#844)
* Localisation updates from https://translatewiki.net.
* Porting math.js blocks to JSON (#846)
Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips.
Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown.
Now warn on raw string in JSON 'extensions'.
* Fixing JSON support for images in dropdowns. Adding tests. (#851)
Fixes #848.
* Update README.md
Add a link to our forum.
* Correcting math_change color
* Enable custom flyout categories.
* Add some safety
* Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861)
* Localisation updates from https://translatewiki.net.
* .getOptions_() to .getOptions() (#869)
Fixes #867.
* Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870)
Defer tooltip message string check until after load, when all Blockly.Msg should be loaded.
Avoids validation in headless mode, due to lack of document.readyState.
* annotation updates
* annotation updates
* jsdoc corrections (#874)
* Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876.
* Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue.
* Change CSS transforms to work with older browsers (#879)
* Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg
* Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform".
* Don't try to get block position in a headless workspace
* Stop bumping neighbours in headless blockly
* Place context menu correctly on touch
* Clear all active desc ids when the 'Erase Workspace' button is pressed.
* Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus.
* Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case.
* Localisation updates from https://translatewiki.net.
* Use the empty field placeholder for dropdowns that do not have a value selected.
* Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895)
* Adding @namespace annotations for JSDoc. (#900)
* Fix typo causing TypeError (#901)
* Pinning the angular2 dependency, and including licenses. (#893)
* Add skeleton for tests on rendered workspaces
* Fix some lint errors
* Localisation updates from https://translatewiki.net.
* Correct changedState in setWarningText() (#908)
When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_).
* Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907)
Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin().
This adds support for a common use pattern in extensions, and adds
error checking to avoid future incompatibilities.
* Porting Logic blocks to JSON (#913)
Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic.
* Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911)
* Add isEditable to field, and add tests
* Separate tests
* Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916)
Also, correcting quotes in logic.js.
* Correction to logic_ternary type check (#920)
* Porting Loop blocks to JSON (#919)
* Improved documentation on `Blockly.Extensions.buildTooltipForDropdown`
* Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`.
* Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper.
* Workspace isDraggable
* JSONify simple list blocks
* JSONify variable blocks
* Initial text block, with a mixin to generate quote image fields. (#923)
Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes.
* Add no-op stub .neighbors() for headless Connection.
* Adding tests for logic_ternary block in a new jsunit test framework.
* Correcting output of the logic_null block.
* Potential bug fix for issue #661
* extension controls_if => controls_if_mutator.
* Renamed extension function constant, and moved variables into the mixin.
* Dereference string table references when loading variable fields from JSON.
* Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen.
Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions.
* Addressing comments.
* .utils.replaceMessageReferences(..) now gracefully returns non-string arguments.
* Clarification update.
Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_()
* Code correction from previous commit. Moved style to css.js and set ROUNDING=15;
* Fixing Enter so it properly propogates to dropdown selection. (#934)
Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes.
* Localisation updates from https://translatewiki.net.
* Make variable add set/get block in context menu obey block limits
* Localisation updates from https://translatewiki.net.
* Use mutator extension for controls_if block
* Fix #946. Don't check for presence of constants.js
* Fix #945 (annotations) and an eslint issue (constant condition)
* Localisation updates from https://translatewiki.net.
* Fix #950: BlockFactory typo and copypasta
* Add safety checks for mutators and non-mutator extensions
* Handle mutations with both mixins and functions
* Adding warning on duplicate JSON block definition.
* period
* Make some functions private and add tests
* Localisation updates from https://translatewiki.net.
* Update help URL per #937.
Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.)
Added missing semicolon in build.py.
* Typo in comment.
* Make it easier to read the code that creates the variable category in the tolbox
* Adding Blockly.Xml.appendDomToWorkspace() (#962)
This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review.
* Annotation fixes
* Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964)
* Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899)
* Adding new minimap demo
* Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener.
* `unction` to `function` corrects #962 (#970)
* Cross browser friendly fix for #904. This calls blur and focus from … (#972)
* Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us.
* Localisation updates from https://translatewiki.net.
* Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974)
* Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged.
* set background color to lilac if opening the playground from file:
* Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document.
* Localisation updates from https://translatewiki.net.
* Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979)
* Fix #969
* Localisation updates from https://translatewiki.net.
* Fix #986. Looks like the original PR just forgot this block. (#992)
* rebuild develop (#996)
* Added the variable modal and component and implemented basic renaming functionality. (#991)
* Fixing commenting from the last commit. (#1000)
* Localisation updates from https://translatewiki.net.
* RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead.
* 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
* use goog.string.startswith instead of string.startswith (#1065)
* New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001)
Refactor of interpreter demo
* Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html.
* Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs.
* Fix #1069 (#1073)
* Fix cursor and mistaken css from merge
* Comment out broken field angle merge
* Fix broken merge with borders
* Add back original package json (woops)
* Remove render function for field angle, may not be the right way but it was broken...
* Revert merge blocking variable shadow blocks
* Add changes from built lang files
* Add back travis and readme
* Revert broken cleanup additions
* Add notes for scratch-block specific functions
* Revert change to css so blocks stay under the toolbox
* Add back accidentally removed files
* Use getFlyout_ instead of getFlyout everywhere
* Satisfy the linter
* Re-remove deprecated function
* Remove duplicated code in block_svg
* Add back flip_rtl option for images
* Remove more duplicated functions from past merges
* Fix flip_rtl code
* Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2018-05-11 16:35:31 -07:00
|
|
|
* Removes a style from the toolbox. Usually used to change the cursor.
|
|
|
|
* @param {string} style The name of the class to remove.
|
Merge google/blockly, May 2017 (#881)
* Move createDom call into the constructor of block drag surface. (#790)
* Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805)
* Don't connect to blocks under the flyout.
* recompile again. (#806)
* Fix german translation
* Option for moving one block from stack.
See thread in support group before merging.
* Fix german translation of 'delete x blocks'
* Adding unit tests for ifelse block.
* Improvements to the generator test framework.
* <field>, <value> reorder due to load/save.
* Expand stack-drag modifier key to include alt and ctrl.
* Use the npm closure library instead of the same library installed at a parallel directory
* Fix undo/redo for FieldCheckbox
Thanks to PR #813 by ademenev
* Localisation updates from https://translatewiki.net.
* PR #818: Adding support for string table lookups in dropdown field labels
Adding support for string table lookups in dropdown field labels specified in JSON.
Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option.
Replaces the direct JavaScript references (not pure JSON, and thus not portable).
Demonstrating this behavior in the logic_boolean dropdown.
* Integrating qqq.json changes into messages.json. (#820)
From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85
* Naming changes in mirror demo
* Adding support for untranslated messages. (#819)
This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms.
Template details: https://translatewiki.net/wiki/Template:Notranslate
* JSON support for message lookup in colour, tooltip, and help URL. (#825)
String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks.
Demonstrated in logic_boolean.
* Fixes as per code review on PR.
* Localisation updates from https://translatewiki.net.
* Reduce number of Closure files in App Engine upload.
* Python false is False. Issue #828.
* Replace 'const' with 'var'.
This unbreaks IE10 and advanced compiled apps such as Blockly Games.
* Fix bug in audioService where attached event callbacks were not being cleared properly.
* Rename workspace-tree to workspace-block.
* Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.).
* FieldNumber & FieldAngle: Default value "0" (#832)
FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests.
* Remove unnecessary check when attaching a new block to a marked connection.
* Remove debug info.
* Refactor and simplify field-segment.component.js.
* Replace single quotes with double. (#836)
Fixes commits in #832.
* Adding extensions for JSON support of dynamic blocks. (#834)
Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators.
Rewrote math_number as an example pure JSON block.
* Add ability to add a class to a scrollbar so that different types of … (#837)
* Add ability to add a class to a scrollbar so that different types of scrollbars can
be distinguished from each other. You used to be able to do this by looking at the parent
element but now all the scrollbars are siblings in the dom.
Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars
are done correctly.
* JSON definitions for colour blocks (#838)
Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions.
Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests.
* Rewrite tree.service.js.
- Remove unnecessary code and functions.
- Add documentation where needed.
- Fix a bug arising when a block on the workspace is attached to an existing link.
* Use setValue in fieldTextInput so that procedure renaming works
* Further cleanup and removal of unnecessary functions. Pull some strings out for i18n.
* Use bindEvent_ instead of bindEventWithChecks_ for longStop
* Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly.
* Unit tests for JSON block definitions (just the start) (#850)
* Beginnings of a JSON block definition unit test set.
* Dispose of unit test workspaces and blocks in finally blocks.
* Clarify JSON error message by echoing arg notation.
* New blocks text_count, text_replace, and text_reverse (#830)
Includes generators for all languages and units tests on those generators.
* Fixing combo boxes getting out-of-sync with NVDA.
Combo boxes need to be special cased like text input. Also, Escape is
a reserved button in NVDA, so I added Enter as a way to "submit and
move up a level" in addition to escape, so these boxes can be edited
while NVDA is on.
* Temporary fix for broken text field validation.
* rebuild
* Add a block to reverse a list (#844)
* Localisation updates from https://translatewiki.net.
* Porting math.js blocks to JSON (#846)
Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips.
Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown.
Now warn on raw string in JSON 'extensions'.
* Fixing JSON support for images in dropdowns. Adding tests. (#851)
Fixes #848.
* Update README.md
Add a link to our forum.
* Correcting math_change color
* Enable custom flyout categories.
* Add some safety
* Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861)
* Localisation updates from https://translatewiki.net.
* .getOptions_() to .getOptions() (#869)
Fixes #867.
* Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870)
Defer tooltip message string check until after load, when all Blockly.Msg should be loaded.
Avoids validation in headless mode, due to lack of document.readyState.
* annotation updates
* annotation updates
* jsdoc corrections (#874)
* Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876.
* Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue.
* Change CSS transforms to work with older browsers (#879)
* Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg
* Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform".
* Don't try to get block position in a headless workspace
* Stop bumping neighbours in headless blockly
* Place context menu correctly on touch
* Clear all active desc ids when the 'Erase Workspace' button is pressed.
* Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus.
* Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case.
* Localisation updates from https://translatewiki.net.
* Use the empty field placeholder for dropdowns that do not have a value selected.
* Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895)
* Adding @namespace annotations for JSDoc. (#900)
* Fix typo causing TypeError (#901)
* Pinning the angular2 dependency, and including licenses. (#893)
* Add skeleton for tests on rendered workspaces
* Fix some lint errors
* Localisation updates from https://translatewiki.net.
* Correct changedState in setWarningText() (#908)
When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_).
* Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907)
Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin().
This adds support for a common use pattern in extensions, and adds
error checking to avoid future incompatibilities.
* Porting Logic blocks to JSON (#913)
Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic.
* Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911)
* Add isEditable to field, and add tests
* Separate tests
* Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916)
Also, correcting quotes in logic.js.
* Correction to logic_ternary type check (#920)
* Porting Loop blocks to JSON (#919)
* Improved documentation on `Blockly.Extensions.buildTooltipForDropdown`
* Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`.
* Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper.
* Workspace isDraggable
* JSONify simple list blocks
* JSONify variable blocks
* Initial text block, with a mixin to generate quote image fields. (#923)
Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes.
* Add no-op stub .neighbors() for headless Connection.
* Adding tests for logic_ternary block in a new jsunit test framework.
* Correcting output of the logic_null block.
* Potential bug fix for issue #661
* extension controls_if => controls_if_mutator.
* Renamed extension function constant, and moved variables into the mixin.
* Dereference string table references when loading variable fields from JSON.
* Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen.
Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions.
* Addressing comments.
* .utils.replaceMessageReferences(..) now gracefully returns non-string arguments.
* Clarification update.
Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_()
* Code correction from previous commit. Moved style to css.js and set ROUNDING=15;
* Fixing Enter so it properly propogates to dropdown selection. (#934)
Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes.
* Localisation updates from https://translatewiki.net.
* Make variable add set/get block in context menu obey block limits
* Localisation updates from https://translatewiki.net.
* Use mutator extension for controls_if block
* Fix #946. Don't check for presence of constants.js
* Fix #945 (annotations) and an eslint issue (constant condition)
* Localisation updates from https://translatewiki.net.
* Fix #950: BlockFactory typo and copypasta
* Add safety checks for mutators and non-mutator extensions
* Handle mutations with both mixins and functions
* Adding warning on duplicate JSON block definition.
* period
* Make some functions private and add tests
* Localisation updates from https://translatewiki.net.
* Update help URL per #937.
Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.)
Added missing semicolon in build.py.
* Typo in comment.
* Make it easier to read the code that creates the variable category in the tolbox
* Adding Blockly.Xml.appendDomToWorkspace() (#962)
This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review.
* Annotation fixes
* Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964)
* Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899)
* Adding new minimap demo
* Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener.
* `unction` to `function` corrects #962 (#970)
* Cross browser friendly fix for #904. This calls blur and focus from … (#972)
* Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us.
* Localisation updates from https://translatewiki.net.
* Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974)
* Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged.
* set background color to lilac if opening the playground from file:
* Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document.
* Localisation updates from https://translatewiki.net.
* Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979)
* Fix #969
* Localisation updates from https://translatewiki.net.
* Fix #986. Looks like the original PR just forgot this block. (#992)
* rebuild develop (#996)
* Added the variable modal and component and implemented basic renaming functionality. (#991)
* Fixing commenting from the last commit. (#1000)
* Localisation updates from https://translatewiki.net.
* RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead.
* 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
* use goog.string.startswith instead of string.startswith (#1065)
* New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001)
Refactor of interpreter demo
* Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html.
* Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs.
* Fix #1069 (#1073)
* Fix cursor and mistaken css from merge
* Comment out broken field angle merge
* Fix broken merge with borders
* Add back original package json (woops)
* Remove render function for field angle, may not be the right way but it was broken...
* Revert merge blocking variable shadow blocks
* Add changes from built lang files
* Add back travis and readme
* Revert broken cleanup additions
* Add notes for scratch-block specific functions
* Revert change to css so blocks stay under the toolbox
* Add back accidentally removed files
* Use getFlyout_ instead of getFlyout everywhere
* Satisfy the linter
* Re-remove deprecated function
* Remove duplicated code in block_svg
* Add back flip_rtl option for images
* Remove more duplicated functions from past merges
* Fix flip_rtl code
* Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
|
|
|
* @package
|
|
|
|
*/
|
2018-05-11 16:35:31 -07:00
|
|
|
Blockly.Toolbox.prototype.removeStyle = function(style) {
|
|
|
|
Blockly.utils.removeClass(/** @type {!Element} */ (this.HtmlDiv), style);
|
Merge google/blockly, May 2017 (#881)
* Move createDom call into the constructor of block drag surface. (#790)
* Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805)
* Don't connect to blocks under the flyout.
* recompile again. (#806)
* Fix german translation
* Option for moving one block from stack.
See thread in support group before merging.
* Fix german translation of 'delete x blocks'
* Adding unit tests for ifelse block.
* Improvements to the generator test framework.
* <field>, <value> reorder due to load/save.
* Expand stack-drag modifier key to include alt and ctrl.
* Use the npm closure library instead of the same library installed at a parallel directory
* Fix undo/redo for FieldCheckbox
Thanks to PR #813 by ademenev
* Localisation updates from https://translatewiki.net.
* PR #818: Adding support for string table lookups in dropdown field labels
Adding support for string table lookups in dropdown field labels specified in JSON.
Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option.
Replaces the direct JavaScript references (not pure JSON, and thus not portable).
Demonstrating this behavior in the logic_boolean dropdown.
* Integrating qqq.json changes into messages.json. (#820)
From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85
* Naming changes in mirror demo
* Adding support for untranslated messages. (#819)
This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms.
Template details: https://translatewiki.net/wiki/Template:Notranslate
* JSON support for message lookup in colour, tooltip, and help URL. (#825)
String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks.
Demonstrated in logic_boolean.
* Fixes as per code review on PR.
* Localisation updates from https://translatewiki.net.
* Reduce number of Closure files in App Engine upload.
* Python false is False. Issue #828.
* Replace 'const' with 'var'.
This unbreaks IE10 and advanced compiled apps such as Blockly Games.
* Fix bug in audioService where attached event callbacks were not being cleared properly.
* Rename workspace-tree to workspace-block.
* Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.).
* FieldNumber & FieldAngle: Default value "0" (#832)
FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests.
* Remove unnecessary check when attaching a new block to a marked connection.
* Remove debug info.
* Refactor and simplify field-segment.component.js.
* Replace single quotes with double. (#836)
Fixes commits in #832.
* Adding extensions for JSON support of dynamic blocks. (#834)
Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators.
Rewrote math_number as an example pure JSON block.
* Add ability to add a class to a scrollbar so that different types of … (#837)
* Add ability to add a class to a scrollbar so that different types of scrollbars can
be distinguished from each other. You used to be able to do this by looking at the parent
element but now all the scrollbars are siblings in the dom.
Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars
are done correctly.
* JSON definitions for colour blocks (#838)
Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions.
Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests.
* Rewrite tree.service.js.
- Remove unnecessary code and functions.
- Add documentation where needed.
- Fix a bug arising when a block on the workspace is attached to an existing link.
* Use setValue in fieldTextInput so that procedure renaming works
* Further cleanup and removal of unnecessary functions. Pull some strings out for i18n.
* Use bindEvent_ instead of bindEventWithChecks_ for longStop
* Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly.
* Unit tests for JSON block definitions (just the start) (#850)
* Beginnings of a JSON block definition unit test set.
* Dispose of unit test workspaces and blocks in finally blocks.
* Clarify JSON error message by echoing arg notation.
* New blocks text_count, text_replace, and text_reverse (#830)
Includes generators for all languages and units tests on those generators.
* Fixing combo boxes getting out-of-sync with NVDA.
Combo boxes need to be special cased like text input. Also, Escape is
a reserved button in NVDA, so I added Enter as a way to "submit and
move up a level" in addition to escape, so these boxes can be edited
while NVDA is on.
* Temporary fix for broken text field validation.
* rebuild
* Add a block to reverse a list (#844)
* Localisation updates from https://translatewiki.net.
* Porting math.js blocks to JSON (#846)
Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips.
Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown.
Now warn on raw string in JSON 'extensions'.
* Fixing JSON support for images in dropdowns. Adding tests. (#851)
Fixes #848.
* Update README.md
Add a link to our forum.
* Correcting math_change color
* Enable custom flyout categories.
* Add some safety
* Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861)
* Localisation updates from https://translatewiki.net.
* .getOptions_() to .getOptions() (#869)
Fixes #867.
* Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870)
Defer tooltip message string check until after load, when all Blockly.Msg should be loaded.
Avoids validation in headless mode, due to lack of document.readyState.
* annotation updates
* annotation updates
* jsdoc corrections (#874)
* Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876.
* Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue.
* Change CSS transforms to work with older browsers (#879)
* Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg
* Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform".
* Don't try to get block position in a headless workspace
* Stop bumping neighbours in headless blockly
* Place context menu correctly on touch
* Clear all active desc ids when the 'Erase Workspace' button is pressed.
* Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus.
* Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case.
* Localisation updates from https://translatewiki.net.
* Use the empty field placeholder for dropdowns that do not have a value selected.
* Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895)
* Adding @namespace annotations for JSDoc. (#900)
* Fix typo causing TypeError (#901)
* Pinning the angular2 dependency, and including licenses. (#893)
* Add skeleton for tests on rendered workspaces
* Fix some lint errors
* Localisation updates from https://translatewiki.net.
* Correct changedState in setWarningText() (#908)
When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_).
* Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907)
Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin().
This adds support for a common use pattern in extensions, and adds
error checking to avoid future incompatibilities.
* Porting Logic blocks to JSON (#913)
Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic.
* Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911)
* Add isEditable to field, and add tests
* Separate tests
* Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916)
Also, correcting quotes in logic.js.
* Correction to logic_ternary type check (#920)
* Porting Loop blocks to JSON (#919)
* Improved documentation on `Blockly.Extensions.buildTooltipForDropdown`
* Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`.
* Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper.
* Workspace isDraggable
* JSONify simple list blocks
* JSONify variable blocks
* Initial text block, with a mixin to generate quote image fields. (#923)
Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes.
* Add no-op stub .neighbors() for headless Connection.
* Adding tests for logic_ternary block in a new jsunit test framework.
* Correcting output of the logic_null block.
* Potential bug fix for issue #661
* extension controls_if => controls_if_mutator.
* Renamed extension function constant, and moved variables into the mixin.
* Dereference string table references when loading variable fields from JSON.
* Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen.
Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions.
* Addressing comments.
* .utils.replaceMessageReferences(..) now gracefully returns non-string arguments.
* Clarification update.
Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_()
* Code correction from previous commit. Moved style to css.js and set ROUNDING=15;
* Fixing Enter so it properly propogates to dropdown selection. (#934)
Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes.
* Localisation updates from https://translatewiki.net.
* Make variable add set/get block in context menu obey block limits
* Localisation updates from https://translatewiki.net.
* Use mutator extension for controls_if block
* Fix #946. Don't check for presence of constants.js
* Fix #945 (annotations) and an eslint issue (constant condition)
* Localisation updates from https://translatewiki.net.
* Fix #950: BlockFactory typo and copypasta
* Add safety checks for mutators and non-mutator extensions
* Handle mutations with both mixins and functions
* Adding warning on duplicate JSON block definition.
* period
* Make some functions private and add tests
* Localisation updates from https://translatewiki.net.
* Update help URL per #937.
Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.)
Added missing semicolon in build.py.
* Typo in comment.
* Make it easier to read the code that creates the variable category in the tolbox
* Adding Blockly.Xml.appendDomToWorkspace() (#962)
This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review.
* Annotation fixes
* Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964)
* Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899)
* Adding new minimap demo
* Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener.
* `unction` to `function` corrects #962 (#970)
* Cross browser friendly fix for #904. This calls blur and focus from … (#972)
* Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us.
* Localisation updates from https://translatewiki.net.
* Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974)
* Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged.
* set background color to lilac if opening the playground from file:
* Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document.
* Localisation updates from https://translatewiki.net.
* Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979)
* Fix #969
* Localisation updates from https://translatewiki.net.
* Fix #986. Looks like the original PR just forgot this block. (#992)
* rebuild develop (#996)
* Added the variable modal and component and implemented basic renaming functionality. (#991)
* Fixing commenting from the last commit. (#1000)
* Localisation updates from https://translatewiki.net.
* RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead.
* 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
* use goog.string.startswith instead of string.startswith (#1065)
* New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001)
Refactor of interpreter demo
* Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html.
* Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs.
* Fix #1069 (#1073)
* Fix cursor and mistaken css from merge
* Comment out broken field angle merge
* Fix broken merge with borders
* Add back original package json (woops)
* Remove render function for field angle, may not be the right way but it was broken...
* Revert merge blocking variable shadow blocks
* Add changes from built lang files
* Add back travis and readme
* Revert broken cleanup additions
* Add notes for scratch-block specific functions
* Revert change to css so blocks stay under the toolbox
* Add back accidentally removed files
* Use getFlyout_ instead of getFlyout everywhere
* Satisfy the linter
* Re-remove deprecated function
* Remove duplicated code in block_svg
* Add back flip_rtl option for images
* Remove more duplicated functions from past merges
* Fix flip_rtl code
* Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the deletion rectangle for this toolbox.
|
2014-12-02 15:00:10 -08:00
|
|
|
* @return {goog.math.Rect} Rectangle in which to delete.
|
|
|
|
*/
|
2016-02-03 15:28:29 -08:00
|
|
|
Blockly.Toolbox.prototype.getClientRect = function() {
|
Merge google/develop June 22 (#441)
* Localisation updates from https://translatewiki.net.
* test page that creates random blocks and randomly drags them around the page
* Localisation updates from https://translatewiki.net.
* add missing return in fake drag
* get rid of drag_tests file:
* Generated JS helper functions should be camelCase.
Complying with Google style guide.
* Localisation updates from https://translatewiki.net.
* Fix extra category error. Clean up code, rename variables, reduce line lengths, fix lint issues.
* Remove claim that good.string.quote should be used.
* Change the blockly workspace resizing strategy. (#386)
* Add a new method to be called when the contents of the workspace change and
the scrollbars need to be adjusted but the the chrome (trash, toolbox, etc)
are expected to stay in the same place.
Change a bunch of calls to svgResize to either be removed or call the new
method instead. This is a nice performance win since the offsetHeight/Width
call in svgResize can be expensive, especially when called as often as we do -
there was some layout thrashing.
This also paves the way for moving calls to recordDeleteAreas
(which is also expensive) to a more cacheable spot than on every
mouse down/touch event.
of things (namely the scrollbars)
* Fix size of graph demo when it first loads by calling svgResize.
The graph starts with fixed width and was relying on a resize event
to fire (which I believe was removed in commit
217c681b86b0f2df76c479c9efae62e6e).
* Fix the resizing of the code demo. The demo's tab min-width used to
match the toolbox's width was only being set on a resize event, but
commit 217c681b86b0f2df76c479c9efae62e6e changed how that worked.
* Fix up some comments.
* Use specific workspaces rather than Blockly.getMainWorkspace().
* Make workspace required for resizeSvgContents and update
some calls to send real workspaces rather than ones that are
null.
Remove the private tag on terminateDrag_ because it is only
actually called from outside the BlockSvg object.
* Remove a rogue period.
* Recategorize BlockSvg.terminateDrag_ to @package instead of @private so that
other developers don't use it, but it still can be used by other Blockly classes.
* Add a TODO to fix issue #307.
* Add @package to workspace resizeContents.
* Routine recompile
* Fix unit tests.
* Fix inheritance on rendered connection.
Closure compiler on maximum compression breaks badly due to lack of
@extends attribute.
* Add toolbox location and toolbox mode options to playground.
* Increase commonality between playgrounds.
* Properly deal with shadow statement blocks in stacks.
* Localisation updates from https://translatewiki.net.
* Use a comment block for function comments in generated JS, Python and Dart.
* Fix typo in flyout.js (#403)
* Fix typo in flyout.js (#402)
* Line wrap comments in generated code.
* Remove reference to undefined variable (#413)
REASON_MUST_DISCONNECT was removed by a refactor in 2a1ffa1.
* Fix airstrike by grabbing the correct toolbox element. (#411)
Probably broken in 266e2ffa9a017d21d7ca2f151730d6ecfcecf173.
* Localisation updates from https://translatewiki.net.
* Fix issue #406 by calling resize from the keypress handler on text inputs. (#408)
* Remove shadow blocks from Accessible Blockly demo. Update README.
* Generate for loops on one line.
* Introduce a common translation pipe; remove local stringMap attributes. Fix variable name error in paste functions. Minor linting.
* Fix precedence on isIndex blocks.
* Add indexing setting for JavaScript Generation (#419)
Adding setting to allow for switching between zero and one based indexing for Blockly Blocks such that the generated code will use this flag to determine whether one based or zero based indexing should be used. One based indexing is enabled by default.
* Remove unused functions and dependencies.
* Remove the unnecessary construction of new services.
* Fix sort block in JS to satisfy tests.
* Trigger a contents resize in block's moveBy. (#422)
This fixes #420 but and it also fixes some other similar problems
with copy/paste and other users of moveBy.
* Consolidate the usages of the 'blockly-disabled' label.
* Fix error when undoing a shadow block replacement. Issue #415.
* Unify setActiveDesc() and updateSelectedNode() in the TreeService. Move function calls made directly within the template to the correct hooks.
* Standardize naming of components.
* Prevent collisions between user functions and helper functions.
* Localisation updates from https://translatewiki.net.
* Fix #425. Attash the resize handler to the workspace so it can be removed (#429)
when workspace.dispose() is called.
* Change the TreeService to a singleton.
* Remove unneeded generated parens around function calls in indexOf blocks.
* Fix #423 by calling workspace's resize when the flyout reflows. (#430)
* Updating URLs to reflect new docs. (#418)
* Updating URLs to reflect new docs. Removing -blockly in URLs.
* Rebuilt.
* Routine recompile
* Prevent selected block from ending up underneath a bumped block.
* Fix undo on fields with validators with side effects.
* Don't fire change event on fields that haven't been named yet.
* Localisation updates from https://translatewiki.net.
* Fix tree focus issues.
* Fix remaining focus issues on block deletion.
* cache delete areas instead of recalculating them onMouseDown
* Cache screen CTM for performance improvement.
* Call svgResizeContents from block_svg's dipose so that deleting blocks (#434)
from the context menu (or anywhere really) causes the workspace to
recalculate its size.
Remove the call to svgResizeContents from onMouseUp's logic for
determining whether the block is being dropped in the trash
since it calls dispose.
One side effect of this is that when you delete multiple blocks
resize gets called for each of them and the scrollbars move during
the operation. This is most obviously seen by doing an airstrike
in the playground and then deleting all the blocks at once.
* Allow terminal blocks to replace other terminal blocks (#433)
* Allow terminal blocks to replace other terminal blocks
* Updated test to allow replacing terminal blocks
* Refactor how activeDescendant is set. Introduce helper functions to ensure that calls like pasteAbove() preserve the focus.
* Localisation updates from https://translatewiki.net.
* Remove unnecessary logging.
* Reduce unneeded parentheses in JS and Python.
* Start using field_number.
* Make it easy to disable unconnected blocks.
* Routine recompile.
* Check if matrix is null in mouseToSvg
* Remove js/ localizations pre-merge
* Fix change to block_render_svg
* Fix error in xml.js
* Playground merge
* Add simple toolboxes to playgrounds
* Fix flyout reference in events listener
* Move tokenizeIntepolation into Blockly.utils namespace.
* Use simpler message interpolation in Code demo.
* Create console stub for IE 9.
* Don't output blockId if not set (e.g., toolbox category event). (#443)
* Fix block in multi-playground
* Increase commonality between playgrounds.
# Conflicts:
# tests/multi_playground.html
# tests/playground.html
* Remove "show flyouts" button
* Recompile for merge June 22
2016-06-22 17:50:16 -04:00
|
|
|
if (!this.HtmlDiv) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-09-21 17:34:39 -04:00
|
|
|
// If not an auto closing flyout, always use the (larger) flyout client rect
|
|
|
|
if (!this.flyout_.autoClose) {
|
|
|
|
return this.flyout_.getClientRect();
|
|
|
|
}
|
|
|
|
|
2014-12-02 15:00:10 -08:00
|
|
|
// BIG_NUM is offscreen padding so that blocks dragged beyond the toolbox
|
|
|
|
// area are still deleted. Must be smaller than Infinity, but larger than
|
|
|
|
// the largest screen size.
|
|
|
|
var BIG_NUM = 10000000;
|
2016-02-19 16:23:32 -08:00
|
|
|
var toolboxRect = this.HtmlDiv.getBoundingClientRect();
|
|
|
|
|
|
|
|
var x = toolboxRect.left;
|
|
|
|
var y = toolboxRect.top;
|
2017-09-21 17:34:39 -04:00
|
|
|
var width = toolboxRect.width;
|
|
|
|
var height = toolboxRect.height;
|
2016-02-17 16:19:40 -08:00
|
|
|
|
|
|
|
// Assumes that the toolbox is on the SVG edge. If this changes
|
|
|
|
// (e.g. toolboxes in mutators) then this code will need to be more complex.
|
|
|
|
if (this.toolboxPosition == Blockly.TOOLBOX_AT_LEFT) {
|
2016-03-17 15:46:22 -07:00
|
|
|
return new goog.math.Rect(-BIG_NUM, -BIG_NUM, BIG_NUM + x + width,
|
|
|
|
2 * BIG_NUM);
|
2016-02-17 16:19:40 -08:00
|
|
|
} else if (this.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT) {
|
2017-07-11 10:50:08 -04:00
|
|
|
return new goog.math.Rect(toolboxRect.right - width, -BIG_NUM, BIG_NUM + width, 2 * BIG_NUM);
|
2016-02-17 16:19:40 -08:00
|
|
|
} else if (this.toolboxPosition == Blockly.TOOLBOX_AT_TOP) {
|
2016-03-30 12:59:29 -07:00
|
|
|
return new goog.math.Rect(-BIG_NUM, -BIG_NUM, 2 * BIG_NUM,
|
|
|
|
BIG_NUM + y + height);
|
2016-05-13 15:30:47 -07:00
|
|
|
} else { // Bottom
|
2017-09-21 17:33:47 -04:00
|
|
|
return new goog.math.Rect(0, y, 2 * BIG_NUM, BIG_NUM);
|
2014-12-02 15:00:10 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-01 15:51:59 -07:00
|
|
|
/**
|
|
|
|
* Update the flyout's contents without closing it. Should be used in response
|
|
|
|
* to a change in one of the dynamic categories, such as variables or
|
|
|
|
* procedures.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.refreshSelection = function() {
|
2017-09-20 14:00:42 -04:00
|
|
|
this.showAll_();
|
2016-07-01 15:51:59 -07:00
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* @return {Blockly.Toolbox.Category} the currently selected category.
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.prototype.getSelectedItem = function() {
|
|
|
|
return this.selectedItem_;
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2018-03-13 20:29:33 -04:00
|
|
|
/**
|
|
|
|
* @return {string} The name of the currently selected category.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getSelectedCategoryName = function() {
|
|
|
|
return this.selectedItem_.name_;
|
|
|
|
};
|
|
|
|
|
2018-05-10 15:15:44 -04:00
|
|
|
/**
|
|
|
|
* @return {string} The id of the currently selected category.
|
2018-05-14 11:02:54 -04:00
|
|
|
* @public
|
2018-05-10 15:15:44 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getSelectedCategoryId = function() {
|
|
|
|
return this.selectedItem_.id_;
|
|
|
|
};
|
|
|
|
|
2018-03-13 20:29:33 -04:00
|
|
|
/**
|
|
|
|
* @return {number} The distance flyout is scrolled below the top of the currently
|
|
|
|
* selected category.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getCategoryScrollOffset = function() {
|
2018-05-10 15:15:44 -04:00
|
|
|
var categoryPos = this.getCategoryPositionById(this.getSelectedCategoryId());
|
2018-03-13 20:29:33 -04:00
|
|
|
return this.flyout_.getScrollPos() - categoryPos;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the position of a category by name.
|
|
|
|
* @param {string} name The name of the category.
|
|
|
|
* @return {number} The position of the category.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getCategoryPositionByName = function(name) {
|
|
|
|
var scrollPositions = this.flyout_.categoryScrollPositions;
|
|
|
|
for (var i = 0; i < scrollPositions.length; i++) {
|
|
|
|
if (name === scrollPositions[i].categoryName) {
|
|
|
|
return scrollPositions[i].position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-10 15:15:44 -04:00
|
|
|
/**
|
|
|
|
* Get the position of a category by id.
|
|
|
|
* @param {string} id The id of the category.
|
|
|
|
* @return {number} The position of the category.
|
2018-05-14 11:02:54 -04:00
|
|
|
* @public
|
2018-05-10 15:15:44 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getCategoryPositionById = function(id) {
|
|
|
|
var scrollPositions = this.flyout_.categoryScrollPositions;
|
|
|
|
for (var i = 0; i < scrollPositions.length; i++) {
|
|
|
|
if (id === scrollPositions[i].categoryId) {
|
|
|
|
return scrollPositions[i].position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-27 09:53:38 -04:00
|
|
|
/**
|
|
|
|
* Get the length of a category by name.
|
|
|
|
* @param {string} name The name of the category.
|
|
|
|
* @return {number} The length of the category.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getCategoryLengthByName = function(name) {
|
|
|
|
var scrollPositions = this.flyout_.categoryScrollPositions;
|
|
|
|
for (var i = 0; i < scrollPositions.length; i++) {
|
|
|
|
if (name === scrollPositions[i].categoryName) {
|
|
|
|
return scrollPositions[i].length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-10 15:15:44 -04:00
|
|
|
/**
|
|
|
|
* Get the length of a category by id.
|
|
|
|
* @param {string} id The id of the category.
|
|
|
|
* @return {number} The length of the category.
|
2018-05-14 11:02:54 -04:00
|
|
|
* @public
|
2018-05-10 15:15:44 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getCategoryLengthById = function(id) {
|
|
|
|
var scrollPositions = this.flyout_.categoryScrollPositions;
|
|
|
|
for (var i = 0; i < scrollPositions.length; i++) {
|
|
|
|
if (id === scrollPositions[i].categoryId) {
|
|
|
|
return scrollPositions[i].length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-13 20:29:33 -04:00
|
|
|
/**
|
|
|
|
* Set the scroll position of the flyout.
|
|
|
|
* @param {number} pos The position to set.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.setFlyoutScrollPos = function(pos) {
|
|
|
|
this.flyout_.setScrollPos(pos);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Set the currently selected category.
|
|
|
|
* @param {Blockly.Toolbox.Category} item The category to select.
|
2018-03-13 20:41:42 -04:00
|
|
|
* @param {boolean=} opt_shouldScroll Whether to scroll to the selected category. Defaults to true.
|
2016-10-25 12:49:22 -07:00
|
|
|
*/
|
2018-03-14 18:35:22 -04:00
|
|
|
Blockly.Toolbox.prototype.setSelectedItem = function(item, opt_shouldScroll) {
|
|
|
|
if (typeof opt_shouldScroll === 'undefined') {
|
|
|
|
opt_shouldScroll = true;
|
2018-03-12 16:43:13 -04:00
|
|
|
}
|
2016-10-07 15:36:21 -04:00
|
|
|
if (this.selectedItem_) {
|
2016-10-25 12:49:22 -07:00
|
|
|
// They selected a different category but one was already open. Close it.
|
2016-10-07 15:36:21 -04:00
|
|
|
this.selectedItem_.setSelected(false);
|
|
|
|
}
|
2016-09-08 16:54:10 -07:00
|
|
|
this.selectedItem_ = item;
|
|
|
|
if (this.selectedItem_ != null) {
|
2016-10-07 15:36:21 -04:00
|
|
|
this.selectedItem_.setSelected(true);
|
2017-08-23 16:58:05 -04:00
|
|
|
// Scroll flyout to the top of the selected category
|
2018-05-10 15:15:44 -04:00
|
|
|
var categoryId = item.id_;
|
2018-03-14 18:35:22 -04:00
|
|
|
if (opt_shouldScroll) {
|
2018-05-10 15:15:44 -04:00
|
|
|
this.scrollToCategoryById(categoryId);
|
2018-03-12 16:43:13 -04:00
|
|
|
}
|
2017-10-05 15:20:04 -04:00
|
|
|
}
|
|
|
|
};
|
2017-10-05 15:20:29 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Select and scroll to a category by name.
|
|
|
|
* @param {string} name The name of the category to select and scroll to.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.setSelectedCategoryByName = function(name) {
|
|
|
|
this.selectCategoryByName(name);
|
|
|
|
this.scrollToCategoryByName(name);
|
|
|
|
};
|
|
|
|
|
2018-05-10 15:15:44 -04:00
|
|
|
/**
|
|
|
|
* Select and scroll to a category by id.
|
|
|
|
* @param {string} id The id of the category to select and scroll to.
|
2018-05-14 11:02:54 -04:00
|
|
|
* @public
|
2018-05-10 15:15:44 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.setSelectedCategoryById = function(id) {
|
|
|
|
this.selectCategoryById(id);
|
|
|
|
this.scrollToCategoryById(id);
|
|
|
|
};
|
|
|
|
|
2017-10-05 15:20:04 -04:00
|
|
|
/**
|
|
|
|
* Scroll to a category by name.
|
|
|
|
* @param {string} name The name of the category to scroll to.
|
|
|
|
* @package
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.scrollToCategoryByName = function(name) {
|
|
|
|
var scrollPositions = this.flyout_.categoryScrollPositions;
|
|
|
|
for (var i = 0; i < scrollPositions.length; i++) {
|
|
|
|
if (name === scrollPositions[i].categoryName) {
|
|
|
|
this.flyout_.setVisible(true);
|
|
|
|
this.flyout_.scrollTo(scrollPositions[i].position);
|
|
|
|
return;
|
2017-08-23 16:58:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-08-23 17:15:27 -04:00
|
|
|
|
2018-05-10 15:15:44 -04:00
|
|
|
/**
|
|
|
|
* Scroll to a category by id.
|
|
|
|
* @param {string} id The id of the category to scroll to.
|
2018-05-14 11:02:54 -04:00
|
|
|
* @public
|
2018-05-10 15:15:44 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.scrollToCategoryById = function(id) {
|
|
|
|
var scrollPositions = this.flyout_.categoryScrollPositions;
|
|
|
|
for (var i = 0; i < scrollPositions.length; i++) {
|
|
|
|
if (id === scrollPositions[i].categoryId) {
|
|
|
|
this.flyout_.setVisible(true);
|
|
|
|
this.flyout_.scrollTo(scrollPositions[i].position);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a category by its index.
|
|
|
|
* @param {number} index The index of the category.
|
2018-05-14 11:02:33 -04:00
|
|
|
* @return {Blockly.Toolbox.Category} the category, or null if there are no categories.
|
2018-05-14 11:02:54 -04:00
|
|
|
* @package
|
2018-05-10 15:15:44 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.getCategoryByIndex = function(index) {
|
2018-05-14 11:02:33 -04:00
|
|
|
if (!this.categoryMenu_.categories_) return null;
|
2018-05-10 15:15:44 -04:00
|
|
|
return this.categoryMenu_.categories_[index];
|
|
|
|
};
|
|
|
|
|
2017-08-23 17:15:27 -04:00
|
|
|
/**
|
|
|
|
* Select a category by name.
|
|
|
|
* @param {string} name The name of the category to select.
|
2017-09-19 17:22:55 -04:00
|
|
|
* @package
|
2017-08-23 17:15:27 -04:00
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.selectCategoryByName = function(name) {
|
2017-09-13 15:25:11 -04:00
|
|
|
for (var i = 0; i < this.categoryMenu_.categories_.length; i++) {
|
2017-08-23 17:15:27 -04:00
|
|
|
var category = this.categoryMenu_.categories_[i];
|
|
|
|
if (name === category.name_) {
|
|
|
|
this.selectedItem_.setSelected(false);
|
|
|
|
this.selectedItem_ = category;
|
|
|
|
this.selectedItem_.setSelected(true);
|
|
|
|
}
|
2013-10-30 14:46:03 -07:00
|
|
|
}
|
|
|
|
};
|
2016-06-29 23:38:32 +02:00
|
|
|
|
2018-05-10 15:15:44 -04:00
|
|
|
/**
|
|
|
|
* Select a category by id.
|
|
|
|
* @param {string} id The id of the category to select.
|
|
|
|
* @package
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.prototype.selectCategoryById = function(id) {
|
|
|
|
for (var i = 0; i < this.categoryMenu_.categories_.length; i++) {
|
|
|
|
var category = this.categoryMenu_.categories_[i];
|
|
|
|
if (id === category.id_) {
|
|
|
|
this.selectedItem_.setSelected(false);
|
|
|
|
this.selectedItem_ = category;
|
|
|
|
this.selectedItem_.setSelected(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Wrapper function for calling setSelectedItem from a touch handler.
|
|
|
|
* @param {Blockly.Toolbox.Category} item The category to select.
|
|
|
|
* @return {function} A function that can be passed to bindEvent.
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.prototype.setSelectedItemFactory = function(item) {
|
|
|
|
var selectedItem = item;
|
|
|
|
return function() {
|
2018-12-18 07:19:31 -05:00
|
|
|
if (!this.workspace_.isDragging()) {
|
|
|
|
this.setSelectedItem(selectedItem);
|
|
|
|
Blockly.Touch.clearTouchIdentifier();
|
|
|
|
}
|
2016-08-26 18:29:34 -07:00
|
|
|
};
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:49:15 -07:00
|
|
|
// Category menu
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Class for a table of category titles that will control which category is
|
|
|
|
* displayed.
|
|
|
|
* @param {Blockly.Toolbox} parent The toolbox that owns the category menu.
|
|
|
|
* @param {Element} parentHtml The containing html div.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.CategoryMenu = function(parent, parentHtml) {
|
|
|
|
this.parent_ = parent;
|
2016-10-20 19:28:54 -07:00
|
|
|
this.height_ = 0;
|
2016-08-26 18:29:34 -07:00
|
|
|
this.parentHtml_ = parentHtml;
|
|
|
|
this.createDom();
|
|
|
|
this.categories_ = [];
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* @return {number} the height of the category menu.
|
|
|
|
*/
|
2016-09-08 16:54:10 -07:00
|
|
|
Blockly.Toolbox.CategoryMenu.prototype.getHeight = function() {
|
2016-10-20 19:28:54 -07:00
|
|
|
return this.height_;
|
2016-09-08 16:54:10 -07:00
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Create the DOM for the category menu.
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.CategoryMenu.prototype.createDom = function() {
|
2017-08-25 10:25:11 -04:00
|
|
|
this.table = goog.dom.createDom('div', this.parent_.horizontalLayout_ ?
|
|
|
|
'scratchCategoryMenuHorizontal' : 'scratchCategoryMenu');
|
2016-08-26 18:29:34 -07:00
|
|
|
this.parentHtml_.appendChild(this.table);
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-10-06 14:49:15 -07:00
|
|
|
* Fill the toolbox with categories and blocks by creating a new
|
|
|
|
* {Blockly.Toolbox.Category} for every category tag in the toolbox xml.
|
2016-08-26 18:29:34 -07:00
|
|
|
* @param {Node} domTree DOM tree of blocks, or null.
|
2013-10-30 14:46:03 -07:00
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.CategoryMenu.prototype.populate = function(domTree) {
|
2016-10-06 14:49:15 -07:00
|
|
|
if (!domTree) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-15 14:51:27 -05:00
|
|
|
// Remove old categories
|
|
|
|
this.dispose();
|
|
|
|
this.createDom();
|
2016-10-07 15:36:21 -04:00
|
|
|
var categories = [];
|
|
|
|
// Find actual categories from the DOM tree.
|
2016-08-26 18:29:34 -07:00
|
|
|
for (var i = 0, child; child = domTree.childNodes[i]; i++) {
|
2016-10-07 15:36:21 -04:00
|
|
|
if (!child.tagName || child.tagName.toUpperCase() != 'CATEGORY') {
|
2016-08-26 18:29:34 -07:00
|
|
|
continue;
|
|
|
|
}
|
2016-10-07 15:36:21 -04:00
|
|
|
categories.push(child);
|
|
|
|
}
|
2017-07-10 13:20:26 -04:00
|
|
|
|
2017-07-11 10:50:08 -04:00
|
|
|
// Create a single column of categories
|
2017-07-10 13:20:26 -04:00
|
|
|
for (var i = 0; i < categories.length; i++) {
|
|
|
|
var child = categories[i];
|
2017-07-11 10:50:08 -04:00
|
|
|
var row = goog.dom.createDom('div', 'scratchCategoryMenuRow');
|
2016-10-07 15:36:21 -04:00
|
|
|
this.table.appendChild(row);
|
2016-10-25 12:49:22 -07:00
|
|
|
if (child) {
|
|
|
|
this.categories_.push(new Blockly.Toolbox.Category(this, row,
|
|
|
|
child));
|
|
|
|
}
|
2014-11-29 15:41:27 -08:00
|
|
|
}
|
2016-10-20 19:28:54 -07:00
|
|
|
this.height_ = this.table.offsetHeight;
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Dispose of this Category Menu and all of its children.
|
|
|
|
*/
|
2016-09-08 16:54:10 -07:00
|
|
|
Blockly.Toolbox.CategoryMenu.prototype.dispose = function() {
|
2016-10-06 14:49:15 -07:00
|
|
|
for (var i = 0, category; category = this.categories_[i]; i++) {
|
|
|
|
category.dispose();
|
|
|
|
}
|
2017-05-10 14:40:05 -04:00
|
|
|
this.categories_ = [];
|
2016-10-06 14:49:15 -07:00
|
|
|
if (this.table) {
|
|
|
|
goog.dom.removeNode(this.table);
|
|
|
|
this.table = null;
|
|
|
|
}
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:49:15 -07:00
|
|
|
|
|
|
|
// Category
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Class for the data model of a category in the toolbox.
|
|
|
|
* @param {Blockly.Toolbox.CategoryMenu} parent The category menu that owns this
|
|
|
|
* category.
|
|
|
|
* @param {Element} parentHtml The containing html div.
|
|
|
|
* @param {Node} domTree DOM tree of blocks.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.Category = function(parent, parentHtml, domTree) {
|
|
|
|
this.parent_ = parent;
|
|
|
|
this.parentHtml_ = parentHtml;
|
|
|
|
this.name_ = domTree.getAttribute('name');
|
2018-05-10 15:15:44 -04:00
|
|
|
this.id_ = domTree.getAttribute('id');
|
2016-08-26 18:29:34 -07:00
|
|
|
this.setColour(domTree);
|
|
|
|
this.custom_ = domTree.getAttribute('custom');
|
2017-12-19 14:23:45 -05:00
|
|
|
this.iconURI_ = domTree.getAttribute('iconURI');
|
2018-06-25 13:16:42 -04:00
|
|
|
this.showStatusButton_ = domTree.getAttribute('showStatusButton');
|
2016-08-26 18:29:34 -07:00
|
|
|
this.contents_ = [];
|
|
|
|
if (!this.custom_) {
|
|
|
|
this.parseContents_(domTree);
|
2013-10-30 14:46:03 -07:00
|
|
|
}
|
2016-08-26 18:29:34 -07:00
|
|
|
this.createDom();
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Dispose of this category and all of its contents.
|
|
|
|
*/
|
2016-10-06 14:49:15 -07:00
|
|
|
Blockly.Toolbox.Category.prototype.dispose = function() {
|
|
|
|
if (this.item_) {
|
|
|
|
goog.dom.removeNode(this.item_);
|
|
|
|
this.item = null;
|
|
|
|
}
|
|
|
|
this.parent_ = null;
|
|
|
|
this.parentHtml_ = null;
|
|
|
|
this.contents_ = null;
|
|
|
|
};
|
|
|
|
|
2018-07-06 12:46:31 +02:00
|
|
|
/**
|
|
|
|
* Used to determine the css classes for the menu item for this category
|
|
|
|
* based on its current state.
|
|
|
|
* @private
|
|
|
|
* @param {boolean=} selected Indication whether the category is currently selected.
|
|
|
|
* @return {string} The css class names to be applied, space-separated.
|
|
|
|
*/
|
|
|
|
Blockly.Toolbox.Category.prototype.getMenuItemClassName_ = function(selected) {
|
|
|
|
var classNames = [
|
|
|
|
'scratchCategoryMenuItem',
|
|
|
|
'scratchCategoryId-' + this.id_,
|
|
|
|
];
|
|
|
|
if (selected) {
|
|
|
|
classNames.push('categorySelected');
|
|
|
|
}
|
|
|
|
return classNames.join(' ');
|
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Create the DOM for a category in the toolbox.
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.Category.prototype.createDom = function() {
|
2016-10-07 15:36:21 -04:00
|
|
|
var toolbox = this.parent_.parent_;
|
2017-07-11 10:50:08 -04:00
|
|
|
this.item_ = goog.dom.createDom('div',
|
2018-07-06 12:46:31 +02:00
|
|
|
{'class': this.getMenuItemClassName_()});
|
2017-07-11 10:50:08 -04:00
|
|
|
this.label_ = goog.dom.createDom('div',
|
2018-06-18 12:14:13 -07:00
|
|
|
{'class': 'scratchCategoryMenuItemLabel'},
|
|
|
|
Blockly.utils.replaceMessageReferences(this.name_));
|
2017-12-19 14:23:45 -05:00
|
|
|
if (this.iconURI_) {
|
|
|
|
this.bubble_ = goog.dom.createDom('div',
|
|
|
|
{'class': 'scratchCategoryItemIcon'});
|
|
|
|
this.bubble_.style.backgroundImage = 'url(' + this.iconURI_ + ')';
|
|
|
|
} else {
|
|
|
|
this.bubble_ = goog.dom.createDom('div',
|
|
|
|
{'class': 'scratchCategoryItemBubble'});
|
|
|
|
this.bubble_.style.backgroundColor = this.colour_;
|
|
|
|
this.bubble_.style.borderColor = this.secondaryColour_;
|
|
|
|
}
|
2016-10-07 15:36:21 -04:00
|
|
|
this.item_.appendChild(this.bubble_);
|
2017-07-11 10:50:08 -04:00
|
|
|
this.item_.appendChild(this.label_);
|
2016-08-26 18:29:34 -07:00
|
|
|
this.parentHtml_.appendChild(this.item_);
|
2018-05-02 11:05:43 -07:00
|
|
|
Blockly.bindEvent_(
|
|
|
|
this.item_, 'mouseup', toolbox, toolbox.setSelectedItemFactory(this));
|
2016-10-07 15:36:21 -04:00
|
|
|
};
|
2016-08-26 18:29:34 -07:00
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Set the selected state of this category.
|
|
|
|
* @param {boolean} selected Whether this category is selected.
|
|
|
|
*/
|
2016-10-07 15:36:21 -04:00
|
|
|
Blockly.Toolbox.Category.prototype.setSelected = function(selected) {
|
2018-07-06 12:46:31 +02:00
|
|
|
this.item_.className = this.getMenuItemClassName_(selected);
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
2014-11-24 17:34:27 -08:00
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Set the contents of this category from DOM.
|
|
|
|
* @param {Node} domTree DOM tree of blocks.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.Category.prototype.parseContents_ = function(domTree) {
|
|
|
|
for (var i = 0, child; child = domTree.childNodes[i]; i++) {
|
|
|
|
if (!child.tagName) {
|
|
|
|
// Skip
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
switch (child.tagName.toUpperCase()) {
|
|
|
|
case 'BLOCK':
|
|
|
|
case 'SHADOW':
|
2016-11-01 18:00:26 -07:00
|
|
|
case 'LABEL':
|
2016-08-26 18:29:34 -07:00
|
|
|
case 'BUTTON':
|
2017-05-22 14:07:57 -07:00
|
|
|
case 'SEP':
|
2016-08-26 18:29:34 -07:00
|
|
|
case 'TEXT':
|
|
|
|
this.contents_.push(child);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-07-19 09:27:58 +05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-25 12:49:22 -07:00
|
|
|
/**
|
|
|
|
* Get the contents of this category.
|
|
|
|
* @return {!Array|string} xmlList List of blocks to show, or a string with the
|
|
|
|
* name of a custom category.
|
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.Category.prototype.getContents = function() {
|
|
|
|
return this.custom_ ? this.custom_ : this.contents_;
|
2013-10-30 14:46:03 -07:00
|
|
|
};
|
2014-11-24 17:34:27 -08:00
|
|
|
|
2016-10-06 14:49:15 -07:00
|
|
|
/**
|
|
|
|
* Set the colour of the category's background from a DOM node.
|
2016-10-07 15:36:21 -04:00
|
|
|
* @param {Node} node DOM node with "colour" and "secondaryColour" attribute.
|
|
|
|
* Colours are a hex string or hue on a colour wheel (0-360).
|
2016-10-06 14:49:15 -07:00
|
|
|
*/
|
2016-08-26 18:29:34 -07:00
|
|
|
Blockly.Toolbox.Category.prototype.setColour = function(node) {
|
|
|
|
var colour = node.getAttribute('colour');
|
2016-10-07 15:36:21 -04:00
|
|
|
var secondaryColour = node.getAttribute('secondaryColour');
|
2016-08-26 18:29:34 -07:00
|
|
|
if (goog.isString(colour)) {
|
|
|
|
if (colour.match(/^#[0-9a-fA-F]{6}$/)) {
|
|
|
|
this.colour_ = colour;
|
|
|
|
} else {
|
|
|
|
this.colour_ = Blockly.hueToRgb(colour);
|
|
|
|
}
|
2016-10-07 15:36:21 -04:00
|
|
|
if (secondaryColour.match(/^#[0-9a-fA-F]{6}$/)) {
|
|
|
|
this.secondaryColour_ = secondaryColour;
|
|
|
|
} else {
|
|
|
|
this.secondaryColour_ = Blockly.hueToRgb(secondaryColour);
|
|
|
|
}
|
2016-08-26 18:29:34 -07:00
|
|
|
this.hasColours_ = true;
|
|
|
|
} else {
|
|
|
|
this.colour_ = '#000000';
|
2016-10-07 15:36:21 -04:00
|
|
|
this.secondaryColour_ = '#000000';
|
2016-07-19 09:27:58 +05:00
|
|
|
}
|
2014-11-24 17:34:27 -08:00
|
|
|
};
|