diff --git a/core/block.js b/core/block.js index 60dba2745..c3f9f9f3d 100644 --- a/core/block.js +++ b/core/block.js @@ -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}$/)) { diff --git a/core/contextmenu.js b/core/contextmenu.js index 1ec302d05..e2c476937 100644 --- a/core/contextmenu.js +++ b/core/contextmenu.js @@ -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); diff --git a/core/field.js b/core/field.js index 4d6c0a43b..d878ad506 100644 --- a/core/field.js +++ b/core/field.js @@ -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); }; diff --git a/core/utils.js b/core/utils.js index 8d87cdc4d..124ea1a6a 100644 --- a/core/utils.js +++ b/core/utils.js @@ -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; diff --git a/demos/blockfactory/app_controller.js b/demos/blockfactory/app_controller.js index b556b4f8d..baf106ac7 100644 --- a/demos/blockfactory/app_controller.js +++ b/demos/blockfactory/app_controller.js @@ -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; } }; diff --git a/demos/blockfactory/blocks.js b/demos/blockfactory/blocks.js index 856780a52..78e351fcd 100644 --- a/demos/blockfactory/blocks.js +++ b/demos/blockfactory/blocks.js @@ -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() diff --git a/demos/blockfactory/devtools.png b/demos/blockfactory/devtools.png deleted file mode 100644 index b38a8894b..000000000 Binary files a/demos/blockfactory/devtools.png and /dev/null differ diff --git a/demos/blockfactory/icon.png b/demos/blockfactory/icon.png index d4d19b457..2fcb25ed7 100644 Binary files a/demos/blockfactory/icon.png and b/demos/blockfactory/icon.png differ diff --git a/demos/blockfactory/index.html b/demos/blockfactory/index.html index 6dfea2e17..4a4423a82 100644 --- a/demos/blockfactory/index.html +++ b/demos/blockfactory/index.html @@ -1,5 +1,3 @@ - -
@@ -37,11 +35,12 @@ var init = function() { blocklyFactory = new AppController(); blocklyFactory.init(); + window.addEventListener('beforeunload', blocklyFactory.confirmLeavePage); }; window.addEventListener('load', init); - +