mirror of
https://github.com/google/blockly.git
synced 2026-01-30 04:00:10 +01:00
clang-format core/events/block_events.js
This commit is contained in:
@@ -42,8 +42,7 @@ const BlockBase = function(opt_block) {
|
||||
*/
|
||||
this.workspaceId = this.isBlank ? '' : opt_block.workspace.id;
|
||||
};
|
||||
object.inherits(BlockBase,
|
||||
Abstract);
|
||||
object.inherits(BlockBase, Abstract);
|
||||
|
||||
/**
|
||||
* Encode the event as JSON.
|
||||
|
||||
@@ -32,8 +32,8 @@ const registry = goog.require('Blockly.registry');
|
||||
* @extends {Events.BlockBase}
|
||||
* @constructor
|
||||
*/
|
||||
const BlockChange = function(opt_block, opt_element, opt_name, opt_oldValue,
|
||||
opt_newValue) {
|
||||
const BlockChange = function(
|
||||
opt_block, opt_element, opt_name, opt_oldValue, opt_newValue) {
|
||||
BlockChange.superClass_.constructor.call(this, opt_block);
|
||||
if (!opt_block) {
|
||||
return; // Blank event to be populated by fromJson.
|
||||
@@ -94,7 +94,7 @@ BlockChange.prototype.run = function(forward) {
|
||||
const workspace = this.getEventWorkspace_();
|
||||
const block = workspace.getBlockById(this.blockId);
|
||||
if (!block) {
|
||||
console.warn("Can't change non-existent block: " + this.blockId);
|
||||
console.warn('Can\'t change non-existent block: ' + this.blockId);
|
||||
return;
|
||||
}
|
||||
if (block.mutator) {
|
||||
@@ -108,7 +108,7 @@ BlockChange.prototype.run = function(forward) {
|
||||
if (field) {
|
||||
field.setValue(value);
|
||||
} else {
|
||||
console.warn("Can't set non-existent field: " + this.name);
|
||||
console.warn('Can\'t set non-existent field: ' + this.name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -132,11 +132,10 @@ BlockChange.prototype.run = function(forward) {
|
||||
}
|
||||
if (block.domToMutation) {
|
||||
const dom = Xml.textToDom(/** @type {string} */
|
||||
(value) || '<mutation/>');
|
||||
(value) || '<mutation/>');
|
||||
block.domToMutation(dom);
|
||||
}
|
||||
Events.fire(new BlockChange(
|
||||
block, 'mutation', null, oldMutation, value));
|
||||
Events.fire(new BlockChange(block, 'mutation', null, oldMutation, value));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -144,7 +143,6 @@ BlockChange.prototype.run = function(forward) {
|
||||
}
|
||||
};
|
||||
|
||||
registry.register(registry.Type.EVENT, Events.CHANGE,
|
||||
BlockChange);
|
||||
registry.register(registry.Type.EVENT, Events.CHANGE, BlockChange);
|
||||
|
||||
exports = BlockChange;
|
||||
|
||||
@@ -100,13 +100,12 @@ BlockCreate.prototype.run = function(forward) {
|
||||
block.dispose(false);
|
||||
} else if (id == this.blockId) {
|
||||
// Only complain about root-level block.
|
||||
console.warn("Can't uncreate non-existent block: " + id);
|
||||
console.warn('Can\'t uncreate non-existent block: ' + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registry.register(registry.Type.EVENT, Events.CREATE,
|
||||
BlockCreate);
|
||||
registry.register(registry.Type.EVENT, Events.CREATE, BlockCreate);
|
||||
|
||||
exports = BlockCreate;
|
||||
|
||||
@@ -99,7 +99,7 @@ BlockDelete.prototype.run = function(forward) {
|
||||
block.dispose(false);
|
||||
} else if (id == this.blockId) {
|
||||
// Only complain about root-level block.
|
||||
console.warn("Can't delete non-existent block: " + id);
|
||||
console.warn('Can\'t delete non-existent block: ' + id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -109,7 +109,6 @@ BlockDelete.prototype.run = function(forward) {
|
||||
}
|
||||
};
|
||||
|
||||
registry.register(registry.Type.EVENT, Events.DELETE,
|
||||
BlockDelete);
|
||||
registry.register(registry.Type.EVENT, Events.DELETE, BlockDelete);
|
||||
|
||||
exports = BlockDelete;
|
||||
|
||||
@@ -85,8 +85,7 @@ BlockMove.prototype.fromJson = function(json) {
|
||||
this.newInputName = json['newInputName'];
|
||||
if (json['newCoordinate']) {
|
||||
const xy = json['newCoordinate'].split(',');
|
||||
this.newCoordinate =
|
||||
new Coordinate(Number(xy[0]), Number(xy[1]));
|
||||
this.newCoordinate = new Coordinate(Number(xy[0]), Number(xy[1]));
|
||||
}
|
||||
if (json['recordUndo'] !== undefined) {
|
||||
this.recordUndo = json['recordUndo'];
|
||||
@@ -144,7 +143,7 @@ BlockMove.prototype.run = function(forward) {
|
||||
const workspace = this.getEventWorkspace_();
|
||||
const block = workspace.getBlockById(this.blockId);
|
||||
if (!block) {
|
||||
console.warn("Can't move non-existent block: " + this.blockId);
|
||||
console.warn('Can\'t move non-existent block: ' + this.blockId);
|
||||
return;
|
||||
}
|
||||
const parentId = forward ? this.newParentId : this.oldParentId;
|
||||
@@ -154,7 +153,7 @@ BlockMove.prototype.run = function(forward) {
|
||||
if (parentId) {
|
||||
parentBlock = workspace.getBlockById(parentId);
|
||||
if (!parentBlock) {
|
||||
console.warn("Can't connect to non-existent block: " + parentId);
|
||||
console.warn('Can\'t connect to non-existent block: ' + parentId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -179,12 +178,11 @@ BlockMove.prototype.run = function(forward) {
|
||||
if (parentConnection) {
|
||||
blockConnection.connect(parentConnection);
|
||||
} else {
|
||||
console.warn("Can't connect to non-existent input: " + inputName);
|
||||
console.warn('Can\'t connect to non-existent input: ' + inputName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registry.register(registry.Type.EVENT, Events.MOVE,
|
||||
BlockMove);
|
||||
registry.register(registry.Type.EVENT, Events.MOVE, BlockMove);
|
||||
|
||||
exports = BlockMove;
|
||||
|
||||
Reference in New Issue
Block a user