mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
19
core/css.js
19
core/css.js
@@ -31,23 +31,6 @@
|
|||||||
goog.provide('Blockly.Css');
|
goog.provide('Blockly.Css');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of cursors.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
Blockly.Css.Cursor = {
|
|
||||||
OPEN: 'handopen',
|
|
||||||
CLOSED: 'handclosed',
|
|
||||||
DELETE: 'handdelete'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current cursor (cached value).
|
|
||||||
* @type {string}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
Blockly.Css.currentCursor_ = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has CSS already been injected?
|
* Has CSS already been injected?
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -105,7 +88,7 @@ Blockly.Css.inject = function(hasCss, pathToMedia) {
|
|||||||
/**
|
/**
|
||||||
* Set the cursor to be displayed when over something draggable.
|
* Set the cursor to be displayed when over something draggable.
|
||||||
* See See https://github.com/google/blockly/issues/981 for context.
|
* See See https://github.com/google/blockly/issues/981 for context.
|
||||||
* @param {Blockly.Css.Cursor} _cursor Enum.
|
* @param {*} _cursor Enum.
|
||||||
* @deprecated April 2017.
|
* @deprecated April 2017.
|
||||||
*/
|
*/
|
||||||
Blockly.Css.setCursor = function(_cursor) {
|
Blockly.Css.setCursor = function(_cursor) {
|
||||||
|
|||||||
@@ -46,15 +46,8 @@ Blockly.Trashcan = function(workspace) {
|
|||||||
this.workspace_ = workspace;
|
this.workspace_ = workspace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the trashcan contains blocks, otherwise false.
|
* A list of XML (stored as strings) representing blocks in the trashcan.
|
||||||
* @type {boolean}
|
* @type {!Array.<string>}
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.hasBlocks_ = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of Xml (stored as strings) representing blocks "inside" the trashcan.
|
|
||||||
* @type {Array}
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.contents_ = [];
|
this.contents_ = [];
|
||||||
@@ -90,7 +83,7 @@ Blockly.Trashcan = function(workspace) {
|
|||||||
}
|
}
|
||||||
this.flyout_ = new Blockly.VerticalFlyout(flyoutWorkspaceOptions);
|
this.flyout_ = new Blockly.VerticalFlyout(flyoutWorkspaceOptions);
|
||||||
}
|
}
|
||||||
this.workspace_.addChangeListener(this.onDelete_());
|
this.workspace_.addChangeListener(this.onDelete_.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,7 +426,7 @@ Blockly.Trashcan.prototype.close = function() {
|
|||||||
* Inspect the contents of the trash.
|
* Inspect the contents of the trash.
|
||||||
*/
|
*/
|
||||||
Blockly.Trashcan.prototype.click = function() {
|
Blockly.Trashcan.prototype.click = function() {
|
||||||
if (!this.hasBlocks_) {
|
if (!this.contents_.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,10 +442,9 @@ Blockly.Trashcan.prototype.click = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.Trashcan.prototype.mouseOver_ = function() {
|
Blockly.Trashcan.prototype.mouseOver_ = function() {
|
||||||
if (!this.hasBlocks_) {
|
if (this.contents_.length) {
|
||||||
return;
|
this.setOpen_(true);
|
||||||
}
|
}
|
||||||
this.setOpen_(true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -468,35 +460,28 @@ Blockly.Trashcan.prototype.mouseOut_ = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a BLOCK_DELETE event. Adds deleted blocks oldXml to the content array.
|
* Handle a BLOCK_DELETE event. Adds deleted blocks oldXml to the content array.
|
||||||
* @return {!Function} Function to call when a block is deleted.
|
* @param {!Blockly.Events.Abstract} event Workspace event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.Trashcan.prototype.onDelete_ = function() {
|
Blockly.Trashcan.prototype.onDelete_ = function(event) {
|
||||||
var trashcan = this;
|
if (this.workspace_.options.maxTrashcanContents <= 0) {
|
||||||
return function(event) {
|
return;
|
||||||
if (trashcan.workspace_.options.maxTrashcanContents <= 0) {
|
}
|
||||||
|
if (event.type == Blockly.Events.BLOCK_DELETE &&
|
||||||
|
event.oldXml.tagName.toLowerCase() != 'shadow') {
|
||||||
|
var cleanedXML = this.cleanBlockXML_(event.oldXml);
|
||||||
|
if (this.contents_.indexOf(cleanedXML) != -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.type == Blockly.Events.BLOCK_DELETE &&
|
this.contents_.unshift(cleanedXML);
|
||||||
event.oldXml.tagName.toLowerCase() != 'shadow') {
|
while (this.contents_.length >
|
||||||
var cleanedXML = trashcan.cleanBlockXML_(event.oldXml);
|
this.workspace_.options.maxTrashcanContents) {
|
||||||
if (trashcan.contents_.indexOf(cleanedXML) != -1) {
|
this.contents_.pop();
|
||||||
return;
|
|
||||||
}
|
|
||||||
trashcan.contents_.unshift(cleanedXML);
|
|
||||||
if (trashcan.contents_.length >
|
|
||||||
trashcan.workspace_.options.maxTrashcanContents) {
|
|
||||||
trashcan.contents_.splice(
|
|
||||||
trashcan.workspace_.options.maxTrashcanContents,
|
|
||||||
trashcan.contents_.length -
|
|
||||||
trashcan.workspace_.options.maxTrashcanContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
trashcan.hasBlocks_ = true;
|
|
||||||
trashcan.minOpenness_ = trashcan.HAS_BLOCKS_LID_ANGLE;
|
|
||||||
trashcan.setLidAngle_(trashcan.minOpenness_ * 45);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
this.minOpenness_ = this.HAS_BLOCKS_LID_ANGLE;
|
||||||
|
this.setLidAngle_(this.minOpenness_ * 45);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ function start() {
|
|||||||
horizontalLayout: side == 'top' || side == 'bottom',
|
horizontalLayout: side == 'top' || side == 'bottom',
|
||||||
maxBlocks: Infinity,
|
maxBlocks: Infinity,
|
||||||
maxInstances: {'test_basic_limit_instances': 3},
|
maxInstances: {'test_basic_limit_instances': 3},
|
||||||
|
maxTrashcanContents: 256,
|
||||||
media: '../media/',
|
media: '../media/',
|
||||||
oneBasedIndex: true,
|
oneBasedIndex: true,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
|
|||||||
10
typings/blockly.d.ts
vendored
10
typings/blockly.d.ts
vendored
@@ -2809,12 +2809,6 @@ declare module Blockly.ContextMenu {
|
|||||||
|
|
||||||
declare module Blockly.Css {
|
declare module Blockly.Css {
|
||||||
|
|
||||||
/**
|
|
||||||
* List of cursors.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
enum Cursor { OPEN, CLOSED, DELETE }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject the CSS into the DOM. This is preferable over using a regular CSS
|
* Inject the CSS into the DOM. This is preferable over using a regular CSS
|
||||||
* file since:
|
* file since:
|
||||||
@@ -2830,10 +2824,10 @@ declare module Blockly.Css {
|
|||||||
/**
|
/**
|
||||||
* Set the cursor to be displayed when over something draggable.
|
* Set the cursor to be displayed when over something draggable.
|
||||||
* See See https://github.com/google/blockly/issues/981 for context.
|
* See See https://github.com/google/blockly/issues/981 for context.
|
||||||
* @param {Blockly.Css.Cursor} cursor Enum.
|
* @param {*} cursor Enum.
|
||||||
* @deprecated April 2017.
|
* @deprecated April 2017.
|
||||||
*/
|
*/
|
||||||
function setCursor(cursor: Blockly.Css.Cursor): void;
|
function setCursor(cursor: any): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array making up the CSS content for Blockly.
|
* Array making up the CSS content for Blockly.
|
||||||
|
|||||||
Reference in New Issue
Block a user