mirror of
https://github.com/google/blockly.git
synced 2026-01-30 20:20:09 +01:00
Remove a bunch of Closure from Block Factory.
This commit is contained in:
@@ -32,7 +32,6 @@ goog.require('FactoryUtils');
|
||||
goog.require('BlockLibraryController');
|
||||
goog.require('BlockExporterController');
|
||||
goog.require('goog.dom.classlist');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.ui.PopupColorPicker');
|
||||
goog.require('goog.ui.ColorPicker');
|
||||
|
||||
@@ -59,11 +58,11 @@ AppController = function() {
|
||||
// Map of tab type to the div element for the tab.
|
||||
this.tabMap = Object.create(null);
|
||||
this.tabMap[AppController.BLOCK_FACTORY] =
|
||||
goog.dom.getElement('blockFactory_tab');
|
||||
document.getElementById('blockFactory_tab');
|
||||
this.tabMap[AppController.WORKSPACE_FACTORY] =
|
||||
goog.dom.getElement('workspaceFactory_tab');
|
||||
document.getElementById('workspaceFactory_tab');
|
||||
this.tabMap[AppController.EXPORTER] =
|
||||
goog.dom.getElement('blocklibraryExporter_tab');
|
||||
document.getElementById('blocklibraryExporter_tab');
|
||||
|
||||
// Last selected tab.
|
||||
this.lastSelectedTab = null;
|
||||
@@ -535,7 +534,7 @@ AppController.prototype.assignBlockFactoryClickHandlers = function() {
|
||||
self.blockLibraryController.setNoneSelected();
|
||||
|
||||
// Close the Block Library Dropdown.
|
||||
goog.dom.getElement('dropdownDiv_blockLib').classList.remove("show");
|
||||
document.getElementById('dropdownDiv_blockLib').classList.remove('show');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ BlockExporterTools = function() {
|
||||
}, ''); // Empty quotes for empty div.
|
||||
// Hide hidden workspace.
|
||||
this.container.style.display = 'none';
|
||||
goog.dom.appendChild(document.body, this.container);
|
||||
document.body.appendChild(this.container);
|
||||
/**
|
||||
* Hidden workspace for the Block Exporter that holds pieces that make
|
||||
* up the block
|
||||
@@ -251,9 +251,12 @@ BlockExporterTools.prototype.createBlockSelectorFromLib =
|
||||
// them in the exporter workspace.
|
||||
this.addBlockDefinitions(blockXmlMap);
|
||||
|
||||
var blockSelector = goog.dom.getElement(blockSelectorID);
|
||||
var blockSelector = document.getElementById(blockSelectorID);
|
||||
// Clear the block selector.
|
||||
goog.dom.removeChildren(blockSelector);
|
||||
var child;
|
||||
while ((child = blockSelector.firstChild)) {
|
||||
blockSelector.removeChild(child);
|
||||
}
|
||||
|
||||
// Append each block option's dom to the selector.
|
||||
var blockOptions = Object.create(null);
|
||||
@@ -266,7 +269,7 @@ BlockExporterTools.prototype.createBlockSelectorFromLib =
|
||||
// option to block selector.
|
||||
var blockOpt = new BlockOption(blockSelector, blockType, previewBlockXml);
|
||||
blockOpt.createDom();
|
||||
goog.dom.appendChild(blockSelector, blockOpt.dom);
|
||||
blockSelector.appendChild(blockOpt.dom);
|
||||
blockOpt.showPreviewBlock();
|
||||
blockOptions[blockType] = blockOpt;
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ BlockExporterView.prototype.setBlockOptions = function(blockOptions) {
|
||||
*/
|
||||
BlockExporterView.prototype.updateHelperText = function(newText, opt_append) {
|
||||
if (opt_append) {
|
||||
goog.dom.getElement('helperText').textContent =
|
||||
goog.dom.getElement('helperText').textContent + newText;
|
||||
document.getElementById('helperText').textContent =
|
||||
document.getElementById('helperText').textContent + newText;
|
||||
} else {
|
||||
goog.dom.getElement('helperText').textContent = newText;
|
||||
document.getElementById('helperText').textContent = newText;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ BlockExporterView.prototype.updateHelperText = function(newText, opt_append) {
|
||||
BlockExporterView.prototype.listSelectedBlocks = function() {
|
||||
|
||||
var selectedBlocksText = this.getSelectedBlockTypes().join(",\n ");
|
||||
goog.dom.getElement('selectedBlocksText').textContent = selectedBlocksText;
|
||||
document.getElementById('selectedBlocksText').textContent = selectedBlocksText;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,13 +41,13 @@ var BlockLibraryView = function() {
|
||||
// Div element to contain the block types to choose from.
|
||||
// Id of the div that holds the block library view.
|
||||
this.blockLibraryViewDivID = 'dropdownDiv_blockLib';
|
||||
this.dropdown = goog.dom.getElement('dropdownDiv_blockLib');
|
||||
this.dropdown = document.getElementById('dropdownDiv_blockLib');
|
||||
// Map of block type to corresponding 'a' element that is the option in the
|
||||
// dropdown. Used to quickly and easily get a specific option.
|
||||
this.optionMap = Object.create(null);
|
||||
// Save and delete buttons.
|
||||
this.saveButton = goog.dom.getElement('saveToBlockLibraryButton');
|
||||
this.deleteButton = goog.dom.getElement('removeBlockFromLibraryButton');
|
||||
this.saveButton = document.getElementById('saveToBlockLibraryButton');
|
||||
this.deleteButton = document.getElementById('removeBlockFromLibraryButton');
|
||||
// Initially, user should not be able to delete a block. They must save a
|
||||
// block or select a stored block first.
|
||||
this.deleteButton.disabled = true;
|
||||
@@ -202,17 +202,15 @@ BlockLibraryView.prototype.getSelectedBlockType = function() {
|
||||
* @return {!Element} HTML 'a' element that is the option for a block type.
|
||||
*/
|
||||
BlockLibraryView.prototype.getSelectedOption = function() {
|
||||
return goog.dom.getElementByClass('dropdown-content-selected', this.dropdown);
|
||||
return this.dropdown.getElementsByClassName('dropdown-content-selected')[0];
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all options from dropdown.
|
||||
*/
|
||||
BlockLibraryView.prototype.clearOptions = function() {
|
||||
var blockOpts = goog.dom.getElementsByClass('blockLibOpt', this.dropdown);
|
||||
if (blockOpts) {
|
||||
for (var i = 0, option; option = blockOpts[i]; i++) {
|
||||
goog.dom.removeNode(option);
|
||||
}
|
||||
var blockOpts = this.dropdown.getElementsByClassName('blockLibOpt');
|
||||
for (var i = 0, option; option = blockOpts[i]; i++) {
|
||||
option.parentNode.removeChild(option);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -81,38 +81,38 @@ BlockOption.prototype.createDom = function() {
|
||||
'id' : this.blockType + '_workspace',
|
||||
'class': 'blockOption_preview'
|
||||
}, '');
|
||||
goog.dom.appendChild(blockOptContainer,blockOptionPreview);
|
||||
blockOptContainer.appendChild(blockOptionPreview);
|
||||
|
||||
// Create and append container to hold checkbox and label.
|
||||
var checkLabelContainer = goog.dom.createDom('div', {
|
||||
'class': 'blockOption_checkLabel'
|
||||
}, '');
|
||||
goog.dom.appendChild(blockOptContainer,checkLabelContainer);
|
||||
blockOptContainer.appendChild(checkLabelContainer);
|
||||
|
||||
// Create and append container for checkbox.
|
||||
var checkContainer = goog.dom.createDom('div', {
|
||||
'class': 'blockOption_check'
|
||||
}, '');
|
||||
goog.dom.appendChild(checkLabelContainer, checkContainer);
|
||||
checkLabelContainer.appendChild(checkContainer);
|
||||
|
||||
// Create and append checkbox.
|
||||
this.checkbox = goog.dom.createDom('input', {
|
||||
'type': 'checkbox',
|
||||
'id': this.blockType + '_check'
|
||||
}, '');
|
||||
goog.dom.appendChild(checkContainer, this.checkbox);
|
||||
checkContainer.appendChild(this.checkbox);
|
||||
|
||||
// Create and append container for block label.
|
||||
var labelContainer = goog.dom.createDom('div', {
|
||||
'class': 'blockOption_label'
|
||||
}, '');
|
||||
goog.dom.appendChild(checkLabelContainer, labelContainer);
|
||||
checkLabelContainer.appendChild(labelContainer);
|
||||
|
||||
// Create and append text node for the label.
|
||||
var labelText = goog.dom.createDom('p', {
|
||||
'id': this.blockType + '_text'
|
||||
}, this.blockType);
|
||||
goog.dom.appendChild(labelContainer, labelText);
|
||||
labelContainer.appendChild(labelText);
|
||||
|
||||
this.dom = blockOptContainer;
|
||||
return this.dom;
|
||||
|
||||
@@ -884,8 +884,8 @@ FactoryUtils.injectCode = function(code, id) {
|
||||
*/
|
||||
FactoryUtils.sameBlockXml = function(blockXml1, blockXml2) {
|
||||
// Each XML element should contain a single child element with a 'block' tag
|
||||
if (goog.string.caseInsensitiveCompare(blockXml1.tagName, 'xml') ||
|
||||
goog.string.caseInsensitiveCompare(blockXml2.tagName, 'xml')) {
|
||||
if (blockXml1.tagName.toLowerCase() == 'xml' ||
|
||||
blockXml2.tagName.toLowerCase() == 'xml') {
|
||||
throw new Error('Expected two XML elements, recieved elements with tag ' +
|
||||
'names: ' + blockXml1.tagName + ' and ' + blockXml2.tagName + '.');
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ WorkspaceFactoryController.prototype.switchElement = function(id) {
|
||||
/**
|
||||
* Switches to a new tab for the element by ID. Helper for switchElement.
|
||||
* Updates selected, clears the workspace and clears undo, loads a new element.
|
||||
* @param {string} id ID of category to load
|
||||
* @param {string} id ID of category to load.
|
||||
*/
|
||||
WorkspaceFactoryController.prototype.clearAndLoadElement = function(id) {
|
||||
// Unselect current tab if switching to and from an element.
|
||||
@@ -1242,7 +1242,7 @@ WorkspaceFactoryController.prototype.setBlockLibCategory =
|
||||
function(categoryXml, libBlockTypes) {
|
||||
var blockLibCategory = document.getElementById('blockLibCategory');
|
||||
|
||||
// Set category id so that it can be easily replaced, and set a standard,
|
||||
// Set category ID so that it can be easily replaced, and set a standard,
|
||||
// arbitrary block library color.
|
||||
categoryXml.setAttribute('id', 'blockLibCategory');
|
||||
categoryXml.setAttribute('colour', 260);
|
||||
|
||||
@@ -121,7 +121,7 @@ WorkspaceFactoryView.prototype.updateState = function(selectedIndex, selected) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines the DOM id for a category given its name.
|
||||
* Determines the DOM ID for a category given its name.
|
||||
* @param {string} name Name of category
|
||||
* @return {string} ID of category tab
|
||||
*/
|
||||
@@ -146,8 +146,8 @@ WorkspaceFactoryView.prototype.setCategoryTabSelection =
|
||||
/**
|
||||
* Used to bind a click to a certain DOM element (used for category tabs).
|
||||
* Taken directly from code.js
|
||||
* @param {string|!Element} e1 tab element or corresponding id string
|
||||
* @param {!Function} func Function to be executed on click
|
||||
* @param {string|!Element} e1 Tab element or corresponding ID string.
|
||||
* @param {!Function} func Function to be executed on click.
|
||||
*/
|
||||
WorkspaceFactoryView.prototype.bindClick = function(el, func) {
|
||||
if (typeof el == 'string') {
|
||||
|
||||
Reference in New Issue
Block a user