Commit Graph

838 Commits

Author SHA1 Message Date
Andrew n marshall 0da5dda1f0 Fixing JSON support for images in dropdowns. Adding tests. (#851)
Fixes #848.
2017-01-23 13:39:14 -08:00
Andrew n marshall 7b0275cd70 Porting math.js blocks to JSON (#846)
Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips.

Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown.

Now warn on raw string in JSON 'extensions'.
2017-01-23 10:23:55 -08:00
Rachel Fenichel f6168e1364 Merge pull request #840 from rachel-fenichel/bugfix/procedure_rename
Use setValue in fieldTextInput so that procedure renaming works
2017-01-20 22:04:16 -08:00
Andrew n marshall fb0f1b05dd Unit tests for JSON block definitions (just the start) (#850)
* Beginnings of a JSON block definition unit test set.
 * Dispose of unit test workspaces and blocks in finally blocks.
 * Clarify JSON error message by echoing arg notation.
2017-01-20 14:18:33 -08:00
Rachel Fenichel 7413413069 Use bindEvent_ instead of bindEventWithChecks_ for longStop 2017-01-18 18:14:30 -08:00
Rachel Fenichel 915f097480 Use setValue in fieldTextInput so that procedure renaming works 2017-01-18 17:08:40 -08:00
Andrew n marshall 78dc5ed9c2 JSON definitions for colour blocks (#838)
Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions.

Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests.
2017-01-18 13:48:46 -08:00
picklesrus 8aa8b1b3ba Add ability to add a class to a scrollbar so that different types of … (#837)
* Add ability to add a class to a scrollbar so that different types of scrollbars can
be distinguished from each other. You used to be able to do this by looking at the parent
element but now all the scrollbars are siblings in the dom.

Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars
are done correctly.
2017-01-18 13:02:08 -08:00
Andrew n marshall a47bd93f4c Adding extensions for JSON support of dynamic blocks. (#834)
Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators.

Rewrote math_number as an example pure JSON block.
2017-01-18 12:45:39 -08:00
Andrew n marshall bf16f11dbd Replace single quotes with double. (#836)
Fixes commits in #832.
2017-01-18 09:24:29 -08:00
Andrew n marshall 211d973054 FieldNumber & FieldAngle: Default value "0" (#832)
FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value.  The constructor value parameter is now optional. Includes tests.
2017-01-17 15:39:59 -08:00
Neil Fraser 59f408592a Replace 'const' with 'var'.
This unbreaks IE10 and advanced compiled apps such as Blockly Games.
2017-01-16 20:35:28 -08:00
Rachel Fenichel 48df04eb72 Merge pull request #800 from groklearning/add-allInputsFilled-methods
Adds `allInputsFilled` methods to Block and Workspace.
2017-01-16 15:33:21 -08:00
Tim Dawborn 69df716ef5 Fixes as per code review on PR. 2017-01-16 08:48:11 +11:00
Andrew n marshall 4fdd16b499 JSON support for message lookup in colour, tooltip, and help URL. (#825)
String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks.
Demonstrated in logic_boolean.
2017-01-13 16:54:27 -08:00
Andrew n marshall ac3df2759c PR #818: Adding support for string table lookups in dropdown field labels
Adding support for string table lookups in dropdown field labels specified in JSON.

Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens.  Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option.

Replaces the direct JavaScript references (not pure JSON, and thus not portable).

Demonstrating this behavior in the logic_boolean dropdown.
2017-01-11 15:47:56 -08:00
Neil Fraser bea74dbbe3 Fix undo/redo for FieldCheckbox
Thanks to PR #813 by ademenev
2017-01-10 22:18:37 -08:00
Rachel Fenichel 37a4e8ece2 Merge pull request #807 from rachel-fenichel/bugfix/connect_under_flyout
Don't connect to blocks under the flyout.
2017-01-09 14:21:36 -08:00
Rachel Fenichel a0e6d4bbb5 Don't connect to blocks under the flyout. 2017-01-05 16:06:15 -08:00
picklesrus 25ed815320 Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) 2017-01-05 15:39:06 -08:00
Rachel Fenichel 3cd62050a2 Merge pull request #802 from rachel-fenichel/bugfix/field_undo
Fix two event bugs on fields
2017-01-05 13:14:20 -08:00
picklesrus 9f3e15cd82 Move createDom call into the constructor of block drag surface. (#790) 2017-01-04 17:02:06 -08:00
Rachel Fenichel 12ffc655b8 Merge pull request #803 from rachel-fenichel/bugfix/xml_function_rename
Init procedure blocks with empty name, and set default name in xml in…
2017-01-04 13:22:41 -08:00
Rachel Fenichel 158df44a94 Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory 2017-01-03 18:41:28 -08:00
Rachel Fenichel 528ea86cbf Check if the text has changed before firing an event 2017-01-03 14:58:05 -08:00
Rachel Fenichel 056824593e Now that text input's setText skips setValue, it needs to explicitly create a change event 2017-01-03 14:51:28 -08:00
picklesrus eb64921da5 Fix #794 and make the workspace grid drag along with the workspace. (#801)
There was some IE specific code that also applies to Edge so just updated
a conditional to include Edge.
2017-01-03 14:36:31 -08:00
Rachel Fenichel 20cf6abb5f End event groups when you finish editing a field 2017-01-03 14:09:41 -08:00
picklesrus 91938c3fb8 Use the drag surface when scrolling using the scrollbars. #783 (#789) 2017-01-03 10:02:28 -08:00
Tim Dawborn f9e0552c11 Add an allInputsConnected method to Block and Workspace to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off develop instead of master as per discussion in PR #791. 2016-12-28 12:26:53 +11:00
picklesrus 6aee3ed2da Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) 2016-12-16 09:52:19 -08:00
Rachel Fenichel 6b39c7d646 Merge pull request #782 from rachel-fenichel/feature/flyout_disable_resize
Disable workspace resizing while loading the flyout from XML
2016-12-15 11:15:39 -08:00
picklesrus e1cd21842a Add a workspace drag surface that blocks and bubble get moved to duri… (#778)
* Add a workspace drag surface that blocks and bubble get moved to during a workspace drag.
The surface is translated using translate3d instead of svg's translate attribute so that
the browser does not have to repaint the entire workspace on every mouse move.
This is very similar to the block drag surface.

* Address code review comments

* add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE
2016-12-15 11:02:49 -08:00
Rachel Fenichel f54f229bc2 Disable workspace resizing while loading the flyout from XML 2016-12-14 17:06:09 -08:00
picklesrus 5b6f1debeb Move the call to disable resize before placeNewBlock so that it is of… (#777)
* Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents
gets triggered by placeNewBlock.  This fixes a bug in rtl mode where the workspace was being resized
between when the block was added to the workspace and when it was moved to the proper location.
2016-12-14 14:57:32 -08:00
Rachel Fenichel 22b018321c update generator comments 2016-12-09 22:10:36 -08:00
Rachel Fenichel 33d6f72b29 Merge pull request #650 from trodi/generator-docs
Add Generator functions to prototype + JSDoc
2016-12-09 17:46:47 -08:00
picklesrus a82bd49d7e Split the scrollbar and flyout out into their own SVG elements. They (#771)
* Split the scrollbar and flyout out into their own SVG elements. They
are siblings of the workpsace SVG.  This paves the way to make performance
improvements to workspace dragging.
2016-12-09 16:19:19 -08:00
Rodrigo Queiro 8384f8fe05 Make zoom speed independent of event granularity
Before, touchpads would give "smoother" scrolling by delivering lots of
mousewheel events with small distance changes. Because the code only
looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than
one 50px scroll.

This change makes zooming with a touchpad more like zooming with a
mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was
about a 5mm finger movement before, and is now about 3cm.

Fixes #758.
2016-12-09 11:12:28 +01:00
Rachel Fenichel 25ca1bccff Merge pull request #767 from rachel-fenichel/feature/register_button_callbacks_on_workspace
Associate flyout button callbacks directly with workspaces
2016-12-08 14:11:18 -08:00
Rachel Fenichel 086fd720b2 Associate flyout button callbacks directly with workspaces 2016-12-08 13:05:19 -08:00
Neil Fraser 5b86b9792d Don't get Toolbox element unless needed. 2016-12-07 00:22:46 -08:00
Rachel Fenichel 885490b835 Merge pull request #761 from rachel-fenichel/feature/label_classes_2
Add classes to labels with web-style attribute in xml
2016-12-05 15:16:57 -08:00
Rachel Fenichel 729c442c31 lint 2016-12-05 15:14:02 -08:00
Neil Fraser 97644fdf04 Improve comments. 2016-12-03 06:34:18 -08:00
Rachel Fenichel 7f4efe4ebe createSvgElement is now in utils. fix two calls. 2016-12-02 14:12:34 -08:00
Rachel Fenichel 7b783dc30a change 'class' to 'web-style' 2016-12-02 14:08:50 -08:00
Rachel Fenichel 1bac79791e console.log -> console.warn 2016-12-02 14:04:02 -08:00
Rachel Fenichel ff87c76557 Don't make labels clickable 2016-12-02 14:03:49 -08:00
Rachel Fenichel effc1d5f1c Add ability to specify a css class for labels and buttons 2016-12-02 14:01:36 -08:00