diff --git a/build.py b/build.py index 770cbc78..e53c4cfb 100755 --- a/build.py +++ b/build.py @@ -337,31 +337,6 @@ class Gen_compressed(threading.Thread): code = HEADER + "\n" + json_data["compiledCode"] code = code.replace(remove, "") - - # Trim down Google's Apache licences. - # The Closure Compiler used to preserve these until August 2015. - # Delete this in a few months if the licences don't return. - LICENSE = re.compile("""/\\* - - [\w ]+ - - (Copyright \\d+ Google Inc.) - https://developers.google.com/blockly/ - - Licensed under the Apache License, Version 2.0 \(the "License"\); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -\\*/""") - code = re.sub(LICENSE, r"\n// \1 Apache License 2.0", code) - stats = json_data["statistics"] original_b = stats["originalSize"] compressed_b = stats["compressedSize"] diff --git a/core/block_svg.js b/core/block_svg.js index 75ceaec3..3b1e040a 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -997,10 +997,8 @@ Blockly.BlockSvg.disposeUiStep_ = function(clone, rtl, start, workspaceScale) { var scale = (1 - percent) * workspaceScale; clone.setAttribute('transform', 'translate(' + x + ',' + y + ')' + ' scale(' + scale + ')'); - var closure = function() { - Blockly.BlockSvg.disposeUiStep_(clone, rtl, start, workspaceScale); - }; - setTimeout(closure, 10); + setTimeout(Blockly.BlockSvg.disposeUiStep_, 10, clone, rtl, start, + workspaceScale); } }; diff --git a/core/extensions.js b/core/extensions.js index f4264027..1f88d6d5 100644 --- a/core/extensions.js +++ b/core/extensions.js @@ -60,7 +60,7 @@ Blockly.Extensions.MUTATOR_PROPERTIES_ = * handlers and mutators. These are applied using Block.applyExtension(), or * the JSON "extensions" array attribute. * @param {string} name The name of this extension. - * @param {function} initFn The function to initialize an extended block. + * @param {Function} initFn The function to initialize an extended block. * @throws {Error} if the extension name is empty, the extension is already * registered, or extensionFn is not a function. */ @@ -97,7 +97,7 @@ Blockly.Extensions.registerMixin = function(name, mixinObj) { * decompose are defined on the mixin. * @param {string} name The name of this mutator extension. * @param {!Object} mixinObj The values to mix in. - * @param {function()=} opt_helperFn An optional function to apply after mixing + * @param {(function())=} opt_helperFn An optional function to apply after mixing * in the object. * @param {Array.=} opt_blockList A list of blocks to appear in the * flyout of the mutator dialog. @@ -108,8 +108,10 @@ Blockly.Extensions.registerMutator = function(name, mixinObj, opt_helperFn, var errorPrefix = 'Error when registering mutator "' + name + '": '; // Sanity check the mixin object before registering it. - Blockly.Extensions.checkHasFunction_(errorPrefix, mixinObj, 'domToMutation'); - Blockly.Extensions.checkHasFunction_(errorPrefix, mixinObj, 'mutationToDom'); + Blockly.Extensions.checkHasFunction_(errorPrefix, mixinObj.domToMutation, + 'domToMutation'); + Blockly.Extensions.checkHasFunction_(errorPrefix, mixinObj.mutationToDom, + 'mutationToDom'); var hasMutatorDialog = Blockly.Extensions.checkMutatorDialog_(mixinObj, errorPrefix); @@ -167,20 +169,19 @@ Blockly.Extensions.apply = function(name, block, isMutator) { }; /** - * Check that the given object has a property with the given name, and that the - * property is a function. + * Check that the given value is a function. * @param {string} errorPrefix The string to prepend to any error message. - * @param {!Object} object The object to check. + * @param {*} func Function to check. * @param {string} propertyName Which property to check. * @throws {Error} if the property does not exist or is not a function. * @private */ -Blockly.Extensions.checkHasFunction_ = function(errorPrefix, object, +Blockly.Extensions.checkHasFunction_ = function(errorPrefix, func, propertyName) { - if (!object.hasOwnProperty(propertyName)) { + if (!func) { throw new Error(errorPrefix + 'missing required property "' + propertyName + '"'); - } else if (typeof object[propertyName] !== "function") { + } else if (typeof func != 'function') { throw new Error(errorPrefix + '" required property "' + propertyName + '" must be a function'); } diff --git a/core/trashcan.js b/core/trashcan.js index 33f9fa5e..c5aa411a 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -165,8 +165,9 @@ Blockly.Trashcan.prototype.createDom = function() { */ this.svgGroup_ = Blockly.utils.createSvgElement('g', {'class': 'blocklyTrash'}, null); + var clip; var rnd = String(Math.random()).substring(2); - var clip = Blockly.utils.createSvgElement('clipPath', + clip = Blockly.utils.createSvgElement('clipPath', {'id': 'blocklyTrashBodyClipPath' + rnd}, this.svgGroup_); Blockly.utils.createSvgElement('rect', @@ -181,7 +182,7 @@ Blockly.Trashcan.prototype.createDom = function() { body.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); - var clip = Blockly.utils.createSvgElement('clipPath', + clip = Blockly.utils.createSvgElement('clipPath', {'id': 'blocklyTrashLidClipPath' + rnd}, this.svgGroup_); Blockly.utils.createSvgElement('rect', diff --git a/core/utils.js b/core/utils.js index 18ab7cd5..a32380ac 100644 --- a/core/utils.js +++ b/core/utils.js @@ -197,7 +197,7 @@ Blockly.utils.getInjectionDivXY_ = function(element) { var scale = 1; while (element) { var xy = Blockly.utils.getRelativeXY(element); - var scale = Blockly.utils.getScale_(element); + scale = Blockly.utils.getScale_(element); x = (x * scale) + xy.x; y = (y * scale) + xy.y; var classes = element.getAttribute('class') || ''; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 08515e45..96799855 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1957,7 +1957,6 @@ Blockly.WorkspaceSvg.prototype.startDragWithFakeEvent = function(fakeEvent, /** * Get the audio manager for this workspace. * @return {Blockly.WorkspaceAudio} The audio manager for this workspace. - * @package */ Blockly.WorkspaceSvg.prototype.getAudioManager = function() { return this.audioManager_; diff --git a/core/xml.js b/core/xml.js index 5c2ab0e8..ff0b431c 100644 --- a/core/xml.js +++ b/core/xml.js @@ -397,7 +397,7 @@ Blockly.Xml.appendDomToWorkspace = function(xml, workspace) { var savetab = Blockly.BlockSvg.TAB_WIDTH; try { Blockly.BlockSvg.TAB_WIDTH = 0; - var bbox = workspace.getBlocksBoundingBox(); + bbox = workspace.getBlocksBoundingBox(); } finally { Blockly.BlockSvg.TAB_WIDTH = savetab; } diff --git a/i18n/create_messages.py b/i18n/create_messages.py index 1010b05f..dc2620a3 100755 --- a/i18n/create_messages.py +++ b/i18n/create_messages.py @@ -34,7 +34,7 @@ def string_is_ascii(s): return True except UnicodeEncodeError: return False - + def load_constants(filename): """Read in constants file, which must be output in every language.""" constant_defs = read_json_file(filename); @@ -42,7 +42,7 @@ def load_constants(filename): for key in constant_defs: value = constant_defs[key] value = value.replace('"', '\\"') - constants_text += '\nBlockly.Msg.{0} = \"{1}\";'.format(key, value) + constants_text += '\nBlockly.Msg["{0}"] = "{1}";'.format(key, value) return constants_text def main(): @@ -139,7 +139,7 @@ goog.require('Blockly.Msg'); value = source_defs[key] comment = ' // untranslated' value = value.replace('"', '\\"') - outfile.write(u'Blockly.Msg.{0} = "{1}";{2}\n'.format( + outfile.write(u'Blockly.Msg["{0}"] = "{1}";{2}\n'.format( key, value, comment)) # Announce any keys defined only for target language.