Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions static/third_party/lib/blockly/core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ goog.require('goog.Timer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.string');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -118,7 +119,7 @@ Blockly.Block.prototype.initialize = function(workspace, prototypeName) {
workspace.addTopBlock(this);
this.fill(workspace, prototypeName);
// Bind an onchange function, if it exists.
if (goog.isFunction(this.onchange)) {
if (Blockly.goog.isFunction(this.onchange)) {
Blockly.bindEvent_(workspace.getCanvas(), 'blocklyWorkspaceChange', this,
this.onchange);
}
Expand Down Expand Up @@ -165,7 +166,7 @@ Blockly.Block.prototype.fill = function(workspace, prototypeName) {
goog.mixin(this, prototype);
}
// Call an initialization function, if it exists.
if (goog.isFunction(this.init)) {
if (Blockly.goog.isFunction(this.init)) {
this.init();
}
};
Expand Down Expand Up @@ -605,7 +606,7 @@ Blockly.Block.prototype.onMouseUp_ = function(e) {
* @private
*/
Blockly.Block.prototype.showHelp_ = function() {
var url = goog.isFunction(this.helpUrl) ? this.helpUrl() : this.helpUrl;
var url = Blockly.goog.isFunction(this.helpUrl) ? this.helpUrl() : this.helpUrl;
if (url) {
window.open(url);
}
Expand Down Expand Up @@ -748,7 +749,7 @@ Blockly.Block.prototype.showContextMenu_ = function(e) {
}

// Option to get help.
var url = goog.isFunction(this.helpUrl) ? this.helpUrl() : this.helpUrl;
var url = Blockly.goog.isFunction(this.helpUrl) ? this.helpUrl() : this.helpUrl;
var helpOption = {enabled: !!url};
helpOption.text = Blockly.Msg.HELP;
helpOption.callback = function() {
Expand Down Expand Up @@ -1672,7 +1673,7 @@ Blockly.Block.prototype.interpolateMsg = function(msg, var_args) {
if (field instanceof Blockly.Field) {
this.appendField(field);
} else {
goog.asserts.assert(goog.isArray(field));
goog.asserts.assert(Blockly.goog.isArray(field));
this.appendField(field[1], field[0]);
}
}
Expand Down Expand Up @@ -1920,7 +1921,7 @@ Blockly.Block.prototype.getCommentText = function() {
*/
Blockly.Block.prototype.setCommentText = function(text) {
var changedState = false;
if (goog.isString(text)) {
if (Blockly.goog.isString(text)) {
if (!this.comment) {
this.comment = new Blockly.Comment(this);
changedState = true;
Expand Down Expand Up @@ -1950,7 +1951,7 @@ Blockly.Block.prototype.setWarningText = function(text) {
text = null;
}
var changedState = false;
if (goog.isString(text)) {
if (Blockly.goog.isString(text)) {
if (!this.warning) {
this.warning = new Blockly.Warning(this);
changedState = true;
Expand Down
5 changes: 3 additions & 2 deletions static/third_party/lib/blockly/core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ goog.require('goog.string');
goog.require('goog.ui.ColorPicker');
goog.require('goog.ui.tree.TreeControl');
goog.require('goog.userAgent');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -716,11 +717,11 @@ Blockly.setMainWorkspaceMetrics_ = function(xyRatio) {
throw 'Attempt to set main workspace scroll without scrollbars.';
}
var metrics = Blockly.getMainWorkspaceMetrics_();
if (goog.isNumber(xyRatio.x)) {
if (Blockly.goog.isNumber(xyRatio.x)) {
Blockly.mainWorkspace.scrollX = -metrics.contentWidth * xyRatio.x -
metrics.contentLeft;
}
if (goog.isNumber(xyRatio.y)) {
if (Blockly.goog.isNumber(xyRatio.y)) {
Blockly.mainWorkspace.scrollY = -metrics.contentHeight * xyRatio.y -
metrics.contentTop;
}
Expand Down
3 changes: 2 additions & 1 deletion static/third_party/lib/blockly/core/field_dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ goog.require('goog.style');
goog.require('goog.ui.Menu');
goog.require('goog.ui.MenuItem');
goog.require('goog.userAgent');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -231,7 +232,7 @@ Blockly.FieldDropdown.prototype.trimOptions_ = function() {
* @private
*/
Blockly.FieldDropdown.prototype.getOptions_ = function() {
if (goog.isFunction(this.menuGenerator_)) {
if (Blockly.goog.isFunction(this.menuGenerator_)) {
return this.menuGenerator_.call(this);
}
return /** @type {!Array.<!Array.<string>>} */ (this.menuGenerator_);
Expand Down
3 changes: 2 additions & 1 deletion static/third_party/lib/blockly/core/field_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ goog.provide('Blockly.FieldImage');

goog.require('Blockly.Field');
goog.require('goog.userAgent');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -146,7 +147,7 @@ Blockly.FieldImage.prototype.setValue = function(src) {
}
this.src_ = src;
this.imageElement_.setAttributeNS('http://www.w3.org/1999/xlink',
'xlink:href', goog.isString(src) ? src : '');
'xlink:href', Blockly.goog.isString(src) ? src : '');
};

/**
Expand Down
3 changes: 2 additions & 1 deletion static/third_party/lib/blockly/core/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ goog.provide('Blockly.Flyout');
goog.require('Blockly.Block');
goog.require('Blockly.Comment');
goog.require('goog.userAgent');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -201,7 +202,7 @@ Blockly.Flyout.prototype.setMetrics_ = function(yRatio) {
if (!metrics) {
return;
}
if (goog.isNumber(yRatio.y)) {
if (Blockly.goog.isNumber(yRatio.y)) {
this.workspace_.scrollY =
-metrics.contentHeight * yRatio.y - metrics.contentTop;
}
Expand Down
11 changes: 6 additions & 5 deletions static/third_party/lib/blockly/core/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
goog.provide('Blockly.Generator');

goog.require('Blockly.Block');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -73,7 +74,7 @@ Blockly.Generator.prototype.workspaceToCode = function() {
var blocks = Blockly.mainWorkspace.getTopBlocks(true);
for (var x = 0, block; block = blocks[x]; x++) {
var line = this.blockToCode(block);
if (goog.isArray(line)) {
if (Blockly.goog.isArray(line)) {
// Value blocks return tuples of code and operator order.
// Top-level blocks don't care about operator order.
line = line[0];
Expand Down Expand Up @@ -156,10 +157,10 @@ Blockly.Generator.prototype.blockToCode = function(block) {
// The current prefered method of accessing the block is through the second
// argument to func.call, which becomes the first parameter to the generator.
var code = func.call(block, block);
if (goog.isArray(code)) {
if (Blockly.goog.isArray(code)) {
// Value blocks return tuples of code and operator order.
return [this.scrub_(block, code[0]), code[1]];
} else if (goog.isString(code)) {
} else if (Blockly.goog.isString(code)) {
if (this.STATEMENT_PREFIX) {
code = this.STATEMENT_PREFIX.replace(/%1/g, '\'' + block.id + '\'') +
code;
Expand Down Expand Up @@ -195,7 +196,7 @@ Blockly.Generator.prototype.valueToCode = function(block, name, order) {
// Disabled block.
return '';
}
if (!goog.isArray(tuple)) {
if (!Blockly.goog.isArray(tuple)) {
// Value blocks must return code and order of operations info.
// Statement blocks must only return code.
throw 'Expecting tuple from value block "' + targetBlock.type + '".';
Expand Down Expand Up @@ -231,7 +232,7 @@ Blockly.Generator.prototype.valueToCode = function(block, name, order) {
Blockly.Generator.prototype.statementToCode = function(block, name) {
var targetBlock = block.getInputTargetBlock(name);
var code = this.blockToCode(targetBlock);
if (!goog.isString(code)) {
if (!Blockly.goog.isString(code)) {
// Value blocks must return code and order of operations info.
// Statement blocks must only return code.
throw 'Expecting code from statement block "' + targetBlock.type + '".';
Expand Down
71 changes: 71 additions & 0 deletions static/third_party/lib/blockly/core/goog-polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use strict';

goog.provide('Blockly.goog');

/**
* Re-adds functions that were deleted from goog.
* These are polyfills for Closure Library's goog.is* functions.
*/

/**
* Returns true if the specified value is not undefined.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is defined.
*/
Blockly.goog.isDef = function(val) {
return val !== void 0;
};

/**
* Returns true if the specified value is `null`.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is null.
*/
Blockly.goog.isNull = function(val) {
return val === null;
};

/**
* Returns true if the specified value is defined and not null.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is defined and not null.
*/
Blockly.goog.isDefAndNotNull = function(val) {
return val != null;
};

/**
* Returns true if the specified value is a string.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is a string.
*/
Blockly.goog.isString = function(val) {
return typeof val == 'string';
};

/**
* Returns true if the specified value is a boolean.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is a boolean.
*/
Blockly.goog.isBoolean = function(val) {
return typeof val == 'boolean';
};

/**
* Returns true if the specified value is a number.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is a number.
*/
Blockly.goog.isNumber = function(val) {
return typeof val == 'number';
};

/**
* Returns true if the specified value is a function.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is a function.
*/
Blockly.goog.isFunction = function(val) {
return typeof val == 'function';
};
3 changes: 2 additions & 1 deletion static/third_party/lib/blockly/core/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ goog.provide('Blockly.Input');
goog.require('Blockly.Connection');
goog.require('Blockly.FieldLabel');
goog.require('goog.asserts');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -66,7 +67,7 @@ Blockly.Input.prototype.appendField = function(field, opt_name) {
return this;
}
// Generate a FieldLabel when given a plain text field.
if (goog.isString(field)) {
if (Blockly.goog.isString(field)) {
field = new Blockly.FieldLabel(/** @type {string} */ (field));
}
if (this.sourceBlock_.svg_) {
Expand Down
5 changes: 3 additions & 2 deletions static/third_party/lib/blockly/core/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'use strict';

goog.provide('Blockly.Tooltip');
goog.require('Blockly.goog');


/**
Expand Down Expand Up @@ -173,7 +174,7 @@ Blockly.Tooltip.onMouseOver_ = function(e) {
// If the tooltip is an object, treat it as a pointer to the next object in
// the chain to look at. Terminate when a string or function is found.
var element = e.target;
while (!goog.isString(element.tooltip) && !goog.isFunction(element.tooltip)) {
while (!Blockly.goog.isString(element.tooltip) && !Blockly.goog.isFunction(element.tooltip)) {
element = element.tooltip;
}
if (Blockly.Tooltip.element_ != element) {
Expand Down Expand Up @@ -267,7 +268,7 @@ Blockly.Tooltip.show_ = function() {
/** @type {!Element} */ (Blockly.Tooltip.svgText_));
// Get the new text.
var tip = Blockly.Tooltip.element_.tooltip;
if (goog.isFunction(tip)) {
if (Blockly.goog.isFunction(tip)) {
tip = tip();
}
tip = Blockly.Tooltip.wrap_(tip, Blockly.Tooltip.LIMIT);
Expand Down