diff --git a/blockly_uncompressed.js b/blockly_uncompressed.js index a44fbad66..f0ea964be 100644 --- a/blockly_uncompressed.js +++ b/blockly_uncompressed.js @@ -336,7 +336,7 @@ goog.addDependency("editor/contenteditablefield.js", ['goog.editor.ContentEditab goog.addDependency("editor/contenteditablefield_test.js", ['goog.editor.ContentEditableFieldTest'], ['goog.dom', 'goog.editor.ContentEditableField', 'goog.editor.field_test', 'goog.testing.jsunit']); goog.addDependency("editor/defines.js", ['goog.editor.defines'], []); goog.addDependency("editor/field.js", ['goog.editor.Field', 'goog.editor.Field.EventType'], ['goog.a11y.aria', 'goog.a11y.aria.Role', 'goog.array', 'goog.asserts', 'goog.async.Delay', 'goog.dom', 'goog.dom.Range', 'goog.dom.TagName', 'goog.dom.classlist', 'goog.editor.BrowserFeature', 'goog.editor.Command', 'goog.editor.Plugin', 'goog.editor.icontent', 'goog.editor.icontent.FieldFormatInfo', 'goog.editor.icontent.FieldStyleInfo', 'goog.editor.node', 'goog.editor.range', 'goog.events', 'goog.events.EventHandler', 'goog.events.EventTarget', 'goog.events.EventType', 'goog.events.KeyCodes', 'goog.functions', 'goog.log', 'goog.log.Level', 'goog.string', 'goog.string.Unicode', 'goog.style', 'goog.userAgent', 'goog.userAgent.product']); -goog.addDependency("editor/field_test.js", ['goog.editor.field_test'], ['goog.array', 'goog.dom', 'goog.dom.Range', 'goog.dom.TagName', 'goog.dom.classes', 'goog.editor.BrowserFeature', 'goog.editor.Field', 'goog.editor.Plugin', 'goog.editor.range', 'goog.events', 'goog.events.BrowserEvent', 'goog.events.EventType', 'goog.events.KeyCodes', 'goog.functions', 'goog.testing.LooseMock', 'goog.testing.MockClock', 'goog.testing.dom', 'goog.testing.events', 'goog.testing.events.Event', 'goog.testing.recordFunction', 'goog.userAgent']); +goog.addDependency("editor/field_test.js", ['goog.editor.field_test'], ['goog.array', 'goog.dom', 'goog.dom.Range', 'goog.dom.TagName', 'goog.dom.classlist', 'goog.editor.BrowserFeature', 'goog.editor.Field', 'goog.editor.Plugin', 'goog.editor.range', 'goog.events', 'goog.events.BrowserEvent', 'goog.events.EventType', 'goog.events.KeyCodes', 'goog.functions', 'goog.testing.LooseMock', 'goog.testing.MockClock', 'goog.testing.dom', 'goog.testing.events', 'goog.testing.events.Event', 'goog.testing.recordFunction', 'goog.userAgent']); goog.addDependency("editor/focus.js", ['goog.editor.focus'], ['goog.dom.selection']); goog.addDependency("editor/focus_test.js", ['goog.editor.focusTest'], ['goog.dom.selection', 'goog.editor.BrowserFeature', 'goog.editor.focus', 'goog.testing.jsunit']); goog.addDependency("editor/icontent.js", ['goog.editor.icontent', 'goog.editor.icontent.FieldFormatInfo', 'goog.editor.icontent.FieldStyleInfo'], ['goog.dom', 'goog.editor.BrowserFeature', 'goog.style', 'goog.userAgent']); @@ -1073,6 +1073,7 @@ goog.addDependency("testing/expectedfailures_test.js", ['goog.testing.ExpectedFa goog.addDependency("testing/functionmock.js", ['goog.testing', 'goog.testing.FunctionMock', 'goog.testing.GlobalFunctionMock', 'goog.testing.MethodMock'], ['goog.object', 'goog.testing.LooseMock', 'goog.testing.Mock', 'goog.testing.PropertyReplacer', 'goog.testing.StrictMock']); goog.addDependency("testing/functionmock_test.js", ['goog.testing.FunctionMockTest'], ['goog.array', 'goog.string', 'goog.testing', 'goog.testing.FunctionMock', 'goog.testing.Mock', 'goog.testing.StrictMock', 'goog.testing.asserts', 'goog.testing.jsunit', 'goog.testing.mockmatchers']); goog.addDependency("testing/graphics.js", ['goog.testing.graphics'], ['goog.graphics.Path', 'goog.testing.asserts']); +goog.addDependency("testing/jstdtestcaseadapter.js", ['goog.testing.JsTdTestCaseAdapter'], ['goog.async.run', 'goog.testing.TestCase', 'goog.testing.jsunit']); goog.addDependency("testing/jsunit.js", ['goog.testing.jsunit'], ['goog.dom.TagName', 'goog.testing.TestCase', 'goog.testing.TestRunner']); goog.addDependency("testing/loosemock.js", ['goog.testing.LooseExpectationCollection', 'goog.testing.LooseMock'], ['goog.array', 'goog.structs.Map', 'goog.testing.Mock']); goog.addDependency("testing/loosemock_test.js", ['goog.testing.LooseMockTest'], ['goog.testing.LooseMock', 'goog.testing.PropertyReplacer', 'goog.testing.jsunit', 'goog.testing.mockmatchers']); @@ -1530,7 +1531,7 @@ goog.addDependency("window/window_test.js", ['goog.windowTest'], ['goog.Promise' goog.addDependency("../../third_party/closure/goog/base.js", [], []); goog.addDependency("../../third_party/closure/goog/deps.js", [], []); goog.addDependency("../../third_party/closure/goog/caja/string/html/htmlparser.js", ['goog.string.html', 'goog.string.html.HtmlParser', 'goog.string.html.HtmlParser.EFlags', 'goog.string.html.HtmlParser.Elements', 'goog.string.html.HtmlParser.Entities', 'goog.string.html.HtmlSaxHandler'], []); -goog.addDependency("../../third_party/closure/goog/caja/string/html/htmlsanitizer.js", ['goog.string.html.HtmlSanitizer', 'goog.string.html.HtmlSanitizer.AttributeType', 'goog.string.html.HtmlSanitizer.Attributes', 'goog.string.html.htmlSanitize'], ['goog.string.StringBuffer', 'goog.string.html.HtmlParser', 'goog.string.html.HtmlParser.EFlags', 'goog.string.html.HtmlParser.Elements', 'goog.string.html.HtmlSaxHandler']); +goog.addDependency("../../third_party/closure/goog/caja/string/html/htmlsanitizer.js", ['goog.string.html.HtmlSanitizer', 'goog.string.html.HtmlSanitizer.AttributeType', 'goog.string.html.HtmlSanitizer.Attributes', 'goog.string.html.htmlSanitize'], ['goog.string.StringBuffer', 'goog.string.html.HtmlParser', 'goog.string.html.HtmlSaxHandler']); goog.addDependency("../../third_party/closure/goog/dojo/dom/query.js", ['goog.dom.query'], ['goog.array', 'goog.dom', 'goog.functions', 'goog.string', 'goog.userAgent']); goog.addDependency("../../third_party/closure/goog/dojo/dom/query_test.js", [], ['goog.dom', 'goog.userAgent']); goog.addDependency("../../third_party/closure/goog/jpeg_encoder/jpeg_encoder_basic.js", ['goog.crypt.JpegEncoder'], ['goog.crypt.base64']); diff --git a/blocks/lists.js b/blocks/lists.js index 8516504c3..88a475202 100644 --- a/blocks/lists.js +++ b/blocks/lists.js @@ -649,14 +649,8 @@ Blockly.Blocks['lists_split'] = { var dropdown = new Blockly.FieldDropdown( [[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT, 'SPLIT'], [Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST, 'JOIN']], - function(newOp) { - if (newOp == 'SPLIT') { - thisBlock.outputConnection.setCheck('Array'); - thisBlock.getInput('INPUT').setCheck('String'); - } else { - thisBlock.outputConnection.setCheck('String'); - thisBlock.getInput('INPUT').setCheck('Array'); - } + function(newMode) { + thisBlock.updateType_(newMode); }); this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL); this.setColour(Blockly.Blocks.lists.HUE); @@ -677,5 +671,38 @@ Blockly.Blocks['lists_split'] = { } throw 'Unknown mode: ' + mode; }); + }, + /** + * Modify this block to have the correct input and output types. + * @param {string} newMode Either 'SPLIT' or 'JOIN'. + * @private + * @this Blockly.Block + */ + updateType_: function(newMode) { + if (newMode == 'SPLIT') { + this.outputConnection.setCheck('Array'); + this.getInput('INPUT').setCheck('String'); + } else { + this.outputConnection.setCheck('String'); + this.getInput('INPUT').setCheck('Array'); + } + }, + /** + * Create XML to represent the input and output types. + * @return {!Element} XML storage element. + * @this Blockly.Block + */ + mutationToDom: function() { + var container = document.createElement('mutation'); + container.setAttribute('mode', this.getFieldValue('MODE')); + return container; + }, + /** + * Parse XML to restore the input and output types. + * @param {!Element} xmlElement XML storage element. + * @this Blockly.Block + */ + domToMutation: function(xmlElement) { + this.updateType_(xmlElement.getAttribute('mode')); } }; diff --git a/blocks/math.js b/blocks/math.js index b79909f14..f89704143 100644 --- a/blocks/math.js +++ b/blocks/math.js @@ -369,6 +369,7 @@ Blockly.Blocks['math_on_list'] = { }, /** * Modify this block to have the correct output type. + * @param {string} newOp Either 'MODE' or some op than returns a number. * @private * @this Blockly.Block */ diff --git a/blocks/text.js b/blocks/text.js index 3bb7dfabd..405e7aeb1 100644 --- a/blocks/text.js +++ b/blocks/text.js @@ -620,6 +620,7 @@ Blockly.Blocks['text_prompt_ext'] = { }, /** * Modify this block to have the correct output type. + * @param {string} newOp Either 'TEXT' or 'NUMBER'. * @private * @this Blockly.Block */ diff --git a/blocks_compressed.js b/blocks_compressed.js index cbdd0af9c..aac7a3f8b 100644 --- a/blocks_compressed.js +++ b/blocks_compressed.js @@ -33,8 +33,9 @@ Blockly.Blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[Blockly. this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);this.appendDummyInput("AT1");this.appendDummyInput("AT2");Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL);this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),b=this.getInput("AT1").type== Blockly.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type==Blockly.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("at1");a="true"==a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)): this.appendDummyInput("AT"+a);var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var e="FROM_START"==c||"FROM_END"==c;if(e!=b){var f=this.sourceBlock_;f.updateAt_(a,e);f.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"));Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}}; -Blockly.Blocks.lists_split={init:function(){var a=this,b=new Blockly.FieldDropdown([[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(b){"SPLIT"==b?(a.outputConnection.setCheck("Array"),a.getInput("INPUT").setCheck("String")):(a.outputConnection.setCheck("String"),a.getInput("INPUT").setCheck("Array"))});this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);this.setColour(Blockly.Blocks.lists.HUE);this.appendValueInput("INPUT").setCheck("String").appendField(b, -"MODE");this.appendValueInput("DELIM").setCheck("String").appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER);this.setInputsInline(!0);this.setOutput(!0,"Array");this.setTooltip(function(){var b=a.getFieldValue("MODE");if("SPLIT"==b)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"==b)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw"Unknown mode: "+b;})}}; +Blockly.Blocks.lists_split={init:function(){var a=this,b=new Blockly.FieldDropdown([[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(b){a.updateType_(b)});this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);this.setColour(Blockly.Blocks.lists.HUE);this.appendValueInput("INPUT").setCheck("String").appendField(b,"MODE");this.appendValueInput("DELIM").setCheck("String").appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER);this.setInputsInline(!0); +this.setOutput(!0,"Array");this.setTooltip(function(){var b=a.getFieldValue("MODE");if("SPLIT"==b)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"==b)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw"Unknown mode: "+b;})},updateType_:function(a){"SPLIT"==a?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("mode", +this.getFieldValue("MODE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("mode"))}}; // Copyright 2012 Google Inc. Apache License 2.0 Blockly.Blocks.logic={};Blockly.Blocks.logic.HUE=210; Blockly.Blocks.controls_if={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL);this.setColour(Blockly.Blocks.logic.HUE);this.appendValueInput("IF0").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setMutator(new Blockly.Mutator(["controls_if_elseif","controls_if_else"]));var a=this;this.setTooltip(function(){if(a.elseifCount_||a.elseCount_){if(!a.elseifCount_&&