Commit 4253de04 authored by Neil Fraser's avatar Neil Fraser

Remove old realtime.

parent 3bce3681
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -41,12 +41,6 @@ goog.require('Blockly.FieldVariable');
goog.require('Blockly.Generator');
goog.require('Blockly.Msg');
goog.require('Blockly.Procedures');
// Realtime is currently badly broken. Stub it out.
Blockly.Realtime = {
isEnabled: function() {return false;},
blockChanged: function() {},
doCommand: function(cmdThunk) {cmdThunk();}
};
goog.require('Blockly.Toolbox');
goog.require('Blockly.WidgetDiv');
goog.require('Blockly.WorkspaceSvg');
......@@ -604,22 +598,6 @@ Blockly.setMainWorkspaceMetrics_ = function(xyRatio) {
}
};
/**
* Execute a command. Generally, a command is the result of a user action
* e.g., a click, drag or context menu selection. Calling the cmdThunk function
* through doCommand() allows us to capture information that can be used for
* capabilities like undo (which is supported by the realtime collaboration
* feature).
* @param {function()} cmdThunk A function representing the command execution.
*/
Blockly.doCommand = function(cmdThunk) {
if (Blockly.Realtime.isEnabled()) {
Blockly.Realtime.doCommand(cmdThunk);
} else {
cmdThunk();
}
};
/**
* When something in Blockly's workspace changes, call a function.
* @param {!Function} func Function to call.
......
......@@ -64,11 +64,8 @@ Blockly.ContextMenu.show = function(e, options, rtl) {
menu.addChild(menuItem, true);
menuItem.setEnabled(option.enabled);
if (option.enabled) {
var evtHandlerCapturer = function(callback) {
return function() { Blockly.doCommand(callback); };
};
goog.events.listen(menuItem, goog.ui.Component.EventType.ACTION,
evtHandlerCapturer(option.callback));
option.callback);
}
}
goog.events.listen(menu, goog.ui.Component.EventType.ACTION,
......
......@@ -108,9 +108,6 @@ Blockly.FieldColour.prototype.setValue = function(colour) {
this.borderRect_.style.fill = colour;
}
if (this.sourceBlock_ && this.sourceBlock_.rendered) {
// Since we're not re-rendering we need to explicitly call
// Blockly.Realtime.blockChanged()
Blockly.Realtime.blockChanged(this.sourceBlock_);
this.sourceBlock_.workspace.fireChangeEvent();
}
};
......
......@@ -41,10 +41,8 @@ goog.require('goog.userAgent');
* @constructor
*/
Blockly.Flyout = function(workspaceOptions) {
var flyout = this;
workspaceOptions.getMetrics = function() {return flyout.getMetrics_();};
workspaceOptions.setMetrics =
function(ratio) {return flyout.setMetrics_(ratio);};
workspaceOptions.getMetrics = this.getMetrics_.bind(this);
workspaceOptions.setMetrics = this.setMetrics_.bind(this);
/**
* @type {!Blockly.Workspace}
* @private
......
......@@ -48,23 +48,11 @@ Blockly.inject = function(container, opt_options) {
throw 'Error: container is not in current document.';
}
var options = Blockly.parseOptions_(opt_options || {});
var workspace;
var startUi = function() {
var svg = Blockly.createDom_(container, options);
workspace = Blockly.createMainWorkspace_(svg, options);
Blockly.init_(workspace);
workspace.markFocused();
Blockly.bindEvent_(svg, 'focus', workspace, workspace.markFocused);
};
if (options.enableRealtime) {
var realtimeElement = document.getElementById('realtime');
if (realtimeElement) {
realtimeElement.style.display = 'block';
}
Blockly.Realtime.startRealtime(startUi, container, options.realtimeOptions);
} else {
startUi();
}
var svg = Blockly.createDom_(container, options);
var workspace = Blockly.createMainWorkspace_(svg, options);
Blockly.init_(workspace);
workspace.markFocused();
Blockly.bindEvent_(svg, 'focus', workspace, workspace.markFocused);
return workspace;
};
......
......@@ -117,15 +117,13 @@ Blockly.Mutator.prototype.createEditor_ = function() {
} else {
var quarkXml = null;
}
var mutator = this;
var workspaceOptions = {
languageTree: quarkXml,
parentWorkspace: this.block_.workspace,
pathToMedia: this.block_.workspace.options.pathToMedia,
RTL: this.block_.RTL,
getMetrics: function() {return mutator.getFlyoutMetrics_();},
setMetrics: null,
svg: this.svgDialog_
getMetrics: this.getFlyoutMetrics_.bind(this),
setMetrics: null
};
this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions);
this.svgDialog_.appendChild(
......
......@@ -341,7 +341,7 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
};
/**
* Get the SVG element that forms the bubble surface.
* Get the SVG element that contains this workspace.
* @return {!Element} SVG element.
*/
Blockly.WorkspaceSvg.prototype.getParentSvg = function() {
......@@ -371,28 +371,6 @@ Blockly.WorkspaceSvg.prototype.translate = function(x, y) {
this.svgBubbleCanvas_.setAttribute('transform', translation);
};
/**
* Add a block to the list of top blocks.
* @param {!Blockly.Block} block Block to remove.
*/
Blockly.WorkspaceSvg.prototype.addTopBlock = function(block) {
Blockly.WorkspaceSvg.superClass_.addTopBlock.call(this, block);
if (Blockly.Realtime.isEnabled() && !this.options.parentWorkspace) {
Blockly.Realtime.addTopBlock(block);
}
};
/**
* Remove a block from the list of top blocks.
* @param {!Blockly.Block} block Block to remove.
*/
Blockly.WorkspaceSvg.prototype.removeTopBlock = function(block) {
Blockly.WorkspaceSvg.superClass_.removeTopBlock.call(this, block);
if (Blockly.Realtime.isEnabled() && !this.options.parentWorkspace) {
Blockly.Realtime.removeTopBlock(block);
}
};
/**
* Returns the horizontal offset of the workspace.
* Intended for LTR/RTL compatibility in XML.
......
......@@ -62,7 +62,7 @@ Blockly.Xml.workspaceToDom = function(workspace) {
Blockly.Xml.blockToDom_ = function(block) {
var element = goog.dom.createDom(block.isShadow() ? 'shadow' : 'block');
element.setAttribute('type', block.type);
if (Blockly.Realtime.isEnabled()) {
if (false) {
// Only used by realtime.
element.setAttribute('id', block.id);
}
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blockly Demo: Realtime Collaboration</title>
<script src="../../blockly_compressed.js"></script>
<script src="../../blocks_compressed.js"></script>
<script src="../../msg/js/en.js"></script>
<script src="https://apis.google.com/js/api.js"></script>
<style>
body {
background-color: #fff;
font-family: sans-serif;
}
h1 {
font-weight: normal;
font-size: 140%;
}
#collaborators > img {
margin-right: 5px;
height: 30px;
padding-bottom: 5px;
width: 30px;
border-radius: 3px;
}
</style>
</head>
<body>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Realtime Collaboration</h1>
<p>This is a simple demo of realtime collaboration in Blockly.</p>
<p>&rarr; More info on
<a href="https://developers.google.com/blockly/realtime-collaboration">
realtime collaboration in Blockly</a>...</p>
<div id="collaborators"></div>
<div id="blocklyDiv"
style="height: 480px; width: 600px;">
</div>
<xml id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="controls_repeat_ext"></block>
<block type="logic_compare"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>
<p>Test realtime collaboration by opening
<a target="_blank" href="#" onmouseover="this.href = window.location.href">
this link</a> in a separate browser window or tab and they will be
synchronized. You can even share the link with a friend!.</p>
<br>
<br>
<!-- Text area that will be used for our collaborative chat box. -->
<textarea id="chatbox" style="width: 26%; height: 12em" disabled="true"></textarea>
<script>
// See https://developers.google.com/blockly/realtime-collaboration for how
// to set up your app for realtime collaboration and how to get the
// clientId that you need below.
Blockly.inject(document.getElementById('blocklyDiv'),
{toolbox: document.getElementById('toolbox'),
realtime: true,
realtimeOptions:
{clientId: 'YOUR CLIENT ID HERE',
chatbox: {elementId: 'chatbox'},
collabElementId: 'collaborators'}});
</script>
</body>
</html>
This diff is collapsed.
......@@ -55,11 +55,6 @@
var rtl = (document.location.search == '?rtl');
var workspace = null;
function enableRealtimeSpecificUi() {
var realtimeDiv = document.getElementById('realtime');
realtimeDiv.display = 'block';
}
function start() {
var toolbox = document.getElementById('toolbox');
workspace = Blockly.inject('blocklyDiv',
......@@ -74,11 +69,6 @@ function start() {
maxBlocks: Infinity,
media: '../media/',
readOnly: false,
realtime: false,
realtimeOptions:
{clientId: 'YOUR CLIENT ID GOES HERE',
chatbox: {elementId: 'chatbox'},
collabElementId: 'collaborators'},
rtl: rtl,
scrollbars: true,
toolbox: toolbox,
......@@ -91,9 +81,6 @@ function start() {
scaleSpeed: 1.1
},
});
if (Blockly.Realtime.isEnabled()) {
enableRealtimeSpecificUi();
}
}
function toXml() {
......@@ -559,26 +546,5 @@ h1 {
<input type="button" value="Spaghetti!" onclick="spaghetti(8)">
</p>
<!-- Realtime setup buttons. -->
<div id="realtime" style="display: none">
<p>Test realtime collaboration by opening
<a target="_blank" href="#" onmouseover="this.href = window.location.href">
this link</a> in a separate browser window or tab and they will be
synchronized. You can even share the link with a friend!.</p>
<br>
<br>
<!-- Undo and redo buttons. -->
<!-- TODO: Uncomment this when undo/redo are fixed. -->
<!--
<button id="undoButton" disabled>Undo</button>
<button id="redoButton" disabled>Redo</button>
<br />
-->
</div>
</body>
</html>
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