Commit 3450d77d authored by carlosperate's avatar carlosperate

Merge branch 'master' of https://github.com/google/blockly into blockly-original

parents a4b18b6b 7da8998d
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -127,11 +127,11 @@ delete window.BLOCKLY_BOOT; ...@@ -127,11 +127,11 @@ delete window.BLOCKLY_BOOT;
}; };
// Delete any existing Closure (e.g. Soy's nogoog_shim). // Delete any existing Closure (e.g. Soy's nogoog_shim).
document.write('<script type="text/javascript">var goog = undefined;</script>'); document.write('<script>var goog = undefined;</script>');
// Load fresh Closure Library. // Load fresh Closure Library.
document.write('<script type="text/javascript" src="' + window.BLOCKLY_DIR + document.write('<script src="' + window.BLOCKLY_DIR +
'/../closure-library/closure/goog/base.js"></script>'); '/../closure-library/closure/goog/base.js"></script>');
document.write('<script type="text/javascript">window.BLOCKLY_BOOT()</script>'); document.write('<script>window.BLOCKLY_BOOT()</script>');
""") """)
f.close() f.close()
print('SUCCESS: ' + target_filename) print('SUCCESS: ' + target_filename)
...@@ -261,10 +261,11 @@ class Gen_compressed(threading.Thread): ...@@ -261,10 +261,11 @@ class Gen_compressed(threading.Thread):
for error in errors: for error in errors:
print('FATAL ERROR') print('FATAL ERROR')
print(error['error']) print(error['error'])
print('%s at line %d:' % ( if error['file']:
file_lookup(error['file']), error['lineno'])) print('%s at line %d:' % (
print(error['line']) file_lookup(error['file']), error['lineno']))
print((' ' * error['charno']) + '^') print(error['line'])
print((' ' * error['charno']) + '^')
sys.exit(1) sys.exit(1)
else: else:
if json_data.has_key('warnings'): if json_data.has_key('warnings'):
...@@ -272,10 +273,11 @@ class Gen_compressed(threading.Thread): ...@@ -272,10 +273,11 @@ class Gen_compressed(threading.Thread):
for warning in warnings: for warning in warnings:
print('WARNING') print('WARNING')
print(warning['warning']) print(warning['warning'])
print('%s at line %d:' % ( if warning['file']:
file_lookup(warning['file']), warning['lineno'])) print('%s at line %d:' % (
print(warning['line']) file_lookup(warning['file']), warning['lineno']))
print((' ' * warning['charno']) + '^') print(warning['line'])
print((' ' * warning['charno']) + '^')
print() print()
if not json_data.has_key('compiledCode'): if not json_data.has_key('compiledCode'):
......
...@@ -300,6 +300,7 @@ Blockly.Block.terminateDrag_ = function() { ...@@ -300,6 +300,7 @@ Blockly.Block.terminateDrag_ = function() {
selected.workspace.fireChangeEvent(); selected.workspace.fireChangeEvent();
} }
Blockly.Block.dragMode_ = 0; Blockly.Block.dragMode_ = 0;
Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
}; };
/** /**
...@@ -572,13 +573,15 @@ Blockly.Block.prototype.onMouseUp_ = function(e) { ...@@ -572,13 +573,15 @@ Blockly.Block.prototype.onMouseUp_ = function(e) {
} }
inferiorConnection.sourceBlock_.svg_.connectionUiEffect(); inferiorConnection.sourceBlock_.svg_.connectionUiEffect();
} }
if (this_.workspace.trashcan && this_.workspace.trashcan.isOpen) { if (this_.workspace.trashcan) {
// Don't throw an object in the trash can if it just got connected. // Don't throw an object in the trash can if it just got connected.
this_.workspace.trashcan.close(); this_.workspace.trashcan.close();
} }
} else if (this_.workspace.trashcan && this_.workspace.trashcan.isOpen) { } else if (this_.workspace.isDeleteArea(e)) {
var trashcan = this_.workspace.trashcan; var trashcan = this_.workspace.trashcan;
goog.Timer.callOnce(trashcan.close, 100, trashcan); if (trashcan) {
goog.Timer.callOnce(trashcan.close, 100, trashcan);
}
Blockly.selected.dispose(false, true); Blockly.selected.dispose(false, true);
// Dropping a block on the trash can will usually cause the workspace to // Dropping a block on the trash can will usually cause the workspace to
// resize to contain the newly positioned block. Force a second resize // resize to contain the newly positioned block. Force a second resize
...@@ -589,6 +592,7 @@ Blockly.Block.prototype.onMouseUp_ = function(e) { ...@@ -589,6 +592,7 @@ Blockly.Block.prototype.onMouseUp_ = function(e) {
Blockly.highlightedConnection_.unhighlight(); Blockly.highlightedConnection_.unhighlight();
Blockly.highlightedConnection_ = null; Blockly.highlightedConnection_ = null;
} }
Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
}); });
}; };
...@@ -862,6 +866,7 @@ Blockly.Block.prototype.onMouseMove_ = function(e) { ...@@ -862,6 +866,7 @@ Blockly.Block.prototype.onMouseMove_ = function(e) {
// Push this block to the very top of the stack. // Push this block to the very top of the stack.
this_.setParent(null); this_.setParent(null);
this_.setDragging_(true); this_.setDragging_(true);
this_.workspace.recordDeleteAreas();
} }
} }
if (Blockly.Block.dragMode_ == 2) { if (Blockly.Block.dragMode_ == 2) {
...@@ -907,9 +912,10 @@ Blockly.Block.prototype.onMouseMove_ = function(e) { ...@@ -907,9 +912,10 @@ Blockly.Block.prototype.onMouseMove_ = function(e) {
Blockly.highlightedConnection_ = closestConnection; Blockly.highlightedConnection_ = closestConnection;
Blockly.localConnection_ = localConnection; Blockly.localConnection_ = localConnection;
} }
// Flip the trash can lid if needed. // Provide visual indication of whether the block will be deleted if
if (this_.workspace.trashcan && this_.isDeletable()) { // dropped here.
this_.workspace.trashcan.onMouseMove(e); if (this_.isDeletable()) {
this_.workspace.isDeleteArea(e);
} }
} }
// This event has been handled. No need to bubble up to the document. // This event has been handled. No need to bubble up to the document.
......
...@@ -868,19 +868,20 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, highlightSteps, ...@@ -868,19 +868,20 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, highlightSteps,
highlightInlineSteps.push('h', highlightInlineSteps.push('h',
input.renderWidth - Blockly.BlockSvg.TAB_WIDTH + 1); input.renderWidth - Blockly.BlockSvg.TAB_WIDTH + 1);
} else { } else {
// Highlight right edge, bottom, and glint at bottom of tab. // Highlight right edge, bottom.
highlightInlineSteps.push('M', highlightInlineSteps.push('M',
(cursorX - Blockly.BlockSvg.SEP_SPACE_X + 1) + ',' + (cursorX - Blockly.BlockSvg.SEP_SPACE_X + 1) + ',' +
(cursorY + Blockly.BlockSvg.INLINE_PADDING_Y + 1)); (cursorY + Blockly.BlockSvg.INLINE_PADDING_Y + 1));
highlightInlineSteps.push('v', input.renderHeight + 1); highlightInlineSteps.push('v', input.renderHeight + 1);
highlightInlineSteps.push('h', Blockly.BlockSvg.TAB_WIDTH - 2 - highlightInlineSteps.push('h', Blockly.BlockSvg.TAB_WIDTH - 2 -
input.renderWidth); input.renderWidth);
// Short highlight glint at bottom of tab.
highlightInlineSteps.push('M', highlightInlineSteps.push('M',
(cursorX - input.renderWidth - Blockly.BlockSvg.SEP_SPACE_X + (cursorX - input.renderWidth - Blockly.BlockSvg.SEP_SPACE_X +
0.8) + ',' + (cursorY + Blockly.BlockSvg.INLINE_PADDING_Y + 1.8) + ',' + (cursorY + Blockly.BlockSvg.INLINE_PADDING_Y +
Blockly.BlockSvg.TAB_HEIGHT - 0.4)); Blockly.BlockSvg.TAB_HEIGHT - 0.4));
highlightInlineSteps.push('l', highlightInlineSteps.push('l',
(Blockly.BlockSvg.TAB_WIDTH * 0.42) + ',-1.8'); (Blockly.BlockSvg.TAB_WIDTH * 0.38) + ',-1.8');
} }
// Create inline input connection. // Create inline input connection.
if (Blockly.RTL) { if (Blockly.RTL) {
...@@ -935,7 +936,7 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, highlightSteps, ...@@ -935,7 +936,7 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, highlightSteps,
// Short highlight glint at bottom of tab. // Short highlight glint at bottom of tab.
highlightSteps.push('M', (inputRows.rightEdge - 4.2) + ',' + highlightSteps.push('M', (inputRows.rightEdge - 4.2) + ',' +
(cursorY + Blockly.BlockSvg.TAB_HEIGHT - 0.4)); (cursorY + Blockly.BlockSvg.TAB_HEIGHT - 0.4));
highlightSteps.push('l', (Blockly.BlockSvg.TAB_WIDTH * 0.42) + highlightSteps.push('l', (Blockly.BlockSvg.TAB_WIDTH * 0.38) +
',-1.8'); ',-1.8');
} }
// Create external input connection. // Create external input connection.
......
...@@ -101,7 +101,7 @@ Blockly.SPRITE = { ...@@ -101,7 +101,7 @@ Blockly.SPRITE = {
*/ */
Blockly.makeColour = function(hue) { Blockly.makeColour = function(hue) {
return goog.color.hsvToHex(hue, Blockly.HSV_SATURATION, return goog.color.hsvToHex(hue, Blockly.HSV_SATURATION,
Blockly.HSV_VALUE * 256); Blockly.HSV_VALUE * 255);
}; };
/** /**
...@@ -512,8 +512,10 @@ Blockly.hideChaff = function(opt_allowToolbox) { ...@@ -512,8 +512,10 @@ Blockly.hideChaff = function(opt_allowToolbox) {
Blockly.Tooltip.hide(); Blockly.Tooltip.hide();
Blockly.WidgetDiv.hide(); Blockly.WidgetDiv.hide();
if (!opt_allowToolbox && if (!opt_allowToolbox &&
Blockly.Toolbox.flyout_ && Blockly.Toolbox.flyout_.autoClose) { Blockly.mainWorkspace.toolbox_ &&
Blockly.Toolbox.clearSelection(); Blockly.mainWorkspace.toolbox_.flyout_ &&
Blockly.mainWorkspace.toolbox_.flyout_.autoClose) {
Blockly.mainWorkspace.toolbox_.clearSelection();
} }
}; };
...@@ -638,7 +640,9 @@ Blockly.playAudio = function(name, opt_volume) { ...@@ -638,7 +640,9 @@ Blockly.playAudio = function(name, opt_volume) {
*/ */
Blockly.getMainWorkspaceMetrics_ = function() { Blockly.getMainWorkspaceMetrics_ = function() {
var svgSize = Blockly.svgSize(); var svgSize = Blockly.svgSize();
svgSize.width -= Blockly.Toolbox.width; // Zero if no Toolbox. if (Blockly.mainWorkspace.toolbox_) {
svgSize.width -= Blockly.mainWorkspace.toolbox_.width;
}
var viewWidth = svgSize.width - Blockly.Scrollbar.scrollbarThickness; var viewWidth = svgSize.width - Blockly.Scrollbar.scrollbarThickness;
var viewHeight = svgSize.height - Blockly.Scrollbar.scrollbarThickness; var viewHeight = svgSize.height - Blockly.Scrollbar.scrollbarThickness;
try { try {
...@@ -664,7 +668,10 @@ Blockly.getMainWorkspaceMetrics_ = function() { ...@@ -664,7 +668,10 @@ Blockly.getMainWorkspaceMetrics_ = function() {
var topEdge = blockBox.y; var topEdge = blockBox.y;
var bottomEdge = topEdge + blockBox.height; var bottomEdge = topEdge + blockBox.height;
} }
var absoluteLeft = Blockly.RTL ? 0 : Blockly.Toolbox.width; var absoluteLeft = 0;
if (!Blockly.RTL && Blockly.mainWorkspace.toolbox_) {
absoluteLeft = Blockly.mainWorkspace.toolbox_.width;
}
var metrics = { var metrics = {
viewHeight: svgSize.height, viewHeight: svgSize.height,
viewWidth: svgSize.width, viewWidth: svgSize.width,
......
...@@ -28,6 +28,7 @@ goog.provide('Blockly.Connection'); ...@@ -28,6 +28,7 @@ goog.provide('Blockly.Connection');
goog.provide('Blockly.ConnectionDB'); goog.provide('Blockly.ConnectionDB');
goog.require('Blockly.Workspace'); goog.require('Blockly.Workspace');
goog.require('Blockly.BlockSvg');
/** /**
...@@ -348,9 +349,9 @@ Blockly.Connection.prototype.highlight = function() { ...@@ -348,9 +349,9 @@ Blockly.Connection.prototype.highlight = function() {
tabWidth + ',-2.5 ' + tabWidth + ',7.5 v 5'; tabWidth + ',-2.5 ' + tabWidth + ',7.5 v 5';
} else { } else {
if (Blockly.RTL) { if (Blockly.RTL) {
steps = 'm 20,0 h -5 l -6,4 -3,0 -6,-4 h -5'; steps = 'm 20,0 h -5 ' + Blockly.BlockSvg.NOTCH_PATH_RIGHT + ' h -5';
} else { } else {
steps = 'm -20,0 h 5 l 6,4 3,0 6,-4 h 5'; steps = 'm -20,0 h 5 ' + Blockly.BlockSvg.NOTCH_PATH_LEFT + ' h 5';
} }
} }
var xy = this.sourceBlock_.getRelativeToSurfaceXY(); var xy = this.sourceBlock_.getRelativeToSurfaceXY();
......
...@@ -28,6 +28,7 @@ goog.provide('Blockly.Css'); ...@@ -28,6 +28,7 @@ goog.provide('Blockly.Css');
goog.require('goog.cssom'); goog.require('goog.cssom');
/** /**
* List of cursors. * List of cursors.
* @enum {string} * @enum {string}
...@@ -38,6 +39,12 @@ Blockly.Css.Cursor = { ...@@ -38,6 +39,12 @@ Blockly.Css.Cursor = {
DELETE: 'handdelete' DELETE: 'handdelete'
}; };
/**
* Current cursor (cached value).
* @type string
*/
Blockly.Css.currentCursor_ = '';
/** /**
* Large stylesheet added by Blockly.Css.inject. * Large stylesheet added by Blockly.Css.inject.
* @type Element * @type Element
...@@ -64,10 +71,8 @@ Blockly.Css.inject = function() { ...@@ -64,10 +71,8 @@ Blockly.Css.inject = function() {
// Strip off any trailing slash (either Unix or Windows). // Strip off any trailing slash (either Unix or Windows).
Blockly.Css.mediaPath_ = Blockly.pathToMedia.replace(/[\\\/]$/, ''); Blockly.Css.mediaPath_ = Blockly.pathToMedia.replace(/[\\\/]$/, '');
text = text.replace(/<<<PATH>>>/g, Blockly.Css.mediaPath_); text = text.replace(/<<<PATH>>>/g, Blockly.Css.mediaPath_);
goog.cssom.addCssText(text); Blockly.Css.styleSheet_ = goog.cssom.addCssText(text).sheet;
var sheets = goog.cssom.getAllCssStyleSheets(); Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
Blockly.Css.styleSheet_ = sheets[sheets.length - 1];
Blockly.Css.setCursor('handopen');
}; };
/** /**
...@@ -75,9 +80,10 @@ Blockly.Css.inject = function() { ...@@ -75,9 +80,10 @@ Blockly.Css.inject = function() {
* @param {Blockly.Cursor} cursor Enum. * @param {Blockly.Cursor} cursor Enum.
*/ */
Blockly.Css.setCursor = function(cursor) { Blockly.Css.setCursor = function(cursor) {
if (Blockly.readOnly) { if (Blockly.readOnly || Blockly.Css.currentCursor_ == cursor) {
return; return;
} }
Blockly.Css.currentCursor_ = cursor;
/* /*
Hotspot coordinates are baked into the CUR file, but they are still Hotspot coordinates are baked into the CUR file, but they are still
required in the CSS due to a Chrome bug. required in the CSS due to a Chrome bug.
...@@ -88,10 +94,30 @@ Blockly.Css.setCursor = function(cursor) { ...@@ -88,10 +94,30 @@ Blockly.Css.setCursor = function(cursor) {
} else { } else {
var xy = '7 3'; var xy = '7 3';
} }
var rule = '.blocklyDraggable {\n' + var url = 'url(' + Blockly.Css.mediaPath_ + '/' + cursor +
' cursor: url(' + Blockly.Css.mediaPath_ + '/' + cursor + '.cur)' + '.cur) ' + xy + ', auto';
' ' + xy + ', auto;\n}\n'; // There are potentially hundreds of draggable objects. Changing their style
// properties individually is too slow, so change the CSS rule instead.
var rule = '.blocklyDraggable {\n cursor: ' + url + ';\n}\n';
goog.cssom.replaceCssRule('', rule, Blockly.Css.styleSheet_, 0); goog.cssom.replaceCssRule('', rule, Blockly.Css.styleSheet_, 0);
// There is probably only one toolbox, so just change its style property.
var toolboxen = document.getElementsByClassName('blocklyToolboxDiv');
for (var i = 0, toolbox; toolbox = toolboxen[i]; i++) {
if (cursor == Blockly.Css.Cursor.OPEN) {
toolbox.style.cursor = '';
} else {
toolbox.style.cursor = url;
}
}
// Set cursor on the SVG surface as well, so that rapid movements
// don't result in cursor changing to an arrow momentarily.
if (Blockly.svg) {
if (cursor == Blockly.Css.Cursor.OPEN) {
Blockly.svg.style.cursor = '';
} else {
Blockly.svg.style.cursor = url;
}
}
}; };
/** /**
......
...@@ -253,6 +253,9 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() { ...@@ -253,6 +253,9 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
* @return {?string} A string representing a valid number, or null if invalid. * @return {?string} A string representing a valid number, or null if invalid.
*/ */
Blockly.FieldTextInput.numberValidator = function(text) { Blockly.FieldTextInput.numberValidator = function(text) {
if(text === null) {
return null;
}
// TODO: Handle cases like 'ten', '1.203,14', etc. // TODO: Handle cases like 'ten', '1.203,14', etc.
// 'O' is sometimes mistaken for '0' by inexperienced users. // 'O' is sometimes mistaken for '0' by inexperienced users.
text = text.replace(/O/ig, '0'); text = text.replace(/O/ig, '0');
......
...@@ -29,6 +29,7 @@ goog.provide('Blockly.Flyout'); ...@@ -29,6 +29,7 @@ goog.provide('Blockly.Flyout');
goog.require('Blockly.Block'); goog.require('Blockly.Block');
goog.require('Blockly.Comment'); goog.require('Blockly.Comment');
goog.require('goog.userAgent'); goog.require('goog.userAgent');
goog.require('goog.math.Rect');
/** /**
...@@ -670,3 +671,20 @@ Blockly.Flyout.terminateDrag_ = function() { ...@@ -670,3 +671,20 @@ Blockly.Flyout.terminateDrag_ = function() {
Blockly.Flyout.startBlock_ = null; Blockly.Flyout.startBlock_ = null;
Blockly.Flyout.startFlyout_ = null; Blockly.Flyout.startFlyout_ = null;
}; };
/**
* Return the deletion rectangle for this flyout.
* @return {goog.math.Rect} Rectangle in which to delete.
*/
Blockly.Flyout.prototype.getRect = function() {
// BIG_NUM is offscreen padding so that blocks dragged beyond the shown flyout
// area are still deleted. Must be smaller than Infinity, but larger than
// the largest screen size.
var BIG_NUM = 10000000;
var x = Blockly.getSvgXY_(this.svgGroup_).x;
if (!Blockly.RTL) {
x -= BIG_NUM;
}
return new goog.math.Rect(x, -BIG_NUM,
BIG_NUM + this.width_, this.height_ + 2 * BIG_NUM);
};
...@@ -117,14 +117,9 @@ Blockly.parseOptions_ = function(options) { ...@@ -117,14 +117,9 @@ Blockly.parseOptions_ = function(options) {
hasDisable = hasCategories; hasDisable = hasCategories;
} }
} }
if (tree && !hasCategories) { var hasScrollbars = options['scrollbars'];
// Scrollbars are not compatible with a non-flyout toolbox. if (hasScrollbars === undefined) {
var hasScrollbars = false; hasScrollbars = hasCategories;
} else {
var hasScrollbars = options['scrollbars'];
if (hasScrollbars === undefined) {
hasScrollbars = true;
}
} }
var hasSounds = options['sounds']; var hasSounds = options['sounds'];
if (hasSounds === undefined) { if (hasSounds === undefined) {
...@@ -275,7 +270,7 @@ Blockly.createDom_ = function(container) { ...@@ -275,7 +270,7 @@ Blockly.createDom_ = function(container) {
// Determine if there needs to be a category tree, or a simple list of // Determine if there needs to be a category tree, or a simple list of
// blocks. This cannot be changed later, since the UI is very different. // blocks. This cannot be changed later, since the UI is very different.
if (Blockly.hasCategories) { if (Blockly.hasCategories) {
Blockly.Toolbox.createDom(svg, container); Blockly.mainWorkspace.toolbox_ = new Blockly.Toolbox(svg, container);
} else { } else {
/** /**
* @type {!Blockly.Flyout} * @type {!Blockly.Flyout}
...@@ -287,51 +282,48 @@ Blockly.createDom_ = function(container) { ...@@ -287,51 +282,48 @@ Blockly.createDom_ = function(container) {
flyout.autoClose = false; flyout.autoClose = false;
// Insert the flyout behind the workspace so that blocks appear on top. // Insert the flyout behind the workspace so that blocks appear on top.
goog.dom.insertSiblingBefore(flyoutSvg, Blockly.mainWorkspace.svgGroup_); goog.dom.insertSiblingBefore(flyoutSvg, Blockly.mainWorkspace.svgGroup_);
}
if (!Blockly.hasScrollbars) {
var workspaceChanged = function() { var workspaceChanged = function() {
if (Blockly.Block.dragMode_ == 0) { if (Blockly.Block.dragMode_ == 0) {
var metrics = Blockly.mainWorkspace.getMetrics(); var metrics = Blockly.mainWorkspace.getMetrics();
if (metrics.contentTop < 0 || var edgeLeft = metrics.viewLeft + metrics.absoluteLeft;
var edgeTop = metrics.viewTop + metrics.absoluteTop;
if (metrics.contentTop < edgeTop ||
metrics.contentTop + metrics.contentHeight > metrics.contentTop + metrics.contentHeight >
metrics.viewHeight + metrics.viewTop || metrics.viewHeight + edgeTop ||
metrics.contentLeft < (Blockly.RTL ? metrics.viewLeft : 0) || metrics.contentLeft <
(Blockly.RTL ? metrics.viewLeft : edgeLeft) ||
metrics.contentLeft + metrics.contentWidth > (Blockly.RTL ? metrics.contentLeft + metrics.contentWidth > (Blockly.RTL ?
metrics.viewWidth : metrics.viewWidth : metrics.viewWidth + edgeLeft)) {
metrics.viewWidth + metrics.viewLeft)) { // One or more blocks may be out of bounds. Bump them back in.
// One or more blocks is out of bounds. Bump them back in.
var MARGIN = 25; var MARGIN = 25;
var blocks = Blockly.mainWorkspace.getTopBlocks(false); var blocks = Blockly.mainWorkspace.getTopBlocks(false);
for (var b = 0, block; block = blocks[b]; b++) { for (var b = 0, block; block = blocks[b]; b++) {
var blockXY = block.getRelativeToSurfaceXY(); var blockXY = block.getRelativeToSurfaceXY();
var blockHW = block.getHeightWidth(); var blockHW = block.getHeightWidth();
// Bump any block that's above the top back inside. // Bump any block that's above the top back inside.
var overflow = metrics.viewTop + MARGIN - blockHW.height - var overflow = edgeTop + MARGIN - blockHW.height - blockXY.y;
blockXY.y;
if (overflow > 0) { if (overflow > 0) {
block.moveBy(0, overflow); block.moveBy(0, overflow);
} }
// Bump any block that's below the bottom back inside. // Bump any block that's below the bottom back inside.
var overflow = metrics.viewTop + metrics.viewHeight - MARGIN - var overflow = edgeTop + metrics.viewHeight - MARGIN - blockXY.y;
blockXY.y;
if (overflow < 0) { if (overflow < 0) {
block.moveBy(0, overflow); block.moveBy(0, overflow);
} }
// Bump any block that's off the left back inside. // Bump any block that's off the left back inside.
var overflow = MARGIN + metrics.viewLeft - blockXY.x - var overflow = MARGIN + edgeLeft -
(Blockly.RTL ? 0 : blockHW.width); blockXY.x - (Blockly.RTL ? 0 : blockHW.width);
if (overflow > 0) { if (overflow > 0) {
block.moveBy(overflow, 0); block.moveBy(overflow, 0);
} }
// Bump any block that's off the right back inside. // Bump any block that's off the right back inside.
var overflow = metrics.viewLeft + metrics.viewWidth - MARGIN - var overflow = edgeLeft + metrics.viewWidth - MARGIN -
blockXY.x + (Blockly.RTL ? blockHW.width : 0); blockXY.x + (Blockly.RTL ? blockHW.width : 0);
if (overflow < 0) { if (overflow < 0) {
block.moveBy(overflow, 0); block.moveBy(overflow, 0);
} }
// Delete any block that's sitting on top of the flyout.
if (block.isDeletable() && (Blockly.RTL ?
blockXY.x - metrics.viewWidth : -blockXY.x) > MARGIN * 2) {
block.dispose(false, true);
}
} }
} }
} }
...@@ -389,9 +381,9 @@ Blockly.init_ = function() { ...@@ -389,9 +381,9 @@ Blockly.init_ = function() {
} }
if (Blockly.languageTree) { if (Blockly.languageTree) {
if (Blockly.hasCategories) { if (Blockly.mainWorkspace.toolbox_) {
Blockly.Toolbox.init(); Blockly.mainWorkspace.toolbox_.init();
} else { } else if (Blockly.mainWorkspace.flyout_) {
// Build a fixed flyout with the root blocks. // Build a fixed flyout with the root blocks.
Blockly.mainWorkspace.flyout_.init(Blockly.mainWorkspace); Blockly.mainWorkspace.flyout_.init(Blockly.mainWorkspace);
Blockly.mainWorkspace.flyout_.show(Blockly.languageTree.childNodes); Blockly.mainWorkspace.flyout_.show(Blockly.languageTree.childNodes);
...@@ -463,7 +455,7 @@ Blockly.updateToolbox = function(tree) { ...@@ -463,7 +455,7 @@ Blockly.updateToolbox = function(tree) {
throw 'Existing toolbox has no categories. Can\'t change mode.'; throw 'Existing toolbox has no categories. Can\'t change mode.';
} }
Blockly.languageTree = tree; Blockly.languageTree = tree;
Blockly.Toolbox.populate_(); Blockly.mainWorkspace.toolbox_.populate_();
} else { } else {
if (Blockly.hasCategories) { if (Blockly.hasCategories) {
throw 'Existing toolbox has categories. Can\'t change mode.'; throw 'Existing toolbox has categories. Can\'t change mode.';
......
...@@ -118,9 +118,9 @@ Blockly.Mutator.prototype.createEditor_ = function() { ...@@ -118,9 +118,9 @@ Blockly.Mutator.prototype.createEditor_ = function() {
var mutator = this; var mutator = this;
this.workspace_ = new Blockly.Workspace( this.workspace_ = new Blockly.Workspace(
function() {return mutator.getFlyoutMetrics_();}, null); function() {return mutator.getFlyoutMetrics_();}, null);
this.flyout_ = new Blockly.Flyout(); this.workspace_.flyout_ = new Blockly.Flyout();
this.flyout_.autoClose = false; this.workspace_.flyout_.autoClose = false;
this.svgDialog_.appendChild(this.flyout_.createDom()); this.svgDialog_.appendChild(this.workspace_.flyout_.createDom());
this.svgDialog_.appendChild(this.workspace_.createDom()); this.svgDialog_.appendChild(this.workspace_.createDom());
return this.svgDialog_; return this.svgDialog_;
}; };
...@@ -148,7 +148,7 @@ Blockly.Mutator.prototype.updateEditable = function() { ...@@ -148,7 +148,7 @@ Blockly.Mutator.prototype.updateEditable = function() {
Blockly.Mutator.prototype.resizeBubble_ = function() { Blockly.Mutator.prototype.resizeBubble_ = function() {
var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH; var doubleBorderWidth = 2 * Blockly.Bubble.BORDER_WIDTH;
var workspaceSize = this.workspace_.getCanvas().getBBox(); var workspaceSize = this.workspace_.getCanvas().getBBox();
var flyoutMetrics = this.flyout_.getMetrics_(); var flyoutMetrics = this.workspace_.flyout_.getMetrics_();
var width; var width;
if (Blockly.RTL) { if (Blockly.RTL) {
width = -workspaceSize.x; width = -workspaceSize.x;
...@@ -193,8 +193,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) { ...@@ -193,8 +193,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
this.createEditor_(), this.block_.svg_.svgPath_, this.createEditor_(), this.block_.svg_.svgPath_,
this.iconX_, this.iconY_, null, null); this.iconX_, this.iconY_, null, null);
var thisObj = this; var thisObj = this;
this.flyout_.init(this.workspace_); this.workspace_.flyout_.init(this.workspace_);
this.flyout_.show(this.quarkXml_); this.workspace_.flyout_.show(this.quarkXml_);
this.rootBlock_ = this.block_.decompose(this.workspace_); this.rootBlock_ = this.block_.decompose(this.workspace_);
var blocks = this.rootBlock_.getDescendants(); var blocks = this.rootBlock_.getDescendants();
...@@ -204,8 +204,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) { ...@@ -204,8 +204,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
// The root block should not be dragable or deletable. // The root block should not be dragable or deletable.
this.rootBlock_.setMovable(false); this.rootBlock_.setMovable(false);
this.rootBlock_.setDeletable(false); this.rootBlock_.setDeletable(false);
var margin = this.flyout_.CORNER_RADIUS * 2; var margin = this.workspace_.flyout_.CORNER_RADIUS * 2;
var x = this.flyout_.width_ + margin; var x = this.workspace_.flyout_.width_ + margin;
if (Blockly.RTL) { if (Blockly.RTL) {
x = -x; x = -x;
} }
...@@ -226,8 +226,6 @@ Blockly.Mutator.prototype.setVisible = function(visible) { ...@@ -226,8 +226,6 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
} else { } else {
// Dispose of the bubble. // Dispose of the bubble.
this.svgDialog_ = null; this.svgDialog_ = null;
this.flyout_.dispose();
this.flyout_ = null;
this.workspace_.dispose(); this.workspace_.dispose();
this.workspace_ = null; this.workspace_ = null;
this.rootBlock_ = null; this.rootBlock_ = null;
...@@ -244,7 +242,7 @@ Blockly.Mutator.prototype.setVisible = function(visible) { ...@@ -244,7 +242,7 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
/** /**
* Update the source block when the mutator's blocks are changed. * Update the source block when the mutator's blocks are changed.
* Delete or bump any block that's out of bounds. * Bump down any block that's too high.
* Fired whenever a change is made to the mutator's workspace. * Fired whenever a change is made to the mutator's workspace.
* @private * @private
*/ */
...@@ -255,12 +253,7 @@ Blockly.Mutator.prototype.workspaceChanged_ = function() { ...@@ -255,12 +253,7 @@ Blockly.Mutator.prototype.workspaceChanged_ = function() {
for (var b = 0, block; block = blocks[b]; b++) { for (var b = 0, block; block = blocks[b]; b++) {
var blockXY = block.getRelativeToSurfaceXY(); var blockXY = block.getRelativeToSurfaceXY();
var blockHW = block.getHeightWidth(); var blockHW = block.getHeightWidth();
if (block.isDeletable() && (Blockly.RTL ? if (blockXY.y + blockHW.height < MARGIN) {
blockXY.x > -this.flyout_.width_ + MARGIN :
blockXY.x < this.flyout_.width_ - MARGIN)) {
// Delete any block that's sitting on top of the flyout.
block.dispose(false, true);
} else if (blockXY.y + blockHW.height < MARGIN) {
// Bump any block that's above the top back inside. // Bump any block that's above the top back inside.
block.moveBy(0, MARGIN - blockHW.height - blockXY.y); block.moveBy(0, MARGIN - blockHW.height - blockXY.y);
} }
......
...@@ -221,7 +221,7 @@ Blockly.Realtime.getBlockById = function(id) { ...@@ -221,7 +221,7 @@ Blockly.Realtime.getBlockById = function(id) {
}; };
/** /**
* Log the event for debugging purposses. * Log the event for debugging purposes.
* @param {gapi.drive.realtime.BaseModelEvent} evt The event that occurred. * @param {gapi.drive.realtime.BaseModelEvent} evt The event that occurred.
* @private * @private
*/ */
...@@ -263,9 +263,9 @@ Blockly.Realtime.onObjectChange_ = function(evt) { ...@@ -263,9 +263,9 @@ Blockly.Realtime.onObjectChange_ = function(evt) {
event.property == 'relativeY') { event.property == 'relativeY') {
Blockly.Realtime.doWithinSync_(function() { Blockly.Realtime.doWithinSync_(function() {
if (!block.svg_) { if (!block.svg_) {
// If this is a move of a newly disconnected (i.e newly top // If this is a move of a newly disconnected (i.e. newly top
// level) block it will not have any svg (because it has been // level) block it will not have any svg (because it has been
// disposed of by it's parent), so we need to handle that here. // disposed of by its parent), so we need to handle that here.
Blockly.Realtime.placeBlockOnWorkspace_(block, false); Blockly.Realtime.placeBlockOnWorkspace_(block, false);
} }
Blockly.Realtime.moveBlock_(block); Blockly.Realtime.moveBlock_(block);
...@@ -715,7 +715,7 @@ Blockly.Realtime.startRealtime = function(uiInitialize, uiContainer, options) { ...@@ -715,7 +715,7 @@ Blockly.Realtime.startRealtime = function(uiInitialize, uiContainer, options) {
Blockly.Realtime.enabled_ = true; Blockly.Realtime.enabled_ = true;
// Note that we need to setup the UI for realtime authorization before // Note that we need to setup the UI for realtime authorization before
// loading the realtime code (which, in turn, will handle initializing the // loading the realtime code (which, in turn, will handle initializing the
// rest of the Blockly UI. // rest of the Blockly UI).
var authDiv = Blockly.Realtime.addAuthUi_(uiContainer); var authDiv = Blockly.Realtime.addAuthUi_(uiContainer);
Blockly.Realtime.initUi_ = function() { Blockly.Realtime.initUi_ = function() {
uiInitialize(); uiInitialize();
...@@ -739,7 +739,7 @@ Blockly.Realtime.startRealtime = function(uiInitialize, uiContainer, options) { ...@@ -739,7 +739,7 @@ Blockly.Realtime.startRealtime = function(uiInitialize, uiContainer, options) {
* @private * @private
*/ */
Blockly.Realtime.addAuthUi_ = function(uiContainer) { Blockly.Realtime.addAuthUi_ = function(uiContainer) {
// Add progess indicator to the UI container. // Add progress indicator to the UI container.
uiContainer.style.background = 'url(' + Blockly.pathToMedia + uiContainer.style.background = 'url(' + Blockly.pathToMedia +
Blockly.Realtime.PROGRESS_URL_ + ') no-repeat center center'; Blockly.Realtime.PROGRESS_URL_ + ') no-repeat center center';
// Setup authorization button // Setup authorization button
...@@ -817,7 +817,7 @@ Blockly.Realtime.onCollaboratorLeft_ = function(event) { ...@@ -817,7 +817,7 @@ Blockly.Realtime.onCollaboratorLeft_ = function(event) {
/** /**
* Execute a command. Generally, a command is the result of a user action * Execute a command. Generally, a command is the result of a user action
* e.g., a click, drag or context menu selection. * e.g. a click, drag or context menu selection.
* @param {function()} cmdThunk A function representing the command execution. * @param {function()} cmdThunk A function representing the command execution.
*/ */
Blockly.Realtime.doCommand = function(cmdThunk) { Blockly.Realtime.doCommand = function(cmdThunk) {
......
This diff is collapsed.
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
goog.provide('Blockly.Trashcan'); goog.provide('Blockly.Trashcan');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.math.Rect');
goog.require('goog.Timer'); goog.require('goog.Timer');
...@@ -238,32 +239,16 @@ Blockly.Trashcan.prototype.position_ = function() { ...@@ -238,32 +239,16 @@ Blockly.Trashcan.prototype.position_ = function() {
}; };
/** /**
* Determines if the mouse is currently over the trash can. * Return the deletion rectangle for this trashcan.
* Opens/closes the lid and sets the isOpen flag. * @return {goog.math.Rect} Rectangle in which to delete.
* @param {!Event} e Mouse move event.
*/ */
Blockly.Trashcan.prototype.onMouseMove = function(e) { Blockly.Trashcan.prototype.getRect = function() {
/*
An alternative approach would be to use onMouseOver and onMouseOut events.
However the selected block will be between the mouse and the trash can,
thus these events won't fire.
Another approach is to use HTML5's drag & drop API, but it's widely hated.
Instead, we'll just have the block's drag_ function call us.
*/
if (!this.svgGroup_) {
return;
}
var mouseXY = Blockly.mouseToSvg(e);
var trashXY = Blockly.getSvgXY_(this.svgGroup_); var trashXY = Blockly.getSvgXY_(this.svgGroup_);
var over = (mouseXY.x > trashXY.x - this.MARGIN_HOTSPOT_) && return new goog.math.Rect(
(mouseXY.x < trashXY.x + this.WIDTH_ + this.MARGIN_HOTSPOT_) && trashXY.x - this.MARGIN_HOTSPOT_,
(mouseXY.y > trashXY.y - this.MARGIN_HOTSPOT_) && trashXY.y - this.MARGIN_HOTSPOT_,
(mouseXY.y < trashXY.y + this.BODY_HEIGHT_ + this.LID_HEIGHT_ + this.WIDTH_ + 2 * this.MARGIN_HOTSPOT_,
this.MARGIN_HOTSPOT_); this.BODY_HEIGHT_ + this.LID_HEIGHT_ + 2 * this.MARGIN_HOTSPOT_);
// For bonus points we might want to match the trapezoidal outline.
if (this.isOpen != over) {
this.setOpen_(over);
}
}; };
/** /**
...@@ -278,8 +263,6 @@ Blockly.Trashcan.prototype.setOpen_ = function(state) { ...@@ -278,8 +263,6 @@ Blockly.Trashcan.prototype.setOpen_ = function(state) {
goog.Timer.clear(this.lidTask_); goog.Timer.clear(this.lidTask_);
this.isOpen = state; this.isOpen = state;
this.animateLid_(); this.animateLid_();
Blockly.Css.setCursor(state ? Blockly.Css.Cursor.DELETE :
Blockly.Css.Cursor.CLOSED);
}; };
/** /**
......
...@@ -30,7 +30,6 @@ goog.provide('Blockly.Variables'); ...@@ -30,7 +30,6 @@ goog.provide('Blockly.Variables');
// TODO(scr): Fix circular dependencies // TODO(scr): Fix circular dependencies
// goog.require('Blockly.Block'); // goog.require('Blockly.Block');
goog.require('Blockly.Toolbox');
goog.require('Blockly.Workspace'); goog.require('Blockly.Workspace');
......
...@@ -32,6 +32,7 @@ goog.require('Blockly.ScrollbarPair'); ...@@ -32,6 +32,7 @@ goog.require('Blockly.ScrollbarPair');
goog.require('Blockly.Trashcan'); goog.require('Blockly.Trashcan');
goog.require('Blockly.Xml'); goog.require('Blockly.Xml');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.math.Coordinate');
/** /**
...@@ -134,6 +135,10 @@ Blockly.Workspace.prototype.dispose = function() { ...@@ -134,6 +135,10 @@ Blockly.Workspace.prototype.dispose = function() {
} }
this.svgBlockCanvas_ = null; this.svgBlockCanvas_ = null;
this.svgBubbleCanvas_ = null; this.svgBubbleCanvas_ = null;
if (this.flyout_) {
this.flyout_.dispose();
this.flyout_ = null;
}
if (this.trashcan) { if (this.trashcan) {
this.trashcan.dispose(); this.trashcan.dispose();
this.trashcan = null; this.trashcan = null;
...@@ -396,5 +401,51 @@ Blockly.Workspace.prototype.remainingCapacity = function() { ...@@ -396,5 +401,51 @@ Blockly.Workspace.prototype.remainingCapacity = function() {
return this.maxBlocks - this.getAllBlocks().length; return this.maxBlocks - this.getAllBlocks().length;
}; };
/**
* Make a list of all the delete areas for this workspace.
*/
Blockly.Workspace.prototype.recordDeleteAreas = function() {
if (this.trashcan) {
this.deleteAreaTrash_ = this.trashcan.getRect();
} else {
this.deleteAreaTrash_ = null;
}
if (this.flyout_) {
this.deleteAreaToolbox_ = this.flyout_.getRect();
} else if (this.toolbox_) {
this.deleteAreaToolbox_ = this.toolbox_.getRect();
} else {
this.deleteAreaToolbox_ = null;
}
};
/**
* Is the mouse event over a delete area (toolbar or non-closing flyout)?
* Opens or closes the trashcan and sets the cursor as a side effect.
* @param {!Event} e Mouse move event.
* @return {boolean} True if event is in a delete area.
*/
Blockly.Workspace.prototype.isDeleteArea = function(e) {
var isDelete = false;
var mouseXY = Blockly.mouseToSvg(e);
var xy = new goog.math.Coordinate(mouseXY.x, mouseXY.y);
if (this.deleteAreaTrash_) {
if (this.deleteAreaTrash_.contains(xy)) {
this.trashcan.setOpen_(true);
Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE);
return true;
}
this.trashcan.setOpen_(false);
}
if (this.deleteAreaToolbox_) {
if (this.deleteAreaToolbox_.contains(xy)) {
Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE);
return true;
}
}
Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);
return false;
};
// Export symbols that would otherwise be renamed by Closure compiler. // Export symbols that would otherwise be renamed by Closure compiler.
Blockly.Workspace.prototype['clear'] = Blockly.Workspace.prototype.clear; Blockly.Workspace.prototype['clear'] = Blockly.Workspace.prototype.clear;
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, height=660, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="target-densitydpi=device-dpi, height=660, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Blockly Demo: Block Factory</title> <title>Blockly Demo: Block Factory</title>
<script type="text/javascript" src="/storage.js"></script> <script src="/storage.js"></script>
<script type="text/javascript" src="factory.js"></script> <script src="factory.js"></script>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../msg/messages.js"></script> <script src="../../msg/messages.js"></script>
<script type="text/javascript" src="blocks.js"></script> <script src="blocks.js"></script>
<style> <style>
html, body { html, body {
height: 100%; height: 100%;
...@@ -74,8 +74,8 @@ ...@@ -74,8 +74,8 @@
display: none; display: none;
} }
</style> </style>
<link rel="stylesheet" type="text/css" href="../prettify.css"> <link rel="stylesheet" href="../prettify.css">
<script type="text/javascript" src="../prettify.js"></script> <script src="../prettify.js"></script>
</head> </head>
<body> <body>
<table> <table>
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="google" value="notranslate"> <meta name="google" value="notranslate">
<title>Block Factory Preview</title> <title>Block Factory Preview</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../msg/messages.js"></script> <script src="../../msg/messages.js"></script>
<script type="text/javascript" src="preview.js"></script> <script src="preview.js"></script>
<style> <style>
html, body { html, body {
background-color: #fff; background-color: #fff;
......
...@@ -192,15 +192,13 @@ Code.bindClick = function(el, func) { ...@@ -192,15 +192,13 @@ Code.bindClick = function(el, func) {
* Load the Prettify CSS and JavaScript. * Load the Prettify CSS and JavaScript.
*/ */
Code.importPrettify = function() { Code.importPrettify = function() {
//<link rel="stylesheet" type="text/css" href="../prettify.css"> //<link rel="stylesheet" href="../prettify.css">
//<script type="text/javascript" src="../prettify.js"></script> //<script src="../prettify.js"></script>
var link = document.createElement('link'); var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet'); link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', '../prettify.css'); link.setAttribute('href', '../prettify.css');
document.head.appendChild(link); document.head.appendChild(link);
var script = document.createElement('script'); var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', '../prettify.js'); script.setAttribute('src', '../prettify.js');
document.head.appendChild(script); document.head.appendChild(script);
}; };
...@@ -496,10 +494,8 @@ Code.discard = function() { ...@@ -496,10 +494,8 @@ Code.discard = function() {
}; };
// Load the Code demo's language strings. // Load the Code demo's language strings.
document.write('<script type="text/javascript" src="msg/' + document.write('<script src="msg/' + Code.LANG + '.js"></script>\n');
Code.LANG + '.js"></script>\n');
// Load Blockly's language strings. // Load Blockly's language strings.
document.write('<script type="text/javascript" src="../../msg/js/' + document.write('<script src="../../msg/js/' + Code.LANG + '.js"></script>\n');
Code.LANG + '.js"></script>\n');
window.addEventListener('load', Code.init); window.addEventListener('load', Code.init);
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="google" value="notranslate"> <meta name="google" value="notranslate">
<title>Blockly Demo:</title> <title>Blockly Demo:</title>
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" href="style.css">
<script type="text/javascript" src="/storage.js"></script> <script src="/storage.js"></script>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../javascript_compressed.js"></script> <script src="../../javascript_compressed.js"></script>
<script type="text/javascript" src="../../python_compressed.js"></script> <script src="../../python_compressed.js"></script>
<script type="text/javascript" src="../../dart_compressed.js"></script> <script src="../../dart_compressed.js"></script>
<script type="text/javascript" src="code.js"></script> <script src="code.js"></script>
</head> </head>
<body> <body>
<table width="100%" height="100%"> <table width="100%" height="100%">
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Fixed Blockly</title> <title>Blockly Demo: Fixed Blockly</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Generating JavaScript</title> <title>Blockly Demo: Generating JavaScript</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../javascript_compressed.js"></script> <script src="../../javascript_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Graph</title> <title>Blockly Demo: Graph</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script> <script src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../javascript_compressed.js"></script> <script src="../../javascript_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
html, body { html, body {
background-color: #fff; background-color: #fff;
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: JS Interpreter</title> <title>Blockly Demo: JS Interpreter</title>
<script type="text/javascript" src="acorn_interpreter.js"></script> <script src="acorn_interpreter.js"></script>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../javascript_compressed.js"></script> <script src="../../javascript_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Maximum Block Limit</title> <title>Blockly Demo: Maximum Block Limit</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="google" value="notranslate"> <meta name="google" value="notranslate">
<title>Blockly Demo:</title> <title>Blockly Demo:</title>
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" href="style.css">
<script type="text/javascript" src="soy/soyutils.js"></script> <script src="soy/soyutils.js"></script>
<script type="text/javascript" src="plane.js"></script> <script src="plane.js"></script>
</head> </head>
<body> <body>
<script type="text/javascript"> <script>
document.write(planepage.start({}, null, document.write(planepage.start({}, null,
{lang: Plane.LANG, {lang: Plane.LANG,
level: Plane.LEVEL, level: Plane.LEVEL,
......
...@@ -387,8 +387,7 @@ Plane.redraw = function(newRows) { ...@@ -387,8 +387,7 @@ Plane.redraw = function(newRows) {
} }
while (newRows > rows1st) { while (newRows > rows1st) {
rows1st++; rows1st++;
var row = document.createElementNS('http://www.w3.org/2000/svg', var row = document.createElementNS('http://www.w3.org/2000/svg', 'use');
'use');
row.setAttribute('id', 'row1st' + rows1st); row.setAttribute('id', 'row1st' + rows1st);
// Row of 4 seats. // Row of 4 seats.
row.setAttribute('x', (rows1st - 1) * 20); row.setAttribute('x', (rows1st - 1) * 20);
...@@ -435,5 +434,4 @@ Plane.redraw = function(newRows) { ...@@ -435,5 +434,4 @@ Plane.redraw = function(newRows) {
window.addEventListener('load', Plane.init); window.addEventListener('load', Plane.init);
// Load the user's language pack. // Load the user's language pack.
document.write('<script type="text/javascript" src="generated/' + document.write('<script src="generated/' + Plane.LANG + '.js"></script>\n');
Plane.LANG + '.js"></script>\n');
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</tr> </tr>
</table> </table>
<script type="text/javascript" src="slider.js"></script> <script src="slider.js"></script>
<svg <svg
id="plane" id="plane"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
...@@ -175,11 +175,11 @@ ...@@ -175,11 +175,11 @@
{msg meaning="Plane.instructions" desc="page text - This text appears below the airplane graphic and above the space for the user to create the formula. The number of rows an the graphic may be changed by the user with a slider. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=1] for a picture."}Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).{/msg} {msg meaning="Plane.instructions" desc="page text - This text appears below the airplane graphic and above the space for the user to create the formula. The number of rows an the graphic may be changed by the user with a slider. See [http://blockly-share.appspot.com/static/apps/plane/plane.html?lang=en&level=1] for a picture."}Build a formula (below) that calculates the total number of seats on the airplane as the rows are changed (above).{/msg}
</p> </p>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../javascript_compressed.js"></script> <script src="../../javascript_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/{$ij.lang}.js"></script> <script src="../../msg/js/{$ij.lang}.js"></script>
<script type="text/javascript" src="blocks.js"></script> <script src="blocks.js"></script>
{call .toolbox /} {call .toolbox /}
<div id="blockly"></div> <div id="blockly"></div>
{/template} {/template}
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Realtime Collaboration</title> <title>Blockly Demo: Realtime Collaboration</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script> <script src="https://apis.google.com/js/api.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="google" value="notranslate"> <meta name="google" value="notranslate">
<title>Blockly Demo: RTL</title> <title>Blockly Demo: RTL</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/ar.js"></script> <script src="../../msg/js/ar.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Cloud Storage</title> <title>Blockly Demo: Cloud Storage</title>
<script type="text/javascript" src="/storage.js"></script> <script src="/storage.js"></script>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Demo: Toolbox</title> <title>Blockly Demo: Toolbox</title>
<script type="text/javascript" src="../../blockly_compressed.js"></script> <script src="../../blockly_compressed.js"></script>
<script type="text/javascript" src="../../blocks_compressed.js"></script> <script src="../../blocks_compressed.js"></script>
<script type="text/javascript" src="../../msg/js/en.js"></script> <script src="../../msg/js/en.js"></script>
<style> <style>
body { body {
background-color: #fff; background-color: #fff;
......
No preview for this file type
...@@ -3,48 +3,48 @@ ...@@ -3,48 +3,48 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Generator Tests</title> <title>Blockly Generator Tests</title>
<script type="text/javascript" src="../../blockly_uncompressed.js"></script> <script src="../../blockly_uncompressed.js"></script>
<script type="text/javascript" src="../../generators/javascript.js"></script> <script src="../../generators/javascript.js"></script>
<script type="text/javascript" src="unittest_javascript.js"></script> <script src="unittest_javascript.js"></script>
<script type="text/javascript" src="../../generators/javascript/logic.js"></script> <script src="../../generators/javascript/logic.js"></script>
<script type="text/javascript" src="../../generators/javascript/loops.js"></script> <script src="../../generators/javascript/loops.js"></script>
<script type="text/javascript" src="../../generators/javascript/math.js"></script> <script src="../../generators/javascript/math.js"></script>
<script type="text/javascript" src="../../generators/javascript/text.js"></script> <script src="../../generators/javascript/text.js"></script>
<script type="text/javascript" src="../../generators/javascript/lists.js"></script> <script src="../../generators/javascript/lists.js"></script>
<script type="text/javascript" src="../../generators/javascript/colour.js"></script> <script src="../../generators/javascript/colour.js"></script>
<script type="text/javascript" src="../../generators/javascript/variables.js"></script> <script src="../../generators/javascript/variables.js"></script>
<script type="text/javascript" src="../../generators/javascript/procedures.js"></script> <script src="../../generators/javascript/procedures.js"></script>
<script type="text/javascript" src="../../generators/python.js"></script> <script src="../../generators/python.js"></script>
<script type="text/javascript" src="unittest_python.js"></script> <script src="unittest_python.js"></script>
<script type="text/javascript" src="../../generators/python/logic.js"></script> <script src="../../generators/python/logic.js"></script>
<script type="text/javascript" src="../../generators/python/loops.js"></script> <script src="../../generators/python/loops.js"></script>
<script type="text/javascript" src="../../generators/python/math.js"></script> <script src="../../generators/python/math.js"></script>
<script type="text/javascript" src="../../generators/python/text.js"></script> <script src="../../generators/python/text.js"></script>
<script type="text/javascript" src="../../generators/python/lists.js"></script> <script src="../../generators/python/lists.js"></script>
<script type="text/javascript" src="../../generators/python/colour.js"></script> <script src="../../generators/python/colour.js"></script>
<script type="text/javascript" src="../../generators/python/variables.js"></script> <script src="../../generators/python/variables.js"></script>
<script type="text/javascript" src="../../generators/python/procedures.js"></script> <script src="../../generators/python/procedures.js"></script>
<script type="text/javascript" src="../../generators/dart.js"></script> <script src="../../generators/dart.js"></script>
<script type="text/javascript" src="unittest_dart.js"></script> <script src="unittest_dart.js"></script>
<script type="text/javascript" src="../../generators/dart/logic.js"></script> <script src="../../generators/dart/logic.js"></script>
<script type="text/javascript" src="../../generators/dart/loops.js"></script> <script src="../../generators/dart/loops.js"></script>
<script type="text/javascript" src="../../generators/dart/math.js"></script> <script src="../../generators/dart/math.js"></script>
<script type="text/javascript" src="../../generators/dart/text.js"></script> <script src="../../generators/dart/text.js"></script>
<script type="text/javascript" src="../../generators/dart/lists.js"></script> <script src="../../generators/dart/lists.js"></script>
<script type="text/javascript" src="../../generators/dart/colour.js"></script> <script src="../../generators/dart/colour.js"></script>
<script type="text/javascript" src="../../generators/dart/variables.js"></script> <script src="../../generators/dart/variables.js"></script>
<script type="text/javascript" src="../../generators/dart/procedures.js"></script> <script src="../../generators/dart/procedures.js"></script>
<script type="text/javascript" src="unittest.js"></script> <script src="unittest.js"></script>
<script type="text/javascript" src="../../msg/messages.js"></script> <script src="../../msg/messages.js"></script>
<script type="text/javascript" src="../../blocks/logic.js"></script> <script src="../../blocks/logic.js"></script>
<script type="text/javascript" src="../../blocks/loops.js"></script> <script src="../../blocks/loops.js"></script>
<script type="text/javascript" src="../../blocks/math.js"></script> <script src="../../blocks/math.js"></script>
<script type="text/javascript" src="../../blocks/text.js"></script> <script src="../../blocks/text.js"></script>
<script type="text/javascript" src="../../blocks/lists.js"></script> <script src="../../blocks/lists.js"></script>
<script type="text/javascript" src="../../blocks/colour.js"></script> <script src="../../blocks/colour.js"></script>
<script type="text/javascript" src="../../blocks/variables.js"></script> <script src="../../blocks/variables.js"></script>
<script type="text/javascript" src="../../blocks/procedures.js"></script> <script src="../../blocks/procedures.js"></script>
<script type="text/javascript"> <script>
'use strict'; 'use strict';
function start() { function start() {
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Unit Tests for Blockly</title> <title>Unit Tests for Blockly</title>
<script type="text/javascript" src="../../blockly_uncompressed.js"></script> <script src="../../blockly_uncompressed.js"></script>
<script type="text/javascript">goog.require('goog.testing.jsunit');</script> <script>goog.require('goog.testing.jsunit');</script>
</head> </head>
<body> <body>
<script type="text/javascript" src="blockly_test.js"></script> <script src="blockly_test.js"></script>
<script type="text/javascript" src="generator_test.js"></script> <script src="generator_test.js"></script>
<script type="text/javascript" src="names_test.js"></script> <script src="names_test.js"></script>
<script type="text/javascript" src="xml_test.js"></script> <script src="xml_test.js"></script>
</body> </body>
</html> </html>
...@@ -3,46 +3,46 @@ ...@@ -3,46 +3,46 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Blockly Playground</title> <title>Blockly Playground</title>
<script type="text/javascript" src="../blockly_uncompressed.js"></script> <script src="../blockly_uncompressed.js"></script>
<script type="text/javascript" src="../generators/javascript.js"></script> <script src="../generators/javascript.js"></script>
<script type="text/javascript" src="../generators/javascript/logic.js"></script> <script src="../generators/javascript/logic.js"></script>
<script type="text/javascript" src="../generators/javascript/loops.js"></script> <script src="../generators/javascript/loops.js"></script>
<script type="text/javascript" src="../generators/javascript/math.js"></script> <script src="../generators/javascript/math.js"></script>
<script type="text/javascript" src="../generators/javascript/text.js"></script> <script src="../generators/javascript/text.js"></script>
<script type="text/javascript" src="../generators/javascript/lists.js"></script> <script src="../generators/javascript/lists.js"></script>
<script type="text/javascript" src="../generators/javascript/colour.js"></script> <script src="../generators/javascript/colour.js"></script>
<script type="text/javascript" src="../generators/javascript/variables.js"></script> <script src="../generators/javascript/variables.js"></script>
<script type="text/javascript" src="../generators/javascript/procedures.js"></script> <script src="../generators/javascript/procedures.js"></script>
<script type="text/javascript" src="../generators/python.js"></script> <script src="../generators/python.js"></script>
<script type="text/javascript" src="../generators/python/logic.js"></script> <script src="../generators/python/logic.js"></script>
<script type="text/javascript" src="../generators/python/loops.js"></script> <script src="../generators/python/loops.js"></script>
<script type="text/javascript" src="../generators/python/math.js"></script> <script src="../generators/python/math.js"></script>
<script type="text/javascript" src="../generators/python/text.js"></script> <script src="../generators/python/text.js"></script>
<script type="text/javascript" src="../generators/python/lists.js"></script> <script src="../generators/python/lists.js"></script>
<script type="text/javascript" src="../generators/python/colour.js"></script> <script src="../generators/python/colour.js"></script>
<script type="text/javascript" src="../generators/python/variables.js"></script> <script src="../generators/python/variables.js"></script>
<script type="text/javascript" src="../generators/python/procedures.js"></script> <script src="../generators/python/procedures.js"></script>
<script type="text/javascript" src="../generators/dart.js"></script> <script src="../generators/dart.js"></script>
<script type="text/javascript" src="../generators/dart/logic.js"></script> <script src="../generators/dart/logic.js"></script>
<script type="text/javascript" src="../generators/dart/loops.js"></script> <script src="../generators/dart/loops.js"></script>
<script type="text/javascript" src="../generators/dart/math.js"></script> <script src="../generators/dart/math.js"></script>
<script type="text/javascript" src="../generators/dart/text.js"></script> <script src="../generators/dart/text.js"></script>
<script type="text/javascript" src="../generators/dart/lists.js"></script> <script src="../generators/dart/lists.js"></script>
<script type="text/javascript" src="../generators/dart/colour.js"></script> <script src="../generators/dart/colour.js"></script>
<script type="text/javascript" src="../generators/dart/variables.js"></script> <script src="../generators/dart/variables.js"></script>
<script type="text/javascript" src="../generators/dart/procedures.js"></script> <script src="../generators/dart/procedures.js"></script>
<script type="text/javascript" src="../msg/messages.js"></script> <script src="../msg/messages.js"></script>
<script type="text/javascript" src="../blocks/logic.js"></script> <script src="../blocks/logic.js"></script>
<script type="text/javascript" src="../blocks/loops.js"></script> <script src="../blocks/loops.js"></script>
<script type="text/javascript" src="../blocks/math.js"></script> <script src="../blocks/math.js"></script>
<script type="text/javascript" src="../blocks/text.js"></script> <script src="../blocks/text.js"></script>
<script type="text/javascript" src="../blocks/lists.js"></script> <script src="../blocks/lists.js"></script>
<script type="text/javascript" src="../blocks/colour.js"></script> <script src="../blocks/colour.js"></script>
<script type="text/javascript" src="../blocks/variables.js"></script> <script src="../blocks/variables.js"></script>
<script type="text/javascript" src="../blocks/procedures.js"></script> <script src="../blocks/procedures.js"></script>
<!-- Load the Google Drive SDK Realtime libraries. --> <!-- Load the Google Drive SDK Realtime libraries. -->
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script> <script src="https://apis.google.com/js/api.js"></script>
<script type="text/javascript"> <script>
'use strict'; 'use strict';
// Depending on the URL argument, render as LTR or RTL. // Depending on the URL argument, render as LTR or RTL.
var rtl = (document.location.search == '?rtl'); var rtl = (document.location.search == '?rtl');
...@@ -362,7 +362,7 @@ h1 { ...@@ -362,7 +362,7 @@ h1 {
<p><a href="javascript:void([document.getElementById('blocklyDiv').style.display = 'block', Blockly.mainWorkspace.render()])">Show</a> <p><a href="javascript:void([document.getElementById('blocklyDiv').style.display = 'block', Blockly.mainWorkspace.render()])">Show</a>
- <a href="javascript:void(document.getElementById('blocklyDiv').style.display = 'none')">Hide</a></p> - <a href="javascript:void(document.getElementById('blocklyDiv').style.display = 'none')">Hide</a></p>
<script type="text/javascript"> <script>
if (rtl) { if (rtl) {
document.write('[ &larr; RTL. Switch to <A HREF="?ltr">LTR</A>. ]'); document.write('[ &larr; RTL. Switch to <A HREF="?ltr">LTR</A>. ]');
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment