mirror of
https://github.com/google/blockly.git
synced 2026-01-06 00:20:37 +01:00
fix variable naming in createnewblock.
This commit is contained in:
@@ -833,7 +833,6 @@ Blockly.Flyout.prototype.onMouseMoveBlock_ = function(e) {
|
|||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
|
Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
|
||||||
var flyout = this;
|
var flyout = this;
|
||||||
var workspace = this.targetWorkspace_;
|
|
||||||
return function(e) {
|
return function(e) {
|
||||||
if (Blockly.isRightButton(e)) {
|
if (Blockly.isRightButton(e)) {
|
||||||
// Right-click. Don't create a block, let the context menu show.
|
// Right-click. Don't create a block, let the context menu show.
|
||||||
@@ -844,7 +843,7 @@ Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Blockly.Events.disable();
|
Blockly.Events.disable();
|
||||||
var block = flyout.placeNewBlock_(originBlock, workspace);
|
var block = flyout.placeNewBlock_(originBlock);
|
||||||
Blockly.Events.enable();
|
Blockly.Events.enable();
|
||||||
if (Blockly.Events.isEnabled()) {
|
if (Blockly.Events.isEnabled()) {
|
||||||
Blockly.Events.setGroup(true);
|
Blockly.Events.setGroup(true);
|
||||||
@@ -864,19 +863,19 @@ Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a block from the flyout to the workspace and position it correctly.
|
* Copy a block from the flyout to the workspace and position it correctly.
|
||||||
* @param {!Blockly.Block} originBlock The flyout block to copy.
|
* @param {!Blockly.Block} originBlock The flyout block to copy..
|
||||||
* @param {!Blockly.Workspace} workspace The main workspace.
|
|
||||||
* @return {!Blockly.Block} The new block in the main workspace.
|
* @return {!Blockly.Block} The new block in the main workspace.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.placeNewBlock_ = function(originBlock, workspace) {
|
Blockly.Flyout.prototype.placeNewBlock_ = function(originBlock) {
|
||||||
|
var targetWorkspace = this.targetWorkspace_;
|
||||||
var svgRootOld = originBlock.getSvgRoot();
|
var svgRootOld = originBlock.getSvgRoot();
|
||||||
if (!svgRootOld) {
|
if (!svgRootOld) {
|
||||||
throw 'originBlock is not rendered.';
|
throw 'originBlock is not rendered.';
|
||||||
}
|
}
|
||||||
// Figure out where the original block is on the screen, relative to the upper
|
// Figure out where the original block is on the screen, relative to the upper
|
||||||
// left corner of the main workspace.
|
// left corner of the main workspace.
|
||||||
var xyOld = Blockly.getSvgXY_(svgRootOld, workspace);
|
var xyOld = Blockly.getSvgXY_(svgRootOld, targetWorkspace);
|
||||||
// Take into account that the flyout might have been scrolled horizontally
|
// Take into account that the flyout might have been scrolled horizontally
|
||||||
// (separately from the main workspace).
|
// (separately from the main workspace).
|
||||||
// Generally a no-op in vertical mode but likely to happen in horizontal
|
// Generally a no-op in vertical mode but likely to happen in horizontal
|
||||||
@@ -888,8 +887,8 @@ Blockly.Flyout.prototype.placeNewBlock_ = function(originBlock, workspace) {
|
|||||||
// the right of (0, 0) in the main workspace. Offset to take that into
|
// the right of (0, 0) in the main workspace. Offset to take that into
|
||||||
// account.
|
// account.
|
||||||
if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_RIGHT) {
|
if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_RIGHT) {
|
||||||
scrollX = workspace.getMetrics().viewWidth - this.width_;
|
scrollX = targetWorkspace.getMetrics().viewWidth - this.width_;
|
||||||
scale = workspace.scale;
|
scale = targetWorkspace.scale;
|
||||||
// Scale the scroll (getSvgXY_ did not do this).
|
// Scale the scroll (getSvgXY_ did not do this).
|
||||||
xyOld.x += scrollX / scale - scrollX;
|
xyOld.x += scrollX / scale - scrollX;
|
||||||
}
|
}
|
||||||
@@ -904,14 +903,14 @@ Blockly.Flyout.prototype.placeNewBlock_ = function(originBlock, workspace) {
|
|||||||
// If the flyout is on the bottom, (0, 0) in the flyout is offset to be below
|
// If the flyout is on the bottom, (0, 0) in the flyout is offset to be below
|
||||||
// (0, 0) in the main workspace. Offset to take that into account.
|
// (0, 0) in the main workspace. Offset to take that into account.
|
||||||
if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_BOTTOM) {
|
if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_BOTTOM) {
|
||||||
scrollY = workspace.getMetrics().viewHeight - this.height_;
|
scrollY = targetWorkspace.getMetrics().viewHeight - this.height_;
|
||||||
scale = workspace.scale;
|
scale = targetWorkspace.scale;
|
||||||
xyOld.y += scrollY / scale - scrollY;
|
xyOld.y += scrollY / scale - scrollY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the new block by cloning the block in the flyout (via XML).
|
// Create the new block by cloning the block in the flyout (via XML).
|
||||||
var xml = Blockly.Xml.blockToDom(originBlock);
|
var xml = Blockly.Xml.blockToDom(originBlock);
|
||||||
var block = Blockly.Xml.domToBlock(xml, workspace);
|
var block = Blockly.Xml.domToBlock(xml, targetWorkspace);
|
||||||
var svgRootNew = block.getSvgRoot();
|
var svgRootNew = block.getSvgRoot();
|
||||||
if (!svgRootNew) {
|
if (!svgRootNew) {
|
||||||
throw 'block is not rendered.';
|
throw 'block is not rendered.';
|
||||||
@@ -920,14 +919,16 @@ Blockly.Flyout.prototype.placeNewBlock_ = function(originBlock, workspace) {
|
|||||||
// upper left corner of the workspace. This may not be the same as the
|
// upper left corner of the workspace. This may not be the same as the
|
||||||
// original block because the flyout's origin may not be the same as the
|
// original block because the flyout's origin may not be the same as the
|
||||||
// main workspace's origin.
|
// main workspace's origin.
|
||||||
var xyNew = Blockly.getSvgXY_(svgRootNew, workspace);
|
var xyNew = Blockly.getSvgXY_(svgRootNew, targetWorkspace);
|
||||||
// Scale the scroll (getSvgXY_ did not do this).
|
// Scale the scroll (getSvgXY_ did not do this).
|
||||||
xyNew.x += workspace.scrollX / workspace.scale - workspace.scrollX;
|
xyNew.x +=
|
||||||
xyNew.y += workspace.scrollY / workspace.scale - workspace.scrollY;
|
targetWorkspace.scrollX / targetWorkspace.scale - targetWorkspace.scrollX;
|
||||||
|
xyNew.y +=
|
||||||
|
targetWorkspace.scrollY / targetWorkspace.scale - targetWorkspace.scrollY;
|
||||||
// If the flyout is collapsible and the workspace can't be scrolled.
|
// If the flyout is collapsible and the workspace can't be scrolled.
|
||||||
if (workspace.toolbox_ && !workspace.scrollbar) {
|
if (targetWorkspace.toolbox_ && !targetWorkspace.scrollbar) {
|
||||||
xyNew.x += workspace.toolbox_.getWidth() / workspace.scale;
|
xyNew.x += targetWorkspace.toolbox_.getWidth() / targetWorkspace.scale;
|
||||||
xyNew.y += workspace.toolbox_.getHeight() / workspace.scale;
|
xyNew.y += targetWorkspace.toolbox_.getHeight() / targetWorkspace.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the new block to where the old block is.
|
// Move the new block to where the old block is.
|
||||||
@@ -1010,8 +1011,6 @@ Blockly.Flyout.terminateDrag_ = function() {
|
|||||||
* Compute height of flyout. Position button under each block.
|
* Compute height of flyout. Position button under each block.
|
||||||
* For RTL: Lay out the blocks right-aligned.
|
* For RTL: Lay out the blocks right-aligned.
|
||||||
* @param {!Array<!Blockly.Block>} blocks The blocks to reflow.
|
* @param {!Array<!Blockly.Block>} blocks The blocks to reflow.
|
||||||
* @param {boolean} opt_skip_resize Possibly skip resizing, since sometimes a
|
|
||||||
* resize will be called immediately anyway.
|
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.reflowHorizontal = function(blocks) {
|
Blockly.Flyout.prototype.reflowHorizontal = function(blocks) {
|
||||||
this.workspace_.scale = this.targetWorkspace_.scale;
|
this.workspace_.scale = this.targetWorkspace_.scale;
|
||||||
@@ -1046,7 +1045,7 @@ Blockly.Flyout.prototype.reflowHorizontal = function(blocks) {
|
|||||||
}
|
}
|
||||||
// Record the height for .getMetrics_ and .position.
|
// Record the height for .getMetrics_ and .position.
|
||||||
this.height_ = flyoutHeight;
|
this.height_ = flyoutHeight;
|
||||||
Blockly.fireUiEvent(window, 'resize');
|
Blockly.asyncSvgResize(this.workspace_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1054,8 +1053,6 @@ Blockly.Flyout.prototype.reflowHorizontal = function(blocks) {
|
|||||||
* Compute width of flyout. Position button under each block.
|
* Compute width of flyout. Position button under each block.
|
||||||
* For RTL: Lay out the blocks right-aligned.
|
* For RTL: Lay out the blocks right-aligned.
|
||||||
* @param {!Array<!Blockly.Block>} blocks The blocks to reflow.
|
* @param {!Array<!Blockly.Block>} blocks The blocks to reflow.
|
||||||
* @param {boolean} opt_skip_resize Possibly skip resizing, since sometimes a
|
|
||||||
* resize will be called immediately anyway.
|
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.reflowVertical = function(blocks) {
|
Blockly.Flyout.prototype.reflowVertical = function(blocks) {
|
||||||
this.workspace_.scale = this.targetWorkspace_.scale;
|
this.workspace_.scale = this.targetWorkspace_.scale;
|
||||||
@@ -1102,14 +1099,12 @@ Blockly.Flyout.prototype.reflowVertical = function(blocks) {
|
|||||||
}
|
}
|
||||||
// Record the width for .getMetrics_ and .position.
|
// Record the width for .getMetrics_ and .position.
|
||||||
this.width_ = flyoutWidth;
|
this.width_ = flyoutWidth;
|
||||||
Blockly.fireUiEvent(window, 'resize');
|
Blockly.asyncSvgResize(this.workspace_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflow blocks and their buttons.
|
* Reflow blocks and their buttons.
|
||||||
* @param {boolean} opt_skip_resize Possibly skip resizing, since sometimes a
|
|
||||||
* resize will be called immediately anyway.
|
|
||||||
*/
|
*/
|
||||||
Blockly.Flyout.prototype.reflow = function() {
|
Blockly.Flyout.prototype.reflow = function() {
|
||||||
var blocks = this.workspace_.getTopBlocks(false);
|
var blocks = this.workspace_.getTopBlocks(false);
|
||||||
|
|||||||
@@ -105,9 +105,6 @@ Blockly.Options = function(options) {
|
|||||||
pathToMedia = options['path'] + 'media/';
|
pathToMedia = options['path'] + 'media/';
|
||||||
}
|
}
|
||||||
|
|
||||||
var enableRealtime = !!options['realtime'];
|
|
||||||
var realtimeOptions = enableRealtime ? options['realtimeOptions'] : undefined;
|
|
||||||
|
|
||||||
this.RTL = rtl;
|
this.RTL = rtl;
|
||||||
this.collapse = hasCollapse;
|
this.collapse = hasCollapse;
|
||||||
this.comments = hasComments;
|
this.comments = hasComments;
|
||||||
@@ -124,8 +121,6 @@ Blockly.Options = function(options) {
|
|||||||
this.languageTree = languageTree;
|
this.languageTree = languageTree;
|
||||||
this.gridOptions = Blockly.Options.parseGridOptions_(options);
|
this.gridOptions = Blockly.Options.parseGridOptions_(options);
|
||||||
this.zoomOptions = Blockly.Options.parseZoomOptions_(options);
|
this.zoomOptions = Blockly.Options.parseZoomOptions_(options);
|
||||||
this.enableRealtime = enableRealtime;
|
|
||||||
this.realtimeOptions = realtimeOptions;
|
|
||||||
this.toolboxPosition = toolboxPosition;
|
this.toolboxPosition = toolboxPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ Code.tabClick = function(clickedName) {
|
|||||||
if (clickedName == 'blocks') {
|
if (clickedName == 'blocks') {
|
||||||
Code.workspace.setVisible(true);
|
Code.workspace.setVisible(true);
|
||||||
}
|
}
|
||||||
Blockly.fireUiEvent(window, 'resize');
|
Blockly.asyncSvgResize(this.workspace_);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user