mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
* Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * 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 * Appease eslint: semicolons and such. * Deserialization variables at top. * Setting up accessible Blockly for Closure compilation. (#1134) Moving closure compilation into the build file. Fixing up goog.requires for accessible blockly. Adding accessible to the build script. * Fix #1109 * Adding command-line options to the buildscript. (#1136) * Fix for travis-ci testing failure (#1141) It looks like the default configuration for Travis might have changed. Adding a manual step to install webdriverio. * Convert text_join block to JSON + mutator format (#1140) * Clean up and create test utilities file. * Add BLOCK events and constructor tests. * Convert more text blocks to json (#1147) * Convert more text blocks to json Converts the mutator blocks for text_join and the text_append block to JSON format. * Fixing modals so they're announced on focus, and changing variables t… (#1030) * Fixing modals so they're announced on focus, and changing variables to only react to enter, not onChange. * Adding a temp index. * Whoops - added it in the wrong spot. * Adding automatically-generated variable lists to the accessible toolbox. (#1149) Fixing a bug with the core-only uncompressed file not finding its own directory. * Field Variable setValue() looks up variable. * Wrap Error in Try Finally Block. * Changing the build file to allow forced rebuilding of the msg files. (#1158) * Split flyout into flyout_base, flyout_horizontal, and flyou_vertical * Rename flyout to flyout_base * flyout_base minus horizontal and vertical code * Add flyout_vertical and flyout_horizontal * review fixes + toolbox and workspace use * Fix hat block case * rebuild uncompressed * Fix travis problem * Fix build problem * Add VAR events. * Correctly named block events called. * Fire VAR events and test. * Create utility function for checking variable values. * In DropdownCreate check for Msg.DELETE_VARIABLE. * Test Delete Variable Twice. * Convert more text blocks to JSON format (#1163) * Convert more text blocks to JSON format Converts text_charAt, text_indexOf, text_isEmpty, and text_length to JSON. Includes a rebuild to pick up message changes. * Fixing the accessible variable stuff so it interacts correctly with (#1170) variableMap. * createVariable in workspaceSvg takes in id and type. * Followup RefreshToolbox. * Fixing an error with block messages and ordering. (#1171) * Remove out of date todo comments. * Fix checkbox delete bug. * Fixing variable dropdowns so they select the correct option. (#1184) * Always open flyout fields are editable. * Fixing the tree service so it doesn't treat unknown block deletion (#1182) as an error, and turning off keypresses on the workspace when the variable modals are open. * Revamping mostly gesture tests. * Merge master to develop (#1189) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Rebuild compressed files * Add some translatewiki annotations back into msg/messages.js * Rebuild msg files * Fix flyout dropdown bug. * Fix python and php procedures. * Dropdown Create does not create a missing variable twice. * Fire field variable change event with variable value, not name. * Fix #1160 (#1197) Fix "Connection UI Effect not playing on block connect" * Only add a block in the flyout if it is not disabled (#1204) * Only add a block in the flyout if it is not disabled * PR feedback * remove previous fix * Fix issue with compression stripping dropdown options (#1207) * Change the build process to be deterministic (#1154) * Change the Blockly build process to be deterministic across machines. * A couple more missed locations for deterministic ordering. * Modularize Rename Variable prompt and allow custom context menus for flyout. * Adding BlocklyDevTools.Analytics (#1217) Adding BlocklyDevTools.Analytics, an interface for integrating an analytics library to track basic usage, including: * navigation. * saving, importing, and exporting. * warnings and errors. * Modify the colour_rgb function to match other languages (#1210) There are two tests fail before modifying the color_rgb function because it behaves differently in Dart and in other languages. In Dart, this function takes parameters ranging from 0 to 1.0 while in other languages such as Lua the counterpart function takes parameters ranging from 0 to 100. Now I have modified it to let it behave the same as other languages. * Fix code generation for procedures (PHP, Python). * Typo in a deprecated variable's value (#1228) Misspelled variable name, should be Blockly.PROCEDURE_CATEGORY_NAME. * Use the same math for dragging blocks out of horizontal and vertical flyouts. (#1215) * Use the same math for dragging blocks out of horizontal and vertical flyouts. * Update flyout_base.js * Add VariableType checks. * Add opt_type to Blockly.Variables.CreateVariable. * Fix Blockly.Procedures.isNameUsed return values. Add tests for Procedures.isNameUsed() so this bug never happens again. * Compatibility for Closure Compiler. (#1240) * Master to develop 07 31 17 (#1243) * Rebuild for master push * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Enable google/blockly with continuous build on travis ci (#1023) * 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 * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Merge develop into master (#1064) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Develop to master (#1209) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * 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 * Appease eslint: semicolons and such. * Deserialization variables at top. * Setting up accessible Blockly for Closure compilation. (#1134) Moving closure compilation into the build file. Fixing up goog.requires for accessible blockly. Adding accessible to the build script. * Fix #1109 * Adding command-line options to the buildscript. (#1136) * Fix for travis-ci testing failure (#1141) It looks like the default configuration for Travis might have changed. Adding a manual step to install webdriverio. * Convert text_join block to JSON + mutator format (#1140) * Clean up and create test utilities file. * Add BLOCK events and constructor tests. * Convert more text blocks to json (#1147) * Convert more text blocks to json Converts the mutator blocks for text_join and the text_append block to JSON format. * Fixing modals so they're announced on focus, and changing variables t… (#1030) * Fixing modals so they're announced on focus, and changing variables to only react to enter, not onChange. * Adding a temp index. * Whoops - added it in the wrong spot. * Adding automatically-generated variable lists to the accessible toolbox. (#1149) Fixing a bug with the core-only uncompressed file not finding its own directory. * Field Variable setValue() looks up variable. * Wrap Error in Try Finally Block. * Changing the build file to allow forced rebuilding of the msg files. (#1158) * Split flyout into flyout_base, flyout_horizontal, and flyou_vertical * Rename flyout to flyout_base * flyout_base minus horizontal and vertical code * Add flyout_vertical and flyout_horizontal * review fixes + toolbox and workspace use * Fix hat block case * rebuild uncompressed * Fix travis problem * Fix build problem * Add VAR events. * Correctly named block events called. * Fire VAR events and test. * Create utility function for checking variable values. * In DropdownCreate check for Msg.DELETE_VARIABLE. * Test Delete Variable Twice. * Convert more text blocks to JSON format (#1163) * Convert more text blocks to JSON format Converts text_charAt, text_indexOf, text_isEmpty, and text_length to JSON. Includes a rebuild to pick up message changes. * Fixing the accessible variable stuff so it interacts correctly with (#1170) variableMap. * createVariable in workspaceSvg takes in id and type. * Followup RefreshToolbox. * Fixing an error with block messages and ordering. (#1171) * Remove out of date todo comments. * Fix checkbox delete bug. * Fixing variable dropdowns so they select the correct option. (#1184) * Always open flyout fields are editable. * Fixing the tree service so it doesn't treat unknown block deletion (#1182) as an error, and turning off keypresses on the workspace when the variable modals are open. * Revamping mostly gesture tests. * Merge master to develop (#1189) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Rebuild compressed files * Add some translatewiki annotations back into msg/messages.js * Rebuild msg files * Fix flyout dropdown bug. * Fix python and php procedures. * Dropdown Create does not create a missing variable twice. * Fire field variable change event with variable value, not name. * Fix #1160 (#1197) Fix "Connection UI Effect not playing on block connect" * Only add a block in the flyout if it is not disabled (#1204) * Only add a block in the flyout if it is not disabled * PR feedback * remove previous fix * Fix issue with compression stripping dropdown options (#1207) * Get some accessible files back from develop * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Rebuild all the things * Fix Blockly.Procedures.isNameUsed return values. Add tests for Procedures.isNameUsed() so this bug never happens again. * rebuild * Change the Lua interpreter (#1246) Change the Lua interpreter to another one with version 5.3 so that it would support goto statement which Blockly uses currently * Fixed the buildscript so it doesn't include the parent directory name in accessible. (#1252) * Fix synonyms when compiled. (#1248) * Procedure block renames variable in mutator if there is a case change. * Change workspace name to playgroundWorkspace. * Fix type tags and todo placement. * Update extensions.js to be compatible with ADVANCED_OPTIMIZATIONS (#1253) * Update extensions.js to be compatible with ADVANCED_OPTIMIZATIONS We were using strings to check for the existence of properties on a mutator, which breaks if those properties were renamed by the closure compiler. This updates all of the uses to direct function references so that anyone building with advanced optimizations turned on will get the correct method references in their mutators. fixes #1251 * Update to extensions.js for advanced optimizations Some minor updates to making extensions.js work with advanced optimizations. * use === undefined instead of typeof == 'undefined' * Missed one use of string instead of .property in extensions.js (#1262) * Fixes positional index for Czech translation (#1264) * Compile messages with externs and demo with advanced optimizations (#1259) * Revert "Fix synonyms when compiled. (#1248)" This reverts commitf08afbb351. * Revert "Compatibility for Closure Compiler. (#1240)" [fc8d4c9] * Adding exports to all messages. * Fixed missing dependency to Blockly.defineBlocksWithJsonArray() * Adding a fully compiled demo draft (still simple optimizations). * Demo optimizations switched to advanced and enabled exports (for Blockly.Msg). * Message interpolation updated to use the exported (global) Blockly.Msg array. * Adding some debug compilation options to the build script. * Adding SVG externs. * Fixed Blockly.inject's config array to work with compilation. * Reverting all compiled code. This fixes commitb307ba1151. This fixes commitdec6910b67. * Reverting all compiled code. This fixes commit824c806ec3. * Removing old todo * Merge commit 'fe96bec765f0eb58c5321101965100c2716760ed' into compile-messages-with-externs * commit 'fe96bec765f0eb58c5321101965100c2716760ed': Fixes positional index for Czech translation (#1264) Missed one use of string instead of .property in extensions.js (#1262) Update extensions.js to be compatible with ADVANCED_OPTIMIZATIONS (#1253) Fix type tags and todo placement. Procedure block renames variable in mutator if there is a case change. * Fixes based on review by @NeilFraser - 80 cols - using goog.global instead of window - @export on the same line as messages * BF: Moving the msg dependency earlier, since Blockly.Msg.en is filling the Blockly.Msg object, which is empty without Blockly.Msg.en (and the rest of the code is using it as Blockly.Msg). * Updating some texts in the demo's html file to be more descriptive. * Commenting the debug options in the build, to maximize the optimizations. They are not removed, to allow anybody to turn them on if needed (since they are not documented on the Closure Compiler's REST API pages). * BF: fixed blocks_compressed.js compilation, as it now requires Blockly namespace to exist. * SVG externs file updated based on the one in https://github.com/google/closure-compiler/blob/master/contrib/externs/svg.js (eliminating 2 warnings) * Code cleanup in BlockSvg.prototype.tab (#1277) * Fix wrong width of field_dropdown with an image on Edge / IE (#1278) * Fix #1275 by adding a more specific rule for overflow:visible on the … (#1280) * Fix #1275 by adding a more specific rule for overflow:visible on the drag surface svg. This wins out over a common bootstrap rule that says: svg:not(:root) {overflow:hidden} and helps avoid a difficult problem for Blockly users to diagnose. * Update css.js * Fixing no-category toolboxes so they populate immediately, rather (#1255) than on a timeout. * BlockFactory: Adding JSON/JavaScript import support (#1235) Updates the BlockFactory main workspace based on the preview block generated from manual construction. This is a continuation of PR #1216 by @JC-Orozco, rebased on latest develop branch. Bring it latest code up to Google styling and standards. * Escape variable names correctly when serializing to XML (#1279) * Bring the most recently edited stack to the front at the end of a drag. (#1283) * Implement Blockly.Events.filter in linear time (#1205) * Implement Blockly.Events.filter in linear time For large App Inventor projects (order 1k+ blocks, 100+ top-level blocks), the O(n^2) behavior of Blockly.Event.filter was causing performance issues when rearranging blocks or pasting from the backpack. This commit provides a linear merge implementation using a key that uniquely identifies a block so that multiple events targeting the same block are merged. This change benefits from O(1) amortized lookup using an object as a key-value store. * Add event filter unit tests and fix logic bugs * Update Blockly.Events.filter unit tests * Clean up code in FieldTextInput (#1284) * Clean up code in FieldTextInput * Explicit annotations * Remove extra newline * Decompose the showEditor_ function in FieldTextInput (#1285) * Explicit annotations * Decompose the showEditor_ function in FieldTextInput * Remove extra newline * Add annotations for units to scrollbar.js (#1290) * Add annotations for units to scrollbar.js * Update comments * Remove all all instances calling setValue with name. (#1254) * Create WorkspaceViewport class (#1291) * Create WorkspaceViewport class * Update comments * Move workspace viewport functions back to the workspace for now * whitespace * Revert "Remove all all instances calling setValue on variable fields with the name instead of the id" (#1296) * Revert "Create WorkspaceViewport class (#1291)" This reverts commit6c00d77c9e. * Revert "Remove all all instances calling setValue with name. (#1254)" This reverts commit8e8b6b27af. * Store Block hue so it can be extracted reliably (#1293) Adds `Block.getHue()` to retrieve the block colour when set via a hue. The hue value is stored in the new `.hue_` field, which is null if the colour was set via a hex string. * Properly escape IDs in procedure generators. (#1305) Issue #251 and #1304. * Fix flyout labels causing flyout scrolling issues (#1301) * Create .github folder and add pull request template and issue template (#1314) * Create .github folder and move CONTRIBUTING.md to the new folder * Add pull request template and issue template * Update ISSUE_TEMPLATE.md * Update PULL_REQUEST_TEMPLATE.md * Update ISSUE_TEMPLATE.md * Update PULL_REQUEST_TEMPLATE.md * Strip licences from compiled code. (#1318) * Code cleanup in FieldDropdown (#1289) * Helper functions for rendering an image or text option. * Break showEditor_ into smaller helper functions * More decomposition, and function comments. * Allow the toolbox to scroll (#1319) * Allow the toolbox to scroll * Switch from onMouseDown to onClick_ for toolbox category taps and clicks. * Fix field_image click handler (#1320) * Make dropdowns update correctly when you switch between images. (#1321) * Subtract metrics.contentTop from metrics.viewTop so that the flyout does not begin to scroll down once the delta is smaller than the value of metrics.contentTop (#1309) * Add margin only for buttons, not labels (#1322) * Scale Firefox scrolling for mouse only, not trackpad (#1324) * Avoid IE and Edge re-rendering (#1326) * Fix wrong width of field_dropdown with an image on Edge / IE * Avoid re-rendering on IE and Edge by using getBBox().width to compute the text width on those browsers * Code cleanup: widget creation (#1332) * Initial checkin for the code for Blockly for the Web codelab (#1273) * Add Blockly for the Web codelab code * Adding licences and comments as per review * Renaming a4/b4 sounds to a5/b5 * Define blocks with defineBlocksWithJsonArray istead of jsonInit * Disable workspace resizing at the beginning of cleanup blocks and re-enable at the end. (#1331) * Move finished codelab code and fix paths (#1337) * Move the finished version of the codelab This moves the finished version of the codelab to app-completed so it's at the same level as the starting app code. * Fix paths to be relative The paths for blockly files and media were absolute, which would break if you ran it from any directory that wasn't identical. * Unify code for positioning the widget div (#1334) * New widget div functions, used in context menu code * Make all widget div positioning functions use the same argument order * Use new widget div functions for fields * share code for measuring menu size * Get rid of positionMenu * Update copyright date * Rebuild blockly_uncompressed because there's a new require in town * Tests for widget div math. (#1338) * New widget div functions, used in context menu code * Make all widget div positioning functions use the same argument order * Use new widget div functions for fields * share code for measuring menu size * Get rid of positionMenu * Update copyright date * Rebuild blockly_uncompressed because there's a new require in town * Test for widget div math * Merge master into develop (#1341) * Rebuild for master push * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Enable google/blockly with continuous build on travis ci (#1023) * 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 * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Merge develop into master (#1064) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Develop to master (#1209) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * 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 * Appease eslint: semicolons and such. * Deserialization variables at top. * Setting up accessible Blockly for Closure compilation. (#1134) Moving closure compilation into the build file. Fixing up goog.requires for accessible blockly. Adding accessible to the build script. * Fix #1109 * Adding command-line options to the buildscript. (#1136) * Fix for travis-ci testing failure (#1141) It looks like the default configuration for Travis might have changed. Adding a manual step to install webdriverio. * Convert text_join block to JSON + mutator format (#1140) * Clean up and create test utilities file. * Add BLOCK events and constructor tests. * Convert more text blocks to json (#1147) * Convert more text blocks to json Converts the mutator blocks for text_join and the text_append block to JSON format. * Fixing modals so they're announced on focus, and changing variables t… (#1030) * Fixing modals so they're announced on focus, and changing variables to only react to enter, not onChange. * Adding a temp index. * Whoops - added it in the wrong spot. * Adding automatically-generated variable lists to the accessible toolbox. (#1149) Fixing a bug with the core-only uncompressed file not finding its own directory. * Field Variable setValue() looks up variable. * Wrap Error in Try Finally Block. * Changing the build file to allow forced rebuilding of the msg files. (#1158) * Split flyout into flyout_base, flyout_horizontal, and flyou_vertical * Rename flyout to flyout_base * flyout_base minus horizontal and vertical code * Add flyout_vertical and flyout_horizontal * review fixes + toolbox and workspace use * Fix hat block case * rebuild uncompressed * Fix travis problem * Fix build problem * Add VAR events. * Correctly named block events called. * Fire VAR events and test. * Create utility function for checking variable values. * In DropdownCreate check for Msg.DELETE_VARIABLE. * Test Delete Variable Twice. * Convert more text blocks to JSON format (#1163) * Convert more text blocks to JSON format Converts text_charAt, text_indexOf, text_isEmpty, and text_length to JSON. Includes a rebuild to pick up message changes. * Fixing the accessible variable stuff so it interacts correctly with (#1170) variableMap. * createVariable in workspaceSvg takes in id and type. * Followup RefreshToolbox. * Fixing an error with block messages and ordering. (#1171) * Remove out of date todo comments. * Fix checkbox delete bug. * Fixing variable dropdowns so they select the correct option. (#1184) * Always open flyout fields are editable. * Fixing the tree service so it doesn't treat unknown block deletion (#1182) as an error, and turning off keypresses on the workspace when the variable modals are open. * Revamping mostly gesture tests. * Merge master to develop (#1189) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Rebuild compressed files * Add some translatewiki annotations back into msg/messages.js * Rebuild msg files * Fix flyout dropdown bug. * Fix python and php procedures. * Dropdown Create does not create a missing variable twice. * Fire field variable change event with variable value, not name. * Fix #1160 (#1197) Fix "Connection UI Effect not playing on block connect" * Only add a block in the flyout if it is not disabled (#1204) * Only add a block in the flyout if it is not disabled * PR feedback * remove previous fix * Fix issue with compression stripping dropdown options (#1207) * Get some accessible files back from develop * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Develop to master (#1244) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * 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 * Appease eslint: semicolons and such. * Deserialization variables at top. * Setting up accessible Blockly for Closure compilation. (#1134) Moving closure compilation into the build file. Fixing up goog.requires for accessible blockly. Adding accessible to the build script. * Fix #1109 * Adding command-line options to the buildscript. (#1136) * Fix for travis-ci testing failure (#1141) It looks like the default configuration for Travis might have changed. Adding a manual step to install webdriverio. * Convert text_join block to JSON + mutator format (#1140) * Clean up and create test utilities file. * Add BLOCK events and constructor tests. * Convert more text blocks to json (#1147) * Convert more text blocks to json Converts the mutator blocks for text_join and the text_append block to JSON format. * Fixing modals so they're announced on focus, and changing variables t… (#1030) * Fixing modals so they're announced on focus, and changing variables to only react to enter, not onChange. * Adding a temp index. * Whoops - added it in the wrong spot. * Adding automatically-generated variable lists to the accessible toolbox. (#1149) Fixing a bug with the core-only uncompressed file not finding its own directory. * Field Variable setValue() looks up variable. * Wrap Error in Try Finally Block. * Changing the build file to allow forced rebuilding of the msg files. (#1158) * Split flyout into flyout_base, flyout_horizontal, and flyou_vertical * Rename flyout to flyout_base * flyout_base minus horizontal and vertical code * Add flyout_vertical and flyout_horizontal * review fixes + toolbox and workspace use * Fix hat block case * rebuild uncompressed * Fix travis problem * Fix build problem * Add VAR events. * Correctly named block events called. * Fire VAR events and test. * Create utility function for checking variable values. * In DropdownCreate check for Msg.DELETE_VARIABLE. * Test Delete Variable Twice. * Convert more text blocks to JSON format (#1163) * Convert more text blocks to JSON format Converts text_charAt, text_indexOf, text_isEmpty, and text_length to JSON. Includes a rebuild to pick up message changes. * Fixing the accessible variable stuff so it interacts correctly with (#1170) variableMap. * createVariable in workspaceSvg takes in id and type. * Followup RefreshToolbox. * Fixing an error with block messages and ordering. (#1171) * Remove out of date todo comments. * Fix checkbox delete bug. * Fixing variable dropdowns so they select the correct option. (#1184) * Always open flyout fields are editable. * Fixing the tree service so it doesn't treat unknown block deletion (#1182) as an error, and turning off keypresses on the workspace when the variable modals are open. * Revamping mostly gesture tests. * Merge master to develop (#1189) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Rebuild compressed files * Add some translatewiki annotations back into msg/messages.js * Rebuild msg files * Fix flyout dropdown bug. * Fix python and php procedures. * Dropdown Create does not create a missing variable twice. * Fire field variable change event with variable value, not name. * Fix #1160 (#1197) Fix "Connection UI Effect not playing on block connect" * Only add a block in the flyout if it is not disabled (#1204) * Only add a block in the flyout if it is not disabled * PR feedback * remove previous fix * Fix issue with compression stripping dropdown options (#1207) * Change the build process to be deterministic (#1154) * Change the Blockly build process to be deterministic across machines. * A couple more missed locations for deterministic ordering. * Modularize Rename Variable prompt and allow custom context menus for flyout. * Adding BlocklyDevTools.Analytics (#1217) Adding BlocklyDevTools.Analytics, an interface for integrating an analytics library to track basic usage, including: * navigation. * saving, importing, and exporting. * warnings and errors. * Modify the colour_rgb function to match other languages (#1210) There are two tests fail before modifying the color_rgb function because it behaves differently in Dart and in other languages. In Dart, this function takes parameters ranging from 0 to 1.0 while in other languages such as Lua the counterpart function takes parameters ranging from 0 to 100. Now I have modified it to let it behave the same as other languages. * Fix code generation for procedures (PHP, Python). * Typo in a deprecated variable's value (#1228) Misspelled variable name, should be Blockly.PROCEDURE_CATEGORY_NAME. * Use the same math for dragging blocks out of horizontal and vertical flyouts. (#1215) * Use the same math for dragging blocks out of horizontal and vertical flyouts. * Update flyout_base.js * Add VariableType checks. * Add opt_type to Blockly.Variables.CreateVariable. * Fix Blockly.Procedures.isNameUsed return values. Add tests for Procedures.isNameUsed() so this bug never happens again. * Compatibility for Closure Compiler. (#1240) * Rebuild all the things * Master to develop 07 31 17 (#1243) * Rebuild for master push * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Enable google/blockly with continuous build on travis ci (#1023) * 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 * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Merge develop into master (#1064) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * Rebuild for translations * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Cherrypick a fix for #1069 and rebuild (#1075) * Fix #1069 (#1073) * rebuild * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Develop to master (#1209) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (add… * Add Kabyle locale to code demo (#1342) * Fix FieldTextInput showPromptEditor_ * Fix FieldTextInput showPromptEditor_ (#1350) * Fix iOS toolbox flashing on tap * rebuild
1523 lines
47 KiB
JavaScript
1523 lines
47 KiB
JavaScript
/**
|
|
* @license
|
|
* Visual Blocks Editor
|
|
*
|
|
* Copyright 2011 Google Inc.
|
|
* https://developers.google.com/blockly/
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview The class representing one block.
|
|
* @author fraser@google.com (Neil Fraser)
|
|
*/
|
|
'use strict';
|
|
|
|
goog.provide('Blockly.Block');
|
|
|
|
goog.require('Blockly.Blocks');
|
|
goog.require('Blockly.Comment');
|
|
goog.require('Blockly.Connection');
|
|
goog.require('Blockly.Extensions');
|
|
goog.require('Blockly.Input');
|
|
goog.require('Blockly.Mutator');
|
|
goog.require('Blockly.Warning');
|
|
goog.require('Blockly.Workspace');
|
|
goog.require('Blockly.Xml');
|
|
goog.require('goog.array');
|
|
goog.require('goog.asserts');
|
|
goog.require('goog.math.Coordinate');
|
|
goog.require('goog.string');
|
|
|
|
|
|
/**
|
|
* Class for one block.
|
|
* 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
|
|
* create a new id.
|
|
* @constructor
|
|
*/
|
|
Blockly.Block = function(workspace, prototypeName, opt_id) {
|
|
/** @type {string} */
|
|
this.id = (opt_id && !workspace.getBlockById(opt_id)) ?
|
|
opt_id : Blockly.utils.genUid();
|
|
workspace.blockDB_[this.id] = this;
|
|
/** @type {Blockly.Connection} */
|
|
this.outputConnection = null;
|
|
/** @type {Blockly.Connection} */
|
|
this.nextConnection = null;
|
|
/** @type {Blockly.Connection} */
|
|
this.previousConnection = null;
|
|
/** @type {!Array.<!Blockly.Input>} */
|
|
this.inputList = [];
|
|
/** @type {boolean|undefined} */
|
|
this.inputsInline = undefined;
|
|
/** @type {boolean} */
|
|
this.disabled = false;
|
|
/** @type {string|!Function} */
|
|
this.tooltip = '';
|
|
/** @type {boolean} */
|
|
this.contextMenu = true;
|
|
|
|
/**
|
|
* @type {Blockly.Block}
|
|
* @private
|
|
*/
|
|
this.parentBlock_ = null;
|
|
|
|
/**
|
|
* @type {!Array.<!Blockly.Block>}
|
|
* @private
|
|
*/
|
|
this.childBlocks_ = [];
|
|
|
|
/**
|
|
* @type {boolean}
|
|
* @private
|
|
*/
|
|
this.deletable_ = true;
|
|
|
|
/**
|
|
* @type {boolean}
|
|
* @private
|
|
*/
|
|
this.movable_ = true;
|
|
|
|
/**
|
|
* @type {boolean}
|
|
* @private
|
|
*/
|
|
this.editable_ = true;
|
|
|
|
/**
|
|
* @type {boolean}
|
|
* @private
|
|
*/
|
|
this.isShadow_ = false;
|
|
|
|
/**
|
|
* @type {boolean}
|
|
* @private
|
|
*/
|
|
this.collapsed_ = false;
|
|
|
|
/** @type {string|Blockly.Comment} */
|
|
this.comment = null;
|
|
|
|
/**
|
|
* The block's position in workspace units. (0, 0) is at the workspace's
|
|
* origin; scale does not change this value.
|
|
* @type {!goog.math.Coordinate}
|
|
* @private
|
|
*/
|
|
this.xy_ = new goog.math.Coordinate(0, 0);
|
|
|
|
/** @type {!Blockly.Workspace} */
|
|
this.workspace = workspace;
|
|
/** @type {boolean} */
|
|
this.isInFlyout = workspace.isFlyout;
|
|
/** @type {boolean} */
|
|
this.isInMutator = workspace.isMutator;
|
|
|
|
/** @type {boolean} */
|
|
this.RTL = workspace.RTL;
|
|
|
|
// Copy the type-specific functions and data from the prototype.
|
|
if (prototypeName) {
|
|
/** @type {string} */
|
|
this.type = prototypeName;
|
|
var prototype = Blockly.Blocks[prototypeName];
|
|
goog.asserts.assertObject(prototype,
|
|
'Error: Unknown block type "%s".', prototypeName);
|
|
goog.mixin(this, prototype);
|
|
}
|
|
|
|
workspace.addTopBlock(this);
|
|
|
|
// Call an initialization function, if it exists.
|
|
if (goog.isFunction(this.init)) {
|
|
this.init();
|
|
}
|
|
// Record initial inline state.
|
|
/** @type {boolean|undefined} */
|
|
this.inputsInlineDefault = this.inputsInline;
|
|
if (Blockly.Events.isEnabled()) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockCreate(this));
|
|
}
|
|
// Bind an onchange function, if it exists.
|
|
if (goog.isFunction(this.onchange)) {
|
|
this.setOnChange(this.onchange);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Obtain a newly created block.
|
|
* @param {!Blockly.Workspace} workspace The block's workspace.
|
|
* @param {?string} prototypeName Name of the language object containing
|
|
* type-specific functions for this block.
|
|
* @return {!Blockly.Block} The created block.
|
|
* @deprecated December 2015
|
|
*/
|
|
Blockly.Block.obtain = function(workspace, prototypeName) {
|
|
console.warn('Deprecated call to Blockly.Block.obtain, ' +
|
|
'use workspace.newBlock instead.');
|
|
return workspace.newBlock(prototypeName);
|
|
};
|
|
|
|
/**
|
|
* Optional text data that round-trips beween blocks and XML.
|
|
* Has no effect. May be used by 3rd parties for meta information.
|
|
* @type {?string}
|
|
*/
|
|
Blockly.Block.prototype.data = null;
|
|
|
|
/**
|
|
* Colour of the block in '#RRGGBB' format.
|
|
* @type {string}
|
|
* @private
|
|
*/
|
|
Blockly.Block.prototype.colour_ = '#000000';
|
|
|
|
/**
|
|
* Colour of the block as HSV hue value (0-360)
|
|
* @type {?number}
|
|
* @private
|
|
*/
|
|
Blockly.Block.prototype.hue_ = null;
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
Blockly.Block.prototype.dispose = function(healStack) {
|
|
if (!this.workspace) {
|
|
// Already deleted.
|
|
return;
|
|
}
|
|
// Terminate onchange event calls.
|
|
if (this.onchangeWrapper_) {
|
|
this.workspace.removeChangeListener(this.onchangeWrapper_);
|
|
}
|
|
this.unplug(healStack);
|
|
if (Blockly.Events.isEnabled()) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockDelete(this));
|
|
}
|
|
Blockly.Events.disable();
|
|
|
|
try {
|
|
// This block is now at the top of the workspace.
|
|
// Remove this block from the workspace's list of top-most blocks.
|
|
if (this.workspace) {
|
|
this.workspace.removeTopBlock(this);
|
|
// Remove from block database.
|
|
delete this.workspace.blockDB_[this.id];
|
|
this.workspace = null;
|
|
}
|
|
|
|
// Just deleting this block from the DOM would result in a memory leak as
|
|
// well as corruption of the connection database. Therefore we must
|
|
// methodically step through the blocks and carefully disassemble them.
|
|
|
|
// First, dispose of all my children.
|
|
for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
|
|
this.childBlocks_[i].dispose(false);
|
|
}
|
|
// Then dispose of myself.
|
|
// Dispose of all inputs and their fields.
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
input.dispose();
|
|
}
|
|
this.inputList.length = 0;
|
|
// Dispose of any remaining connections (next/previous/output).
|
|
var connections = this.getConnections_(true);
|
|
for (var i = 0; i < connections.length; i++) {
|
|
var connection = connections[i];
|
|
if (connection.isConnected()) {
|
|
connection.disconnect();
|
|
}
|
|
connections[i].dispose();
|
|
}
|
|
} finally {
|
|
Blockly.Events.enable();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Unplug this block from its superior block. If this block is a statement,
|
|
* optionally reconnect the block underneath with the block on top.
|
|
* @param {boolean} opt_healStack Disconnect child statement and reconnect
|
|
* stack. Defaults to false.
|
|
*/
|
|
Blockly.Block.prototype.unplug = function(opt_healStack) {
|
|
if (this.outputConnection) {
|
|
if (this.outputConnection.isConnected()) {
|
|
// Disconnect from any superior block.
|
|
this.outputConnection.disconnect();
|
|
}
|
|
} else if (this.previousConnection) {
|
|
var previousTarget = null;
|
|
if (this.previousConnection.isConnected()) {
|
|
// Remember the connection that any next statements need to connect to.
|
|
previousTarget = this.previousConnection.targetConnection;
|
|
// Detach this block from the parent's tree.
|
|
this.previousConnection.disconnect();
|
|
}
|
|
var nextBlock = this.getNextBlock();
|
|
if (opt_healStack && nextBlock) {
|
|
// Disconnect the next statement.
|
|
var nextTarget = this.nextConnection.targetConnection;
|
|
nextTarget.disconnect();
|
|
if (previousTarget && previousTarget.checkType_(nextTarget)) {
|
|
// Attach the next statement to the previous statement.
|
|
previousTarget.connect(nextTarget);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns all connections originating from this block.
|
|
* @return {!Array.<!Blockly.Connection>} Array of connections.
|
|
* @private
|
|
*/
|
|
Blockly.Block.prototype.getConnections_ = function() {
|
|
var myConnections = [];
|
|
if (this.outputConnection) {
|
|
myConnections.push(this.outputConnection);
|
|
}
|
|
if (this.previousConnection) {
|
|
myConnections.push(this.previousConnection);
|
|
}
|
|
if (this.nextConnection) {
|
|
myConnections.push(this.nextConnection);
|
|
}
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection) {
|
|
myConnections.push(input.connection);
|
|
}
|
|
}
|
|
return myConnections;
|
|
};
|
|
|
|
/**
|
|
* Walks down a stack of blocks and finds the last next connection on the stack.
|
|
* @return {Blockly.Connection} The last next connection on the stack, or null.
|
|
* @package
|
|
*/
|
|
Blockly.Block.prototype.lastConnectionInStack_ = function() {
|
|
var nextConnection = this.nextConnection;
|
|
while (nextConnection) {
|
|
var nextBlock = nextConnection.targetBlock();
|
|
if (!nextBlock) {
|
|
// Found a next connection with nothing on the other side.
|
|
return nextConnection;
|
|
}
|
|
nextConnection = nextBlock.nextConnection;
|
|
}
|
|
// Ran out of next connections.
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
|
|
* connected should not coincidentally line up on screen.
|
|
* @private
|
|
*/
|
|
Blockly.Block.prototype.bumpNeighbours_ = function() {
|
|
console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
|
|
'BlockSvg function for bumpNeighbours_ was expected to be called instead.');
|
|
};
|
|
|
|
/**
|
|
* Return the parent block or null if this block is at the top level.
|
|
* @return {Blockly.Block} The block that holds the current block.
|
|
*/
|
|
Blockly.Block.prototype.getParent = function() {
|
|
// Look at the DOM to see if we are nested in another block.
|
|
return this.parentBlock_;
|
|
};
|
|
|
|
/**
|
|
* Return the input that connects to the specified block.
|
|
* @param {!Blockly.Block} block A block connected to an input on this block.
|
|
* @return {Blockly.Input} The input that connects to the specified block.
|
|
*/
|
|
Blockly.Block.prototype.getInputWithBlock = function(block) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection && input.connection.targetBlock() == block) {
|
|
return input;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Return the parent block that surrounds the current block, or null if this
|
|
* block has no surrounding block. A parent block might just be the previous
|
|
* statement, whereas the surrounding block is an if statement, while loop, etc.
|
|
* @return {Blockly.Block} The block that surrounds the current block.
|
|
*/
|
|
Blockly.Block.prototype.getSurroundParent = function() {
|
|
var block = this;
|
|
do {
|
|
var prevBlock = block;
|
|
block = block.getParent();
|
|
if (!block) {
|
|
// Ran off the top.
|
|
return null;
|
|
}
|
|
} while (block.getNextBlock() == prevBlock);
|
|
// This block is an enclosing parent, not just a statement in a stack.
|
|
return block;
|
|
};
|
|
|
|
/**
|
|
* Return the next statement block directly connected to this block.
|
|
* @return {Blockly.Block} The next statement block or null.
|
|
*/
|
|
Blockly.Block.prototype.getNextBlock = function() {
|
|
return this.nextConnection && this.nextConnection.targetBlock();
|
|
};
|
|
|
|
/**
|
|
* Return the top-most block in this block's tree.
|
|
* This will return itself if this block is at the top level.
|
|
* @return {!Blockly.Block} The root block.
|
|
*/
|
|
Blockly.Block.prototype.getRootBlock = function() {
|
|
var rootBlock;
|
|
var block = this;
|
|
do {
|
|
rootBlock = block;
|
|
block = rootBlock.parentBlock_;
|
|
} while (block);
|
|
return rootBlock;
|
|
};
|
|
|
|
/**
|
|
* Find all the blocks that are directly nested inside this one.
|
|
* Includes value and block inputs, as well as any following statement.
|
|
* Excludes any connection on an output tab or any preceding statement.
|
|
* @return {!Array.<!Blockly.Block>} Array of blocks.
|
|
*/
|
|
Blockly.Block.prototype.getChildren = function() {
|
|
return this.childBlocks_;
|
|
};
|
|
|
|
/**
|
|
* Set parent of this block to be a new block or null.
|
|
* @param {Blockly.Block} newParent New parent block.
|
|
*/
|
|
Blockly.Block.prototype.setParent = function(newParent) {
|
|
if (newParent == this.parentBlock_) {
|
|
return;
|
|
}
|
|
if (this.parentBlock_) {
|
|
// Remove this block from the old parent's child list.
|
|
goog.array.remove(this.parentBlock_.childBlocks_, this);
|
|
|
|
// Disconnect from superior blocks.
|
|
if (this.previousConnection && this.previousConnection.isConnected()) {
|
|
throw 'Still connected to previous block.';
|
|
}
|
|
if (this.outputConnection && this.outputConnection.isConnected()) {
|
|
throw 'Still connected to parent block.';
|
|
}
|
|
this.parentBlock_ = null;
|
|
// This block hasn't actually moved on-screen, so there's no need to update
|
|
// its connection locations.
|
|
} else {
|
|
// Remove this block from the workspace's list of top-most blocks.
|
|
this.workspace.removeTopBlock(this);
|
|
}
|
|
|
|
this.parentBlock_ = newParent;
|
|
if (newParent) {
|
|
// Add this block to the new parent's child list.
|
|
newParent.childBlocks_.push(this);
|
|
} else {
|
|
this.workspace.addTopBlock(this);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Find all the blocks that are directly or indirectly nested inside this one.
|
|
* Includes this block in the list.
|
|
* Includes value and block inputs, as well as any following statements.
|
|
* Excludes any connection on an output tab or any preceding statements.
|
|
* @return {!Array.<!Blockly.Block>} Flattened array of blocks.
|
|
*/
|
|
Blockly.Block.prototype.getDescendants = function() {
|
|
var blocks = [this];
|
|
for (var child, x = 0; child = this.childBlocks_[x]; x++) {
|
|
blocks.push.apply(blocks, child.getDescendants());
|
|
}
|
|
return blocks;
|
|
};
|
|
|
|
/**
|
|
* Get whether this block is deletable or not.
|
|
* @return {boolean} True if deletable.
|
|
*/
|
|
Blockly.Block.prototype.isDeletable = function() {
|
|
return this.deletable_ && !this.isShadow_ &&
|
|
!(this.workspace && this.workspace.options.readOnly);
|
|
};
|
|
|
|
/**
|
|
* Set whether this block is deletable or not.
|
|
* @param {boolean} deletable True if deletable.
|
|
*/
|
|
Blockly.Block.prototype.setDeletable = function(deletable) {
|
|
this.deletable_ = deletable;
|
|
};
|
|
|
|
/**
|
|
* Get whether this block is movable or not.
|
|
* @return {boolean} True if movable.
|
|
*/
|
|
Blockly.Block.prototype.isMovable = function() {
|
|
return this.movable_ && !this.isShadow_ &&
|
|
!(this.workspace && this.workspace.options.readOnly);
|
|
};
|
|
|
|
/**
|
|
* Set whether this block is movable or not.
|
|
* @param {boolean} movable True if movable.
|
|
*/
|
|
Blockly.Block.prototype.setMovable = function(movable) {
|
|
this.movable_ = movable;
|
|
};
|
|
|
|
/**
|
|
* Get whether this block is a shadow block or not.
|
|
* @return {boolean} True if a shadow.
|
|
*/
|
|
Blockly.Block.prototype.isShadow = function() {
|
|
return this.isShadow_;
|
|
};
|
|
|
|
/**
|
|
* Set whether this block is a shadow block or not.
|
|
* @param {boolean} shadow True if a shadow.
|
|
*/
|
|
Blockly.Block.prototype.setShadow = function(shadow) {
|
|
this.isShadow_ = shadow;
|
|
};
|
|
|
|
/**
|
|
* Get whether this block is editable or not.
|
|
* @return {boolean} True if editable.
|
|
*/
|
|
Blockly.Block.prototype.isEditable = function() {
|
|
return this.editable_ && !(this.workspace && this.workspace.options.readOnly);
|
|
};
|
|
|
|
/**
|
|
* Set whether this block is editable or not.
|
|
* @param {boolean} editable True if editable.
|
|
*/
|
|
Blockly.Block.prototype.setEditable = function(editable) {
|
|
this.editable_ = editable;
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
field.updateEditable();
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Set whether the connections are hidden (not tracked in a database) or not.
|
|
* Recursively walk down all child blocks (except collapsed blocks).
|
|
* @param {boolean} hidden True if connections are hidden.
|
|
*/
|
|
Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
|
|
if (!hidden && this.isCollapsed()) {
|
|
if (this.outputConnection) {
|
|
this.outputConnection.setHidden(hidden);
|
|
}
|
|
if (this.previousConnection) {
|
|
this.previousConnection.setHidden(hidden);
|
|
}
|
|
if (this.nextConnection) {
|
|
this.nextConnection.setHidden(hidden);
|
|
var child = this.nextConnection.targetBlock();
|
|
if (child) {
|
|
child.setConnectionsHidden(hidden);
|
|
}
|
|
}
|
|
} else {
|
|
var myConnections = this.getConnections_(true);
|
|
for (var i = 0, connection; connection = myConnections[i]; i++) {
|
|
connection.setHidden(hidden);
|
|
if (connection.isSuperior()) {
|
|
var child = connection.targetBlock();
|
|
if (child) {
|
|
child.setConnectionsHidden(hidden);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Set the URL of this block's help page.
|
|
* @param {string|Function} url URL string for block help, or function that
|
|
* returns a URL. Null for no help.
|
|
*/
|
|
Blockly.Block.prototype.setHelpUrl = function(url) {
|
|
this.helpUrl = url;
|
|
};
|
|
|
|
/**
|
|
* Change the tooltip text for a block.
|
|
* @param {string|!Function} newTip Text for tooltip or a parent element to
|
|
* link to for its tooltip. May be a function that returns a string.
|
|
*/
|
|
Blockly.Block.prototype.setTooltip = function(newTip) {
|
|
this.tooltip = newTip;
|
|
};
|
|
|
|
/**
|
|
* Get the colour of a block.
|
|
* @return {string} #RRGGBB string.
|
|
*/
|
|
Blockly.Block.prototype.getColour = function() {
|
|
return this.colour_;
|
|
};
|
|
|
|
/**
|
|
* Get the HSV hue value of a block. Null if hue not set.
|
|
* @return {?number} Hue value (0-360)
|
|
*/
|
|
Blockly.Block.prototype.getHue = function() {
|
|
return this.hue_;
|
|
}
|
|
|
|
/**
|
|
* Change the colour of a block.
|
|
* @param {number|string} colour HSV hue value, or #RRGGBB string.
|
|
*/
|
|
Blockly.Block.prototype.setColour = function(colour) {
|
|
var hue = Number(colour);
|
|
if (!isNaN(hue) && 0 <= hue && hue <= 360) {
|
|
this.hue_ = hue;
|
|
this.colour_ = Blockly.hueToRgb(hue);
|
|
} else if (goog.isString(colour) && colour.match(/^#[0-9a-fA-F]{6}$/)) {
|
|
this.colour_ = colour;
|
|
// Only store hue if colour is set as a hue
|
|
this.hue_ = null;
|
|
} else {
|
|
throw 'Invalid colour: ' + colour;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Sets a callback function to use whenever the block's parent workspace
|
|
* changes, replacing any prior onchange handler. This is usually only called
|
|
* from the constructor, the block type initializer function, or an extension
|
|
* initializer function.
|
|
* @param {function(Blockly.Events.Abstract)} onchangeFn The callback to call
|
|
* when the block's workspace changes.
|
|
* @throws {Error} if onchangeFn is not falsey or a function.
|
|
*/
|
|
Blockly.Block.prototype.setOnChange = function(onchangeFn) {
|
|
if (onchangeFn && !goog.isFunction(onchangeFn)) {
|
|
throw new Error("onchange must be a function.");
|
|
}
|
|
if (this.onchangeWrapper_) {
|
|
this.workspace.removeChangeListener(this.onchangeWrapper_);
|
|
}
|
|
this.onchange = onchangeFn;
|
|
if (this.onchange) {
|
|
this.onchangeWrapper_ = onchangeFn.bind(this);
|
|
this.workspace.addChangeListener(this.onchangeWrapper_);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns the named field from a block.
|
|
* @param {string} name The name of the field.
|
|
* @return {Blockly.Field} Named field, or null if field does not exist.
|
|
*/
|
|
Blockly.Block.prototype.getField = function(name) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.name === name) {
|
|
return field;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Return all variables referenced by this block.
|
|
* @return {!Array.<string>} List of variable names.
|
|
*/
|
|
Blockly.Block.prototype.getVars = function() {
|
|
var vars = [];
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field instanceof Blockly.FieldVariable) {
|
|
vars.push(field.getValue());
|
|
}
|
|
}
|
|
}
|
|
return vars;
|
|
};
|
|
|
|
/**
|
|
* Notification that a variable is renaming.
|
|
* If the name matches one of this block's variables, rename it.
|
|
* @param {string} oldName Previous name of variable.
|
|
* @param {string} newName Renamed variable.
|
|
*/
|
|
Blockly.Block.prototype.renameVar = function(oldName, newName) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field instanceof Blockly.FieldVariable &&
|
|
Blockly.Names.equals(oldName, field.getValue())) {
|
|
field.setValue(newName);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns the language-neutral value from the field of a block.
|
|
* @param {string} name The name of the field.
|
|
* @return {?string} Value from the field or null if field does not exist.
|
|
*/
|
|
Blockly.Block.prototype.getFieldValue = function(name) {
|
|
var field = this.getField(name);
|
|
if (field) {
|
|
return field.getValue();
|
|
}
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Change the field value for a block (e.g. 'CHOOSE' or 'REMOVE').
|
|
* @param {string} newValue Value to be the new field.
|
|
* @param {string} name The name of the field.
|
|
*/
|
|
Blockly.Block.prototype.setFieldValue = function(newValue, name) {
|
|
var field = this.getField(name);
|
|
goog.asserts.assertObject(field, 'Field "%s" not found.', name);
|
|
field.setValue(newValue);
|
|
};
|
|
|
|
/**
|
|
* 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|undefined} opt_check Statement type or
|
|
* list of statement types. Null/undefined if any type could be connected.
|
|
*/
|
|
Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
|
|
if (newBoolean) {
|
|
if (opt_check === undefined) {
|
|
opt_check = null;
|
|
}
|
|
if (!this.previousConnection) {
|
|
goog.asserts.assert(!this.outputConnection,
|
|
'Remove output connection prior to adding previous connection.');
|
|
this.previousConnection =
|
|
this.makeConnection_(Blockly.PREVIOUS_STATEMENT);
|
|
}
|
|
this.previousConnection.setCheck(opt_check);
|
|
} else {
|
|
if (this.previousConnection) {
|
|
goog.asserts.assert(!this.previousConnection.isConnected(),
|
|
'Must disconnect previous statement before removing connection.');
|
|
this.previousConnection.dispose();
|
|
this.previousConnection = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* 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|undefined} opt_check Statement type or
|
|
* list of statement types. Null/undefined if any type could be connected.
|
|
*/
|
|
Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
|
|
if (newBoolean) {
|
|
if (opt_check === undefined) {
|
|
opt_check = null;
|
|
}
|
|
if (!this.nextConnection) {
|
|
this.nextConnection = this.makeConnection_(Blockly.NEXT_STATEMENT);
|
|
}
|
|
this.nextConnection.setCheck(opt_check);
|
|
} else {
|
|
if (this.nextConnection) {
|
|
goog.asserts.assert(!this.nextConnection.isConnected(),
|
|
'Must disconnect next statement before removing connection.');
|
|
this.nextConnection.dispose();
|
|
this.nextConnection = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Set whether this block returns a value.
|
|
* @param {boolean} newBoolean True if there is an output.
|
|
* @param {string|Array.<string>|null|undefined} opt_check Returned type or list
|
|
* of returned types. Null or undefined if any type could be returned
|
|
* (e.g. variable get).
|
|
*/
|
|
Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) {
|
|
if (newBoolean) {
|
|
if (opt_check === undefined) {
|
|
opt_check = null;
|
|
}
|
|
if (!this.outputConnection) {
|
|
goog.asserts.assert(!this.previousConnection,
|
|
'Remove previous connection prior to adding output connection.');
|
|
this.outputConnection = this.makeConnection_(Blockly.OUTPUT_VALUE);
|
|
}
|
|
this.outputConnection.setCheck(opt_check);
|
|
} else {
|
|
if (this.outputConnection) {
|
|
goog.asserts.assert(!this.outputConnection.isConnected(),
|
|
'Must disconnect output value before removing connection.');
|
|
this.outputConnection.dispose();
|
|
this.outputConnection = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Set whether value inputs are arranged horizontally or vertically.
|
|
* @param {boolean} newBoolean True if inputs are horizontal.
|
|
*/
|
|
Blockly.Block.prototype.setInputsInline = function(newBoolean) {
|
|
if (this.inputsInline != newBoolean) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'inline', null, this.inputsInline, newBoolean));
|
|
this.inputsInline = newBoolean;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Get whether value inputs are arranged horizontally or vertically.
|
|
* @return {boolean} True if inputs are horizontal.
|
|
*/
|
|
Blockly.Block.prototype.getInputsInline = function() {
|
|
if (this.inputsInline != undefined) {
|
|
// Set explicitly.
|
|
return this.inputsInline;
|
|
}
|
|
// Not defined explicitly. Figure out what would look best.
|
|
for (var i = 1; i < this.inputList.length; i++) {
|
|
if (this.inputList[i - 1].type == Blockly.DUMMY_INPUT &&
|
|
this.inputList[i].type == Blockly.DUMMY_INPUT) {
|
|
// Two dummy inputs in a row. Don't inline them.
|
|
return false;
|
|
}
|
|
}
|
|
for (var i = 1; i < this.inputList.length; i++) {
|
|
if (this.inputList[i - 1].type == Blockly.INPUT_VALUE &&
|
|
this.inputList[i].type == Blockly.DUMMY_INPUT) {
|
|
// Dummy input after a value input. Inline them.
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Set whether the block is disabled or not.
|
|
* @param {boolean} disabled True if disabled.
|
|
*/
|
|
Blockly.Block.prototype.setDisabled = function(disabled) {
|
|
if (this.disabled != disabled) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'disabled', null, this.disabled, disabled));
|
|
this.disabled = disabled;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Get whether the block is disabled or not due to parents.
|
|
* The block's own disabled property is not considered.
|
|
* @return {boolean} True if disabled.
|
|
*/
|
|
Blockly.Block.prototype.getInheritedDisabled = function() {
|
|
var ancestor = this.getSurroundParent();
|
|
while (ancestor) {
|
|
if (ancestor.disabled) {
|
|
return true;
|
|
}
|
|
ancestor = ancestor.getSurroundParent();
|
|
}
|
|
// Ran off the top.
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Get whether the block is collapsed or not.
|
|
* @return {boolean} True if collapsed.
|
|
*/
|
|
Blockly.Block.prototype.isCollapsed = function() {
|
|
return this.collapsed_;
|
|
};
|
|
|
|
/**
|
|
* Set whether the block is collapsed or not.
|
|
* @param {boolean} collapsed True if collapsed.
|
|
*/
|
|
Blockly.Block.prototype.setCollapsed = function(collapsed) {
|
|
if (this.collapsed_ != collapsed) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'collapsed', null, this.collapsed_, collapsed));
|
|
this.collapsed_ = collapsed;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Create a human-readable text representation of this block and any children.
|
|
* @param {number=} opt_maxLength Truncate the string to this length.
|
|
* @param {string=} opt_emptyToken The placeholder string used to denote an
|
|
* empty field. If not specified, '?' is used.
|
|
* @return {string} Text of block.
|
|
*/
|
|
Blockly.Block.prototype.toString = function(opt_maxLength, opt_emptyToken) {
|
|
var text = [];
|
|
var emptyFieldPlaceholder = opt_emptyToken || '?';
|
|
if (this.collapsed_) {
|
|
text.push(this.getInput('_TEMP_COLLAPSED_INPUT').fieldRow[0].text_);
|
|
} else {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field instanceof Blockly.FieldDropdown && !field.getValue()) {
|
|
text.push(emptyFieldPlaceholder);
|
|
} else {
|
|
text.push(field.getText());
|
|
}
|
|
}
|
|
if (input.connection) {
|
|
var child = input.connection.targetBlock();
|
|
if (child) {
|
|
text.push(child.toString(undefined, opt_emptyToken));
|
|
} else {
|
|
text.push(emptyFieldPlaceholder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
text = goog.string.trim(text.join(' ')) || '???';
|
|
if (opt_maxLength) {
|
|
// TODO: Improve truncation so that text from this block is given priority.
|
|
// E.g. "1+2+3+4+5+6+7+8+9=0" should be "...6+7+8+9=0", not "1+2+3+4+5...".
|
|
// E.g. "1+2+3+4+5=6+7+8+9+0" should be "...4+5=6+7...".
|
|
text = goog.string.truncate(text, opt_maxLength);
|
|
}
|
|
return text;
|
|
};
|
|
|
|
/**
|
|
* Shortcut for appending a value input row.
|
|
* @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.
|
|
*/
|
|
Blockly.Block.prototype.appendValueInput = function(name) {
|
|
return this.appendInput_(Blockly.INPUT_VALUE, name);
|
|
};
|
|
|
|
/**
|
|
* Shortcut for appending a statement input row.
|
|
* @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.
|
|
*/
|
|
Blockly.Block.prototype.appendStatementInput = function(name) {
|
|
return this.appendInput_(Blockly.NEXT_STATEMENT, name);
|
|
};
|
|
|
|
/**
|
|
* Shortcut for appending a dummy input row.
|
|
* @param {string=} opt_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.
|
|
*/
|
|
Blockly.Block.prototype.appendDummyInput = function(opt_name) {
|
|
return this.appendInput_(Blockly.DUMMY_INPUT, opt_name || '');
|
|
};
|
|
|
|
/**
|
|
* Initialize this block using a cross-platform, internationalization-friendly
|
|
* JSON description.
|
|
* @param {!Object} json Structured data describing the block.
|
|
*/
|
|
Blockly.Block.prototype.jsonInit = function(json) {
|
|
|
|
// Validate inputs.
|
|
goog.asserts.assert(json['output'] == undefined ||
|
|
json['previousStatement'] == undefined,
|
|
'Must not have both an output and a previousStatement.');
|
|
|
|
// Set basic properties of block.
|
|
if (json['colour'] !== undefined) {
|
|
var rawValue = json['colour'];
|
|
var colour = goog.isString(rawValue) ?
|
|
Blockly.utils.replaceMessageReferences(rawValue) : rawValue;
|
|
this.setColour(colour);
|
|
}
|
|
|
|
// Interpolate the message blocks.
|
|
var i = 0;
|
|
while (json['message' + i] !== undefined) {
|
|
this.interpolate_(json['message' + i], json['args' + i] || [],
|
|
json['lastDummyAlign' + i]);
|
|
i++;
|
|
}
|
|
|
|
if (json['inputsInline'] !== undefined) {
|
|
this.setInputsInline(json['inputsInline']);
|
|
}
|
|
// Set output and previous/next connections.
|
|
if (json['output'] !== undefined) {
|
|
this.setOutput(true, json['output']);
|
|
}
|
|
if (json['previousStatement'] !== undefined) {
|
|
this.setPreviousStatement(true, json['previousStatement']);
|
|
}
|
|
if (json['nextStatement'] !== undefined) {
|
|
this.setNextStatement(true, json['nextStatement']);
|
|
}
|
|
if (json['tooltip'] !== undefined) {
|
|
var rawValue = json['tooltip'];
|
|
var localizedText = Blockly.utils.replaceMessageReferences(rawValue);
|
|
this.setTooltip(localizedText);
|
|
}
|
|
if (json['enableContextMenu'] !== undefined) {
|
|
var rawValue = json['enableContextMenu'];
|
|
this.contextMenu = !!rawValue;
|
|
}
|
|
if (json['helpUrl'] !== undefined) {
|
|
var rawValue = json['helpUrl'];
|
|
var localizedValue = Blockly.utils.replaceMessageReferences(rawValue);
|
|
this.setHelpUrl(localizedValue);
|
|
}
|
|
if (goog.isString(json['extensions'])) {
|
|
console.warn('JSON attribute \'extensions\' should be an array of ' +
|
|
'strings. Found raw string in JSON for \'' + json['type'] + '\' block.');
|
|
json['extensions'] = [json['extensions']]; // Correct and continue.
|
|
}
|
|
|
|
// Add the mutator to the block
|
|
if (json['mutator'] !== undefined) {
|
|
Blockly.Extensions.apply(json['mutator'], this, true);
|
|
}
|
|
|
|
if (Array.isArray(json['extensions'])) {
|
|
var extensionNames = json['extensions'];
|
|
for (var i = 0; i < extensionNames.length; ++i) {
|
|
var extensionName = extensionNames[i];
|
|
Blockly.Extensions.apply(extensionName, this, false);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Add key/values from mixinObj to this block object. By default, this method
|
|
* will check that the keys in mixinObj will not overwrite existing values in
|
|
* the block, including prototype values. This provides some insurance against
|
|
* mixin / extension incompatibilities with future block features. This check
|
|
* can be disabled by passing true as the second argument.
|
|
* @param {!Object} mixinObj The key/values pairs to add to this block object.
|
|
* @param {boolean=} opt_disableCheck Option flag to disable overwrite checks.
|
|
*/
|
|
Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
|
|
if (goog.isDef(opt_disableCheck) && !goog.isBoolean(opt_disableCheck)) {
|
|
throw new Error("opt_disableCheck must be a boolean if provided");
|
|
}
|
|
if (!opt_disableCheck) {
|
|
var overwrites = [];
|
|
for (var key in mixinObj) {
|
|
if (this[key] !== undefined) {
|
|
overwrites.push(key);
|
|
}
|
|
}
|
|
if (overwrites.length) {
|
|
throw new Error('Mixin will overwrite block members: ' +
|
|
JSON.stringify(overwrites));
|
|
}
|
|
}
|
|
goog.mixin(this, mixinObj);
|
|
};
|
|
|
|
/**
|
|
* Interpolate a message description onto the block.
|
|
* @param {string} message Text contains interpolation tokens (%1, %2, ...)
|
|
* that match with fields or inputs defined in the args array.
|
|
* @param {!Array} args Array of arguments to be interpolated.
|
|
* @param {string=} lastDummyAlign If a dummy input is added at the end,
|
|
* how should it be aligned?
|
|
* @private
|
|
*/
|
|
Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
|
var tokens = Blockly.utils.tokenizeInterpolation(message);
|
|
// Interpolate the arguments. Build a list of elements.
|
|
var indexDup = [];
|
|
var indexCount = 0;
|
|
var elements = [];
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
var token = tokens[i];
|
|
if (typeof token == 'number') {
|
|
if (token <= 0 || token > args.length) {
|
|
throw new Error('Block \"' + this.type + '\": ' +
|
|
'Message index %' + token + ' out of range.');
|
|
}
|
|
if (indexDup[token]) {
|
|
throw new Error('Block \"' + this.type + '\": ' +
|
|
'Message index %' + token + ' duplicated.');
|
|
}
|
|
indexDup[token] = true;
|
|
indexCount++;
|
|
elements.push(args[token - 1]);
|
|
} else {
|
|
token = token.trim();
|
|
if (token) {
|
|
elements.push(token);
|
|
}
|
|
}
|
|
}
|
|
if(indexCount != args.length) {
|
|
throw new Error('Block \"' + this.type + '\": ' +
|
|
'Message does not reference all ' + args.length + ' arg(s).');
|
|
}
|
|
// Add last dummy input if needed.
|
|
if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
|
|
goog.string.startsWith(elements[elements.length - 1]['type'],
|
|
'field_'))) {
|
|
var dummyInput = {type: 'input_dummy'};
|
|
if (lastDummyAlign) {
|
|
dummyInput['align'] = lastDummyAlign;
|
|
}
|
|
elements.push(dummyInput);
|
|
}
|
|
// Lookup of alignment constants.
|
|
var alignmentLookup = {
|
|
'LEFT': Blockly.ALIGN_LEFT,
|
|
'RIGHT': Blockly.ALIGN_RIGHT,
|
|
'CENTRE': Blockly.ALIGN_CENTRE
|
|
};
|
|
// Populate block with inputs and fields.
|
|
var fieldStack = [];
|
|
for (var i = 0; i < elements.length; i++) {
|
|
var element = elements[i];
|
|
if (typeof element == 'string') {
|
|
fieldStack.push([element, undefined]);
|
|
} else {
|
|
var field = null;
|
|
var input = null;
|
|
do {
|
|
var altRepeat = false;
|
|
if (typeof element == 'string') {
|
|
field = new Blockly.FieldLabel(element);
|
|
} else {
|
|
switch (element['type']) {
|
|
case 'input_value':
|
|
input = this.appendValueInput(element['name']);
|
|
break;
|
|
case 'input_statement':
|
|
input = this.appendStatementInput(element['name']);
|
|
break;
|
|
case 'input_dummy':
|
|
input = this.appendDummyInput(element['name']);
|
|
break;
|
|
case 'field_label':
|
|
field = Blockly.Block.newFieldLabelFromJson_(element);
|
|
break;
|
|
case 'field_input':
|
|
field = Blockly.Block.newFieldTextInputFromJson_(element);
|
|
break;
|
|
case 'field_angle':
|
|
field = new Blockly.FieldAngle(element['angle']);
|
|
break;
|
|
case 'field_checkbox':
|
|
field = new Blockly.FieldCheckbox(
|
|
element['checked'] ? 'TRUE' : 'FALSE');
|
|
break;
|
|
case 'field_colour':
|
|
field = new Blockly.FieldColour(element['colour']);
|
|
break;
|
|
case 'field_variable':
|
|
field = Blockly.Block.newFieldVariableFromJson_(element);
|
|
break;
|
|
case 'field_dropdown':
|
|
field = new Blockly.FieldDropdown(element['options']);
|
|
break;
|
|
case 'field_image':
|
|
field = Blockly.Block.newFieldImageFromJson_(element);
|
|
break;
|
|
case 'field_number':
|
|
field = new Blockly.FieldNumber(element['value'],
|
|
element['min'], element['max'], element['precision']);
|
|
break;
|
|
case 'field_date':
|
|
if (Blockly.FieldDate) {
|
|
field = new Blockly.FieldDate(element['date']);
|
|
break;
|
|
}
|
|
// Fall through if FieldDate is not compiled in.
|
|
default:
|
|
// Unknown field.
|
|
if (element['alt']) {
|
|
element = element['alt'];
|
|
altRepeat = true;
|
|
}
|
|
}
|
|
}
|
|
} while (altRepeat);
|
|
if (field) {
|
|
fieldStack.push([field, element['name']]);
|
|
} else if (input) {
|
|
if (element['check']) {
|
|
input.setCheck(element['check']);
|
|
}
|
|
if (element['align']) {
|
|
input.setAlign(alignmentLookup[element['align']]);
|
|
}
|
|
for (var j = 0; j < fieldStack.length; j++) {
|
|
input.appendField(fieldStack[j][0], fieldStack[j][1]);
|
|
}
|
|
fieldStack.length = 0;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Helper function to construct a FieldImage from a JSON arg object,
|
|
* dereferencing any string table references.
|
|
* @param {!Object} options A JSON object with options (src, width, height, and alt).
|
|
* @returns {!Blockly.FieldImage} The new image.
|
|
* @private
|
|
*/
|
|
Blockly.Block.newFieldImageFromJson_ = function(options) {
|
|
var src = Blockly.utils.replaceMessageReferences(options['src']);
|
|
var width = Number(Blockly.utils.replaceMessageReferences(options['width']));
|
|
var height =
|
|
Number(Blockly.utils.replaceMessageReferences(options['height']));
|
|
var alt = Blockly.utils.replaceMessageReferences(options['alt']);
|
|
return new Blockly.FieldImage(src, width, height, alt);
|
|
};
|
|
|
|
/**
|
|
* Helper function to construct a FieldLabel from a JSON arg object,
|
|
* dereferencing any string table references.
|
|
* @param {!Object} options A JSON object with options (text, and class).
|
|
* @returns {!Blockly.FieldLabel} The new label.
|
|
* @private
|
|
*/
|
|
Blockly.Block.newFieldLabelFromJson_ = function(options) {
|
|
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
|
return new Blockly.FieldLabel(text, options['class']);
|
|
};
|
|
|
|
/**
|
|
* Helper function to construct a FieldTextInput from a JSON arg object,
|
|
* dereferencing any string table references.
|
|
* @param {!Object} options A JSON object with options (text, class, and
|
|
* spellcheck).
|
|
* @returns {!Blockly.FieldTextInput} The new text input.
|
|
* @private
|
|
*/
|
|
Blockly.Block.newFieldTextInputFromJson_ = function(options) {
|
|
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
|
var field = new Blockly.FieldTextInput(text, options['class']);
|
|
if (typeof options['spellcheck'] == 'boolean') {
|
|
field.setSpellcheck(options['spellcheck']);
|
|
}
|
|
return field;
|
|
};
|
|
|
|
/**
|
|
* Helper function to construct a FieldVariable from a JSON arg object,
|
|
* dereferencing any string table references.
|
|
* @param {!Object} options A JSON object with options (variable).
|
|
* @returns {!Blockly.FieldVariable} The variable field.
|
|
* @private
|
|
*/
|
|
Blockly.Block.newFieldVariableFromJson_ = function(options) {
|
|
var varname = Blockly.utils.replaceMessageReferences(options['variable']);
|
|
var variableTypes = options['variableTypes'];
|
|
return new Blockly.FieldVariable(varname, null, variableTypes);
|
|
};
|
|
|
|
|
|
/**
|
|
* 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.Block.prototype.appendInput_ = function(type, name) {
|
|
var connection = null;
|
|
if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
|
|
connection = this.makeConnection_(type);
|
|
}
|
|
var input = new Blockly.Input(type, name, this, connection);
|
|
// Append input to list.
|
|
this.inputList.push(input);
|
|
return input;
|
|
};
|
|
|
|
/**
|
|
* Move a named input to a different location on this block.
|
|
* @param {string} name The name of the input to move.
|
|
* @param {?string} refName Name of input that should be after the moved input,
|
|
* or null to be the input at the end.
|
|
*/
|
|
Blockly.Block.prototype.moveInputBefore = function(name, refName) {
|
|
if (name == refName) {
|
|
return;
|
|
}
|
|
// Find both inputs.
|
|
var inputIndex = -1;
|
|
var refIndex = refName ? -1 : this.inputList.length;
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.name == name) {
|
|
inputIndex = i;
|
|
if (refIndex != -1) {
|
|
break;
|
|
}
|
|
} else if (refName && input.name == refName) {
|
|
refIndex = i;
|
|
if (inputIndex != -1) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
goog.asserts.assert(inputIndex != -1, 'Named input "%s" not found.', name);
|
|
goog.asserts.assert(refIndex != -1, 'Reference input "%s" not found.',
|
|
refName);
|
|
this.moveNumberedInputBefore(inputIndex, refIndex);
|
|
};
|
|
|
|
/**
|
|
* 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.Block.prototype.moveNumberedInputBefore = function(
|
|
inputIndex, refIndex) {
|
|
// Validate arguments.
|
|
goog.asserts.assert(inputIndex != refIndex, 'Can\'t move input to itself.');
|
|
goog.asserts.assert(inputIndex < this.inputList.length,
|
|
'Input index ' + inputIndex + ' out of bounds.');
|
|
goog.asserts.assert(refIndex <= this.inputList.length,
|
|
'Reference input ' + refIndex + ' out of bounds.');
|
|
// Remove input.
|
|
var input = this.inputList[inputIndex];
|
|
this.inputList.splice(inputIndex, 1);
|
|
if (inputIndex < refIndex) {
|
|
refIndex--;
|
|
}
|
|
// Reinsert input.
|
|
this.inputList.splice(refIndex, 0, input);
|
|
};
|
|
|
|
/**
|
|
* 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.Block.prototype.removeInput = function(name, opt_quiet) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.name == name) {
|
|
if (input.connection && input.connection.isConnected()) {
|
|
input.connection.setShadowDom(null);
|
|
var block = input.connection.targetBlock();
|
|
if (block.isShadow()) {
|
|
// Destroy any attached shadow block.
|
|
block.dispose();
|
|
} else {
|
|
// Disconnect any attached normal block.
|
|
block.unplug();
|
|
}
|
|
}
|
|
input.dispose();
|
|
this.inputList.splice(i, 1);
|
|
return;
|
|
}
|
|
}
|
|
if (!opt_quiet) {
|
|
goog.asserts.fail('Input "%s" not found.', name);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Fetches the named input object.
|
|
* @param {string} name The name of the input.
|
|
* @return {Blockly.Input} The input object, or null if input does not exist.
|
|
*/
|
|
Blockly.Block.prototype.getInput = function(name) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.name == name) {
|
|
return input;
|
|
}
|
|
}
|
|
// This input does not exist.
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Fetches the block attached to the named input.
|
|
* @param {string} name The name of the input.
|
|
* @return {Blockly.Block} The attached value block, or null if the input is
|
|
* either disconnected or if the input does not exist.
|
|
*/
|
|
Blockly.Block.prototype.getInputTargetBlock = function(name) {
|
|
var input = this.getInput(name);
|
|
return input && input.connection && input.connection.targetBlock();
|
|
};
|
|
|
|
/**
|
|
* Returns the comment on this block (or '' if none).
|
|
* @return {string} Block's comment.
|
|
*/
|
|
Blockly.Block.prototype.getCommentText = function() {
|
|
return this.comment || '';
|
|
};
|
|
|
|
/**
|
|
* Set this block's comment text.
|
|
* @param {?string} text The text, or null to delete.
|
|
*/
|
|
Blockly.Block.prototype.setCommentText = function(text) {
|
|
if (this.comment != text) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'comment', null, this.comment, text || ''));
|
|
this.comment = text;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Set this block's warning text.
|
|
* @param {?string} text The text, or null to delete.
|
|
*/
|
|
Blockly.Block.prototype.setWarningText = function(/* text */) {
|
|
// NOP.
|
|
};
|
|
|
|
/**
|
|
* Give this block a mutator dialog.
|
|
* @param {Blockly.Mutator} mutator A mutator dialog instance or null to remove.
|
|
*/
|
|
Blockly.Block.prototype.setMutator = function(/* mutator */) {
|
|
// NOP.
|
|
};
|
|
|
|
/**
|
|
* Return the coordinates of the top-left corner of this block relative to the
|
|
* drawing surface's origin (0,0), in workspace units.
|
|
* @return {!goog.math.Coordinate} Object with .x and .y properties.
|
|
*/
|
|
Blockly.Block.prototype.getRelativeToSurfaceXY = function() {
|
|
return this.xy_;
|
|
};
|
|
|
|
/**
|
|
* Move a block by a relative offset.
|
|
* @param {number} dx Horizontal offset, in workspace units.
|
|
* @param {number} dy Vertical offset, in workspace units.
|
|
*/
|
|
Blockly.Block.prototype.moveBy = function(dx, dy) {
|
|
goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
|
|
var event = new Blockly.Events.BlockMove(this);
|
|
this.xy_.translate(dx, dy);
|
|
event.recordNew();
|
|
Blockly.Events.fire(event);
|
|
};
|
|
|
|
/**
|
|
* Create a connection of the specified type.
|
|
* @param {number} type The type of the connection to create.
|
|
* @return {!Blockly.Connection} A new connection of the specified type.
|
|
* @private
|
|
*/
|
|
Blockly.Block.prototype.makeConnection_ = function(type) {
|
|
return new Blockly.Connection(this, type);
|
|
};
|
|
|
|
/**
|
|
* Recursively checks whether all statement and value inputs are filled with
|
|
* blocks. Also checks all following statement blocks in this stack.
|
|
* @param {boolean=} opt_shadowBlocksAreFilled An optional argument controlling
|
|
* whether shadow blocks are counted as filled. Defaults to true.
|
|
* @return {boolean} True if all inputs are filled, false otherwise.
|
|
*/
|
|
Blockly.Block.prototype.allInputsFilled = function(opt_shadowBlocksAreFilled) {
|
|
// Account for the shadow block filledness toggle.
|
|
if (opt_shadowBlocksAreFilled === undefined) {
|
|
opt_shadowBlocksAreFilled = true;
|
|
}
|
|
if (!opt_shadowBlocksAreFilled && this.isShadow()) {
|
|
return false;
|
|
}
|
|
|
|
// Recursively check each input block of the current block.
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (!input.connection) {
|
|
continue;
|
|
}
|
|
var target = input.connection.targetBlock();
|
|
if (!target || !target.allInputsFilled(opt_shadowBlocksAreFilled)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Recursively check the next block after the current block.
|
|
var next = this.getNextBlock();
|
|
if (next) {
|
|
return next.allInputsFilled(opt_shadowBlocksAreFilled);
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
/**
|
|
* This method returns a string describing this Block in developer terms (type
|
|
* name and ID; English only).
|
|
*
|
|
* Intended to on be used in console logs and errors. If you need a string that
|
|
* uses the user's native language (including block text, field values, and
|
|
* child blocks), use [toString()]{@link Blockly.Block#toString}.
|
|
* @return {string} The description.
|
|
*/
|
|
Blockly.Block.prototype.toDevString = function() {
|
|
var msg = this.type ? '"' + this.type + '" block' : 'Block';
|
|
if (this.id) {
|
|
msg += ' (id="' + this.id + '")';
|
|
}
|
|
return msg;
|
|
};
|