mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Move constants to their own file
This commit is contained in:
109
core/blockly.js
109
core/blockly.js
@@ -45,6 +45,7 @@ goog.require('Blockly.Procedures');
|
||||
goog.require('Blockly.Toolbox');
|
||||
goog.require('Blockly.WidgetDiv');
|
||||
goog.require('Blockly.WorkspaceSvg');
|
||||
goog.require('Blockly.constants');
|
||||
goog.require('Blockly.inject');
|
||||
goog.require('Blockly.utils');
|
||||
goog.require('goog.color');
|
||||
@@ -54,37 +55,6 @@ goog.require('goog.userAgent');
|
||||
// Turn off debugging when compiled.
|
||||
var CLOSURE_DEFINES = {'goog.DEBUG': false};
|
||||
|
||||
/**
|
||||
* Required name space for SVG elements.
|
||||
* @const
|
||||
*/
|
||||
Blockly.SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
/**
|
||||
* Required name space for HTML elements.
|
||||
* @const
|
||||
*/
|
||||
Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml';
|
||||
|
||||
/**
|
||||
* The richness of block colours, regardless of the hue.
|
||||
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
||||
*/
|
||||
Blockly.HSV_SATURATION = 0.45;
|
||||
/**
|
||||
* The intensity of block colours, regardless of the hue.
|
||||
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
||||
*/
|
||||
Blockly.HSV_VALUE = 0.65;
|
||||
|
||||
/**
|
||||
* Sprited icons and images.
|
||||
*/
|
||||
Blockly.SPRITE = {
|
||||
width: 96,
|
||||
height: 124,
|
||||
url: 'sprites.png'
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a hue (HSV model) into an RGB hex triplet.
|
||||
* @param {number} hue Hue on a colour wheel (0-360).
|
||||
@@ -95,58 +65,6 @@ Blockly.hueToRgb = function(hue) {
|
||||
Blockly.HSV_VALUE * 255);
|
||||
};
|
||||
|
||||
/**
|
||||
* ENUM for a right-facing value input. E.g. 'set item to' or 'return'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.INPUT_VALUE = 1;
|
||||
/**
|
||||
* ENUM for a left-facing value output. E.g. 'random fraction'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.OUTPUT_VALUE = 2;
|
||||
/**
|
||||
* ENUM for a down-facing block stack. E.g. 'if-do' or 'else'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.NEXT_STATEMENT = 3;
|
||||
/**
|
||||
* ENUM for an up-facing block stack. E.g. 'break out of loop'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.PREVIOUS_STATEMENT = 4;
|
||||
/**
|
||||
* ENUM for an dummy input. Used to add field(s) with no input.
|
||||
* @const
|
||||
*/
|
||||
Blockly.DUMMY_INPUT = 5;
|
||||
|
||||
/**
|
||||
* ENUM for left alignment.
|
||||
* @const
|
||||
*/
|
||||
Blockly.ALIGN_LEFT = -1;
|
||||
/**
|
||||
* ENUM for centre alignment.
|
||||
* @const
|
||||
*/
|
||||
Blockly.ALIGN_CENTRE = 0;
|
||||
/**
|
||||
* ENUM for right alignment.
|
||||
* @const
|
||||
*/
|
||||
Blockly.ALIGN_RIGHT = 1;
|
||||
|
||||
/**
|
||||
* Lookup table for determining the opposite type of a connection.
|
||||
* @const
|
||||
*/
|
||||
Blockly.OPPOSITE_TYPE = [];
|
||||
Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE] = Blockly.OUTPUT_VALUE;
|
||||
Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE] = Blockly.INPUT_VALUE;
|
||||
Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT] = Blockly.PREVIOUS_STATEMENT;
|
||||
Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT] = Blockly.NEXT_STATEMENT;
|
||||
|
||||
/**
|
||||
* Currently selected block.
|
||||
* @type {Blockly.Block}
|
||||
@@ -167,31 +85,6 @@ Blockly.highlightedConnection_ = null;
|
||||
*/
|
||||
Blockly.localConnection_ = null;
|
||||
|
||||
/**
|
||||
* Number of pixels the mouse must move before a drag starts.
|
||||
*/
|
||||
Blockly.DRAG_RADIUS = 5;
|
||||
|
||||
/**
|
||||
* Maximum misalignment between connections for them to snap together.
|
||||
*/
|
||||
Blockly.SNAP_RADIUS = 20;
|
||||
|
||||
/**
|
||||
* Delay in ms between trigger and bumping unconnected block out of alignment.
|
||||
*/
|
||||
Blockly.BUMP_DELAY = 250;
|
||||
|
||||
/**
|
||||
* Number of characters to truncate a collapsed block to.
|
||||
*/
|
||||
Blockly.COLLAPSE_CHARS = 30;
|
||||
|
||||
/**
|
||||
* Length in ms for a touch to become a long press.
|
||||
*/
|
||||
Blockly.LONGPRESS = 750;
|
||||
|
||||
/**
|
||||
* The main workspace most recently used.
|
||||
* Set by Blockly.WorkspaceSvg.prototype.markFocused
|
||||
|
||||
142
core/constants.js
Normal file
142
core/constants.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2016 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly constants.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.constants');
|
||||
|
||||
|
||||
/**
|
||||
* Required name space for SVG elements.
|
||||
* @const
|
||||
*/
|
||||
Blockly.SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
|
||||
/**
|
||||
* Required name space for HTML elements.
|
||||
* @const
|
||||
*/
|
||||
Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml';
|
||||
|
||||
/**
|
||||
* The richness of block colours, regardless of the hue.
|
||||
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
||||
*/
|
||||
Blockly.HSV_SATURATION = 0.45;
|
||||
|
||||
/**
|
||||
* The intensity of block colours, regardless of the hue.
|
||||
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
||||
*/
|
||||
Blockly.HSV_VALUE = 0.65;
|
||||
|
||||
/**
|
||||
* Sprited icons and images.
|
||||
*/
|
||||
Blockly.SPRITE = {
|
||||
width: 96,
|
||||
height: 124,
|
||||
url: 'sprites.png'
|
||||
};
|
||||
|
||||
/**
|
||||
* ENUM for a right-facing value input. E.g. 'set item to' or 'return'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.INPUT_VALUE = 1;
|
||||
|
||||
/**
|
||||
* ENUM for a left-facing value output. E.g. 'random fraction'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.OUTPUT_VALUE = 2;
|
||||
|
||||
/**
|
||||
* ENUM for a down-facing block stack. E.g. 'if-do' or 'else'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.NEXT_STATEMENT = 3;
|
||||
|
||||
/**
|
||||
* ENUM for an up-facing block stack. E.g. 'break out of loop'.
|
||||
* @const
|
||||
*/
|
||||
Blockly.PREVIOUS_STATEMENT = 4;
|
||||
|
||||
/**
|
||||
* ENUM for an dummy input. Used to add field(s) with no input.
|
||||
* @const
|
||||
*/
|
||||
Blockly.DUMMY_INPUT = 5;
|
||||
|
||||
/**
|
||||
* ENUM for left alignment.
|
||||
* @const
|
||||
*/
|
||||
Blockly.ALIGN_LEFT = -1;
|
||||
/**
|
||||
* ENUM for centre alignment.
|
||||
* @const
|
||||
*/
|
||||
Blockly.ALIGN_CENTRE = 0;
|
||||
/**
|
||||
* ENUM for right alignment.
|
||||
* @const
|
||||
*/
|
||||
Blockly.ALIGN_RIGHT = 1;
|
||||
|
||||
/**
|
||||
* Lookup table for determining the opposite type of a connection.
|
||||
* @const
|
||||
*/
|
||||
Blockly.OPPOSITE_TYPE = [];
|
||||
Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE] = Blockly.OUTPUT_VALUE;
|
||||
Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE] = Blockly.INPUT_VALUE;
|
||||
Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT] = Blockly.PREVIOUS_STATEMENT;
|
||||
Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT] = Blockly.NEXT_STATEMENT;
|
||||
|
||||
/**
|
||||
* Number of pixels the mouse must move before a drag starts.
|
||||
*/
|
||||
Blockly.DRAG_RADIUS = 5;
|
||||
|
||||
/**
|
||||
* Maximum misalignment between connections for them to snap together.
|
||||
*/
|
||||
Blockly.SNAP_RADIUS = 20;
|
||||
|
||||
/**
|
||||
* Delay in ms between trigger and bumping unconnected block out of alignment.
|
||||
*/
|
||||
Blockly.BUMP_DELAY = 250;
|
||||
|
||||
/**
|
||||
* Number of characters to truncate a collapsed block to.
|
||||
*/
|
||||
Blockly.COLLAPSE_CHARS = 30;
|
||||
|
||||
/**
|
||||
* Length in ms for a touch to become a long press.
|
||||
*/
|
||||
Blockly.LONGPRESS = 750;
|
||||
Reference in New Issue
Block a user