diff options
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 73 |
1 files changed, 36 insertions, 37 deletions
@@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2013-April-19'; +modules.gui = '2013-April-22'; // Declarations @@ -1989,7 +1989,7 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem( shiftClicked ? - 'Export project as plain text ...' : 'Export project...', + 'Export project as plain text...' : 'Export project...', function () { if (myself.projectName) { myself.exportProject(myself.projectName, shiftClicked); @@ -2004,14 +2004,14 @@ IDE_Morph.prototype.projectMenu = function () { ); menu.addItem( - 'Export blocks ...', + 'Export blocks...', function () {myself.exportGlobalBlocks(); }, 'show global custom block definitions as XML\nin a new browser window' ); menu.addLine(); menu.addItem( - 'Import tools...', + 'Import tools', function () { var url = 'http://snap.berkeley.edu/snapsource/tools.xml', @@ -2901,6 +2901,7 @@ IDE_Morph.prototype.userSetBlocksScale = function () { */ sample = new FrameMorph(); + sample.acceptsDrops = false; sample.texture = 'scriptsPaneTexture.gif'; sample.setExtent(new Point(250, 180)); scrpt.setPosition(sample.position().add(10)); @@ -3723,7 +3724,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { myself.ide.cloudError().call(null, err, lbl); } ); - break; + return; case 'local': this.projectList = this.getLocalProjectList(); break; @@ -3731,14 +3732,16 @@ ProjectDialogMorph.prototype.setSource = function (source) { this.projectList = []; break; } - this.listField.destroy(); + this.listField.destroy(); this.listField = new ListMorph( this.projectList, this.projectList.length > 0 ? function (element) { return element.name; - } : null + } : null, + null, + function () {myself.ok(); } ); this.fixListFieldItemColors(); @@ -3754,6 +3757,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { this.listField.action = function (item) { var src, xml; + if (item === undefined) {return; } if (myself.nameField) { myself.nameField.setContents(item.name || ''); } @@ -3775,6 +3779,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { }; } else { // 'examples', 'cloud' is initialized elsewhere this.listField.action = function (item) { + if (item === undefined) {return; } if (myself.nameField) { myself.nameField.setContents(item.name || ''); } @@ -3791,21 +3796,14 @@ ProjectDialogMorph.prototype.setSource = function (source) { } this.body.add(this.listField); - if (this.source === 'cloud') { - this.shareButton.show(); - this.unshareButton.hide(); + this.shareButton.hide(); + this.unshareButton.hide(); + if (this.source === 'local') { this.deleteButton.show(); - } else { - this.shareButton.hide(); - this.unshareButton.hide(); - if (this.source === 'local') { - this.deleteButton.show(); - } else { // examples - this.deleteButton.hide(); - } + } else { // examples + this.deleteButton.hide(); } this.buttons.fixLayout(); - this.fixLayout(); if (this.task === 'open') { this.clearDetails(); @@ -3852,9 +3850,9 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { 'bold', function (proj) {return proj.Public === 'true'; } ] - ] + ], + function () {myself.ok(); } ); - this.fixListFieldItemColors(); this.listField.fixLayout = nop; this.listField.edge = InputFieldMorph.prototype.edge; @@ -3865,6 +3863,7 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { this.listField.drawRectBorder = InputFieldMorph.prototype.drawRectBorder; this.listField.action = function (item) { + if (item === undefined) {return; } if (myself.nameField) { myself.nameField.setContents(item.ProjectName || ''); } @@ -3888,6 +3887,10 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { myself.edit(); }; this.body.add(this.listField); + this.shareButton.show(); + this.unshareButton.hide(); + this.deleteButton.show(); + this.buttons.fixLayout(); this.fixLayout(); if (this.task === 'open') { this.clearDetails(); @@ -3904,36 +3907,32 @@ ProjectDialogMorph.prototype.clearDetails = function () { }; ProjectDialogMorph.prototype.openProject = function () { - var myself = this; - + var myself = this, + proj = this.listField.selected; + if (!proj) {return; } if (this.source === 'cloud') { - if (this.listField.selected) { - this.openSelectedCloudProject(); - } + this.openCloudProject(proj); } else { // 'local, examples' - if (this.listField.selected) { - myself.ide.source = 'local'; - this.ide.openProject(this.listField.selected.name); - this.destroy(); - } + myself.ide.source = 'local'; + this.ide.openProject(proj.name); + this.destroy(); } }; -ProjectDialogMorph.prototype.openSelectedCloudProject = function () { +ProjectDialogMorph.prototype.openCloudProject = function (project) { var myself = this; - this.nextSteps([ + myself.ide.nextSteps([ function () { myself.ide.showMessage('Fetching project\nfrom the cloud...'); }, function () { - myself.rawOpenSelectedCloudProject(); + myself.rawOpenCloudProject(project); } ]); }; -ProjectDialogMorph.prototype.rawOpenSelectedCloudProject = function () { - var myself = this, - proj = this.listField.selected; +ProjectDialogMorph.prototype.rawOpenCloudProject = function (proj) { + var myself = this; SnapCloud.reconnect( function () { SnapCloud.callService( |
