diff --git a/blockly_compressed.js b/blockly_compressed.js index b7a431061..30083c77a 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -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
separator tag in the toolbox XML needs to be changed to (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
separator tag in the toolbox XML needs to be changed to (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()}}; diff --git a/core/blockly.js b/core/blockly.js index 5d5aa485b..7ef8e789c 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -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; diff --git a/core/toolbox.js b/core/toolbox.js index be25290f9..ad7b75910 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -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) { diff --git a/demos/toolbox/index.html b/demos/toolbox/index.html index 58f6db667..ef737d0db 100644 --- a/demos/toolbox/index.html +++ b/demos/toolbox/index.html @@ -139,7 +139,7 @@ - + diff --git a/msg/js/ms.js b/msg/js/ms.js index 20f58354d..7ca01fd97 100644 --- a/msg/js/ms.js +++ b/msg/js/ms.js @@ -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 diff --git a/msg/js/th.js b/msg/js/th.js index aff90e51f..ee86d99d1 100644 --- a/msg/js/th.js +++ b/msg/js/th.js @@ -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"; diff --git a/msg/json/th.json b/msg/json/th.json index 63c3a17c2..032774294 100644 --- a/msg/json/th.json +++ b/msg/json/th.json @@ -21,7 +21,7 @@ "DISABLE_BLOCK": "ปิดใช้งานบล็อก", "ENABLE_BLOCK": "เปิดใช้งานบล็อก", "HELP": "ช่วยเหลือ", - "CHAT": "คุยกับ\tผู้ร่วมงานของคุณโดยพิมพ์ลงในกล่องนี้!", + "CHAT": "คุยกับ ผู้ร่วมงานของคุณโดยพิมพ์ลงในกล่องนี้!", "AUTH": "กรุณาอนุญาตแอปนี้เพื่อเปิดใช้งาน การบันทึกงานของคุณ และยินยอมให้คุณแบ่งปันงานของคุณได้", "ME": "ฉัน", "CHANGE_VALUE_TITLE": "เปลี่ยนค่า:",