scrollable block lib, fix bug for repeated alert about unsaved changes (#612)

This commit is contained in:
Tina Quach
2016-08-30 13:59:07 -07:00
committed by picklesrus
parent 64d34b3cdc
commit d6e71ffe38
3 changed files with 27 additions and 9 deletions

View File

@@ -161,7 +161,8 @@ BlockLibraryController.prototype.saveToBlockLibrary = function() {
// main workspace.
this.openBlock(blockType);
this.addOptionSelectHandlers();
// Add select handler to the new option.
this.addOptionSelectHandler(blockType);
};
/**
@@ -254,10 +255,13 @@ BlockLibraryController.prototype.setNoneSelected = function() {
};
/**
* Add select handlers to each option to update the view and the selected
* blocks accordingly.
* Add select handler for an option of a given block type. The handler will to
* update the view and the selected block accordingly.
*
* @param {!string} blockType - The type of block represented by the option is
* for.
*/
BlockLibraryController.prototype.addOptionSelectHandlers = function() {
BlockLibraryController.prototype.addOptionSelectHandler = function(blockType) {
var self = this;
// Click handler for a block option. Sets the block option as the selected
@@ -287,12 +291,21 @@ BlockLibraryController.prototype.addOptionSelectHandlers = function() {
};
};
// Assign a click handler to the block option.
var blockOption = this.view.optionMap[blockType];
// Use an additional closure to correctly assign the tab callback.
blockOption.addEventListener(
'click', makeOptionSelectHandler_(blockOption));
};
/**
* Add select handlers to each option to update the view and the selected
* blocks accordingly.
*/
BlockLibraryController.prototype.addOptionSelectHandlers = function() {
// Assign a click handler to each block option.
for (var blockType in this.view.optionMap) {
var blockOption = this.view.optionMap[blockType];
// Use an additional closure to correctly assign the tab callback.
blockOption.addEventListener(
'click', makeOptionSelectHandler_(blockOption));
this.addOptionSelectHandler(blockType);
}
};

View File

@@ -304,6 +304,11 @@ button, .buttonStyle {
/* Block Library */
#dropdownDiv_blockLib {
max-height: 65%;
overflow-y: scroll;
}
#button_blockLib {
border-color: darkgrey;
font-size: large;

View File

@@ -994,7 +994,7 @@ FactoryUtils.warnIfUnsavedChanges = function() {
if (!BlockFactory.isStarterBlock() &&
!FactoryUtils.savedBlockChanges(self.blockLibraryController)) {
return confirm('You have unsaved changes. By proceeding without saving ' +
' your block first, you will lose these changes.');
' your block first, you will lose these changes.');
}
return true;
};