mirror of
https://github.com/google/blockly.git
synced 2026-06-17 16:45:13 +02:00
Merge branch 'develop' into feature/category_with_buttons
This commit is contained in:
@@ -25,9 +25,6 @@
|
||||
|
||||
blocklyApp.workspace = new Blockly.Workspace();
|
||||
|
||||
// If the debug flag is true, print console.logs to help with debugging.
|
||||
blocklyApp.debug = false;
|
||||
|
||||
blocklyApp.AppView = ng.core
|
||||
.Component({
|
||||
selector: 'blockly-app',
|
||||
|
||||
@@ -30,6 +30,43 @@ blocklyApp.ClipboardService = ng.core
|
||||
this.clipboardBlockNextConnection_ = null;
|
||||
this.markedConnection_ = null;
|
||||
},
|
||||
areConnectionsCompatible_: function(blockConnection, connection) {
|
||||
// Check that both connections exist, that it's the right kind of
|
||||
// connection, and that the types match.
|
||||
return Boolean(
|
||||
connection && blockConnection &&
|
||||
Blockly.OPPOSITE_TYPE[blockConnection.type] == connection.type &&
|
||||
connection.checkType_(blockConnection));
|
||||
},
|
||||
isCompatibleWithClipboard: function(connection) {
|
||||
var superiorConnection = this.clipboardBlockSuperiorConnection_;
|
||||
var nextConnection = this.clipboardBlockNextConnection_;
|
||||
return Boolean(
|
||||
this.areConnectionsCompatible_(connection, superiorConnection) ||
|
||||
this.areConnectionsCompatible_(connection, nextConnection));
|
||||
},
|
||||
canBeMovedToMarkedConnection: function(block) {
|
||||
// It should not be possible to move a block to one of its own
|
||||
// connections.
|
||||
if (this.markedConnection_ &&
|
||||
this.markedConnection_.sourceBlock_.id == block.id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.canBeCopiedToMarkedConnection(block);
|
||||
},
|
||||
canBeCopiedToMarkedConnection: function(block) {
|
||||
var blockConnection = block.outputConnection || block.previousConnection;
|
||||
return Boolean(
|
||||
this.markedConnection_ &&
|
||||
this.markedConnection_.sourceBlock_.workspace &&
|
||||
this.areConnectionsCompatible_(
|
||||
blockConnection, this.markedConnection_));
|
||||
},
|
||||
markConnection: function(connection) {
|
||||
this.markedConnection_ = connection;
|
||||
alert(Blockly.Msg.MARKED_SPOT_MSG);
|
||||
},
|
||||
cut: function(block) {
|
||||
var blockSummary = block.toString();
|
||||
this.copy(block, false);
|
||||
@@ -64,8 +101,8 @@ blocklyApp.ClipboardService = ng.core
|
||||
},
|
||||
pasteToMarkedConnection: function(block, announce) {
|
||||
var xml = Blockly.Xml.blockToDom(block);
|
||||
var reconstitutedBlock =
|
||||
Blockly.Xml.domToBlock(blocklyApp.workspace, xml);
|
||||
var reconstitutedBlock = Blockly.Xml.domToBlock(
|
||||
blocklyApp.workspace, xml);
|
||||
this.markedConnection_.connect(
|
||||
reconstitutedBlock.outputConnection ||
|
||||
reconstitutedBlock.previousConnection);
|
||||
@@ -74,32 +111,5 @@ blocklyApp.ClipboardService = ng.core
|
||||
Blockly.Msg.PASTED_BLOCK_TO_MARKED_SPOT_MSG +
|
||||
reconstitutedBlock.toString());
|
||||
}
|
||||
},
|
||||
markConnection: function(connection) {
|
||||
this.markedConnection_ = connection;
|
||||
alert(Blockly.Msg.MARKED_SPOT_MSG);
|
||||
},
|
||||
isCompatibleWithConnection_: function(blockConnection, connection) {
|
||||
// Check that both connections exist, that the types match, and that it's
|
||||
// the right kind of connection.
|
||||
return Boolean(
|
||||
connection && blockConnection &&
|
||||
Blockly.OPPOSITE_TYPE[blockConnection.type] == connection.type &&
|
||||
connection.checkType_(blockConnection));
|
||||
},
|
||||
isBlockCompatibleWithMarkedConnection: function(block) {
|
||||
var blockConnection = block.outputConnection || block.previousConnection;
|
||||
return Boolean(
|
||||
this.markedConnection_ &&
|
||||
this.markedConnection_.sourceBlock_.workspace &&
|
||||
this.isCompatibleWithConnection_(
|
||||
blockConnection, this.markedConnection_));
|
||||
},
|
||||
isClipboardCompatibleWithConnection: function(connection) {
|
||||
var superiorConnection = this.clipboardBlockSuperiorConnection_;
|
||||
var nextConnection = this.clipboardBlockNextConnection_;
|
||||
return Boolean(
|
||||
this.isCompatibleWithConnection_(connection, superiorConnection) ||
|
||||
this.isCompatibleWithConnection_(connection, nextConnection));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,12 +59,12 @@ blocklyApp.ToolboxTreeComponent = ng.core
|
||||
</button>
|
||||
</li>
|
||||
<li #sendToSelected [id]="idMap['sendToSelected']" role="treeitem"
|
||||
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['sendToSelectedButton'], 'blockly-button', !clipboardService.isBlockCompatibleWithMarkedConnection(block))"
|
||||
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['sendToSelectedButton'], 'blockly-button', !canBeCopiedToMarkedConnection(block))"
|
||||
[attr.aria-level]="level+2" aria-selected=false>
|
||||
<button #sendToSelectedButton
|
||||
[id]="idMap['sendToSelectedButton']"
|
||||
(click)="copyToMarked(block)"
|
||||
[disabled]="!clipboardService.isBlockCompatibleWithMarkedConnection(block)">
|
||||
[disabled]="!canBeCopiedToMarkedConnection(block)">
|
||||
{{'COPY_TO_MARKED_SPOT'|translate}}
|
||||
</button>
|
||||
</li>
|
||||
@@ -138,6 +138,9 @@ blocklyApp.ToolboxTreeComponent = ng.core
|
||||
return this.utilsService.generateAriaLabelledByAttr(
|
||||
mainLabel, secondLabel, isDisabled);
|
||||
},
|
||||
canBeCopiedToMarkedConnection: function(block) {
|
||||
return this.clipboardService.canBeCopiedToMarkedConnection(block);
|
||||
},
|
||||
copyToWorkspace: function(block) {
|
||||
var xml = Blockly.Xml.blockToDom(block);
|
||||
Blockly.Xml.domToBlock(blocklyApp.workspace, xml);
|
||||
|
||||
@@ -98,7 +98,7 @@ blocklyApp.ToolboxComponent = ng.core
|
||||
this.idMap['Parent' + i] = 'blockly-toolbox-tree-node' + i;
|
||||
}
|
||||
} else {
|
||||
// Create a single category is created with all the top-level blocks.
|
||||
// Create a single category with all the top-level blocks.
|
||||
this.xmlHasCategories = false;
|
||||
this.toolboxCategories = [Array.from(xmlToolboxElt.children)];
|
||||
}
|
||||
@@ -108,8 +108,7 @@ blocklyApp.ToolboxComponent = ng.core
|
||||
// descendant after the ids have been computed.
|
||||
if (this.xmlHasCategories) {
|
||||
this.treeService.setActiveDesc(
|
||||
document.getElementById('blockly-toolbox-tree-node0'),
|
||||
document.getElementById('blockly-toolbox-tree'));
|
||||
'blockly-toolbox-tree-node0', 'blockly-toolbox-tree');
|
||||
}
|
||||
},
|
||||
getToolboxWorkspace: function(categoryNode) {
|
||||
|
||||
+83
-115
@@ -27,12 +27,6 @@
|
||||
blocklyApp.TreeService = ng.core
|
||||
.Class({
|
||||
constructor: function() {
|
||||
// Keeping track of the last key pressed. If the user presses
|
||||
// enter (to edit a text input or press a button), the keyboard
|
||||
// focus shifts to that element. In the next keystroke, if the user
|
||||
// navigates away from the element using the arrow keys, we want
|
||||
// to shift focus back to the tree as a whole.
|
||||
this.previousKey_ = null;
|
||||
// Stores active descendant ids for each tree in the page.
|
||||
this.activeDescendantIds_ = {};
|
||||
},
|
||||
@@ -76,6 +70,16 @@ blocklyApp.TreeService = ng.core
|
||||
|
||||
return this.getToolboxTreeNode_();
|
||||
},
|
||||
focusOnCurrentTree_: function(treeId) {
|
||||
var trees = this.getAllTreeNodes_();
|
||||
for (var i = 0; i < trees.length; i++) {
|
||||
if (trees[i].id == treeId) {
|
||||
trees[i].focus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
focusOnNextTree_: function(treeId) {
|
||||
var trees = this.getAllTreeNodes_();
|
||||
for (var i = 0; i < trees.length - 1; i++) {
|
||||
@@ -129,126 +133,92 @@ blocklyApp.TreeService = ng.core
|
||||
}, 0);
|
||||
},
|
||||
// Make a given node the active descendant of a given tree.
|
||||
setActiveDesc: function(newActiveDesc, tree) {
|
||||
this.unmarkActiveDesc_(this.getActiveDescId(tree.id));
|
||||
this.markActiveDesc_(newActiveDesc.id);
|
||||
this.activeDescendantIds_[tree.id] = newActiveDesc.id;
|
||||
setActiveDesc: function(newActiveDescId, treeId) {
|
||||
this.unmarkActiveDesc_(this.getActiveDescId(treeId));
|
||||
this.markActiveDesc_(newActiveDescId);
|
||||
this.activeDescendantIds_[treeId] = newActiveDescId;
|
||||
},
|
||||
onWorkspaceToolbarKeypress: function(e, treeId) {
|
||||
switch (e.keyCode) {
|
||||
case 9:
|
||||
// 16,9: shift, tab
|
||||
if (e.shiftKey) {
|
||||
// If the previous key is shift, we're shift-tabbing mode.
|
||||
this.focusOnPreviousTree_(treeId);
|
||||
} else {
|
||||
// If previous key isn't shift, we're tabbing.
|
||||
this.focusOnNextTree_(treeId);
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
break;
|
||||
if (e.keyCode == 9) {
|
||||
// Tab key.
|
||||
if (e.shiftKey) {
|
||||
this.focusOnPreviousTree_(treeId);
|
||||
} else {
|
||||
this.focusOnNextTree_(treeId);
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
},
|
||||
isButtonOrFieldNode_: function(node) {
|
||||
return ['BUTTON', 'INPUT'].indexOf(node.tagName) != -1;
|
||||
},
|
||||
onKeypress: function(e, tree) {
|
||||
var treeId = tree.id;
|
||||
var node = document.getElementById(this.getActiveDescId(treeId));
|
||||
var keepFocus = this.previousKey_ == 13;
|
||||
if (!node) {
|
||||
blocklyApp.debug && console.log('KeyHandler: no active descendant');
|
||||
var activeDesc = document.getElementById(this.getActiveDescId(treeId));
|
||||
if (!activeDesc) {
|
||||
console.log('ERROR: no active descendant for current tree.');
|
||||
return;
|
||||
}
|
||||
switch (e.keyCode) {
|
||||
case 9:
|
||||
// 16,9: shift, tab
|
||||
if (e.shiftKey) {
|
||||
// If the previous key is shift, we're shift-tabbing.
|
||||
this.focusOnPreviousTree_(treeId);
|
||||
} else {
|
||||
// If previous key isn't shift, we're tabbing
|
||||
// we want to go to the run code button.
|
||||
this.focusOnNextTree_(treeId);
|
||||
|
||||
var isFocusingIntoField = false;
|
||||
|
||||
if (e.keyCode == 13) {
|
||||
// Enter key. The user wants to interact with a child.
|
||||
if (activeDesc.children.length == 1) {
|
||||
var child = activeDesc.children[0];
|
||||
if (child.tagName == 'BUTTON') {
|
||||
child.click();
|
||||
this.isFocusingIntoField = true;
|
||||
} else if (child.tagName == 'INPUT') {
|
||||
child.focus();
|
||||
}
|
||||
// Setting the previous key variable in each case because
|
||||
// we only want to save the previous navigation keystroke,
|
||||
// not any typing.
|
||||
this.previousKey_ = e.keyCode;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 37:
|
||||
// Left-facing arrow: go out a level, if possible. If not, do nothing.
|
||||
var nextNode = node.parentNode;
|
||||
if (node.tagName == 'BUTTON' || node.tagName == 'INPUT') {
|
||||
}
|
||||
} else if (e.keyCode == 9) {
|
||||
// Tab key.
|
||||
if (e.shiftKey) {
|
||||
this.focusOnPreviousTree_(treeId);
|
||||
} else {
|
||||
this.focusOnNextTree_(treeId);
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
} else if (e.keyCode >= 37 && e.keyCode <= 40) {
|
||||
// Arrow keys.
|
||||
if (e.keyCode == 37) {
|
||||
// Left arrow key. Go up a level, if possible.
|
||||
var nextNode = activeDesc.parentNode;
|
||||
if (this.isButtonOrFieldNode_(activeDesc)) {
|
||||
nextNode = nextNode.parentNode;
|
||||
}
|
||||
while (nextNode && nextNode.className != 'treeview' &&
|
||||
nextNode.tagName != 'LI') {
|
||||
while (nextNode && nextNode.tagName != 'LI') {
|
||||
nextNode = nextNode.parentNode;
|
||||
}
|
||||
if (!nextNode || nextNode.className == 'treeview') {
|
||||
return;
|
||||
if (nextNode) {
|
||||
this.setActiveDesc(nextNode.id, treeId);
|
||||
}
|
||||
this.setActiveDesc(nextNode, tree);
|
||||
this.previousKey_ = e.keyCode;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 38:
|
||||
// Up-facing arrow: go up a level, if possible. If not, do nothing.
|
||||
var prevSibling = this.getPreviousSibling(node);
|
||||
if (prevSibling && prevSibling.tagName != 'H1') {
|
||||
this.setActiveDesc(prevSibling, tree);
|
||||
} else {
|
||||
blocklyApp.debug && console.log('no previous sibling');
|
||||
} else if (e.keyCode == 38) {
|
||||
// Up arrow key. Go to the previous sibling, if possible.
|
||||
var prevSibling = this.getPreviousSibling(activeDesc);
|
||||
if (prevSibling) {
|
||||
this.setActiveDesc(prevSibling.id, treeId);
|
||||
}
|
||||
this.previousKey_ = e.keyCode;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 39:
|
||||
var firstChild = this.getFirstChild(node);
|
||||
} else if (e.keyCode == 39) {
|
||||
// Right arrow key. Go down a level, if possible.
|
||||
var firstChild = this.getFirstChild(activeDesc);
|
||||
if (firstChild) {
|
||||
this.setActiveDesc(firstChild, tree);
|
||||
} else {
|
||||
blocklyApp.debug && console.log('no valid child');
|
||||
this.setActiveDesc(firstChild.id, treeId);
|
||||
}
|
||||
this.previousKey_ = e.keyCode;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 40:
|
||||
// Down-facing arrow: go down a level, if possible.
|
||||
// If not, do nothing.
|
||||
var nextSibling = this.getNextSibling(node);
|
||||
} else if (e.keyCode == 40) {
|
||||
// Down arrow key. Go to the next sibling, if possible.
|
||||
var nextSibling = this.getNextSibling(activeDesc);
|
||||
if (nextSibling) {
|
||||
this.setActiveDesc(nextSibling, tree);
|
||||
} else {
|
||||
blocklyApp.debug && console.log('no next sibling');
|
||||
this.setActiveDesc(nextSibling.id, treeId);
|
||||
}
|
||||
this.previousKey_ = e.keyCode;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 13:
|
||||
// If I've pressed enter, I want to interact with a child.
|
||||
var activeDesc = node;
|
||||
if (activeDesc) {
|
||||
var children = activeDesc.children;
|
||||
var child = children[0];
|
||||
if (children.length == 1 && (child.tagName == 'INPUT' ||
|
||||
child.tagName == 'BUTTON')) {
|
||||
if (child.tagName == 'BUTTON') {
|
||||
child.click();
|
||||
}
|
||||
else if (child.tagName == 'INPUT') {
|
||||
child.focus();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
blocklyApp.debug && console.log('no activeDesc');
|
||||
}
|
||||
this.previousKey_ = e.keyCode;
|
||||
break;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
},
|
||||
getFirstChild: function(element) {
|
||||
@@ -273,13 +243,12 @@ blocklyApp.TreeService = ng.core
|
||||
if (element.nextElementSibling) {
|
||||
// If there is a sibling, find the list element child of the sibling.
|
||||
var node = element.nextElementSibling;
|
||||
if (node.tagName != 'LI') {
|
||||
var listElems = node.getElementsByTagName('li');
|
||||
// getElementsByTagName returns in DFS order
|
||||
// therefore the first element is the first relevant list child.
|
||||
return listElems[0];
|
||||
if (node.tagName == 'LI') {
|
||||
return node;
|
||||
} else {
|
||||
return element.nextElementSibling;
|
||||
// getElementsByTagName returns in DFS order, therefore the first
|
||||
// element is the first relevant list child.
|
||||
return node.getElementsByTagName('li')[0];
|
||||
}
|
||||
} else {
|
||||
var parent = element.parentNode;
|
||||
@@ -343,7 +312,6 @@ blocklyApp.TreeService = ng.core
|
||||
}
|
||||
}
|
||||
}
|
||||
blocklyApp.debug && console.log('no last child');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ blocklyApp.WorkspaceTreeComponent = ng.core
|
||||
[disabled]="!hasPreviousConnection(block)">{{'MARK_SPOT_ABOVE'|translate}}</button>
|
||||
</li>
|
||||
<li [id]="idMap['sendToSelectedListItem']" role="treeitem"
|
||||
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['sendToSelectedButton'], 'blockly-button', !clipboardService.isBlockCompatibleWithMarkedConnection(block))"
|
||||
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['sendToSelectedButton'], 'blockly-button', !canBeMovedToMarkedConnection(block))"
|
||||
[attr.aria-level]="level+2" aria-selected=false>
|
||||
<button [id]="idMap['sendToSelectedButton']" (click)="sendToMarkedSpot(block)"
|
||||
[disabled]="!clipboardService.isBlockCompatibleWithMarkedConnection(block)">{{'MOVE_TO_MARKED_SPOT'|translate}}</button>
|
||||
[disabled]="!canBeMovedToMarkedConnection(block)">{{'MOVE_TO_MARKED_SPOT'|translate}}</button>
|
||||
</li>
|
||||
<li [id]="idMap['delete']" role="treeitem"
|
||||
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['deleteButton'], 'blockly-button')"
|
||||
@@ -161,7 +161,10 @@ blocklyApp.WorkspaceTreeComponent = ng.core
|
||||
|
||||
return elementsNeedingIds;
|
||||
},
|
||||
ngOnInit: function() {
|
||||
ngOnChanges: function() {
|
||||
// The ids needs to be generated on every change (as opposed to only on
|
||||
// init), so that they will update if, e.g., a new workspace-tree
|
||||
// component is added to the middle of an array.
|
||||
var elementsNeedingIds = this.getElementsNeedingIds_();
|
||||
|
||||
this.idMap = {}
|
||||
@@ -180,11 +183,12 @@ blocklyApp.WorkspaceTreeComponent = ng.core
|
||||
|
||||
if (this.tree && this.isTopLevel &&
|
||||
!this.treeService.getActiveDescId(this.tree.id)) {
|
||||
this.treeService.setActiveDesc(
|
||||
document.getElementById(this.idMap['parentList']),
|
||||
this.tree);
|
||||
this.treeService.setActiveDesc(this.idMap['parentList'], this.tree.id);
|
||||
}
|
||||
},
|
||||
canBeMovedToMarkedConnection: function(block) {
|
||||
return this.clipboardService.canBeMovedToMarkedConnection(block);
|
||||
},
|
||||
hasPreviousConnection: function(block) {
|
||||
return Boolean(block.previousConnection);
|
||||
},
|
||||
@@ -192,14 +196,17 @@ blocklyApp.WorkspaceTreeComponent = ng.core
|
||||
return Boolean(block.nextConnection);
|
||||
},
|
||||
isCompatibleWithClipboard: function(connection) {
|
||||
return this.clipboardService.isClipboardCompatibleWithConnection(
|
||||
connection);
|
||||
return this.clipboardService.isCompatibleWithClipboard(connection);
|
||||
},
|
||||
isTopLevelBlock: function(block) {
|
||||
return blocklyApp.workspace.topBlocks_.some(function(topBlock) {
|
||||
return topBlock.id == block.id;
|
||||
});
|
||||
},
|
||||
generateAriaLabelledByAttr: function(mainLabel, secondLabel, isDisabled) {
|
||||
return this.utilsService.generateAriaLabelledByAttr(
|
||||
mainLabel, secondLabel, isDisabled);
|
||||
},
|
||||
pasteAbove: function(block) {
|
||||
var that = this;
|
||||
this.treeService.runWhilePreservingFocus(function() {
|
||||
@@ -234,10 +241,6 @@ blocklyApp.WorkspaceTreeComponent = ng.core
|
||||
block.dispose(true);
|
||||
}
|
||||
},
|
||||
generateAriaLabelledByAttr: function(mainLabel, secondLabel, isDisabled) {
|
||||
return this.utilsService.generateAriaLabelledByAttr(
|
||||
mainLabel, secondLabel, isDisabled);
|
||||
},
|
||||
sendToMarkedSpot: function(block) {
|
||||
this.clipboardService.pasteToMarkedConnection(block, false);
|
||||
|
||||
|
||||
+38
-36
@@ -889,7 +889,7 @@ Blockly.Bubble.prototype.renderArrow_=function(){var a=[],b=this.width_/2,c=this
|
||||
p*d,e=c+p*e,p=b+h*m,l=c+h*k,b=b-h*m,c=c-h*k,k=g+this.arrow_radians_;k>2*Math.PI&&(k-=2*Math.PI);g=Math.sin(k)*f/Blockly.Bubble.ARROW_BEND;f=Math.cos(k)*f/Blockly.Bubble.ARROW_BEND;a.push("M"+p+","+l);a.push("C"+(p+f)+","+(l+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");this.bubbleArrow_.setAttribute("d",a.join(" "))};Blockly.Bubble.prototype.setColour=function(a){this.bubbleBack_.setAttribute("fill",a);this.bubbleArrow_.setAttribute("fill",a)};
|
||||
Blockly.Bubble.prototype.dispose=function(){Blockly.Bubble.unbindDragEvents_();goog.dom.removeNode(this.bubbleGroup_);this.shape_=this.content_=this.workspace_=this.resizeGroup_=this.bubbleBack_=this.bubbleArrow_=this.bubbleGroup_=null};Blockly.Icon=function(a){this.block_=a};Blockly.Icon.prototype.collapseHidden=!0;Blockly.Icon.prototype.SIZE=17;Blockly.Icon.prototype.bubble_=null;Blockly.Icon.prototype.iconXY_=null;Blockly.Icon.prototype.createIcon=function(){this.iconGroup_||(this.iconGroup_=Blockly.createSvgElement("g",{"class":"blocklyIconGroup"},null),this.drawIcon_(this.iconGroup_),this.block_.getSvgRoot().appendChild(this.iconGroup_),Blockly.bindEvent_(this.iconGroup_,"mouseup",this,this.iconClick_),this.updateEditable())};
|
||||
Blockly.Icon.prototype.dispose=function(){goog.dom.removeNode(this.iconGroup_);this.iconGroup_=null;this.setVisible(!1);this.block_=null};Blockly.Icon.prototype.updateEditable=function(){this.block_.isInFlyout||!this.block_.isEditable()?Blockly.addClass_(this.iconGroup_,"blocklyIconGroupReadonly"):Blockly.removeClass_(this.iconGroup_,"blocklyIconGroupReadonly")};Blockly.Icon.prototype.isVisible=function(){return!!this.bubble_};
|
||||
Blockly.Icon.prototype.iconClick_=function(a){Blockly.dragMode_!=Blockly.DRAG_FREE&&(this.block_.isInFlyout||Blockly.isRightButton(a)||this.setVisible(!this.isVisible()))};Blockly.Icon.prototype.updateColour=function(){this.isVisible()&&this.bubble_.setColour(this.block_.getColour())};
|
||||
Blockly.Icon.prototype.iconClick_=function(a){this.block_.workspace.isDragging()||this.block_.isInFlyout||Blockly.isRightButton(a)||this.setVisible(!this.isVisible())};Blockly.Icon.prototype.updateColour=function(){this.isVisible()&&this.bubble_.setColour(this.block_.getColour())};
|
||||
Blockly.Icon.prototype.renderIcon=function(a){if(this.collapseHidden&&this.block_.isCollapsed())return this.iconGroup_.setAttribute("display","none"),a;this.iconGroup_.setAttribute("display","block");var b=this.SIZE;this.block_.RTL&&(a-=b);this.iconGroup_.setAttribute("transform","translate("+a+",5)");this.computeIconLocation();return a=this.block_.RTL?a-Blockly.BlockSvg.SEP_SPACE_X:a+(b+Blockly.BlockSvg.SEP_SPACE_X)};
|
||||
Blockly.Icon.prototype.setIconLocation=function(a){this.iconXY_=a;this.isVisible()&&this.bubble_.setAnchorLocation(a)};Blockly.Icon.prototype.computeIconLocation=function(){var a=this.block_.getRelativeToSurfaceXY(),b=Blockly.getRelativeXY_(this.iconGroup_),a=new goog.math.Coordinate(a.x+b.x+this.SIZE/2,a.y+b.y+this.SIZE/2);goog.math.Coordinate.equals(this.getIconLocation(),a)||this.setIconLocation(a)};Blockly.Icon.prototype.getIconLocation=function(){return this.iconXY_};
|
||||
// Copyright 2011 Google Inc. Apache License 2.0
|
||||
@@ -930,7 +930,7 @@ Blockly.Field.prototype.render_=function(){if(this.visible_&&this.textElement_){
|
||||
Blockly.Field.prototype.getScaledBBox_=function(){var a=this.borderRect_.getBBox();return new goog.math.Size(a.width*this.sourceBlock_.workspace.scale,a.height*this.sourceBlock_.workspace.scale)};Blockly.Field.prototype.getText=function(){return this.text_};Blockly.Field.prototype.setText=function(a){null!==a&&(a=String(a),a!==this.text_&&(this.text_=a,this.updateTextNode_(),this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_())))};
|
||||
Blockly.Field.prototype.updateTextNode_=function(){if(this.textElement_){var a=this.text_;a.length>this.maxDisplayLength&&(a=a.substring(0,this.maxDisplayLength-2)+"\u2026");goog.dom.removeChildren(this.textElement_);a=a.replace(/\s/g,Blockly.Field.NBSP);this.sourceBlock_.RTL&&a&&(a+="\u200f");a||(a=Blockly.Field.NBSP);a=document.createTextNode(a);this.textElement_.appendChild(a);this.size_.width=0}};Blockly.Field.prototype.getValue=function(){return this.getText()};
|
||||
Blockly.Field.prototype.setValue=function(a){if(null!==a){var b=this.getValue();b!=a&&(this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,b,a)),this.setText(a))}};
|
||||
Blockly.Field.prototype.onMouseUp_=function(a){if(!goog.userAgent.IPHONE&&!goog.userAgent.IPAD||goog.userAgent.isVersionOrHigher("537.51.2")||0===a.layerX||0===a.layerY)Blockly.isRightButton(a)||Blockly.dragMode_!=Blockly.DRAG_FREE&&this.sourceBlock_.isEditable()&&this.showEditor_()};Blockly.Field.prototype.setTooltip=function(a){};Blockly.Field.prototype.getAbsoluteXY_=function(){return goog.style.getPageOffset(this.borderRect_)};Blockly.Tooltip={};Blockly.Tooltip.visible=!1;Blockly.Tooltip.LIMIT=50;Blockly.Tooltip.mouseOutPid_=0;Blockly.Tooltip.showPid_=0;Blockly.Tooltip.lastX_=0;Blockly.Tooltip.lastY_=0;Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.OFFSET_X=0;Blockly.Tooltip.OFFSET_Y=10;Blockly.Tooltip.RADIUS_OK=10;Blockly.Tooltip.HOVER_MS=750;Blockly.Tooltip.MARGINS=5;Blockly.Tooltip.DIV=null;
|
||||
Blockly.Field.prototype.onMouseUp_=function(a){if(!goog.userAgent.IPHONE&&!goog.userAgent.IPAD||goog.userAgent.isVersionOrHigher("537.51.2")||0===a.layerX||0===a.layerY)Blockly.isRightButton(a)||this.sourceBlock_.workspace.isDragging()||this.sourceBlock_.isEditable()&&this.showEditor_()};Blockly.Field.prototype.setTooltip=function(a){};Blockly.Field.prototype.getAbsoluteXY_=function(){return goog.style.getPageOffset(this.borderRect_)};Blockly.Tooltip={};Blockly.Tooltip.visible=!1;Blockly.Tooltip.LIMIT=50;Blockly.Tooltip.mouseOutPid_=0;Blockly.Tooltip.showPid_=0;Blockly.Tooltip.lastX_=0;Blockly.Tooltip.lastY_=0;Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.OFFSET_X=0;Blockly.Tooltip.OFFSET_Y=10;Blockly.Tooltip.RADIUS_OK=10;Blockly.Tooltip.HOVER_MS=750;Blockly.Tooltip.MARGINS=5;Blockly.Tooltip.DIV=null;
|
||||
Blockly.Tooltip.createDom=function(){Blockly.Tooltip.DIV||(Blockly.Tooltip.DIV=goog.dom.createDom("div","blocklyTooltipDiv"),document.body.appendChild(Blockly.Tooltip.DIV))};Blockly.Tooltip.bindMouseEvents=function(a){Blockly.bindEvent_(a,"mouseover",null,Blockly.Tooltip.onMouseOver_);Blockly.bindEvent_(a,"mouseout",null,Blockly.Tooltip.onMouseOut_);Blockly.bindEvent_(a,"mousemove",null,Blockly.Tooltip.onMouseMove_)};
|
||||
Blockly.Tooltip.onMouseOver_=function(a){for(a=a.target;!goog.isString(a.tooltip)&&!goog.isFunction(a.tooltip);)a=a.tooltip;Blockly.Tooltip.element_!=a&&(Blockly.Tooltip.hide(),Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.element_=a);clearTimeout(Blockly.Tooltip.mouseOutPid_)};Blockly.Tooltip.onMouseOut_=function(a){Blockly.Tooltip.mouseOutPid_=setTimeout(function(){Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.hide()},1);clearTimeout(Blockly.Tooltip.showPid_)};
|
||||
Blockly.Tooltip.onMouseMove_=function(a){if(Blockly.Tooltip.element_&&Blockly.Tooltip.element_.tooltip&&Blockly.dragMode_==Blockly.DRAG_NONE&&!Blockly.WidgetDiv.isVisible())if(Blockly.Tooltip.visible){var b=Blockly.Tooltip.lastX_-a.pageX;a=Blockly.Tooltip.lastY_-a.pageY;Math.sqrt(b*b+a*a)>Blockly.Tooltip.RADIUS_OK&&Blockly.Tooltip.hide()}else Blockly.Tooltip.poisonedElement_!=Blockly.Tooltip.element_&&(clearTimeout(Blockly.Tooltip.showPid_),Blockly.Tooltip.lastX_=a.pageX,Blockly.Tooltip.lastY_=a.pageY,
|
||||
@@ -972,11 +972,12 @@ Blockly.Scrollbar.prototype.resizeViewVertical=function(a){var b=a.viewHeight-1;
|
||||
Blockly.Scrollbar.prototype.resizeContentVertical=function(a){this.pair_||this.setVisible(this.scrollViewSize_<a.contentHeight);this.ratio_=this.scrollViewSize_/a.contentHeight;if(-Infinity==this.ratio_||Infinity==this.ratio_||isNaN(this.ratio_))this.ratio_=0;this.setHandleLength_(Math.max(0,a.viewHeight*this.ratio_));this.setHandlePosition(this.constrainHandle_((a.viewTop-a.contentTop)*this.ratio_))};
|
||||
Blockly.Scrollbar.prototype.createDom_=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyScrollbar"+(this.horizontal_?"Horizontal":"Vertical")},null);this.svgBackground_=Blockly.createSvgElement("rect",{"class":"blocklyScrollbarBackground"},this.svgGroup_);var a=Math.floor((Blockly.Scrollbar.scrollbarThickness-5)/2);this.svgHandle_=Blockly.createSvgElement("rect",{"class":"blocklyScrollbarHandle",rx:a,ry:a},this.svgGroup_);Blockly.Scrollbar.insertAfter_(this.svgGroup_,this.workspace_.getBubbleCanvas())};
|
||||
Blockly.Scrollbar.prototype.isVisible=function(){return this.isVisible_};Blockly.Scrollbar.prototype.setVisible=function(a){if(a!=this.isVisible()){if(this.pair_)throw"Unable to toggle visibility of paired scrollbars.";(this.isVisible_=a)?this.svgGroup_.setAttribute("display","block"):(this.workspace_.setMetrics({x:0,y:0}),this.svgGroup_.setAttribute("display","none"))}};
|
||||
Blockly.Scrollbar.prototype.onMouseDownBar_=function(a){this.onMouseUpHandle_();if(Blockly.isRightButton(a))a.stopPropagation();else{var b=Blockly.mouseToSvg(a,this.workspace_.getParentSvg()),b=this.horizontal_?b.x:b.y,c=Blockly.getSvgXY_(this.svgHandle_,this.workspace_),c=this.horizontal_?c.x:c.y,d=this.handlePosition_,e=.95*this.handleLength_;b<=c?d-=e:b>=c+this.handleLength_&&(d+=e);this.setHandlePosition(this.constrainHandle_(d));this.onScroll_();a.stopPropagation();a.preventDefault()}};
|
||||
Blockly.Scrollbar.prototype.onMouseDownHandle_=function(a){this.onMouseUpHandle_();Blockly.isRightButton(a)?a.stopPropagation():(this.startDragHandle=this.handlePosition_,this.startDragMouse=this.horizontal_?a.clientX:a.clientY,Blockly.Scrollbar.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUpHandle_),Blockly.Scrollbar.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMoveHandle_),a.stopPropagation(),a.preventDefault())};
|
||||
Blockly.Scrollbar.prototype.onMouseDownBar_=function(a){this.onMouseUpHandle_();if(Blockly.isRightButton(a))a.stopPropagation();else{var b=Blockly.mouseToSvg(a,this.workspace_.getParentSvg(),this.workspace_.getInverseScreenCTM()),b=this.horizontal_?b.x:b.y,c=Blockly.getSvgXY_(this.svgHandle_,this.workspace_),c=this.horizontal_?c.x:c.y,d=this.handlePosition_,e=.95*this.handleLength_;b<=c?d-=e:b>=c+this.handleLength_&&(d+=e);this.setHandlePosition(this.constrainHandle_(d));this.onScroll_();a.stopPropagation();
|
||||
a.preventDefault()}};Blockly.Scrollbar.prototype.onMouseDownHandle_=function(a){this.onMouseUpHandle_();Blockly.isRightButton(a)?a.stopPropagation():(this.startDragHandle=this.handlePosition_,this.startDragMouse=this.horizontal_?a.clientX:a.clientY,Blockly.Scrollbar.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUpHandle_),Blockly.Scrollbar.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMoveHandle_),a.stopPropagation(),a.preventDefault())};
|
||||
Blockly.Scrollbar.prototype.onMouseMoveHandle_=function(a){this.setHandlePosition(this.constrainHandle_(this.startDragHandle+((this.horizontal_?a.clientX:a.clientY)-this.startDragMouse)));this.onScroll_()};
|
||||
Blockly.Scrollbar.prototype.onMouseUpHandle_=function(){Blockly.hideChaff(!0);Blockly.Scrollbar.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseUpWrapper_),Blockly.Scrollbar.onMouseUpWrapper_=null);Blockly.Scrollbar.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseMoveWrapper_),Blockly.Scrollbar.onMouseMoveWrapper_=null)};Blockly.Scrollbar.prototype.constrainHandle_=function(a){return a=0>=a||isNaN(a)?0:Math.min(a,this.scrollViewSize_-this.handleLength_)};
|
||||
Blockly.Scrollbar.prototype.onScroll_=function(){var a=this.handlePosition_/this.scrollViewSize_;isNaN(a)&&(a=0);var b={};this.horizontal_?b.x=a:b.y=a;this.workspace_.setMetrics(b)};Blockly.Scrollbar.prototype.set=function(a){this.setHandlePosition(this.constrainHandle_(a*this.ratio_));this.onScroll_()};Blockly.Scrollbar.insertAfter_=function(a,b){var c=b.nextSibling,d=b.parentNode;if(!d)throw"Reference node has no parent.";c?d.insertBefore(a,c):d.appendChild(a)};Blockly.Trashcan=function(a){this.workspace_=a};Blockly.Trashcan.prototype.WIDTH_=47;Blockly.Trashcan.prototype.BODY_HEIGHT_=44;Blockly.Trashcan.prototype.LID_HEIGHT_=16;Blockly.Trashcan.prototype.MARGIN_BOTTOM_=20;Blockly.Trashcan.prototype.MARGIN_SIDE_=20;Blockly.Trashcan.prototype.MARGIN_HOTSPOT_=10;Blockly.Trashcan.prototype.SPRITE_LEFT_=0;Blockly.Trashcan.prototype.SPRITE_TOP_=32;Blockly.Trashcan.prototype.isOpen=!1;Blockly.Trashcan.prototype.svgGroup_=null;
|
||||
Blockly.Scrollbar.prototype.onMouseUpHandle_=function(){Blockly.hideChaff(!0);Blockly.Scrollbar.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseUpWrapper_),Blockly.Scrollbar.onMouseUpWrapper_=null);Blockly.Scrollbar.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseMoveWrapper_),Blockly.Scrollbar.onMouseMoveWrapper_=null)};
|
||||
Blockly.Scrollbar.prototype.constrainHandle_=function(a){return a=0>=a||isNaN(a)||this.scrollViewSize_<this.handleLength_?0:Math.min(a,this.scrollViewSize_-this.handleLength_)};Blockly.Scrollbar.prototype.onScroll_=function(){var a=this.handlePosition_/this.scrollViewSize_;isNaN(a)&&(a=0);var b={};this.horizontal_?b.x=a:b.y=a;this.workspace_.setMetrics(b)};Blockly.Scrollbar.prototype.set=function(a){this.setHandlePosition(this.constrainHandle_(a*this.ratio_));this.onScroll_()};
|
||||
Blockly.Scrollbar.insertAfter_=function(a,b){var c=b.nextSibling,d=b.parentNode;if(!d)throw"Reference node has no parent.";c?d.insertBefore(a,c):d.appendChild(a)};Blockly.Trashcan=function(a){this.workspace_=a};Blockly.Trashcan.prototype.WIDTH_=47;Blockly.Trashcan.prototype.BODY_HEIGHT_=44;Blockly.Trashcan.prototype.LID_HEIGHT_=16;Blockly.Trashcan.prototype.MARGIN_BOTTOM_=20;Blockly.Trashcan.prototype.MARGIN_SIDE_=20;Blockly.Trashcan.prototype.MARGIN_HOTSPOT_=10;Blockly.Trashcan.prototype.SPRITE_LEFT_=0;Blockly.Trashcan.prototype.SPRITE_TOP_=32;Blockly.Trashcan.prototype.isOpen=!1;Blockly.Trashcan.prototype.svgGroup_=null;
|
||||
Blockly.Trashcan.prototype.svgLid_=null;Blockly.Trashcan.prototype.lidTask_=0;Blockly.Trashcan.prototype.lidOpen_=0;Blockly.Trashcan.prototype.left_=0;Blockly.Trashcan.prototype.top_=0;
|
||||
Blockly.Trashcan.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyTrash"},null);var a=String(Math.random()).substring(2),b=Blockly.createSvgElement("clipPath",{id:"blocklyTrashBodyClipPath"+a},this.svgGroup_);Blockly.createSvgElement("rect",{width:this.WIDTH_,height:this.BODY_HEIGHT_,y:this.LID_HEIGHT_},b);Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,x:-this.SPRITE_LEFT_,height:Blockly.SPRITE.height,y:-this.SPRITE_TOP_,"clip-path":"url(#blocklyTrashBodyClipPath"+
|
||||
a+")"},this.svgGroup_).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace_.options.pathToMedia+Blockly.SPRITE.url);b=Blockly.createSvgElement("clipPath",{id:"blocklyTrashLidClipPath"+a},this.svgGroup_);Blockly.createSvgElement("rect",{width:this.WIDTH_,height:this.LID_HEIGHT_},b);this.svgLid_=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,x:-this.SPRITE_LEFT_,height:Blockly.SPRITE.height,y:-this.SPRITE_TOP_,"clip-path":"url(#blocklyTrashLidClipPath"+a+")"},this.svgGroup_);
|
||||
@@ -1015,15 +1016,16 @@ Blockly.ZoomControls.prototype.position=function(){var a=this.workspace_.getMetr
|
||||
a.absoluteTop-this.HEIGHT_-this.bottom_,a.toolboxPosition==Blockly.TOOLBOX_AT_BOTTOM&&(this.top_-=a.flyoutHeight),this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")"))};
|
||||
// Copyright 2014 Google Inc. Apache License 2.0
|
||||
Blockly.WorkspaceSvg=function(a){Blockly.WorkspaceSvg.superClass_.constructor.call(this,a);this.getMetrics=a.getMetrics;this.setMetrics=a.setMetrics;Blockly.ConnectionDB.init(this);this.SOUNDS_=Object.create(null)};goog.inherits(Blockly.WorkspaceSvg,Blockly.Workspace);Blockly.WorkspaceSvg.prototype.resizeHandlerWrapper_=null;Blockly.WorkspaceSvg.prototype.rendered=!0;Blockly.WorkspaceSvg.prototype.isFlyout=!1;Blockly.WorkspaceSvg.prototype.isScrolling=!1;Blockly.WorkspaceSvg.prototype.scrollX=0;
|
||||
Blockly.WorkspaceSvg.prototype.scrollY=0;Blockly.WorkspaceSvg.prototype.startScrollX=0;Blockly.WorkspaceSvg.prototype.startScrollY=0;Blockly.WorkspaceSvg.prototype.dragDeltaXY_=null;Blockly.WorkspaceSvg.prototype.scale=1;Blockly.WorkspaceSvg.prototype.trashcan=null;Blockly.WorkspaceSvg.prototype.scrollbar=null;Blockly.WorkspaceSvg.prototype.lastSound_=null;Blockly.WorkspaceSvg.prototype.setResizeHandlerWrapper=function(a){this.resizeHandlerWrapper_=a};
|
||||
Blockly.WorkspaceSvg.prototype.scrollY=0;Blockly.WorkspaceSvg.prototype.startScrollX=0;Blockly.WorkspaceSvg.prototype.startScrollY=0;Blockly.WorkspaceSvg.prototype.dragDeltaXY_=null;Blockly.WorkspaceSvg.prototype.scale=1;Blockly.WorkspaceSvg.prototype.trashcan=null;Blockly.WorkspaceSvg.prototype.scrollbar=null;Blockly.WorkspaceSvg.prototype.lastSound_=null;Blockly.WorkspaceSvg.prototype.inverseScreenCTM_=null;Blockly.WorkspaceSvg.prototype.getInverseScreenCTM=function(){return this.inverseScreenCTM_};
|
||||
Blockly.WorkspaceSvg.prototype.updateInverseScreenCTM=function(){this.inverseScreenCTM_=this.getParentSvg().getScreenCTM().inverse()};Blockly.WorkspaceSvg.prototype.setResizeHandlerWrapper=function(a){this.resizeHandlerWrapper_=a};
|
||||
Blockly.WorkspaceSvg.prototype.createDom=function(a){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyWorkspace"},null);a&&(this.svgBackground_=Blockly.createSvgElement("rect",{height:"100%",width:"100%","class":a},this.svgGroup_),"blocklyMainBackground"==a&&(this.svgBackground_.style.fill="url(#"+this.options.gridPattern.id+")"));this.svgBlockCanvas_=Blockly.createSvgElement("g",{"class":"blocklyBlockCanvas"},this.svgGroup_,this);this.svgBubbleCanvas_=Blockly.createSvgElement("g",{"class":"blocklyBubbleCanvas"},
|
||||
this.svgGroup_,this);a=Blockly.Scrollbar.scrollbarThickness;this.options.hasTrashcan&&(a=this.addTrashcan_(a));this.options.zoomOptions&&this.options.zoomOptions.controls&&(a=this.addZoomControls_(a));Blockly.bindEvent_(this.svgGroup_,"mousedown",this,this.onMouseDown_);var b=this;Blockly.bindEvent_(this.svgGroup_,"touchstart",null,function(a){Blockly.longStart_(a,b)});this.options.zoomOptions&&this.options.zoomOptions.wheel&&Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.onMouseWheel_);this.options.hasCategories?
|
||||
this.toolbox_=new Blockly.Toolbox(this):this.options.languageTree&&this.addFlyout_();this.updateGridPattern_();this.recordDeleteAreas();return this.svgGroup_};
|
||||
Blockly.WorkspaceSvg.prototype.dispose=function(){this.rendered=!1;Blockly.WorkspaceSvg.superClass_.dispose.call(this);this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.svgBubbleCanvas_=this.svgBlockCanvas_=null;this.toolbox_&&(this.toolbox_.dispose(),this.toolbox_=null);this.flyout_&&(this.flyout_.dispose(),this.flyout_=null);this.trashcan&&(this.trashcan.dispose(),this.trashcan=null);this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null);this.zoomControls_&&
|
||||
(this.zoomControls_.dispose(),this.zoomControls_=null);this.options.parentWorkspace||goog.dom.removeNode(this.getParentSvg());this.resizeHandlerWrapper_&&(Blockly.unbindEvent_(this.resizeHandlerWrapper_),this.resizeHandlerWrapper_=null)};Blockly.WorkspaceSvg.prototype.newBlock=function(a,b){return new Blockly.BlockSvg(this,a,b)};
|
||||
Blockly.WorkspaceSvg.prototype.addTrashcan_=function(a){this.trashcan=new Blockly.Trashcan(this);var b=this.trashcan.createDom();this.svgGroup_.insertBefore(b,this.svgBlockCanvas_);return this.trashcan.init(a)};Blockly.WorkspaceSvg.prototype.addZoomControls_=function(a){this.zoomControls_=new Blockly.ZoomControls(this);var b=this.zoomControls_.createDom();this.svgGroup_.appendChild(b);return this.zoomControls_.init(a)};
|
||||
Blockly.WorkspaceSvg.prototype.addFlyout_=function(){this.flyout_=new Blockly.Flyout({disabledPatternId:this.options.disabledPatternId,parentWorkspace:this,RTL:this.RTL,horizontalLayout:this.horizontalLayout,toolboxPosition:this.options.toolboxPosition});this.flyout_.autoClose=!1;var a=this.flyout_.createDom();this.svgGroup_.insertBefore(a,this.svgBlockCanvas_)};Blockly.WorkspaceSvg.prototype.resizeContents=function(){this.scrollbar&&this.scrollbar.resize()};
|
||||
Blockly.WorkspaceSvg.prototype.resize=function(){this.toolbox_&&this.toolbox_.position();this.flyout_&&this.flyout_.position();this.trashcan&&this.trashcan.position();this.zoomControls_&&this.zoomControls_.position();this.scrollbar&&this.scrollbar.resize();this.recordDeleteAreas()};Blockly.WorkspaceSvg.prototype.getCanvas=function(){return this.svgBlockCanvas_};Blockly.WorkspaceSvg.prototype.getBubbleCanvas=function(){return this.svgBubbleCanvas_};
|
||||
Blockly.WorkspaceSvg.prototype.addFlyout_=function(){this.flyout_=new Blockly.Flyout({disabledPatternId:this.options.disabledPatternId,parentWorkspace:this,RTL:this.RTL,horizontalLayout:this.horizontalLayout,toolboxPosition:this.options.toolboxPosition});this.flyout_.autoClose=!1;var a=this.flyout_.createDom();this.svgGroup_.insertBefore(a,this.svgBlockCanvas_)};Blockly.WorkspaceSvg.prototype.resizeContents=function(){this.scrollbar&&this.scrollbar.resize();this.updateInverseScreenCTM()};
|
||||
Blockly.WorkspaceSvg.prototype.resize=function(){this.toolbox_&&this.toolbox_.position();this.flyout_&&this.flyout_.position();this.trashcan&&this.trashcan.position();this.zoomControls_&&this.zoomControls_.position();this.scrollbar&&this.scrollbar.resize();this.updateInverseScreenCTM();this.recordDeleteAreas()};Blockly.WorkspaceSvg.prototype.getCanvas=function(){return this.svgBlockCanvas_};Blockly.WorkspaceSvg.prototype.getBubbleCanvas=function(){return this.svgBubbleCanvas_};
|
||||
Blockly.WorkspaceSvg.prototype.getParentSvg=function(){if(this.cachedParentSvg_)return this.cachedParentSvg_;for(var a=this.svgGroup_;a;){if("svg"==a.tagName)return this.cachedParentSvg_=a;a=a.parentNode}return null};Blockly.WorkspaceSvg.prototype.translate=function(a,b){var c="translate("+a+","+b+") scale("+this.scale+")";this.svgBlockCanvas_.setAttribute("transform",c);this.svgBubbleCanvas_.setAttribute("transform",c)};
|
||||
Blockly.WorkspaceSvg.prototype.getWidth=function(){var a=this.getMetrics();return a?a.viewWidth/this.scale:0};Blockly.WorkspaceSvg.prototype.setVisible=function(a){this.getParentSvg().style.display=a?"block":"none";this.toolbox_&&(this.toolbox_.HtmlDiv.style.display=a?"block":"none");a?(this.render(),this.toolbox_&&this.toolbox_.position()):Blockly.hideChaff(!0)};Blockly.WorkspaceSvg.prototype.render=function(){for(var a=this.getAllBlocks(),b=a.length-1;0<=b;b--)a[b].render(!1)};
|
||||
Blockly.WorkspaceSvg.prototype.traceOn=function(a){this.traceOn_=a;this.traceWrapper_&&(Blockly.unbindEvent_(this.traceWrapper_),this.traceWrapper_=null);a&&(this.traceWrapper_=Blockly.bindEvent_(this.svgBlockCanvas_,"blocklySelectChange",this,function(){this.traceOn_=!1}))};
|
||||
@@ -1034,8 +1036,8 @@ Blockly.WorkspaceSvg.prototype.recordDeleteAreas=function(){this.deleteAreaTrash
|
||||
Blockly.WorkspaceSvg.prototype.isDeleteArea=function(a){a=new goog.math.Coordinate(a.clientX,a.clientY);if(this.deleteAreaTrash_){if(this.deleteAreaTrash_.contains(a))return this.trashcan.setOpen_(!0),Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;this.trashcan.setOpen_(!1)}if(this.deleteAreaToolbox_&&this.deleteAreaToolbox_.contains(a))return Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);return!1};
|
||||
Blockly.WorkspaceSvg.prototype.onMouseDown_=function(a){this.markFocused();Blockly.isTargetInput_(a)||(Blockly.terminateDrag_(),Blockly.hideChaff(),a.target&&a.target.nodeName&&("svg"==a.target.nodeName.toLowerCase()||a.target==this.svgBackground_)&&Blockly.selected&&!this.options.readOnly&&Blockly.selected.unselect(),Blockly.isRightButton(a)?this.showContextMenu_(a):this.scrollbar&&(this.isScrolling=!0,this.startDragMouseX=a.clientX,this.startDragMouseY=a.clientY,this.startDragMetrics=this.getMetrics(),
|
||||
this.startScrollX=this.scrollX,this.startScrollY=this.scrollY,"mouseup"in Blockly.bindEvent_.TOUCH_MAP&&(Blockly.onTouchUpWrapper_=Blockly.onTouchUpWrapper_||[],Blockly.onTouchUpWrapper_=Blockly.onTouchUpWrapper_.concat(Blockly.bindEvent_(document,"mouseup",null,Blockly.onMouseUp_))),Blockly.onMouseMoveWrapper_=Blockly.onMouseMoveWrapper_||[],Blockly.onMouseMoveWrapper_=Blockly.onMouseMoveWrapper_.concat(Blockly.bindEvent_(document,"mousemove",null,Blockly.onMouseMove_))),a.stopPropagation(),a.preventDefault())};
|
||||
Blockly.WorkspaceSvg.prototype.startDrag=function(a,b){var c=Blockly.mouseToSvg(a,this.getParentSvg());c.x/=this.scale;c.y/=this.scale;this.dragDeltaXY_=goog.math.Coordinate.difference(b,c)};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.mouseToSvg(a,this.getParentSvg());a.x/=this.scale;a.y/=this.scale;return goog.math.Coordinate.sum(this.dragDeltaXY_,a)};
|
||||
Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){Blockly.terminateDrag_();var b=0<a.deltaY?-1:1,c=Blockly.mouseToSvg(a,this.getParentSvg());this.zoom(c.x,c.y,b);a.preventDefault()};
|
||||
Blockly.WorkspaceSvg.prototype.startDrag=function(a,b){var c=Blockly.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());c.x/=this.scale;c.y/=this.scale;this.dragDeltaXY_=goog.math.Coordinate.difference(b,c)};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());a.x/=this.scale;a.y/=this.scale;return goog.math.Coordinate.sum(this.dragDeltaXY_,a)};
|
||||
Blockly.WorkspaceSvg.prototype.isDragging=function(){return Blockly.dragMode_==Blockly.DRAG_FREE||this.isScrolling};Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){Blockly.terminateDrag_();var b=0<a.deltaY?-1:1,c=Blockly.mouseToSvg(a,this.getParentSvg(),this.getInverseScreenCTM());this.zoom(c.x,c.y,b);a.preventDefault()};
|
||||
Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox=function(){var a=this.getTopBlocks();if(!a.length)return{x:0,y:0,width:0,height:0};for(var b=a[0].getBoundingRectangle(),c=1;c<a.length;c++){var d=a[c].getBoundingRectangle();d.topLeft.x<b.topLeft.x&&(b.topLeft.x=d.topLeft.x);d.bottomRight.x>b.bottomRight.x&&(b.bottomRight.x=d.bottomRight.x);d.topLeft.y<b.topLeft.y&&(b.topLeft.y=d.topLeft.y);d.bottomRight.y>b.bottomRight.y&&(b.bottomRight.y=d.bottomRight.y)}return{x:b.topLeft.x,y:b.topLeft.y,width:b.bottomRight.x-
|
||||
b.topLeft.x,height:b.bottomRight.y-b.topLeft.y}};Blockly.WorkspaceSvg.prototype.cleanUp_=function(){Blockly.Events.setGroup(!0);for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.Events.setGroup(!1);Blockly.resizeSvgContents(this)};
|
||||
Blockly.WorkspaceSvg.prototype.showContextMenu_=function(a){function b(a){if(a.isDeletable())l=l.concat(a.getDescendants());else{a=a.getChildren();for(var c=0;c<a.length;c++)b(a[c])}}function c(){Blockly.Events.setGroup(f);var a=l.shift();a&&(a.workspace?(a.dispose(!1,!0),setTimeout(c,10)):c());Blockly.Events.setGroup(!1)}if(!this.options.readOnly&&!this.isFlyout){var d=[],e=this.getTopBlocks(!0),f=Blockly.genUid(),g={};g.text=Blockly.Msg.UNDO;g.enabled=0<this.undoStack_.length;g.callback=this.undo.bind(this,
|
||||
@@ -1097,10 +1099,10 @@ Blockly.Block.prototype.toString=function(a){var b=[];if(this.collapsed_)b.push(
|
||||
Blockly.Block.prototype.appendStatementInput=function(a){return this.appendInput_(Blockly.NEXT_STATEMENT,a)};Blockly.Block.prototype.appendDummyInput=function(a){return this.appendInput_(Blockly.DUMMY_INPUT,a||"")};
|
||||
Blockly.Block.prototype.jsonInit=function(a){goog.asserts.assert(void 0==a.output||void 0==a.previousStatement,"Must not have both an output and a previousStatement.");void 0!==a.colour&&this.setColour(a.colour);for(var b=0;void 0!==a["message"+b];)this.interpolate_(a["message"+b],a["args"+b]||[],a["lastDummyAlign"+b]),b++;void 0!==a.inputsInline&&this.setInputsInline(a.inputsInline);void 0!==a.output&&this.setOutput(!0,a.output);void 0!==a.previousStatement&&this.setPreviousStatement(!0,a.previousStatement);
|
||||
void 0!==a.nextStatement&&this.setNextStatement(!0,a.nextStatement);void 0!==a.tooltip&&this.setTooltip(a.tooltip);void 0!==a.helpUrl&&this.setHelpUrl(a.helpUrl)};
|
||||
Blockly.Block.prototype.interpolate_=function(a,b,c){var d=Blockly.tokenizeInterpolation(a),e=[],f=0;a=[];for(var g=0;g<d.length;g++){var h=d[g];"number"==typeof h?(goog.asserts.assert(0<h&&h<=b.length,'Message index "%s" out of range.',h),goog.asserts.assert(!e[h],'Message index "%s" duplicated.',h),e[h]=!0,f++,a.push(b[h-1])):(h=h.trim())&&a.push(h)}goog.asserts.assert(f==b.length,"Message does not reference all %s arg(s).",b.length);!a.length||"string"!=typeof a[a.length-1]&&0!=a[a.length-1].type.indexOf("field_")||
|
||||
(g={type:"input_dummy"},c&&(g.align=c),a.push(g));c={LEFT:Blockly.ALIGN_LEFT,RIGHT:Blockly.ALIGN_RIGHT,CENTRE:Blockly.ALIGN_CENTRE};b=[];for(g=0;g<a.length;g++)if(e=a[g],"string"==typeof e)b.push([e,void 0]);else{d=f=null;do switch(h=!1,e.type){case "input_value":d=this.appendValueInput(e.name);break;case "input_statement":d=this.appendStatementInput(e.name);break;case "input_dummy":d=this.appendDummyInput(e.name);break;case "field_label":f=new Blockly.FieldLabel(e.text,e["class"]);break;case "field_input":f=
|
||||
new Blockly.FieldTextInput(e.text);"boolean"==typeof e.spellcheck&&f.setSpellcheck(e.spellcheck);break;case "field_angle":f=new Blockly.FieldAngle(e.angle);break;case "field_checkbox":f=new Blockly.FieldCheckbox(e.checked?"TRUE":"FALSE");break;case "field_colour":f=new Blockly.FieldColour(e.colour);break;case "field_variable":f=new Blockly.FieldVariable(e.variable);break;case "field_dropdown":f=new Blockly.FieldDropdown(e.options);break;case "field_image":f=new Blockly.FieldImage(e.src,e.width,e.height,
|
||||
e.alt);break;case "field_number":f=new Blockly.FieldNumber(e.value);f.setPrecision(e.precision);f.setMin(e.min);f.setMax(e.max);break;case "field_date":if(Blockly.FieldDate){f=new Blockly.FieldDate(e.date);break}default:e.alt&&(e=e.alt,h=!0)}while(h);if(f)b.push([f,e.name]);else if(d){e.check&&d.setCheck(e.check);e.align&&d.setAlign(c[e.align]);for(e=0;e<b.length;e++)d.appendField(b[e][0],b[e][1]);b.length=0}}};
|
||||
Blockly.Block.prototype.interpolate_=function(a,b,c){var d=Blockly.utils.tokenizeInterpolation(a),e=[],f=0;a=[];for(var g=0;g<d.length;g++){var h=d[g];"number"==typeof h?(goog.asserts.assert(0<h&&h<=b.length,'Message index "%s" out of range.',h),goog.asserts.assert(!e[h],'Message index "%s" duplicated.',h),e[h]=!0,f++,a.push(b[h-1])):(h=h.trim())&&a.push(h)}goog.asserts.assert(f==b.length,"Message does not reference all %s arg(s).",b.length);!a.length||"string"!=typeof a[a.length-1]&&0!=a[a.length-
|
||||
1].type.indexOf("field_")||(g={type:"input_dummy"},c&&(g.align=c),a.push(g));c={LEFT:Blockly.ALIGN_LEFT,RIGHT:Blockly.ALIGN_RIGHT,CENTRE:Blockly.ALIGN_CENTRE};b=[];for(g=0;g<a.length;g++)if(e=a[g],"string"==typeof e)b.push([e,void 0]);else{d=f=null;do switch(h=!1,e.type){case "input_value":d=this.appendValueInput(e.name);break;case "input_statement":d=this.appendStatementInput(e.name);break;case "input_dummy":d=this.appendDummyInput(e.name);break;case "field_label":f=new Blockly.FieldLabel(e.text,
|
||||
e["class"]);break;case "field_input":f=new Blockly.FieldTextInput(e.text);"boolean"==typeof e.spellcheck&&f.setSpellcheck(e.spellcheck);break;case "field_angle":f=new Blockly.FieldAngle(e.angle);break;case "field_checkbox":f=new Blockly.FieldCheckbox(e.checked?"TRUE":"FALSE");break;case "field_colour":f=new Blockly.FieldColour(e.colour);break;case "field_variable":f=new Blockly.FieldVariable(e.variable);break;case "field_dropdown":f=new Blockly.FieldDropdown(e.options);break;case "field_image":f=
|
||||
new Blockly.FieldImage(e.src,e.width,e.height,e.alt);break;case "field_number":f=new Blockly.FieldNumber(e.value,e.min,e.max,e.precision);break;case "field_date":if(Blockly.FieldDate){f=new Blockly.FieldDate(e.date);break}default:e.alt&&(e=e.alt,h=!0)}while(h);if(f)b.push([f,e.name]);else if(d){e.check&&d.setCheck(e.check);e.align&&d.setAlign(c[e.align]);for(e=0;e<b.length;e++)d.appendField(b[e][0],b[e][1]);b.length=0}}};
|
||||
Blockly.Block.prototype.appendInput_=function(a,b){var c=null;if(a==Blockly.INPUT_VALUE||a==Blockly.NEXT_STATEMENT)c=this.makeConnection_(a);c=new Blockly.Input(a,b,this,c);this.inputList.push(c);return c};
|
||||
Blockly.Block.prototype.moveInputBefore=function(a,b){if(a!=b){for(var c=-1,d=b?-1:this.inputList.length,e=0,f;f=this.inputList[e];e++)if(f.name==a){if(c=e,-1!=d)break}else if(b&&f.name==b&&(d=e,-1!=c))break;goog.asserts.assert(-1!=c,'Named input "%s" not found.',a);goog.asserts.assert(-1!=d,'Reference input "%s" not found.',b);this.moveNumberedInputBefore(c,d)}};
|
||||
Blockly.Block.prototype.moveNumberedInputBefore=function(a,b){goog.asserts.assert(a!=b,"Can't move input to itself.");goog.asserts.assert(a<this.inputList.length,"Input index "+a+" out of bounds.");goog.asserts.assert(b<=this.inputList.length,"Reference input "+b+" out of bounds.");var c=this.inputList[a];this.inputList.splice(a,1);a<b&&b--;this.inputList.splice(b,0,c)};
|
||||
@@ -1214,7 +1216,7 @@ Blockly.Events.filter=function(a,b){var c=goog.array.clone(a);b||c.reverse();for
|
||||
e.element&&"mutatorOpen"!=e.element&&"warningOpen"!=e.element||(e.newValue=g.newValue,c.splice(f,1),f--));for(d=c.length-1;0<=d;d--)c[d].isNull()&&c.splice(d,1);b||c.reverse();for(d=1;e=c[d];d++)e.type==Blockly.Events.CHANGE&&"mutation"==e.element&&c.unshift(c.splice(d,1)[0]);return c};Blockly.Events.clearPendingUndo=function(){for(var a=0,b;b=Blockly.Events.FIRE_QUEUE_[a];a++)b.recordUndo=!1};Blockly.Events.disable=function(){Blockly.Events.disabled_++};Blockly.Events.enable=function(){Blockly.Events.disabled_--};
|
||||
Blockly.Events.isEnabled=function(){return 0==Blockly.Events.disabled_};Blockly.Events.getGroup=function(){return Blockly.Events.group_};Blockly.Events.setGroup=function(a){Blockly.Events.group_="boolean"==typeof a?a?Blockly.genUid():"":a};Blockly.Events.getDescendantIds_=function(a){var b=[];a=a.getDescendants();for(var c=0,d;d=a[c];c++)b[c]=d.id;return b};
|
||||
Blockly.Events.fromJson=function(a,b){var c;switch(a.type){case Blockly.Events.CREATE:c=new Blockly.Events.Create(null);break;case Blockly.Events.DELETE:c=new Blockly.Events.Delete(null);break;case Blockly.Events.CHANGE:c=new Blockly.Events.Change(null);break;case Blockly.Events.MOVE:c=new Blockly.Events.Move(null);break;case Blockly.Events.UI:c=new Blockly.Events.Ui(null);break;default:throw"Unknown event type.";}c.fromJson(a);c.workspaceId=b.id;return c};
|
||||
Blockly.Events.Abstract=function(a){a&&(this.blockId=a.id,this.workspaceId=a.workspace.id);this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.Events.Abstract.prototype.toJson=function(){var a={type:this.type,blockId:this.blockId};this.group&&(a.group=this.group);return a};Blockly.Events.Abstract.prototype.fromJson=function(a){this.blockId=a.blockId;this.group=a.group};Blockly.Events.Abstract.prototype.isNull=function(){return!1};
|
||||
Blockly.Events.Abstract=function(a){a&&(this.blockId=a.id,this.workspaceId=a.workspace.id);this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.Events.Abstract.prototype.toJson=function(){var a={type:this.type};this.blockId&&(a.blockId=this.blockId);this.group&&(a.group=this.group);return a};Blockly.Events.Abstract.prototype.fromJson=function(a){this.blockId=a.blockId;this.group=a.group};Blockly.Events.Abstract.prototype.isNull=function(){return!1};
|
||||
Blockly.Events.Abstract.prototype.run=function(a){};Blockly.Events.Create=function(a){a&&(Blockly.Events.Create.superClass_.constructor.call(this,a),this.xml=Blockly.Xml.blockToDomWithXY(a),this.ids=Blockly.Events.getDescendantIds_(a))};goog.inherits(Blockly.Events.Create,Blockly.Events.Abstract);Blockly.Events.Create.prototype.type=Blockly.Events.CREATE;
|
||||
Blockly.Events.Create.prototype.toJson=function(){var a=Blockly.Events.Create.superClass_.toJson.call(this);a.xml=Blockly.Xml.domToText(this.xml);a.ids=this.ids;return a};Blockly.Events.Create.prototype.fromJson=function(a){Blockly.Events.Create.superClass_.fromJson.call(this,a);this.xml=Blockly.Xml.textToDom("<xml>"+a.xml+"</xml>").firstChild;this.ids=a.ids};
|
||||
Blockly.Events.Create.prototype.run=function(a){var b=Blockly.Workspace.getById(this.workspaceId);if(a)a=goog.dom.createDom("xml"),a.appendChild(this.xml),Blockly.Xml.domToWorkspace(a,b);else{a=0;for(var c;c=this.ids[a];a++){var d=b.getBlockById(c);d?d.dispose(!1,!1):c==this.blockId&&console.warn("Can't uncreate non-existant block: "+c)}}};
|
||||
@@ -1271,9 +1273,9 @@ Blockly.FieldDropdown.prototype.setText=function(a){this.sourceBlock_&&this.arro
|
||||
Blockly.FieldDropdown.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldDropdown.superClass_.dispose.call(this)};Blockly.FieldImage=function(a,b,c,d){this.sourceBlock_=null;this.height_=Number(c);this.width_=Number(b);this.size_=new goog.math.Size(this.width_,this.height_+2*Blockly.BlockSvg.INLINE_PADDING_Y);this.text_=d||"";this.setValue(a)};goog.inherits(Blockly.FieldImage,Blockly.Field);Blockly.FieldImage.prototype.rectElement_=null;Blockly.FieldImage.prototype.EDITABLE=!1;
|
||||
Blockly.FieldImage.prototype.init=function(){if(!this.fieldGroup_){this.fieldGroup_=Blockly.createSvgElement("g",{},null);this.visible_||(this.fieldGroup_.style.display="none");this.imageElement_=Blockly.createSvgElement("image",{height:this.height_+"px",width:this.width_+"px"},this.fieldGroup_);this.setValue(this.src_);goog.userAgent.GECKO&&(this.rectElement_=Blockly.createSvgElement("rect",{height:this.height_+"px",width:this.width_+"px","fill-opacity":0},this.fieldGroup_));this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||
var a=this.rectElement_||this.imageElement_;a.tooltip=this.sourceBlock_;Blockly.Tooltip.bindMouseEvents(a)}};Blockly.FieldImage.prototype.dispose=function(){goog.dom.removeNode(this.fieldGroup_);this.rectElement_=this.imageElement_=this.fieldGroup_=null};Blockly.FieldImage.prototype.setTooltip=function(a){(this.rectElement_||this.imageElement_).tooltip=a};Blockly.FieldImage.prototype.getValue=function(){return this.src_};
|
||||
Blockly.FieldImage.prototype.setValue=function(a){null!==a&&(this.src_=a,this.imageElement_&&this.imageElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",goog.isString(a)?a:""))};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.text_=a)};Blockly.FieldImage.prototype.render_=function(){};Blockly.FieldNumber=function(a,b){Blockly.FieldNumber.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldNumber,Blockly.FieldTextInput);Blockly.FieldNumber.prototype.precision_=0;Blockly.FieldNumber.prototype.min_=-Infinity;Blockly.FieldNumber.prototype.max_=Infinity;Blockly.FieldNumber.prototype.setPrecision=function(a){a=parseFloat(a);isNaN(a)||(this.precision_=a)};Blockly.FieldNumber.prototype.setMin=function(a){a=parseFloat(a);isNaN(a)||(this.min_=a)};
|
||||
Blockly.FieldNumber.prototype.setMax=function(a){a=parseFloat(a);isNaN(a)||(this.max_=a)};Blockly.FieldNumber.prototype.setValidator=function(a){Blockly.FieldNumber.superClass_.setValidator.call(this,a?function(b){var c=a.call(this,b);if(null===c)var d=c;else void 0===c&&(c=b),d=Blockly.FieldNumber.numberValidator.call(this,c),void 0===d&&(d=c);return d===b?void 0:d}:Blockly.FieldNumber.numberValidator)};
|
||||
Blockly.FieldNumber.numberValidator=function(a){if(null===a)return null;a=String(a);a=a.replace(/O/ig,"0");a=a.replace(/,/g,"");a=parseFloat(a||0);if(isNaN(a))return null;this.precision_&&Number.isFinite(a)&&(a=Math.round(a/this.precision_)*this.precision_);a=goog.math.clamp(a,this.min_,this.max_);return String(a)};Blockly.Variables={};Blockly.Variables.NAME_TYPE="VARIABLE";Blockly.Variables.allVariables=function(a){var b;if(a.getDescendants)b=a.getDescendants();else if(a.getAllBlocks)b=a.getAllBlocks();else throw"Not Block or Workspace: "+a;a=Object.create(null);for(var c=0;c<b.length;c++)for(var d=b[c].getVars(),e=0;e<d.length;e++){var f=d[e];f&&(a[f.toLowerCase()]=f)}b=[];for(var g in a)b.push(a[g]);return b};
|
||||
Blockly.FieldImage.prototype.setValue=function(a){null!==a&&(this.src_=a,this.imageElement_&&this.imageElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",goog.isString(a)?a:""))};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.text_=a)};Blockly.FieldImage.prototype.render_=function(){};Blockly.FieldNumber=function(a,b,c,d,e){Blockly.FieldNumber.superClass_.constructor.call(this,a,e);this.setConstraints(b,c,d)};goog.inherits(Blockly.FieldNumber,Blockly.FieldTextInput);Blockly.FieldNumber.prototype.setConstraints=function(a,b,c){c=parseFloat(c);this.precision_=isNaN(c)?0:c;a=parseFloat(a);this.min_=isNaN(a)?-Infinity:a;b=parseFloat(b);this.max_=isNaN(b)?Infinity:b;this.setValue(this.numberValidator(this.getValue))};
|
||||
Blockly.FieldNumber.prototype.setValidator=function(a){Blockly.FieldNumber.superClass_.setValidator.call(this,a?function(b){var c=a.call(this,b);if(null===c)var d=c;else void 0===c&&(c=b),d=this.numberValidator(c),void 0===d&&(d=c);return d===b?void 0:d}:this.numberValidator)};
|
||||
Blockly.FieldNumber.prototype.numberValidator=function(a){if(null===a)return null;a=String(a);a=a.replace(/O/ig,"0");a=a.replace(/,/g,"");a=parseFloat(a||0);if(isNaN(a))return null;this.precision_&&Number.isFinite(a)&&(a=Math.round(a/this.precision_)*this.precision_);a=goog.math.clamp(a,this.min_,this.max_);return String(a)};Blockly.Variables={};Blockly.Variables.NAME_TYPE="VARIABLE";Blockly.Variables.allVariables=function(a){var b;if(a.getDescendants)b=a.getDescendants();else if(a.getAllBlocks)b=a.getAllBlocks();else throw"Not Block or Workspace: "+a;a=Object.create(null);for(var c=0;c<b.length;c++)for(var d=b[c].getVars(),e=0;e<d.length;e++){var f=d[e];f&&(a[f.toLowerCase()]=f)}b=[];for(var g in a)b.push(a[g]);return b};
|
||||
Blockly.Variables.renameVariable=function(a,b,c){Blockly.Events.setGroup(!0);c=c.getAllBlocks();for(var d=0;d<c.length;d++)c[d].renameVar(a,b);Blockly.Events.setGroup(!1)};
|
||||
Blockly.Variables.flyoutCategory=function(a){a=Blockly.Variables.allVariables(a);a.sort(goog.string.caseInsensitiveCompare);goog.array.remove(a,Blockly.Msg.VARIABLES_DEFAULT_NAME);a.unshift(Blockly.Msg.VARIABLES_DEFAULT_NAME);var b=[],c=goog.dom.createDom("button");c.setAttribute("text","Create variable");b.push(c);for(c=0;c<a.length;c++){if(Blockly.Blocks.variables_set){var d=goog.dom.createDom("block");d.setAttribute("type","variables_set");Blockly.Blocks.variables_get&&d.setAttribute("gap",8);
|
||||
var e=goog.dom.createDom("field",null,a[c]);e.setAttribute("name","VAR");d.appendChild(e);b.push(d)}Blockly.Blocks.variables_get&&(d=goog.dom.createDom("block"),d.setAttribute("type","variables_get"),Blockly.Blocks.variables_set&&d.setAttribute("gap",24),e=goog.dom.createDom("field",null,a[c]),e.setAttribute("name","VAR"),d.appendChild(e),b.push(d))}return b};
|
||||
@@ -1299,15 +1301,15 @@ Blockly.Procedures.flyoutCategory=function(a){function b(a,b){for(var d=0;d<a.le
|
||||
d.setAttribute("gap",16);c.push(d)}Blockly.Blocks.procedures_defreturn&&(d=goog.dom.createDom("block"),d.setAttribute("type","procedures_defreturn"),d.setAttribute("gap",16),c.push(d));Blockly.Blocks.procedures_ifreturn&&(d=goog.dom.createDom("block"),d.setAttribute("type","procedures_ifreturn"),d.setAttribute("gap",16),c.push(d));c.length&&c[c.length-1].setAttribute("gap",24);a=Blockly.Procedures.allProcedures(a);b(a[0],"procedures_callnoreturn");b(a[1],"procedures_callreturn");return c};
|
||||
Blockly.Procedures.getCallers=function(a,b){for(var c=[],d=b.getAllBlocks(),e=0;e<d.length;e++)if(d[e].getProcedureCall){var f=d[e].getProcedureCall();f&&Blockly.Names.equals(f,a)&&c.push(d[e])}return c};Blockly.Procedures.disposeCallers=function(a,b){for(var c=Blockly.Procedures.getCallers(a,b),d=0;d<c.length;d++)c[d].dispose(!0,!1)};
|
||||
Blockly.Procedures.mutateCallers=function(a){var b=Blockly.Events.recordUndo,c=a.getProcedureDef()[0],d=a.mutationToDom(!0);a=Blockly.Procedures.getCallers(c,a.workspace);for(var c=0,e;e=a[c];c++){var f=e.mutationToDom(),f=f&&Blockly.Xml.domToText(f);e.domToMutation(d);var g=e.mutationToDom(),g=g&&Blockly.Xml.domToText(g);f!=g&&(Blockly.Events.recordUndo=!1,Blockly.Events.fire(new Blockly.Events.Change(e,"mutation",null,f,g)),Blockly.Events.recordUndo=b)}};
|
||||
Blockly.Procedures.getDefinition=function(a,b){for(var c=b.getAllBlocks(),d=0;d<c.length;d++)if(c[d].getProcedureDef){var e=c[d].getProcedureDef();if(e&&Blockly.Names.equals(e[0],a))return c[d]}return null};Blockly.FlyoutButton=function(a){this.workspace_=a};Blockly.FlyoutButton.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyFlyoutButton"},null);this.height=16;this.width=40;Blockly.createSvgElement("rect",{"class":"blocklyIconShape",rx:"4",ry:"4",height:this.height,width:this.width},this.svgGroup_);return this.svgGroup_};Blockly.FlyoutButton.prototype.show=function(){this.svgGroup_.setAttribute("display","block")};
|
||||
Blockly.FlyoutButton.prototype.moveTo=function(a,b){this.svgGroup_.setAttribute("transform","translate("+a+","+b+")")};Blockly.Flyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new Blockly.WorkspaceSvg(a);this.workspace_.isFlyout=!0;this.RTL=!!a.RTL;this.horizontalLayout_=a.horizontalLayout;this.toolboxPosition_=a.toolboxPosition;this.eventWrappers_=[];this.buttons_=[];this.listeners_=[];this.permanentlyDisabled_=[]};Blockly.Flyout.prototype.autoClose=!0;Blockly.Flyout.prototype.CORNER_RADIUS=8;Blockly.Flyout.prototype.MARGIN=Blockly.Flyout.prototype.CORNER_RADIUS;
|
||||
Blockly.Flyout.prototype.SCROLLBAR_PADDING=2;Blockly.Flyout.prototype.width_=0;Blockly.Flyout.prototype.height_=0;Blockly.Flyout.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyFlyout"},null);this.svgBackground_=Blockly.createSvgElement("path",{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());return this.svgGroup_};
|
||||
Blockly.Procedures.getDefinition=function(a,b){for(var c=b.getAllBlocks(),d=0;d<c.length;d++)if(c[d].getProcedureDef){var e=c[d].getProcedureDef();if(e&&Blockly.Names.equals(e[0],a))return c[d]}return null};Blockly.FlyoutButton=function(a,b){this.workspace_=a;this.text_=b};Blockly.FlyoutButton.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyFlyoutButton"},this.workspace_.svgGroup_);this.height=16;this.width=40;Blockly.createSvgElement("rect",{"class":"blocklyIconShape",rx:"4",ry:"4",height:this.height,width:this.width},this.svgGroup_);Blockly.createSvgElement("text",{"class":"blocklyButtonText",x:"0",y:"0"},this.svgGroup_);return this.svgGroup_};
|
||||
Blockly.FlyoutButton.prototype.show=function(){this.svgGroup_.setAttribute("display","block")};Blockly.FlyoutButton.prototype.moveTo=function(a,b){this.svgGroup_.setAttribute("transform","translate("+a+","+b+")")};Blockly.FlyoutButton.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.workspace_=null};Blockly.FlyoutButton.prototype.click=function(){console.log("Go away")};Blockly.Flyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new Blockly.WorkspaceSvg(a);this.workspace_.isFlyout=!0;this.RTL=!!a.RTL;this.horizontalLayout_=a.horizontalLayout;this.toolboxPosition_=a.toolboxPosition;this.eventWrappers_=[];this.backgroundButtons_=[];this.buttons_=[];this.listeners_=[];this.permanentlyDisabled_=[]};Blockly.Flyout.prototype.autoClose=!0;Blockly.Flyout.prototype.CORNER_RADIUS=8;
|
||||
Blockly.Flyout.prototype.MARGIN=Blockly.Flyout.prototype.CORNER_RADIUS;Blockly.Flyout.prototype.SCROLLBAR_PADDING=2;Blockly.Flyout.prototype.width_=0;Blockly.Flyout.prototype.height_=0;Blockly.Flyout.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyFlyout"},null);this.svgBackground_=Blockly.createSvgElement("path",{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());return this.svgGroup_};
|
||||
Blockly.Flyout.prototype.init=function(a){this.targetWorkspace_=a;this.workspace_.targetWorkspace=a;this.scrollbar_=new Blockly.Scrollbar(this.workspace_,this.horizontalLayout_,!1);this.hide();Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.wheel_));this.autoClose||(this.filterWrapper_=this.filterForCapacity_.bind(this),this.targetWorkspace_.addChangeListener(this.filterWrapper_));Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.svgGroup_,
|
||||
"mousedown",this,this.onMouseDown_))};
|
||||
Blockly.Flyout.prototype.dispose=function(){this.hide();Blockly.unbindEvent_(this.eventWrappers_);this.filterWrapper_&&(this.targetWorkspace_.removeChangeListener(this.filterWrapper_),this.filterWrapper_=null);this.scrollbar_&&(this.scrollbar_.dispose(),this.scrollbar_=null);this.workspace_&&(this.workspace_.targetWorkspace=null,this.workspace_.dispose(),this.workspace_=null);this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.targetWorkspace_=this.svgBackground_=null};
|
||||
Blockly.Flyout.prototype.getWidth=function(){return this.width_};Blockly.Flyout.prototype.getHeight=function(){return this.height_};
|
||||
Blockly.Flyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;try{var a=this.workspace_.getCanvas().getBBox()}catch(f){a={height:0,y:0,width:0,x:0}}var b=this.SCROLLBAR_PADDING,c=this.SCROLLBAR_PADDING;if(this.horizontalLayout_){this.toolboxPosition_==Blockly.TOOLBOX_AT_BOTTOM&&(b=0);var d=this.height_;this.toolboxPosition_==Blockly.TOOLBOX_AT_TOP&&(d+=this.MARGIN-this.SCROLLBAR_PADDING);var e=this.width_-2*this.SCROLLBAR_PADDING}else c=0,d=this.height_-2*this.SCROLLBAR_PADDING,
|
||||
e=this.width_,this.RTL||(e-=this.SCROLLBAR_PADDING);return{viewHeight:d,viewWidth:e,contentHeight:(a.height+2*this.MARGIN)*this.workspace_.scale,contentWidth:(a.width+2*this.MARGIN)*this.workspace_.scale,viewTop:-this.workspace_.scrollY,viewLeft:-this.workspace_.scrollX,contentTop:0,contentLeft:0,absoluteTop:b,absoluteLeft:c}};
|
||||
e=this.width_,this.RTL||(e-=this.SCROLLBAR_PADDING);return{viewHeight:d,viewWidth:e,contentHeight:(a.height+2*this.MARGIN)*this.workspace_.scale,contentWidth:(a.width+2*this.MARGIN)*this.workspace_.scale,viewTop:-this.workspace_.scrollY,viewLeft:-this.workspace_.scrollX,contentTop:a.y,contentLeft:a.x,absoluteTop:b,absoluteLeft:c}};
|
||||
Blockly.Flyout.prototype.setMetrics_=function(a){var b=this.getMetrics_();b&&(!this.horizontalLayout_&&goog.isNumber(a.y)?this.workspace_.scrollY=-b.contentHeight*a.y:this.horizontalLayout_&&goog.isNumber(a.x)&&(this.workspace_.scrollX=-b.contentWidth*a.x),this.workspace_.translate(this.workspace_.scrollX+b.absoluteLeft,this.workspace_.scrollY+b.absoluteTop))};
|
||||
Blockly.Flyout.prototype.position=function(){if(this.isVisible()){var a=this.targetWorkspace_.getMetrics();if(a){var b=this.horizontalLayout_?a.viewWidth:this.width_,b=b-this.CORNER_RADIUS;this.toolboxPosition_==Blockly.TOOLBOX_AT_RIGHT&&(b*=-1);this.setBackgroundPath_(b,this.horizontalLayout_?this.height_:a.viewHeight);b=a.absoluteLeft;this.toolboxPosition_==Blockly.TOOLBOX_AT_RIGHT&&(b+=a.viewWidth,b-=this.width_);var c=a.absoluteTop;this.toolboxPosition_==Blockly.TOOLBOX_AT_BOTTOM&&(c+=a.viewHeight,
|
||||
c-=this.height_);this.svgGroup_.setAttribute("transform","translate("+b+","+c+")");this.horizontalLayout_?this.width_=a.viewWidth:this.height_=a.viewHeight;this.scrollbar_&&this.scrollbar_.resize()}}};Blockly.Flyout.prototype.setBackgroundPath_=function(a,b){this.horizontalLayout_?this.setBackgroundPathHorizontal_(a,b):this.setBackgroundPathVertical_(a,b)};
|
||||
@@ -1318,16 +1320,16 @@ Blockly.Flyout.prototype.setBackgroundPathHorizontal_=function(a,b){var c=this.t
|
||||
Blockly.Flyout.prototype.wheel_=function(a){var b=this.horizontalLayout_?a.deltaX:a.deltaY;if(b){goog.userAgent.GECKO&&(b*=10);var c=this.getMetrics_(),b=this.horizontalLayout_?c.viewLeft+b:c.viewTop+b,b=Math.min(b,this.horizontalLayout_?c.contentWidth-c.viewWidth:c.contentHeight-c.viewHeight),b=Math.max(b,0);this.scrollbar_.set(b)}a.preventDefault();a.stopPropagation()};Blockly.Flyout.prototype.isVisible=function(){return this.svgGroup_&&"block"==this.svgGroup_.style.display};
|
||||
Blockly.Flyout.prototype.hide=function(){if(this.isVisible()){this.svgGroup_.style.display="none";for(var a=0,b;b=this.listeners_[a];a++)Blockly.unbindEvent_(b);this.listeners_.length=0;this.reflowWrapper_&&(this.workspace_.removeChangeListener(this.reflowWrapper_),this.reflowWrapper_=null)}};
|
||||
Blockly.Flyout.prototype.show=function(a){this.hide();this.clearOldBlocks_();a==Blockly.Variables.NAME_TYPE?a=Blockly.Variables.flyoutCategory(this.workspace_.targetWorkspace):a==Blockly.Procedures.NAME_TYPE&&(a=Blockly.Procedures.flyoutCategory(this.workspace_.targetWorkspace));this.svgGroup_.style.display="block";for(var b=[],c=[],d=this.permanentlyDisabled_.length=0,e;e=a[d];d++)if(e.tagName){var f=e.tagName.toUpperCase();"BLOCK"==f?(f=Blockly.Xml.domToBlock(e,this.workspace_),f.disabled&&this.permanentlyDisabled_.push(f),
|
||||
b.push({type:"block",block:f}),e=parseInt(e.getAttribute("gap"),10),c.push(isNaN(e)?3*this.MARGIN:e)):"BUTTON"==f&&(b.push({type:"button",label:e.getAttribute("text")}),c.push(this.MARGIN))}this.layoutBlocks_(b,c);this.listeners_.push(Blockly.bindEvent_(this.svgBackground_,"mouseover",this,function(){for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++)c.removeSelect()}));this.horizontalLayout_?this.height_=0:this.width_=0;this.reflow();this.offsetHorizontalRtlBlocks(this.workspace_.getTopBlocks(!1));
|
||||
this.filterForCapacity_();this.position();this.reflowWrapper_=this.reflow.bind(this);this.workspace_.addChangeListener(this.reflowWrapper_)};
|
||||
Blockly.Flyout.prototype.layoutBlocks_=function(a,b){for(var c=this.MARGIN*this.workspace_.scale,d=this.RTL?c:c+Blockly.BlockSvg.TAB_WIDTH,e=0,f;f=a[e];e++)if("block"==f.type){f=f.block;for(var g=f.getDescendants(),h=0,k;k=g[h];h++)k.isInFlyout=!0;f.render();g=f.getSvgRoot();h=f.getHeightWidth();k=f.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0;this.horizontalLayout_&&(d+=k);f.moveBy(this.horizontalLayout_&&this.RTL?-d:d,c);this.horizontalLayout_?d+=h.width+b[e]-k:c+=h.height+b[e];h=Blockly.createSvgElement("rect",
|
||||
{"fill-opacity":0},null);h.tooltip=f;Blockly.Tooltip.bindMouseEvents(h);this.workspace_.getCanvas().insertBefore(h,f.getSvgRoot());f.flyoutRect_=h;this.buttons_[e]=h;this.addBlockListeners_(g,f,h)}else"button"==f.type&&(f=new FlyoutButton(this.workspace_),f.createDom(),f.show(),f.moveTo(d,c),this.horizontalLayout_?d+=f.width+b[e]:c+=f.height+b[e])};
|
||||
Blockly.Flyout.prototype.clearOldBlocks_=function(){for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++)c.workspace==this.workspace_&&c.dispose(!1,!1);for(a=0;b=this.buttons_[a];a++)goog.dom.removeNode(b);this.buttons_.length=0};
|
||||
b.push({type:"block",block:f}),e=parseInt(e.getAttribute("gap"),10),c.push(isNaN(e)?3*this.MARGIN:e)):"BUTTON"==f&&(b.push({type:"button",label:e.getAttribute("text")}),c.push(this.MARGIN))}this.layoutBlocks_(b,c);this.listeners_.push(Blockly.bindEvent_(this.svgBackground_,"mouseover",this,function(){for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++)c.removeSelect()}));this.horizontalLayout_?this.height_=0:this.width_=0;this.reflow();this.filterForCapacity_();this.position();this.reflowWrapper_=
|
||||
this.reflow.bind(this);this.workspace_.addChangeListener(this.reflowWrapper_)};
|
||||
Blockly.Flyout.prototype.layoutBlocks_=function(a,b){var c=this.MARGIN,d=this.RTL?c:c+Blockly.BlockSvg.TAB_WIDTH;this.horizontalLayout_&&this.RTL&&(a=a.reverse());for(var e=0,f;f=a[e];e++)if("block"==f.type){f=f.block;for(var g=f.getDescendants(),h=0,k;k=g[h];h++)k.isInFlyout=!0;f.render();g=f.getSvgRoot();h=f.getHeightWidth();k=f.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0;this.horizontalLayout_&&(d+=k);f.moveBy(this.horizontalLayout_&&this.RTL?-d:d,c);this.horizontalLayout_?d+=h.width+b[e]-k:
|
||||
c+=h.height+b[e];h=Blockly.createSvgElement("rect",{"fill-opacity":0},null);h.tooltip=f;Blockly.Tooltip.bindMouseEvents(h);this.workspace_.getCanvas().insertBefore(h,f.getSvgRoot());f.flyoutRect_=h;this.backgroundButtons_[e]=h;this.addBlockListeners_(g,f,h)}else"button"==f.type&&(f=new Blockly.FlyoutButton(this.workspace_,f.text),g=f.createDom(),f.show(),f.moveTo(d,c),Blockly.bindEvent_(g,"mouseup",f,f.click),this.buttons_.push(f),this.horizontalLayout_?d+=f.width+b[e]:c+=f.height+b[e])};
|
||||
Blockly.Flyout.prototype.clearOldBlocks_=function(){for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++)c.workspace==this.workspace_&&c.dispose(!1,!1);for(b=0;a=this.backgroundButtons_[b];b++)goog.dom.removeNode(a);for(b=this.backgroundButtons_.length=0;a=this.buttons_[b];b++)a.dispose();this.buttons_.length};
|
||||
Blockly.Flyout.prototype.addBlockListeners_=function(a,b,c){this.autoClose?(this.listeners_.push(Blockly.bindEvent_(a,"mousedown",null,this.createBlockFunc_(b))),this.listeners_.push(Blockly.bindEvent_(c,"mousedown",null,this.createBlockFunc_(b)))):(this.listeners_.push(Blockly.bindEvent_(a,"mousedown",null,this.blockMouseDown_(b))),this.listeners_.push(Blockly.bindEvent_(c,"mousedown",null,this.blockMouseDown_(b))));this.listeners_.push(Blockly.bindEvent_(a,"mouseover",b,b.addSelect));this.listeners_.push(Blockly.bindEvent_(a,
|
||||
"mouseout",b,b.removeSelect));this.listeners_.push(Blockly.bindEvent_(c,"mouseover",b,b.addSelect));this.listeners_.push(Blockly.bindEvent_(c,"mouseout",b,b.removeSelect))};
|
||||
Blockly.Flyout.prototype.blockMouseDown_=function(a){var b=this;return function(c){Blockly.terminateDrag_();Blockly.hideChaff();Blockly.isRightButton(c)?a.showContextMenu_(c):(Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED),Blockly.Flyout.startDownEvent_=c,Blockly.Flyout.startBlock_=a,Blockly.Flyout.startFlyout_=b,Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,b.onMouseUp_),Blockly.Flyout.onMouseMoveBlockWrapper_=Blockly.bindEvent_(document,"mousemove",this,b.onMouseMoveBlock_));
|
||||
c.stopPropagation()}};Blockly.Flyout.prototype.onMouseDown_=function(a){Blockly.isRightButton(a)||(Blockly.hideChaff(!0),Blockly.Flyout.terminateDrag_(),this.startDragMouseY_=a.clientY,this.startDragMouseX_=a.clientX,Blockly.Flyout.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_),Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.Flyout.terminateDrag_),a.preventDefault(),a.stopPropagation())};
|
||||
Blockly.Flyout.prototype.onMouseUp_=function(a){Blockly.dragMode_==Blockly.DRAG_FREE||Blockly.WidgetDiv.isVisible()||Blockly.Events.fire(new Blockly.Events.Ui(Blockly.Flyout.startBlock_,"click",void 0,void 0));Blockly.terminateDrag_()};
|
||||
Blockly.Flyout.prototype.onMouseUp_=function(a){this.workspace_.isDragging()||Blockly.WidgetDiv.isVisible()||Blockly.Events.fire(new Blockly.Events.Ui(Blockly.Flyout.startBlock_,"click",void 0,void 0));Blockly.terminateDrag_()};
|
||||
Blockly.Flyout.prototype.onMouseMove_=function(a){var b=this.getMetrics_();if(this.horizontalLayout_){if(!(0>b.contentWidth-b.viewWidth)){var c=a.clientX-this.startDragMouseX_;this.startDragMouseX_=a.clientX;a=b.viewLeft-c;a=goog.math.clamp(a,0,b.contentWidth-b.viewWidth);this.scrollbar_.set(a)}}else 0>b.contentHeight-b.viewHeight||(c=a.clientY-this.startDragMouseY_,this.startDragMouseY_=a.clientY,a=b.viewTop-c,a=goog.math.clamp(a,0,b.contentHeight-b.viewHeight),this.scrollbar_.set(a))};
|
||||
Blockly.Flyout.prototype.onMouseMoveBlock_=function(a){if("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)a.stopPropagation();else{var b=a.clientX-Blockly.Flyout.startDownEvent_.clientX;a=a.clientY-Blockly.Flyout.startDownEvent_.clientY;Math.sqrt(b*b+a*a)>Blockly.DRAG_RADIUS&&Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(Blockly.Flyout.startDownEvent_)}};
|
||||
Blockly.Flyout.prototype.createBlockFunc_=function(a){var b=this;return function(c){if(!Blockly.isRightButton(c)&&!a.disabled){Blockly.Events.disable();var d=b.placeNewBlock_(a);Blockly.Events.enable();Blockly.Events.isEnabled()&&(Blockly.Events.setGroup(!0),Blockly.Events.fire(new Blockly.Events.Create(d)));b.autoClose?b.hide():b.filterForCapacity_();d.onMouseDown_(c);Blockly.dragMode_=Blockly.DRAG_FREE;d.setDragging_(!0)}}};
|
||||
@@ -1339,10 +1341,9 @@ Blockly.Flyout.terminateDrag_=function(){Blockly.Flyout.onMouseUpWrapper_&&(Bloc
|
||||
Blockly.Flyout.onMouseUpWrapper_=null);Blockly.Flyout.startDownEvent_=null;Blockly.Flyout.startBlock_=null;Blockly.Flyout.startFlyout_=null};
|
||||
Blockly.Flyout.prototype.reflowHorizontal=function(a){this.workspace_.scale=this.targetWorkspace_.scale;for(var b=0,c=0,d;d=a[c];c++)b=Math.max(b,d.getHeightWidth().height);b+=1.5*this.MARGIN;b*=this.workspace_.scale;b+=Blockly.Scrollbar.scrollbarThickness;if(this.height_!=b){for(c=0;d=a[c];c++){var e=d.getHeightWidth();if(d.flyoutRect_){d.flyoutRect_.setAttribute("width",e.width);d.flyoutRect_.setAttribute("height",e.height);var f=d.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0,g=d.getRelativeToSurfaceXY();
|
||||
d.flyoutRect_.setAttribute("y",g.y);d.flyoutRect_.setAttribute("x",this.RTL?g.x-e.width+f:g.x-f);(e=d.startHat_?Blockly.BlockSvg.START_HAT_HEIGHT:0)&&d.moveBy(0,e);d.flyoutRect_.setAttribute("y",g.y)}}this.height_=b;this.targetWorkspace_.resize()}};
|
||||
Blockly.Flyout.prototype.reflowVertical=function(a){this.workspace_.scale=this.targetWorkspace_.scale;for(var b=0,c=0,d;d=a[c];c++){var e=d.getHeightWidth().width;d.outputConnection&&(e-=Blockly.BlockSvg.TAB_WIDTH);b=Math.max(b,e)}b+=1.5*this.MARGIN+Blockly.BlockSvg.TAB_WIDTH;b*=this.workspace_.scale;b+=Blockly.Scrollbar.scrollbarThickness;if(this.width_!=b){for(c=0;d=a[c];c++){e=d.getHeightWidth();if(this.RTL){var f=d.getRelativeToSurfaceXY().x,g=b-this.MARGIN,g=g/this.workspace_.scale,g=g-Blockly.BlockSvg.TAB_WIDTH;
|
||||
Blockly.Flyout.prototype.reflowVertical=function(a){this.workspace_.scale=this.targetWorkspace_.scale;for(var b=0,c=0,d;d=a[c];c++){var e=d.getHeightWidth().width;d.outputConnection&&(e-=Blockly.BlockSvg.TAB_WIDTH);b=Math.max(b,e)}b+=1.5*this.MARGIN+Blockly.BlockSvg.TAB_WIDTH;b*=this.workspace_.scale;b+=Blockly.Scrollbar.scrollbarThickness;if(this.width_!=b){for(c=0;d=a[c];c++){e=d.getHeightWidth();if(this.RTL){var f=d.getRelativeToSurfaceXY().x,g=b/this.workspace_.scale-this.MARGIN,g=g-Blockly.BlockSvg.TAB_WIDTH;
|
||||
d.moveBy(g-f,0)}d.flyoutRect_&&(d.flyoutRect_.setAttribute("width",e.width),d.flyoutRect_.setAttribute("height",e.height),g=d.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0,f=d.getRelativeToSurfaceXY(),d.flyoutRect_.setAttribute("x",this.RTL?f.x-e.width+g:f.x-g),(e=d.startHat_?Blockly.BlockSvg.START_HAT_HEIGHT:0)&&d.moveBy(0,e),d.flyoutRect_.setAttribute("y",f.y))}this.width_=b;this.targetWorkspace_.resize()}};
|
||||
Blockly.Flyout.prototype.reflow=function(){var a=this.workspace_.getTopBlocks(!1);this.horizontalLayout_?this.reflowHorizontal(a):this.reflowVertical(a)};
|
||||
Blockly.Flyout.prototype.offsetHorizontalRtlBlocks=function(a){if(this.horizontalLayout_&&this.RTL){this.position();try{var b=this.workspace_.getCanvas().getBBox()}catch(e){b={height:0,y:0,width:0,x:0}}for(var b=Math.max(-b.x+this.MARGIN,this.width_/this.workspace_.scale),c=0,d;d=a[c];c++)d.moveBy(b,0),d.flyoutRect_&&d.flyoutRect_.setAttribute("x",b+Number(d.flyoutRect_.getAttribute("x")))}};Blockly.Toolbox=function(a){this.workspace_=a;this.RTL=a.options.RTL;this.horizontalLayout_=a.options.horizontalLayout;this.toolboxPosition=a.options.toolboxPosition;this.config_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"};this.treeSeparatorConfig_={cssTreeRow:"blocklyTreeSeparator"};
|
||||
Blockly.Flyout.prototype.reflow=function(){this.reflowWrapper_&&this.workspace_.removeChangeListener(this.reflowWrapper_);var a=this.workspace_.getTopBlocks(!1);this.horizontalLayout_?this.reflowHorizontal(a):this.reflowVertical(a);this.reflowWrapper_&&this.workspace_.addChangeListener(this.reflowWrapper_)};Blockly.Toolbox=function(a){this.workspace_=a;this.RTL=a.options.RTL;this.horizontalLayout_=a.options.horizontalLayout;this.toolboxPosition=a.options.toolboxPosition;this.config_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"};this.treeSeparatorConfig_={cssTreeRow:"blocklyTreeSeparator"};
|
||||
this.horizontalLayout_&&(this.config_.cssTreeRow+=a.RTL?" blocklyHorizontalTreeRtl":" blocklyHorizontalTree",this.treeSeparatorConfig_.cssTreeRow="blocklyTreeSeparatorHorizontal "+(a.RTL?"blocklyHorizontalTreeRtl":"blocklyHorizontalTree"),this.config_.cssTreeIcon="")};Blockly.Toolbox.prototype.width=0;Blockly.Toolbox.prototype.height=0;Blockly.Toolbox.prototype.selectedOption_=null;Blockly.Toolbox.prototype.lastCategory_=null;
|
||||
Blockly.Toolbox.prototype.init=function(){var a=this.workspace_;this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv");this.HtmlDiv.setAttribute("dir",a.RTL?"RTL":"LTR");document.body.appendChild(this.HtmlDiv);Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(a){Blockly.isRightButton(a)||a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0)});this.flyout_=new Blockly.Flyout({disabledPatternId:a.options.disabledPatternId,parentWorkspace:a,RTL:a.RTL,horizontalLayout:a.horizontalLayout,
|
||||
toolboxPosition:a.options.toolboxPosition});goog.dom.insertSiblingAfter(this.flyout_.createDom(),a.svgGroup_);this.flyout_.init(a);this.config_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.config_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(a.RTL?"Rtl":"Ltr");var b=new Blockly.Toolbox.TreeControl(this,this.config_);this.tree_=b;b.setShowRootNode(!1);b.setShowLines(!1);b.setShowExpandIcons(!1);b.setSelectedItem(null);this.populate_(a.options.languageTree);b.render(this.HtmlDiv);this.addColour_();
|
||||
@@ -1401,11 +1402,11 @@ Blockly.bindEvent_.TOUCH_MAP={};goog.events.BrowserFeature.TOUCH_ENABLED&&(Block
|
||||
Blockly.isTargetInput_=function(a){return"textarea"==a.target.type||"text"==a.target.type||"number"==a.target.type||"email"==a.target.type||"password"==a.target.type||"search"==a.target.type||"tel"==a.target.type||"url"==a.target.type||a.target.isContentEditable};
|
||||
Blockly.getRelativeXY_=function(a){var b=new goog.math.Coordinate(0,0),c=a.getAttribute("x");c&&(b.x=parseInt(c,10));if(c=a.getAttribute("y"))b.y=parseInt(c,10);if(a=(a=a.getAttribute("transform"))&&a.match(Blockly.getRelativeXY_.XY_REGEXP_))b.x+=parseFloat(a[1]),a[3]&&(b.y+=parseFloat(a[3]));return b};Blockly.getRelativeXY_.XY_REGEXP_=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*\))?/;
|
||||
Blockly.getSvgXY_=function(a,b){var c=0,d=0,e=1;if(goog.dom.contains(b.getCanvas(),a)||goog.dom.contains(b.getBubbleCanvas(),a))e=b.scale;do{var f=Blockly.getRelativeXY_(a);if(a==b.getCanvas()||a==b.getBubbleCanvas())e=1;c+=f.x*e;d+=f.y*e;a=a.parentNode}while(a&&a!=b.getParentSvg());return new goog.math.Coordinate(c,d)};
|
||||
Blockly.createSvgElement=function(a,b,c,d){a=document.createElementNS(Blockly.SVG_NS,a);for(var e in b)a.setAttribute(e,b[e]);document.body.runtimeStyle&&(a.runtimeStyle=a.currentStyle=a.style);c&&c.appendChild(a);return a};Blockly.isRightButton=function(a){return a.ctrlKey&&goog.userAgent.MAC?!0:2==a.button};Blockly.mouseToSvg=function(a,b){var c=b.createSVGPoint();c.x=a.clientX;c.y=a.clientY;var d=b.getScreenCTM(),d=d.inverse();return c.matrixTransform(d)};
|
||||
Blockly.createSvgElement=function(a,b,c,d){a=document.createElementNS(Blockly.SVG_NS,a);for(var e in b)a.setAttribute(e,b[e]);document.body.runtimeStyle&&(a.runtimeStyle=a.currentStyle=a.style);c&&c.appendChild(a);return a};Blockly.isRightButton=function(a){return a.ctrlKey&&goog.userAgent.MAC?!0:2==a.button};Blockly.mouseToSvg=function(a,b,c){var d=b.createSVGPoint();d.x=a.clientX;d.y=a.clientY;c||(c=b.getScreenCTM().inverse());return d.matrixTransform(c)};
|
||||
Blockly.shortestStringLength=function(a){if(!a.length)return 0;for(var b=a[0].length,c=1;c<a.length;c++)b=Math.min(b,a[c].length);return b};Blockly.commonWordPrefix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0][e],g=1;g<a.length;g++)if(f!=a[g][e])return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g][e])&&" "!=f)return c;return d};
|
||||
Blockly.commonWordSuffix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0].substr(-e-1,1),g=1;g<a.length;g++)if(f!=a[g].substr(-e-1,1))return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g].charAt(a[g].length-e-1))&&" "!=f)return c;return d};Blockly.isNumber=function(a){return!!a.match(/^\s*-?\d+(\.\d+)?\s*$/)};
|
||||
Blockly.tokenizeInterpolation=function(a){var b=[];a=a.split("");a.push("");for(var c=0,d=[],e=null,f=0;f<a.length;f++){var g=a[f];0==c?"%"==g?c=1:d.push(g):1==c?"%"==g?(d.push(g),c=0):"0"<=g&&"9">=g?(c=2,e=g,(g=d.join(""))&&b.push(g),d.length=0):(d.push("%",g),c=0):2==c&&("0"<=g&&"9">=g?e+=g:(b.push(parseInt(e,10)),f--,c=0))}(g=d.join(""))&&b.push(g);return b};Blockly.genUid=function(){for(var a=Blockly.genUid.soup_.length,b=[],c=0;20>c;c++)b[c]=Blockly.genUid.soup_.charAt(Math.random()*a);return b.join("")};
|
||||
Blockly.genUid.soup_="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";Blockly.utils.wrap=function(a,b){for(var c=a.split("\n"),d=0;d<c.length;d++)c[d]=Blockly.utils.wrap_line_(c[d],b);return c.join("\n")};
|
||||
Blockly.utils.tokenizeInterpolation=function(a){var b=[];a=a.split("");a.push("");for(var c=0,d=[],e=null,f=0;f<a.length;f++){var g=a[f];0==c?"%"==g?c=1:d.push(g):1==c?"%"==g?(d.push(g),c=0):"0"<=g&&"9">=g?(c=2,e=g,(g=d.join(""))&&b.push(g),d.length=0):(d.push("%",g),c=0):2==c&&("0"<=g&&"9">=g?e+=g:(b.push(parseInt(e,10)),f--,c=0))}(g=d.join(""))&&b.push(g);return b};
|
||||
Blockly.genUid=function(){for(var a=Blockly.genUid.soup_.length,b=[],c=0;20>c;c++)b[c]=Blockly.genUid.soup_.charAt(Math.random()*a);return b.join("")};Blockly.genUid.soup_="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";Blockly.utils.wrap=function(a,b){for(var c=a.split("\n"),d=0;d<c.length;d++)c[d]=Blockly.utils.wrap_line_(c[d],b);return c.join("\n")};
|
||||
Blockly.utils.wrap_line_=function(a,b){if(a.length<=b)return a;for(var c=a.trim().split(/\s+/),d=0;d<c.length;d++)c[d].length>b&&(b=c[d].length);var e,d=-Infinity,f,g=1;do{e=d;f=a;for(var h=[],k=c.length/g,m=1,d=0;d<c.length-1;d++)m<(d+1.5)/k?(m++,h[d]=!0):h[d]=!1;h=Blockly.utils.wrapMutate_(c,h,b);d=Blockly.utils.wrapScore_(c,h,b);a=Blockly.utils.wrapToText_(c,h);g++}while(d>e);return f};
|
||||
Blockly.utils.wrapScore_=function(a,b,c){for(var d=[0],e=[],f=0;f<a.length;f++)d[d.length-1]+=a[f].length,!0===b[f]?(d.push(0),e.push(a[f].charAt(a[f].length-1))):!1===b[f]&&d[d.length-1]++;a=Math.max.apply(Math,d);for(f=b=0;f<d.length;f++)b-=2*Math.pow(Math.abs(c-d[f]),1.5),b-=Math.pow(a-d[f],1.5),-1!=".?!".indexOf(e[f])?b+=c/3:-1!=",;)]}".indexOf(e[f])&&(b+=c/4);1<d.length&&d[d.length-1]<=d[d.length-2]&&(b+=.5);return b};
|
||||
Blockly.utils.wrapMutate_=function(a,b,c){for(var d=Blockly.utils.wrapScore_(a,b,c),e,f=0;f<b.length-1;f++)if(b[f]!=b[f+1]){var g=[].concat(b);g[f]=!g[f];g[f+1]=!g[f+1];var h=Blockly.utils.wrapScore_(a,g,c);h>d&&(d=h,e=g)}return e?Blockly.utils.wrapMutate_(a,e,c):b};Blockly.utils.wrapToText_=function(a,b){for(var c=[],d=0;d<a.length;d++)c.push(a[d]),void 0!==b[d]&&c.push(b[d]?"\n":" ");return c.join("")};var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.highlightedConnection_=null;Blockly.localConnection_=null;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.dragMode_=Blockly.DRAG_NONE;Blockly.onTouchUpWrapper_=null;Blockly.hueToRgb=function(a){return goog.color.hsvToHex(a,Blockly.HSV_SATURATION,255*Blockly.HSV_VALUE)};Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};
|
||||
@@ -1422,4 +1423,5 @@ Blockly.getMainWorkspaceMetrics_=function(){var a=Blockly.svgSize(this.getParent
|
||||
this.scale,h=e.x*this.scale,k=e.y*this.scale;this.scrollbar?(b=Math.min(h-c/2,h+f-c),c=Math.max(h+f+c/2,h+c),f=Math.min(k-d/2,k+g-d),d=Math.max(k+g+d/2,k+d)):(b=e.x,c=b+e.width,f=e.y,d=f+e.height);e=0;this.toolbox_&&this.toolboxPosition==Blockly.TOOLBOX_AT_LEFT&&(e=this.toolbox_.getWidth());g=0;this.toolbox_&&this.toolboxPosition==Blockly.TOOLBOX_AT_TOP&&(g=this.toolbox_.getHeight());return{viewHeight:a.height,viewWidth:a.width,contentHeight:d-f,contentWidth:c-b,viewTop:-this.scrollY,viewLeft:-this.scrollX,
|
||||
contentTop:f,contentLeft:b,absoluteTop:g,absoluteLeft:e,toolboxWidth:this.toolbox_?this.toolbox_.getWidth():0,toolboxHeight:this.toolbox_?this.toolbox_.getHeight():0,flyoutWidth:this.flyout_?this.flyout_.getWidth():0,flyoutHeight:this.flyout_?this.flyout_.getHeight():0,toolboxPosition:this.toolboxPosition}};
|
||||
Blockly.setMainWorkspaceMetrics_=function(a){if(!this.scrollbar)throw"Attempt to set main workspace scroll without scrollbars.";var b=this.getMetrics();goog.isNumber(a.x)&&(this.scrollX=-b.contentWidth*a.x-b.contentLeft);goog.isNumber(a.y)&&(this.scrollY=-b.contentHeight*a.y-b.contentTop);a=this.scrollX+b.absoluteLeft;b=this.scrollY+b.absoluteTop;this.translate(a,b);this.options.gridPattern&&(this.options.gridPattern.setAttribute("x",a),this.options.gridPattern.setAttribute("y",b),goog.userAgent.IE&&
|
||||
this.updateGridPattern_())};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)};Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};goog.global.Blockly||(goog.global.Blockly={});goog.global.Blockly.getMainWorkspace=Blockly.getMainWorkspace;goog.global.Blockly.addChangeListener=Blockly.addChangeListener;
|
||||
this.updateGridPattern_())};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)};Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};goog.global.console||(goog.global.console={log:function(){},warn:function(){}});goog.global.Blockly||(goog.global.Blockly={});goog.global.Blockly.getMainWorkspace=Blockly.getMainWorkspace;
|
||||
goog.global.Blockly.addChangeListener=Blockly.addChangeListener;
|
||||
+1
-812
File diff suppressed because one or more lines are too long
+3
-5
@@ -1021,7 +1021,7 @@ Blockly.Block.prototype.jsonInit = function(json) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
||||
var tokens = Blockly.tokenizeInterpolation(message);
|
||||
var tokens = Blockly.utils.tokenizeInterpolation(message);
|
||||
// Interpolate the arguments. Build a list of elements.
|
||||
var indexDup = [];
|
||||
var indexCount = 0;
|
||||
@@ -1111,10 +1111,8 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
||||
element['width'], element['height'], element['alt']);
|
||||
break;
|
||||
case 'field_number':
|
||||
field = new Blockly.FieldNumber(element['value']);
|
||||
field.setPrecision(element['precision']);
|
||||
field.setMin(element['min']);
|
||||
field.setMax(element['max']);
|
||||
field = new Blockly.FieldNumber(element['value'],
|
||||
element['min'], element['max'], element['precision']);
|
||||
break;
|
||||
case 'field_date':
|
||||
if (Blockly.FieldDate) {
|
||||
|
||||
+10
-1
@@ -549,13 +549,22 @@ Blockly.addChangeListener = function(func) {
|
||||
|
||||
/**
|
||||
* Returns the main workspace. Returns the last used main workspace (based on
|
||||
* focus).
|
||||
* focus). Try not to use this function, particularly if there are multiple
|
||||
* Blockly instances on a page.
|
||||
* @return {!Blockly.Workspace} The main workspace.
|
||||
*/
|
||||
Blockly.getMainWorkspace = function() {
|
||||
return Blockly.mainWorkspace;
|
||||
};
|
||||
|
||||
// IE9 does not have a console. Create a stub to stop errors.
|
||||
if (!goog.global['console']) {
|
||||
goog.global['console'] = {
|
||||
'log': function() {},
|
||||
'warn': function() {}
|
||||
};
|
||||
}
|
||||
|
||||
// Export symbols that would otherwise be renamed by Closure compiler.
|
||||
if (!goog.global['Blockly']) {
|
||||
goog.global['Blockly'] = {};
|
||||
|
||||
+3
-1
@@ -303,8 +303,10 @@ Blockly.Events.Abstract = function(block) {
|
||||
Blockly.Events.Abstract.prototype.toJson = function() {
|
||||
var json = {
|
||||
'type': this.type,
|
||||
'blockId': this.blockId
|
||||
};
|
||||
if (this.blockId) {
|
||||
json['blockId'] = this.blockId;
|
||||
}
|
||||
if (this.group) {
|
||||
json['group'] = this.group;
|
||||
}
|
||||
|
||||
+1
-1
@@ -433,7 +433,7 @@ Blockly.Field.prototype.onMouseUp_ = function(e) {
|
||||
} else if (Blockly.isRightButton(e)) {
|
||||
// Right-click.
|
||||
return;
|
||||
} else if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
|
||||
} else if (this.sourceBlock_.workspace.isDragging()) {
|
||||
// Drag operation is concluding. Don't open the editor.
|
||||
return;
|
||||
} else if (this.sourceBlock_.isEditable()) {
|
||||
|
||||
+2
-2
@@ -193,14 +193,14 @@ Blockly.FieldDate.loadLanguage_ = function() {
|
||||
*/
|
||||
Blockly.FieldDate.CSS = [
|
||||
/* Copied from: goog/css/datepicker.css */
|
||||
/*
|
||||
/**
|
||||
* Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by the Apache License, Version 2.0.
|
||||
* See the COPYING file for details.
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Standard styling for a goog.ui.DatePicker.
|
||||
*
|
||||
* @author arv@google.com (Erik Arvidsson)
|
||||
|
||||
+18
-49
@@ -32,6 +32,9 @@ goog.require('goog.math');
|
||||
/**
|
||||
* Class for an editable number field.
|
||||
* @param {string} value The initial content of the field.
|
||||
* @param {number|string|undefined} opt_min Minimum value.
|
||||
* @param {number|string|undefined} opt_max Maximum value.
|
||||
* @param {number|string|undefined} opt_precision Precision for value.
|
||||
* @param {Function=} opt_validator An optional function that is called
|
||||
* to validate any constraints on what the user entered. Takes the new
|
||||
* text as an argument and returns either the accepted text, a replacement
|
||||
@@ -39,66 +42,32 @@ goog.require('goog.math');
|
||||
* @extends {Blockly.FieldTextInput}
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.FieldNumber = function(value, opt_validator) {
|
||||
Blockly.FieldNumber =
|
||||
function(value, opt_min, opt_max, opt_precision, opt_validator) {
|
||||
Blockly.FieldNumber.superClass_.constructor.call(this, value, opt_validator);
|
||||
this.setConstraints(opt_min, opt_max, opt_precision);
|
||||
};
|
||||
goog.inherits(Blockly.FieldNumber, Blockly.FieldTextInput);
|
||||
|
||||
/**
|
||||
* Steps between allowed numbers.
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
Blockly.FieldNumber.prototype.precision_ = 0;
|
||||
|
||||
/**
|
||||
* Minimum allowed value.
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
Blockly.FieldNumber.prototype.min_ = -Infinity;
|
||||
|
||||
/**
|
||||
* Maximum allowed value.
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
Blockly.FieldNumber.prototype.max_ = Infinity;
|
||||
|
||||
/**
|
||||
* Set the maximum, minimum and precision constraints on this field.
|
||||
* Any of these properties may be undefiend or NaN to be disabled.
|
||||
* Setting precision (usually a power of 10) enforces a minimum step between
|
||||
* values. That is, the user's value will rounded to the closest multiple of
|
||||
* precision. The least significant digit place is inferred from the precision.
|
||||
* Integers values can be enforces by choosing an integer precision.
|
||||
* @param {number|string|undefined} min Minimum value.
|
||||
* @param {number|string|undefined} max Maximum value.
|
||||
* @param {number|string|undefined} precision Precision for value.
|
||||
*/
|
||||
Blockly.FieldNumber.prototype.setPrecision = function(precision) {
|
||||
Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) {
|
||||
precision = parseFloat(precision);
|
||||
if (!isNaN(precision)) {
|
||||
this.precision_ = precision;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a maximum limit on this field's value.
|
||||
* @param {number|string|undefined} max Maximum value.
|
||||
*/
|
||||
Blockly.FieldNumber.prototype.setMin = function(min) {
|
||||
this.precision_ = isNaN(precision) ? 0 : precision;
|
||||
min = parseFloat(min);
|
||||
if (!isNaN(min)) {
|
||||
this.min_ = min;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a maximum limit on this field's value.
|
||||
* @param {number|string|undefined} max Minimum value.
|
||||
*/
|
||||
Blockly.FieldNumber.prototype.setMax = function(max) {
|
||||
this.min_ = isNaN(min) ? -Infinity : min;
|
||||
max = parseFloat(max);
|
||||
if (!isNaN(max)) {
|
||||
this.max_ = max;
|
||||
}
|
||||
this.max_ = isNaN(max) ? Infinity : max;
|
||||
this.setValue(this.numberValidator(this.getValue));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -117,7 +86,7 @@ Blockly.FieldNumber.prototype.setValidator = function(handler) {
|
||||
if (v1 === undefined) {
|
||||
v1 = value;
|
||||
}
|
||||
var v2 = Blockly.FieldNumber.numberValidator.call(this, v1);
|
||||
var v2 = this.numberValidator(v1);
|
||||
if (v2 === undefined) {
|
||||
v2 = v1;
|
||||
}
|
||||
@@ -125,7 +94,7 @@ Blockly.FieldNumber.prototype.setValidator = function(handler) {
|
||||
return v2 === value ? undefined : v2;
|
||||
};
|
||||
} else {
|
||||
wrappedHandler = Blockly.FieldNumber.numberValidator;
|
||||
wrappedHandler = this.numberValidator;
|
||||
}
|
||||
Blockly.FieldNumber.superClass_.setValidator.call(this, wrappedHandler);
|
||||
};
|
||||
@@ -135,7 +104,7 @@ Blockly.FieldNumber.prototype.setValidator = function(handler) {
|
||||
* @param {string} text The user's text.
|
||||
* @return {?string} A string representing a valid number, or null if invalid.
|
||||
*/
|
||||
Blockly.FieldNumber.numberValidator = function(text) {
|
||||
Blockly.FieldNumber.prototype.numberValidator = function(text) {
|
||||
if (text === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+19
-45
@@ -292,8 +292,8 @@ Blockly.Flyout.prototype.getMetrics_ = function() {
|
||||
contentWidth: (optionBox.width + 2 * this.MARGIN) * this.workspace_.scale,
|
||||
viewTop: -this.workspace_.scrollY,
|
||||
viewLeft: -this.workspace_.scrollX,
|
||||
contentTop: 0, // TODO: #349
|
||||
contentLeft: 0, // TODO: #349
|
||||
contentTop: optionBox.y,
|
||||
contentLeft: optionBox.x,
|
||||
absoluteTop: absoluteTop,
|
||||
absoluteLeft: absoluteLeft
|
||||
};
|
||||
@@ -432,9 +432,8 @@ Blockly.Flyout.prototype.setBackgroundPathVertical_ = function(width, height) {
|
||||
* rounded corners.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.setBackgroundPathHorizontal_ =
|
||||
function(width, height) {
|
||||
/* eslint-disable indent */
|
||||
Blockly.Flyout.prototype.setBackgroundPathHorizontal_ = function(width,
|
||||
height) {
|
||||
var atTop = this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP;
|
||||
// Start at top left.
|
||||
var path = ['M 0,' + (atTop ? 0 : this.CORNER_RADIUS)];
|
||||
@@ -467,7 +466,7 @@ Blockly.Flyout.prototype.setBackgroundPathHorizontal_ =
|
||||
path.push('z');
|
||||
}
|
||||
this.svgBackground_.setAttribute('d', path.join(' '));
|
||||
}; /* eslint-enable indent */
|
||||
};
|
||||
|
||||
/**
|
||||
* Scroll the flyout to the top.
|
||||
@@ -601,7 +600,6 @@ Blockly.Flyout.prototype.show = function(xmlList) {
|
||||
}
|
||||
this.reflow();
|
||||
|
||||
this.offsetHorizontalRtlBlocks(this.workspace_.getTopBlocks(false));
|
||||
this.filterForCapacity_();
|
||||
|
||||
// Correctly position the flyout's scrollbar when it opens.
|
||||
@@ -618,9 +616,12 @@ Blockly.Flyout.prototype.show = function(xmlList) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.layoutBlocks_ = function(blocks, gaps) {
|
||||
var margin = this.MARGIN * this.workspace_.scale;
|
||||
var margin = this.MARGIN;
|
||||
var cursorX = this.RTL ? margin : margin + Blockly.BlockSvg.TAB_WIDTH;
|
||||
var cursorY = margin;
|
||||
if (this.horizontalLayout_ && this.RTL) {
|
||||
blocks = blocks.reverse();
|
||||
}
|
||||
for (var i = 0, block; block = blocks[i]; i++) {
|
||||
if (block.type == 'block') {
|
||||
block = block.block;
|
||||
@@ -694,7 +695,7 @@ Blockly.Flyout.prototype.clearOldBlocks_ = function() {
|
||||
for (var i = 0, button; button = this.buttons_[i]; i++) {
|
||||
button.dispose();
|
||||
}
|
||||
this.buttons_.length;
|
||||
this.buttons_.length = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -788,8 +789,7 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.onMouseUp_ = function(e) {
|
||||
if (Blockly.dragMode_ != Blockly.DRAG_FREE &&
|
||||
!Blockly.WidgetDiv.isVisible()) {
|
||||
if (!this.workspace_.isDragging() && !Blockly.WidgetDiv.isVisible()) {
|
||||
Blockly.Events.fire(
|
||||
new Blockly.Events.Ui(Blockly.Flyout.startBlock_, 'click',
|
||||
undefined, undefined));
|
||||
@@ -1107,10 +1107,9 @@ Blockly.Flyout.prototype.reflowVertical = function(blocks) {
|
||||
if (this.RTL) {
|
||||
// With the flyoutWidth known, right-align the blocks.
|
||||
var oldX = block.getRelativeToSurfaceXY().x;
|
||||
var dx = flyoutWidth - this.MARGIN;
|
||||
dx /= this.workspace_.scale;
|
||||
dx -= Blockly.BlockSvg.TAB_WIDTH;
|
||||
block.moveBy(dx - oldX, 0);
|
||||
var newX = flyoutWidth / this.workspace_.scale - this.MARGIN;
|
||||
newX -= Blockly.BlockSvg.TAB_WIDTH;
|
||||
block.moveBy(newX - oldX, 0);
|
||||
}
|
||||
if (block.flyoutRect_) {
|
||||
block.flyoutRect_.setAttribute('width', blockHW.width);
|
||||
@@ -1142,41 +1141,16 @@ Blockly.Flyout.prototype.reflowVertical = function(blocks) {
|
||||
* Reflow blocks and their buttons.
|
||||
*/
|
||||
Blockly.Flyout.prototype.reflow = function() {
|
||||
if (this.reflowWrapper_) {
|
||||
this.workspace_.removeChangeListener(this.reflowWrapper_);
|
||||
}
|
||||
var blocks = this.workspace_.getTopBlocks(false);
|
||||
if (this.horizontalLayout_) {
|
||||
this.reflowHorizontal(blocks);
|
||||
} else {
|
||||
this.reflowVertical(blocks);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* In the horizontal RTL case all of the blocks will be laid out to the left of
|
||||
* the origin, but we won't know how big the workspace is until the layout pass
|
||||
* is done.
|
||||
* Now that it's done, shunt all the blocks to be right of the origin.
|
||||
* @param {!Array<!Blockly.Block>} blocks The blocks to reposition.
|
||||
*/
|
||||
Blockly.Flyout.prototype.offsetHorizontalRtlBlocks = function(blocks) {
|
||||
if (this.horizontalLayout_ && this.RTL) {
|
||||
// We don't know this workspace's view width yet.
|
||||
this.position();
|
||||
try {
|
||||
var optionBox = this.workspace_.getCanvas().getBBox();
|
||||
} catch (e) {
|
||||
// Firefox has trouble with hidden elements (Bug 528969).
|
||||
optionBox = {height: 0, y: 0, width: 0, x: 0};
|
||||
}
|
||||
|
||||
var offset = Math.max(-optionBox.x + this.MARGIN,
|
||||
this.width_ / this.workspace_.scale);
|
||||
|
||||
for (var i = 0, block; block = blocks[i]; i++) {
|
||||
block.moveBy(offset, 0);
|
||||
if (block.flyoutRect_) {
|
||||
block.flyoutRect_.setAttribute('x',
|
||||
offset + Number(block.flyoutRect_.getAttribute('x')));
|
||||
}
|
||||
}
|
||||
if (this.reflowWrapper_) {
|
||||
this.workspace_.addChangeListener(this.reflowWrapper_);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ Blockly.Icon.prototype.isVisible = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Icon.prototype.iconClick_ = function(e) {
|
||||
if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
|
||||
if (this.block_.workspace.isDragging()) {
|
||||
// Drag operation is concluding. Don't open the editor.
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-2
@@ -606,7 +606,8 @@ Blockly.Scrollbar.prototype.onMouseDownBar_ = function(e) {
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
var mouseXY = Blockly.mouseToSvg(e, this.workspace_.getParentSvg());
|
||||
var mouseXY = Blockly.mouseToSvg(e, this.workspace_.getParentSvg(),
|
||||
this.workspace_.getInverseScreenCTM());
|
||||
var mouseLocation = this.horizontal_ ? mouseXY.x : mouseXY.y;
|
||||
|
||||
var handleXY = Blockly.getSvgXY_(this.svgHandle_, this.workspace_);
|
||||
@@ -693,7 +694,7 @@ Blockly.Scrollbar.prototype.onMouseUpHandle_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Scrollbar.prototype.constrainHandle_ = function(value) {
|
||||
if (value <= 0 || isNaN(value)) {
|
||||
if (value <= 0 || isNaN(value) || this.scrollViewSize_ < this.handleLength_) {
|
||||
value = 0;
|
||||
} else {
|
||||
value = Math.min(value, this.scrollViewSize_ - this.handleLength_);
|
||||
|
||||
+7
-4
@@ -308,14 +308,17 @@ Blockly.isRightButton = function(e) {
|
||||
* The origin (0,0) is the top-left corner of the Blockly svg.
|
||||
* @param {!Event} e Mouse event.
|
||||
* @param {!Element} svg SVG element.
|
||||
* @param {SVGMatrix} matrix Inverted screen CTM to use.
|
||||
* @return {!Object} Object with .x and .y properties.
|
||||
*/
|
||||
Blockly.mouseToSvg = function(e, svg) {
|
||||
Blockly.mouseToSvg = function(e, svg, matrix) {
|
||||
var svgPoint = svg.createSVGPoint();
|
||||
svgPoint.x = e.clientX;
|
||||
svgPoint.y = e.clientY;
|
||||
var matrix = svg.getScreenCTM();
|
||||
matrix = matrix.inverse();
|
||||
|
||||
if (!matrix) {
|
||||
matrix = svg.getScreenCTM().inverse();
|
||||
}
|
||||
return svgPoint.matrixTransform(matrix);
|
||||
};
|
||||
|
||||
@@ -420,7 +423,7 @@ Blockly.isNumber = function(str) {
|
||||
* @param {string} message Text containing interpolation tokens.
|
||||
* @return {!Array.<string|number>} Array of strings and numbers.
|
||||
*/
|
||||
Blockly.tokenizeInterpolation = function(message) {
|
||||
Blockly.utils.tokenizeInterpolation = function(message) {
|
||||
var tokens = [];
|
||||
var chars = message.split('');
|
||||
chars.push(''); // End marker.
|
||||
|
||||
+38
-3
@@ -144,6 +144,28 @@ Blockly.WorkspaceSvg.prototype.scrollbar = null;
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.lastSound_ = null;
|
||||
|
||||
/**
|
||||
* Inverted screen CTM, for use in mouseToSvg.
|
||||
* @type {SVGMatrix}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.inverseScreenCTM_ = null;
|
||||
|
||||
/**
|
||||
* Getter for the inverted screen CTM.
|
||||
* @return {SVGMatrix} The matrix to use in mouseToSvg
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.getInverseScreenCTM = function() {
|
||||
return this.inverseScreenCTM_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the inverted screen CTM.
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.updateInverseScreenCTM = function() {
|
||||
this.inverseScreenCTM_ = this.getParentSvg().getScreenCTM().inverse();
|
||||
};
|
||||
|
||||
/**
|
||||
* Save resize handler data so we can delete it later in dispose.
|
||||
* @param {!Array.<!Array>} handler Data that can be passed to unbindEvent_.
|
||||
@@ -331,6 +353,7 @@ Blockly.WorkspaceSvg.prototype.resizeContents = function() {
|
||||
// based on contents.
|
||||
this.scrollbar.resize();
|
||||
}
|
||||
this.updateInverseScreenCTM();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -357,6 +380,7 @@ Blockly.WorkspaceSvg.prototype.resize = function() {
|
||||
this.scrollbar.resize();
|
||||
}
|
||||
|
||||
this.updateInverseScreenCTM();
|
||||
this.recordDeleteAreas();
|
||||
};
|
||||
|
||||
@@ -664,7 +688,8 @@ Blockly.WorkspaceSvg.prototype.onMouseDown_ = function(e) {
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.startDrag = function(e, xy) {
|
||||
// Record the starting offset between the bubble's location and the mouse.
|
||||
var point = Blockly.mouseToSvg(e, this.getParentSvg());
|
||||
var point = Blockly.mouseToSvg(e, this.getParentSvg(),
|
||||
this.getInverseScreenCTM());
|
||||
// Fix scale of mouse event.
|
||||
point.x /= this.scale;
|
||||
point.y /= this.scale;
|
||||
@@ -677,13 +702,22 @@ Blockly.WorkspaceSvg.prototype.startDrag = function(e, xy) {
|
||||
* @return {!goog.math.Coordinate} New location of object.
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.moveDrag = function(e) {
|
||||
var point = Blockly.mouseToSvg(e, this.getParentSvg());
|
||||
var point = Blockly.mouseToSvg(e, this.getParentSvg(),
|
||||
this.getInverseScreenCTM());
|
||||
// Fix scale of mouse event.
|
||||
point.x /= this.scale;
|
||||
point.y /= this.scale;
|
||||
return goog.math.Coordinate.sum(this.dragDeltaXY_, point);
|
||||
};
|
||||
|
||||
/**
|
||||
* Is the user currently dragging a block or scrolling the workspace?
|
||||
* @return {boolean} True if currently dragging or scrolling
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.isDragging = function() {
|
||||
return Blockly.dragMode_ == Blockly.DRAG_FREE || this.isScrolling;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle a mouse-wheel on SVG drawing surface.
|
||||
* @param {!Event} e Mouse wheel event.
|
||||
@@ -693,7 +727,8 @@ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) {
|
||||
// TODO: Remove terminateDrag and compensate for coordinate skew during zoom.
|
||||
Blockly.terminateDrag_();
|
||||
var delta = e.deltaY > 0 ? -1 : 1;
|
||||
var position = Blockly.mouseToSvg(e, this.getParentSvg());
|
||||
var position = Blockly.mouseToSvg(e, this.getParentSvg(),
|
||||
this.getInverseScreenCTM());
|
||||
this.zoom(position.x, position.y, delta);
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
@@ -470,9 +470,9 @@ Blockly.Blocks['field_image'] = {
|
||||
.appendField(new Blockly.FieldTextInput(src), 'SRC');
|
||||
this.appendDummyInput()
|
||||
.appendField('width')
|
||||
.appendField(new Blockly.FieldNumber('15'), 'WIDTH')
|
||||
.appendField(new Blockly.FieldNumber('15', 0, NaN, 1), 'WIDTH')
|
||||
.appendField('height')
|
||||
.appendField(new Blockly.FieldNumber('15'), 'HEIGHT')
|
||||
.appendField(new Blockly.FieldNumber('15', 0, NaN, 1), 'HEIGHT')
|
||||
.appendField('alt text')
|
||||
.appendField(new Blockly.FieldTextInput('*'), 'ALT');
|
||||
this.setPreviousStatement(true, 'Field');
|
||||
|
||||
+7
-16
@@ -382,7 +382,12 @@ Code.init = function() {
|
||||
};
|
||||
window.addEventListener('resize', onresize, false);
|
||||
|
||||
var toolbox = document.getElementById('toolbox');
|
||||
// Interpolate translated messages into toolbox.
|
||||
var toolboxText = document.getElementById('toolbox').outerHTML;
|
||||
toolboxText = toolboxText.replace(/{(\w+)}/g,
|
||||
function(m, p1) {return MSG[p1]});
|
||||
var toolboxXml = Blockly.Xml.textToDom(toolboxText);
|
||||
|
||||
Code.workspace = Blockly.inject('content_blocks',
|
||||
{grid:
|
||||
{spacing: 25,
|
||||
@@ -391,7 +396,7 @@ Code.init = function() {
|
||||
snap: true},
|
||||
media: '../../media/',
|
||||
rtl: rtl,
|
||||
toolbox: toolbox,
|
||||
toolbox: toolboxXml,
|
||||
zoom:
|
||||
{controls: true,
|
||||
wheel: true}
|
||||
@@ -481,20 +486,6 @@ Code.initLanguage = function() {
|
||||
document.getElementById('linkButton').title = MSG['linkTooltip'];
|
||||
document.getElementById('runButton').title = MSG['runTooltip'];
|
||||
document.getElementById('trashButton').title = MSG['trashTooltip'];
|
||||
|
||||
var categories = ['catLogic', 'catLoops', 'catMath', 'catText', 'catLists',
|
||||
'catColour', 'catVariables', 'catFunctions'];
|
||||
for (var i = 0, cat; cat = categories[i]; i++) {
|
||||
document.getElementById(cat).setAttribute('name', MSG[cat]);
|
||||
}
|
||||
var textVars = document.getElementsByClassName('textVar');
|
||||
for (var i = 0, textVar; textVar = textVars[i]; i++) {
|
||||
textVar.textContent = MSG['textVariable'];
|
||||
}
|
||||
var listVars = document.getElementsByClassName('listVar');
|
||||
for (var i = 0, listVar; listVar = listVars[i]; i++) {
|
||||
listVar.textContent = MSG['listVariable'];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+15
-15
@@ -74,7 +74,7 @@
|
||||
<textarea id="content_xml" class="content" wrap="off"></textarea>
|
||||
|
||||
<xml id="toolbox" style="display: none">
|
||||
<category id="catLogic" colour="210">
|
||||
<category name="{catLogic}" colour="210">
|
||||
<block type="controls_if"></block>
|
||||
<block type="logic_compare"></block>
|
||||
<block type="logic_operation"></block>
|
||||
@@ -83,7 +83,7 @@
|
||||
<block type="logic_null"></block>
|
||||
<block type="logic_ternary"></block>
|
||||
</category>
|
||||
<category id="catLoops" colour="120">
|
||||
<category name="{catLoops}" colour="120">
|
||||
<block type="controls_repeat_ext">
|
||||
<value name="TIMES">
|
||||
<shadow type="math_number">
|
||||
@@ -112,7 +112,7 @@
|
||||
<block type="controls_forEach"></block>
|
||||
<block type="controls_flow_statements"></block>
|
||||
</category>
|
||||
<category id="catMath" colour="230">
|
||||
<category name="{catMath}" colour="230">
|
||||
<block type="math_number"></block>
|
||||
<block type="math_arithmetic">
|
||||
<value name="A">
|
||||
@@ -206,7 +206,7 @@
|
||||
</block>
|
||||
<block type="math_random_float"></block>
|
||||
</category>
|
||||
<category id="catText" colour="160">
|
||||
<category name="{catText}" colour="160">
|
||||
<block type="text"></block>
|
||||
<block type="text_join"></block>
|
||||
<block type="text_append">
|
||||
@@ -231,7 +231,7 @@
|
||||
<block type="text_indexOf">
|
||||
<value name="VALUE">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">text</field>
|
||||
<field name="VAR">{textVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="FIND">
|
||||
@@ -243,14 +243,14 @@
|
||||
<block type="text_charAt">
|
||||
<value name="VALUE">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">text</field>
|
||||
<field name="VAR">{textVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
<block type="text_getSubstring">
|
||||
<value name="STRING">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">text</field>
|
||||
<field name="VAR">{textVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
@@ -283,7 +283,7 @@
|
||||
</value>
|
||||
</block>
|
||||
</category>
|
||||
<category id="catLists" colour="260">
|
||||
<category name="{catLists}" colour="260">
|
||||
<block type="lists_create_with">
|
||||
<mutation items="0"></mutation>
|
||||
</block>
|
||||
@@ -300,28 +300,28 @@
|
||||
<block type="lists_indexOf">
|
||||
<value name="VALUE">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">list</field>
|
||||
<field name="VAR">{listVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
<block type="lists_getIndex">
|
||||
<value name="VALUE">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">list</field>
|
||||
<field name="VAR">{listVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
<block type="lists_setIndex">
|
||||
<value name="LIST">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">list</field>
|
||||
<field name="VAR">{listVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
<block type="lists_getSublist">
|
||||
<value name="LIST">
|
||||
<block type="variables_get">
|
||||
<field name="VAR">list</field>
|
||||
<field name="VAR">{listVariable}</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
@@ -334,7 +334,7 @@
|
||||
</block>
|
||||
<block type="lists_sort"></block>
|
||||
</category>
|
||||
<category id="catColour" colour="20">
|
||||
<category name="{catColour}" colour="20">
|
||||
<block type="colour_picker"></block>
|
||||
<block type="colour_random"></block>
|
||||
<block type="colour_rgb">
|
||||
@@ -373,8 +373,8 @@
|
||||
</block>
|
||||
</category>
|
||||
<sep></sep>
|
||||
<category id="catVariables" colour="330" custom="VARIABLE"></category>
|
||||
<category id="catFunctions" colour="290" custom="PROCEDURE"></category>
|
||||
<category name="{catVariables}" colour="330" custom="VARIABLE"></category>
|
||||
<category name="{catFunctions}" colour="290" custom="PROCEDURE"></category>
|
||||
</xml>
|
||||
|
||||
</body>
|
||||
|
||||
+20
-12
@@ -71,23 +71,23 @@ Blockly.JavaScript.addReservedWords(
|
||||
* https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence
|
||||
*/
|
||||
Blockly.JavaScript.ORDER_ATOMIC = 0; // 0 "" ...
|
||||
Blockly.JavaScript.ORDER_MEMBER = 1.1; // . []
|
||||
Blockly.JavaScript.ORDER_NEW = 1.2; // new
|
||||
Blockly.JavaScript.ORDER_NEW = 1.1; // new
|
||||
Blockly.JavaScript.ORDER_MEMBER = 1.2; // . []
|
||||
Blockly.JavaScript.ORDER_FUNCTION_CALL = 2; // ()
|
||||
Blockly.JavaScript.ORDER_INCREMENT = 3; // ++
|
||||
Blockly.JavaScript.ORDER_DECREMENT = 3; // --
|
||||
Blockly.JavaScript.ORDER_LOGICAL_NOT = 4.1; // !
|
||||
Blockly.JavaScript.ORDER_BITWISE_NOT = 4.2; // ~
|
||||
Blockly.JavaScript.ORDER_UNARY_PLUS = 4.3; // +
|
||||
Blockly.JavaScript.ORDER_UNARY_NEGATION = 4.4; // -
|
||||
Blockly.JavaScript.ORDER_BITWISE_NOT = 4.1; // ~
|
||||
Blockly.JavaScript.ORDER_UNARY_PLUS = 4.2; // +
|
||||
Blockly.JavaScript.ORDER_UNARY_NEGATION = 4.3; // -
|
||||
Blockly.JavaScript.ORDER_LOGICAL_NOT = 4.4; // !
|
||||
Blockly.JavaScript.ORDER_TYPEOF = 4.5; // typeof
|
||||
Blockly.JavaScript.ORDER_VOID = 4.6; // void
|
||||
Blockly.JavaScript.ORDER_DELETE = 4.7; // delete
|
||||
Blockly.JavaScript.ORDER_MULTIPLICATION = 5.1; // *
|
||||
Blockly.JavaScript.ORDER_DIVISION = 5.2; // /
|
||||
Blockly.JavaScript.ORDER_DIVISION = 5.1; // /
|
||||
Blockly.JavaScript.ORDER_MULTIPLICATION = 5.2; // *
|
||||
Blockly.JavaScript.ORDER_MODULUS = 5.3; // %
|
||||
Blockly.JavaScript.ORDER_ADDITION = 6.1; // +
|
||||
Blockly.JavaScript.ORDER_SUBTRACTION = 6.2; // -
|
||||
Blockly.JavaScript.ORDER_SUBTRACTION = 6.1; // -
|
||||
Blockly.JavaScript.ORDER_ADDITION = 6.2; // +
|
||||
Blockly.JavaScript.ORDER_BITWISE_SHIFT = 7; // << >> >>>
|
||||
Blockly.JavaScript.ORDER_RELATIONAL = 8; // < <= > >=
|
||||
Blockly.JavaScript.ORDER_IN = 8; // in
|
||||
@@ -108,12 +108,20 @@ Blockly.JavaScript.ORDER_NONE = 99; // (...)
|
||||
* @type {!Array.<!Array.<number>>}
|
||||
*/
|
||||
Blockly.JavaScript.ORDER_OVERRIDES = [
|
||||
// (foo()).bar() -> foo().bar()
|
||||
// (foo()).bar -> foo().bar
|
||||
// (foo())[0] -> foo()[0]
|
||||
[Blockly.JavaScript.ORDER_FUNCTION_CALL, Blockly.JavaScript.ORDER_MEMBER],
|
||||
// (foo[0])[1] -> foo[0][1]
|
||||
// (foo())() -> foo()()
|
||||
[Blockly.JavaScript.ORDER_FUNCTION_CALL, Blockly.JavaScript.ORDER_FUNCTION_CALL],
|
||||
// (foo.bar).baz -> foo.bar.baz
|
||||
// (foo.bar)[0] -> foo.bar[0]
|
||||
// (foo[0]).bar -> foo[0].bar
|
||||
// (foo[0])[1] -> foo[0][1]
|
||||
[Blockly.JavaScript.ORDER_MEMBER, Blockly.JavaScript.ORDER_MEMBER],
|
||||
// (foo.bar)() -> foo.bar()
|
||||
// (foo[0])() -> foo[0]()
|
||||
[Blockly.JavaScript.ORDER_MEMBER, Blockly.JavaScript.ORDER_FUNCTION_CALL],
|
||||
|
||||
// !(!foo) -> !!foo
|
||||
[Blockly.JavaScript.ORDER_LOGICAL_NOT, Blockly.JavaScript.ORDER_LOGICAL_NOT],
|
||||
// a * (b * c) -> a * b * c
|
||||
|
||||
+21
-4
@@ -59,8 +59,8 @@ Blockly.Python.addReservedWords(
|
||||
Blockly.Python.ORDER_ATOMIC = 0; // 0 "" ...
|
||||
Blockly.Python.ORDER_COLLECTION = 1; // tuples, lists, dictionaries
|
||||
Blockly.Python.ORDER_STRING_CONVERSION = 1; // `expression...`
|
||||
Blockly.Python.ORDER_MEMBER = 2; // . []
|
||||
Blockly.Python.ORDER_FUNCTION_CALL = 2; // ()
|
||||
Blockly.Python.ORDER_MEMBER = 2.1; // . []
|
||||
Blockly.Python.ORDER_FUNCTION_CALL = 2.2; // ()
|
||||
Blockly.Python.ORDER_EXPONENTIATION = 3; // **
|
||||
Blockly.Python.ORDER_UNARY_SIGN = 4; // + -
|
||||
Blockly.Python.ORDER_BITWISE_NOT = 4; // ~
|
||||
@@ -84,9 +84,26 @@ Blockly.Python.ORDER_NONE = 99; // (...)
|
||||
* @type {!Array.<!Array.<number>>}
|
||||
*/
|
||||
Blockly.Python.ORDER_OVERRIDES = [
|
||||
// (foo()).bar() -> foo().bar()
|
||||
// (foo()).bar -> foo().bar
|
||||
// (foo())[0] -> foo()[0]
|
||||
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_MEMBER]
|
||||
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_MEMBER],
|
||||
// (foo())() -> foo()()
|
||||
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_FUNCTION_CALL],
|
||||
// (foo.bar).baz -> foo.bar.baz
|
||||
// (foo.bar)[0] -> foo.bar[0]
|
||||
// (foo[0]).bar -> foo[0].bar
|
||||
// (foo[0])[1] -> foo[0][1]
|
||||
[Blockly.Python.ORDER_MEMBER, Blockly.Python.ORDER_MEMBER],
|
||||
// (foo.bar)() -> foo.bar()
|
||||
// (foo[0])() -> foo[0]()
|
||||
[Blockly.Python.ORDER_MEMBER, Blockly.Python.ORDER_FUNCTION_CALL],
|
||||
|
||||
// not (not foo) -> not not foo
|
||||
[Blockly.Python.ORDER_LOGICAL_NOT, Blockly.Python.ORDER_LOGICAL_NOT],
|
||||
// a and (b and c) -> a and b and c
|
||||
[Blockly.Python.ORDER_LOGICAL_AND, Blockly.Python.ORDER_LOGICAL_AND],
|
||||
// a or (b or c) -> a or b or c
|
||||
[Blockly.Python.ORDER_LOGICAL_OR, Blockly.Python.ORDER_LOGICAL_OR]
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -148,7 +148,7 @@ Blockly.Msg.LISTS_SORT_ORDER_ASCENDING = "па павелічэньні";
|
||||
Blockly.Msg.LISTS_SORT_ORDER_DESCENDING = "па зьмяншэньні";
|
||||
Blockly.Msg.LISTS_SORT_TITLE = "сартаваць %1 %2 %3";
|
||||
Blockly.Msg.LISTS_SORT_TOOLTIP = "Сартаваць копію сьпісу.";
|
||||
Blockly.Msg.LISTS_SORT_TYPE_IGNORECASE = "alphabetic, ignore case"; // untranslated
|
||||
Blockly.Msg.LISTS_SORT_TYPE_IGNORECASE = "паводле альфабэту, ігнараваць рэгістар";
|
||||
Blockly.Msg.LISTS_SORT_TYPE_NUMERIC = "як лікі";
|
||||
Blockly.Msg.LISTS_SORT_TYPE_TEXT = "паводле альфабэту";
|
||||
Blockly.Msg.LISTS_SPLIT_HELPURL = "https://github.com/google/blockly/wiki/Lists#splitting-strings-and-joining-lists"; // untranslated
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = "Ignora o resto deste la
|
||||
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING = "Atenção: Este bloco só pode ser usado dentro de um laço.";
|
||||
Blockly.Msg.CONTROLS_FOREACH_HELPURL = "https://github.com/google/blockly/wiki/Loops#for-each"; // untranslated
|
||||
Blockly.Msg.CONTROLS_FOREACH_TITLE = "para cada item %1 na lista %2";
|
||||
Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "Para cada item em uma lista, atribui o item à variável '%1' e então realiza algumas instruções.";
|
||||
Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "Para cada item em uma lista, atribuir o item à variável '%1' e então realiza algumas instruções.";
|
||||
Blockly.Msg.CONTROLS_FOR_HELPURL = "https://github.com/google/blockly/wiki/Loops#count-with"; // untranslated
|
||||
Blockly.Msg.CONTROLS_FOR_TITLE = "contar com %1 de %2 até %3 por %4";
|
||||
Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Faz com que a variável '%1' assuma os valores do número inicial ao número final, contando de acordo com o intervalo especificado e executa os blocos especificados.";
|
||||
@@ -143,7 +143,7 @@ Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM_END = "Define o item da posição e
|
||||
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM_START = "Define o item da posição especificada de uma lista. #1 é o primeiro item.";
|
||||
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST = "Define o último item de uma lista.";
|
||||
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM = "Define um item aleatório de uma lista.";
|
||||
Blockly.Msg.LISTS_SORT_HELPURL = "https://github.com/google/blockly/wiki/Lists#sorting-a-list"; // untranslated
|
||||
Blockly.Msg.LISTS_SORT_HELPURL = "https://github.com/google/blockly/wiki/Lists#sorting-a-list";
|
||||
Blockly.Msg.LISTS_SORT_ORDER_ASCENDING = "ascendente";
|
||||
Blockly.Msg.LISTS_SORT_ORDER_DESCENDING = "descendente";
|
||||
Blockly.Msg.LISTS_SORT_TITLE = "ordenar %1 %2 %3";
|
||||
|
||||
@@ -280,6 +280,7 @@
|
||||
"LISTS_SORT_ORDER_DESCENDING": "па зьмяншэньні",
|
||||
"LISTS_SORT_TYPE_NUMERIC": "як лікі",
|
||||
"LISTS_SORT_TYPE_TEXT": "паводле альфабэту",
|
||||
"LISTS_SORT_TYPE_IGNORECASE": "паводле альфабэту, ігнараваць рэгістар",
|
||||
"LISTS_SPLIT_LIST_FROM_TEXT": "стварыць сьпіс з тэксту",
|
||||
"LISTS_SPLIT_TEXT_FROM_LIST": "стварыць тэкст са сьпісу",
|
||||
"LISTS_SPLIT_WITH_DELIMITER": "з падзяляльнікам",
|
||||
|
||||
+2
-1
@@ -70,7 +70,7 @@
|
||||
"CONTROLS_FOR_TOOLTIP": "Faz com que a variável '%1' assuma os valores do número inicial ao número final, contando de acordo com o intervalo especificado e executa os blocos especificados.",
|
||||
"CONTROLS_FOR_TITLE": "contar com %1 de %2 até %3 por %4",
|
||||
"CONTROLS_FOREACH_TITLE": "para cada item %1 na lista %2",
|
||||
"CONTROLS_FOREACH_TOOLTIP": "Para cada item em uma lista, atribui o item à variável '%1' e então realiza algumas instruções.",
|
||||
"CONTROLS_FOREACH_TOOLTIP": "Para cada item em uma lista, atribuir o item à variável '%1' e então realiza algumas instruções.",
|
||||
"CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK": "encerra o laço",
|
||||
"CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE": "continua com a próxima iteração do laço",
|
||||
"CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK": "Encerra o laço.",
|
||||
@@ -285,6 +285,7 @@
|
||||
"LISTS_GET_SUBLIST_END_FROM_END": "até nº a partir do final",
|
||||
"LISTS_GET_SUBLIST_END_LAST": "até último",
|
||||
"LISTS_GET_SUBLIST_TOOLTIP": "Cria uma cópia da porção especificada de uma lista.",
|
||||
"LISTS_SORT_HELPURL": "https://github.com/google/blockly/wiki/Lists#sorting-a-list",
|
||||
"LISTS_SORT_TITLE": "ordenar %1 %2 %3",
|
||||
"LISTS_SORT_TOOLTIP": "Ordenar uma cópia de uma lista.",
|
||||
"LISTS_SORT_ORDER_ASCENDING": "ascendente",
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
// Copyright 2012 Google Inc. Apache License 2.0
|
||||
Blockly.Python=new Blockly.Generator("Python");Blockly.Python.addReservedWords("and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,not,or,pass,print,raise,return,try,while,with,yield,True,False,None,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,abs,divmod,input,open,staticmethod,all,enumerate,int,ord,str,any,eval,isinstance,pow,sum,basestring,execfile,issubclass,print,super,bin,file,iter,property,tuple,bool,filter,len,range,type,bytearray,float,list,raw_input,unichr,callable,format,locals,reduce,unicode,chr,frozenset,long,reload,vars,classmethod,getattr,map,repr,xrange,cmp,globals,max,reversed,zip,compile,hasattr,memoryview,round,__import__,complex,hash,min,set,apply,delattr,help,next,setattr,buffer,dict,hex,object,slice,coerce,dir,id,oct,sorted,intern");
|
||||
Blockly.Python.ORDER_ATOMIC=0;Blockly.Python.ORDER_COLLECTION=1;Blockly.Python.ORDER_STRING_CONVERSION=1;Blockly.Python.ORDER_MEMBER=2;Blockly.Python.ORDER_FUNCTION_CALL=2;Blockly.Python.ORDER_EXPONENTIATION=3;Blockly.Python.ORDER_UNARY_SIGN=4;Blockly.Python.ORDER_BITWISE_NOT=4;Blockly.Python.ORDER_MULTIPLICATIVE=5;Blockly.Python.ORDER_ADDITIVE=6;Blockly.Python.ORDER_BITWISE_SHIFT=7;Blockly.Python.ORDER_BITWISE_AND=8;Blockly.Python.ORDER_BITWISE_XOR=9;Blockly.Python.ORDER_BITWISE_OR=10;
|
||||
Blockly.Python.ORDER_RELATIONAL=11;Blockly.Python.ORDER_LOGICAL_NOT=12;Blockly.Python.ORDER_LOGICAL_AND=13;Blockly.Python.ORDER_LOGICAL_OR=14;Blockly.Python.ORDER_CONDITIONAL=15;Blockly.Python.ORDER_LAMBDA=16;Blockly.Python.ORDER_NONE=99;Blockly.Python.ORDER_OVERRIDES=[[Blockly.Python.ORDER_FUNCTION_CALL,Blockly.Python.ORDER_MEMBER]];
|
||||
Blockly.Python.ORDER_ATOMIC=0;Blockly.Python.ORDER_COLLECTION=1;Blockly.Python.ORDER_STRING_CONVERSION=1;Blockly.Python.ORDER_MEMBER=2.1;Blockly.Python.ORDER_FUNCTION_CALL=2.2;Blockly.Python.ORDER_EXPONENTIATION=3;Blockly.Python.ORDER_UNARY_SIGN=4;Blockly.Python.ORDER_BITWISE_NOT=4;Blockly.Python.ORDER_MULTIPLICATIVE=5;Blockly.Python.ORDER_ADDITIVE=6;Blockly.Python.ORDER_BITWISE_SHIFT=7;Blockly.Python.ORDER_BITWISE_AND=8;Blockly.Python.ORDER_BITWISE_XOR=9;Blockly.Python.ORDER_BITWISE_OR=10;
|
||||
Blockly.Python.ORDER_RELATIONAL=11;Blockly.Python.ORDER_LOGICAL_NOT=12;Blockly.Python.ORDER_LOGICAL_AND=13;Blockly.Python.ORDER_LOGICAL_OR=14;Blockly.Python.ORDER_CONDITIONAL=15;Blockly.Python.ORDER_LAMBDA=16;Blockly.Python.ORDER_NONE=99;
|
||||
Blockly.Python.ORDER_OVERRIDES=[[Blockly.Python.ORDER_FUNCTION_CALL,Blockly.Python.ORDER_MEMBER],[Blockly.Python.ORDER_FUNCTION_CALL,Blockly.Python.ORDER_FUNCTION_CALL],[Blockly.Python.ORDER_MEMBER,Blockly.Python.ORDER_MEMBER],[Blockly.Python.ORDER_MEMBER,Blockly.Python.ORDER_FUNCTION_CALL],[Blockly.Python.ORDER_LOGICAL_NOT,Blockly.Python.ORDER_LOGICAL_NOT],[Blockly.Python.ORDER_LOGICAL_AND,Blockly.Python.ORDER_LOGICAL_AND],[Blockly.Python.ORDER_LOGICAL_OR,Blockly.Python.ORDER_LOGICAL_OR]];
|
||||
Blockly.Python.init=function(a){Blockly.Python.PASS=this.INDENT+"pass\n";Blockly.Python.definitions_=Object.create(null);Blockly.Python.functionNames_=Object.create(null);Blockly.Python.variableDB_?Blockly.Python.variableDB_.reset():Blockly.Python.variableDB_=new Blockly.Names(Blockly.Python.RESERVED_WORDS_);var b=[];a=Blockly.Variables.allVariables(a);for(var c=0;c<a.length;c++)b[c]=Blockly.Python.variableDB_.getName(a[c],Blockly.Variables.NAME_TYPE)+" = None";Blockly.Python.definitions_.variables=
|
||||
b.join("\n")};Blockly.Python.finish=function(a){var b=[],c=[],d;for(d in Blockly.Python.definitions_){var e=Blockly.Python.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\S+/)?b.push(e):c.push(e)}delete Blockly.Python.definitions_;delete Blockly.Python.functionNames_;Blockly.Python.variableDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};Blockly.Python.scrubNakedValue=function(a){return a+"\n"};
|
||||
Blockly.Python.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\%/g,"\\%").replace(/'/g,"\\'");return"'"+a+"'"};
|
||||
|
||||
@@ -123,18 +123,18 @@ function test_commonWordSuffix() {
|
||||
}
|
||||
|
||||
function test_tokenizeInterpolation() {
|
||||
var tokens = Blockly.tokenizeInterpolation('');
|
||||
var tokens = Blockly.utils.tokenizeInterpolation('');
|
||||
assertArrayEquals('Null interpolation', [], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello');
|
||||
assertArrayEquals('No interpolation', ['Hello'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello%World');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello%World');
|
||||
assertArrayEquals('Unescaped %.', ['Hello%World'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello%%World');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello%%World');
|
||||
assertArrayEquals('Escaped %.', ['Hello%World'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('Hello %1 World');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('Hello %1 World');
|
||||
assertArrayEquals('Interpolation.', ['Hello ', 1, ' World'], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('%123Hello%456World%789');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('%123Hello%456World%789');
|
||||
assertArrayEquals('Interpolations.', [123, 'Hello', 456, 'World', 789], tokens);
|
||||
tokens = Blockly.tokenizeInterpolation('%%%x%%0%00%01%');
|
||||
tokens = Blockly.utils.tokenizeInterpolation('%%%x%%0%00%01%');
|
||||
assertArrayEquals('Torture interpolations.', ['%%x%0', 0, 1, '%'], tokens);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user