Commit bcebb077 authored by Neil Fraser's avatar Neil Fraser

Allow flights to be initially expanded in toolbox.

parent 24ffee62
This diff is collapsed.
......@@ -195,9 +195,6 @@ Blockly.Toolbox.prototype.populate_ = function(newTree) {
case 'CATEGORY':
var childOut = rootOut.createNode(childIn.getAttribute('name'));
childOut.blocks = [];
if (childIn.getAttribute('expanded') == 'true') {
childOut.setExpanded(true);
}
treeOut.add(childOut);
var custom = childIn.getAttribute('custom');
if (custom) {
......@@ -206,6 +203,12 @@ Blockly.Toolbox.prototype.populate_ = function(newTree) {
} else {
syncTrees(childIn, childOut);
}
if (childIn.getAttribute('expanded') == 'true') {
if (childOut.blocks.length) {
rootOut.setSelectedItem(childOut);
}
childOut.setExpanded(true);
}
break;
case 'SEP':
treeOut.add(new Blockly.Toolbox.TreeSeparator());
......
......@@ -184,36 +184,5 @@ Blockly.Workspace.prototype.fireChangeEvent = function() {
// NOP.
};
/**
* Modify the block tree on the existing toolbox.
* @param {Node|string} tree DOM tree of blocks, or text representation of same.
*/
Blockly.Workspace.prototype.updateToolbox = function(tree) {
tree = Blockly.parseToolboxTree_(tree);
if (!tree) {
if (this.options.languageTree) {
throw 'Can\'t nullify an existing toolbox.';
}
// No change (null to null).
return;
}
if (!this.options.languageTree) {
throw 'Existing toolbox is null. Can\'t create new toolbox.';
}
if (this.options.hasCategories) {
if (!this.toolbox_) {
throw 'Existing toolbox has no categories. Can\'t change mode.';
}
this.options.languageTree = tree;
this.toolbox_.populate_(tree);
} else {
if (!this.flyout_) {
throw 'Existing toolbox has categories. Can\'t change mode.';
}
this.options.languageTree = tree;
this.flyout_.show(tree.childNodes);
}
};
// Export symbols that would otherwise be renamed by Closure compiler.
Blockly.Workspace.prototype['clear'] = Blockly.Workspace.prototype.clear;
......@@ -655,6 +655,37 @@ Blockly.WorkspaceSvg.prototype.playAudio = function(name, opt_volume) {
}
};
/**
* Modify the block tree on the existing toolbox.
* @param {Node|string} tree DOM tree of blocks, or text representation of same.
*/
Blockly.WorkspaceSvg.prototype.updateToolbox = function(tree) {
tree = Blockly.parseToolboxTree_(tree);
if (!tree) {
if (this.options.languageTree) {
throw 'Can\'t nullify an existing toolbox.';
}
// No change (null to null).
return;
}
if (!this.options.languageTree) {
throw 'Existing toolbox is null. Can\'t create new toolbox.';
}
if (this.options.hasCategories) {
if (!this.toolbox_) {
throw 'Existing toolbox has no categories. Can\'t change mode.';
}
this.options.languageTree = tree;
this.toolbox_.populate_(tree);
} else {
if (!this.flyout_) {
throw 'Existing toolbox has categories. Can\'t change mode.';
}
this.options.languageTree = tree;
this.flyout_.show(tree.childNodes);
}
};
/**
* When something in this workspace changes, call a function.
* @param {!Function} func Function to call.
......
......@@ -69,7 +69,7 @@ Blockly.Msg.ENABLE_BLOCK = "Aktifkan blok";
Blockly.Msg.EXPAND_ALL = "Kembangkan blok-blok";
Blockly.Msg.EXPAND_BLOCK = "Kembangkan blok";
Blockly.Msg.EXTERNAL_INPUTS = "Input-input eksternal";
Blockly.Msg.HELP = "Tolong";
Blockly.Msg.HELP = "Bantuan";
Blockly.Msg.INLINE_INPUTS = "Input inline";
Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-empty-list";
Blockly.Msg.LISTS_CREATE_EMPTY_TITLE = "buat list kosong";
......
......@@ -142,8 +142,8 @@ Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM_START = "リスト内の指定さ
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST = "リスト内の最後の項目を設定します。";
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM = "リスト内にランダムなアイテムを設定します。";
Blockly.Msg.LISTS_SPLIT_HELPURL = "https://github.com/google/blockly/wiki/Lists#splitting-strings-and-joining-lists"; // untranslated
Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT = "make list from text"; // untranslated
Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST = "make text from list"; // untranslated
Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT = "テキストからリストを作る";
Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST = "リストからテキストを作る";
Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN = "Join a list of texts into one text, separated by a delimiter."; // untranslated
Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT = "Split text into a list of texts, breaking at each delimiter."; // untranslated
Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER = "with delimiter"; // untranslated
......@@ -257,7 +257,7 @@ Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN = "番号のarctangent を返すます";
Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "番号のcosineの次数を返す";
Blockly.Msg.MATH_TRIG_TOOLTIP_SIN = "番号のsineの次数を返す";
Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "番号のtangentの次数を返す";
Blockly.Msg.ME = "Me"; // untranslated
Blockly.Msg.ME = "私に";
Blockly.Msg.NEW_VARIABLE = "新しい変数";
Blockly.Msg.NEW_VARIABLE_TITLE = "新しい変数の、名前";
Blockly.Msg.ORDINAL_NUMBER_SUFFIX = "";
......
......@@ -55,7 +55,7 @@ Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "Если первое условие ист
Blockly.Msg.CONTROLS_REPEAT_HELPURL = "https://ru.wikipedia.org/wiki/Цикл_(программирование)";
Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "выполнить";
Blockly.Msg.CONTROLS_REPEAT_TITLE = "повторить %1 раз";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Выполняет команды несколько раз.";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Выполняет некоторые команды несколько раз.";
Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL = "https://github.com/google/blockly/wiki/Loops#repeat"; // untranslated
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "повторять, пока не";
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "повторять, пока";
......
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