mirror of
https://github.com/google/blockly.git
synced 2026-01-15 04:47:10 +01:00
Strip 200 lines of unreachable code
There’s a lot more junk in here, this is just a quick first pass.
This commit is contained in:
@@ -617,82 +617,6 @@ Blockly.tree.BaseNode.prototype.toggle = function() {
|
||||
this.setExpanded(!this.getExpanded());
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.expand = function() {
|
||||
this.setExpanded(true);
|
||||
};
|
||||
/**
|
||||
* Collapses the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.collapse = function() {
|
||||
this.setExpanded(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Collapses the children of the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.collapseChildren = function() {
|
||||
this.forEachChild(function(child) { child.collapseAll(); });
|
||||
};
|
||||
|
||||
/**
|
||||
* Collapses the children and the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.collapseAll = function() {
|
||||
this.collapseChildren();
|
||||
this.collapse();
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands the children of the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.expandChildren = function() {
|
||||
this.forEachChild(function(child) { child.expandAll(); });
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands the children and the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.expandAll = function() {
|
||||
this.expandChildren();
|
||||
this.expand();
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands the parent chain of this node so that it is visible.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.reveal = function() {
|
||||
var parent = this.getParent();
|
||||
if (parent) {
|
||||
parent.setExpanded(true);
|
||||
parent.reveal();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets whether the node will allow the user to collapse it.
|
||||
* @param {boolean} isCollapsible Whether to allow node collapse.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setIsUserCollapsible = function(isCollapsible) {
|
||||
this.isUserCollapsible_ = isCollapsible;
|
||||
if (!this.isUserCollapsible_) {
|
||||
this.expand();
|
||||
}
|
||||
if (this.getElement()) {
|
||||
this.updateExpandIcon();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the node is collapsible by user actions.
|
||||
* @protected
|
||||
@@ -776,7 +700,6 @@ Blockly.tree.BaseNode.prototype.getRowClassName = function() {
|
||||
Blockly.tree.BaseNode.prototype.getLabelDom = function() {
|
||||
var label = document.createElement('span');
|
||||
label.setAttribute('class', this.config_.cssItemLabel || '');
|
||||
label.setAttribute('title', this.getToolTip() || '');
|
||||
label.textContent = this.getText();
|
||||
return label;
|
||||
};
|
||||
@@ -932,15 +855,6 @@ Blockly.tree.BaseNode.prototype.getLabelElement = function() {
|
||||
null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Element} The element after the label.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getAfterLabelElement = function() {
|
||||
var el = this.getRowElement();
|
||||
return el ? /** @type {Element} */ (el.lastChild) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Element} The div containing the children.
|
||||
* @protected
|
||||
@@ -950,18 +864,6 @@ Blockly.tree.BaseNode.prototype.getChildrenElement = function() {
|
||||
return el ? /** @type {Element} */ (el.lastChild) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the icon class for the node.
|
||||
* @param {string} s The icon class.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setIconClass = function(s) {
|
||||
this.iconClass_ = s;
|
||||
if (this.isInDocument()) {
|
||||
this.updateIcon_();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the icon class for the node.
|
||||
* @return {string} s The icon source.
|
||||
@@ -971,18 +873,6 @@ Blockly.tree.BaseNode.prototype.getIconClass = function() {
|
||||
return this.iconClass_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the icon class for when the node is expanded.
|
||||
* @param {string} s The expanded icon class.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setExpandedIconClass = function(s) {
|
||||
this.expandedIconClass_ = s;
|
||||
if (this.isInDocument()) {
|
||||
this.updateIcon_();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the icon class for when the node is expanded.
|
||||
* @return {string} The class.
|
||||
@@ -1011,28 +901,6 @@ Blockly.tree.BaseNode.prototype.getText = function() {
|
||||
return this.content_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the text of the tooltip.
|
||||
* @param {string} s The tooltip text to set.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setToolTip = function(s) {
|
||||
this.toolTip_ = s;
|
||||
var el = this.getLabelElement();
|
||||
if (el) {
|
||||
el.title = s;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the text of the tooltip.
|
||||
* @return {?string} The tooltip text.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getToolTip = function() {
|
||||
return this.toolTip_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the row styles.
|
||||
* @protected
|
||||
@@ -1096,24 +964,6 @@ Blockly.tree.BaseNode.prototype.onClick_ = function(e) {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles a double click event.
|
||||
* @param {!Event} e The browser event.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.onDoubleClick_ = function(e) {
|
||||
var el = e.target;
|
||||
// expand icon
|
||||
var type = el.getAttribute('type');
|
||||
if (type == 'expand' && this.hasChildren()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isUserCollapsible_) {
|
||||
this.toggle();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles a key down event.
|
||||
* @param {!Event} e The browser event.
|
||||
|
||||
@@ -86,16 +86,6 @@ Blockly.tree.TreeControl.prototype.getDepth = function() {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands the parent chain of this node so that it is visible.
|
||||
* @override
|
||||
*/
|
||||
Blockly.tree.TreeControl.prototype.reveal = function() {
|
||||
// always expanded by default
|
||||
// needs to be overriden so that we don't try to reveal our parent
|
||||
// which is a generic component
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles focus on the tree.
|
||||
* @param {!Event} _e The browser event.
|
||||
@@ -250,38 +240,6 @@ Blockly.tree.TreeControl.prototype.getSelectedItem = function() {
|
||||
return this.selectedItem_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the lines after the tree has been drawn.
|
||||
* @private
|
||||
*/
|
||||
Blockly.tree.TreeControl.prototype.updateLinesAndExpandIcons_ = function() {
|
||||
var tree = this;
|
||||
var showLines = false;
|
||||
var showRootLines = false;
|
||||
|
||||
/**
|
||||
* Recursively walk through all nodes and update the class names of the
|
||||
* expand icon and the children element.
|
||||
* @param {!Blockly.tree.BaseNode} node tree node
|
||||
*/
|
||||
function updateShowLines(node) {
|
||||
var childrenEl = node.getChildrenElement();
|
||||
if (childrenEl) {
|
||||
var hideLines = !showLines || tree == node.getParent() && !showRootLines;
|
||||
var childClass = hideLines ? node.getConfig().cssChildrenNoLines :
|
||||
node.getConfig().cssChildren;
|
||||
childrenEl.className = childClass;
|
||||
|
||||
var expandIconEl = node.getExpandIconElement();
|
||||
if (expandIconEl) {
|
||||
expandIconEl.className = node.getExpandIconClass();
|
||||
}
|
||||
}
|
||||
node.forEachChild(updateShowLines);
|
||||
}
|
||||
updateShowLines(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add roles and states.
|
||||
* @protected
|
||||
|
||||
Reference in New Issue
Block a user