init; finish basic css for field_icon_drop_down
Showing
326 changed files
with
4931 additions
and
0 deletions
.editorconfig
0 → 100644
.eslintignore
0 → 100644
.eslintrc
0 → 100644
| 1 | { | ||
| 2 | "rules": { | ||
| 3 | "curly": ["error", "multi-line"], | ||
| 4 | "eol-last": ["error"], | ||
| 5 | "indent": [ | ||
| 6 | "error", 2, # Blockly/Google use 2-space indents | ||
| 7 | # Blockly/Google uses +4 space indents for line continuations. | ||
| 8 | { | ||
| 9 | "SwitchCase": 1, | ||
| 10 | "MemberExpression": 2, | ||
| 11 | "ObjectExpression": 1, | ||
| 12 | "FunctionDeclaration": { | ||
| 13 | "body": 1, | ||
| 14 | "parameters": 2 | ||
| 15 | }, | ||
| 16 | "FunctionExpression": { | ||
| 17 | "body": 1, | ||
| 18 | "parameters": 2 | ||
| 19 | }, | ||
| 20 | "CallExpression": { | ||
| 21 | "arguments": 2 | ||
| 22 | }, | ||
| 23 | # Ignore default rules for ternary expressions. | ||
| 24 | "ignoredNodes": ["ConditionalExpression"] | ||
| 25 | } | ||
| 26 | ], | ||
| 27 | "linebreak-style": ["error", "unix"], | ||
| 28 | "max-len": ["error", 120, 4], | ||
| 29 | "no-trailing-spaces": ["error", { "skipBlankLines": true }], | ||
| 30 | "no-unused-vars": [ | ||
| 31 | "error", | ||
| 32 | { | ||
| 33 | "args": "after-used", | ||
| 34 | # Ignore vars starting with an underscore. | ||
| 35 | "varsIgnorePattern": "^_", | ||
| 36 | # Ignore arguments starting with an underscore. | ||
| 37 | "argsIgnorePattern": "^_" | ||
| 38 | } | ||
| 39 | ], | ||
| 40 | "no-use-before-define": ["error"], | ||
| 41 | "quotes": ["off"], # Blockly mixes single and double quotes | ||
| 42 | "semi": ["error", "always"], | ||
| 43 | "space-before-function-paren": ["error", "never"], # Blockly doesn't have space before function paren | ||
| 44 | "space-infix-ops": ["error"], | ||
| 45 | "strict": ["off"], # Blockly uses 'use strict' in files | ||
| 46 | "no-cond-assign": ["off"], # Blockly often uses cond-assignment in loops | ||
| 47 | "no-redeclare": ["off"], # Closure style allows redeclarations | ||
| 48 | "valid-jsdoc": ["error", {"requireReturn": false}], | ||
| 49 | "no-console": ["off"], | ||
| 50 | "no-constant-condition": ["off"] | ||
| 51 | }, | ||
| 52 | "env": { | ||
| 53 | "browser": true | ||
| 54 | }, | ||
| 55 | "globals": { | ||
| 56 | "Blockly": true, # Blockly global | ||
| 57 | "goog": true, # goog closure libraries/includes | ||
| 58 | }, | ||
| 59 | "extends": "eslint:recommended" | ||
| 60 | } |
.github/CONTRIBUTING.md
0 → 100644
| 1 | ## Contributing | ||
| 2 | The development of Scratch is an ongoing process, and we love to have people in the Scratch and open source communities help us along the way. | ||
| 3 | |||
| 4 | ### Ways to Help | ||
| 5 | |||
| 6 | * **Documenting bugs** | ||
| 7 | * If you've identified a bug in Scratch you should first check to see if it's been filed as an issue, if not you can file one. Make sure you follow the issue template. | ||
| 8 | * It's important that we can consistently reproduce issues. When writing an issue, be sure to follow our [reproduction step guidelines](https://github.com/LLK/scratch-gui/wiki/Writing-good-repro-steps). | ||
| 9 | * Some issues are marked "Needs Repro". Adding a comment with good reproduction steps to those issues is a great way to help. | ||
| 10 | * If you don't have an issue in mind already, you can look through the [Bugs & Glitches forum.](https://scratch.mit.edu/discuss/3/) Look for users reporting problems, reproduce the problem yourself, and file new issues following our guidelines. | ||
| 11 | |||
| 12 | * **Fixing bugs** | ||
| 13 | * You can request to fix a bug in a comment on the issue if you at mention the repo coordinator, who for this repo is @ericrosenbaum. | ||
| 14 | * If the issue is marked "Help Wanted" you can go ahead and start working on it! | ||
| 15 | * **We will only accept Pull Requests for bugs that have an issue filed that has a priority label** | ||
| 16 | * If you're interested in fixing a bug with no issue, file the issue first and wait for it to have a priority added to it. | ||
| 17 | |||
| 18 | * We are not looking for Pull Requests ("PR") for every issue and may deny a PR if it doesn't fit our criteria. | ||
| 19 | * We are far more likely to accept a PR if it is for an issue marked with Help Wanted. | ||
| 20 | * We will not accept PRs for issues marked with "Needs Discussion" or "Needs Design." | ||
| 21 | * Wait until the Repo Coordinator assigns the issue to you before you begin work or submit a PR. | ||
| 22 | |||
| 23 | ### Learning Git and Github | ||
| 24 | |||
| 25 | If you want to work on fixing issues, you should be familiar with Git and Github. | ||
| 26 | |||
| 27 | * [Learn Git branching](https://learngitbranching.js.org/) includes an introduction to basic git commands and useful branching features. | ||
| 28 | * Here's a general introduction to [contributing to an open source project](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). | ||
| 29 | |||
| 30 | **Important:** we follow the [Github Flow process](https://guides.github.com/introduction/flow/) as our development process. | ||
| 31 | |||
| 32 | ### How to Fix Bugs | ||
| 33 | 1. Identify which Github issue you are working on. Leave a comment on the issue to let us (and other contributors) know you're working on it. | ||
| 34 | 2. Make sure you have a fork of this repo (see [Github's forking a repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) for details) | ||
| 35 | 3. Switch to the `develop` branch, and pull down the latest changes from upstream | ||
| 36 | 4. Run the code, and reproduce the problem | ||
| 37 | 5. Create your branch from the `develop` branch | ||
| 38 | 6. Make code changes to fix the problem | ||
| 39 | 7. Run `npm test` to make sure that your changes pass our tests | ||
| 40 | 8. Commit your changes | ||
| 41 | 9. Push your branch to your fork | ||
| 42 | 10. Create your pull request | ||
| 43 | 1. Make sure to follow the template in the PR description | ||
| 44 | 1. Remember to check the “[Allow edits from maintainers](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork)” box | ||
| 45 | |||
| 46 | When submitting pull requests keep in mind: | ||
| 47 | * please be patient -- it can take a while to find time to review them | ||
| 48 | * try to change the least amount of code necessary to fix the bug | ||
| 49 | * the code can't be radically changed without significant coordination with the Scratch Team, so these types of changes should be avoided | ||
| 50 | * if you find yourself changing a substantial amount of code or considering radical changes, please ask for clarification -- we may have envisioned a different approach, or underestimated the amount of effort | ||
| 51 | |||
| 52 | ### Suggestions | ||
| 53 |  | ||
| 54 | |||
| 55 | Please note: **_we are unlikely to accept PRs with new features that haven't been thought through and discussed as a group_**. | ||
| 56 | |||
| 57 | Why? Because we have a strong belief in the value of keeping things simple for new users. It's been said that the Scratch Team spends about one hour of design discussion for every pixel in Scratch. To learn more about our design philosophy, see [the Scratch Developers page](https://scratch.mit.edu/developers), or [this paper](http://web.media.mit.edu/~mres/papers/Scratch-CACM-final.pdf). | ||
| 58 | |||
| 59 | We welcome suggestions! If you want to suggest a feature, please post in our [suggestions forum](https://scratch.mit.edu/discuss/1/). Your suggestion will be helped if you include a mockup design; this can be simple, even hand-drawn. | ||
| 60 | |||
| 61 | ### Other resources | ||
| 62 | Beyond this repo, there are also some other resources that you might want to take a look at: | ||
| 63 | * [Community Guidelines](https://github.com/LLK/scratch-www/wiki/Community-Guidelines) (we find it important to maintain a constructive and welcoming community, just like on Scratch) | ||
| 64 | * [Open Source forum](https://scratch.mit.edu/discuss/49/) on Scratch | ||
| 65 | * [Suggestions forum](https://scratch.mit.edu/discuss/1/) on Scratch | ||
| 66 | * [Bugs & Glitches forum](https://scratch.mit.edu/discuss/3/) on Scratch |
.github/ISSUE_TEMPLATE.md
0 → 100644
| 1 | ### Expected Behavior | ||
| 2 | |||
| 3 | _Please describe what should happen_ | ||
| 4 | |||
| 5 | ### Actual Behavior | ||
| 6 | |||
| 7 | _Describe what actually happens_ | ||
| 8 | |||
| 9 | ### Steps to Reproduce | ||
| 10 | |||
| 11 | _Explain what someone needs to do in order to see what's described in *Actual behavior* above_ | ||
| 12 | |||
| 13 | ### Operating System and Browser | ||
| 14 | |||
| 15 | _e.g. Mac OS 10.11.6 Safari 10.0_ |
.github/PULL_REQUEST_TEMPLATE.md
0 → 100644
| 1 | ### Resolves | ||
| 2 | |||
| 3 | _What Github issue does this resolve (please include link)?_ | ||
| 4 | |||
| 5 | ### Proposed Changes | ||
| 6 | |||
| 7 | _Describe what this Pull Request does_ | ||
| 8 | |||
| 9 | ### Reason for Changes | ||
| 10 | |||
| 11 | _Explain why these changes should be made_ | ||
| 12 | |||
| 13 | ### Test Coverage | ||
| 14 | |||
| 15 | _Please show how you have added tests to cover your changes_ |
.github/workflows/publish-npm-package.yml
0 → 100644
| 1 | name: Publish Npm Package | ||
| 2 | |||
| 3 | on: | ||
| 4 | push: | ||
| 5 | branches: [ main ] | ||
| 6 | paths-ignore: | ||
| 7 | - 'README.md' | ||
| 8 | - '.github/*' | ||
| 9 | |||
| 10 | jobs: | ||
| 11 | check: | ||
| 12 | runs-on: ubuntu-latest | ||
| 13 | strategy: | ||
| 14 | matrix: | ||
| 15 | node-version: [14.x, 16.x] | ||
| 16 | steps: | ||
| 17 | - uses: actions/checkout@v2 | ||
| 18 | |||
| 19 | - name: Use Node.js ${{ matrix.node-version }} | ||
| 20 | uses: actions/setup-node@v2 | ||
| 21 | with: | ||
| 22 | node-version: ${{ matrix.node-version }} | ||
| 23 | cache: 'npm' | ||
| 24 | |||
| 25 | - name: Set up Python 2.7 | ||
| 26 | run: | | ||
| 27 | sudo apt-get update | ||
| 28 | sudo apt-get install -y \ | ||
| 29 | python2.7 python2.7-dev python2-pip-whl | ||
| 30 | sudo ln -sf python2.7 /usr/bin/python | ||
| 31 | export PYTHONPATH=`echo /usr/share/python-wheels/pip-*py2*.whl` | ||
| 32 | sudo --preserve-env=PYTHONPATH python -m pip install --upgrade pip setuptools wheel | ||
| 33 | sudo chown -R $USER /usr/local/lib/python2.7 | ||
| 34 | |||
| 35 | - name: Cache node modules | ||
| 36 | uses: actions/cache@v2 | ||
| 37 | env: | ||
| 38 | cache-name: cache-node-modules | ||
| 39 | with: | ||
| 40 | path: ~/.npm | ||
| 41 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
| 42 | restore-keys: | | ||
| 43 | ${{ runner.os }}-build-${{ env.cache-name }}- | ||
| 44 | ${{ runner.os }}-build- | ||
| 45 | ${{ runner.os }}- | ||
| 46 | |||
| 47 | - run: npm ci | ||
| 48 | |||
| 49 | - name: Set test env | ||
| 50 | run: | | ||
| 51 | CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') | ||
| 52 | CHROME_MAJOR_VERSION=$(echo $CHROME_VERSION | cut -d '.' -f 1) | ||
| 53 | npm install --save-dev chromedriver@$CHROME_MAJOR_VERSION | ||
| 54 | export DISPLAY=:99.0 | ||
| 55 | tests/scripts/setup_linux_env.sh | ||
| 56 | sleep 2 | ||
| 57 | |||
| 58 | - run: npm test | ||
| 59 | |||
| 60 | publish: | ||
| 61 | needs: check | ||
| 62 | runs-on: ubuntu-latest | ||
| 63 | steps: | ||
| 64 | - uses: actions/checkout@v2 | ||
| 65 | |||
| 66 | - uses: actions/setup-node@v2 | ||
| 67 | with: | ||
| 68 | node-version: '14.x' | ||
| 69 | |||
| 70 | - name: Cache node modules | ||
| 71 | uses: actions/cache@v2 | ||
| 72 | env: | ||
| 73 | cache-name: cache-node-modules | ||
| 74 | with: | ||
| 75 | path: ~/.npm | ||
| 76 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
| 77 | restore-keys: | | ||
| 78 | ${{ runner.os }}-build-${{ env.cache-name }}- | ||
| 79 | ${{ runner.os }}-build- | ||
| 80 | ${{ runner.os }}- | ||
| 81 | |||
| 82 | - name: Set up Python 2.7 | ||
| 83 | run: | | ||
| 84 | sudo apt-get update | ||
| 85 | sudo apt-get install -y \ | ||
| 86 | python2.7 python2.7-dev python2-pip-whl | ||
| 87 | sudo ln -sf python2.7 /usr/bin/python | ||
| 88 | export PYTHONPATH=`echo /usr/share/python-wheels/pip-*py2*.whl` | ||
| 89 | sudo --preserve-env=PYTHONPATH python -m pip install --upgrade pip setuptools wheel | ||
| 90 | sudo chown -R $USER /usr/local/lib/python2.7 | ||
| 91 | |||
| 92 | - run: npm ci | ||
| 93 | |||
| 94 | - name: Update openblock-l10n | ||
| 95 | run: npm i --save openblock-l10n@latest | ||
| 96 | |||
| 97 | # Don't push translations to TX, just pull, The push step will be run by the distro repository. | ||
| 98 | # - name: Sync translations | ||
| 99 | # run: | | ||
| 100 | # export TX_TOKEN=${{ secrets.TX_TOKEN }} | ||
| 101 | # npm run translate | ||
| 102 | # npm run translate:update | ||
| 103 | - name: Pull translations | ||
| 104 | run: | | ||
| 105 | export TX_TOKEN=${{ secrets.TX_TOKEN }} | ||
| 106 | npm run translate | ||
| 107 | npm run translate:sync:translations | ||
| 108 | |||
| 109 | - name: Set test env | ||
| 110 | run: | | ||
| 111 | CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') | ||
| 112 | CHROME_MAJOR_VERSION=$(echo $CHROME_VERSION | cut -d '.' -f 1) | ||
| 113 | npm install --save-dev chromedriver@$CHROME_MAJOR_VERSION | ||
| 114 | export DISPLAY=:99.0 | ||
| 115 | tests/scripts/setup_linux_env.sh | ||
| 116 | sleep 2 | ||
| 117 | |||
| 118 | - run: npm test | ||
| 119 | |||
| 120 | - name: Check for modified files | ||
| 121 | id: git-check | ||
| 122 | # Check if there are any files update, but ignore the case where only package-lock.json is updated. | ||
| 123 | run: | | ||
| 124 | echo ::set-output name=modified::$(if [ -n "$(git status --porcelain)" ] && [ "$(git status --porcelain)" != " M package-lock.json" ]; then echo "true"; else echo "false"; fi) | ||
| 125 | |||
| 126 | - name: Commit translations | ||
| 127 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 128 | run: | | ||
| 129 | git config --global user.name github-actions | ||
| 130 | git config --global user.email github-actions@github.com | ||
| 131 | git add . | ||
| 132 | git commit -m '[skip ci] Update translations from transifex' | ||
| 133 | git remote add origin-translation https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/$GITHUB_REPOSITORY | ||
| 134 | git push --set-upstream origin-translation main | ||
| 135 | |||
| 136 | - name: Get package main version | ||
| 137 | id: package-version | ||
| 138 | uses: martinbeentjes/npm-get-version-action@v1.1.0 | ||
| 139 | |||
| 140 | - name: Generate release version | ||
| 141 | run: | | ||
| 142 | echo "RELEASE_VERSION=${{ steps.package-version.outputs.current-version }}-prerelease.$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | ||
| 143 | |||
| 144 | - name: Set package version | ||
| 145 | run: npm --no-git-tag-version version $RELEASE_VERSION | ||
| 146 | |||
| 147 | - name: Tag release | ||
| 148 | run: | | ||
| 149 | git tag $RELEASE_VERSION | ||
| 150 | git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/$GITHUB_REPOSITORY $RELEASE_VERSION | ||
| 151 | |||
| 152 | - name: Deploy with gh-pages | ||
| 153 | run: | | ||
| 154 | git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | ||
| 155 | git apply gh-pages/patch | ||
| 156 | npm run prepublish | ||
| 157 | npm run deploy -- -u "github-actions-bot <support+actions@github.com>" | ||
| 158 | env: | ||
| 159 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| 160 | |||
| 161 | - uses: JS-DevTools/npm-publish@v1 | ||
| 162 | with: | ||
| 163 | token: ${{ secrets.NPM_TOKEN }} | ||
| 164 |
.github/workflows/pull-request-check.yml
0 → 100644
| 1 | name: Pull Request Check | ||
| 2 | |||
| 3 | on: | ||
| 4 | pull_request: | ||
| 5 | branches: [ main ] | ||
| 6 | paths-ignore: | ||
| 7 | - 'README.md' | ||
| 8 | |||
| 9 | jobs: | ||
| 10 | check: | ||
| 11 | runs-on: ubuntu-latest | ||
| 12 | strategy: | ||
| 13 | matrix: | ||
| 14 | node-version: [14.x, 16.x] | ||
| 15 | steps: | ||
| 16 | - uses: actions/checkout@v2 | ||
| 17 | |||
| 18 | - name: Use Node.js ${{ matrix.node-version }} | ||
| 19 | uses: actions/setup-node@v2 | ||
| 20 | with: | ||
| 21 | node-version: ${{ matrix.node-version }} | ||
| 22 | cache: 'npm' | ||
| 23 | |||
| 24 | - name: Set up Python 2.7 | ||
| 25 | run: | | ||
| 26 | sudo apt-get update | ||
| 27 | sudo apt-get install -y \ | ||
| 28 | python2.7 python2.7-dev python2-pip-whl | ||
| 29 | sudo ln -sf python2.7 /usr/bin/python | ||
| 30 | export PYTHONPATH=`echo /usr/share/python-wheels/pip-*py2*.whl` | ||
| 31 | sudo --preserve-env=PYTHONPATH python -m pip install --upgrade pip setuptools wheel | ||
| 32 | sudo chown -R $USER /usr/local/lib/python2.7 | ||
| 33 | |||
| 34 | - name: Set test env | ||
| 35 | run: | | ||
| 36 | CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') | ||
| 37 | CHROME_MAJOR_VERSION=$(echo $CHROME_VERSION | cut -d '.' -f 1) | ||
| 38 | npm install --save-dev chromedriver@$CHROME_MAJOR_VERSION | ||
| 39 | export DISPLAY=:99.0 | ||
| 40 | tests/scripts/setup_linux_env.sh | ||
| 41 | sleep 2 | ||
| 42 | |||
| 43 | - run: npm ci | ||
| 44 | |||
| 45 | - run: npm test |
| 1 | name: Weekly Update Translations | ||
| 2 | |||
| 3 | on: | ||
| 4 | schedule: | ||
| 5 | - cron: '0 1 * * 1,4' # Runs at 01:00 UTC on Monday and Thursday | ||
| 6 | |||
| 7 | jobs: | ||
| 8 | weekly-update: | ||
| 9 | runs-on: ubuntu-latest | ||
| 10 | steps: | ||
| 11 | - uses: actions/checkout@v2 | ||
| 12 | |||
| 13 | - uses: actions/setup-node@v2 | ||
| 14 | with: | ||
| 15 | node-version: '14.x' | ||
| 16 | |||
| 17 | - name: Cache node modules | ||
| 18 | uses: actions/cache@v2 | ||
| 19 | env: | ||
| 20 | cache-name: cache-node-modules | ||
| 21 | with: | ||
| 22 | path: ~/.npm | ||
| 23 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
| 24 | restore-keys: | | ||
| 25 | ${{ runner.os }}-build-${{ env.cache-name }}- | ||
| 26 | ${{ runner.os }}-build- | ||
| 27 | ${{ runner.os }}- | ||
| 28 | |||
| 29 | - name: Set up Python 2.7 | ||
| 30 | run: | | ||
| 31 | sudo apt-get update | ||
| 32 | sudo apt-get install -y \ | ||
| 33 | python2.7 python2.7-dev python2-pip-whl | ||
| 34 | sudo ln -sf python2.7 /usr/bin/python | ||
| 35 | export PYTHONPATH=`echo /usr/share/python-wheels/pip-*py2*.whl` | ||
| 36 | sudo --preserve-env=PYTHONPATH python -m pip install --upgrade pip setuptools wheel | ||
| 37 | sudo chown -R $USER /usr/local/lib/python2.7 | ||
| 38 | |||
| 39 | - run: npm ci | ||
| 40 | |||
| 41 | - name: Update openblock-l10n | ||
| 42 | run: npm i --save openblock-l10n@latest | ||
| 43 | |||
| 44 | # Don't push translations to TX, just pull, The push step will be run by the enterprise edition repository. | ||
| 45 | # - name: Sync translations | ||
| 46 | # run: | | ||
| 47 | # export TX_TOKEN=${{ secrets.TX_TOKEN }} | ||
| 48 | # npm run translate | ||
| 49 | # npm run translate:update | ||
| 50 | - name: Pull translations | ||
| 51 | run: | | ||
| 52 | export TX_TOKEN=${{ secrets.TX_TOKEN }} | ||
| 53 | npm run translate | ||
| 54 | npm run translate:sync:translations | ||
| 55 | |||
| 56 | - name: Check for modified files | ||
| 57 | id: git-check | ||
| 58 | # Check if there are any files update, but ignore the case where only package-lock.json is updated. | ||
| 59 | run: | | ||
| 60 | echo ::set-output name=modified::$(if [ -n "$(git status --porcelain)" ] && [ "$(git status --porcelain)" != " M package-lock.json" ]; then echo "true"; else echo "false"; fi) | ||
| 61 | |||
| 62 | - name: Set test env | ||
| 63 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 64 | run: | | ||
| 65 | CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') | ||
| 66 | CHROME_MAJOR_VERSION=$(echo $CHROME_VERSION | cut -d '.' -f 1) | ||
| 67 | npm install --save-dev chromedriver@$CHROME_MAJOR_VERSION | ||
| 68 | export DISPLAY=:99.0 | ||
| 69 | tests/scripts/setup_linux_env.sh | ||
| 70 | sleep 2 | ||
| 71 | |||
| 72 | - run: npm test | ||
| 73 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 74 | |||
| 75 | - name: Update translations changes in GitHub repository | ||
| 76 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 77 | id: git-push | ||
| 78 | run: | | ||
| 79 | git config --global user.name github-actions | ||
| 80 | git config --global user.email github-actions@github.com | ||
| 81 | git add . | ||
| 82 | git commit -m '[skip ci] Update translations from transifex' | ||
| 83 | git remote add origin-translation https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/$GITHUB_REPOSITORY | ||
| 84 | git push --set-upstream origin-translation main | ||
| 85 | |||
| 86 | - name: Get package main version | ||
| 87 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 88 | id: package-version | ||
| 89 | uses: martinbeentjes/npm-get-version-action@v1.1.0 | ||
| 90 | |||
| 91 | - name: Generate release version | ||
| 92 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 93 | run: | | ||
| 94 | echo "RELEASE_VERSION=${{ steps.package-version.outputs.current-version }}-prerelease.$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | ||
| 95 | |||
| 96 | - name: Set package version | ||
| 97 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 98 | run: npm --no-git-tag-version version $RELEASE_VERSION | ||
| 99 | |||
| 100 | - name: Tag release | ||
| 101 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 102 | run: | | ||
| 103 | git tag $RELEASE_VERSION | ||
| 104 | git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/$GITHUB_REPOSITORY $RELEASE_VERSION | ||
| 105 | |||
| 106 | - uses: JS-DevTools/npm-publish@v1 | ||
| 107 | if: ${{ steps.git-check.outputs.modified == 'true' }} | ||
| 108 | with: | ||
| 109 | token: ${{ secrets.NPM_TOKEN }} |
.gitignore
0 → 100644
| 1 | # OSX | ||
| 2 | .DS_Store | ||
| 3 | |||
| 4 | # NPM | ||
| 5 | /node_modules | ||
| 6 | npm-* | ||
| 7 | |||
| 8 | # Localization / I18N | ||
| 9 | common.pyc | ||
| 10 | .settings | ||
| 11 | .project | ||
| 12 | *.pyc | ||
| 13 | *.komodoproject | ||
| 14 | /nbproject/private/ | ||
| 15 | |||
| 16 | # Unused by openblock-blocks | ||
| 17 | arduino_compressed.js | ||
| 18 | dart_compressed.js | ||
| 19 | javascript_compressed.js | ||
| 20 | lua_compressed.js | ||
| 21 | php_compressed.js | ||
| 22 | python_compressed.js | ||
| 23 | |||
| 24 | # Editor | ||
| 25 | .vscode | ||
| 26 | |||
| 27 | # Chromedriver | ||
| 28 | LICENSE.chromedriver | ||
| 29 | |||
| 30 | /accessible/* | ||
| 31 | /dist | ||
| 32 | /msg/js/* | ||
| 33 | !/msg/js/en.js | ||
| 34 | /msg/json/* | ||
| 35 | !/msg/json/en.json | ||
| 36 | /blockly_compressed_horizontal.js | ||
| 37 | /blockly_compressed_vertical.js | ||
| 38 | /blockly_uncompressed_horizontal.js | ||
| 39 | /blockly_uncompressed_vertical.js | ||
| 40 | /blocks_compressed_horizontal.js | ||
| 41 | /blocks_compressed_vertical.js | ||
| 42 | /blocks_compressed.js | ||
| 43 | /gh-pages/main.js | ||
| 44 | /gh-pages/playgrounds | ||
| 45 | /gh-pages/Gemfile.lock | ||
| 46 | /gh-pages/closure-library | ||
| 47 | /gh-pages/_site | ||
| 48 | /*compiler*.jar | ||
| 49 | /local_blockly_compressed_vertical.js | ||
| 50 | /chromedriver |
.npmignore
0 → 100644
| 1 | # Development files | ||
| 2 | .eslintrc | ||
| 3 | /.editorconfig | ||
| 4 | /.eslintignore | ||
| 5 | /.gitattributes | ||
| 6 | /.github | ||
| 7 | /.travis.yml | ||
| 8 | /.tx | ||
| 9 | /tests | ||
| 10 | /webpack.config.js | ||
| 11 | |||
| 12 | # Localization / I18N | ||
| 13 | common.pyc | ||
| 14 | .settings | ||
| 15 | .project | ||
| 16 | *.pyc | ||
| 17 | *.komodoproject | ||
| 18 | /nbproject/private/ | ||
| 19 | |||
| 20 | /accessible/* | ||
| 21 | |||
| 22 | # Build created files | ||
| 23 | /gh-pages | ||
| 24 | |||
| 25 | # Chromedriver | ||
| 26 | /LICENSE.chromedriver | ||
| 27 | |||
| 28 | # Exclude already built packages from testing with npm pack | ||
| 29 | /openblock-blocks-*.{tar,tgz} |
.tx/config
0 → 100644
LICENSE
0 → 100644
| 1 | |||
| 2 | Apache License | ||
| 3 | Version 2.0, January 2011 | ||
| 4 | http://www.apache.org/licenses/ | ||
| 5 | |||
| 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||
| 7 | |||
| 8 | 1. Definitions. | ||
| 9 | |||
| 10 | "License" shall mean the terms and conditions for use, reproduction, | ||
| 11 | and distribution as defined by Sections 1 through 9 of this document. | ||
| 12 | |||
| 13 | "Licensor" shall mean the copyright owner or entity authorized by | ||
| 14 | the copyright owner that is granting the License. | ||
| 15 | |||
| 16 | "Legal Entity" shall mean the union of the acting entity and all | ||
| 17 | other entities that control, are controlled by, or are under common | ||
| 18 | control with that entity. For the purposes of this definition, | ||
| 19 | "control" means (i) the power, direct or indirect, to cause the | ||
| 20 | direction or management of such entity, whether by contract or | ||
| 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the | ||
| 22 | outstanding shares, or (iii) beneficial ownership of such entity. | ||
| 23 | |||
| 24 | "You" (or "Your") shall mean an individual or Legal Entity | ||
| 25 | exercising permissions granted by this License. | ||
| 26 | |||
| 27 | "Source" form shall mean the preferred form for making modifications, | ||
| 28 | including but not limited to software source code, documentation | ||
| 29 | source, and configuration files. | ||
| 30 | |||
| 31 | "Object" form shall mean any form resulting from mechanical | ||
| 32 | transformation or translation of a Source form, including but | ||
| 33 | not limited to compiled object code, generated documentation, | ||
| 34 | and conversions to other media types. | ||
| 35 | |||
| 36 | "Work" shall mean the work of authorship, whether in Source or | ||
| 37 | Object form, made available under the License, as indicated by a | ||
| 38 | copyright notice that is included in or attached to the work | ||
| 39 | (an example is provided in the Appendix below). | ||
| 40 | |||
| 41 | "Derivative Works" shall mean any work, whether in Source or Object | ||
| 42 | form, that is based on (or derived from) the Work and for which the | ||
| 43 | editorial revisions, annotations, elaborations, or other modifications | ||
| 44 | represent, as a whole, an original work of authorship. For the purposes | ||
| 45 | of this License, Derivative Works shall not include works that remain | ||
| 46 | separable from, or merely link (or bind by name) to the interfaces of, | ||
| 47 | the Work and Derivative Works thereof. | ||
| 48 | |||
| 49 | "Contribution" shall mean any work of authorship, including | ||
| 50 | the original version of the Work and any modifications or additions | ||
| 51 | to that Work or Derivative Works thereof, that is intentionally | ||
| 52 | submitted to Licensor for inclusion in the Work by the copyright owner | ||
| 53 | or by an individual or Legal Entity authorized to submit on behalf of | ||
| 54 | the copyright owner. For the purposes of this definition, "submitted" | ||
| 55 | means any form of electronic, verbal, or written communication sent | ||
| 56 | to the Licensor or its representatives, including but not limited to | ||
| 57 | communication on electronic mailing lists, source code control systems, | ||
| 58 | and issue tracking systems that are managed by, or on behalf of, the | ||
| 59 | Licensor for the purpose of discussing and improving the Work, but | ||
| 60 | excluding communication that is conspicuously marked or otherwise | ||
| 61 | designated in writing by the copyright owner as "Not a Contribution." | ||
| 62 | |||
| 63 | "Contributor" shall mean Licensor and any individual or Legal Entity | ||
| 64 | on behalf of whom a Contribution has been received by Licensor and | ||
| 65 | subsequently incorporated within the Work. | ||
| 66 | |||
| 67 | 2. Grant of Copyright License. Subject to the terms and conditions of | ||
| 68 | this License, each Contributor hereby grants to You a perpetual, | ||
| 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
| 70 | copyright license to reproduce, prepare Derivative Works of, | ||
| 71 | publicly display, publicly perform, sublicense, and distribute the | ||
| 72 | Work and such Derivative Works in Source or Object form. | ||
| 73 | |||
| 74 | 3. Grant of Patent License. Subject to the terms and conditions of | ||
| 75 | this License, each Contributor hereby grants to You a perpetual, | ||
| 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
| 77 | (except as stated in this section) patent license to make, have made, | ||
| 78 | use, offer to sell, sell, import, and otherwise transfer the Work, | ||
| 79 | where such license applies only to those patent claims licensable | ||
| 80 | by such Contributor that are necessarily infringed by their | ||
| 81 | Contribution(s) alone or by combination of their Contribution(s) | ||
| 82 | with the Work to which such Contribution(s) was submitted. If You | ||
| 83 | institute patent litigation against any entity (including a | ||
| 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work | ||
| 85 | or a Contribution incorporated within the Work constitutes direct | ||
| 86 | or contributory patent infringement, then any patent licenses | ||
| 87 | granted to You under this License for that Work shall terminate | ||
| 88 | as of the date such litigation is filed. | ||
| 89 | |||
| 90 | 4. Redistribution. You may reproduce and distribute copies of the | ||
| 91 | Work or Derivative Works thereof in any medium, with or without | ||
| 92 | modifications, and in Source or Object form, provided that You | ||
| 93 | meet the following conditions: | ||
| 94 | |||
| 95 | (a) You must give any other recipients of the Work or | ||
| 96 | Derivative Works a copy of this License; and | ||
| 97 | |||
| 98 | (b) You must cause any modified files to carry prominent notices | ||
| 99 | stating that You changed the files; and | ||
| 100 | |||
| 101 | (c) You must retain, in the Source form of any Derivative Works | ||
| 102 | that You distribute, all copyright, patent, trademark, and | ||
| 103 | attribution notices from the Source form of the Work, | ||
| 104 | excluding those notices that do not pertain to any part of | ||
| 105 | the Derivative Works; and | ||
| 106 | |||
| 107 | (d) If the Work includes a "NOTICE" text file as part of its | ||
| 108 | distribution, then any Derivative Works that You distribute must | ||
| 109 | include a readable copy of the attribution notices contained | ||
| 110 | within such NOTICE file, excluding those notices that do not | ||
| 111 | pertain to any part of the Derivative Works, in at least one | ||
| 112 | of the following places: within a NOTICE text file distributed | ||
| 113 | as part of the Derivative Works; within the Source form or | ||
| 114 | documentation, if provided along with the Derivative Works; or, | ||
| 115 | within a display generated by the Derivative Works, if and | ||
| 116 | wherever such third-party notices normally appear. The contents | ||
| 117 | of the NOTICE file are for informational purposes only and | ||
| 118 | do not modify the License. You may add Your own attribution | ||
| 119 | notices within Derivative Works that You distribute, alongside | ||
| 120 | or as an addendum to the NOTICE text from the Work, provided | ||
| 121 | that such additional attribution notices cannot be construed | ||
| 122 | as modifying the License. | ||
| 123 | |||
| 124 | You may add Your own copyright statement to Your modifications and | ||
| 125 | may provide additional or different license terms and conditions | ||
| 126 | for use, reproduction, or distribution of Your modifications, or | ||
| 127 | for any such Derivative Works as a whole, provided Your use, | ||
| 128 | reproduction, and distribution of the Work otherwise complies with | ||
| 129 | the conditions stated in this License. | ||
| 130 | |||
| 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, | ||
| 132 | any Contribution intentionally submitted for inclusion in the Work | ||
| 133 | by You to the Licensor shall be under the terms and conditions of | ||
| 134 | this License, without any additional terms or conditions. | ||
| 135 | Notwithstanding the above, nothing herein shall supersede or modify | ||
| 136 | the terms of any separate license agreement you may have executed | ||
| 137 | with Licensor regarding such Contributions. | ||
| 138 | |||
| 139 | 6. Trademarks. This License does not grant permission to use the trade | ||
| 140 | names, trademarks, service marks, or product names of the Licensor, | ||
| 141 | except as required for reasonable and customary use in describing the | ||
| 142 | origin of the Work and reproducing the content of the NOTICE file. | ||
| 143 | |||
| 144 | 7. Disclaimer of Warranty. Unless required by applicable law or | ||
| 145 | agreed to in writing, Licensor provides the Work (and each | ||
| 146 | Contributor provides its Contributions) on an "AS IS" BASIS, | ||
| 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
| 148 | implied, including, without limitation, any warranties or conditions | ||
| 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | ||
| 150 | PARTICULAR PURPOSE. You are solely responsible for determining the | ||
| 151 | appropriateness of using or redistributing the Work and assume any | ||
| 152 | risks associated with Your exercise of permissions under this License. | ||
| 153 | |||
| 154 | 8. Limitation of Liability. In no event and under no legal theory, | ||
| 155 | whether in tort (including negligence), contract, or otherwise, | ||
| 156 | unless required by applicable law (such as deliberate and grossly | ||
| 157 | negligent acts) or agreed to in writing, shall any Contributor be | ||
| 158 | liable to You for damages, including any direct, indirect, special, | ||
| 159 | incidental, or consequential damages of any character arising as a | ||
| 160 | result of this License or out of the use or inability to use the | ||
| 161 | Work (including but not limited to damages for loss of goodwill, | ||
| 162 | work stoppage, computer failure or malfunction, or any and all | ||
| 163 | other commercial damages or losses), even if such Contributor | ||
| 164 | has been advised of the possibility of such damages. | ||
| 165 | |||
| 166 | 9. Accepting Warranty or Additional Liability. While redistributing | ||
| 167 | the Work or Derivative Works thereof, You may choose to offer, | ||
| 168 | and charge a fee for, acceptance of support, warranty, indemnity, | ||
| 169 | or other liability obligations and/or rights consistent with this | ||
| 170 | License. However, in accepting such obligations, You may act only | ||
| 171 | on Your own behalf and on Your sole responsibility, not on behalf | ||
| 172 | of any other Contributor, and only if You agree to indemnify, | ||
| 173 | defend, and hold each Contributor harmless for any liability | ||
| 174 | incurred by, or claims asserted against, such Contributor by reason | ||
| 175 | of your accepting any such warranty or additional liability. | ||
| 176 | |||
| 177 | END OF TERMS AND CONDITIONS |
TRADEMARK
0 → 100644
| 1 | The Scratch trademarks, including the Scratch name, logo, the Scratch Cat, Gobo, Pico, Nano, Tera and Giga graphics (the "Marks"), are property of the Massachusetts Institute of Technology (MIT). Marks may not be used to endorse or promote products derived from this software without specific prior written permission. |
blocks_common/colour.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2012 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Colour blocks for Blockly. | ||
| 23 | * @author fraser@google.com (Neil Fraser) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.colour'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.constants'); | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Pick a random colour. | ||
| 35 | * @return {string} #RRGGBB for random colour. | ||
| 36 | */ | ||
| 37 | function randomColour() { | ||
| 38 | var num = Math.floor(Math.random() * Math.pow(2, 24)); | ||
| 39 | return '#' + ('00000' + num.toString(16)).substr(-6); | ||
| 40 | } | ||
| 41 | |||
| 42 | Blockly.Blocks['colour_picker'] = { | ||
| 43 | /** | ||
| 44 | * Block for colour picker. | ||
| 45 | * @this Blockly.Block | ||
| 46 | */ | ||
| 47 | init: function() { | ||
| 48 | this.jsonInit({ | ||
| 49 | "message0": "%1", | ||
| 50 | "args0": [ | ||
| 51 | { | ||
| 52 | "type": "field_colour_slider", | ||
| 53 | "name": "COLOUR", | ||
| 54 | "colour": randomColour() | ||
| 55 | } | ||
| 56 | ], | ||
| 57 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 58 | "output": "Colour" | ||
| 59 | }); | ||
| 60 | } | ||
| 61 | }; |
blocks_common/math.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2012 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Math blocks for Blockly. | ||
| 23 | * @author q.neutron@gmail.com (Quynh Neutron) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.math'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.Colours'); | ||
| 32 | |||
| 33 | goog.require('Blockly.constants'); | ||
| 34 | |||
| 35 | Blockly.Blocks['math_number'] = { | ||
| 36 | /** | ||
| 37 | * Block for generic numeric value. | ||
| 38 | * @this Blockly.Block | ||
| 39 | */ | ||
| 40 | init: function() { | ||
| 41 | this.jsonInit({ | ||
| 42 | "message0": "%1", | ||
| 43 | "args0": [ | ||
| 44 | { | ||
| 45 | "type": "field_number", | ||
| 46 | "name": "NUM", | ||
| 47 | "value": "0" | ||
| 48 | } | ||
| 49 | ], | ||
| 50 | "output": "Number", | ||
| 51 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 52 | "colour": Blockly.Colours.textField, | ||
| 53 | "colourSecondary": Blockly.Colours.textField, | ||
| 54 | "colourTertiary": Blockly.Colours.textField | ||
| 55 | }); | ||
| 56 | } | ||
| 57 | }; | ||
| 58 | |||
| 59 | Blockly.Blocks['math_integer'] = { | ||
| 60 | /** | ||
| 61 | * Block for integer value (no decimal, + or -). | ||
| 62 | * @this Blockly.Block | ||
| 63 | */ | ||
| 64 | init: function() { | ||
| 65 | this.jsonInit({ | ||
| 66 | "message0": "%1", | ||
| 67 | "args0": [ | ||
| 68 | { | ||
| 69 | "type": "field_number", | ||
| 70 | "name": "NUM", | ||
| 71 | "precision": 1 | ||
| 72 | } | ||
| 73 | ], | ||
| 74 | "output": "Number", | ||
| 75 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 76 | "colour": Blockly.Colours.textField, | ||
| 77 | "colourSecondary": Blockly.Colours.textField, | ||
| 78 | "colourTertiary": Blockly.Colours.textField | ||
| 79 | }); | ||
| 80 | } | ||
| 81 | }; | ||
| 82 | |||
| 83 | Blockly.Blocks['math_whole_number'] = { | ||
| 84 | /** | ||
| 85 | * Block for whole number value, no negatives or decimals. | ||
| 86 | * @this Blockly.Block | ||
| 87 | */ | ||
| 88 | init: function() { | ||
| 89 | this.jsonInit({ | ||
| 90 | "message0": "%1", | ||
| 91 | "args0": [ | ||
| 92 | { | ||
| 93 | "type": "field_number", | ||
| 94 | "name": "NUM", | ||
| 95 | "min": 0, | ||
| 96 | "precision": 1 | ||
| 97 | } | ||
| 98 | ], | ||
| 99 | "output": "Number", | ||
| 100 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 101 | "colour": Blockly.Colours.textField, | ||
| 102 | "colourSecondary": Blockly.Colours.textField, | ||
| 103 | "colourTertiary": Blockly.Colours.textField | ||
| 104 | }); | ||
| 105 | } | ||
| 106 | }; | ||
| 107 | |||
| 108 | Blockly.Blocks['math_positive_number'] = { | ||
| 109 | /** | ||
| 110 | * Block for positive number value, with decimal. | ||
| 111 | * @this Blockly.Block | ||
| 112 | */ | ||
| 113 | init: function() { | ||
| 114 | this.jsonInit({ | ||
| 115 | "message0": "%1", | ||
| 116 | "args0": [ | ||
| 117 | { | ||
| 118 | "type": "field_number", | ||
| 119 | "name": "NUM", | ||
| 120 | "min": 0 | ||
| 121 | } | ||
| 122 | ], | ||
| 123 | "output": "Number", | ||
| 124 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 125 | "colour": Blockly.Colours.textField, | ||
| 126 | "colourSecondary": Blockly.Colours.textField, | ||
| 127 | "colourTertiary": Blockly.Colours.textField | ||
| 128 | }); | ||
| 129 | } | ||
| 130 | }; | ||
| 131 | |||
| 132 | Blockly.Blocks['math_angle'] = { | ||
| 133 | /** | ||
| 134 | * Block for angle picker. | ||
| 135 | * @this Blockly.Block | ||
| 136 | */ | ||
| 137 | init: function() { | ||
| 138 | this.jsonInit({ | ||
| 139 | "message0": "%1", | ||
| 140 | "args0": [ | ||
| 141 | { | ||
| 142 | "type": "field_angle", | ||
| 143 | "name": "NUM", | ||
| 144 | "value": 90 | ||
| 145 | } | ||
| 146 | ], | ||
| 147 | "output": "Number", | ||
| 148 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 149 | "colour": Blockly.Colours.textField, | ||
| 150 | "colourSecondary": Blockly.Colours.textField, | ||
| 151 | "colourTertiary": Blockly.Colours.textField | ||
| 152 | }); | ||
| 153 | } | ||
| 154 | }; |
blocks_common/matrix.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2012 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Matrix blocks for Blockly. | ||
| 23 | * @author khanning@gmail.com (Kreg Hanning) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.matrix'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.Colours'); | ||
| 32 | |||
| 33 | goog.require('Blockly.constants'); | ||
| 34 | |||
| 35 | Blockly.Blocks['matrix'] = { | ||
| 36 | /** | ||
| 37 | * Block for matrix value. | ||
| 38 | * @this Blockly.Block | ||
| 39 | */ | ||
| 40 | init: function() { | ||
| 41 | this.jsonInit({ | ||
| 42 | "message0": "%1", | ||
| 43 | "args0": [ | ||
| 44 | { | ||
| 45 | "type": "field_matrix", | ||
| 46 | "name": "MATRIX", | ||
| 47 | "width": 5, | ||
| 48 | "height": 5 | ||
| 49 | } | ||
| 50 | ], | ||
| 51 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 52 | "output": "Number", | ||
| 53 | "extensions": ["colours_pen"] | ||
| 54 | }); | ||
| 55 | } | ||
| 56 | }; |
blocks_common/note.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2012 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Note block. | ||
| 23 | * @author ericr@media.mit.edu (Eric Rosenbaum) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.note'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.Colours'); | ||
| 32 | |||
| 33 | goog.require('Blockly.constants'); | ||
| 34 | |||
| 35 | Blockly.Blocks['note'] = { | ||
| 36 | /** | ||
| 37 | * Block for musical note value. | ||
| 38 | * @this Blockly.Block | ||
| 39 | */ | ||
| 40 | init: function() { | ||
| 41 | this.jsonInit({ | ||
| 42 | "message0": "%1", | ||
| 43 | "args0": [ | ||
| 44 | { | ||
| 45 | "type": "field_note", | ||
| 46 | "name": "NOTE", | ||
| 47 | "value": 60 | ||
| 48 | } | ||
| 49 | ], | ||
| 50 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 51 | "output": "Number", | ||
| 52 | "colour": Blockly.Colours.textField, | ||
| 53 | "colourSecondary": Blockly.Colours.textField, | ||
| 54 | "colourTertiary": Blockly.Colours.textField | ||
| 55 | }); | ||
| 56 | } | ||
| 57 | }; |
blocks_common/text.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2012 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Text blocks for Blockly. | ||
| 23 | * @author fraser@google.com (Neil Fraser) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.texts'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.Colours'); | ||
| 32 | |||
| 33 | goog.require('Blockly.constants'); | ||
| 34 | |||
| 35 | Blockly.Blocks['text'] = { | ||
| 36 | /** | ||
| 37 | * Block for text value. | ||
| 38 | * @this Blockly.Block | ||
| 39 | */ | ||
| 40 | init: function() { | ||
| 41 | this.jsonInit({ | ||
| 42 | "message0": "%1", | ||
| 43 | "args0": [ | ||
| 44 | { | ||
| 45 | "type": "field_input", | ||
| 46 | "name": "TEXT" | ||
| 47 | } | ||
| 48 | ], | ||
| 49 | "output": "String", | ||
| 50 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 51 | "colour": Blockly.Colours.textField, | ||
| 52 | "colourSecondary": Blockly.Colours.textField, | ||
| 53 | "colourTertiary": Blockly.Colours.textField | ||
| 54 | }); | ||
| 55 | } | ||
| 56 | }; |
blocks_compressed_vertical.js.config
0 → 100644
| 1 | --compilation_level SIMPLE build\\gen_blocks.js blocks_vertical\\control.js blocks_vertical\\data.js blocks_vertical\\default_toolbox.js blocks_vertical\\device.js blocks_vertical\\event.js blocks_vertical\\extensions.js blocks_vertical\\looks.js blocks_vertical\\motion.js blocks_vertical\\operators.js blocks_vertical\\procedures.js blocks_vertical\\sensing.js blocks_vertical\\sound.js blocks_vertical\\stdint.js blocks_vertical\\vertical_extensions.js core\\colours.js core\\constants.js | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
blocks_horizontal/control.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Control blocks for Scratch (Horizontal) | ||
| 23 | * @author ascii@media.mit.edu <Andrew Sliwinski> | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.control'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.Colours'); | ||
| 32 | |||
| 33 | Blockly.Blocks['control_repeat'] = { | ||
| 34 | /** | ||
| 35 | * Block for repeat n times (external number). | ||
| 36 | * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9 | ||
| 37 | * @this Blockly.Block | ||
| 38 | */ | ||
| 39 | init: function() { | ||
| 40 | this.jsonInit({ | ||
| 41 | "id": "control_repeat", | ||
| 42 | "message0": "%1 %2 %3", | ||
| 43 | "args0": [ | ||
| 44 | { | ||
| 45 | "type": "input_statement", | ||
| 46 | "name": "SUBSTACK" | ||
| 47 | }, | ||
| 48 | { | ||
| 49 | "type": "field_image", | ||
| 50 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_repeat.svg", | ||
| 51 | "width": 40, | ||
| 52 | "height": 40, | ||
| 53 | "alt": "*", | ||
| 54 | "flip_rtl": true | ||
| 55 | }, | ||
| 56 | { | ||
| 57 | "type": "input_value", | ||
| 58 | "name": "TIMES", | ||
| 59 | "check": "Number" | ||
| 60 | } | ||
| 61 | ], | ||
| 62 | "inputsInline": true, | ||
| 63 | "previousStatement": null, | ||
| 64 | "nextStatement": null, | ||
| 65 | "category": Blockly.Categories.control, | ||
| 66 | "colour": Blockly.Colours.control.primary, | ||
| 67 | "colourSecondary": Blockly.Colours.control.secondary, | ||
| 68 | "colourTertiary": Blockly.Colours.control.tertiary | ||
| 69 | }); | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | |||
| 73 | Blockly.Blocks['control_forever'] = { | ||
| 74 | /** | ||
| 75 | * Block for repeat n times (external number). | ||
| 76 | * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#5eke39 | ||
| 77 | * @this Blockly.Block | ||
| 78 | */ | ||
| 79 | init: function() { | ||
| 80 | this.jsonInit({ | ||
| 81 | "id": "control_forever", | ||
| 82 | "message0": "%1 %2", | ||
| 83 | "args0": [ | ||
| 84 | { | ||
| 85 | "type": "input_statement", | ||
| 86 | "name": "SUBSTACK" | ||
| 87 | }, | ||
| 88 | { | ||
| 89 | "type": "field_image", | ||
| 90 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_forever.svg", | ||
| 91 | "width": 40, | ||
| 92 | "height": 40, | ||
| 93 | "alt": "*", | ||
| 94 | "flip_rtl": true | ||
| 95 | } | ||
| 96 | ], | ||
| 97 | "inputsInline": true, | ||
| 98 | "previousStatement": null, | ||
| 99 | "category": Blockly.Categories.control, | ||
| 100 | "colour": Blockly.Colours.control.primary, | ||
| 101 | "colourSecondary": Blockly.Colours.control.secondary, | ||
| 102 | "colourTertiary": Blockly.Colours.control.tertiary | ||
| 103 | }); | ||
| 104 | } | ||
| 105 | }; | ||
| 106 | |||
| 107 | Blockly.Blocks['control_repeat'] = { | ||
| 108 | /** | ||
| 109 | * Block for repeat n times (external number). | ||
| 110 | * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9 | ||
| 111 | * @this Blockly.Block | ||
| 112 | */ | ||
| 113 | init: function() { | ||
| 114 | this.jsonInit({ | ||
| 115 | "id": "control_repeat", | ||
| 116 | "message0": "%1 %2 %3", | ||
| 117 | "args0": [ | ||
| 118 | { | ||
| 119 | "type": "input_statement", | ||
| 120 | "name": "SUBSTACK" | ||
| 121 | }, | ||
| 122 | { | ||
| 123 | "type": "field_image", | ||
| 124 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_repeat.svg", | ||
| 125 | "width": 40, | ||
| 126 | "height": 40, | ||
| 127 | "alt": "*", | ||
| 128 | "flip_rtl": true | ||
| 129 | }, | ||
| 130 | { | ||
| 131 | "type": "input_value", | ||
| 132 | "name": "TIMES", | ||
| 133 | "check": "Number" | ||
| 134 | } | ||
| 135 | ], | ||
| 136 | "inputsInline": true, | ||
| 137 | "previousStatement": null, | ||
| 138 | "nextStatement": null, | ||
| 139 | "category": Blockly.Categories.control, | ||
| 140 | "colour": Blockly.Colours.control.primary, | ||
| 141 | "colourSecondary": Blockly.Colours.control.secondary, | ||
| 142 | "colourTertiary": Blockly.Colours.control.tertiary | ||
| 143 | }); | ||
| 144 | } | ||
| 145 | }; | ||
| 146 | |||
| 147 | Blockly.Blocks['control_stop'] = { | ||
| 148 | /** | ||
| 149 | * Block for stop all scripts. | ||
| 150 | * @this Blockly.Block | ||
| 151 | */ | ||
| 152 | init: function() { | ||
| 153 | this.jsonInit({ | ||
| 154 | "id": "control_stop", | ||
| 155 | "message0": "%1", | ||
| 156 | "args0": [ | ||
| 157 | { | ||
| 158 | "type": "field_image", | ||
| 159 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_stop.svg", | ||
| 160 | "width": 40, | ||
| 161 | "height": 40, | ||
| 162 | "alt": "Stop" | ||
| 163 | } | ||
| 164 | ], | ||
| 165 | "inputsInline": true, | ||
| 166 | "previousStatement": null, | ||
| 167 | "category": Blockly.Categories.control, | ||
| 168 | "colour": Blockly.Colours.control.primary, | ||
| 169 | "colourSecondary": Blockly.Colours.control.secondary, | ||
| 170 | "colourTertiary": Blockly.Colours.control.tertiary | ||
| 171 | }); | ||
| 172 | } | ||
| 173 | }; | ||
| 174 | |||
| 175 | Blockly.Blocks['control_wait'] = { | ||
| 176 | /** | ||
| 177 | * Block to wait (pause) stack. | ||
| 178 | * @this Blockly.Block | ||
| 179 | */ | ||
| 180 | init: function() { | ||
| 181 | this.jsonInit({ | ||
| 182 | "id": "control_wait", | ||
| 183 | "message0": "%1 %2", | ||
| 184 | "args0": [ | ||
| 185 | { | ||
| 186 | "type": "field_image", | ||
| 187 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_wait.svg", | ||
| 188 | "width": 40, | ||
| 189 | "height": 40, | ||
| 190 | "alt": "Wait" | ||
| 191 | }, | ||
| 192 | { | ||
| 193 | "type": "input_value", | ||
| 194 | "name": "DURATION", | ||
| 195 | "check": "Number" | ||
| 196 | } | ||
| 197 | ], | ||
| 198 | "inputsInline": true, | ||
| 199 | "previousStatement": null, | ||
| 200 | "nextStatement": null, | ||
| 201 | "category": Blockly.Categories.control, | ||
| 202 | "colour": Blockly.Colours.control.primary, | ||
| 203 | "colourSecondary": Blockly.Colours.control.secondary, | ||
| 204 | "colourTertiary": Blockly.Colours.control.tertiary | ||
| 205 | }); | ||
| 206 | } | ||
| 207 | }; |
blocks_horizontal/default_toolbox.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Blocks.defaultToolbox'); | ||
| 24 | |||
| 25 | goog.require('Blockly.Blocks'); | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @fileoverview Provide a default toolbox XML. | ||
| 29 | */ | ||
| 30 | |||
| 31 | Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: none">' + | ||
| 32 | '<category name="Events">' + | ||
| 33 | '<block type="event_whenflagclicked"></block>' + | ||
| 34 | '<block type="event_whenbroadcastreceived">' + | ||
| 35 | '<value name="CHOICE">' + | ||
| 36 | '<shadow type="dropdown_whenbroadcast">' + | ||
| 37 | '<field name="CHOICE">blue</field>' + | ||
| 38 | '</shadow>' + | ||
| 39 | '</value>' + | ||
| 40 | '</block>' + | ||
| 41 | '<block type="event_broadcast">' + | ||
| 42 | '<value name="CHOICE">' + | ||
| 43 | '<shadow type="dropdown_broadcast">' + | ||
| 44 | '<field name="CHOICE">blue</field>' + | ||
| 45 | '</shadow>' + | ||
| 46 | '</value>' + | ||
| 47 | '</block>' + | ||
| 48 | '</category>' + | ||
| 49 | '<category name="Control">' + | ||
| 50 | '<block type="control_forever"></block>' + | ||
| 51 | '<block type="control_repeat">' + | ||
| 52 | '<value name="TIMES">' + | ||
| 53 | '<shadow type="math_whole_number">' + | ||
| 54 | '<field name="NUM">4</field>' + | ||
| 55 | '</shadow>' + | ||
| 56 | '</value>' + | ||
| 57 | '</block>' + | ||
| 58 | '<block type="control_stop"></block>' + | ||
| 59 | '<block type="control_wait">' + | ||
| 60 | '<value name="DURATION">' + | ||
| 61 | '<shadow type="math_positive_number">' + | ||
| 62 | '<field name="NUM">1</field>' + | ||
| 63 | '</shadow>' + | ||
| 64 | '</value>' + | ||
| 65 | '</block>' + | ||
| 66 | '</category>' + | ||
| 67 | '<category name="Wedo">' + | ||
| 68 | '<block type="wedo_setcolor">' + | ||
| 69 | '<value name="CHOICE">' + | ||
| 70 | '<shadow type="dropdown_wedo_setcolor">' + | ||
| 71 | '<field name="CHOICE">mystery</field>' + | ||
| 72 | '</shadow>' + | ||
| 73 | '</value>' + | ||
| 74 | '</block>' + | ||
| 75 | '<block type="wedo_motorclockwise">' + | ||
| 76 | '<value name="DURATION">' + | ||
| 77 | '<shadow type="math_positive_number">' + | ||
| 78 | '<field name="NUM">1</field>' + | ||
| 79 | '</shadow>' + | ||
| 80 | '</value>' + | ||
| 81 | '</block>' + | ||
| 82 | '<block type="wedo_motorcounterclockwise">' + | ||
| 83 | '<value name="DURATION">' + | ||
| 84 | '<shadow type="math_positive_number">' + | ||
| 85 | '<field name="NUM">1</field>' + | ||
| 86 | '</shadow>' + | ||
| 87 | '</value>' + | ||
| 88 | '</block>' + | ||
| 89 | '<block type="wedo_motorspeed">' + | ||
| 90 | '<value name="CHOICE">' + | ||
| 91 | '<shadow type="dropdown_wedo_motorspeed">' + | ||
| 92 | '<field name="CHOICE">fast</field>' + | ||
| 93 | '</shadow>' + | ||
| 94 | '</value>' + | ||
| 95 | '</block>' + | ||
| 96 | '<block type="wedo_whentilt">' + | ||
| 97 | '<value name="CHOICE">' + | ||
| 98 | '<shadow type="dropdown_wedo_whentilt">' + | ||
| 99 | '<field name="CHOICE">forward</field>' + | ||
| 100 | '</shadow>' + | ||
| 101 | '</value>' + | ||
| 102 | '</block>' + | ||
| 103 | '<block type="wedo_whendistanceclose"></block>' + | ||
| 104 | '</category>' + | ||
| 105 | '</xml>'; | ||
| 106 | |||
| 107 | Blockly.Blocks.defaultToolboxSimple = '<xml id="toolbox-simple" style="display: none">' + | ||
| 108 | '<block type="event_whenflagclicked"></block>' + | ||
| 109 | '<block type="event_whenbroadcastreceived">' + | ||
| 110 | '<value name="CHOICE">' + | ||
| 111 | '<shadow type="dropdown_whenbroadcast">' + | ||
| 112 | '<field name="CHOICE">blue</field>' + | ||
| 113 | '</shadow>' + | ||
| 114 | '</value>' + | ||
| 115 | '</block>' + | ||
| 116 | '<block type="event_broadcast">' + | ||
| 117 | '<value name="CHOICE">' + | ||
| 118 | '<shadow type="dropdown_broadcast">' + | ||
| 119 | '<field name="CHOICE">blue</field>' + | ||
| 120 | '</shadow>' + | ||
| 121 | '</value>' + | ||
| 122 | '</block>' + | ||
| 123 | '<block type="control_forever"></block>' + | ||
| 124 | '<block type="control_repeat">' + | ||
| 125 | '<value name="TIMES">' + | ||
| 126 | '<shadow type="math_whole_number">' + | ||
| 127 | '<field name="NUM">4</field>' + | ||
| 128 | '</shadow>' + | ||
| 129 | '</value>' + | ||
| 130 | '</block>' + | ||
| 131 | '<block type="control_stop"></block>' + | ||
| 132 | '<block type="control_wait">' + | ||
| 133 | '<value name="DURATION">' + | ||
| 134 | '<shadow type="math_positive_number">' + | ||
| 135 | '<field name="NUM">1</field>' + | ||
| 136 | '</shadow>' + | ||
| 137 | '</value>' + | ||
| 138 | '</block>' + | ||
| 139 | '</xml>'; |
blocks_horizontal/event.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Control blocks for Scratch (Horizontal) | ||
| 23 | * @author ascii@media.mit.edu <Andrew Sliwinski> | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Blocks.event'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Blocks'); | ||
| 30 | |||
| 31 | goog.require('Blockly.Colours'); | ||
| 32 | |||
| 33 | Blockly.Blocks['event_whenflagclicked'] = { | ||
| 34 | /** | ||
| 35 | * Block for when flag clicked. | ||
| 36 | * @this Blockly.Block | ||
| 37 | */ | ||
| 38 | init: function() { | ||
| 39 | this.jsonInit({ | ||
| 40 | "id": "event_whenflagclicked", | ||
| 41 | "message0": "%1", | ||
| 42 | "args0": [ | ||
| 43 | { | ||
| 44 | "type": "field_image", | ||
| 45 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_whenflagclicked.svg", | ||
| 46 | "width": 40, | ||
| 47 | "height": 40, | ||
| 48 | "alt": "When green flag clicked", | ||
| 49 | "flip_rtl": true | ||
| 50 | } | ||
| 51 | ], | ||
| 52 | "inputsInline": true, | ||
| 53 | "nextStatement": null, | ||
| 54 | "category": Blockly.Categories.event, | ||
| 55 | "colour": Blockly.Colours.event.primary, | ||
| 56 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 57 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 58 | }); | ||
| 59 | } | ||
| 60 | }; | ||
| 61 | |||
| 62 | Blockly.Blocks['dropdown_whenbroadcast'] = { | ||
| 63 | /** | ||
| 64 | * Block for when broadcast dropdown (used for shadow). | ||
| 65 | * @this Blockly.Block | ||
| 66 | */ | ||
| 67 | init: function() { | ||
| 68 | this.appendDummyInput() | ||
| 69 | .appendField(new Blockly.FieldIconMenu( | ||
| 70 | [ | ||
| 71 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_blue.svg', | ||
| 72 | value: 'blue', width: 48, height: 48, alt: 'Blue'}, | ||
| 73 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_green.svg', | ||
| 74 | value: 'green', width: 48, height: 48, alt: 'Green'}, | ||
| 75 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_coral.svg', | ||
| 76 | value: 'coral', width: 48, height: 48, alt: 'Coral'}, | ||
| 77 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_magenta.svg', | ||
| 78 | value: 'magenta', width: 48, height: 48, alt: 'Magenta'}, | ||
| 79 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_orange.svg', | ||
| 80 | value: 'orange', width: 48, height: 48, alt: 'Orange'}, | ||
| 81 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_purple.svg', | ||
| 82 | value: 'purple', width: 48, height: 48, alt: 'Purple'} | ||
| 83 | ]), 'CHOICE'); | ||
| 84 | this.setOutput(true); | ||
| 85 | this.setColour(Blockly.Colours.event.primary, | ||
| 86 | Blockly.Colours.event.secondary, | ||
| 87 | Blockly.Colours.event.tertiary | ||
| 88 | ); | ||
| 89 | } | ||
| 90 | }; | ||
| 91 | |||
| 92 | Blockly.Blocks['event_whenbroadcastreceived'] = { | ||
| 93 | /** | ||
| 94 | * Block for when broadcast received. | ||
| 95 | * @this Blockly.Block | ||
| 96 | */ | ||
| 97 | init: function() { | ||
| 98 | this.jsonInit({ | ||
| 99 | "id": "event_whenbroadcastreceived", | ||
| 100 | "message0": "%1 %2", | ||
| 101 | "args0": [ | ||
| 102 | { | ||
| 103 | "type": "field_image", | ||
| 104 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_when-broadcast-received_blue.svg", | ||
| 105 | "width": 40, | ||
| 106 | "height": 40, | ||
| 107 | "alt": "Broadcast received" | ||
| 108 | }, | ||
| 109 | { | ||
| 110 | "type": "input_value", | ||
| 111 | "name": "CHOICE" | ||
| 112 | } | ||
| 113 | ], | ||
| 114 | "inputsInline": true, | ||
| 115 | "nextStatement": null, | ||
| 116 | "category": Blockly.Categories.event, | ||
| 117 | "colour": Blockly.Colours.event.primary, | ||
| 118 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 119 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 120 | }); | ||
| 121 | } | ||
| 122 | }; | ||
| 123 | |||
| 124 | Blockly.Blocks['dropdown_broadcast'] = { | ||
| 125 | /** | ||
| 126 | * Block for broadcast dropdown (used for shadow). | ||
| 127 | * @this Blockly.Block | ||
| 128 | */ | ||
| 129 | init: function() { | ||
| 130 | this.appendDummyInput() | ||
| 131 | .appendField(new Blockly.FieldIconMenu( | ||
| 132 | [ | ||
| 133 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_blue.svg', | ||
| 134 | value: 'blue', width: 48, height: 48, alt: 'Blue'}, | ||
| 135 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_green.svg', | ||
| 136 | value: 'green', width: 48, height: 48, alt: 'Green'}, | ||
| 137 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_coral.svg', | ||
| 138 | value: 'coral', width: 48, height: 48, alt: 'Coral'}, | ||
| 139 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_magenta.svg', | ||
| 140 | value: 'magenta', width: 48, height: 48, alt: 'Magenta'}, | ||
| 141 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_orange.svg', | ||
| 142 | value: 'orange', width: 48, height: 48, alt: 'Orange'}, | ||
| 143 | {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_purple.svg', | ||
| 144 | value: 'purple', width: 48, height: 48, alt: 'Purple'} | ||
| 145 | ]), 'CHOICE'); | ||
| 146 | this.setOutput(true); | ||
| 147 | this.setColour(Blockly.Colours.event.primary, | ||
| 148 | Blockly.Colours.event.secondary, | ||
| 149 | Blockly.Colours.event.tertiary | ||
| 150 | ); | ||
| 151 | } | ||
| 152 | }; | ||
| 153 | |||
| 154 | Blockly.Blocks['event_broadcast'] = { | ||
| 155 | /** | ||
| 156 | * Block to send a broadcast. | ||
| 157 | * @this Blockly.Block | ||
| 158 | */ | ||
| 159 | init: function() { | ||
| 160 | this.jsonInit({ | ||
| 161 | "id": "event_broadcast", | ||
| 162 | "message0": "%1 %2", | ||
| 163 | "args0": [ | ||
| 164 | { | ||
| 165 | "type": "field_image", | ||
| 166 | "src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_broadcast_blue.svg", | ||
| 167 | "width": 40, | ||
| 168 | "height": 40, | ||
| 169 | "alt": "Broadcast" | ||
| 170 | }, | ||
| 171 | { | ||
| 172 | "type": "input_value", | ||
| 173 | "name": "CHOICE" | ||
| 174 | } | ||
| 175 | ], | ||
| 176 | "inputsInline": true, | ||
| 177 | "previousStatement": null, | ||
| 178 | "nextStatement": null, | ||
| 179 | "category": Blockly.Categories.event, | ||
| 180 | "colour": Blockly.Colours.event.primary, | ||
| 181 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 182 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 183 | }); | ||
| 184 | } | ||
| 185 | }; |
blocks_horizontal/wedo.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/control.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/data.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/default_toolbox.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/device.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2020 openblock.cc. | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Blocks.device'); | ||
| 24 | |||
| 25 | goog.require('Blockly.Blocks'); | ||
| 26 | goog.require('Blockly.Colours'); | ||
| 27 | |||
| 28 | |||
| 29 | Blockly.Blocks['event_whenarduinobegin'] = { | ||
| 30 | /** | ||
| 31 | * Block for when arduino begin. | ||
| 32 | * @this Blockly.Block | ||
| 33 | */ | ||
| 34 | init: function() { | ||
| 35 | this.jsonInit({ | ||
| 36 | "id": "event_whenarduinobegin", | ||
| 37 | "message0": Blockly.Msg.EVENT_WHENARDUINOBEGIN, | ||
| 38 | "nextStatement": null, | ||
| 39 | "category": Blockly.Categories.event, | ||
| 40 | "colour": Blockly.Colours.event.primary, | ||
| 41 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 42 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 43 | }); | ||
| 44 | } | ||
| 45 | }; | ||
| 46 | |||
| 47 | Blockly.Blocks['event_whenmicropythonbegin'] = { | ||
| 48 | /** | ||
| 49 | * Block for when arduino begin. | ||
| 50 | * @this Blockly.Block | ||
| 51 | */ | ||
| 52 | init: function() { | ||
| 53 | this.jsonInit({ | ||
| 54 | "id": "event_whenmicropythonbegin", | ||
| 55 | "message0": Blockly.Msg.EVENT_WHENMICROPYTHONBEGIN, | ||
| 56 | "nextStatement": null, | ||
| 57 | "category": Blockly.Categories.event, | ||
| 58 | "colour": Blockly.Colours.event.primary, | ||
| 59 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 60 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 61 | }); | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | |||
| 65 | Blockly.Blocks['event_whenmicrobitbegin'] = { | ||
| 66 | /** | ||
| 67 | * Block for when microbit begin. | ||
| 68 | * @this Blockly.Block | ||
| 69 | */ | ||
| 70 | init: function() { | ||
| 71 | this.jsonInit({ | ||
| 72 | "id": "event_whenmicrobitbegin", | ||
| 73 | "message0": Blockly.Msg.EVENT_WHENMICROBITBEGIN, | ||
| 74 | "nextStatement": null, | ||
| 75 | "category": Blockly.Categories.event, | ||
| 76 | "colour": Blockly.Colours.event.primary, | ||
| 77 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 78 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 79 | }); | ||
| 80 | } | ||
| 81 | }; | ||
| 82 | |||
| 83 | Blockly.Blocks['event_whenmicrobitbuttonpressed'] = { | ||
| 84 | /** | ||
| 85 | * Block for when microbit button pressed. | ||
| 86 | * @this Blockly.Block | ||
| 87 | */ | ||
| 88 | init: function() { | ||
| 89 | this.jsonInit({ | ||
| 90 | "id": "event_whenmicrobitbuttonpressed", | ||
| 91 | "message0": Blockly.Msg.EVENT_WHENMICROBITBUTTONPRESSED, | ||
| 92 | "args0": [ | ||
| 93 | { | ||
| 94 | "type": "field_dropdown", | ||
| 95 | "name": "KEY_OPTION", | ||
| 96 | "options": [ | ||
| 97 | ['A', 'a'], | ||
| 98 | ['B', 'b'], | ||
| 99 | ['A+B', 'ab'] | ||
| 100 | ] | ||
| 101 | } | ||
| 102 | ], | ||
| 103 | "nextStatement": null, | ||
| 104 | "category": Blockly.Categories.event, | ||
| 105 | "colour": Blockly.Colours.event.primary, | ||
| 106 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 107 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 108 | }); | ||
| 109 | } | ||
| 110 | }; | ||
| 111 | |||
| 112 | Blockly.Blocks['event_whenmicrobitpinbeingtouched'] = { | ||
| 113 | /** | ||
| 114 | * Block for when microbit pin was touched. | ||
| 115 | * @this Blockly.Block | ||
| 116 | */ | ||
| 117 | init: function() { | ||
| 118 | this.jsonInit({ | ||
| 119 | "id": "event_whenmicrobitpinbeingtouched", | ||
| 120 | "message0": Blockly.Msg.EVENT_WHENMICROBITPINBEINGTOUCHED, | ||
| 121 | "args0": [ | ||
| 122 | { | ||
| 123 | "type": "field_dropdown", | ||
| 124 | "name": "PIN_OPTION", | ||
| 125 | "options": [ | ||
| 126 | ['0', '0'], | ||
| 127 | ['1', '1'], | ||
| 128 | ['2', '2'] | ||
| 129 | ] | ||
| 130 | } | ||
| 131 | ], | ||
| 132 | "nextStatement": null, | ||
| 133 | "category": Blockly.Categories.event, | ||
| 134 | "colour": Blockly.Colours.event.primary, | ||
| 135 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 136 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 137 | }); | ||
| 138 | } | ||
| 139 | }; | ||
| 140 | |||
| 141 | Blockly.Blocks['event_whenmicrobitgesture'] = { | ||
| 142 | /** | ||
| 143 | * Block for when microbit gesture is XXX. | ||
| 144 | * @this Blockly.Block | ||
| 145 | */ | ||
| 146 | init: function() { | ||
| 147 | this.jsonInit({ | ||
| 148 | "id": "event_whenmicrobitgesture", | ||
| 149 | "message0": Blockly.Msg.EVENT_WHENMICROBITGESTURE, | ||
| 150 | "args0": [ | ||
| 151 | { | ||
| 152 | "type": "field_dropdown", | ||
| 153 | "name": "GESTURE_OPTION", | ||
| 154 | "options": [ | ||
| 155 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_SHAKEN, 'shake'], | ||
| 156 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_TILTEDUPWARD, 'up'], | ||
| 157 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_TILTEDDOWNWARD, 'down'], | ||
| 158 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_TILTEDDLEFTWARD, 'left'], | ||
| 159 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_TILTEDDRIGHTWARD, 'right'], | ||
| 160 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_FACEUP, 'face up'], | ||
| 161 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_FACEDOWN, 'face down'], | ||
| 162 | [Blockly.Msg.EVENT_WHENMICROBITGESTURE_FREEFALL, 'freefall'], | ||
| 163 | ['3g', '3g'], | ||
| 164 | ['6g', '6g'], | ||
| 165 | ['8g', '8g'] | ||
| 166 | ] | ||
| 167 | } | ||
| 168 | ], | ||
| 169 | "nextStatement": null, | ||
| 170 | "category": Blockly.Categories.event, | ||
| 171 | "colour": Blockly.Colours.event.primary, | ||
| 172 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 173 | "colourTertiary": Blockly.Colours.event.tertiary | ||
| 174 | }); | ||
| 175 | } | ||
| 176 | }; |
blocks_vertical/event.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Blocks.event'); | ||
| 24 | |||
| 25 | goog.require('Blockly.Blocks'); | ||
| 26 | goog.require('Blockly.Colours'); | ||
| 27 | goog.require('Blockly.constants'); | ||
| 28 | goog.require('Blockly.ScratchBlocks.VerticalExtensions'); | ||
| 29 | |||
| 30 | Blockly.Blocks['event_whentouchingobject'] = { | ||
| 31 | /** | ||
| 32 | * Block for when a sprite is touching an object. | ||
| 33 | * @this Blockly.Block | ||
| 34 | */ | ||
| 35 | init: function() { | ||
| 36 | this.jsonInit({ | ||
| 37 | "message0": Blockly.Msg.EVENT_WHENTOUCHINGOBJECT, | ||
| 38 | "args0": [ | ||
| 39 | { | ||
| 40 | "type": "input_value", | ||
| 41 | "name": "TOUCHINGOBJECTMENU" | ||
| 42 | } | ||
| 43 | ], | ||
| 44 | "category": Blockly.Categories.event, | ||
| 45 | "extensions": ["colours_event", "shape_hat"] | ||
| 46 | }); | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | |||
| 50 | Blockly.Blocks['event_touchingobjectmenu'] = { | ||
| 51 | /** | ||
| 52 | * "Touching [Object]" Block Menu. | ||
| 53 | * @this Blockly.Block | ||
| 54 | */ | ||
| 55 | init: function() { | ||
| 56 | this.jsonInit({ | ||
| 57 | "message0": "%1", | ||
| 58 | "args0": [ | ||
| 59 | { | ||
| 60 | "type": "field_dropdown", | ||
| 61 | "name": "TOUCHINGOBJECTMENU", | ||
| 62 | "options": [ | ||
| 63 | [Blockly.Msg.SENSING_TOUCHINGOBJECT_POINTER, '_mouse_'], | ||
| 64 | [Blockly.Msg.SENSING_TOUCHINGOBJECT_EDGE, '_edge_'] | ||
| 65 | ] | ||
| 66 | } | ||
| 67 | ], | ||
| 68 | "extensions": ["colours_event", "output_string"] | ||
| 69 | }); | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | |||
| 73 | Blockly.Blocks['event_whenflagclicked'] = { | ||
| 74 | /** | ||
| 75 | * Block for when flag clicked. | ||
| 76 | * @this Blockly.Block | ||
| 77 | */ | ||
| 78 | init: function() { | ||
| 79 | this.jsonInit({ | ||
| 80 | "id": "event_whenflagclicked", | ||
| 81 | "message0": Blockly.Msg.EVENT_WHENFLAGCLICKED, | ||
| 82 | "args0": [ | ||
| 83 | { | ||
| 84 | "type": "field_image", | ||
| 85 | "src": Blockly.mainWorkspace.options.pathToMedia + "green-flag.svg", | ||
| 86 | "width": 24, | ||
| 87 | "height": 24, | ||
| 88 | "alt": "flag" | ||
| 89 | } | ||
| 90 | ], | ||
| 91 | "category": Blockly.Categories.event, | ||
| 92 | "extensions": ["colours_event", "shape_hat"] | ||
| 93 | }); | ||
| 94 | } | ||
| 95 | }; | ||
| 96 | |||
| 97 | Blockly.Blocks['event_whenthisspriteclicked'] = { | ||
| 98 | /** | ||
| 99 | * Block for when this sprite clicked. | ||
| 100 | * @this Blockly.Block | ||
| 101 | */ | ||
| 102 | init: function() { | ||
| 103 | this.jsonInit({ | ||
| 104 | "message0": Blockly.Msg.EVENT_WHENTHISSPRITECLICKED, | ||
| 105 | "category": Blockly.Categories.event, | ||
| 106 | "extensions": ["colours_event", "shape_hat"] | ||
| 107 | }); | ||
| 108 | } | ||
| 109 | |||
| 110 | }; | ||
| 111 | |||
| 112 | Blockly.Blocks['event_whenstageclicked'] = { | ||
| 113 | /** | ||
| 114 | * Block for when the stage is clicked. | ||
| 115 | * @this Blockly.Block | ||
| 116 | */ | ||
| 117 | init: function() { | ||
| 118 | this.jsonInit({ | ||
| 119 | "message0": Blockly.Msg.EVENT_WHENSTAGECLICKED, | ||
| 120 | "category": Blockly.Categories.event, | ||
| 121 | "extensions": ["colours_event", "shape_hat"] | ||
| 122 | }); | ||
| 123 | } | ||
| 124 | }; | ||
| 125 | |||
| 126 | Blockly.Blocks['event_whenbroadcastreceived'] = { | ||
| 127 | /** | ||
| 128 | * Block for when broadcast received. | ||
| 129 | * @this Blockly.Block | ||
| 130 | */ | ||
| 131 | init: function() { | ||
| 132 | this.jsonInit({ | ||
| 133 | "id": "event_whenbroadcastreceived", | ||
| 134 | "message0": Blockly.Msg.EVENT_WHENBROADCASTRECEIVED, | ||
| 135 | "args0": [ | ||
| 136 | { | ||
| 137 | "type": "field_variable", | ||
| 138 | "name": "BROADCAST_OPTION", | ||
| 139 | "variableTypes": [Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE], | ||
| 140 | "variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME | ||
| 141 | } | ||
| 142 | ], | ||
| 143 | "category": Blockly.Categories.event, | ||
| 144 | "extensions": ["colours_event", "shape_hat"] | ||
| 145 | }); | ||
| 146 | } | ||
| 147 | }; | ||
| 148 | |||
| 149 | Blockly.Blocks['event_whenbackdropswitchesto'] = { | ||
| 150 | /** | ||
| 151 | * Block for when the current backdrop switched to a selected backdrop. | ||
| 152 | * @this Blockly.Block | ||
| 153 | */ | ||
| 154 | init: function() { | ||
| 155 | this.jsonInit({ | ||
| 156 | "message0": Blockly.Msg.EVENT_WHENBACKDROPSWITCHESTO, | ||
| 157 | "args0": [ | ||
| 158 | { | ||
| 159 | "type": "field_dropdown", | ||
| 160 | "name": "BACKDROP", | ||
| 161 | "options": [ | ||
| 162 | ['backdrop1', 'BACKDROP1'] | ||
| 163 | ] | ||
| 164 | } | ||
| 165 | ], | ||
| 166 | "category": Blockly.Categories.event, | ||
| 167 | "extensions": ["colours_event", "shape_hat"] | ||
| 168 | }); | ||
| 169 | } | ||
| 170 | }; | ||
| 171 | |||
| 172 | Blockly.Blocks['event_whengreaterthan'] = { | ||
| 173 | /** | ||
| 174 | * Block for when loudness/timer/video motion is greater than the value. | ||
| 175 | * @this Blockly.Block | ||
| 176 | */ | ||
| 177 | init: function() { | ||
| 178 | this.jsonInit({ | ||
| 179 | "message0": Blockly.Msg.EVENT_WHENGREATERTHAN, | ||
| 180 | "args0": [ | ||
| 181 | { | ||
| 182 | "type": "field_dropdown", | ||
| 183 | "name": "WHENGREATERTHANMENU", | ||
| 184 | "options": [ | ||
| 185 | [Blockly.Msg.EVENT_WHENGREATERTHAN_LOUDNESS, 'LOUDNESS'], | ||
| 186 | [Blockly.Msg.EVENT_WHENGREATERTHAN_TIMER, 'TIMER'] | ||
| 187 | ] | ||
| 188 | }, | ||
| 189 | { | ||
| 190 | "type": "input_value", | ||
| 191 | "name": "VALUE" | ||
| 192 | } | ||
| 193 | ], | ||
| 194 | "category": Blockly.Categories.event, | ||
| 195 | "extensions": ["colours_event", "shape_hat"] | ||
| 196 | }); | ||
| 197 | } | ||
| 198 | }; | ||
| 199 | |||
| 200 | Blockly.Blocks['event_broadcast_menu'] = { | ||
| 201 | /** | ||
| 202 | * Broadcast drop-down menu. | ||
| 203 | * @this Blockly.Block | ||
| 204 | */ | ||
| 205 | init: function() { | ||
| 206 | this.jsonInit({ | ||
| 207 | "message0": "%1", | ||
| 208 | "args0": [ | ||
| 209 | { | ||
| 210 | "type": "field_variable", | ||
| 211 | "name": "BROADCAST_OPTION", | ||
| 212 | "variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE], | ||
| 213 | "variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME | ||
| 214 | } | ||
| 215 | ], | ||
| 216 | "colour": Blockly.Colours.event.secondary, | ||
| 217 | "colourSecondary": Blockly.Colours.event.secondary, | ||
| 218 | "colourTertiary": Blockly.Colours.event.tertiary, | ||
| 219 | "extensions": ["output_string"] | ||
| 220 | }); | ||
| 221 | } | ||
| 222 | }; | ||
| 223 | |||
| 224 | Blockly.Blocks['event_broadcast'] = { | ||
| 225 | /** | ||
| 226 | * Block to send a broadcast. | ||
| 227 | * @this Blockly.Block | ||
| 228 | */ | ||
| 229 | init: function() { | ||
| 230 | this.jsonInit({ | ||
| 231 | "id": "event_broadcast", | ||
| 232 | "message0": Blockly.Msg.EVENT_BROADCAST, | ||
| 233 | "args0": [ | ||
| 234 | { | ||
| 235 | "type": "input_value", | ||
| 236 | "name": "BROADCAST_INPUT" | ||
| 237 | } | ||
| 238 | ], | ||
| 239 | "category": Blockly.Categories.event, | ||
| 240 | "extensions": ["colours_event", "shape_statement"] | ||
| 241 | }); | ||
| 242 | } | ||
| 243 | }; | ||
| 244 | |||
| 245 | Blockly.Blocks['event_broadcastandwait'] = { | ||
| 246 | /** | ||
| 247 | * Block to send a broadcast. | ||
| 248 | * @this Blockly.Block | ||
| 249 | */ | ||
| 250 | init: function() { | ||
| 251 | this.jsonInit({ | ||
| 252 | "message0": Blockly.Msg.EVENT_BROADCASTANDWAIT, | ||
| 253 | "args0": [ | ||
| 254 | { | ||
| 255 | "type":"input_value", | ||
| 256 | "name":"BROADCAST_INPUT" | ||
| 257 | } | ||
| 258 | ], | ||
| 259 | "category": Blockly.Categories.event, | ||
| 260 | "extensions": ["colours_event", "shape_statement"] | ||
| 261 | }); | ||
| 262 | } | ||
| 263 | }; | ||
| 264 | |||
| 265 | Blockly.Blocks['event_whenkeypressed'] = { | ||
| 266 | /** | ||
| 267 | * Block to send a broadcast. | ||
| 268 | * @this Blockly.Block | ||
| 269 | */ | ||
| 270 | init: function() { | ||
| 271 | this.jsonInit({ | ||
| 272 | "id": "event_whenkeypressed", | ||
| 273 | "message0": Blockly.Msg.EVENT_WHENKEYPRESSED, | ||
| 274 | "args0": [ | ||
| 275 | { | ||
| 276 | "type": "field_dropdown", | ||
| 277 | "name": "KEY_OPTION", | ||
| 278 | "options": [ | ||
| 279 | [Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'], | ||
| 280 | [Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'], | ||
| 281 | [Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'], | ||
| 282 | [Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'], | ||
| 283 | [Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'], | ||
| 284 | [Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'], | ||
| 285 | ['a', 'a'], | ||
| 286 | ['b', 'b'], | ||
| 287 | ['c', 'c'], | ||
| 288 | ['d', 'd'], | ||
| 289 | ['e', 'e'], | ||
| 290 | ['f', 'f'], | ||
| 291 | ['g', 'g'], | ||
| 292 | ['h', 'h'], | ||
| 293 | ['i', 'i'], | ||
| 294 | ['j', 'j'], | ||
| 295 | ['k', 'k'], | ||
| 296 | ['l', 'l'], | ||
| 297 | ['m', 'm'], | ||
| 298 | ['n', 'n'], | ||
| 299 | ['o', 'o'], | ||
| 300 | ['p', 'p'], | ||
| 301 | ['q', 'q'], | ||
| 302 | ['r', 'r'], | ||
| 303 | ['s', 's'], | ||
| 304 | ['t', 't'], | ||
| 305 | ['u', 'u'], | ||
| 306 | ['v', 'v'], | ||
| 307 | ['w', 'w'], | ||
| 308 | ['x', 'x'], | ||
| 309 | ['y', 'y'], | ||
| 310 | ['z', 'z'], | ||
| 311 | ['0', '0'], | ||
| 312 | ['1', '1'], | ||
| 313 | ['2', '2'], | ||
| 314 | ['3', '3'], | ||
| 315 | ['4', '4'], | ||
| 316 | ['5', '5'], | ||
| 317 | ['6', '6'], | ||
| 318 | ['7', '7'], | ||
| 319 | ['8', '8'], | ||
| 320 | ['9', '9'] | ||
| 321 | ] | ||
| 322 | } | ||
| 323 | ], | ||
| 324 | "category": Blockly.Categories.event, | ||
| 325 | "extensions": ["colours_event", "shape_hat"] | ||
| 326 | }); | ||
| 327 | } | ||
| 328 | }; |
blocks_vertical/extensions.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Blocks.extensions'); | ||
| 24 | |||
| 25 | goog.require('Blockly.Blocks'); | ||
| 26 | goog.require('Blockly.Colours'); | ||
| 27 | goog.require('Blockly.constants'); | ||
| 28 | goog.require('Blockly.ScratchBlocks.VerticalExtensions'); | ||
| 29 | |||
| 30 | Blockly.Blocks['extension_pen_down'] = { | ||
| 31 | /** | ||
| 32 | * @this Blockly.Block | ||
| 33 | */ | ||
| 34 | init: function() { | ||
| 35 | this.jsonInit({ | ||
| 36 | "message0": "%1 %2 pen down", | ||
| 37 | "args0": [ | ||
| 38 | { | ||
| 39 | "type": "field_image", | ||
| 40 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/pen-block-icon.svg", | ||
| 41 | "width": 40, | ||
| 42 | "height": 40 | ||
| 43 | }, | ||
| 44 | { | ||
| 45 | "type": "field_vertical_separator" | ||
| 46 | } | ||
| 47 | ], | ||
| 48 | "category": Blockly.Categories.more, | ||
| 49 | "extensions": ["colours_more", "shape_statement", "scratch_extension"] | ||
| 50 | }); | ||
| 51 | } | ||
| 52 | }; | ||
| 53 | |||
| 54 | Blockly.Blocks['extension_music_drum'] = { | ||
| 55 | /** | ||
| 56 | * @this Blockly.Block | ||
| 57 | */ | ||
| 58 | init: function() { | ||
| 59 | this.jsonInit({ | ||
| 60 | "message0": "%1 %2 play drum %3", | ||
| 61 | "args0": [ | ||
| 62 | { | ||
| 63 | "type": "field_image", | ||
| 64 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/music-block-icon.svg", | ||
| 65 | "width": 40, | ||
| 66 | "height": 40 | ||
| 67 | }, | ||
| 68 | { | ||
| 69 | "type": "field_vertical_separator" | ||
| 70 | }, | ||
| 71 | { | ||
| 72 | "type": "input_value", | ||
| 73 | "name": "NUMBER" | ||
| 74 | } | ||
| 75 | ], | ||
| 76 | "category": Blockly.Categories.more, | ||
| 77 | "extensions": ["colours_more", "shape_statement", "scratch_extension"] | ||
| 78 | }); | ||
| 79 | } | ||
| 80 | }; | ||
| 81 | |||
| 82 | Blockly.Blocks['extension_wedo_motor'] = { | ||
| 83 | /** | ||
| 84 | * @this Blockly.Block | ||
| 85 | */ | ||
| 86 | init: function() { | ||
| 87 | this.jsonInit({ | ||
| 88 | "message0": "%1 %2 turn a motor %3", | ||
| 89 | "args0": [ | ||
| 90 | { | ||
| 91 | "type": "field_image", | ||
| 92 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/wedo2-block-icon.svg", | ||
| 93 | "width": 40, | ||
| 94 | "height": 40 | ||
| 95 | }, | ||
| 96 | { | ||
| 97 | "type": "field_vertical_separator" | ||
| 98 | }, | ||
| 99 | { | ||
| 100 | "type": "field_image", | ||
| 101 | "src": Blockly.mainWorkspace.options.pathToMedia + "rotate-right.svg", | ||
| 102 | "width": 24, | ||
| 103 | "height": 24 | ||
| 104 | } | ||
| 105 | ], | ||
| 106 | "category": Blockly.Categories.more, | ||
| 107 | "extensions": ["colours_more", "shape_statement", "scratch_extension"] | ||
| 108 | }); | ||
| 109 | } | ||
| 110 | }; | ||
| 111 | |||
| 112 | Blockly.Blocks['extension_wedo_hat'] = { | ||
| 113 | /** | ||
| 114 | * @this Blockly.Block | ||
| 115 | */ | ||
| 116 | init: function() { | ||
| 117 | this.jsonInit({ | ||
| 118 | "message0": "%1 %2 when I am wearing a hat", | ||
| 119 | "args0": [ | ||
| 120 | { | ||
| 121 | "type": "field_image", | ||
| 122 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/wedo2-block-icon.svg", | ||
| 123 | "width": 40, | ||
| 124 | "height": 40 | ||
| 125 | }, | ||
| 126 | { | ||
| 127 | "type": "field_vertical_separator" | ||
| 128 | } | ||
| 129 | ], | ||
| 130 | "category": Blockly.Categories.more, | ||
| 131 | "extensions": ["colours_more", "shape_hat", "scratch_extension"] | ||
| 132 | }); | ||
| 133 | } | ||
| 134 | }; | ||
| 135 | |||
| 136 | Blockly.Blocks['extension_wedo_boolean'] = { | ||
| 137 | /** | ||
| 138 | * @this Blockly.Block | ||
| 139 | */ | ||
| 140 | init: function() { | ||
| 141 | this.jsonInit({ | ||
| 142 | "message0": "%1 %2 O RLY?", | ||
| 143 | "args0": [ | ||
| 144 | { | ||
| 145 | "type": "field_image", | ||
| 146 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/wedo2-block-icon.svg", | ||
| 147 | "width": 40, | ||
| 148 | "height": 40 | ||
| 149 | }, | ||
| 150 | { | ||
| 151 | "type": "field_vertical_separator" | ||
| 152 | } | ||
| 153 | ], | ||
| 154 | "category": Blockly.Categories.more, | ||
| 155 | "extensions": ["colours_more", "output_boolean", "scratch_extension"] | ||
| 156 | }); | ||
| 157 | } | ||
| 158 | }; | ||
| 159 | |||
| 160 | Blockly.Blocks['extension_wedo_tilt_reporter'] = { | ||
| 161 | /** | ||
| 162 | * @this Blockly.Block | ||
| 163 | */ | ||
| 164 | init: function() { | ||
| 165 | this.jsonInit({ | ||
| 166 | "message0": "%1 %2 tilt angle %3", | ||
| 167 | "args0": [ | ||
| 168 | { | ||
| 169 | "type": "field_image", | ||
| 170 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/wedo2-block-icon.svg", | ||
| 171 | "width": 40, | ||
| 172 | "height": 40 | ||
| 173 | }, | ||
| 174 | { | ||
| 175 | "type": "field_vertical_separator" | ||
| 176 | }, | ||
| 177 | { | ||
| 178 | "type": "input_value", | ||
| 179 | "name": "TILT" | ||
| 180 | } | ||
| 181 | ], | ||
| 182 | "category": Blockly.Categories.more, | ||
| 183 | "extensions": ["colours_more", "output_number", "scratch_extension"] | ||
| 184 | }); | ||
| 185 | } | ||
| 186 | }; | ||
| 187 | |||
| 188 | Blockly.Blocks['extension_wedo_tilt_menu'] = { | ||
| 189 | /** | ||
| 190 | * @this Blockly.Block | ||
| 191 | */ | ||
| 192 | init: function() { | ||
| 193 | this.jsonInit({ | ||
| 194 | "message0": "%1", | ||
| 195 | "args0": [ | ||
| 196 | { | ||
| 197 | "type": "field_dropdown", | ||
| 198 | "name": "TILT", | ||
| 199 | "options": [ | ||
| 200 | ['Any', 'Any'], | ||
| 201 | ['Whirl', 'Whirl'], | ||
| 202 | ['South', 'South'], | ||
| 203 | ['Back in time', 'Back in time'] | ||
| 204 | ] | ||
| 205 | } | ||
| 206 | ], | ||
| 207 | "extensions": ["colours_more", "output_string"] | ||
| 208 | }); | ||
| 209 | } | ||
| 210 | }; | ||
| 211 | |||
| 212 | Blockly.Blocks['extension_music_reporter'] = { | ||
| 213 | /** | ||
| 214 | * @this Blockly.Block | ||
| 215 | */ | ||
| 216 | init: function() { | ||
| 217 | this.jsonInit({ | ||
| 218 | "message0": "%1 %2 hey now, you're an all-star", | ||
| 219 | "args0": [ | ||
| 220 | { | ||
| 221 | "type": "field_image", | ||
| 222 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/music-block-icon.svg", | ||
| 223 | "width": 40, | ||
| 224 | "height": 40 | ||
| 225 | }, | ||
| 226 | { | ||
| 227 | "type": "field_vertical_separator" | ||
| 228 | } | ||
| 229 | ], | ||
| 230 | "category": Blockly.Categories.more, | ||
| 231 | "extensions": ["colours_more", "output_number", "scratch_extension"] | ||
| 232 | }); | ||
| 233 | } | ||
| 234 | }; | ||
| 235 | |||
| 236 | Blockly.Blocks['extension_microbit_display'] = { | ||
| 237 | /** | ||
| 238 | * @this Blockly.Block | ||
| 239 | */ | ||
| 240 | init: function() { | ||
| 241 | this.jsonInit({ | ||
| 242 | "message0": "%1 %2 display %3", | ||
| 243 | "args0": [ | ||
| 244 | { | ||
| 245 | "type": "field_image", | ||
| 246 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/microbit-block-icon.svg", | ||
| 247 | "width": 40, | ||
| 248 | "height": 40 | ||
| 249 | }, | ||
| 250 | { | ||
| 251 | "type": "field_vertical_separator" | ||
| 252 | }, | ||
| 253 | { | ||
| 254 | "type": "input_value", | ||
| 255 | "name": "MATRIX" | ||
| 256 | }, | ||
| 257 | ], | ||
| 258 | "category": Blockly.Categories.pen, | ||
| 259 | "extensions": ["colours_pen", "shape_statement", "scratch_extension"] | ||
| 260 | }); | ||
| 261 | } | ||
| 262 | }; | ||
| 263 | |||
| 264 | Blockly.Blocks['extension_music_play_note'] = { | ||
| 265 | /** | ||
| 266 | * @this Blockly.Block | ||
| 267 | */ | ||
| 268 | init: function() { | ||
| 269 | this.jsonInit({ | ||
| 270 | "message0": "%1 %2 play note %3 for %4 beats", | ||
| 271 | "args0": [ | ||
| 272 | { | ||
| 273 | "type": "field_image", | ||
| 274 | "src": Blockly.mainWorkspace.options.pathToMedia + "extensions/music-block-icon.svg", | ||
| 275 | "width": 40, | ||
| 276 | "height": 40 | ||
| 277 | }, | ||
| 278 | { | ||
| 279 | "type": "field_vertical_separator" | ||
| 280 | }, | ||
| 281 | { | ||
| 282 | "type": "input_value", | ||
| 283 | "name": "NOTE" | ||
| 284 | }, | ||
| 285 | { | ||
| 286 | "type": "input_value", | ||
| 287 | "name": "BEATS" | ||
| 288 | } | ||
| 289 | ], | ||
| 290 | "category": Blockly.Categories.pen, | ||
| 291 | "extensions": ["colours_pen", "shape_statement", "scratch_extension"] | ||
| 292 | }); | ||
| 293 | } | ||
| 294 | }; |
blocks_vertical/looks.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/motion.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/operators.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/procedures.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/sensing.js
0 → 100644
This diff is collapsed.
Click to expand it.
blocks_vertical/sound.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Blocks.sound'); | ||
| 24 | |||
| 25 | goog.require('Blockly.Blocks'); | ||
| 26 | goog.require('Blockly.Colours'); | ||
| 27 | goog.require('Blockly.constants'); | ||
| 28 | goog.require('Blockly.ScratchBlocks.VerticalExtensions'); | ||
| 29 | |||
| 30 | Blockly.Blocks['sound_sounds_menu'] = { | ||
| 31 | /** | ||
| 32 | * Sound effects drop-down menu. | ||
| 33 | * @this Blockly.Block | ||
| 34 | */ | ||
| 35 | init: function() { | ||
| 36 | this.jsonInit({ | ||
| 37 | "message0": "%1", | ||
| 38 | "args0": [ | ||
| 39 | { | ||
| 40 | "type": "field_dropdown", | ||
| 41 | "name": "SOUND_MENU", | ||
| 42 | "options": [ | ||
| 43 | ['1', '0'], | ||
| 44 | ['2', '1'], | ||
| 45 | ['3', '2'], | ||
| 46 | ['4', '3'], | ||
| 47 | ['5', '4'], | ||
| 48 | ['6', '5'], | ||
| 49 | ['7', '6'], | ||
| 50 | ['8', '7'], | ||
| 51 | ['9', '8'], | ||
| 52 | ['10', '9'], | ||
| 53 | ['call a function', function() { | ||
| 54 | window.alert('function called!');} | ||
| 55 | ] | ||
| 56 | ] | ||
| 57 | } | ||
| 58 | ], | ||
| 59 | "colour": Blockly.Colours.sounds.secondary, | ||
| 60 | "colourSecondary": Blockly.Colours.sounds.secondary, | ||
| 61 | "colourTertiary": Blockly.Colours.sounds.tertiary, | ||
| 62 | "extensions": ["output_string"] | ||
| 63 | }); | ||
| 64 | } | ||
| 65 | }; | ||
| 66 | |||
| 67 | Blockly.Blocks['sound_play'] = { | ||
| 68 | /** | ||
| 69 | * Block to play sound. | ||
| 70 | * @this Blockly.Block | ||
| 71 | */ | ||
| 72 | init: function() { | ||
| 73 | this.jsonInit({ | ||
| 74 | "message0": Blockly.Msg.SOUND_PLAY, | ||
| 75 | "args0": [ | ||
| 76 | { | ||
| 77 | "type": "input_value", | ||
| 78 | "name": "SOUND_MENU" | ||
| 79 | } | ||
| 80 | ], | ||
| 81 | "category": Blockly.Categories.sound, | ||
| 82 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 83 | }); | ||
| 84 | } | ||
| 85 | }; | ||
| 86 | |||
| 87 | Blockly.Blocks['sound_playuntildone'] = { | ||
| 88 | /** | ||
| 89 | * Block to play sound until done. | ||
| 90 | * @this Blockly.Block | ||
| 91 | */ | ||
| 92 | init: function() { | ||
| 93 | this.jsonInit({ | ||
| 94 | "message0": Blockly.Msg.SOUND_PLAYUNTILDONE, | ||
| 95 | "args0": [ | ||
| 96 | { | ||
| 97 | "type": "input_value", | ||
| 98 | "name": "SOUND_MENU" | ||
| 99 | } | ||
| 100 | ], | ||
| 101 | "category": Blockly.Categories.sound, | ||
| 102 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 103 | }); | ||
| 104 | } | ||
| 105 | }; | ||
| 106 | |||
| 107 | Blockly.Blocks['sound_stopallsounds'] = { | ||
| 108 | /** | ||
| 109 | * Block to stop all sounds | ||
| 110 | * @this Blockly.Block | ||
| 111 | */ | ||
| 112 | init: function() { | ||
| 113 | this.jsonInit({ | ||
| 114 | "message0": Blockly.Msg.SOUND_STOPALLSOUNDS, | ||
| 115 | "category": Blockly.Categories.sound, | ||
| 116 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 117 | }); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | Blockly.Blocks['sound_seteffectto'] = { | ||
| 122 | /** | ||
| 123 | * Block to set the audio effect | ||
| 124 | * @this Blockly.Block | ||
| 125 | */ | ||
| 126 | init: function() { | ||
| 127 | this.jsonInit({ | ||
| 128 | "message0": Blockly.Msg.SOUND_SETEFFECTO, | ||
| 129 | "args0": [ | ||
| 130 | { | ||
| 131 | "type": "field_dropdown", | ||
| 132 | "name": "EFFECT", | ||
| 133 | "options": [ | ||
| 134 | [Blockly.Msg.SOUND_EFFECTS_PITCH, 'PITCH'], | ||
| 135 | [Blockly.Msg.SOUND_EFFECTS_PAN, 'PAN'] | ||
| 136 | ] | ||
| 137 | }, | ||
| 138 | { | ||
| 139 | "type": "input_value", | ||
| 140 | "name": "VALUE" | ||
| 141 | } | ||
| 142 | ], | ||
| 143 | "category": Blockly.Categories.sound, | ||
| 144 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 145 | }); | ||
| 146 | } | ||
| 147 | }; | ||
| 148 | |||
| 149 | |||
| 150 | Blockly.Blocks['sound_changeeffectby'] = { | ||
| 151 | /** | ||
| 152 | * Block to change the audio effect | ||
| 153 | * @this Blockly.Block | ||
| 154 | */ | ||
| 155 | init: function() { | ||
| 156 | this.jsonInit({ | ||
| 157 | "message0": Blockly.Msg.SOUND_CHANGEEFFECTBY, | ||
| 158 | "args0": [ | ||
| 159 | { | ||
| 160 | "type": "field_dropdown", | ||
| 161 | "name": "EFFECT", | ||
| 162 | "options": [ | ||
| 163 | [Blockly.Msg.SOUND_EFFECTS_PITCH, 'PITCH'], | ||
| 164 | [Blockly.Msg.SOUND_EFFECTS_PAN, 'PAN'] | ||
| 165 | ] | ||
| 166 | }, | ||
| 167 | { | ||
| 168 | "type": "input_value", | ||
| 169 | "name": "VALUE" | ||
| 170 | } | ||
| 171 | ], | ||
| 172 | "category": Blockly.Categories.sound, | ||
| 173 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 174 | }); | ||
| 175 | } | ||
| 176 | }; | ||
| 177 | |||
| 178 | Blockly.Blocks['sound_cleareffects'] = { | ||
| 179 | /** | ||
| 180 | * Block to clear audio effects | ||
| 181 | * @this Blockly.Block | ||
| 182 | */ | ||
| 183 | init: function() { | ||
| 184 | this.jsonInit({ | ||
| 185 | "message0": Blockly.Msg.SOUND_CLEAREFFECTS, | ||
| 186 | "category": Blockly.Categories.sound, | ||
| 187 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 188 | }); | ||
| 189 | } | ||
| 190 | }; | ||
| 191 | |||
| 192 | Blockly.Blocks['sound_changevolumeby'] = { | ||
| 193 | /** | ||
| 194 | * Block to change the sprite's volume by a certain value | ||
| 195 | * @this Blockly.Block | ||
| 196 | */ | ||
| 197 | init: function() { | ||
| 198 | this.jsonInit({ | ||
| 199 | "message0": Blockly.Msg.SOUND_CHANGEVOLUMEBY, | ||
| 200 | "args0": [ | ||
| 201 | { | ||
| 202 | "type": "input_value", | ||
| 203 | "name": "VOLUME" | ||
| 204 | } | ||
| 205 | ], | ||
| 206 | "category": Blockly.Categories.sound, | ||
| 207 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 208 | }); | ||
| 209 | } | ||
| 210 | }; | ||
| 211 | |||
| 212 | Blockly.Blocks['sound_setvolumeto'] = { | ||
| 213 | /** | ||
| 214 | * Block to set the sprite's volume to a certain percent | ||
| 215 | * @this Blockly.Block | ||
| 216 | */ | ||
| 217 | init: function() { | ||
| 218 | this.jsonInit({ | ||
| 219 | "message0": Blockly.Msg.SOUND_SETVOLUMETO, | ||
| 220 | "args0": [ | ||
| 221 | { | ||
| 222 | "type": "input_value", | ||
| 223 | "name": "VOLUME" | ||
| 224 | } | ||
| 225 | ], | ||
| 226 | "category": Blockly.Categories.sound, | ||
| 227 | "extensions": ["colours_sounds", "shape_statement"] | ||
| 228 | }); | ||
| 229 | } | ||
| 230 | }; | ||
| 231 | |||
| 232 | Blockly.Blocks['sound_volume'] = { | ||
| 233 | /** | ||
| 234 | * Block to report volume | ||
| 235 | * @this Blockly.Block | ||
| 236 | */ | ||
| 237 | init: function() { | ||
| 238 | this.jsonInit({ | ||
| 239 | "message0": Blockly.Msg.SOUND_VOLUME, | ||
| 240 | "category": Blockly.Categories.sound, | ||
| 241 | "checkboxInFlyout": true, | ||
| 242 | "extensions": ["colours_sounds", "output_number"] | ||
| 243 | }); | ||
| 244 | } | ||
| 245 | }; |
blocks_vertical/stdint.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2020 openblock.cc. | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Blocks.stdint'); | ||
| 24 | |||
| 25 | goog.require('Blockly.Blocks'); | ||
| 26 | goog.require('Blockly.Colours'); | ||
| 27 | |||
| 28 | |||
| 29 | Blockly.Blocks['math_int8_number'] = { | ||
| 30 | init: function() { | ||
| 31 | this.jsonInit({ | ||
| 32 | "message0": "%1", | ||
| 33 | "args0": [ | ||
| 34 | { | ||
| 35 | "type": "field_slider", | ||
| 36 | "name": "NUM", | ||
| 37 | "value": "0", | ||
| 38 | "precision": 1, | ||
| 39 | "min": "-127", | ||
| 40 | "max": "127" | ||
| 41 | } | ||
| 42 | ], | ||
| 43 | "output": "Number", | ||
| 44 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 45 | "colour": Blockly.Colours.textField, | ||
| 46 | "colourSecondary": Blockly.Colours.textField, | ||
| 47 | "colourTertiary": Blockly.Colours.textField | ||
| 48 | }); | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | Blockly.Blocks['math_uint8_number'] = { | ||
| 53 | init: function() { | ||
| 54 | this.jsonInit({ | ||
| 55 | message0: "%1", | ||
| 56 | args0: [ | ||
| 57 | { | ||
| 58 | "type": "field_slider", | ||
| 59 | "name": "NUM", | ||
| 60 | "value": "0", | ||
| 61 | "precision": 1, | ||
| 62 | "min": "0", | ||
| 63 | "max": "255" | ||
| 64 | } | ||
| 65 | ], | ||
| 66 | "output": "Number", | ||
| 67 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 68 | "colour": Blockly.Colours.textField, | ||
| 69 | "colourSecondary": Blockly.Colours.textField, | ||
| 70 | "colourTertiary": Blockly.Colours.textField | ||
| 71 | }); | ||
| 72 | } | ||
| 73 | }; | ||
| 74 | |||
| 75 | Blockly.Blocks['math_int9_number'] = { | ||
| 76 | init: function() { | ||
| 77 | this.jsonInit({ | ||
| 78 | "message0": "%1", | ||
| 79 | "args0": [ | ||
| 80 | { | ||
| 81 | "type": "field_slider", | ||
| 82 | "name": "NUM", | ||
| 83 | "value": "0", | ||
| 84 | "precision": 1, | ||
| 85 | "min": "-255", | ||
| 86 | "max": "255" | ||
| 87 | } | ||
| 88 | ], | ||
| 89 | "output": "Number", | ||
| 90 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 91 | "colour": Blockly.Colours.textField, | ||
| 92 | "colourSecondary": Blockly.Colours.textField, | ||
| 93 | "colourTertiary": Blockly.Colours.textField | ||
| 94 | }); | ||
| 95 | } | ||
| 96 | }; | ||
| 97 | |||
| 98 | Blockly.Blocks['math_uint10_number'] = { | ||
| 99 | init: function() { | ||
| 100 | this.jsonInit({ | ||
| 101 | "message0": "%1", | ||
| 102 | "args0": [ | ||
| 103 | { | ||
| 104 | "type": "field_slider", | ||
| 105 | "name": "NUM", | ||
| 106 | "value": "0", | ||
| 107 | "precision": 1, | ||
| 108 | "min": "0", | ||
| 109 | "max": "1023" | ||
| 110 | } | ||
| 111 | ], | ||
| 112 | "output": "Number", | ||
| 113 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 114 | "colour": Blockly.Colours.textField, | ||
| 115 | "colourSecondary": Blockly.Colours.textField, | ||
| 116 | "colourTertiary": Blockly.Colours.textField | ||
| 117 | }); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | Blockly.Blocks['math_int11_number'] = { | ||
| 122 | init: function() { | ||
| 123 | this.jsonInit({ | ||
| 124 | "message0": "%1", | ||
| 125 | "args0": [ | ||
| 126 | { | ||
| 127 | "type": "field_slider", | ||
| 128 | "name": "NUM", | ||
| 129 | "value": "0", | ||
| 130 | "precision": 1, | ||
| 131 | "min": "-1023", | ||
| 132 | "max": "1023" | ||
| 133 | } | ||
| 134 | ], | ||
| 135 | "output": "Number", | ||
| 136 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 137 | "colour": Blockly.Colours.textField, | ||
| 138 | "colourSecondary": Blockly.Colours.textField, | ||
| 139 | "colourTertiary": Blockly.Colours.textField | ||
| 140 | }); | ||
| 141 | } | ||
| 142 | }; | ||
| 143 | |||
| 144 | Blockly.Blocks['math_uint16_number'] = { | ||
| 145 | init: function() { | ||
| 146 | this.jsonInit({ | ||
| 147 | "message0": "%1", | ||
| 148 | "args0": [ | ||
| 149 | { | ||
| 150 | "type": "field_slider", | ||
| 151 | "name": "NUM", | ||
| 152 | "value": "0", | ||
| 153 | "precision": 1, | ||
| 154 | "min": "0", | ||
| 155 | "max": "65535" | ||
| 156 | } | ||
| 157 | ], | ||
| 158 | "output": "Number", | ||
| 159 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 160 | "colour": Blockly.Colours.textField, | ||
| 161 | "colourSecondary": Blockly.Colours.textField, | ||
| 162 | "colourTertiary": Blockly.Colours.textField | ||
| 163 | }); | ||
| 164 | } | ||
| 165 | }; | ||
| 166 | |||
| 167 | Blockly.Blocks['math_int0to100_number'] = { | ||
| 168 | init: function() { | ||
| 169 | this.jsonInit({ | ||
| 170 | "message0": "%1", | ||
| 171 | "args0": [ | ||
| 172 | { | ||
| 173 | "type": "field_slider", | ||
| 174 | "name": "NUM", | ||
| 175 | "value": "0", | ||
| 176 | "precision": 1, | ||
| 177 | "min": "0", | ||
| 178 | "max": "100" | ||
| 179 | } | ||
| 180 | ], | ||
| 181 | "output": "Number", | ||
| 182 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 183 | "colour": Blockly.Colours.textField, | ||
| 184 | "colourSecondary": Blockly.Colours.textField, | ||
| 185 | "colourTertiary": Blockly.Colours.textField | ||
| 186 | }); | ||
| 187 | } | ||
| 188 | }; | ||
| 189 | |||
| 190 | Blockly.Blocks['math_0to100_number'] = { | ||
| 191 | init: function() { | ||
| 192 | this.jsonInit({ | ||
| 193 | "message0": "%1", | ||
| 194 | "args0": [ | ||
| 195 | { | ||
| 196 | "type": "field_slider", | ||
| 197 | "name": "NUM", | ||
| 198 | "value": "0", | ||
| 199 | "min": "0", | ||
| 200 | "max": "100" | ||
| 201 | } | ||
| 202 | ], | ||
| 203 | "output": "Number", | ||
| 204 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 205 | "colour": Blockly.Colours.textField, | ||
| 206 | "colourSecondary": Blockly.Colours.textField, | ||
| 207 | "colourTertiary": Blockly.Colours.textField | ||
| 208 | }); | ||
| 209 | } | ||
| 210 | }; | ||
| 211 | |||
| 212 | Blockly.Blocks['math_intn100to100_number'] = { | ||
| 213 | init: function() { | ||
| 214 | this.jsonInit({ | ||
| 215 | "message0": "%1", | ||
| 216 | "args0": [ | ||
| 217 | { | ||
| 218 | "type": "field_slider", | ||
| 219 | "name": "NUM", | ||
| 220 | "value": "0", | ||
| 221 | "precision": 1, | ||
| 222 | "min": "-100", | ||
| 223 | "max": "100" | ||
| 224 | } | ||
| 225 | ], | ||
| 226 | "output": "Number", | ||
| 227 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 228 | "colour": Blockly.Colours.textField, | ||
| 229 | "colourSecondary": Blockly.Colours.textField, | ||
| 230 | "colourTertiary": Blockly.Colours.textField | ||
| 231 | }); | ||
| 232 | } | ||
| 233 | }; | ||
| 234 | |||
| 235 | Blockly.Blocks['math_n100to100_number'] = { | ||
| 236 | init: function() { | ||
| 237 | this.jsonInit({ | ||
| 238 | "message0": "%1", | ||
| 239 | "args0": [ | ||
| 240 | { | ||
| 241 | "type": "field_slider", | ||
| 242 | "name": "NUM", | ||
| 243 | "value": "0", | ||
| 244 | "min": "-100", | ||
| 245 | "max": "100" | ||
| 246 | } | ||
| 247 | ], | ||
| 248 | "output": "Number", | ||
| 249 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 250 | "colour": Blockly.Colours.textField, | ||
| 251 | "colourSecondary": Blockly.Colours.textField, | ||
| 252 | "colourTertiary": Blockly.Colours.textField | ||
| 253 | }); | ||
| 254 | } | ||
| 255 | }; | ||
| 256 | |||
| 257 | |||
| 258 | |||
| 259 | Blockly.Blocks['math_half_angle'] = { | ||
| 260 | init: function() { | ||
| 261 | this.jsonInit({ | ||
| 262 | "message0": "%1", | ||
| 263 | "args0": [ | ||
| 264 | { | ||
| 265 | "type": "field_angle", | ||
| 266 | "name": "NUM", | ||
| 267 | "value": 90, | ||
| 268 | "max": 180 | ||
| 269 | } | ||
| 270 | ], | ||
| 271 | "output": "Number", | ||
| 272 | "outputShape": Blockly.OUTPUT_SHAPE_ROUND, | ||
| 273 | "colour": Blockly.Colours.textField, | ||
| 274 | "colourSecondary": Blockly.Colours.textField, | ||
| 275 | "colourTertiary": Blockly.Colours.textField | ||
| 276 | }); | ||
| 277 | } | ||
| 278 | }; | ||
| 279 |
blocks_vertical/vertical_extensions.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2017 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Extensions for vertical blocks in scratch-blocks. | ||
| 23 | * The following extensions can be used to describe a block in Scratch terms. | ||
| 24 | * For instance, a block in the operators colour scheme with a number output | ||
| 25 | * would have the "colours_operators" and "output_number" extensions. | ||
| 26 | * @author fenichel@google.com (Rachel Fenichel) | ||
| 27 | */ | ||
| 28 | 'use strict'; | ||
| 29 | |||
| 30 | goog.provide('Blockly.ScratchBlocks.VerticalExtensions'); | ||
| 31 | |||
| 32 | goog.require('Blockly.Colours'); | ||
| 33 | goog.require('Blockly.constants'); | ||
| 34 | |||
| 35 | |||
| 36 | /** | ||
| 37 | * Helper function that generates an extension based on a category name. | ||
| 38 | * The generated function will set primary, secondary, and tertiary colours | ||
| 39 | * based on the category name. | ||
| 40 | * @param {String} category The name of the category to set colours for. | ||
| 41 | * @return {function} An extension function that sets colours based on the given | ||
| 42 | * category. | ||
| 43 | */ | ||
| 44 | Blockly.ScratchBlocks.VerticalExtensions.colourHelper = function(category) { | ||
| 45 | var colours = Blockly.Colours[category]; | ||
| 46 | if (!(colours && colours.primary && colours.secondary && colours.tertiary)) { | ||
| 47 | throw new Error('Could not find colours for category "' + category + '"'); | ||
| 48 | } | ||
| 49 | /** | ||
| 50 | * Set the primary, secondary, and tertiary colours on this block for the | ||
| 51 | * given category. | ||
| 52 | * @this {Blockly.Block} | ||
| 53 | */ | ||
| 54 | return function() { | ||
| 55 | this.setColourFromRawValues_(colours.primary, colours.secondary, | ||
| 56 | colours.tertiary); | ||
| 57 | }; | ||
| 58 | }; | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Extension to set the colours of a text field, which are all the same. | ||
| 62 | */ | ||
| 63 | Blockly.ScratchBlocks.VerticalExtensions.COLOUR_TEXTFIELD = function() { | ||
| 64 | this.setColourFromRawValues_(Blockly.Colours.textField, | ||
| 65 | Blockly.Colours.textField, Blockly.Colours.textField); | ||
| 66 | }; | ||
| 67 | |||
| 68 | /** | ||
| 69 | * Extension to make a block fit into a stack of statements, regardless of its | ||
| 70 | * inputs. That means the block should have a previous connection and a next | ||
| 71 | * connection and have inline inputs. | ||
| 72 | * @this {Blockly.Block} | ||
| 73 | * @readonly | ||
| 74 | */ | ||
| 75 | Blockly.ScratchBlocks.VerticalExtensions.SHAPE_STATEMENT = function() { | ||
| 76 | this.setInputsInline(true); | ||
| 77 | this.setPreviousStatement(true, null); | ||
| 78 | this.setNextStatement(true, null); | ||
| 79 | }; | ||
| 80 | |||
| 81 | /** | ||
| 82 | * Extension to make a block be shaped as a hat block, regardless of its | ||
| 83 | * inputs. That means the block should have a next connection and have inline | ||
| 84 | * inputs, but have no previous connection. | ||
| 85 | * @this {Blockly.Block} | ||
| 86 | * @readonly | ||
| 87 | */ | ||
| 88 | Blockly.ScratchBlocks.VerticalExtensions.SHAPE_HAT = function() { | ||
| 89 | this.setInputsInline(true); | ||
| 90 | this.setNextStatement(true, null); | ||
| 91 | }; | ||
| 92 | |||
| 93 | /** | ||
| 94 | * Extension to make a block be shaped as an end block, regardless of its | ||
| 95 | * inputs. That means the block should have a previous connection and have | ||
| 96 | * inline inputs, but have no next connection. | ||
| 97 | * @this {Blockly.Block} | ||
| 98 | * @readonly | ||
| 99 | */ | ||
| 100 | Blockly.ScratchBlocks.VerticalExtensions.SHAPE_END = function() { | ||
| 101 | this.setInputsInline(true); | ||
| 102 | this.setPreviousStatement(true, null); | ||
| 103 | }; | ||
| 104 | |||
| 105 | /** | ||
| 106 | * Extension to make represent a number reporter in Scratch-Blocks. | ||
| 107 | * That means the block has inline inputs, a round output shape, and a 'Number' | ||
| 108 | * output type. | ||
| 109 | * @this {Blockly.Block} | ||
| 110 | * @readonly | ||
| 111 | */ | ||
| 112 | Blockly.ScratchBlocks.VerticalExtensions.OUTPUT_NUMBER = function() { | ||
| 113 | this.setInputsInline(true); | ||
| 114 | this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND); | ||
| 115 | this.setOutput(true, 'Number'); | ||
| 116 | }; | ||
| 117 | |||
| 118 | /** | ||
| 119 | * Extension to make represent a string reporter in Scratch-Blocks. | ||
| 120 | * That means the block has inline inputs, a round output shape, and a 'String' | ||
| 121 | * output type. | ||
| 122 | * @this {Blockly.Block} | ||
| 123 | * @readonly | ||
| 124 | */ | ||
| 125 | Blockly.ScratchBlocks.VerticalExtensions.OUTPUT_STRING = function() { | ||
| 126 | this.setInputsInline(true); | ||
| 127 | this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND); | ||
| 128 | this.setOutput(true, 'String'); | ||
| 129 | }; | ||
| 130 | |||
| 131 | /** | ||
| 132 | * Extension to make represent a boolean reporter in Scratch-Blocks. | ||
| 133 | * That means the block has inline inputs, a round output shape, and a 'Boolean' | ||
| 134 | * output type. | ||
| 135 | * @this {Blockly.Block} | ||
| 136 | * @readonly | ||
| 137 | */ | ||
| 138 | Blockly.ScratchBlocks.VerticalExtensions.OUTPUT_BOOLEAN = function() { | ||
| 139 | this.setInputsInline(true); | ||
| 140 | this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL); | ||
| 141 | this.setOutput(true, 'Boolean'); | ||
| 142 | }; | ||
| 143 | |||
| 144 | /** | ||
| 145 | * Mixin to add a context menu for a procedure definition block. | ||
| 146 | * It adds the "edit" option and removes the "duplicate" option. | ||
| 147 | * @mixin | ||
| 148 | * @augments Blockly.Block | ||
| 149 | * @package | ||
| 150 | * @readonly | ||
| 151 | */ | ||
| 152 | Blockly.ScratchBlocks.VerticalExtensions.PROCEDURE_DEF_CONTEXTMENU = { | ||
| 153 | /** | ||
| 154 | * Add the "edit" option and removes the "duplicate" option from the context | ||
| 155 | * menu. | ||
| 156 | * @param {!Array.<!Object>} menuOptions List of menu options to edit. | ||
| 157 | * @this Blockly.Block | ||
| 158 | */ | ||
| 159 | customContextMenu: function(menuOptions) { | ||
| 160 | // Add the edit option at the end. | ||
| 161 | menuOptions.push(Blockly.Procedures.makeEditOption(this)); | ||
| 162 | |||
| 163 | // Find the delete option and update its callback to be specific to | ||
| 164 | // functions. | ||
| 165 | for (var i = 0, option; option = menuOptions[i]; i++) { | ||
| 166 | if (option.text == Blockly.Msg.DELETE_BLOCK) { | ||
| 167 | var input = this.getInput('custom_block'); | ||
| 168 | // this is the root block, not the shadow block. | ||
| 169 | if (input && input.connection && input.connection.targetBlock()) { | ||
| 170 | var procCode = input.connection.targetBlock().getProcCode(); | ||
| 171 | } else { | ||
| 172 | return; | ||
| 173 | } | ||
| 174 | var rootBlock = this; | ||
| 175 | option.callback = function() { | ||
| 176 | var didDelete = Blockly.Procedures.deleteProcedureDefCallback( | ||
| 177 | procCode, rootBlock); | ||
| 178 | if (!didDelete) { | ||
| 179 | alert(Blockly.Msg.PROCEDURE_USED); | ||
| 180 | } | ||
| 181 | }; | ||
| 182 | } | ||
| 183 | } | ||
| 184 | // Find and remove the duplicate option | ||
| 185 | for (var i = 0, option; option = menuOptions[i]; i++) { | ||
| 186 | if (option.text == Blockly.Msg.DUPLICATE) { | ||
| 187 | menuOptions.splice(i, 1); | ||
| 188 | break; | ||
| 189 | } | ||
| 190 | } | ||
| 191 | } | ||
| 192 | }; | ||
| 193 | |||
| 194 | /** | ||
| 195 | * Mixin to add a context menu for a procedure call block. | ||
| 196 | * It adds the "edit" option and the "define" option. | ||
| 197 | * @mixin | ||
| 198 | * @augments Blockly.Block | ||
| 199 | * @package | ||
| 200 | * @readonly | ||
| 201 | */ | ||
| 202 | Blockly.ScratchBlocks.VerticalExtensions.PROCEDURE_CALL_CONTEXTMENU = { | ||
| 203 | /** | ||
| 204 | * Add the "edit" option to the context menu. | ||
| 205 | * @todo Add "go to definition" option once implemented. | ||
| 206 | * @param {!Array.<!Object>} menuOptions List of menu options to edit. | ||
| 207 | * @this Blockly.Block | ||
| 208 | */ | ||
| 209 | customContextMenu: function(menuOptions) { | ||
| 210 | menuOptions.push(Blockly.Procedures.makeEditOption(this)); | ||
| 211 | } | ||
| 212 | }; | ||
| 213 | |||
| 214 | |||
| 215 | Blockly.ScratchBlocks.VerticalExtensions.SCRATCH_EXTENSION = function() { | ||
| 216 | this.isScratchExtension = true; | ||
| 217 | }; | ||
| 218 | /** | ||
| 219 | * Register all extensions for scratch-blocks. | ||
| 220 | * @package | ||
| 221 | */ | ||
| 222 | Blockly.ScratchBlocks.VerticalExtensions.registerAll = function() { | ||
| 223 | var categoryNames = | ||
| 224 | ['control', 'data', 'data_lists', 'sounds', 'motion', 'looks', 'event', | ||
| 225 | 'sensing', 'pen', 'operators', 'more']; | ||
| 226 | // Register functions for all category colours. | ||
| 227 | for (var i = 0; i < categoryNames.length; i++) { | ||
| 228 | var name = categoryNames[i]; | ||
| 229 | Blockly.Extensions.register('colours_' + name, | ||
| 230 | Blockly.ScratchBlocks.VerticalExtensions.colourHelper(name)); | ||
| 231 | } | ||
| 232 | |||
| 233 | // Text fields transcend categories. | ||
| 234 | Blockly.Extensions.register('colours_textfield', | ||
| 235 | Blockly.ScratchBlocks.VerticalExtensions.COLOUR_TEXTFIELD); | ||
| 236 | |||
| 237 | // Register extensions for common block shapes. | ||
| 238 | Blockly.Extensions.register('shape_statement', | ||
| 239 | Blockly.ScratchBlocks.VerticalExtensions.SHAPE_STATEMENT); | ||
| 240 | Blockly.Extensions.register('shape_hat', | ||
| 241 | Blockly.ScratchBlocks.VerticalExtensions.SHAPE_HAT); | ||
| 242 | Blockly.Extensions.register('shape_end', | ||
| 243 | Blockly.ScratchBlocks.VerticalExtensions.SHAPE_END); | ||
| 244 | |||
| 245 | // Output shapes and types are related. | ||
| 246 | Blockly.Extensions.register('output_number', | ||
| 247 | Blockly.ScratchBlocks.VerticalExtensions.OUTPUT_NUMBER); | ||
| 248 | Blockly.Extensions.register('output_string', | ||
| 249 | Blockly.ScratchBlocks.VerticalExtensions.OUTPUT_STRING); | ||
| 250 | Blockly.Extensions.register('output_boolean', | ||
| 251 | Blockly.ScratchBlocks.VerticalExtensions.OUTPUT_BOOLEAN); | ||
| 252 | |||
| 253 | // Custom procedures have interesting context menus. | ||
| 254 | Blockly.Extensions.registerMixin('procedure_def_contextmenu', | ||
| 255 | Blockly.ScratchBlocks.VerticalExtensions.PROCEDURE_DEF_CONTEXTMENU); | ||
| 256 | Blockly.Extensions.registerMixin('procedure_call_contextmenu', | ||
| 257 | Blockly.ScratchBlocks.VerticalExtensions.PROCEDURE_CALL_CONTEXTMENU); | ||
| 258 | |||
| 259 | // Extension blocks have slightly different block rendering. | ||
| 260 | Blockly.Extensions.register('scratch_extension', | ||
| 261 | Blockly.ScratchBlocks.VerticalExtensions.SCRATCH_EXTENSION); | ||
| 262 | }; | ||
| 263 | |||
| 264 | Blockly.ScratchBlocks.VerticalExtensions.registerAll(); |
build.py
0 → 100644
This diff is collapsed.
Click to expand it.
build/gen_blocks.js
0 → 100644
| 1 | goog.provide('Blockly.Blocks'); |
build/gen_language.js
0 → 100644
| 1 | goog.provide('Blockly.Generator'); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
build/test_expect.js
0 → 100644
| 1 | var Blockly={Blocks:{}}; |
build/test_input.js
0 → 100644
| 1 | goog.provide('Blockly.Blocks'); |
cleanup.sh
0 → 100644
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Script for cleaning up blockly-specific files when merging blockly into scratch-blocks | ||
| 4 | # Removes files and directories that scratch-blocks doesn't want. | ||
| 5 | # Rachel Fenichel (fenichel@google.com) | ||
| 6 | |||
| 7 | # Note: 'ours' is scratch-blocks, 'theirs' is blockly. | ||
| 8 | |||
| 9 | # Formatting helpers. | ||
| 10 | indent() { sed 's/^/ /'; } | ||
| 11 | indent_more() { sed 's/^/\t/'; } | ||
| 12 | empty_lines() { printf '\n\n'; } | ||
| 13 | |||
| 14 | |||
| 15 | empty_lines | ||
| 16 | echo Cleaning up a merge from Blockly to Scratch-Blocks... | ||
| 17 | |||
| 18 | # Get rid of Blockly's internationalization/messages. This is not usually worth | ||
| 19 | # scrolling up to look at. | ||
| 20 | empty_lines | ||
| 21 | echo Cleaning up Blockly message files... | ||
| 22 | # Turn on more powerful globbing | ||
| 23 | shopt -s extglob | ||
| 24 | |||
| 25 | # Having trouble with directories. Let's just go there. | ||
| 26 | cd msg/json | ||
| 27 | git rm -f !(en.json|synonyms.json) | indent_more | ||
| 28 | cd ../.. | ||
| 29 | |||
| 30 | # Having trouble with directories. Let's just go there. | ||
| 31 | cd msg/js | ||
| 32 | git rm -f !(en.js) | indent_more | ||
| 33 | cd ../.. | ||
| 34 | |||
| 35 | # Turn powerful globbing off again | ||
| 36 | shopt -u extglob | ||
| 37 | |||
| 38 | # Whole directories that we want to get rid of. | ||
| 39 | empty_lines | ||
| 40 | echo Removing blockly-specific directories... | ||
| 41 | dirslist="accessible demos tests/generators appengine blocks local_build" | ||
| 42 | for directory in $dirslist | ||
| 43 | do | ||
| 44 | echo 'Cleaning up' $directory | indent | ||
| 45 | git rm -rf $directory | indent_more | ||
| 46 | done | ||
| 47 | |||
| 48 | # Scratch-blocks does not use generators | ||
| 49 | empty_lines | ||
| 50 | echo Removing generators... | ||
| 51 | generated_langs="dart javascript lua php python" | ||
| 52 | for lang in $generated_langs | ||
| 53 | do | ||
| 54 | echo 'Cleaning up' $lang | indent | ||
| 55 | # Directories containing block generators. | ||
| 56 | git rm -rf generators/${lang} | indent_more | ||
| 57 | done | ||
| 58 | |||
| 59 | # Built stuff that we should get rid of. | ||
| 60 | empty_lines | ||
| 61 | echo Removing built files... | ||
| 62 | built_files="blockly_compressed.js \ | ||
| 63 | blockly_uncompressed.js \ | ||
| 64 | blockly_accessible_compressed.js \ | ||
| 65 | blockly_accessible_uncompressed.js \ | ||
| 66 | blocks_compressed.js \ | ||
| 67 | arduino_compressed.js\ | ||
| 68 | dart_compressed.js \ | ||
| 69 | php_compressed.js \ | ||
| 70 | python_compressed.js \ | ||
| 71 | javascript_compressed.js \ | ||
| 72 | lua_compressed.js" | ||
| 73 | |||
| 74 | for filename in $built_files | ||
| 75 | do | ||
| 76 | git rm $filename | indent_more | ||
| 77 | done | ||
| 78 | |||
| 79 | empty_lines | ||
| 80 | echo Miscellaneous cleanup... | ||
| 81 | # Use ours. | ||
| 82 | keep_ours=".github/ISSUE_TEMPLATE.md \ | ||
| 83 | .github/PULL_REQUEST_TEMPLATE.md \ | ||
| 84 | .gitignore \ | ||
| 85 | .travis.yml \ | ||
| 86 | core/block_animations.js \ | ||
| 87 | msg/messages.js \ | ||
| 88 | msg/js/en.js \ | ||
| 89 | msg/json/en.json" | ||
| 90 | |||
| 91 | |||
| 92 | for filename in $keep_ours | ||
| 93 | do | ||
| 94 | git checkout --ours $filename && git add $filename | indent_more | ||
| 95 | done | ||
| 96 | |||
| 97 | # Scratch-blocks has separate vertical and horizontal playgrounds and block | ||
| 98 | # rendering. | ||
| 99 | git rm -f tests/playground.html core/block_render_svg.js | indent_more | ||
| 100 | |||
| 101 | empty_lines | ||
| 102 | echo Done with cleanup. |
core/block.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/block_animations.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2018 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Methods animating a block on connection and disconnection. | ||
| 23 | * @author fenichel@google.com (Rachel Fenichel) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.BlockAnimations'); | ||
| 28 | |||
| 29 | |||
| 30 | /** | ||
| 31 | * Play some UI effects (sound, animation) when disposing of a block. | ||
| 32 | * @param {!Blockly.BlockSvg} block The block being disposed of. | ||
| 33 | * @package | ||
| 34 | */ | ||
| 35 | Blockly.BlockAnimations.disposeUiEffect = function(block) { | ||
| 36 | var workspace = block.workspace; | ||
| 37 | var svgGroup = block.getSvgRoot(); | ||
| 38 | workspace.getAudioManager().play('delete'); | ||
| 39 | |||
| 40 | var xy = workspace.getSvgXY(svgGroup); | ||
| 41 | // Deeply clone the current block. | ||
| 42 | var clone = svgGroup.cloneNode(true); | ||
| 43 | clone.translateX_ = xy.x; | ||
| 44 | clone.translateY_ = xy.y; | ||
| 45 | clone.setAttribute('transform', 'translate(' + xy.x + ',' + xy.y + ')'); | ||
| 46 | workspace.getParentSvg().appendChild(clone); | ||
| 47 | clone.bBox_ = clone.getBBox(); | ||
| 48 | // Start the animation. | ||
| 49 | Blockly.BlockAnimations.disposeUiStep_(clone, workspace.RTL, new Date, | ||
| 50 | workspace.scale); | ||
| 51 | }; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Animate a cloned block and eventually dispose of it. | ||
| 55 | * This is a class method, not an instance method since the original block has | ||
| 56 | * been destroyed and is no longer accessible. | ||
| 57 | * @param {!Element} clone SVG element to animate and dispose of. | ||
| 58 | * @param {boolean} rtl True if RTL, false if LTR. | ||
| 59 | * @param {!Date} start Date of animation's start. | ||
| 60 | * @param {number} workspaceScale Scale of workspace. | ||
| 61 | * @private | ||
| 62 | */ | ||
| 63 | Blockly.BlockAnimations.disposeUiStep_ = function(clone, rtl, start, | ||
| 64 | workspaceScale) { | ||
| 65 | var ms = new Date - start; | ||
| 66 | var percent = ms / 150; | ||
| 67 | if (percent > 1) { | ||
| 68 | goog.dom.removeNode(clone); | ||
| 69 | } else { | ||
| 70 | var x = clone.translateX_ + | ||
| 71 | (rtl ? -1 : 1) * clone.bBox_.width * workspaceScale / 2 * percent; | ||
| 72 | var y = clone.translateY_ + clone.bBox_.height * workspaceScale * percent; | ||
| 73 | var scale = (1 - percent) * workspaceScale; | ||
| 74 | clone.setAttribute('transform', 'translate(' + x + ',' + y + ')' + | ||
| 75 | ' scale(' + scale + ')'); | ||
| 76 | setTimeout(Blockly.BlockAnimations.disposeUiStep_, 10, clone, rtl, start, | ||
| 77 | workspaceScale); | ||
| 78 | } | ||
| 79 | }; | ||
| 80 | |||
| 81 | /** | ||
| 82 | * Play some UI effects (sound, ripple) after a connection has been established. | ||
| 83 | * @param {!Blockly.BlockSvg} block The block being connected. | ||
| 84 | * @package | ||
| 85 | */ | ||
| 86 | Blockly.BlockAnimations.connectionUiEffect = function(block) { | ||
| 87 | block.workspace.getAudioManager().play('click'); | ||
| 88 | }; | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Play some UI effects (sound, animation) when disconnecting a block. | ||
| 92 | * No-op in scratch-blocks, which has no disconnect animation. | ||
| 93 | * @param {!Blockly.BlockSvg} _block The block being disconnected. | ||
| 94 | * @package | ||
| 95 | */ | ||
| 96 | Blockly.BlockAnimations.disconnectUiEffect = function( | ||
| 97 | /* eslint-disable no-unused-vars */ _block | ||
| 98 | /* eslint-enable no-unused-vars */) { | ||
| 99 | }; | ||
| 100 | |||
| 101 | /** | ||
| 102 | * Stop the disconnect UI animation immediately. | ||
| 103 | * No-op in scratch-blocks, which has no disconnect animation. | ||
| 104 | * @package | ||
| 105 | */ | ||
| 106 | Blockly.BlockAnimations.disconnectUiStop = function() { | ||
| 107 | }; |
core/block_drag_surface.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/block_dragger.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/block_events.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/block_render_svg_horizontal.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/block_render_svg_vertical.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/block_svg.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/blockly.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/blocks.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2013 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview A mapping of block type names to block prototype objects. | ||
| 23 | * @author spertus@google.com (Ellen Spertus) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * A mapping of block type names to block prototype objects. | ||
| 29 | * @name Blockly.Blocks | ||
| 30 | */ | ||
| 31 | goog.provide('Blockly.Blocks'); | ||
| 32 | |||
| 33 | /* | ||
| 34 | * A mapping of block type names to block prototype objects. | ||
| 35 | * @type {!Object.<string,Object>} | ||
| 36 | */ | ||
| 37 | Blockly.Blocks = new Object(null); |
core/bubble.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/bubble_dragger.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2018 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Methods for dragging a bubble visually. | ||
| 23 | * @author fenichel@google.com (Rachel Fenichel) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.BubbleDragger'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Bubble'); | ||
| 30 | goog.require('Blockly.Events.CommentMove'); | ||
| 31 | goog.require('Blockly.WorkspaceCommentSvg'); | ||
| 32 | |||
| 33 | goog.require('goog.math.Coordinate'); | ||
| 34 | goog.require('goog.asserts'); | ||
| 35 | |||
| 36 | |||
| 37 | /** | ||
| 38 | * Class for a bubble dragger. It moves things on the bubble canvas around the | ||
| 39 | * workspace when they are being dragged by a mouse or touch. These can be | ||
| 40 | * block comments, mutators, warnings, or workspace comments. | ||
| 41 | * @param {!Blockly.Bubble|!Blockly.WorkspaceCommentSvg} bubble The item on the | ||
| 42 | * bubble canvas to drag. | ||
| 43 | * @param {!Blockly.WorkspaceSvg} workspace The workspace to drag on. | ||
| 44 | * @constructor | ||
| 45 | */ | ||
| 46 | Blockly.BubbleDragger = function(bubble, workspace) { | ||
| 47 | /** | ||
| 48 | * The item on the bubble canvas that is being dragged. | ||
| 49 | * @type {!Blockly.Bubble|!Blockly.WorkspaceCommentSvg} | ||
| 50 | * @private | ||
| 51 | */ | ||
| 52 | this.draggingBubble_ = bubble; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * The workspace on which the bubble is being dragged. | ||
| 56 | * @type {!Blockly.WorkspaceSvg} | ||
| 57 | * @private | ||
| 58 | */ | ||
| 59 | this.workspace_ = workspace; | ||
| 60 | |||
| 61 | /** | ||
| 62 | * Which delete area the mouse pointer is over, if any. | ||
| 63 | * One of {@link Blockly.DELETE_AREA_TRASH}, | ||
| 64 | * {@link Blockly.DELETE_AREA_TOOLBOX}, or {@link Blockly.DELETE_AREA_NONE}. | ||
| 65 | * @type {?number} | ||
| 66 | * @private | ||
| 67 | */ | ||
| 68 | this.deleteArea_ = null; | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Whether the bubble would be deleted if dropped immediately. | ||
| 72 | * @type {boolean} | ||
| 73 | * @private | ||
| 74 | */ | ||
| 75 | this.wouldDeleteBubble_ = false; | ||
| 76 | |||
| 77 | /** | ||
| 78 | * The location of the top left corner of the dragging bubble's body at the | ||
| 79 | * beginning of the drag, in workspace coordinates. | ||
| 80 | * @type {!goog.math.Coordinate} | ||
| 81 | * @private | ||
| 82 | */ | ||
| 83 | this.startXY_ = this.draggingBubble_.getRelativeToSurfaceXY(); | ||
| 84 | |||
| 85 | /** | ||
| 86 | * The drag surface to move bubbles to during a drag, or null if none should | ||
| 87 | * be used. Block dragging and bubble dragging use the same surface. | ||
| 88 | * @type {?Blockly.BlockDragSurfaceSvg} | ||
| 89 | * @private | ||
| 90 | */ | ||
| 91 | this.dragSurface_ = | ||
| 92 | Blockly.utils.is3dSupported() && !!workspace.getBlockDragSurface() ? | ||
| 93 | workspace.getBlockDragSurface() : null; | ||
| 94 | }; | ||
| 95 | |||
| 96 | /** | ||
| 97 | * Sever all links from this object. | ||
| 98 | * @package | ||
| 99 | */ | ||
| 100 | Blockly.BubbleDragger.prototype.dispose = function() { | ||
| 101 | this.draggingBubble_ = null; | ||
| 102 | this.workspace_ = null; | ||
| 103 | this.dragSurface_ = null; | ||
| 104 | }; | ||
| 105 | |||
| 106 | /** | ||
| 107 | * Start dragging a bubble. This includes moving it to the drag surface. | ||
| 108 | * @package | ||
| 109 | */ | ||
| 110 | Blockly.BubbleDragger.prototype.startBubbleDrag = function() { | ||
| 111 | if (!Blockly.Events.getGroup()) { | ||
| 112 | Blockly.Events.setGroup(true); | ||
| 113 | } | ||
| 114 | |||
| 115 | this.workspace_.setResizesEnabled(false); | ||
| 116 | this.draggingBubble_.setAutoLayout(false); | ||
| 117 | if (this.dragSurface_) { | ||
| 118 | this.moveToDragSurface_(); | ||
| 119 | } | ||
| 120 | |||
| 121 | this.draggingBubble_.setDragging && this.draggingBubble_.setDragging(true); | ||
| 122 | |||
| 123 | var toolbox = this.workspace_.getToolbox(); | ||
| 124 | if (toolbox) { | ||
| 125 | var style = this.draggingBubble_.isDeletable() ? 'blocklyToolboxDelete' : | ||
| 126 | 'blocklyToolboxGrab'; | ||
| 127 | toolbox.addStyle(style); | ||
| 128 | } | ||
| 129 | }; | ||
| 130 | |||
| 131 | /** | ||
| 132 | * Execute a step of bubble dragging, based on the given event. Update the | ||
| 133 | * display accordingly. | ||
| 134 | * @param {!Event} e The most recent move event. | ||
| 135 | * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has | ||
| 136 | * moved from the position at the start of the drag, in pixel units. | ||
| 137 | * @package | ||
| 138 | */ | ||
| 139 | Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) { | ||
| 140 | var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); | ||
| 141 | var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); | ||
| 142 | |||
| 143 | this.draggingBubble_.moveDuringDrag(this.dragSurface_, newLoc); | ||
| 144 | |||
| 145 | if (this.draggingBubble_.isDeletable()) { | ||
| 146 | this.deleteArea_ = this.workspace_.isDeleteArea(e); | ||
| 147 | this.updateCursorDuringBubbleDrag_(); | ||
| 148 | } | ||
| 149 | }; | ||
| 150 | |||
| 151 | /** | ||
| 152 | * Shut the trash can and, if necessary, delete the dragging bubble. | ||
| 153 | * Should be called at the end of a bubble drag. | ||
| 154 | * @return {boolean} whether the bubble was deleted. | ||
| 155 | * @private | ||
| 156 | */ | ||
| 157 | Blockly.BubbleDragger.prototype.maybeDeleteBubble_ = function() { | ||
| 158 | var trashcan = this.workspace_.trashcan; | ||
| 159 | |||
| 160 | if (this.wouldDeleteBubble_) { | ||
| 161 | if (trashcan) { | ||
| 162 | setTimeout(trashcan.close.bind(trashcan), 100); | ||
| 163 | } | ||
| 164 | // Fire a move event, so we know where to go back to for an undo. | ||
| 165 | this.fireMoveEvent_(); | ||
| 166 | this.draggingBubble_.dispose(false, true); | ||
| 167 | } else if (trashcan) { | ||
| 168 | // Make sure the trash can is closed. | ||
| 169 | trashcan.close(); | ||
| 170 | } | ||
| 171 | return this.wouldDeleteBubble_; | ||
| 172 | }; | ||
| 173 | |||
| 174 | /** | ||
| 175 | * Update the cursor (and possibly the trash can lid) to reflect whether the | ||
| 176 | * dragging bubble would be deleted if released immediately. | ||
| 177 | * @private | ||
| 178 | */ | ||
| 179 | Blockly.BubbleDragger.prototype.updateCursorDuringBubbleDrag_ = function() { | ||
| 180 | this.wouldDeleteBubble_ = this.deleteArea_ != Blockly.DELETE_AREA_NONE; | ||
| 181 | var trashcan = this.workspace_.trashcan; | ||
| 182 | if (this.wouldDeleteBubble_) { | ||
| 183 | this.draggingBubble_.setDeleteStyle(true); | ||
| 184 | if (this.deleteArea_ == Blockly.DELETE_AREA_TRASH && trashcan) { | ||
| 185 | trashcan.setOpen_(true); | ||
| 186 | } | ||
| 187 | } else { | ||
| 188 | this.draggingBubble_.setDeleteStyle(false); | ||
| 189 | if (trashcan) { | ||
| 190 | trashcan.setOpen_(false); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | }; | ||
| 194 | |||
| 195 | /** | ||
| 196 | * Finish a bubble drag and put the bubble back on the workspace. | ||
| 197 | * @param {!Event} e The mouseup/touchend event. | ||
| 198 | * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has | ||
| 199 | * moved from the position at the start of the drag, in pixel units. | ||
| 200 | * @package | ||
| 201 | */ | ||
| 202 | Blockly.BubbleDragger.prototype.endBubbleDrag = function( | ||
| 203 | e, currentDragDeltaXY) { | ||
| 204 | // Make sure internal state is fresh. | ||
| 205 | this.dragBubble(e, currentDragDeltaXY); | ||
| 206 | |||
| 207 | var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); | ||
| 208 | var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); | ||
| 209 | |||
| 210 | // Move the bubble to its final location. | ||
| 211 | this.draggingBubble_.moveTo(newLoc.x, newLoc.y); | ||
| 212 | var deleted = this.maybeDeleteBubble_(); | ||
| 213 | |||
| 214 | if (!deleted) { | ||
| 215 | // Put everything back onto the bubble canvas. | ||
| 216 | if (this.dragSurface_) { | ||
| 217 | this.dragSurface_.clearAndHide(this.workspace_.getBubbleCanvas()); | ||
| 218 | } | ||
| 219 | |||
| 220 | this.draggingBubble_.setDragging && this.draggingBubble_.setDragging(false); | ||
| 221 | this.fireMoveEvent_(); | ||
| 222 | } | ||
| 223 | this.workspace_.setResizesEnabled(true); | ||
| 224 | |||
| 225 | if (this.workspace_.toolbox_) { | ||
| 226 | var style = this.draggingBubble_.isDeletable() ? 'blocklyToolboxDelete' : | ||
| 227 | 'blocklyToolboxGrab'; | ||
| 228 | this.workspace_.toolbox_.removeStyle(style); | ||
| 229 | } | ||
| 230 | Blockly.Events.setGroup(false); | ||
| 231 | }; | ||
| 232 | |||
| 233 | /** | ||
| 234 | * Fire a move event at the end of a bubble drag. | ||
| 235 | * @private | ||
| 236 | */ | ||
| 237 | Blockly.BubbleDragger.prototype.fireMoveEvent_ = function() { | ||
| 238 | var event = null; | ||
| 239 | if (this.draggingBubble_.isComment) { | ||
| 240 | event = new Blockly.Events.CommentMove(this.draggingBubble_); | ||
| 241 | } else if (this.draggingBubble_ instanceof Blockly.ScratchBubble) { | ||
| 242 | event = new Blockly.Events.CommentMove(this.draggingBubble_.comment); | ||
| 243 | } else { | ||
| 244 | return; | ||
| 245 | } | ||
| 246 | event.setOldCoordinate(this.startXY_); | ||
| 247 | event.recordNew(); | ||
| 248 | Blockly.Events.fire(event); | ||
| 249 | }; | ||
| 250 | |||
| 251 | /** | ||
| 252 | * Convert a coordinate object from pixels to workspace units, including a | ||
| 253 | * correction for mutator workspaces. | ||
| 254 | * This function does not consider differing origins. It simply scales the | ||
| 255 | * input's x and y values. | ||
| 256 | * @param {!goog.math.Coordinate} pixelCoord A coordinate with x and y values | ||
| 257 | * in css pixel units. | ||
| 258 | * @return {!goog.math.Coordinate} The input coordinate divided by the workspace | ||
| 259 | * scale. | ||
| 260 | * @private | ||
| 261 | */ | ||
| 262 | Blockly.BubbleDragger.prototype.pixelsToWorkspaceUnits_ = function(pixelCoord) { | ||
| 263 | var result = new goog.math.Coordinate(pixelCoord.x / this.workspace_.scale, | ||
| 264 | pixelCoord.y / this.workspace_.scale); | ||
| 265 | if (this.workspace_.isMutator) { | ||
| 266 | // If we're in a mutator, its scale is always 1, purely because of some | ||
| 267 | // oddities in our rendering optimizations. The actual scale is the same as | ||
| 268 | // the scale on the parent workspace. | ||
| 269 | // Fix that for dragging. | ||
| 270 | var mainScale = this.workspace_.options.parentWorkspace.scale; | ||
| 271 | result = result.scale(1 / mainScale); | ||
| 272 | } | ||
| 273 | return result; | ||
| 274 | }; | ||
| 275 | /** | ||
| 276 | * Move the bubble onto the drag surface at the beginning of a drag. Move the | ||
| 277 | * drag surface to preserve the apparent location of the bubble. | ||
| 278 | * @private | ||
| 279 | */ | ||
| 280 | Blockly.BubbleDragger.prototype.moveToDragSurface_ = function() { | ||
| 281 | this.draggingBubble_.moveTo(0, 0); | ||
| 282 | this.dragSurface_.translateSurface(this.startXY_.x, this.startXY_.y); | ||
| 283 | // Execute the move on the top-level SVG component. | ||
| 284 | this.dragSurface_.setBlocksAndShow(this.draggingBubble_.getSvgRoot()); | ||
| 285 | }; |
core/colours.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Massachusetts Institute of Technology | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | 'use strict'; | ||
| 22 | |||
| 23 | goog.provide('Blockly.Colours'); | ||
| 24 | |||
| 25 | Blockly.Colours = { | ||
| 26 | // SVG colours: these must be specificed in #RRGGBB style | ||
| 27 | // To add an opacity, this must be specified as a separate property (for SVG fill-opacity) | ||
| 28 | "motion": { | ||
| 29 | "primary": "#4C97FF", | ||
| 30 | "secondary": "#4280D7", | ||
| 31 | "tertiary": "#3373CC" | ||
| 32 | }, | ||
| 33 | "looks": { | ||
| 34 | "primary": "#9966FF", | ||
| 35 | "secondary": "#855CD6", | ||
| 36 | "tertiary": "#774DCB" | ||
| 37 | }, | ||
| 38 | "sounds": { | ||
| 39 | "primary": "#CF63CF", | ||
| 40 | "secondary": "#C94FC9", | ||
| 41 | "tertiary": "#BD42BD" | ||
| 42 | }, | ||
| 43 | "control": { | ||
| 44 | "primary": "#FFAB19", | ||
| 45 | "secondary": "#EC9C13", | ||
| 46 | "tertiary": "#CF8B17" | ||
| 47 | }, | ||
| 48 | "event": { | ||
| 49 | "primary": "#FFBF00", | ||
| 50 | "secondary": "#E6AC00", | ||
| 51 | "tertiary": "#CC9900" | ||
| 52 | }, | ||
| 53 | "sensing": { | ||
| 54 | "primary": "#5CB1D6", | ||
| 55 | "secondary": "#47A8D1", | ||
| 56 | "tertiary": "#2E8EB8" | ||
| 57 | }, | ||
| 58 | "pen": { | ||
| 59 | "primary": "#0fBD8C", | ||
| 60 | "secondary": "#0DA57A", | ||
| 61 | "tertiary": "#0B8E69" | ||
| 62 | }, | ||
| 63 | "operators": { | ||
| 64 | "primary": "#59C059", | ||
| 65 | "secondary": "#46B946", | ||
| 66 | "tertiary": "#389438" | ||
| 67 | }, | ||
| 68 | "data": { | ||
| 69 | "primary": "#FF8C1A", | ||
| 70 | "secondary": "#FF8000", | ||
| 71 | "tertiary": "#DB6E00" | ||
| 72 | }, | ||
| 73 | // This is not a new category, but rather for differentiation | ||
| 74 | // between lists and scalar variables. | ||
| 75 | "data_lists": { | ||
| 76 | "primary": "#FF661A", | ||
| 77 | "secondary": "#FF5500", | ||
| 78 | "tertiary": "#E64D00" | ||
| 79 | }, | ||
| 80 | "more": { | ||
| 81 | "primary": "#FF6680", | ||
| 82 | "secondary": "#FF4D6A", | ||
| 83 | "tertiary": "#FF3355" | ||
| 84 | }, | ||
| 85 | "text": "#575E75", | ||
| 86 | "workspace": "#F9F9F9", | ||
| 87 | "toolboxHover": "#4C97FF", | ||
| 88 | "toolboxSelected": "#e9eef2", | ||
| 89 | "toolboxText": "#575E75", | ||
| 90 | "toolbox": "#FFFFFF", | ||
| 91 | "flyout": "#F9F9F9", | ||
| 92 | "scrollbar": "#CECDCE", | ||
| 93 | "scrollbarHover": '#CECDCE', | ||
| 94 | "textField": "#FFFFFF", | ||
| 95 | "insertionMarker": "#000000", | ||
| 96 | "insertionMarkerOpacity": 0.2, | ||
| 97 | "dragShadowOpacity": 0.3, | ||
| 98 | "stackGlow": "#FFF200", | ||
| 99 | "stackGlowSize": 4, | ||
| 100 | "stackGlowOpacity": 1, | ||
| 101 | "replacementGlow": "#FFFFFF", | ||
| 102 | "replacementGlowSize": 2, | ||
| 103 | "replacementGlowOpacity": 1, | ||
| 104 | "colourPickerStroke": "#FFFFFF", | ||
| 105 | // CSS colours: support RGBA | ||
| 106 | "fieldShadow": "rgba(0,0,0,0.1)", | ||
| 107 | "dropDownShadow": "rgba(0, 0, 0, .3)", | ||
| 108 | "numPadBackground": "#547AB2", | ||
| 109 | "numPadBorder": "#435F91", | ||
| 110 | "numPadActiveBackground": "#435F91", | ||
| 111 | "numPadText": "white", // Do not use hex here, it cannot be inlined with data-uri SVG | ||
| 112 | "valueReportBackground": "#FFFFFF", | ||
| 113 | "valueReportBorder": "#AAAAAA" | ||
| 114 | }; | ||
| 115 | |||
| 116 | /** | ||
| 117 | * Override the colours in Blockly.Colours with new values basded on the | ||
| 118 | * given dictionary. | ||
| 119 | * @param {!Object} colours Dictionary of colour properties and new values. | ||
| 120 | * @package | ||
| 121 | */ | ||
| 122 | Blockly.Colours.overrideColours = function(colours) { | ||
| 123 | // Colour overrides provided by the injection | ||
| 124 | if (colours) { | ||
| 125 | for (var colourProperty in colours) { | ||
| 126 | if (colours.hasOwnProperty(colourProperty) && | ||
| 127 | Blockly.Colours.hasOwnProperty(colourProperty)) { | ||
| 128 | // If a property is in both colours option and Blockly.Colours, | ||
| 129 | // set the Blockly.Colours value to the override. | ||
| 130 | // Override Blockly category color object properties with those | ||
| 131 | // provided. | ||
| 132 | var colourPropertyValue = colours[colourProperty]; | ||
| 133 | if (goog.isObject(colourPropertyValue)) { | ||
| 134 | for (var colourSequence in colourPropertyValue) { | ||
| 135 | if (colourPropertyValue.hasOwnProperty(colourSequence) && | ||
| 136 | Blockly.Colours[colourProperty].hasOwnProperty(colourSequence)) { | ||
| 137 | Blockly.Colours[colourProperty][colourSequence] = | ||
| 138 | colourPropertyValue[colourSequence]; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | } else { | ||
| 142 | Blockly.Colours[colourProperty] = colourPropertyValue; | ||
| 143 | } | ||
| 144 | } | ||
| 145 | } | ||
| 146 | } | ||
| 147 | }; |
core/comment.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2011 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Object representing a code comment. | ||
| 23 | * @author fraser@google.com (Neil Fraser) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.Comment'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Bubble'); | ||
| 30 | goog.require('Blockly.Events.BlockChange'); | ||
| 31 | goog.require('Blockly.Events.Ui'); | ||
| 32 | goog.require('Blockly.Icon'); | ||
| 33 | goog.require('goog.userAgent'); | ||
| 34 | |||
| 35 | |||
| 36 | /** | ||
| 37 | * Class for a comment. | ||
| 38 | * @param {!Blockly.Block} block The block associated with this comment. | ||
| 39 | * @extends {Blockly.Icon} | ||
| 40 | * @constructor | ||
| 41 | */ | ||
| 42 | Blockly.Comment = function(block) { | ||
| 43 | Blockly.Comment.superClass_.constructor.call(this, block); | ||
| 44 | this.createIcon(); | ||
| 45 | }; | ||
| 46 | goog.inherits(Blockly.Comment, Blockly.Icon); | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Comment text (if bubble is not visible). | ||
| 50 | * @private | ||
| 51 | */ | ||
| 52 | Blockly.Comment.prototype.text_ = ''; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Width of bubble. | ||
| 56 | * @private | ||
| 57 | */ | ||
| 58 | Blockly.Comment.prototype.width_ = 160; | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Height of bubble. | ||
| 62 | * @private | ||
| 63 | */ | ||
| 64 | Blockly.Comment.prototype.height_ = 80; | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Draw the comment icon. | ||
| 68 | * @param {!Element} group The icon group. | ||
| 69 | * @private | ||
| 70 | */ | ||
| 71 | Blockly.Comment.prototype.drawIcon_ = function(group) { | ||
| 72 | // Circle. | ||
| 73 | Blockly.utils.createSvgElement('circle', | ||
| 74 | {'class': 'blocklyIconShape', 'r': '8', 'cx': '8', 'cy': '8'}, | ||
| 75 | group); | ||
| 76 | // Can't use a real '?' text character since different browsers and operating | ||
| 77 | // systems render it differently. | ||
| 78 | // Body of question mark. | ||
| 79 | Blockly.utils.createSvgElement('path', | ||
| 80 | { | ||
| 81 | 'class': 'blocklyIconSymbol', | ||
| 82 | 'd': 'm6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.405' + | ||
| 83 | '0.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25' + | ||
| 84 | '-1.201,0.998 -1.201,1.528 -1.204,2.19z' | ||
| 85 | }, | ||
| 86 | group); | ||
| 87 | // Dot of question mark. | ||
| 88 | Blockly.utils.createSvgElement('rect', | ||
| 89 | { | ||
| 90 | 'class': 'blocklyIconSymbol', | ||
| 91 | 'x': '6.8', | ||
| 92 | 'y': '10.78', | ||
| 93 | 'height': '2', | ||
| 94 | 'width': '2' | ||
| 95 | }, | ||
| 96 | group); | ||
| 97 | }; | ||
| 98 | |||
| 99 | /** | ||
| 100 | * Create the editor for the comment's bubble. | ||
| 101 | * @return {!Element} The top-level node of the editor. | ||
| 102 | * @private | ||
| 103 | */ | ||
| 104 | Blockly.Comment.prototype.createEditor_ = function() { | ||
| 105 | /* Create the editor. Here's the markup that will be generated: | ||
| 106 | <foreignObject x="8" y="8" width="164" height="164"> | ||
| 107 | <body xmlns="http://www.w3.org/1999/xhtml" class="blocklyMinimalBody"> | ||
| 108 | <textarea xmlns="http://www.w3.org/1999/xhtml" | ||
| 109 | class="blocklyCommentTextarea" | ||
| 110 | style="height: 164px; width: 164px;"></textarea> | ||
| 111 | </body> | ||
| 112 | </foreignObject> | ||
| 113 | */ | ||
| 114 | this.foreignObject_ = Blockly.utils.createSvgElement('foreignObject', | ||
| 115 | {'x': Blockly.Bubble.BORDER_WIDTH, 'y': Blockly.Bubble.BORDER_WIDTH}, | ||
| 116 | null); | ||
| 117 | var body = document.createElementNS(Blockly.HTML_NS, 'body'); | ||
| 118 | body.setAttribute('xmlns', Blockly.HTML_NS); | ||
| 119 | body.className = 'blocklyMinimalBody'; | ||
| 120 | var textarea = document.createElementNS(Blockly.HTML_NS, 'textarea'); | ||
| 121 | textarea.className = 'blocklyCommentTextarea'; | ||
| 122 | textarea.setAttribute('dir', this.block_.RTL ? 'RTL' : 'LTR'); | ||
| 123 | body.appendChild(textarea); | ||
| 124 | this.textarea_ = textarea; | ||
| 125 | this.foreignObject_.appendChild(body); | ||
| 126 | Blockly.bindEventWithChecks_(textarea, 'mouseup', this, this.textareaFocus_); | ||
| 127 | // Don't zoom with mousewheel. | ||
| 128 | Blockly.bindEventWithChecks_(textarea, 'wheel', this, function(e) { | ||
| 129 | e.stopPropagation(); | ||
| 130 | }); | ||
| 131 | Blockly.bindEventWithChecks_(textarea, 'change', this, function(_e) { | ||
| 132 | if (this.text_ != textarea.value) { | ||
| 133 | Blockly.Events.fire(new Blockly.Events.BlockChange( | ||
| 134 | this.block_, 'comment', null, this.text_, textarea.value)); | ||
| 135 | this.text_ = textarea.value; | ||
| 136 | } | ||
| 137 | }); | ||
| 138 | setTimeout(function() { | ||
| 139 | textarea.focus(); | ||
| 140 | }, 0); | ||
| 141 | return this.foreignObject_; | ||
| 142 | }; | ||
| 143 | |||
| 144 | /** | ||
| 145 | * Add or remove editability of the comment. | ||
| 146 | * @override | ||
| 147 | */ | ||
| 148 | Blockly.Comment.prototype.updateEditable = function() { | ||
| 149 | if (this.isVisible()) { | ||
| 150 | // Toggling visibility will force a rerendering. | ||
| 151 | this.setVisible(false); | ||
| 152 | this.setVisible(true); | ||
| 153 | } | ||
| 154 | // Allow the icon to update. | ||
| 155 | Blockly.Icon.prototype.updateEditable.call(this); | ||
| 156 | }; | ||
| 157 | |||
| 158 | /** | ||
| 159 | * Callback function triggered when the bubble has resized. | ||
| 160 | * Resize the text area accordingly. | ||
| 161 | * @private | ||
| 162 | */ | ||
| 163 | Blockly.Comment.prototype.resizeBubble_ = function() { | ||
| 164 | if (this.isVisible()) { | ||
| 165 | var size = this.bubble_.getBubbleSize(); | ||
| 166 | var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH; | ||
| 167 | this.foreignObject_.setAttribute('width', size.width - doubleBorderWidth); | ||
| 168 | this.foreignObject_.setAttribute('height', size.height - doubleBorderWidth); | ||
| 169 | this.textarea_.style.width = (size.width - doubleBorderWidth - 4) + 'px'; | ||
| 170 | this.textarea_.style.height = (size.height - doubleBorderWidth - 4) + 'px'; | ||
| 171 | } | ||
| 172 | }; | ||
| 173 | |||
| 174 | /** | ||
| 175 | * Show or hide the comment bubble. | ||
| 176 | * @param {boolean} visible True if the bubble should be visible. | ||
| 177 | */ | ||
| 178 | Blockly.Comment.prototype.setVisible = function(visible) { | ||
| 179 | if (visible == this.isVisible()) { | ||
| 180 | // No change. | ||
| 181 | return; | ||
| 182 | } | ||
| 183 | Blockly.Events.fire( | ||
| 184 | new Blockly.Events.Ui(this.block_, 'commentOpen', !visible, visible)); | ||
| 185 | if ((!this.block_.isEditable() && !this.textarea_) || goog.userAgent.IE) { | ||
| 186 | // Steal the code from warnings to make an uneditable text bubble. | ||
| 187 | // MSIE does not support foreignobject; textareas are impossible. | ||
| 188 | // http://msdn.microsoft.com/en-us/library/hh834675%28v=vs.85%29.aspx | ||
| 189 | // Always treat comments in IE as uneditable. | ||
| 190 | Blockly.Warning.prototype.setVisible.call(this, visible); | ||
| 191 | return; | ||
| 192 | } | ||
| 193 | // Save the bubble stats before the visibility switch. | ||
| 194 | var text = this.getText(); | ||
| 195 | var size = this.getBubbleSize(); | ||
| 196 | if (visible) { | ||
| 197 | // Create the bubble. | ||
| 198 | this.bubble_ = new Blockly.Bubble( | ||
| 199 | /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), | ||
| 200 | this.createEditor_(), this.block_.svgPath_, | ||
| 201 | this.iconXY_, this.width_, this.height_); | ||
| 202 | // Expose this comment's block's ID on its top-level SVG group. | ||
| 203 | this.bubble_.setSvgId(this.block_.id); | ||
| 204 | this.bubble_.registerResizeEvent(this.resizeBubble_.bind(this)); | ||
| 205 | this.updateColour(); | ||
| 206 | } else { | ||
| 207 | // Dispose of the bubble. | ||
| 208 | this.bubble_.dispose(); | ||
| 209 | this.bubble_ = null; | ||
| 210 | this.textarea_ = null; | ||
| 211 | this.foreignObject_ = null; | ||
| 212 | } | ||
| 213 | // Restore the bubble stats after the visibility switch. | ||
| 214 | this.setText(text); | ||
| 215 | this.setBubbleSize(size.width, size.height); | ||
| 216 | }; | ||
| 217 | |||
| 218 | /** | ||
| 219 | * Bring the comment to the top of the stack when clicked on. | ||
| 220 | * @param {!Event} _e Mouse up event. | ||
| 221 | * @private | ||
| 222 | */ | ||
| 223 | Blockly.Comment.prototype.textareaFocus_ = function(_e) { | ||
| 224 | // Ideally this would be hooked to the focus event for the comment. | ||
| 225 | // This is tied to mousedown, however doing so in Firefox swallows the cursor | ||
| 226 | // for unknown reasons. | ||
| 227 | // See https://github.com/LLK/scratch-blocks/issues/1631 for more history. | ||
| 228 | if (this.bubble_.promote_()) { | ||
| 229 | // Since the act of moving this node within the DOM causes a loss of focus, | ||
| 230 | // we need to reapply the focus. | ||
| 231 | this.textarea_.focus(); | ||
| 232 | } | ||
| 233 | }; | ||
| 234 | |||
| 235 | /** | ||
| 236 | * Get the dimensions of this comment's bubble. | ||
| 237 | * @return {!Object} Object with width and height properties. | ||
| 238 | */ | ||
| 239 | Blockly.Comment.prototype.getBubbleSize = function() { | ||
| 240 | if (this.isVisible()) { | ||
| 241 | return this.bubble_.getBubbleSize(); | ||
| 242 | } else { | ||
| 243 | return {width: this.width_, height: this.height_}; | ||
| 244 | } | ||
| 245 | }; | ||
| 246 | |||
| 247 | /** | ||
| 248 | * Size this comment's bubble. | ||
| 249 | * @param {number} width Width of the bubble. | ||
| 250 | * @param {number} height Height of the bubble. | ||
| 251 | */ | ||
| 252 | Blockly.Comment.prototype.setBubbleSize = function(width, height) { | ||
| 253 | if (this.textarea_) { | ||
| 254 | this.bubble_.setBubbleSize(width, height); | ||
| 255 | } else { | ||
| 256 | this.width_ = width; | ||
| 257 | this.height_ = height; | ||
| 258 | } | ||
| 259 | }; | ||
| 260 | |||
| 261 | /** | ||
| 262 | * Returns this comment's text. | ||
| 263 | * @return {string} Comment text. | ||
| 264 | */ | ||
| 265 | Blockly.Comment.prototype.getText = function() { | ||
| 266 | return this.textarea_ ? this.textarea_.value : this.text_; | ||
| 267 | }; | ||
| 268 | |||
| 269 | /** | ||
| 270 | * Set this comment's text. | ||
| 271 | * @param {string} text Comment text. | ||
| 272 | */ | ||
| 273 | Blockly.Comment.prototype.setText = function(text) { | ||
| 274 | if (this.text_ != text) { | ||
| 275 | Blockly.Events.fire(new Blockly.Events.BlockChange( | ||
| 276 | this.block_, 'comment', null, this.text_, text)); | ||
| 277 | this.text_ = text; | ||
| 278 | } | ||
| 279 | if (this.textarea_) { | ||
| 280 | this.textarea_.value = text; | ||
| 281 | } | ||
| 282 | }; | ||
| 283 | |||
| 284 | /** | ||
| 285 | * Dispose of this comment. | ||
| 286 | */ | ||
| 287 | Blockly.Comment.prototype.dispose = function() { | ||
| 288 | if (Blockly.Events.isEnabled()) { | ||
| 289 | this.setText(''); // Fire event to delete comment. | ||
| 290 | } | ||
| 291 | this.block_.comment = null; | ||
| 292 | Blockly.Icon.prototype.dispose.call(this); | ||
| 293 | }; |
core/comment_events.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/connection.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/connection_db.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2011 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Components for managing connections between blocks. | ||
| 23 | * @author fraser@google.com (Neil Fraser) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.ConnectionDB'); | ||
| 28 | |||
| 29 | goog.require('Blockly.Connection'); | ||
| 30 | |||
| 31 | |||
| 32 | /** | ||
| 33 | * Database of connections. | ||
| 34 | * Connections are stored in order of their vertical component. This way | ||
| 35 | * connections in an area may be looked up quickly using a binary search. | ||
| 36 | * @constructor | ||
| 37 | */ | ||
| 38 | Blockly.ConnectionDB = function() { | ||
| 39 | /** | ||
| 40 | * Array of connections sorted by y coordinate. | ||
| 41 | * @type {!Array.<!Blockly.Connection>} | ||
| 42 | * @private | ||
| 43 | */ | ||
| 44 | this.connections_ = []; | ||
| 45 | }; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Add a connection to the database. Must not already exist in DB. | ||
| 49 | * @param {!Blockly.Connection} connection The connection to be added. | ||
| 50 | */ | ||
| 51 | Blockly.ConnectionDB.prototype.addConnection = function(connection) { | ||
| 52 | if (connection.inDB_) { | ||
| 53 | throw Error('Connection already in database.'); | ||
| 54 | } | ||
| 55 | if (connection.getSourceBlock().isInFlyout) { | ||
| 56 | // Don't bother maintaining a database of connections in a flyout. | ||
| 57 | return; | ||
| 58 | } | ||
| 59 | var position = this.findPositionForConnection_(connection); | ||
| 60 | this.connections_.splice(position, 0, connection); | ||
| 61 | connection.inDB_ = true; | ||
| 62 | }; | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Find the given connection. | ||
| 66 | * Starts by doing a binary search to find the approximate location, then | ||
| 67 | * linearly searches nearby for the exact connection. | ||
| 68 | * @param {!Blockly.Connection} conn The connection to find. | ||
| 69 | * @return {number} The index of the connection, or -1 if the connection was | ||
| 70 | * not found. | ||
| 71 | */ | ||
| 72 | Blockly.ConnectionDB.prototype.findConnection = function(conn) { | ||
| 73 | if (!this.connections_.length) { | ||
| 74 | return -1; | ||
| 75 | } | ||
| 76 | |||
| 77 | var bestGuess = this.findPositionForConnection_(conn); | ||
| 78 | if (bestGuess >= this.connections_.length) { | ||
| 79 | // Not in list | ||
| 80 | return -1; | ||
| 81 | } | ||
| 82 | |||
| 83 | var yPos = conn.y_; | ||
| 84 | // Walk forward and back on the y axis looking for the connection. | ||
| 85 | var pointerMin = bestGuess; | ||
| 86 | var pointerMax = bestGuess; | ||
| 87 | while (pointerMin >= 0 && this.connections_[pointerMin].y_ == yPos) { | ||
| 88 | if (this.connections_[pointerMin] == conn) { | ||
| 89 | return pointerMin; | ||
| 90 | } | ||
| 91 | pointerMin--; | ||
| 92 | } | ||
| 93 | |||
| 94 | while (pointerMax < this.connections_.length && | ||
| 95 | this.connections_[pointerMax].y_ == yPos) { | ||
| 96 | if (this.connections_[pointerMax] == conn) { | ||
| 97 | return pointerMax; | ||
| 98 | } | ||
| 99 | pointerMax++; | ||
| 100 | } | ||
| 101 | return -1; | ||
| 102 | }; | ||
| 103 | |||
| 104 | /** | ||
| 105 | * Finds a candidate position for inserting this connection into the list. | ||
| 106 | * This will be in the correct y order but makes no guarantees about ordering in | ||
| 107 | * the x axis. | ||
| 108 | * @param {!Blockly.Connection} connection The connection to insert. | ||
| 109 | * @return {number} The candidate index. | ||
| 110 | * @private | ||
| 111 | */ | ||
| 112 | Blockly.ConnectionDB.prototype.findPositionForConnection_ = function( | ||
| 113 | connection) { | ||
| 114 | if (!this.connections_.length) { | ||
| 115 | return 0; | ||
| 116 | } | ||
| 117 | var pointerMin = 0; | ||
| 118 | var pointerMax = this.connections_.length; | ||
| 119 | while (pointerMin < pointerMax) { | ||
| 120 | var pointerMid = Math.floor((pointerMin + pointerMax) / 2); | ||
| 121 | if (this.connections_[pointerMid].y_ < connection.y_) { | ||
| 122 | pointerMin = pointerMid + 1; | ||
| 123 | } else if (this.connections_[pointerMid].y_ > connection.y_) { | ||
| 124 | pointerMax = pointerMid; | ||
| 125 | } else { | ||
| 126 | pointerMin = pointerMid; | ||
| 127 | break; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | return pointerMin; | ||
| 131 | }; | ||
| 132 | |||
| 133 | /** | ||
| 134 | * Remove a connection from the database. Must already exist in DB. | ||
| 135 | * @param {!Blockly.Connection} connection The connection to be removed. | ||
| 136 | * @private | ||
| 137 | */ | ||
| 138 | Blockly.ConnectionDB.prototype.removeConnection_ = function(connection) { | ||
| 139 | if (!connection.inDB_) { | ||
| 140 | throw Error('Connection not in database.'); | ||
| 141 | } | ||
| 142 | var removalIndex = this.findConnection(connection); | ||
| 143 | if (removalIndex == -1) { | ||
| 144 | throw Error('Unable to find connection in connectionDB.'); | ||
| 145 | } | ||
| 146 | connection.inDB_ = false; | ||
| 147 | this.connections_.splice(removalIndex, 1); | ||
| 148 | }; | ||
| 149 | |||
| 150 | /** | ||
| 151 | * Find all nearby connections to the given connection. | ||
| 152 | * Type checking does not apply, since this function is used for bumping. | ||
| 153 | * @param {!Blockly.Connection} connection The connection whose neighbours | ||
| 154 | * should be returned. | ||
| 155 | * @param {number} maxRadius The maximum radius to another connection. | ||
| 156 | * @return {!Array.<Blockly.Connection>} List of connections. | ||
| 157 | */ | ||
| 158 | Blockly.ConnectionDB.prototype.getNeighbours = function(connection, maxRadius) { | ||
| 159 | var db = this.connections_; | ||
| 160 | var currentX = connection.x_; | ||
| 161 | var currentY = connection.y_; | ||
| 162 | |||
| 163 | // Binary search to find the closest y location. | ||
| 164 | var pointerMin = 0; | ||
| 165 | var pointerMax = db.length - 2; | ||
| 166 | var pointerMid = pointerMax; | ||
| 167 | while (pointerMin < pointerMid) { | ||
| 168 | if (db[pointerMid].y_ < currentY) { | ||
| 169 | pointerMin = pointerMid; | ||
| 170 | } else { | ||
| 171 | pointerMax = pointerMid; | ||
| 172 | } | ||
| 173 | pointerMid = Math.floor((pointerMin + pointerMax) / 2); | ||
| 174 | } | ||
| 175 | |||
| 176 | var neighbours = []; | ||
| 177 | /** | ||
| 178 | * Computes if the current connection is within the allowed radius of another | ||
| 179 | * connection. | ||
| 180 | * This function is a closure and has access to outside variables. | ||
| 181 | * @param {number} yIndex The other connection's index in the database. | ||
| 182 | * @return {boolean} True if the current connection's vertical distance from | ||
| 183 | * the other connection is less than the allowed radius. | ||
| 184 | */ | ||
| 185 | function checkConnection_(yIndex) { | ||
| 186 | var dx = currentX - db[yIndex].x_; | ||
| 187 | var dy = currentY - db[yIndex].y_; | ||
| 188 | var r = Math.sqrt(dx * dx + dy * dy); | ||
| 189 | if (r <= maxRadius) { | ||
| 190 | neighbours.push(db[yIndex]); | ||
| 191 | } | ||
| 192 | return dy < maxRadius; | ||
| 193 | } | ||
| 194 | |||
| 195 | // Walk forward and back on the y axis looking for the closest x,y point. | ||
| 196 | pointerMin = pointerMid; | ||
| 197 | pointerMax = pointerMid; | ||
| 198 | if (db.length) { | ||
| 199 | while (pointerMin >= 0 && checkConnection_(pointerMin)) { | ||
| 200 | pointerMin--; | ||
| 201 | } | ||
| 202 | do { | ||
| 203 | pointerMax++; | ||
| 204 | } while (pointerMax < db.length && checkConnection_(pointerMax)); | ||
| 205 | } | ||
| 206 | |||
| 207 | return neighbours; | ||
| 208 | }; | ||
| 209 | |||
| 210 | |||
| 211 | /** | ||
| 212 | * Is the candidate connection close to the reference connection. | ||
| 213 | * Extremely fast; only looks at Y distance. | ||
| 214 | * @param {number} index Index in database of candidate connection. | ||
| 215 | * @param {number} baseY Reference connection's Y value. | ||
| 216 | * @param {number} maxRadius The maximum radius to another connection. | ||
| 217 | * @return {boolean} True if connection is in range. | ||
| 218 | * @private | ||
| 219 | */ | ||
| 220 | Blockly.ConnectionDB.prototype.isInYRange_ = function(index, baseY, maxRadius) { | ||
| 221 | return (Math.abs(this.connections_[index].y_ - baseY) <= maxRadius); | ||
| 222 | }; | ||
| 223 | |||
| 224 | /** | ||
| 225 | * Find the closest compatible connection to this connection. | ||
| 226 | * @param {!Blockly.Connection} conn The connection searching for a compatible | ||
| 227 | * mate. | ||
| 228 | * @param {number} maxRadius The maximum radius to another connection. | ||
| 229 | * @param {!goog.math.Coordinate} dxy Offset between this connection's location | ||
| 230 | * in the database and the current location (as a result of dragging). | ||
| 231 | * @return {!{connection: ?Blockly.Connection, radius: number}} Contains two | ||
| 232 | * properties:' connection' which is either another connection or null, | ||
| 233 | * and 'radius' which is the distance. | ||
| 234 | */ | ||
| 235 | Blockly.ConnectionDB.prototype.searchForClosest = function(conn, maxRadius, | ||
| 236 | dxy) { | ||
| 237 | // Don't bother. | ||
| 238 | if (!this.connections_.length) { | ||
| 239 | return {connection: null, radius: maxRadius}; | ||
| 240 | } | ||
| 241 | |||
| 242 | // Stash the values of x and y from before the drag. | ||
| 243 | var baseY = conn.y_; | ||
| 244 | var baseX = conn.x_; | ||
| 245 | |||
| 246 | conn.x_ = baseX + dxy.x; | ||
| 247 | conn.y_ = baseY + dxy.y; | ||
| 248 | |||
| 249 | // findPositionForConnection finds an index for insertion, which is always | ||
| 250 | // after any block with the same y index. We want to search both forward | ||
| 251 | // and back, so search on both sides of the index. | ||
| 252 | var closestIndex = this.findPositionForConnection_(conn); | ||
| 253 | |||
| 254 | var bestConnection = null; | ||
| 255 | var bestRadius = maxRadius; | ||
| 256 | var temp; | ||
| 257 | |||
| 258 | // Walk forward and back on the y axis looking for the closest x,y point. | ||
| 259 | var pointerMin = closestIndex - 1; | ||
| 260 | while (pointerMin >= 0 && this.isInYRange_(pointerMin, conn.y_, maxRadius)) { | ||
| 261 | temp = this.connections_[pointerMin]; | ||
| 262 | if (conn.isConnectionAllowed(temp, bestRadius)) { | ||
| 263 | bestConnection = temp; | ||
| 264 | bestRadius = temp.distanceFrom(conn); | ||
| 265 | } | ||
| 266 | pointerMin--; | ||
| 267 | } | ||
| 268 | |||
| 269 | var pointerMax = closestIndex; | ||
| 270 | while (pointerMax < this.connections_.length && | ||
| 271 | this.isInYRange_(pointerMax, conn.y_, maxRadius)) { | ||
| 272 | temp = this.connections_[pointerMax]; | ||
| 273 | if (conn.isConnectionAllowed(temp, bestRadius)) { | ||
| 274 | bestConnection = temp; | ||
| 275 | bestRadius = temp.distanceFrom(conn); | ||
| 276 | } | ||
| 277 | pointerMax++; | ||
| 278 | } | ||
| 279 | |||
| 280 | // Reset the values of x and y. | ||
| 281 | conn.x_ = baseX; | ||
| 282 | conn.y_ = baseY; | ||
| 283 | |||
| 284 | // If there were no valid connections, bestConnection will be null. | ||
| 285 | return {connection: bestConnection, radius: bestRadius}; | ||
| 286 | }; | ||
| 287 | |||
| 288 | /** | ||
| 289 | * Initialize a set of connection DBs for a specified workspace. | ||
| 290 | * @param {!Blockly.Workspace} workspace The workspace this DB is for. | ||
| 291 | */ | ||
| 292 | Blockly.ConnectionDB.init = function(workspace) { | ||
| 293 | // Create four databases, one for each connection type. | ||
| 294 | var dbList = []; | ||
| 295 | dbList[Blockly.INPUT_VALUE] = new Blockly.ConnectionDB(); | ||
| 296 | dbList[Blockly.OUTPUT_VALUE] = new Blockly.ConnectionDB(); | ||
| 297 | dbList[Blockly.NEXT_STATEMENT] = new Blockly.ConnectionDB(); | ||
| 298 | dbList[Blockly.PREVIOUS_STATEMENT] = new Blockly.ConnectionDB(); | ||
| 299 | workspace.connectionDBList = dbList; | ||
| 300 | }; |
core/constants.js
0 → 100644
| 1 | /** | ||
| 2 | * @license | ||
| 3 | * Visual Blocks Editor | ||
| 4 | * | ||
| 5 | * Copyright 2016 Google Inc. | ||
| 6 | * https://developers.google.com/blockly/ | ||
| 7 | * | ||
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | * you may not use this file except in compliance with the License. | ||
| 10 | * You may obtain a copy of the License at | ||
| 11 | * | ||
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | * | ||
| 14 | * Unless required by applicable law or agreed to in writing, software | ||
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | * See the License for the specific language governing permissions and | ||
| 18 | * limitations under the License. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @fileoverview Blockly constants. | ||
| 23 | * @author fenichel@google.com (Rachel Fenichel) | ||
| 24 | */ | ||
| 25 | 'use strict'; | ||
| 26 | |||
| 27 | goog.provide('Blockly.constants'); | ||
| 28 | |||
| 29 | |||
| 30 | /** | ||
| 31 | * Number of pixels the mouse must move before a drag starts. | ||
| 32 | */ | ||
| 33 | Blockly.DRAG_RADIUS = 3; | ||
| 34 | |||
| 35 | /** | ||
| 36 | * Number of pixels the mouse must move before a drag/scroll starts from the | ||
| 37 | * flyout. Because the drag-intention is determined when this is reached, it is | ||
| 38 | * larger than Blockly.DRAG_RADIUS so that the drag-direction is clearer. | ||
| 39 | */ | ||
| 40 | Blockly.FLYOUT_DRAG_RADIUS = 10; | ||
| 41 | |||
| 42 | /** | ||
| 43 | * Maximum misalignment between connections for them to snap together. | ||
| 44 | */ | ||
| 45 | Blockly.SNAP_RADIUS = 48; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Maximum misalignment between connections for them to snap together, | ||
| 49 | * when a connection is already highlighted. | ||
| 50 | */ | ||
| 51 | Blockly.CONNECTING_SNAP_RADIUS = 68; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * How much to prefer staying connected to the current connection over moving to | ||
| 55 | * a new connection. The current previewed connection is considered to be this | ||
| 56 | * much closer to the matching connection on the block than it actually is. | ||
| 57 | */ | ||
| 58 | Blockly.CURRENT_CONNECTION_PREFERENCE = 20; | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Delay in ms between trigger and bumping unconnected block out of alignment. | ||
| 62 | */ | ||
| 63 | Blockly.BUMP_DELAY = 0; | ||
| 64 | |||
| 65 | /** | ||
| 66 | * Number of characters to truncate a collapsed block to. | ||
| 67 | */ | ||
| 68 | Blockly.COLLAPSE_CHARS = 30; | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Length in ms for a touch to become a long press. | ||
| 72 | */ | ||
| 73 | Blockly.LONGPRESS = 750; | ||
| 74 | |||
| 75 | /** | ||
| 76 | * Distance to scroll when a mouse wheel event is received and its delta mode | ||
| 77 | * is line (0x1) instead of pixel (0x0). In these cases, a single "scroll" has | ||
| 78 | * a delta of 1, which makes the workspace scroll very slowly (just one pixel). | ||
| 79 | * To compensate, that delta is multiplied by this value. | ||
| 80 | * @const | ||
| 81 | * @package | ||
| 82 | */ | ||
| 83 | Blockly.LINE_SCROLL_MULTIPLIER = 15; | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Prevent a sound from playing if another sound preceded it within this many | ||
| 87 | * milliseconds. | ||
| 88 | */ | ||
| 89 | Blockly.SOUND_LIMIT = 100; | ||
| 90 | |||
| 91 | /** | ||
| 92 | * When dragging a block out of a stack, split the stack in two (true), or drag | ||
| 93 | * out the block healing the stack (false). | ||
| 94 | */ | ||
| 95 | Blockly.DRAG_STACK = true; | ||
| 96 | |||
| 97 | /** | ||
| 98 | * The richness of block colours, regardless of the hue. | ||
| 99 | * Must be in the range of 0 (inclusive) to 1 (exclusive). | ||
| 100 | */ | ||
| 101 | Blockly.HSV_SATURATION = 0.45; | ||
| 102 | |||
| 103 | /** | ||
| 104 | * The intensity of block colours, regardless of the hue. | ||
| 105 | * Must be in the range of 0 (inclusive) to 1 (exclusive). | ||
| 106 | */ | ||
| 107 | Blockly.HSV_VALUE = 0.65; | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Sprited icons and images. | ||
| 111 | */ | ||
| 112 | Blockly.SPRITE = { | ||
| 113 | width: 96, | ||
| 114 | height: 124, | ||
| 115 | url: 'sprites.png' | ||
| 116 | }; | ||
| 117 | |||
| 118 | // Constants below this point are not intended to be changed. | ||
| 119 | |||
| 120 | /** | ||
| 121 | * Required name space for SVG elements. | ||
| 122 | * @const | ||
| 123 | */ | ||
| 124 | Blockly.SVG_NS = 'http://www.w3.org/2000/svg'; | ||
| 125 | |||
| 126 | /** | ||
| 127 | * Required name space for HTML elements. | ||
| 128 | * @const | ||
| 129 | */ | ||
| 130 | Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml'; | ||
| 131 | |||
| 132 | /** | ||
| 133 | * ENUM for a right-facing value input. E.g. 'set item to' or 'return'. | ||
| 134 | * @const | ||
| 135 | */ | ||
| 136 | Blockly.INPUT_VALUE = 1; | ||
| 137 | |||
| 138 | /** | ||
| 139 | * ENUM for a left-facing value output. E.g. 'random fraction'. | ||
| 140 | * @const | ||
| 141 | */ | ||
| 142 | Blockly.OUTPUT_VALUE = 2; | ||
| 143 | |||
| 144 | /** | ||
| 145 | * ENUM for a down-facing block stack. E.g. 'if-do' or 'else'. | ||
| 146 | * @const | ||
| 147 | */ | ||
| 148 | Blockly.NEXT_STATEMENT = 3; | ||
| 149 | |||
| 150 | /** | ||
| 151 | * ENUM for an up-facing block stack. E.g. 'break out of loop'. | ||
| 152 | * @const | ||
| 153 | */ | ||
| 154 | Blockly.PREVIOUS_STATEMENT = 4; | ||
| 155 | |||
| 156 | /** | ||
| 157 | * ENUM for an dummy input. Used to add field(s) with no input. | ||
| 158 | * @const | ||
| 159 | */ | ||
| 160 | Blockly.DUMMY_INPUT = 5; | ||
| 161 | |||
| 162 | /** | ||
| 163 | * ENUM for left alignment. | ||
| 164 | * @const | ||
| 165 | */ | ||
| 166 | Blockly.ALIGN_LEFT = -1; | ||
| 167 | |||
| 168 | /** | ||
| 169 | * ENUM for centre alignment. | ||
| 170 | * @const | ||
| 171 | */ | ||
| 172 | Blockly.ALIGN_CENTRE = 0; | ||
| 173 | |||
| 174 | /** | ||
| 175 | * ENUM for right alignment. | ||
| 176 | * @const | ||
| 177 | */ | ||
| 178 | Blockly.ALIGN_RIGHT = 1; | ||
| 179 | |||
| 180 | /** | ||
| 181 | * ENUM for no drag operation. | ||
| 182 | * @const | ||
| 183 | */ | ||
| 184 | Blockly.DRAG_NONE = 0; | ||
| 185 | |||
| 186 | /** | ||
| 187 | * ENUM for inside the sticky DRAG_RADIUS. | ||
| 188 | * @const | ||
| 189 | */ | ||
| 190 | Blockly.DRAG_STICKY = 1; | ||
| 191 | |||
| 192 | /** | ||
| 193 | * ENUM for inside the non-sticky DRAG_RADIUS, for differentiating between | ||
| 194 | * clicks and drags. | ||
| 195 | * @const | ||
| 196 | */ | ||
| 197 | Blockly.DRAG_BEGIN = 1; | ||
| 198 | |||
| 199 | /** | ||
| 200 | * ENUM for freely draggable (outside the DRAG_RADIUS, if one applies). | ||
| 201 | * @const | ||
| 202 | */ | ||
| 203 | Blockly.DRAG_FREE = 2; | ||
| 204 | |||
| 205 | /** | ||
| 206 | * Lookup table for determining the opposite type of a connection. | ||
| 207 | * @const | ||
| 208 | */ | ||
| 209 | Blockly.OPPOSITE_TYPE = []; | ||
| 210 | Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE] = Blockly.OUTPUT_VALUE; | ||
| 211 | Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE] = Blockly.INPUT_VALUE; | ||
| 212 | Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT] = Blockly.PREVIOUS_STATEMENT; | ||
| 213 | Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT] = Blockly.NEXT_STATEMENT; | ||
| 214 | |||
| 215 | /** | ||
| 216 | * ENUM for toolbox and flyout at top of screen. | ||
| 217 | * @const | ||
| 218 | */ | ||
| 219 | Blockly.TOOLBOX_AT_TOP = 0; | ||
| 220 | |||
| 221 | /** | ||
| 222 | * ENUM for toolbox and flyout at bottom of screen. | ||
| 223 | * @const | ||
| 224 | */ | ||
| 225 | Blockly.TOOLBOX_AT_BOTTOM = 1; | ||
| 226 | |||
| 227 | /** | ||
| 228 | * ENUM for toolbox and flyout at left of screen. | ||
| 229 | * @const | ||
| 230 | */ | ||
| 231 | Blockly.TOOLBOX_AT_LEFT = 2; | ||
| 232 | |||
| 233 | /** | ||
| 234 | * ENUM for toolbox and flyout at right of screen. | ||
| 235 | * @const | ||
| 236 | */ | ||
| 237 | Blockly.TOOLBOX_AT_RIGHT = 3; | ||
| 238 | |||
| 239 | /** | ||
| 240 | * ENUM for output shape: hexagonal (booleans/predicates). | ||
| 241 | * @const | ||
| 242 | */ | ||
| 243 | Blockly.OUTPUT_SHAPE_HEXAGONAL = 1; | ||
| 244 | |||
| 245 | /** | ||
| 246 | * ENUM for output shape: rounded (numbers). | ||
| 247 | * @const | ||
| 248 | */ | ||
| 249 | Blockly.OUTPUT_SHAPE_ROUND = 2; | ||
| 250 | |||
| 251 | /** | ||
| 252 | * ENUM for output shape: squared (any/all values; strings). | ||
| 253 | * @const | ||
| 254 | */ | ||
| 255 | Blockly.OUTPUT_SHAPE_SQUARE = 3; | ||
| 256 | |||
| 257 | /** | ||
| 258 | * ENUM for categories. | ||
| 259 | * @const | ||
| 260 | */ | ||
| 261 | Blockly.Categories = { | ||
| 262 | "motion": "motion", | ||
| 263 | "looks": "looks", | ||
| 264 | "sound": "sounds", | ||
| 265 | "pen": "pen", | ||
| 266 | "data": "data", | ||
| 267 | "dataLists": "data-lists", | ||
| 268 | "event": "events", | ||
| 269 | "control": "control", | ||
| 270 | "sensing": "sensing", | ||
| 271 | "operators": "operators", | ||
| 272 | "more": "more" | ||
| 273 | }; | ||
| 274 | |||
| 275 | /** | ||
| 276 | * ENUM representing that an event is not in any delete areas. | ||
| 277 | * Null for backwards compatibility reasons. | ||
| 278 | * @const | ||
| 279 | */ | ||
| 280 | Blockly.DELETE_AREA_NONE = null; | ||
| 281 | |||
| 282 | /** | ||
| 283 | * ENUM representing that an event is in the delete area of the trash can. | ||
| 284 | * @const | ||
| 285 | */ | ||
| 286 | Blockly.DELETE_AREA_TRASH = 1; | ||
| 287 | |||
| 288 | /** | ||
| 289 | * ENUM representing that an event is in the delete area of the toolbox or | ||
| 290 | * flyout. | ||
| 291 | * @const | ||
| 292 | */ | ||
| 293 | Blockly.DELETE_AREA_TOOLBOX = 2; | ||
| 294 | |||
| 295 | /** | ||
| 296 | * String for use in the "custom" attribute of a category in toolbox xml. | ||
| 297 | * This string indicates that the category should be dynamically populated with | ||
| 298 | * variable blocks. | ||
| 299 | * @const {string} | ||
| 300 | */ | ||
| 301 | Blockly.VARIABLE_CATEGORY_NAME = 'VARIABLE'; | ||
| 302 | |||
| 303 | /** | ||
| 304 | * String for use in the "custom" attribute of a category in toolbox xml. | ||
| 305 | * This string indicates that the category should be dynamically populated with | ||
| 306 | * procedure blocks. | ||
| 307 | * @const {string} | ||
| 308 | */ | ||
| 309 | Blockly.PROCEDURE_CATEGORY_NAME = 'PROCEDURE'; | ||
| 310 | |||
| 311 | /** | ||
| 312 | * String for use in the dropdown created in field_variable. | ||
| 313 | * This string indicates that this option in the dropdown is 'Rename | ||
| 314 | * variable...' and if selected, should trigger the prompt to rename a variable. | ||
| 315 | * @const {string} | ||
| 316 | */ | ||
| 317 | Blockly.RENAME_VARIABLE_ID = 'RENAME_VARIABLE_ID'; | ||
| 318 | |||
| 319 | /** | ||
| 320 | * String for use in the dropdown created in field_variable. | ||
| 321 | * This string indicates that this option in the dropdown is 'Delete the "%1" | ||
| 322 | * variable' and if selected, should trigger the prompt to delete a variable. | ||
| 323 | * @const {string} | ||
| 324 | */ | ||
| 325 | Blockly.DELETE_VARIABLE_ID = 'DELETE_VARIABLE_ID'; | ||
| 326 | |||
| 327 | /** | ||
| 328 | * String for use in the dropdown created in field_variable, | ||
| 329 | * specifically for broadcast messages. | ||
| 330 | * This string indicates that this option in the dropdown is 'New message...' | ||
| 331 | * and if selected, should trigger the prompt to create a new message. | ||
| 332 | * @const {string} | ||
| 333 | */ | ||
| 334 | Blockly.NEW_BROADCAST_MESSAGE_ID = 'NEW_BROADCAST_MESSAGE_ID'; | ||
| 335 | |||
| 336 | /** | ||
| 337 | * String representing the variable type of broadcast message blocks. | ||
| 338 | * This string, for use in differentiating between types of variables, | ||
| 339 | * indicates that the current variable is a broadcast message. | ||
| 340 | * @const {string} | ||
| 341 | */ | ||
| 342 | Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE = 'broadcast_msg'; | ||
| 343 | |||
| 344 | /** | ||
| 345 | * String representing the variable type of list blocks. | ||
| 346 | * This string, for use in differentiating between types of variables, | ||
| 347 | * indicates that the current variable is a list. | ||
| 348 | * @const {string} | ||
| 349 | */ | ||
| 350 | Blockly.LIST_VARIABLE_TYPE = 'list'; | ||
| 351 | |||
| 352 | // TODO (#1251) Replace '' below with 'scalar', and start using this constant | ||
| 353 | // everywhere. | ||
| 354 | /** | ||
| 355 | * String representing the variable type of scalar variables. | ||
| 356 | * This string, for use in differentiating between types of variables, | ||
| 357 | * indicates that the current variable is a scalar variable. | ||
| 358 | * @const {string} | ||
| 359 | */ | ||
| 360 | Blockly.SCALAR_VARIABLE_TYPE = ''; | ||
| 361 | |||
| 362 | /** | ||
| 363 | * The type of all procedure definition blocks. | ||
| 364 | * @const {string} | ||
| 365 | */ | ||
| 366 | Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE = 'procedures_definition'; | ||
| 367 | |||
| 368 | /** | ||
| 369 | * The type of all procedure prototype blocks. | ||
| 370 | * @const {string} | ||
| 371 | */ | ||
| 372 | Blockly.PROCEDURES_PROTOTYPE_BLOCK_TYPE = 'procedures_prototype'; | ||
| 373 | |||
| 374 | /** | ||
| 375 | * The type of all procedure call blocks. | ||
| 376 | * @const {string} | ||
| 377 | */ | ||
| 378 | Blockly.PROCEDURES_CALL_BLOCK_TYPE = 'procedures_call'; | ||
| 379 | |||
| 380 | /** | ||
| 381 | * ENUM for flyout status button states. | ||
| 382 | * @const | ||
| 383 | */ | ||
| 384 | Blockly.StatusButtonState = { | ||
| 385 | "READY": "ready", | ||
| 386 | "NOT_READY": "not ready", | ||
| 387 | }; |
core/contextmenu.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/css.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/data_category.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/device.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/dragged_connection_manager.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/dropdowndiv.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/events.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/events_abstract.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/extensions.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_angle.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_checkbox.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_colour.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_colour_slider.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_date.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_dropdown.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_icon_dropdown.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_iconmenu.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_image.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_label.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_label_serializable.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_matrix.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_note.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_number.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_numberdropdown.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_slider.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_textdropdown.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_textinput.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_textinput_removable.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_variable.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_variable_getter.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/field_vertical_separator.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/flyout_base.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/flyout_button.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/flyout_dragger.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/flyout_extension_category_header.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/flyout_horizontal.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/flyout_vertical.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/generator.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/gesture.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/grid.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/icon.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/inject.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/input.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/insertion_marker_manager.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/msg.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/mutator.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/names.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/options.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/procedures.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/program_mode.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/rendered_connection.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/scratch_block_comment.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/scratch_blocks_utils.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/scratch_bubble.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/scratch_events.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/scratch_msgs.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/scrollbar.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/toolbox.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/tooltip.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/touch.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/trashcan.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/ui_events.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/ui_menu_utils.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/utils.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/variable_events.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/variable_map.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/variable_model.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/variables.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/warning.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/widgetdiv.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_audio.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_comment.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_comment_render_svg.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_comment_svg.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_drag_surface_svg.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_dragger.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/workspace_svg.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/xml.js
0 → 100644
This diff is collapsed.
Click to expand it.
core/zoom_controls.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/arduino.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/colour.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/control.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/data.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/esp32.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/esp8266.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/event.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/k210.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/math.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/matrix.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/operator.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/procedures.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/raspberryPiPico.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/arduino/text.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/colour.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/control.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/data.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/event.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/math.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/matrix.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/microbit.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/operator.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/procedures.js
0 → 100644
This diff is collapsed.
Click to expand it.
generators/python/text.js
0 → 100644
This diff is collapsed.
Click to expand it.
gh-pages/Gemfile
0 → 100644
This diff is collapsed.
Click to expand it.
gh-pages/_config.yml
0 → 100644
This diff is collapsed.
Click to expand it.
gh-pages/index.md
0 → 100644
This diff is collapsed.
Click to expand it.
gh-pages/patch
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/common.py
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/create_messages.py
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/create_scratch_msgs.js
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/dedup_json.py
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/js_to_json.js
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/js_to_json.py
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/json_to_js.js
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/json_to_js.py
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/sync_translations.sh
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/sync_tx_translations.js
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/test_scratch_msgs.js
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/tests.py
0 → 100644
This diff is collapsed.
Click to expand it.
i18n/xliff_to_json.py
0 → 100644
This diff is collapsed.
Click to expand it.
local_build.sh
0 → 100644
This diff is collapsed.
Click to expand it.
media/1x1.gif
0 → 100644
43 Bytes
media/click.mp3
0 → 100644
No preview for this file type
media/click.ogg
0 → 100644
No preview for this file type
media/click.wav
0 → 100644
No preview for this file type
media/comment-arrow-down.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/comment-arrow-up.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/delete-x.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/delete.mp3
0 → 100644
No preview for this file type
media/delete.ogg
0 → 100644
No preview for this file type
media/delete.wav
0 → 100644
No preview for this file type
media/dropdown-arrow-dark.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/dropdown-arrow.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/extensions/microbit-block-icon.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/extensions/music-block-icon.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/extensions/pen-block-icon.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/extensions/wedo2-block-icon.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/eyedropper.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/green-flag.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/handclosed.cur
0 → 100644
No preview for this file type
media/handdelete.cur
0 → 100644
No preview for this file type
media/handopen.cur
0 → 100644
No preview for this file type
media/icons/arrow.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/arrow_button.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/control_forever.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/control_repeat.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/control_stop.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/control_wait.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/event_broadcast_blue.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/event_broadcast_coral.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/event_broadcast_green.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/event_broadcast_magenta.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/event_broadcast_orange.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/event_broadcast_purple.svg
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
media/icons/event_whenflagclicked.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/remove.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_blue.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_coral.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_green.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_magenta.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_mystery.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_orange.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_purple.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_white.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/set-led_yellow.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_motor-clockwise.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_motor-counterclockwise.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_motor-speed_fast.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_motor-speed_med.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_motor-speed_slow.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_when-distance_close.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_when-tilt-backward.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_when-tilt-forward.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_when-tilt-left.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_when-tilt-right.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/icons/wedo_when-tilt.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/repeat.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/rotate-left.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/rotate-right.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/sprites.png
0 → 100644
4.05 KB
media/sprites.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/status-not-ready.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/status-ready.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/zoom-in.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/zoom-out.svg
0 → 100644
This diff is collapsed.
Click to expand it.
media/zoom-reset.svg
0 → 100644
This diff is collapsed.
Click to expand it.
msg/js/en.js
0 → 100644
This diff is collapsed.
Click to expand it.
msg/json/en.json
0 → 100644
This diff is collapsed.
Click to expand it.
msg/messages.js
0 → 100644
This diff is collapsed.
Click to expand it.
msg/scratch_msgs.js
0 → 100644
This diff is collapsed.
Click to expand it.
package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
package.json
0 → 100644
This diff is collapsed.
Click to expand it.
pull_from_blockly.sh
0 → 100644
This diff is collapsed.
Click to expand it.
renovate.json5
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
shim/blockly_compressed_horizontal.goog.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/blockly_compressed_horizontal.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
shim/blockly_compressed_vertical.Blockly.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/blockly_compressed_vertical.goog.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/blockly_compressed_vertical.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
shim/blocks_compressed_horizontal.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
shim/blocks_compressed_vertical.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/gh-pages.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/horizontal.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/index.js
0 → 100644
This diff is collapsed.
Click to expand it.
shim/vertical.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/blocks/index.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/blocks/logic_ternary_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/custom_procedure_playground.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/horizontal_playground.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/block_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/connection_db_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/connection_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/db_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/event_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/extensions_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/field_angle_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/field_number_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/field_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/field_variable_getter_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/field_variable_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/generator_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/gesture_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/horizontal_tests.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/index.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/input_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/json_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/names_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/procedure_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/scratch_block_comment_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/svg_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/test_runner.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/test_utilities.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/utils_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/variable_map_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/variable_model_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/vertical_tests.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/widget_div_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/workspace_comment_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/workspace_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/workspace_undo_redo_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/jsunit/xml_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
tests/multi_playground.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/scripts/setup_linux_env.sh
0 → 100644
This diff is collapsed.
Click to expand it.
tests/vertical_playground.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/vertical_playground_compressed.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/workspace_svg/index.html
0 → 100644
This diff is collapsed.
Click to expand it.
tests/workspace_svg/workspace_svg_test.js
0 → 100644
This diff is collapsed.
Click to expand it.
webpack.config.js
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment