Commit 6e4a1d1b authored by neil.fraser@gmail.com's avatar neil.fraser@gmail.com

Fix Toolbox when compiled aggressively.

git-svn-id: http://blockly.googlecode.com/svn/trunk@1730 c400ca83-b69d-9dd7-9705-49c6b8615e23
parent d7f29afc
This diff is collapsed.
......@@ -54,7 +54,7 @@ goog.addDependency("../../../" + dir + "/core/procedures.js", ['Blockly.Procedur
goog.addDependency("../../../" + dir + "/core/realtime-client-utils.js", ['rtclient'], []);
goog.addDependency("../../../" + dir + "/core/realtime.js", ['Blockly.Realtime'], ['goog.array', 'goog.dom', 'goog.style', 'rtclient']);
goog.addDependency("../../../" + dir + "/core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/toolbox.js", ['Blockly.Toolbox'], ['Blockly.Flyout', 'goog.events.BrowserFeature', 'goog.style', 'goog.ui.tree.TreeControl', 'goog.ui.tree.TreeNode']);
goog.addDependency("../../../" + dir + "/core/toolbox.js", ['Blockly.Toolbox'], ['Blockly.Flyout', 'goog.events.BrowserFeature', 'goog.html.SafeHtml', 'goog.style', 'goog.ui.tree.TreeControl', 'goog.ui.tree.TreeNode']);
goog.addDependency("../../../" + dir + "/core/tooltip.js", ['Blockly.Tooltip'], []);
goog.addDependency("../../../" + dir + "/core/trashcan.js", ['Blockly.Trashcan'], ['goog.Timer']);
goog.addDependency("../../../" + dir + "/core/utils.js", ['Blockly.utils'], []);
......
......@@ -57,7 +57,7 @@ Blockly.ContextMenu.show = function(e, options) {
var menu = new goog.ui.Menu();
for (var x = 0, option; option = options[x]; x++) {
var menuItem = new goog.ui.MenuItem(option.text);
menu.addItem(menuItem);
menu.addChild(menuItem, true);
menuItem.setEnabled(option.enabled);
if (option.enabled) {
var evtHandlerCapturer = function(callback) {
......
......@@ -119,7 +119,7 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
var menuItem = new goog.ui.MenuItem(text);
menuItem.setValue(value);
menuItem.setCheckable(true);
menu.addItem(menuItem);
menu.addChild(menuItem, true);
menuItem.setChecked(value == this.value_);
}
goog.events.listen(menu, goog.ui.Component.EventType.ACTION, callback);
......
......@@ -28,6 +28,7 @@ goog.provide('Blockly.Toolbox');
goog.require('Blockly.Flyout');
goog.require('goog.events.BrowserFeature');
goog.require('goog.html.SafeHtml');
goog.require('goog.style');
goog.require('goog.ui.tree.TreeControl');
goog.require('goog.ui.tree.TreeNode');
......@@ -53,16 +54,16 @@ Blockly.Toolbox.selectedOption_ = null;
* @private
*/
Blockly.Toolbox.CONFIG_ = {
'indentWidth': 19,
'cssRoot': 'blocklyTreeRoot',
'cssHideRoot': 'blocklyHidden',
'cssItem': '',
'cssTreeRow': 'blocklyTreeRow',
'cssItemLabel': 'blocklyTreeLabel',
'cssTreeIcon': 'blocklyTreeIcon',
'cssExpandedFolderIcon': 'blocklyTreeIconOpen',
'cssFileIcon': 'blocklyTreeIconNone',
'cssSelectedRow': 'blocklyTreeSelected'
indentWidth: 19,
cssRoot: 'blocklyTreeRoot',
cssHideRoot: 'blocklyHidden',
cssItem: '',
cssTreeRow: 'blocklyTreeRow',
cssItemLabel: 'blocklyTreeLabel',
cssTreeIcon: 'blocklyTreeIcon',
cssExpandedFolderIcon: 'blocklyTreeIconOpen',
cssFileIcon: 'blocklyTreeIconNone',
cssSelectedRow: 'blocklyTreeSelected'
};
/**
......@@ -104,7 +105,8 @@ Blockly.Toolbox.init = function() {
Blockly.pathToBlockly + 'media/1x1.gif';
Blockly.Toolbox.CONFIG_['cssCollapsedFolderIcon'] =
'blocklyTreeIconClosed' + (Blockly.RTL ? 'Rtl' : 'Ltr');
var tree = new Blockly.Toolbox.TreeControl('root', Blockly.Toolbox.CONFIG_);
var tree = new Blockly.Toolbox.TreeControl(goog.html.SafeHtml.EMPTY,
Blockly.Toolbox.CONFIG_);
Blockly.Toolbox.tree_ = tree;
tree.setShowRootNode(false);
tree.setShowLines(false);
......@@ -196,7 +198,7 @@ Blockly.Toolbox.clearSelection = function() {
/**
* Extention of a TreeControl object that uses a custom tree node.
* @param {string} html The HTML content of the node label.
* @param {!goog.html.SafeHtml} html The HTML content of the node label.
* @param {Object=} opt_config The configuration for the tree. See
* goog.ui.tree.TreeControl.DefaultConfig. If not specified, a default config
* will be used.
......@@ -247,8 +249,9 @@ Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_ = function(e) {
* @override
*/
Blockly.Toolbox.TreeControl.prototype.createNode = function(opt_html) {
return new Blockly.Toolbox.TreeNode(opt_html || '', this.getConfig(),
this.getDomHelper());
return new Blockly.Toolbox.TreeNode(opt_html ?
goog.html.SafeHtml.htmlEscape(opt_html) : goog.html.SafeHtml.EMPTY,
this.getConfig(), this.getDomHelper());
};
/**
......@@ -271,7 +274,7 @@ Blockly.Toolbox.TreeControl.prototype.setSelectedItem = function(node) {
/**
* An single node in the tree, customized for Blockly's UI.
* @param {string} html The html content of the node label.
* @param {!goog.html.SafeHtml} html The HTML content of the node label.
* @param {Object=} opt_config The configuration for the tree. See
* goog.ui.tree.TreeControl.DefaultConfig. If not specified, a default config
* will be used.
......
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