Misc cleanup.

This commit is contained in:
Neil Fraser
2016-11-05 00:15:39 -07:00
parent 917b8ff542
commit 5b033e2f7b
10 changed files with 21 additions and 19 deletions

View File

@@ -631,7 +631,7 @@ Blockly.Block.prototype.getColour = function() {
* @param {number|string} colour HSV hue value, or #RRGGBB string.
*/
Blockly.Block.prototype.setColour = function(colour) {
var hue = parseFloat(colour);
var hue = Number(colour);
if (!isNaN(hue)) {
this.colour_ = Blockly.hueToRgb(hue);
} else if (goog.isString(colour) && colour.match(/^#[0-9a-fA-F]{6}$/)) {

View File

@@ -82,7 +82,8 @@ Blockly.ContextMenu.show = function(e, options, rtl) {
var menuDom = menu.getElement();
Blockly.addClass_(menuDom, 'blocklyContextMenu');
// Prevent system context menu when right-clicking a Blockly context menu.
Blockly.bindEventWithChecks_(menuDom, 'contextmenu', null, Blockly.noEvent);
Blockly.bindEventWithChecks_(menuDom, 'contextmenu', null,
Blockly.utils.noEvent);
// Record menuSize after adding menu.
var menuSize = goog.style.getSize(menuDom);

View File

@@ -45,7 +45,7 @@ goog.require('goog.userAgent');
* @constructor
*/
Blockly.Field = function(text, opt_validator) {
this.size_ = new goog.math.Size(0, 25);
this.size_ = new goog.math.Size(0, Blockly.BlockSvg.MIN_BLOCK_Y);
this.setValue(text);
this.setValidator(opt_validator);
};

View File

@@ -219,7 +219,7 @@ Blockly.unbindEvent_ = function(bindData) {
* Don't do anything for this event, just halt propagation.
* @param {!Event} e An event.
*/
Blockly.noEvent = function(e) {
Blockly.utils.noEvent = function(e) {
// This event has been handled. No need to bubble up to the document.
e.preventDefault();
e.stopPropagation();
@@ -561,7 +561,7 @@ Blockly.genUid.soup_ = '!#$%()*+,-./:;=?@[]^_`{|}~' +
Blockly.utils.wrap = function(text, limit) {
var lines = text.split('\n');
for (var i = 0; i < lines.length; i++) {
lines[i] = Blockly.utils.wrap_line_(lines[i], limit);
lines[i] = Blockly.utils.wrapLine_(lines[i], limit);
}
return lines.join('\n');
};
@@ -573,7 +573,7 @@ Blockly.utils.wrap = function(text, limit) {
* @return {string} Wrapped text.
* @private
*/
Blockly.utils.wrap_line_ = function(text, limit) {
Blockly.utils.wrapLine_ = function(text, limit) {
if (text.length <= limit) {
// Short text, no need to wrap.
return text;

View File

@@ -616,18 +616,20 @@ AppController.prototype.onresize = function(event) {
};
/**
* Handler for the window's 'onbeforeunload' event. When a user has unsaved
* Handler for the window's 'beforeunload' event. When a user has unsaved
* changes and refreshes or leaves the page, confirm that they want to do so
* before actually refreshing.
* @param {!Event} e beforeunload event.
*/
AppController.prototype.confirmLeavePage = function() {
AppController.prototype.confirmLeavePage = function(e) {
if ((!BlockFactory.isStarterBlock() &&
!FactoryUtils.savedBlockChanges(this.blockLibraryController)) ||
this.workspaceFactoryController.hasUnsavedChanges()) {
// When a string is assigned to the returnValue Event property, a dialog box
// appears, asking the users for confirmation to leave the page.
return 'You will lose any unsaved changes. Are you sure you want ' +
'to exit this page?';
!FactoryUtils.savedBlockChanges(blocklyFactory.blockLibraryController)) ||
blocklyFactory.workspaceFactoryController.hasUnsavedChanges()) {
var confirmationMessage = 'You will lose any unsaved changes. ' +
'Are you sure you want to exit this page?';
e.returnValue = confirmationMessage;
return confirmationMessage;
}
};

View File

@@ -47,7 +47,7 @@ Blockly.Blocks['factory_base'] = {
['↓ bottom connection', 'BOTTOM']],
function(option) {
this.sourceBlock_.updateShape_(option);
// Connect a shadow block to this new input.
// Connect a shadow block to this new input.
this.sourceBlock_.spawnOutputShadow_(option);
});
this.appendDummyInput()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,5 +1,3 @@
<!-- TODO(quachtina96): move the CSS out to a separate file -->
<!DOCTYPE html>
<html>
<head>
@@ -37,11 +35,12 @@
var init = function() {
blocklyFactory = new AppController();
blocklyFactory.init();
window.addEventListener('beforeunload', blocklyFactory.confirmLeavePage);
};
window.addEventListener('load', init);
</script>
</head>
<body onbeforeunload="return blocklyFactory.confirmLeavePage()">
<body>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Blockly Developer Tools
<button id="helpButton" title="View documentation in new window.">

View File

@@ -199,7 +199,7 @@
<tr>
<td>
<a href="blockfactory/index.html">
<img src="blockfactory/devtools.png" height=96 width=184>
<img src="blockfactory/icon.png" height=80 width=173>
</a>
</td>
<td>