mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Add expanded property to toolbox XML.
This commit is contained in:
@@ -1281,8 +1281,8 @@ Blockly.Toolbox=function(a){this.workspace_=a};Blockly.Toolbox.prototype.width=0
|
||||
Blockly.Toolbox.prototype.init=function(){var a=this.workspace_;this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv");this.HtmlDiv.setAttribute("dir",this.workspace_.RTL?"RTL":"LTR");document.body.appendChild(this.HtmlDiv);Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(a){Blockly.isRightButton(a)||a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0)});this.flyout_=new Blockly.Flyout({parentWorkspace:a,RTL:a.RTL});goog.dom.insertSiblingAfter(this.flyout_.createDom(),a.svgGroup_);
|
||||
this.flyout_.init(a);this.CONFIG_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(this.workspace_.RTL?"Rtl":"Ltr");var b=new Blockly.Toolbox.TreeControl(this,this.CONFIG_);this.tree_=b;b.setShowRootNode(!1);b.setShowLines(!1);b.setShowExpandIcons(!1);b.setSelectedItem(null);this.populate_(a.options.languageTree);b.render(this.HtmlDiv);this.position()};
|
||||
Blockly.Toolbox.prototype.position=function(){var a=this.HtmlDiv;if(a){var b=this.workspace_.options.svg,c=goog.style.getPageOffset(b),b=Blockly.svgSize(b);a.style.left=this.workspace_.RTL?c.x+b.width-a.offsetWidth+"px":c.x+"px";a.style.height=b.height+"px";a.style.top=c.y+"px";this.width=a.offsetWidth;this.workspace_.RTL||--this.width;this.flyout_.position()}};
|
||||
Blockly.Toolbox.prototype.populate_=function(a){function b(a,e){for(var f=0,g;g=a.childNodes[f];f++)if(g.tagName){var h=g.tagName.toUpperCase();if("CATEGORY"==h){h=c.createNode(g.getAttribute("name"));h.blocks=[];e.add(h);var k=g.getAttribute("custom");k?h.blocks=k:b(g,h)}else"HR"==h?console.warn("The <hr> separator tag in the toolbox XML needs to be changed to <sep></sep> (due to a bug in IE)."):"SEP"==h?e.add(new Blockly.Toolbox.TreeSeparator):"BLOCK"==h&&e.blocks.push(g)}}var c=this.tree_;c.removeChildren();
|
||||
c.blocks=[];b(a,this.tree_);if(c.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";Blockly.fireUiEvent(window,"resize")};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.prototype.getRect=function(){var a=this.workspace_.RTL?Blockly.svgSize(this.workspace_.options.svg).width-this.width:-1E7;return new goog.math.Rect(a,-1E7,1E7+this.width,2E7)};
|
||||
Blockly.Toolbox.prototype.populate_=function(a){function b(a,e){for(var f=0,g;g=a.childNodes[f];f++)if(g.tagName){var h=g.tagName.toUpperCase();if("CATEGORY"==h){h=c.createNode(g.getAttribute("name"));h.blocks=[];"true"==g.getAttribute("expanded")&&h.setExpanded(!0);e.add(h);var k=g.getAttribute("custom");k?h.blocks=k:b(g,h)}else"HR"==h?console.warn("The <hr> separator tag in the toolbox XML needs to be changed to <sep></sep> (due to a bug in IE)."):"SEP"==h?e.add(new Blockly.Toolbox.TreeSeparator):
|
||||
"BLOCK"==h&&e.blocks.push(g)}}var c=this.tree_;c.removeChildren();c.blocks=[];b(a,this.tree_);if(c.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";Blockly.fireUiEvent(window,"resize")};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.prototype.getRect=function(){var a=this.workspace_.RTL?Blockly.svgSize(this.workspace_.options.svg).width-this.width:-1E7;return new goog.math.Rect(a,-1E7,1E7+this.width,2E7)};
|
||||
Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(goog.events.BrowserFeature.TOUCH_ENABLED){var a=this.getElement();Blockly.bindEvent_(a,goog.events.EventType.TOUCHSTART,this,this.handleTouchEvent_)}};
|
||||
Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){a.preventDefault();var b=this.getNodeFromEvent_(a);b&&a.type===goog.events.EventType.TOUCHSTART&&setTimeout(function(){b.onMouseDown(a)},1)};Blockly.Toolbox.TreeControl.prototype.createNode=function(a){return new Blockly.Toolbox.TreeNode(this.toolbox_,a?goog.html.SafeHtml.htmlEscape(a):goog.html.SafeHtml.EMPTY,this.getConfig(),this.getDomHelper())};
|
||||
Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(a){Blockly.removeAllRanges();if(this.selectedItem_!=a){goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,a);var b=this.toolbox_;a&&a.blocks&&a.blocks.length?(b.flyout_.show(a.blocks),b.lastCategory_!=a.blocks&&(b.flyout_.scrollToTop(),b.lastCategory_=a.blocks)):b.flyout_.hide()}};
|
||||
|
||||
@@ -569,12 +569,10 @@ Blockly.setMainWorkspaceMetrics_ = function(xyRatio) {
|
||||
}
|
||||
var metrics = this.getMetrics();
|
||||
if (goog.isNumber(xyRatio.x)) {
|
||||
this.scrollX = -metrics.contentWidth * xyRatio.x -
|
||||
metrics.contentLeft;
|
||||
this.scrollX = -metrics.contentWidth * xyRatio.x - metrics.contentLeft;
|
||||
}
|
||||
if (goog.isNumber(xyRatio.y)) {
|
||||
this.scrollY = -metrics.contentHeight * xyRatio.y -
|
||||
metrics.contentTop;
|
||||
this.scrollY = -metrics.contentHeight * xyRatio.y - metrics.contentTop;
|
||||
}
|
||||
var x = this.scrollX + metrics.absoluteLeft;
|
||||
var y = this.scrollY + metrics.absoluteTop;
|
||||
|
||||
@@ -184,6 +184,9 @@ Blockly.Toolbox.prototype.populate_ = function(newTree) {
|
||||
if (name == '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) {
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<category name="Variables" custom="VARIABLE"></category>
|
||||
<category name="Functions" custom="PROCEDURE"></category>
|
||||
<sep></sep>
|
||||
<category name="Library">
|
||||
<category name="Library" expanded="true">
|
||||
<category name="Randomize">
|
||||
<block type="procedures_defnoreturn">
|
||||
<mutation>
|
||||
|
||||
@@ -181,7 +181,7 @@ Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "Jika benar";
|
||||
Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "Check the condition in 'test'. If the condition is true, returns the 'if true' value; otherwise returns the 'if false' value.";
|
||||
Blockly.Msg.MATH_ADDITION_SYMBOL = "+";
|
||||
Blockly.Msg.MATH_ARITHMETIC_HELPURL = "https://ms.wikipedia.org/wiki/Aritmetik";
|
||||
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "Return the sum of the two numbers.";
|
||||
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "Kembalikan jumlah kedua-dua bilangan.";
|
||||
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE = "Taip balik hasil bahagi dua nombor tersebut.";
|
||||
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS = "Taip balik hasil tolak dua nombor tersebut.";
|
||||
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY = "Taip balik hasil darab dua nombor tersebut.";
|
||||
@@ -356,7 +356,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH = "mengurangkan kawasan dari kedua-dua belah
|
||||
Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "mengurangkan ruang dari sebelah kiri";
|
||||
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "mengurangkan kawasan dari sisi kanan";
|
||||
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Kembali salinan teks dengan ruang yang dikeluarkan daripada satu atau hujung kedua belah.";
|
||||
Blockly.Msg.TODAY = "Today"; // untranslated
|
||||
Blockly.Msg.TODAY = "Hari ini";
|
||||
Blockly.Msg.VARIABLES_DEFAULT_NAME = "Perkara";
|
||||
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Hasilkan 'set %1'";
|
||||
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
|
||||
|
||||
@@ -9,7 +9,7 @@ goog.require('Blockly.Msg');
|
||||
Blockly.Msg.ADD_COMMENT = "ใส่คำอธิบาย";
|
||||
Blockly.Msg.AUTH = "กรุณาอนุญาตแอปนี้เพื่อเปิดใช้งาน การบันทึกงานของคุณ และยินยอมให้คุณแบ่งปันงานของคุณได้";
|
||||
Blockly.Msg.CHANGE_VALUE_TITLE = "เปลี่ยนค่า:";
|
||||
Blockly.Msg.CHAT = "คุยกับ ผู้ร่วมงานของคุณโดยพิมพ์ลงในกล่องนี้!";
|
||||
Blockly.Msg.CHAT = "คุยกับ ผู้ร่วมงานของคุณโดยพิมพ์ลงในกล่องนี้!";
|
||||
Blockly.Msg.COLLAPSE_ALL = "ย่อบล็อก";
|
||||
Blockly.Msg.COLLAPSE_BLOCK = "ย่อบล็อก";
|
||||
Blockly.Msg.COLOUR_BLEND_COLOUR1 = "สีที่ 1";
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"DISABLE_BLOCK": "ปิดใช้งานบล็อก",
|
||||
"ENABLE_BLOCK": "เปิดใช้งานบล็อก",
|
||||
"HELP": "ช่วยเหลือ",
|
||||
"CHAT": "คุยกับ\tผู้ร่วมงานของคุณโดยพิมพ์ลงในกล่องนี้!",
|
||||
"CHAT": "คุยกับ ผู้ร่วมงานของคุณโดยพิมพ์ลงในกล่องนี้!",
|
||||
"AUTH": "กรุณาอนุญาตแอปนี้เพื่อเปิดใช้งาน การบันทึกงานของคุณ และยินยอมให้คุณแบ่งปันงานของคุณได้",
|
||||
"ME": "ฉัน",
|
||||
"CHANGE_VALUE_TITLE": "เปลี่ยนค่า:",
|
||||
|
||||
Reference in New Issue
Block a user