diff options
| author | Nathan Dinsmore <queryselector@gmail.com> | 2013-04-09 17:15:24 -0400 |
|---|---|---|
| committer | Nathan Dinsmore <queryselector@gmail.com> | 2013-04-09 17:15:24 -0400 |
| commit | ceeb41c0de5f6853a71011c34f1cf3a11a3583f0 (patch) | |
| tree | 75301091928dae10599dea1a3d3f9c78bec836f3 /gui.js | |
| parent | 6f053fe214ce1f32530b708fd48f778d71244542 (diff) | |
| parent | 74ad2abc66cd2652048de4b7906b1f9f015540e7 (diff) | |
| download | snap-byow-ceeb41c0de5f6853a71011c34f1cf3a11a3583f0.tar.gz snap-byow-ceeb41c0de5f6853a71011c34f1cf3a11a3583f0.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 87 |
1 files changed, 81 insertions, 6 deletions
@@ -143,6 +143,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.stageRatio = 1; // for IDE animations, e.g. when zooming this.loadNewProject = false; // flag when starting up translated + this.shield = null; // initialize inherited properties: IDE_Morph.uber.init.call(this); @@ -248,6 +249,11 @@ IDE_Morph.prototype.openIn = function (world) { this.toggleAppMode(true); this.runScripts(); } else if (location.hash.substr(0, 9) === '#present:') { + this.shield = new Morph(); + this.shield.color = this.color; + this.shield.setExtent(this.parent.extent()); + this.parent.add(this.shield); + myself.showMessage('Fetching project\nfrom the cloud...'); SnapCloud.getPublicProject( location.hash.substr(9), @@ -261,6 +267,8 @@ IDE_Morph.prototype.openIn = function (world) { myself.rawOpenCloudDataString(projectData); }, function () { + myself.shield.destroy(); + myself.shield = null; msg.destroy(); myself.toggleAppMode(true); myself.runScripts(); @@ -1686,7 +1694,6 @@ IDE_Morph.prototype.cloudMenu = function () { null, new Color(100, 0, 0) ); - menu.addLine(); menu.addItem( 'export project as cloud data...', function () { @@ -1701,6 +1708,53 @@ IDE_Morph.prototype.cloudMenu = function () { null, new Color(100, 0, 0) ); + menu.addLine(); + menu.addItem( + 'open shared project from cloud...', + function () { + myself.prompt('Author nameā¦', function (usr) { + myself.prompt('Project name...', function (prj) { + var id = 'Username=' + + encodeURIComponent(usr) + + '&ProjectName=' + + encodeURIComponent(prj); + myself.showMessage( + 'Fetching project\nfrom the cloud...' + ); + SnapCloud.getPublicProject( + id, + function (projectData) { + var msg; + if (!Process.prototype.isCatchingErrors) { + window.open( + 'data:text/xml,' + projectData + ); + } + myself.nextSteps([ + function () { + msg = myself.showMessage( + 'Opening project...' + ); + }, + function () { + myself.rawOpenCloudDataString( + projectData + ); + }, + function () { + msg.destroy(); + } + ]); + }, + myself.cloudError() + ); + + }); + }); + }, + null, + new Color(100, 0, 0) + ); } menu.popup(world, pos); }; @@ -3235,6 +3289,10 @@ IDE_Morph.prototype.cloudError = function () { // if none is found, show an error dialog box var response = responseText, explanation = getURL('http://snap.berkeley.edu/cloudmsg.txt'); + if (myself.shield) { + myself.shield.destroy(); + myself.shield = null; + } if (explanation) { myself.showMessage(explanation); return; @@ -3785,7 +3843,13 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { this.projectList.length > 0 ? function (element) { return element.ProjectName; - } : null + } : null, + [ // format: display shared project names bold + [ + 'bold', + function (proj) {return proj.Public === 'true'; } + ] + ] ); this.fixListFieldItemColors(); @@ -4012,7 +4076,8 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, - proj = this.listField.selected; + proj = this.listField.selected, + entry = this.listField.active; if (proj) { this.ide.confirm( @@ -4021,6 +4086,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ) + '\n"' + proj.ProjectName + '"?', 'Share Project', function () { + myself.ide.showMessage('sharing\nproject...'); SnapCloud.reconnect( function () { SnapCloud.callService( @@ -4028,7 +4094,10 @@ ProjectDialogMorph.prototype.shareProject = function () { function () { SnapCloud.disconnect(); proj.Public = 'true'; - myself.listField.select(proj); + entry.label.isBold = true; + entry.label.drawNew(); + entry.label.changed(); + myself.listField.select(proj, entry); myself.ide.showMessage('shared.', 2); }, myself.ide.cloudError(), @@ -4044,7 +4113,9 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, - proj = this.listField.selected; + proj = this.listField.selected, + entry = this.listField.active; + if (proj) { this.ide.confirm( @@ -4053,6 +4124,7 @@ ProjectDialogMorph.prototype.unshareProject = function () { ) + '\n"' + proj.ProjectName + '"?', 'Unshare Project', function () { + myself.ide.showMessage('unsharing\nproject...'); SnapCloud.reconnect( function () { SnapCloud.callService( @@ -4060,7 +4132,10 @@ ProjectDialogMorph.prototype.unshareProject = function () { function () { SnapCloud.disconnect(); proj.Public = 'false'; - myself.listField.select(proj); + entry.label.isBold = false; + entry.label.drawNew(); + entry.label.changed(); + myself.listField.select(proj, entry); myself.ide.showMessage('unshared.', 2); }, myself.ide.cloudError(), |
