scratch-blocks/core/block_svg.js

1317 lines
40 KiB
JavaScript
Raw Permalink Normal View History

/**
* @license
* Visual Blocks Editor
*
* Copyright 2012 Google Inc.
2014-10-07 13:09:55 -07:00
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Methods for graphically rendering a block as SVG.
* @author fraser@google.com (Neil Fraser)
*/
'use strict';
goog.provide('Blockly.BlockSvg');
2014-12-23 11:22:02 -08:00
goog.require('Blockly.Block');
goog.require('Blockly.BlockAnimations');
2014-12-23 11:22:02 -08:00
goog.require('Blockly.ContextMenu');
2018-05-09 13:34:21 -07:00
goog.require('Blockly.Events.Ui');
goog.require('Blockly.Events.BlockMove');
Merge/05 24 (#903) * 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. * VariableMap and functions added. * Create separate file for VariableMap and its functions. * Fix #1069 (#1073) * VariableMap and functions added. * Fix #1051 (#1084) * Improve errors when validating JSON block definitions. (#1086) goog.asserts to not run from blockly_compressed.js. User data validation should always run. * Dragging changes, rebased on develop (#1078) * Add block drag surface translateSurfaceBy * Add dragged connection manager * Add gesture.js * Add GestureHandler * Implemented gesture skeleton * Most basic workspace dragging * Add dragged connection manager * cleanup * doc * more cleanup * Add gesture handler * Add translateSurfaceInternal * core/block_dragger.js * cleanup * Pull in changes to dragged connection manager * Pull in changes to dragged connection manager * comments * more annotations * Add workspace dragger * Add coordinate annotations * Start on block dragging * Limit number of concurrent gestures * Add some TODOs * start using dragged connection manager * Set origin correctly for dragging blocks * Connect or delete at the end of a block drag. * cleanup * handle field clicks and block + workspace right-clicks * move code into BlockDragger class, but still reach into Gesture internals a lot * Clean up block dragger * Call blockDragger constructor with correct arguments * Enable block dragging in a mutator workspace * Add workspace dragger * click todos * Drag flyout with background * more dragging from flyout * nit * fix dragging from flyouts * Remove unused code and rename gestureHandler to gestureDB * Rename gesture handler * Added some jsdoc in gesture.js * Update some docs * Move some code to block_svg and clean up code * Lots of coordinate annotations * Fix block dragging when zoomed. * Remove built files from branch * More dragging work (#1026) -- Drag bubbles while dragging blocks -- Use bindEventWithChecks to work in touch on Android. Not tested anywhere else yet. -- Handle dragging blocks while zoomed -- Handle dragging blocks in mutators -- Handle right-clicks (I hope) -- Removed lots of unused code * More dragging work (#1048) - Removed gestureDB - Removing uses of terminateDrag - Cleaned up disposal code * Dragging bugfixes (#1058) - Get rid of flyout.dragMode_ and blockly.dragMode_ - Make drags from the flyout start from the top block in the group - Block tooltips from being scheduled or shown during gestures - Don't resize mutator bubbles mid-drag * Fix events in new dragging (#1060) * rebuild for testing * unbuild * Fix events * rebuild * Fix up cursors * Use language files from develop * Remove handled TODOS * attempt to fix IE rerendering bug, and recalculate workspace positions on scroll * Rebuild all the things * Comment cleanup; annotations; delete unused variables. * Tidy up context menu code. (#1081) * add osx travis test run job (#1074) * Names are correctly fetched from VariableModels! * add more wait time for test setup (#1091) * Work around timing issue with travis osx issue (#1092) * add more wait time for test setup * increase selenium wait time * add more wait * Fix #1077 by adding a rule to cover the toolbox labels too. (#1099) * Assign variable UUID to field_variable dropdown. * Change registration link to a static one (#1106) This lets us redirect to a different form if we change it in the future. * Edit generators to read in Variable Models. * Add VariableMap requirement to workspace. * Changed parameter name in workspace for clarity. * Add type, id, and info to the generated xml. Add xml tests for fieldToDom. Update workspace tests to pass with new changes. * Fix apostrophe in tooltips and helpurls (#1111) * Click events on shadow blocks have the correct id (#1089) * Add image_onclick option (#1080) * Cleanup: semicolons, spacing, etc. (#1116) * Spelling. Spelling is hard. * Add variable info to xml generated in variables.js * Add missing CLAs info to the contributing file (#1119) * Add missing CLAs info to the contributing file * Added larger changes paragraph * Replacing latest prettifier hosted in repo with latest version at rawgit CDN. (#1120) * Forgot update code demo (#1121) * Move audio code to a new file (#1122) * move audio code to a new file * dispose * null check * Make flyout get variables from target workspace's variableMap. * Require VariableModel in field_variable.js. * Update contributing.md (#1126) * Include variables at top of serialization. * Move blockSvg.getHeightWidth to block_render_svg.js (#1118) * Deserialization variables at top. * Create grid object (#1131) * Create grid object * Doc * Units! Thanks @RoboErikG * Add our sound files in other formats * Remove duplicate merged code * Remove translation files * Cleanup duplicate functions * Add back scrollbar code * Fix variable related issues * Revert workspace variable creation change * Delete language files * Appease linter * Remove duplication * Add spaces to jsdoc line
2017-05-30 09:26:06 -04:00
goog.require('Blockly.Grid');
goog.require('Blockly.RenderedConnection');
goog.require('Blockly.scratchBlocksUtils');
goog.require('Blockly.Tooltip');
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
goog.require('Blockly.Touch');
goog.require('Blockly.utils');
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
goog.require('goog.Timer');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.math.Coordinate');
/**
* Class for a block's SVG representation.
* Not normally called directly, workspace.newBlock() is preferred.
* @param {!Blockly.Workspace} workspace The block's workspace.
* @param {?string} prototypeName Name of the language object containing
* type-specific functions for this block.
* @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
2018-05-15 17:09:08 -07:00
* create a new ID. If the ID conflicts with an in-use ID, a new one will
* be generated.
2014-12-23 11:22:02 -08:00
* @extends {Blockly.Block}
* @constructor
*/
2015-12-09 10:02:42 +01:00
Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
// Create core elements for the block.
2016-05-04 15:05:45 -07:00
/**
* @type {SVGElement}
* @private
*/
this.svgGroup_ = Blockly.utils.createSvgElement('g', {}, null);
2015-12-01 14:04:54 -06:00
/** @type {SVGElement} */
this.svgPath_ = Blockly.utils.createSvgElement('path',
{'class': 'blocklyPath blocklyBlockBackground'},
this.svgGroup_);
2014-12-23 11:22:02 -08:00
this.svgPath_.tooltip = this;
/** @type {boolean} */
this.rendered = false;
/**
* Whether to move the block to the drag surface when it is dragged.
* True if it should move, false if it should be translated directly.
* @type {boolean}
* @private
*/
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
this.useDragSurface_ = Blockly.utils.is3dSupported() && !!workspace.blockDragSurface_;
2014-09-08 14:26:52 -07:00
Blockly.Tooltip.bindMouseEvents(this.svgPath_);
2015-12-17 14:16:04 -08:00
Blockly.BlockSvg.superClass_.constructor.call(this,
workspace, prototypeName, opt_id);
2018-08-16 16:46:19 -07:00
// Expose this block's ID on its top-level SVG group.
if (this.svgGroup_.dataset) {
this.svgGroup_.dataset.id = this.id;
}
};
2014-12-23 11:22:02 -08:00
goog.inherits(Blockly.BlockSvg, Blockly.Block);
2014-09-08 14:26:52 -07:00
/**
* Height of this block, not including any statement blocks above or below.
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
* Height is in workspace units.
2014-09-08 14:26:52 -07:00
*/
Blockly.BlockSvg.prototype.height = 0;
2014-09-08 14:26:52 -07:00
/**
* Width of this block, including any connected value blocks.
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
* Width is in workspace units.
2014-09-08 14:26:52 -07:00
*/
Blockly.BlockSvg.prototype.width = 0;
/**
* Minimum width of block if insertion marker; comes from inserting block.
* @type {number}
*/
Blockly.BlockSvg.prototype.insertionMarkerMinWidth_ = 0;
/**
* Opacity of this block between 0 and 1.
* @type {number}
* @private
*/
Blockly.BlockSvg.prototype.opacity_ = 1;
2015-08-19 17:21:05 -07:00
/**
* Original location of block being dragged.
* @type {goog.math.Coordinate}
* @private
*/
Blockly.BlockSvg.prototype.dragStartXY_ = null;
/**
* Whether the block glows as if running.
* @type {boolean}
* @private
*/
Blockly.BlockSvg.prototype.isGlowingBlock_ = false;
/**
* Whether the block's whole stack glows as if running.
* @type {boolean}
* @private
*/
Blockly.BlockSvg.prototype.isGlowingStack_ = false;
/**
* Constant for identifying rows that are to be rendered inline.
* Don't collide with Blockly.INPUT_VALUE and friends.
* @const
*/
Blockly.BlockSvg.INLINE = -1;
/**
2014-12-23 11:22:02 -08:00
* Create and initialize the SVG representation of the block.
2015-01-05 12:04:01 -08:00
* May be called more than once.
*/
2014-12-23 11:22:02 -08:00
Blockly.BlockSvg.prototype.initSvg = function() {
goog.asserts.assert(this.workspace.rendered, 'Workspace is headless.');
if (!this.isInsertionMarker()) { // Insertion markers not allowed to have inputs or icons
// Input shapes are empty holes drawn when a value input is not connected.
for (var i = 0, input; input = this.inputList[i]; i++) {
input.init();
input.initOutlinePath(this.svgGroup_);
}
var icons = this.getIcons();
for (i = 0; i < icons.length; i++) {
icons[i].createIcon();
}
}
2014-12-24 13:48:45 -08:00
this.updateColour();
2015-04-28 13:51:25 -07:00
this.updateMovable();
if (!this.workspace.options.readOnly && !this.eventsInit_) {
Blockly.bindEventWithChecks_(
this.getSvgRoot(), 'mousedown', this, this.onMouseDown_);
2014-12-23 11:22:02 -08:00
}
this.eventsInit_ = true;
2015-01-05 12:04:01 -08:00
if (!this.getSvgRoot().parentNode) {
this.workspace.getCanvas().appendChild(this.getSvgRoot());
}
2014-12-23 11:22:02 -08:00
};
/**
* Select this block. Highlight it visually.
*/
Blockly.BlockSvg.prototype.select = function() {
if (this.isShadow() && this.getParent()) {
// Shadow blocks should not be selected.
this.getParent().select();
return;
}
2016-03-29 08:10:44 -07:00
if (Blockly.selected == this) {
return;
}
var oldId = null;
2014-12-23 11:22:02 -08:00
if (Blockly.selected) {
2016-03-29 08:10:44 -07:00
oldId = Blockly.selected.id;
2014-12-23 11:22:02 -08:00
// Unselect any previously selected block.
2016-03-29 08:10:44 -07:00
Blockly.Events.disable();
try {
Blockly.selected.unselect();
} finally {
Blockly.Events.enable();
}
2014-12-23 11:22:02 -08:00
}
2016-03-29 08:10:44 -07:00
var event = new Blockly.Events.Ui(null, 'selected', oldId, this.id);
event.workspaceId = this.workspace.id;
Blockly.Events.fire(event);
2014-12-23 11:22:02 -08:00
Blockly.selected = this;
this.addSelect();
};
/**
* Unselect this block. Remove its highlighting.
*/
Blockly.BlockSvg.prototype.unselect = function() {
2016-03-28 15:40:37 -07:00
if (Blockly.selected != this) {
return;
}
2016-03-29 08:10:44 -07:00
var event = new Blockly.Events.Ui(null, 'selected', this.id, null);
event.workspaceId = this.workspace.id;
Blockly.Events.fire(event);
2014-12-23 11:22:02 -08:00
Blockly.selected = null;
this.removeSelect();
};
/**
* Glow only this particular block, to highlight it visually as if it's running.
* @param {boolean} isGlowingBlock Whether the block should glow.
*/
Blockly.BlockSvg.prototype.setGlowBlock = function(isGlowingBlock) {
this.isGlowingBlock_ = isGlowingBlock;
this.updateColour();
};
/**
* Glow the stack starting with this block, to highlight it visually as if it's running.
* @param {boolean} isGlowingStack Whether the stack starting with this block should glow.
*/
Blockly.BlockSvg.prototype.setGlowStack = function(isGlowingStack) {
this.isGlowingStack_ = isGlowingStack;
// Update the applied SVG filter if the property has changed
var svg = this.getSvgRoot();
if (this.isGlowingStack_ && !svg.hasAttribute('filter')) {
2018-05-31 12:23:20 -07:00
var stackGlowFilterId = this.workspace.options.stackGlowFilterId || 'blocklyStackGlowFilter';
svg.setAttribute('filter', 'url(#' + stackGlowFilterId + ')');
} else if (!this.isGlowingStack_ && svg.hasAttribute('filter')) {
svg.removeAttribute('filter');
}
};
2014-12-23 11:22:02 -08:00
/**
* Block's mutator icon (if any).
* @type {Blockly.Mutator}
*/
Blockly.BlockSvg.prototype.mutator = null;
/**
* Block's comment icon (if any).
* @type {Blockly.Comment}
*/
Blockly.BlockSvg.prototype.comment = null;
/**
* Block's warning icon (if any).
* @type {Blockly.Warning}
*/
Blockly.BlockSvg.prototype.warning = null;
/**
* Returns a list of mutator, comment, and warning icons.
* @return {!Array} List of icons.
*/
Blockly.BlockSvg.prototype.getIcons = function() {
var icons = [];
if (this.mutator) {
icons.push(this.mutator);
}
if (this.comment) {
icons.push(this.comment);
}
if (this.warning) {
icons.push(this.warning);
}
return icons;
};
/**
* Set parent of this block to be a new block or null.
* @param {Blockly.BlockSvg} newParent New parent block.
*/
Blockly.BlockSvg.prototype.setParent = function(newParent) {
var oldParent = this.parentBlock_;
if (newParent == oldParent) {
return;
}
Blockly.Field.startCache();
2014-12-23 11:22:02 -08:00
Blockly.BlockSvg.superClass_.setParent.call(this, newParent);
Blockly.Field.stopCache();
2014-12-23 11:22:02 -08:00
var svgRoot = this.getSvgRoot();
// Bail early if workspace is clearing, or we aren't rendered.
// We won't need to reattach ourselves anywhere.
if (this.workspace.isClearing || !svgRoot) {
return;
}
var oldXY = this.getRelativeToSurfaceXY();
2014-12-23 11:22:02 -08:00
if (newParent) {
newParent.getSvgRoot().appendChild(svgRoot);
var newXY = this.getRelativeToSurfaceXY();
// Move the connections to match the child's new position.
this.moveConnections_(newXY.x - oldXY.x, newXY.y - oldXY.y);
// If we are a shadow block, inherit tertiary colour.
if (this.isShadow()) {
this.setColour(this.getColour(), this.getColourSecondary(),
newParent.getColourTertiary(), this.getColourQuaternary());
}
2014-12-23 11:22:02 -08:00
}
// If we are losing a parent, we want to move our DOM element to the
// root of the workspace.
else if (oldParent) {
this.workspace.getCanvas().appendChild(svgRoot);
this.translate(oldXY.x, oldXY.y);
}
2014-12-23 11:22:02 -08:00
};
/**
* Return the coordinates of the top-left corner of this block relative to the
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
* drawing surface's origin (0,0), in workspace units.
* If the block is on the workspace, (0, 0) is the origin of the workspace
* coordinate system.
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
* This does not change with workspace scale.
* @return {!goog.math.Coordinate} Object with .x and .y properties in
* workspace coordinates.
2014-12-23 11:22:02 -08:00
*/
Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() {
2016-04-05 00:10:44 -04:00
// The drawing surface is relative to either the workspace canvas
// or to the drag surface group.
2014-12-23 11:22:02 -08:00
var x = 0;
var y = 0;
var dragSurfaceGroup = this.useDragSurface_ ?
this.workspace.blockDragSurface_.getGroup() : null;
2014-12-23 11:22:02 -08:00
var element = this.getSvgRoot();
if (element) {
do {
// Loop through this block and every parent.
var xy = Blockly.utils.getRelativeXY(element);
2014-12-23 11:22:02 -08:00
x += xy.x;
y += xy.y;
// If this element is the current element on the drag surface, include
// the translation of the drag surface itself.
if (this.useDragSurface_ &&
this.workspace.blockDragSurface_.getCurrentBlock() == element) {
var surfaceTranslation = this.workspace.blockDragSurface_.getSurfaceTranslation();
x += surfaceTranslation.x;
y += surfaceTranslation.y;
}
2014-12-23 11:22:02 -08:00
element = element.parentNode;
} while (element && element != this.workspace.getCanvas() &&
element != dragSurfaceGroup);
2014-12-23 11:22:02 -08:00
}
return new goog.math.Coordinate(x, y);
};
/**
* Move a block by a relative offset.
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
* @param {number} dx Horizontal offset in workspace units.
* @param {number} dy Vertical offset in workspace units.
2014-12-23 11:22:02 -08:00
*/
Blockly.BlockSvg.prototype.moveBy = function(dx, dy) {
goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
var eventsEnabled = Blockly.Events.isEnabled();
if (eventsEnabled) {
2017-06-22 10:38:20 -04:00
var event = new Blockly.Events.BlockMove(this);
}
2014-12-23 11:22:02 -08:00
var xy = this.getRelativeToSurfaceXY();
this.translate(xy.x + dx, xy.y + dy);
2014-12-23 11:22:02 -08:00
this.moveConnections_(dx, dy);
if (eventsEnabled) {
event.recordNew();
Blockly.Events.fire(event);
}
this.workspace.resizeContents();
2014-12-23 11:22:02 -08:00
};
/**
* Transforms a block by setting the translation on the transform attribute
* of the block's SVG.
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
* @param {number} x The x coordinate of the translation in workspace units.
* @param {number} y The y coordinate of the translation in workspace units.
*/
Blockly.BlockSvg.prototype.translate = function(x, y) {
this.getSvgRoot().setAttribute('transform',
'translate(' + x + ',' + y + ')');
};
/**
* Move this block to its workspace's drag surface, accounting for positioning.
* Generally should be called at the same time as setDragging_(true).
* Does nothing if useDragSurface_ is false.
* @private
*/
Blockly.BlockSvg.prototype.moveToDragSurface_ = function() {
if (!this.useDragSurface_) {
return;
}
// The translation for drag surface blocks,
// is equal to the current relative-to-surface position,
// to keep the position in sync as it move on/off the surface.
// This is in workspace coordinates.
var xy = this.getRelativeToSurfaceXY();
this.clearTransformAttributes_();
this.workspace.blockDragSurface_.translateSurface(xy.x, xy.y);
// Execute the move on the top-level SVG component
this.workspace.blockDragSurface_.setBlocksAndShow(this.getSvgRoot());
};
/**
* Move this block back to the workspace block canvas.
* Generally should be called at the same time as setDragging_(false).
* Does nothing if useDragSurface_ is false.
* @param {!goog.math.Coordinate} newXY The position the block should take on
* on the workspace canvas, in workspace coordinates.
* @private
*/
Blockly.BlockSvg.prototype.moveOffDragSurface_ = function(newXY) {
if (!this.useDragSurface_) {
return;
}
// Translate to current position, turning off 3d.
this.translate(newXY.x, newXY.y);
this.workspace.blockDragSurface_.clearAndHide(this.workspace.getCanvas());
};
/**
* Move this block during a drag, taking into account whether we are using a
* drag surface to translate blocks.
* This block must be a top-level block.
* @param {!goog.math.Coordinate} newLoc The location to translate to, in
* workspace coordinates.
* @package
*/
Blockly.BlockSvg.prototype.moveDuringDrag = function(newLoc) {
if (this.useDragSurface_) {
this.workspace.blockDragSurface_.translateSurface(newLoc.x, newLoc.y);
} else {
this.svgGroup_.translate_ = 'translate(' + newLoc.x + ',' + newLoc.y + ')';
this.svgGroup_.setAttribute('transform',
this.svgGroup_.translate_ + this.svgGroup_.skew_);
}
};
/**
* Clear the block of transform="..." attributes.
* Used when the block is switching from 3d to 2d transform or vice versa.
* @private
*/
Blockly.BlockSvg.prototype.clearTransformAttributes_ = function() {
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
Blockly.utils.removeAttribute(this.getSvgRoot(), 'transform');
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * 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 * 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. * 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 * 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. * 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. * Add a block to reverse a list (#844) * 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) * .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 * 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. * 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 * 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. * 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. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
};
2015-03-07 19:44:58 -06:00
/**
* Snap this block to the nearest grid point.
*/
Blockly.BlockSvg.prototype.snapToGrid = function() {
2015-03-08 17:39:30 -07:00
if (!this.workspace) {
return; // Deleted block.
}
if (this.workspace.isDragging()) {
2015-03-08 17:39:30 -07:00
return; // Don't bump blocks during a drag.
}
2015-03-07 19:44:58 -06:00
if (this.getParent()) {
return; // Only snap top-level blocks.
}
2015-03-08 17:39:30 -07:00
if (this.isInFlyout) {
return; // Don't move blocks around in a flyout.
}
Merge/05 24 (#903) * 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. * VariableMap and functions added. * Create separate file for VariableMap and its functions. * Fix #1069 (#1073) * VariableMap and functions added. * Fix #1051 (#1084) * Improve errors when validating JSON block definitions. (#1086) goog.asserts to not run from blockly_compressed.js. User data validation should always run. * Dragging changes, rebased on develop (#1078) * Add block drag surface translateSurfaceBy * Add dragged connection manager * Add gesture.js * Add GestureHandler * Implemented gesture skeleton * Most basic workspace dragging * Add dragged connection manager * cleanup * doc * more cleanup * Add gesture handler * Add translateSurfaceInternal * core/block_dragger.js * cleanup * Pull in changes to dragged connection manager * Pull in changes to dragged connection manager * comments * more annotations * Add workspace dragger * Add coordinate annotations * Start on block dragging * Limit number of concurrent gestures * Add some TODOs * start using dragged connection manager * Set origin correctly for dragging blocks * Connect or delete at the end of a block drag. * cleanup * handle field clicks and block + workspace right-clicks * move code into BlockDragger class, but still reach into Gesture internals a lot * Clean up block dragger * Call blockDragger constructor with correct arguments * Enable block dragging in a mutator workspace * Add workspace dragger * click todos * Drag flyout with background * more dragging from flyout * nit * fix dragging from flyouts * Remove unused code and rename gestureHandler to gestureDB * Rename gesture handler * Added some jsdoc in gesture.js * Update some docs * Move some code to block_svg and clean up code * Lots of coordinate annotations * Fix block dragging when zoomed. * Remove built files from branch * More dragging work (#1026) -- Drag bubbles while dragging blocks -- Use bindEventWithChecks to work in touch on Android. Not tested anywhere else yet. -- Handle dragging blocks while zoomed -- Handle dragging blocks in mutators -- Handle right-clicks (I hope) -- Removed lots of unused code * More dragging work (#1048) - Removed gestureDB - Removing uses of terminateDrag - Cleaned up disposal code * Dragging bugfixes (#1058) - Get rid of flyout.dragMode_ and blockly.dragMode_ - Make drags from the flyout start from the top block in the group - Block tooltips from being scheduled or shown during gestures - Don't resize mutator bubbles mid-drag * Fix events in new dragging (#1060) * rebuild for testing * unbuild * Fix events * rebuild * Fix up cursors * Use language files from develop * Remove handled TODOS * attempt to fix IE rerendering bug, and recalculate workspace positions on scroll * Rebuild all the things * Comment cleanup; annotations; delete unused variables. * Tidy up context menu code. (#1081) * add osx travis test run job (#1074) * Names are correctly fetched from VariableModels! * add more wait time for test setup (#1091) * Work around timing issue with travis osx issue (#1092) * add more wait time for test setup * increase selenium wait time * add more wait * Fix #1077 by adding a rule to cover the toolbox labels too. (#1099) * Assign variable UUID to field_variable dropdown. * Change registration link to a static one (#1106) This lets us redirect to a different form if we change it in the future. * Edit generators to read in Variable Models. * Add VariableMap requirement to workspace. * Changed parameter name in workspace for clarity. * Add type, id, and info to the generated xml. Add xml tests for fieldToDom. Update workspace tests to pass with new changes. * Fix apostrophe in tooltips and helpurls (#1111) * Click events on shadow blocks have the correct id (#1089) * Add image_onclick option (#1080) * Cleanup: semicolons, spacing, etc. (#1116) * Spelling. Spelling is hard. * Add variable info to xml generated in variables.js * Add missing CLAs info to the contributing file (#1119) * Add missing CLAs info to the contributing file * Added larger changes paragraph * Replacing latest prettifier hosted in repo with latest version at rawgit CDN. (#1120) * Forgot update code demo (#1121) * Move audio code to a new file (#1122) * move audio code to a new file * dispose * null check * Make flyout get variables from target workspace's variableMap. * Require VariableModel in field_variable.js. * Update contributing.md (#1126) * Include variables at top of serialization. * Move blockSvg.getHeightWidth to block_render_svg.js (#1118) * Deserialization variables at top. * Create grid object (#1131) * Create grid object * Doc * Units! Thanks @RoboErikG * Add our sound files in other formats * Remove duplicate merged code * Remove translation files * Cleanup duplicate functions * Add back scrollbar code * Fix variable related issues * Revert workspace variable creation change * Delete language files * Appease linter * Remove duplication * Add spaces to jsdoc line
2017-05-30 09:26:06 -04:00
var grid = this.workspace.getGrid();
if (!grid || !grid.shouldSnap()) {
return; // Config says no snapping.
}
Merge/05 24 (#903) * 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. * VariableMap and functions added. * Create separate file for VariableMap and its functions. * Fix #1069 (#1073) * VariableMap and functions added. * Fix #1051 (#1084) * Improve errors when validating JSON block definitions. (#1086) goog.asserts to not run from blockly_compressed.js. User data validation should always run. * Dragging changes, rebased on develop (#1078) * Add block drag surface translateSurfaceBy * Add dragged connection manager * Add gesture.js * Add GestureHandler * Implemented gesture skeleton * Most basic workspace dragging * Add dragged connection manager * cleanup * doc * more cleanup * Add gesture handler * Add translateSurfaceInternal * core/block_dragger.js * cleanup * Pull in changes to dragged connection manager * Pull in changes to dragged connection manager * comments * more annotations * Add workspace dragger * Add coordinate annotations * Start on block dragging * Limit number of concurrent gestures * Add some TODOs * start using dragged connection manager * Set origin correctly for dragging blocks * Connect or delete at the end of a block drag. * cleanup * handle field clicks and block + workspace right-clicks * move code into BlockDragger class, but still reach into Gesture internals a lot * Clean up block dragger * Call blockDragger constructor with correct arguments * Enable block dragging in a mutator workspace * Add workspace dragger * click todos * Drag flyout with background * more dragging from flyout * nit * fix dragging from flyouts * Remove unused code and rename gestureHandler to gestureDB * Rename gesture handler * Added some jsdoc in gesture.js * Update some docs * Move some code to block_svg and clean up code * Lots of coordinate annotations * Fix block dragging when zoomed. * Remove built files from branch * More dragging work (#1026) -- Drag bubbles while dragging blocks -- Use bindEventWithChecks to work in touch on Android. Not tested anywhere else yet. -- Handle dragging blocks while zoomed -- Handle dragging blocks in mutators -- Handle right-clicks (I hope) -- Removed lots of unused code * More dragging work (#1048) - Removed gestureDB - Removing uses of terminateDrag - Cleaned up disposal code * Dragging bugfixes (#1058) - Get rid of flyout.dragMode_ and blockly.dragMode_ - Make drags from the flyout start from the top block in the group - Block tooltips from being scheduled or shown during gestures - Don't resize mutator bubbles mid-drag * Fix events in new dragging (#1060) * rebuild for testing * unbuild * Fix events * rebuild * Fix up cursors * Use language files from develop * Remove handled TODOS * attempt to fix IE rerendering bug, and recalculate workspace positions on scroll * Rebuild all the things * Comment cleanup; annotations; delete unused variables. * Tidy up context menu code. (#1081) * add osx travis test run job (#1074) * Names are correctly fetched from VariableModels! * add more wait time for test setup (#1091) * Work around timing issue with travis osx issue (#1092) * add more wait time for test setup * increase selenium wait time * add more wait * Fix #1077 by adding a rule to cover the toolbox labels too. (#1099) * Assign variable UUID to field_variable dropdown. * Change registration link to a static one (#1106) This lets us redirect to a different form if we change it in the future. * Edit generators to read in Variable Models. * Add VariableMap requirement to workspace. * Changed parameter name in workspace for clarity. * Add type, id, and info to the generated xml. Add xml tests for fieldToDom. Update workspace tests to pass with new changes. * Fix apostrophe in tooltips and helpurls (#1111) * Click events on shadow blocks have the correct id (#1089) * Add image_onclick option (#1080) * Cleanup: semicolons, spacing, etc. (#1116) * Spelling. Spelling is hard. * Add variable info to xml generated in variables.js * Add missing CLAs info to the contributing file (#1119) * Add missing CLAs info to the contributing file * Added larger changes paragraph * Replacing latest prettifier hosted in repo with latest version at rawgit CDN. (#1120) * Forgot update code demo (#1121) * Move audio code to a new file (#1122) * move audio code to a new file * dispose * null check * Make flyout get variables from target workspace's variableMap. * Require VariableModel in field_variable.js. * Update contributing.md (#1126) * Include variables at top of serialization. * Move blockSvg.getHeightWidth to block_render_svg.js (#1118) * Deserialization variables at top. * Create grid object (#1131) * Create grid object * Doc * Units! Thanks @RoboErikG * Add our sound files in other formats * Remove duplicate merged code * Remove translation files * Cleanup duplicate functions * Add back scrollbar code * Fix variable related issues * Revert workspace variable creation change * Delete language files * Appease linter * Remove duplication * Add spaces to jsdoc line
2017-05-30 09:26:06 -04:00
var spacing = grid.getSpacing();
2015-03-07 19:44:58 -06:00
var half = spacing / 2;
var xy = this.getRelativeToSurfaceXY();
var dx = Math.round((xy.x - half) / spacing) * spacing + half - xy.x;
var dy = Math.round((xy.y - half) / spacing) * spacing + half - xy.y;
dx = Math.round(dx);
dy = Math.round(dy);
2015-03-07 19:44:58 -06:00
if (dx != 0 || dy != 0) {
this.moveBy(dx, dy);
}
};
/**
* Returns the coordinates of a bounding box describing the dimensions of this
* block and any blocks stacked below it.
* Coordinate system: workspace coordinates.
* @return {!{topLeft: goog.math.Coordinate, bottomRight: goog.math.Coordinate}}
* Object with top left and bottom right coordinates of the bounding box.
*/
Blockly.BlockSvg.prototype.getBoundingRectangle = function() {
var blockXY = this.getRelativeToSurfaceXY(this);
var blockBounds = this.getHeightWidth();
var topLeft;
var bottomRight;
if (this.RTL) {
Vertical shapes pass (#362) * Add if, if-else, equals; remove old if-elses * Naming fixes and removal of a dummy input for if-else * Fix spacing constants; add correct notches. * Fixing inner notches and connections on vertical statements * Fix size of extra row after last statement input * Add minimum block width * Vertical hat shape to spec * Larger vertical minimum block width * Remove INLINE_PADDING_Y and increase MIN_BLOCK_X INLINE_PADDING_Y, a fixed padding for the internal inputs, shouldn't be necessary in Scratch Blocks. Instead, we'll attempt to center the inputs vertically, and give a padding eventually not for inline inputs but rather for non-shadow blocks in inputs... * Remove code for horizontal puzzle tabs * Remove code for "external naked fields" * Start hats are always on in Scratch Blocks * Update vertical playground to start at 75% * Vertical field alignment in vertical rendering * Increase size of vertical green flag icon * Minimum width for blocks with C- or E-. * Remove unused field alignment code * Fix up inner spacing on statement input * Fix overhang to avoid clobbering height calculation * Subtract correct height in getHeightWidth * Subtract notch height in drawing statement bay * Add MIN_STATEMENT_INPUT_HEIGHT * Update size of extra row after statement input * Don't add extra pixel on statement input connection * Fix psuedo-height for blocks with no next connection * Rows after a statement input take the same size as EXTRA_STATEMENT_ROW_Y * Simplify height management to never include notches * Consolidate inputRows.rightEdge calculation * Clean up tab removal * Fix domToWorkspace in vertical_playground.html * Render constant newlines * Updating NOTCH_LEFT_PADDING to NOTCH_START_PADDING * Update comments about vertical field centering; spacing * Remove old comment about baseline * Simplify logic for positioning inline inputs * Ensure inputs in the first row don't overlap with notch
2016-05-27 13:21:40 -04:00
topLeft = new goog.math.Coordinate(blockXY.x - blockBounds.width,
blockXY.y);
Vertical shapes pass (#362) * Add if, if-else, equals; remove old if-elses * Naming fixes and removal of a dummy input for if-else * Fix spacing constants; add correct notches. * Fixing inner notches and connections on vertical statements * Fix size of extra row after last statement input * Add minimum block width * Vertical hat shape to spec * Larger vertical minimum block width * Remove INLINE_PADDING_Y and increase MIN_BLOCK_X INLINE_PADDING_Y, a fixed padding for the internal inputs, shouldn't be necessary in Scratch Blocks. Instead, we'll attempt to center the inputs vertically, and give a padding eventually not for inline inputs but rather for non-shadow blocks in inputs... * Remove code for horizontal puzzle tabs * Remove code for "external naked fields" * Start hats are always on in Scratch Blocks * Update vertical playground to start at 75% * Vertical field alignment in vertical rendering * Increase size of vertical green flag icon * Minimum width for blocks with C- or E-. * Remove unused field alignment code * Fix up inner spacing on statement input * Fix overhang to avoid clobbering height calculation * Subtract correct height in getHeightWidth * Subtract notch height in drawing statement bay * Add MIN_STATEMENT_INPUT_HEIGHT * Update size of extra row after statement input * Don't add extra pixel on statement input connection * Fix psuedo-height for blocks with no next connection * Rows after a statement input take the same size as EXTRA_STATEMENT_ROW_Y * Simplify height management to never include notches * Consolidate inputRows.rightEdge calculation * Clean up tab removal * Fix domToWorkspace in vertical_playground.html * Render constant newlines * Updating NOTCH_LEFT_PADDING to NOTCH_START_PADDING * Update comments about vertical field centering; spacing * Remove old comment about baseline * Simplify logic for positioning inline inputs * Ensure inputs in the first row don't overlap with notch
2016-05-27 13:21:40 -04:00
bottomRight = new goog.math.Coordinate(blockXY.x,
blockXY.y + blockBounds.height);
} else {
Vertical shapes pass (#362) * Add if, if-else, equals; remove old if-elses * Naming fixes and removal of a dummy input for if-else * Fix spacing constants; add correct notches. * Fixing inner notches and connections on vertical statements * Fix size of extra row after last statement input * Add minimum block width * Vertical hat shape to spec * Larger vertical minimum block width * Remove INLINE_PADDING_Y and increase MIN_BLOCK_X INLINE_PADDING_Y, a fixed padding for the internal inputs, shouldn't be necessary in Scratch Blocks. Instead, we'll attempt to center the inputs vertically, and give a padding eventually not for inline inputs but rather for non-shadow blocks in inputs... * Remove code for horizontal puzzle tabs * Remove code for "external naked fields" * Start hats are always on in Scratch Blocks * Update vertical playground to start at 75% * Vertical field alignment in vertical rendering * Increase size of vertical green flag icon * Minimum width for blocks with C- or E-. * Remove unused field alignment code * Fix up inner spacing on statement input * Fix overhang to avoid clobbering height calculation * Subtract correct height in getHeightWidth * Subtract notch height in drawing statement bay * Add MIN_STATEMENT_INPUT_HEIGHT * Update size of extra row after statement input * Don't add extra pixel on statement input connection * Fix psuedo-height for blocks with no next connection * Rows after a statement input take the same size as EXTRA_STATEMENT_ROW_Y * Simplify height management to never include notches * Consolidate inputRows.rightEdge calculation * Clean up tab removal * Fix domToWorkspace in vertical_playground.html * Render constant newlines * Updating NOTCH_LEFT_PADDING to NOTCH_START_PADDING * Update comments about vertical field centering; spacing * Remove old comment about baseline * Simplify logic for positioning inline inputs * Ensure inputs in the first row don't overlap with notch
2016-05-27 13:21:40 -04:00
topLeft = new goog.math.Coordinate(blockXY.x, blockXY.y);
bottomRight = new goog.math.Coordinate(blockXY.x + blockBounds.width,
2016-03-18 15:19:26 -07:00
blockXY.y + blockBounds.height);
}
Vertical shapes pass (#362) * Add if, if-else, equals; remove old if-elses * Naming fixes and removal of a dummy input for if-else * Fix spacing constants; add correct notches. * Fixing inner notches and connections on vertical statements * Fix size of extra row after last statement input * Add minimum block width * Vertical hat shape to spec * Larger vertical minimum block width * Remove INLINE_PADDING_Y and increase MIN_BLOCK_X INLINE_PADDING_Y, a fixed padding for the internal inputs, shouldn't be necessary in Scratch Blocks. Instead, we'll attempt to center the inputs vertically, and give a padding eventually not for inline inputs but rather for non-shadow blocks in inputs... * Remove code for horizontal puzzle tabs * Remove code for "external naked fields" * Start hats are always on in Scratch Blocks * Update vertical playground to start at 75% * Vertical field alignment in vertical rendering * Increase size of vertical green flag icon * Minimum width for blocks with C- or E-. * Remove unused field alignment code * Fix up inner spacing on statement input * Fix overhang to avoid clobbering height calculation * Subtract correct height in getHeightWidth * Subtract notch height in drawing statement bay * Add MIN_STATEMENT_INPUT_HEIGHT * Update size of extra row after statement input * Don't add extra pixel on statement input connection * Fix psuedo-height for blocks with no next connection * Rows after a statement input take the same size as EXTRA_STATEMENT_ROW_Y * Simplify height management to never include notches * Consolidate inputRows.rightEdge calculation * Clean up tab removal * Fix domToWorkspace in vertical_playground.html * Render constant newlines * Updating NOTCH_LEFT_PADDING to NOTCH_START_PADDING * Update comments about vertical field centering; spacing * Remove old comment about baseline * Simplify logic for positioning inline inputs * Ensure inputs in the first row don't overlap with notch
2016-05-27 13:21:40 -04:00
2016-03-18 15:19:26 -07:00
return {topLeft: topLeft, bottomRight: bottomRight};
};
/**
* Set block opacity for SVG rendering.
* @param {number} opacity Intended opacity, betweeen 0 and 1
*/
Blockly.BlockSvg.prototype.setOpacity = function(opacity) {
this.opacity_ = opacity;
if (this.rendered) {
this.updateColour();
}
};
/**
* Get block opacity for SVG rendering.
* @return {number} Intended opacity, betweeen 0 and 1
*/
Blockly.BlockSvg.prototype.getOpacity = function() {
return this.opacity_;
};
2014-12-23 11:22:02 -08:00
/**
* Set whether the block is collapsed or not.
* @param {boolean} collapsed True if collapsed.
*/
Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) {
if (this.collapsed_ == collapsed) {
return;
}
var renderList = [];
// Show/hide the inputs.
for (var i = 0, input; input = this.inputList[i]; i++) {
2014-12-23 11:22:02 -08:00
renderList.push.apply(renderList, input.setVisible(!collapsed));
}
var COLLAPSED_INPUT_NAME = '_TEMP_COLLAPSED_INPUT';
if (collapsed) {
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
icons[i].setVisible(false);
2014-12-23 11:22:02 -08:00
}
var text = this.toString(Blockly.COLLAPSE_CHARS);
this.appendDummyInput(COLLAPSED_INPUT_NAME).appendField(text).init();
} else {
this.removeInput(COLLAPSED_INPUT_NAME);
// Clear any warnings inherited from enclosed blocks.
this.setWarningText(null);
2014-12-23 11:22:02 -08:00
}
2015-03-02 12:45:20 -05:00
Blockly.BlockSvg.superClass_.setCollapsed.call(this, collapsed);
2014-12-23 11:22:02 -08:00
if (!renderList.length) {
// No child blocks, just render this block.
renderList[0] = this;
}
if (this.rendered) {
for (var i = 0, block; block = renderList[i]; i++) {
2014-12-23 11:22:02 -08:00
block.render();
}
2015-03-10 17:47:03 -07:00
// Don't bump neighbours.
// Although bumping neighbours would make sense, users often collapse
// all their functions and store them next to each other. Expanding and
// bumping causes all their definitions to go out of alignment.
2014-12-23 11:22:02 -08:00
}
};
2015-10-14 16:23:23 -07:00
/**
* Open the next (or previous) FieldTextInput.
* @param {Blockly.Field|Blockly.Block} start Current location.
* @param {boolean} forward If true go forward, otherwise backward.
*/
Blockly.BlockSvg.prototype.tab = function(start, forward) {
var list = this.createTabList_();
var i = list.indexOf(start);
2015-10-14 16:23:23 -07:00
if (i == -1) {
// No start location, start at the beginning or end.
i = forward ? -1 : list.length;
}
var target = list[forward ? i + 1 : i - 1];
if (!target) {
// Ran off of list.
2017-07-27 15:13:06 -04:00
// If there is an output, tab up to that block.
var outputBlock = this.outputConnection && this.outputConnection.targetBlock();
if (outputBlock) {
outputBlock.tab(this, forward);
} else { // Otherwise, go to next / previous block, depending on value of `forward`
2017-08-03 15:38:55 -04:00
var block = forward ? this.getNextBlock() : this.getPreviousBlock();
if (block) {
block.tab(this, forward);
2017-07-27 15:13:06 -04:00
}
2015-10-14 16:23:23 -07:00
}
} else if (target instanceof Blockly.Field) {
target.showEditor_();
} else {
target.tab(null, forward);
}
};
/**
* Create an ordered list of all text fields and connected inputs.
* @return {!Array.<!Blockly.FieldTextInput|!Blockly.Input>} The ordered list.
* @private
*/
Blockly.BlockSvg.prototype.createTabList_ = function() {
// This function need not be efficient since it runs once on a keypress.
var list = [];
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field instanceof Blockly.FieldTextInput) {
// TODO(# 1276): Also support dropdown fields.
list.push(field);
}
}
if (input.connection) {
var block = input.connection.targetBlock();
if (block) {
list.push(block);
}
}
}
return list;
};
2014-12-23 11:22:02 -08:00
/**
* Handle a mouse-down on an SVG block.
* @param {!Event} e Mouse down event or touch start event.
2014-12-23 11:22:02 -08:00
* @private
*/
Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
var gesture = this.workspace && this.workspace.getGesture(e);
if (gesture) {
gesture.handleBlockStart(e, this);
}
2014-12-23 11:22:02 -08:00
};
/**
* Load the block's help page in a new window.
* @private
*/
Blockly.BlockSvg.prototype.showHelp_ = function() {
var url = goog.isFunction(this.helpUrl) ? this.helpUrl() : this.helpUrl;
2014-12-23 11:22:02 -08:00
if (url) {
// @todo rewrite
alert(url);
2014-12-23 11:22:02 -08:00
}
};
2014-12-23 11:22:02 -08:00
/**
* Show the context menu for this block.
* @param {!Event} e Mouse event.
* @private
*/
Blockly.BlockSvg.prototype.showContextMenu_ = function(e) {
2015-04-28 13:51:25 -07:00
if (this.workspace.options.readOnly || !this.contextMenu) {
2014-12-23 11:22:02 -08:00
return;
}
// Save the current block in a variable for use in closures.
var block = this;
var menuOptions = [];
2014-12-23 11:22:02 -08:00
if (this.isDeletable() && this.isMovable() && !block.isInFlyout) {
2018-10-23 13:47:04 -07:00
menuOptions.push(
Blockly.ContextMenu.blockDuplicateOption(block, e));
if (this.isEditable() && this.workspace.options.comments) {
menuOptions.push(Blockly.ContextMenu.blockCommentOption(block));
2014-12-23 11:22:02 -08:00
}
menuOptions.push(Blockly.ContextMenu.blockDeleteOption(block));
2017-02-20 10:30:32 -05:00
} else if (this.parentBlock_ && this.isShadow_) {
2017-02-20 10:13:43 -05:00
this.parentBlock_.showContextMenu_(e);
2017-02-20 10:18:58 -05:00
return;
2014-12-23 11:22:02 -08:00
}
// Allow the block to add or modify menuOptions.
2017-06-29 09:57:59 -07:00
if (this.customContextMenu) {
this.customContextMenu(menuOptions);
2014-12-23 11:22:02 -08:00
}
Blockly.ContextMenu.show(e, menuOptions, this.RTL);
2014-12-23 11:22:02 -08:00
Blockly.ContextMenu.currentBlock = this;
};
/**
* Move the connections for this block and all blocks attached under it.
* Also update any attached bubbles.
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
* @param {number} dx Horizontal offset from current location, in workspace
* units.
* @param {number} dy Vertical offset from current location, in workspace
* units.
2014-12-23 11:22:02 -08:00
* @private
*/
Blockly.BlockSvg.prototype.moveConnections_ = function(dx, dy) {
if (!this.rendered) {
// Rendering is required to lay out the blocks.
// This is probably an invisible block attached to a collapsed block.
return;
}
var myConnections = this.getConnections_(false);
for (var i = 0; i < myConnections.length; i++) {
myConnections[i].moveBy(dx, dy);
2014-12-23 11:22:02 -08:00
}
var icons = this.getIcons();
for (i = 0; i < icons.length; i++) {
icons[i].computeIconLocation();
2014-12-23 11:22:02 -08:00
}
// Recurse through all blocks attached under this one.
for (i = 0; i < this.childBlocks_.length; i++) {
this.childBlocks_[i].moveConnections_(dx, dy);
2014-12-23 11:22:02 -08:00
}
};
/**
* Recursively adds or removes the dragging class to this node and its children.
* @param {boolean} adding True if adding, false if removing.
* @package
2014-12-23 11:22:02 -08:00
*/
Blockly.BlockSvg.prototype.setDragging = function(adding) {
2014-12-23 11:22:02 -08:00
if (adding) {
var group = this.getSvgRoot();
group.translate_ = '';
group.skew_ = '';
Blockly.draggingConnections_ =
Blockly.draggingConnections_.concat(this.getConnections_(true));
Blockly.utils.addClass(
/** @type {!Element} */ (this.svgGroup_), 'blocklyDragging');
2014-12-23 11:22:02 -08:00
} else {
Blockly.draggingConnections_ = [];
Blockly.utils.removeClass(
/** @type {!Element} */ (this.svgGroup_), 'blocklyDragging');
2014-12-23 11:22:02 -08:00
}
// Recurse through all blocks attached under this one.
for (var i = 0; i < this.childBlocks_.length; i++) {
this.childBlocks_[i].setDragging(adding);
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * 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 * 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. * 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 * 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. * 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. * Add a block to reverse a list (#844) * 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) * .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 * 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. * 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 * 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. * 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. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
}
};
/**
* Add or remove the UI indicating if this block is movable or not.
*/
Blockly.BlockSvg.prototype.updateMovable = function() {
2014-12-23 11:22:02 -08:00
if (this.isMovable()) {
Blockly.utils.addClass(
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable');
} else {
Blockly.utils.removeClass(
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggable');
}
};
2015-04-28 13:51:25 -07:00
/**
* Set whether this block is movable or not.
* @param {boolean} movable True if movable.
*/
Blockly.BlockSvg.prototype.setMovable = function(movable) {
Blockly.BlockSvg.superClass_.setMovable.call(this, movable);
this.updateMovable();
};
/**
* Set whether this block is editable or not.
2016-02-16 13:04:47 -08:00
* @param {boolean} editable True if editable.
*/
Blockly.BlockSvg.prototype.setEditable = function(editable) {
Blockly.BlockSvg.superClass_.setEditable.call(this, editable);
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
icons[i].updateEditable();
}
};
/**
* Set whether this block is a shadow block or not.
* @param {boolean} shadow True if a shadow.
*/
Blockly.BlockSvg.prototype.setShadow = function(shadow) {
Blockly.BlockSvg.superClass_.setShadow.call(this, shadow);
this.updateColour();
};
2016-02-23 14:46:04 -08:00
/**
2016-04-06 14:42:12 -07:00
* Set whether this block is an insertion marker block or not.
* @param {boolean} insertionMarker True if an insertion marker.
* @param {Number=} opt_minWidth Optional minimum width of the marker.
2016-02-23 14:46:04 -08:00
*/
Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker, opt_minWidth) {
2016-04-06 14:42:12 -07:00
Blockly.BlockSvg.superClass_.setInsertionMarker.call(this, insertionMarker);
this.insertionMarkerMinWidth_ = opt_minWidth;
2016-02-23 14:46:04 -08:00
this.updateColour();
};
/**
2014-12-23 11:22:02 -08:00
* Return the root node of the SVG or null if none exists.
* @return {Element} The root SVG node (probably a group).
*/
2014-12-23 11:22:02 -08:00
Blockly.BlockSvg.prototype.getSvgRoot = function() {
return this.svgGroup_;
};
/**
2014-12-23 11:22:02 -08:00
* Dispose of this block.
* @param {boolean} healStack If true, then try to heal any gap by connecting
* the next statement with the previous statement. Otherwise, dispose of
* all children of this block.
* @param {boolean} animate If true, show a disposal animation and sound.
*/
Blockly.BlockSvg.prototype.dispose = function(healStack, animate) {
if (!this.workspace) {
// The block has already been deleted.
return;
}
Merge upstream may 24 (#352) * Localisation updates from https://translatewiki.net. * Initialize generated JS and Dart variables in one line. * proxy option for build.py * Localisation updates from https://translatewiki.net. * Revert "proxy option for build.py" * Prevent sounds from playing on top of each other. * Routine recompile. * Remove sound and animation on delete during undo/redo. * Accessible demo (#373) * adding a folder in demos for blind and setting up the package.json file for development. Adding package.json to .gitignore * removing gitignore~ file * copied blind blockly demo code over. set up a new dev environment. Up for review: the blind blockly demo code. Much of the drop downs don't actually do anything, but a general look at the way angular is used would be helpful in shaping future development. * adding an index file that was being ignored by .gitignore * adding required angular files and libraries previously ignored by git add --a for some unknown reason. * starting work on toolbox * got workspace and toolbox connected. Copy to workspace annd copy to clipboard working at 80%. * cleaning up autogenerated files * adding my own files. Not sure why the test files are being added. * cleaning up comments * removed empty html_formatter.html file from project and put on git ignore list. The file is used on my end to help with formatting the html in javascript files. * getting rid of unnecessary html_formatter file * removing merge conflicts * cleaned up comments * cleaned up comments, organized file structure, made ToolboxXML a file that can be changed by other developers porting this code, added copyright and file summaries to js files, linted files, moved third party libraries to lib folder * removing lint files that shouldn't be tracked. * Made the clipboard a service instead of multiple pieces embedded within the app. Not sold on the name ClipboardService. Open to suggestions. * syncing up demo updates * adding insert block menus above and below appropriate blocks. * hacky version of getting code to run. * changing toolbox to be a menu. making both the toolbox and workspace ordered lists * adding new folder dev-old containing a version of blind blockly that uses nested lists for the toolbox * getting rid of menubar experiment * adding treeview shenanigans part 1 * adding treeview experiment page and finishing up treeview. * getting a treeview implementation working in the toolbox * creating a fishfood folder for fishfood development * making first level of fishfood * fixing something * adding index file for fishfood * beginning merging the treeview system. * creating two treeviews * fishfood level 1 without working music blocks * fixes to treeview navigation * final fishfood features done * adding support for toolboxes without categories * beginning integration of Sean's new music code * adding Sean's music blocks and beginning music_player integration. * merged Sean's music block code into fishfood * merged Sean's music code and fixed treeview bug with toolbox when no categories * adding blank_demo * fixing tab navigation. * fixing bug with shift-tab. New bug found in alt+tab not opening dropdown? * fixing labels * fixing bugs and finding more. * removing dropdowns in favor of buttons part 1. Still need to change field options. * index.html for blank_demo * beginning cleanup * adding blockly- prefix to label ids. * integrating AccessibleBlockly with Blockly library. * remove closure library * removing testing files that aren't in develop * removing all demo stuff for a later pull request * removing gitignore file that doesn't exist in developer branch * syncing with develop branch files * removing music files from this pull request * doing some lint cleanup * rolling back accidental package.json change * removing var blocklyApp = blocklyApp || {} from each extraneous file * adding last debug statement * changed name of inputType function * renaming _service arguments * fixing function names * fixing all comments. * fixing minor comments * renaming variables, etc * fixing bugs that break demo. Adding the run code and clear workspace buttons back to the workspaceview as their current position breaks tab navigation. * fixing minor comments * fixing function names, etc. * adding comments to getInputTypeLabel function * removing addClass() calls from the template * small change to clipboardService * splitting getCategoryDependantId into two functions: getCategoryId and setActiveDesc * fixing minor bug with last commit * using conditional attributes to remove setActiveAttributes function from treeService and do same work in template. * deleting unnecessary comment created in previous commit. * adding a utilsService to remove duplicated code. * changing function names in utilsService * changing delete to [delete] to allow HTMLText functions to return an empty string instead of undefined. Also renaming concatStringWithSpaces to generateAriaLabelledByAttr * generating ids in ngOnInit instead of on the fly, allowing us to use [attr.aria-labelledBy] in the template instead of using setLabelledBy(element). Deleting function utilsService.setLabelledBy. * fixing small bug with tree service left arrow: was throwing an error when you can't go any further left. * reformatting html to make it easier to read. * moving from importing the xml file to using an xml toolbox in the demo. * fixing minor bugs and removing code relevant only to the music game. * minor fixes * adding alerts to copy, paste, and mark actions. renaming blocklyApp.TreeView to blocklyApp.WorkspaceTreeView * Beginning to add Blockly.msg strings. * making sure index file is being tracked * adding all demo bits * removing demo files from this pull request * fixing providers, some linting, and removing getInfo() function. * adding small todo comment for sll@ * adding minimal blockly accessible demo * removing unnecessary files * putting package file back * fixing package file * fixing msg file * fixing boot.js file * fixing boot.js file * fixing indentation on boot * fixing indentation on index file. * AccessibleBlockly (#354) * adding a folder in demos for blind and setting up the package.json file for development. Adding package.json to .gitignore * removing gitignore~ file * copied blind blockly demo code over. set up a new dev environment. Up for review: the blind blockly demo code. Much of the drop downs don't actually do anything, but a general look at the way angular is used would be helpful in shaping future development. * adding an index file that was being ignored by .gitignore * adding required angular files and libraries previously ignored by git add --a for some unknown reason. * starting work on toolbox * got workspace and toolbox connected. Copy to workspace annd copy to clipboard working at 80%. * cleaning up autogenerated files * adding my own files. Not sure why the test files are being added. * cleaning up comments * removed empty html_formatter.html file from project and put on git ignore list. The file is used on my end to help with formatting the html in javascript files. * getting rid of unnecessary html_formatter file * removing merge conflicts * cleaned up comments * cleaned up comments, organized file structure, made ToolboxXML a file that can be changed by other developers porting this code, added copyright and file summaries to js files, linted files, moved third party libraries to lib folder * removing lint files that shouldn't be tracked. * Made the clipboard a service instead of multiple pieces embedded within the app. Not sold on the name ClipboardService. Open to suggestions. * syncing up demo updates * adding insert block menus above and below appropriate blocks. * hacky version of getting code to run. * changing toolbox to be a menu. making both the toolbox and workspace ordered lists * adding new folder dev-old containing a version of blind blockly that uses nested lists for the toolbox * getting rid of menubar experiment * adding treeview shenanigans part 1 * adding treeview experiment page and finishing up treeview. * getting a treeview implementation working in the toolbox * creating a fishfood folder for fishfood development * making first level of fishfood * fixing something * adding index file for fishfood * beginning merging the treeview system. * creating two treeviews * fishfood level 1 without working music blocks * fixes to treeview navigation * final fishfood features done * adding support for toolboxes without categories * beginning integration of Sean's new music code * adding Sean's music blocks and beginning music_player integration. * merged Sean's music block code into fishfood * merged Sean's music code and fixed treeview bug with toolbox when no categories * adding blank_demo * fixing tab navigation. * fixing bug with shift-tab. New bug found in alt+tab not opening dropdown? * fixing labels * fixing bugs and finding more. * removing dropdowns in favor of buttons part 1. Still need to change field options. * index.html for blank_demo * beginning cleanup * adding blockly- prefix to label ids. * integrating AccessibleBlockly with Blockly library. * remove closure library * removing testing files that aren't in develop * removing all demo stuff for a later pull request * removing gitignore file that doesn't exist in developer branch * syncing with develop branch files * removing music files from this pull request * doing some lint cleanup * rolling back accidental package.json change * removing var blocklyApp = blocklyApp || {} from each extraneous file * adding last debug statement * changed name of inputType function * renaming _service arguments * fixing function names * fixing all comments. * fixing minor comments * renaming variables, etc * fixing bugs that break demo. Adding the run code and clear workspace buttons back to the workspaceview as their current position breaks tab navigation. * fixing minor comments * fixing function names, etc. * adding comments to getInputTypeLabel function * removing addClass() calls from the template * small change to clipboardService * splitting getCategoryDependantId into two functions: getCategoryId and setActiveDesc * fixing minor bug with last commit * using conditional attributes to remove setActiveAttributes function from treeService and do same work in template. * deleting unnecessary comment created in previous commit. * adding a utilsService to remove duplicated code. * changing function names in utilsService * changing delete to [delete] to allow HTMLText functions to return an empty string instead of undefined. Also renaming concatStringWithSpaces to generateAriaLabelledByAttr * generating ids in ngOnInit instead of on the fly, allowing us to use [attr.aria-labelledBy] in the template instead of using setLabelledBy(element). Deleting function utilsService.setLabelledBy. * fixing small bug with tree service left arrow: was throwing an error when you can't go any further left. * reformatting html to make it easier to read. * moving from importing the xml file to using an xml toolbox in the demo. * fixing minor bugs and removing code relevant only to the music game. * minor fixes * adding alerts to copy, paste, and mark actions. renaming blocklyApp.TreeView to blocklyApp.WorkspaceTreeView * Beginning to add Blockly.msg strings. * making sure index file is being tracked * adding all demo bits * removing demo files from this pull request * fixing providers, some linting, and removing getInfo() function. * adding small todo comment for sll@ * adding minimal Accessible Blockly demo * removing demo: accidentally committed to wrong branch * fixing Blockly.Msg string bugs * fixing TODOs * package file changed by an automerge. Changing back. * addressing sll's comments. Creating shim for utilsService functions. * fixing comments, changing fieldview to deal with this.field. * fixing clipboard service bug * fixing focus bug when editing a text input. * fixed clipboard bug and added README * fixing workspaceview not to implement on runCode() function and adding note to README * Cleanup accessible Blockly. * Recompile May 24
2016-05-24 14:44:04 -04:00
Blockly.Tooltip.hide();
Blockly.Field.startCache();
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
// Save the block's workspace temporarily so we can resize the
// contents once the block is disposed.
var blockWorkspace = this.workspace;
2015-04-28 13:51:25 -07:00
// If this block is being dragged, unlink the mouse events.
if (Blockly.selected == this) {
this.unselect();
this.workspace.cancelCurrentGesture();
2015-04-28 13:51:25 -07:00
}
2014-12-23 11:22:02 -08:00
// If this block has a context menu open, close it.
if (Blockly.ContextMenu.currentBlock == this) {
Blockly.ContextMenu.hide();
}
if (animate && this.rendered) {
2016-02-01 16:13:05 -08:00
this.unplug(healStack);
Blockly.BlockAnimations.disposeUiEffect(this);
2014-12-23 11:22:02 -08:00
}
// Stop rerendering.
this.rendered = false;
Blockly.Events.disable();
try {
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
icons[i].dispose();
}
} finally {
Blockly.Events.enable();
2014-12-23 11:22:02 -08:00
}
Blockly.BlockSvg.superClass_.dispose.call(this, healStack);
2014-12-23 11:22:02 -08:00
goog.dom.removeNode(this.svgGroup_);
blockWorkspace.resizeContents();
// Sever JavaScript to DOM connections.
this.svgGroup_ = null;
this.svgPath_ = null;
Blockly.Field.stopCache();
};
/**
* Enable or disable a block.
*/
Blockly.BlockSvg.prototype.updateDisabled = function() {
// not supported
2014-12-23 11:22:02 -08:00
};
/**
* Returns the comment on this block (or '' if none).
* @return {string} Block's comment.
*/
Blockly.BlockSvg.prototype.getCommentText = function() {
if (this.comment) {
var comment = this.comment.getText();
// Trim off trailing whitespace.
return comment.replace(/\s+$/, '').replace(/ +\n/g, '\n');
}
return '';
};
/**
* Set this block's comment text.
* @param {?string} text The text, or null to delete.
* @param {string=} commentId Id of the comment, or a new one will be generated if not provided.
* @param {number=} commentX Optional x position for scratch comment in workspace coordinates
* @param {number=} commentY Optional y position for scratch comment in workspace coordinates
* @param {boolean=} minimized Optional minimized state for scratch comment, defaults to false
2014-12-23 11:22:02 -08:00
*/
Blockly.BlockSvg.prototype.setCommentText = function(text, commentId,
commentX, commentY, minimized) {
2014-12-23 11:22:02 -08:00
var changedState = false;
if (goog.isString(text)) {
2014-12-23 11:22:02 -08:00
if (!this.comment) {
this.comment = new Blockly.ScratchBlockComment(this, text, commentId,
commentX, commentY, minimized);
2014-12-23 11:22:02 -08:00
changedState = true;
} else {
this.comment.setText(/** @type {string} */ (text));
2014-12-23 11:22:02 -08:00
}
} else {
if (this.comment) {
this.comment.dispose();
changedState = true;
}
}
if (changedState && this.rendered) {
this.render();
if (goog.isString(text)) {
2018-05-25 17:21:31 -04:00
this.comment.setVisible(true);
}
2014-12-23 11:22:02 -08:00
// Adding or removing a comment icon will cause the block to change shape.
this.bumpNeighbours_();
}
};
/**
* Set this block's warning text.
* @param {?string} text The text, or null to delete.
* @param {string=} opt_id An optional ID for the warning text to be able to
* maintain multiple warnings.
2014-12-23 11:22:02 -08:00
*/
Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) {
if (!this.setWarningText.pid_) {
// Create a database of warning PIDs.
// Only runs once per block (and only those with warnings).
this.setWarningText.pid_ = Object.create(null);
}
var id = opt_id || '';
if (!id) {
// Kill all previous pending processes, this edit supersedes them all.
for (var n in this.setWarningText.pid_) {
clearTimeout(this.setWarningText.pid_[n]);
delete this.setWarningText.pid_[n];
}
} else if (this.setWarningText.pid_[id]) {
2015-02-25 15:07:04 -08:00
// Only queue up the latest change. Kill any earlier pending process.
clearTimeout(this.setWarningText.pid_[id]);
delete this.setWarningText.pid_[id];
2015-02-25 15:07:04 -08:00
}
if (this.workspace.isDragging()) {
2015-02-25 15:07:04 -08:00
// Don't change the warning text during a drag.
// Wait until the drag finishes.
var thisBlock = this;
this.setWarningText.pid_[id] = setTimeout(function() {
if (thisBlock.workspace) { // Check block wasn't deleted.
delete thisBlock.setWarningText.pid_[id];
thisBlock.setWarningText(text, id);
}
2015-02-25 15:07:04 -08:00
}, 100);
return;
}
2014-12-23 11:22:02 -08:00
if (this.isInFlyout) {
text = null;
}
2014-12-23 11:22:02 -08:00
var changedState = false;
if (goog.isString(text)) {
2014-12-23 11:22:02 -08:00
if (!this.warning) {
this.warning = new Blockly.Warning(this);
changedState = true;
}
this.warning.setText(/** @type {string} */ (text), id);
2014-12-23 11:22:02 -08:00
} else {
// Dispose all warnings if no ID is given.
if (this.warning && !id) {
2014-12-23 11:22:02 -08:00
this.warning.dispose();
changedState = true;
} else if (this.warning) {
var oldText = this.warning.getText();
this.warning.setText('', id);
var newText = this.warning.getText();
if (!newText) {
this.warning.dispose();
}
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * 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 * 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. * 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 * 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. * 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. * Add a block to reverse a list (#844) * 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) * .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 * 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. * 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 * 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. * 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. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
changedState = oldText != newText;
2014-12-23 11:22:02 -08:00
}
}
if (changedState && this.rendered) {
this.render();
// Adding or removing a warning icon will cause the block to change shape.
this.bumpNeighbours_();
}
};
/**
* Give this block a mutator dialog.
* @param {Blockly.Mutator} mutator A mutator dialog instance or null to remove.
*/
Blockly.BlockSvg.prototype.setMutator = function(mutator) {
if (this.mutator && this.mutator !== mutator) {
this.mutator.dispose();
}
if (mutator) {
mutator.block_ = this;
this.mutator = mutator;
2015-12-17 14:16:04 -08:00
mutator.createIcon();
2014-12-23 11:22:02 -08:00
}
};
/**
* Select this block. Highlight it visually.
*/
Blockly.BlockSvg.prototype.addSelect = function() {
Blockly.utils.addClass(
/** @type {!Element} */ (this.svgGroup_), 'blocklySelected');
};
/**
* Unselect this block. Remove its highlighting.
*/
Blockly.BlockSvg.prototype.removeSelect = function() {
Blockly.utils.removeClass(
/** @type {!Element} */ (this.svgGroup_), 'blocklySelected');
};
2018-02-12 12:25:09 -05:00
/**
* Update the cursor over this block by adding or removing a class.
* @param {boolean} letMouseThrough True if the blocks should ignore pointer
2018-02-12 12:25:09 -05:00
* events, false otherwise.
* @package
*/
Blockly.BlockSvg.prototype.setMouseThroughStyle = function(letMouseThrough) {
if (letMouseThrough) {
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyDraggingMouseThrough');
} else {
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyDraggingMouseThrough');
}
};
/**
* Update the cursor over this block by adding or removing a class.
* @param {boolean} enable True if the delete cursor should be shown, false
* otherwise.
* @package
*/
Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) {
if (enable) {
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyDraggingDelete');
} else {
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyDraggingDelete');
}
};
// Overrides of functions on Blockly.Block that take into account whether the
// block has been rendered.
/**
* Change the colour of a block.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
* @param {number|string} colourSecondary Secondary HSV hue value, or #RRGGBB
* string.
* @param {number|string} colourTertiary Tertiary HSV hue value, or #RRGGBB
* string.
* @param {number|string} colourQuaternary Quaternary HSV hue value, or #RRGGBB
* string.
*/
Blockly.BlockSvg.prototype.setColour = function(colour, colourSecondary,
colourTertiary, colourQuaternary) {
Blockly.BlockSvg.superClass_.setColour.call(this, colour, colourSecondary,
colourTertiary, colourQuaternary);
if (this.rendered) {
this.updateColour();
}
};
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
/**
* Move this block to the front of the visible workspace.
* <g> tags do not respect z-index so SVG renders them in the
* order that they are in the DOM. By placing this block first within the
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
* block group's <g>, it will render on top of any other blocks.
* @package
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
*/
Blockly.BlockSvg.prototype.bringToFront = function() {
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
var block = this;
do {
var root = block.getSvgRoot();
root.parentNode.appendChild(root);
block = block.getParent();
} while (block);
};
/**
* Set whether this block can chain onto the bottom of another block.
* @param {boolean} newBoolean True if there can be a previous statement.
* @param {(string|Array.<string>|null)=} opt_check Statement type or
* list of statement types. Null/undefined if any type could be connected.
*/
Blockly.BlockSvg.prototype.setPreviousStatement = function(newBoolean,
opt_check) {
Blockly.BlockSvg.superClass_.setPreviousStatement.call(this, newBoolean,
opt_check);
if (this.rendered) {
this.render();
this.bumpNeighbours_();
}
};
/**
* Set whether another block can chain onto the bottom of this block.
* @param {boolean} newBoolean True if there can be a next statement.
* @param {(string|Array.<string>|null)=} opt_check Statement type or
* list of statement types. Null/undefined if any type could be connected.
*/
Blockly.BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) {
Blockly.BlockSvg.superClass_.setNextStatement.call(this, newBoolean,
opt_check);
if (this.rendered) {
this.render();
this.bumpNeighbours_();
}
};
/**
* Set whether this block returns a value.
* @param {boolean} newBoolean True if there is an output.
* @param {(string|Array.<string>|null)=} opt_check Returned type or list
* of returned types. Null or undefined if any type could be returned
* (e.g. variable get).
*/
Blockly.BlockSvg.prototype.setOutput = function(newBoolean, opt_check) {
Blockly.BlockSvg.superClass_.setOutput.call(this, newBoolean, opt_check);
if (this.rendered) {
this.render();
this.bumpNeighbours_();
}
};
/**
* Set whether value inputs are arranged horizontally or vertically.
* @param {boolean} newBoolean True if inputs are horizontal.
*/
Blockly.BlockSvg.prototype.setInputsInline = function(newBoolean) {
Blockly.BlockSvg.superClass_.setInputsInline.call(this, newBoolean);
if (this.rendered) {
this.render();
this.bumpNeighbours_();
}
};
/**
* Remove an input from this block.
* @param {string} name The name of the input.
* @param {boolean=} opt_quiet True to prevent error if input is not present.
* @throws {goog.asserts.AssertionError} if the input is not present and
* opt_quiet is not true.
*/
Blockly.BlockSvg.prototype.removeInput = function(name, opt_quiet) {
Blockly.BlockSvg.superClass_.removeInput.call(this, name, opt_quiet);
if (this.rendered) {
this.render();
// Removing an input will cause the block to change shape.
this.bumpNeighbours_();
}
};
/**
* Move a numbered input to a different location on this block.
* @param {number} inputIndex Index of the input to move.
* @param {number} refIndex Index of input that should be after the moved input.
*/
Blockly.BlockSvg.prototype.moveNumberedInputBefore = function(
inputIndex, refIndex) {
Blockly.BlockSvg.superClass_.moveNumberedInputBefore.call(this, inputIndex,
refIndex);
if (this.rendered) {
this.render();
// Moving an input will cause the block to change shape.
this.bumpNeighbours_();
}
};
/**
* Add a value input, statement input or local variable to this block.
* @param {number} type Either Blockly.INPUT_VALUE or Blockly.NEXT_STATEMENT or
* Blockly.DUMMY_INPUT.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
* @private
*/
Blockly.BlockSvg.prototype.appendInput_ = function(type, name) {
var input = Blockly.BlockSvg.superClass_.appendInput_.call(this, type, name);
if (this.rendered) {
this.render();
// Adding an input will cause the block to change shape.
this.bumpNeighbours_();
}
return input;
};
/**
* Returns connections originating from this block.
* @param {boolean} all If true, return all connections even hidden ones.
* Otherwise, for a non-rendered block return an empty list, and for a
* collapsed block don't return inputs connections.
* @return {!Array.<!Blockly.Connection>} Array of connections.
* @package
*/
Blockly.BlockSvg.prototype.getConnections_ = function(all) {
var myConnections = [];
if (all || this.rendered) {
if (this.outputConnection) {
myConnections.push(this.outputConnection);
}
if (this.previousConnection) {
myConnections.push(this.previousConnection);
}
if (this.nextConnection) {
myConnections.push(this.nextConnection);
}
if (all || !this.collapsed_) {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection) {
myConnections.push(input.connection);
}
}
}
}
return myConnections;
};
2016-05-10 15:39:37 -07:00
/**
* Create a connection of the specified type.
* @param {number} type The type of the connection to create.
* @return {!Blockly.RenderedConnection} A new connection of the specified type.
* @private
*/
Blockly.BlockSvg.prototype.makeConnection_ = function(type) {
return new Blockly.RenderedConnection(this, type);
};
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
/**
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
* connected should not coincidentally line up on screen.
* @private
*/
Blockly.BlockSvg.prototype.bumpNeighbours_ = function() {
if (!this.workspace) {
return; // Deleted block.
}
if (this.workspace.isDragging()) {
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; // Don't bump blocks during a drag.
}
var rootBlock = this.getRootBlock();
if (rootBlock.isInFlyout) {
return; // Don't move blocks around in a flyout.
}
// Loop through every connection on this block.
var myConnections = this.getConnections_(false);
for (var i = 0, connection; connection = myConnections[i]; i++) {
// Spider down from this block bumping all sub-blocks.
if (connection.isConnected() && connection.isSuperior()) {
connection.targetBlock().bumpNeighbours_();
}
var neighbours = connection.neighbours_(Blockly.SNAP_RADIUS);
for (var j = 0, otherConnection; otherConnection = neighbours[j]; j++) {
// If both connections are connected, that's probably fine. But if
// either one of them is unconnected, then there could be confusion.
if (!connection.isConnected() || !otherConnection.isConnected()) {
// Only bump blocks if they are from different tree structures.
if (otherConnection.getSourceBlock().getRootBlock() != rootBlock) {
// Always bump the inferior block.
if (connection.isSuperior()) {
otherConnection.bumpAwayFrom_(connection);
} else {
connection.bumpAwayFrom_(otherConnection);
}
}
}
}
}
};
/**
* Schedule snapping to grid and bumping neighbours to occur after a brief
* delay.
* @package
*/
Blockly.BlockSvg.prototype.scheduleSnapAndBump = function() {
var block = this;
// Ensure that any snap and bump are part of this move's event group.
var group = Blockly.Events.getGroup();
setTimeout(function() {
Blockly.Events.setGroup(group);
block.snapToGrid();
Blockly.Events.setGroup(false);
}, Blockly.BUMP_DELAY / 2);
setTimeout(function() {
Blockly.Events.setGroup(group);
block.bumpNeighbours_();
Blockly.Events.setGroup(false);
}, Blockly.BUMP_DELAY);
};