kopia lustrzana https://github.com/backface/turtlestitch
Fixed #23
Only one of each kind of dialog can now be open at any given time. You can still open multiple dialogs for editing a costume and editing a block.pull/3/merge
rodzic
977da0314c
commit
cad54f7433
32
byob.js
32
byob.js
|
@ -1026,6 +1026,10 @@ BlockDialogMorph.prototype = new DialogBoxMorph();
|
||||||
BlockDialogMorph.prototype.constructor = BlockDialogMorph;
|
BlockDialogMorph.prototype.constructor = BlockDialogMorph;
|
||||||
BlockDialogMorph.uber = DialogBoxMorph.prototype;
|
BlockDialogMorph.uber = DialogBoxMorph.prototype;
|
||||||
|
|
||||||
|
// BlockDialogMorph constants:
|
||||||
|
|
||||||
|
BlockDialogMorph.prototype.key = 'makeABlock';
|
||||||
|
|
||||||
// BlockDialogMorph instance creation:
|
// BlockDialogMorph instance creation:
|
||||||
|
|
||||||
function BlockDialogMorph(target, action, environment) {
|
function BlockDialogMorph(target, action, environment) {
|
||||||
|
@ -1099,11 +1103,7 @@ BlockDialogMorph.prototype.openForChange = function (
|
||||||
this.scopes = null;
|
this.scopes = null;
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
if (world) {
|
this.popUp(world);
|
||||||
world.add(this);
|
|
||||||
this.setCenter(world.center());
|
|
||||||
this.edit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// category buttons
|
// category buttons
|
||||||
|
@ -1544,8 +1544,7 @@ BlockEditorMorph.prototype.popUp = function () {
|
||||||
var world = this.target.world();
|
var world = this.target.world();
|
||||||
|
|
||||||
if (world) {
|
if (world) {
|
||||||
world.add(this);
|
BlockEditorMorph.uber.popUp.call(this, world);
|
||||||
world.keyboardReceiver = this;
|
|
||||||
this.handle = new HandleMorph(
|
this.handle = new HandleMorph(
|
||||||
this,
|
this,
|
||||||
280,
|
280,
|
||||||
|
@ -1553,7 +1552,6 @@ BlockEditorMorph.prototype.popUp = function () {
|
||||||
this.corner,
|
this.corner,
|
||||||
this.corner
|
this.corner
|
||||||
);
|
);
|
||||||
this.setCenter(world.center());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2424,11 +2422,7 @@ InputSlotDialogMorph.prototype.open = function (
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
if (world) {
|
this.popUp(world);
|
||||||
world.add(this);
|
|
||||||
this.setCenter(world.center());
|
|
||||||
this.edit();
|
|
||||||
}
|
|
||||||
this.add(this.types); // make the types come to front
|
this.add(this.types); // make the types come to front
|
||||||
Morph.prototype.trackChanges = oldFlag;
|
Morph.prototype.trackChanges = oldFlag;
|
||||||
this.changed();
|
this.changed();
|
||||||
|
@ -2846,6 +2840,10 @@ BlockExportDialogMorph.prototype = new DialogBoxMorph();
|
||||||
BlockExportDialogMorph.prototype.constructor = BlockExportDialogMorph;
|
BlockExportDialogMorph.prototype.constructor = BlockExportDialogMorph;
|
||||||
BlockExportDialogMorph.uber = DialogBoxMorph.prototype;
|
BlockExportDialogMorph.uber = DialogBoxMorph.prototype;
|
||||||
|
|
||||||
|
// BlockExportDialogMorph constants:
|
||||||
|
|
||||||
|
BlockExportDialogMorph.prototype.key = 'blockExport';
|
||||||
|
|
||||||
// BlockExportDialogMorph instance creation:
|
// BlockExportDialogMorph instance creation:
|
||||||
|
|
||||||
function BlockExportDialogMorph(serializer, blocks) {
|
function BlockExportDialogMorph(serializer, blocks) {
|
||||||
|
@ -2952,8 +2950,7 @@ BlockExportDialogMorph.prototype.buildContents = function () {
|
||||||
BlockExportDialogMorph.prototype.popUp = function (wrrld) {
|
BlockExportDialogMorph.prototype.popUp = function (wrrld) {
|
||||||
var world = wrrld || this.target.world();
|
var world = wrrld || this.target.world();
|
||||||
if (world) {
|
if (world) {
|
||||||
world.add(this);
|
BlockExportDialogMorph.uber.popUp.call(this, world);
|
||||||
world.keyboardReceiver = this;
|
|
||||||
this.handle = new HandleMorph(
|
this.handle = new HandleMorph(
|
||||||
this,
|
this,
|
||||||
200,
|
200,
|
||||||
|
@ -2961,7 +2958,6 @@ BlockExportDialogMorph.prototype.popUp = function (wrrld) {
|
||||||
this.corner,
|
this.corner,
|
||||||
this.corner
|
this.corner
|
||||||
);
|
);
|
||||||
this.setCenter(world.center());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3024,6 +3020,10 @@ BlockImportDialogMorph.prototype = new DialogBoxMorph();
|
||||||
BlockImportDialogMorph.prototype.constructor = BlockImportDialogMorph;
|
BlockImportDialogMorph.prototype.constructor = BlockImportDialogMorph;
|
||||||
BlockImportDialogMorph.uber = DialogBoxMorph.prototype;
|
BlockImportDialogMorph.uber = DialogBoxMorph.prototype;
|
||||||
|
|
||||||
|
// BlockImportDialogMorph constants:
|
||||||
|
|
||||||
|
BlockImportDialogMorph.prototype.key = 'blockImport';
|
||||||
|
|
||||||
// BlockImportDialogMorph instance creation:
|
// BlockImportDialogMorph instance creation:
|
||||||
|
|
||||||
function BlockImportDialogMorph(blocks, target, name) {
|
function BlockImportDialogMorph(blocks, target, name) {
|
||||||
|
|
43
gui.js
43
gui.js
|
@ -1679,7 +1679,7 @@ IDE_Morph.prototype.cloudMenu = function () {
|
||||||
} else {
|
} else {
|
||||||
myself.prompt('Export Project As...', function (name) {
|
myself.prompt('Export Project As...', function (name) {
|
||||||
myself.exportProjectMedia(name);
|
myself.exportProjectMedia(name);
|
||||||
});
|
}, 'exportProject');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
|
@ -1693,7 +1693,7 @@ IDE_Morph.prototype.cloudMenu = function () {
|
||||||
} else {
|
} else {
|
||||||
myself.prompt('Export Project As...', function (name) {
|
myself.prompt('Export Project As...', function (name) {
|
||||||
myself.exportProjectNoMedia(name);
|
myself.exportProjectNoMedia(name);
|
||||||
});
|
}, 'exportProject');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
|
@ -1707,7 +1707,7 @@ IDE_Morph.prototype.cloudMenu = function () {
|
||||||
} else {
|
} else {
|
||||||
myself.prompt('Export Project As...', function (name) {
|
myself.prompt('Export Project As...', function (name) {
|
||||||
myself.exportProjectAsCloudData(name);
|
myself.exportProjectAsCloudData(name);
|
||||||
});
|
}, 'exportProject');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
|
@ -1754,8 +1754,8 @@ IDE_Morph.prototype.cloudMenu = function () {
|
||||||
myself.cloudError()
|
myself.cloudError()
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
}, 'project');
|
||||||
});
|
}, 'project');
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
new Color(100, 0, 0)
|
new Color(100, 0, 0)
|
||||||
|
@ -1996,7 +1996,7 @@ IDE_Morph.prototype.projectMenu = function () {
|
||||||
} else {
|
} else {
|
||||||
myself.prompt('Export Project As...', function (name) {
|
myself.prompt('Export Project As...', function (name) {
|
||||||
myself.exportProject(name);
|
myself.exportProject(name);
|
||||||
});
|
}, 'exportProject');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'show project data as XML\nin a new browser window',
|
'show project data as XML\nin a new browser window',
|
||||||
|
@ -2181,7 +2181,7 @@ IDE_Morph.prototype.aboutSnap = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.editProjectNotes = function () {
|
IDE_Morph.prototype.editProjectNotes = function () {
|
||||||
var dialog = new DialogBoxMorph(),
|
var dialog = new DialogBoxMorph().withKey('projectNotes'),
|
||||||
frame = new ScrollFrameMorph(),
|
frame = new ScrollFrameMorph(),
|
||||||
text = new TextMorph(this.projectNotes || ''),
|
text = new TextMorph(this.projectNotes || ''),
|
||||||
ok = dialog.ok,
|
ok = dialog.ok,
|
||||||
|
@ -2228,7 +2228,7 @@ IDE_Morph.prototype.editProjectNotes = function () {
|
||||||
dialog.addButton('cancel', 'Cancel');
|
dialog.addButton('cancel', 'Cancel');
|
||||||
dialog.fixLayout();
|
dialog.fixLayout();
|
||||||
dialog.drawNew();
|
dialog.drawNew();
|
||||||
world.add(dialog);
|
dialog.popUp(world);
|
||||||
dialog.setCenter(world.center());
|
dialog.setCenter(world.center());
|
||||||
text.edit();
|
text.edit();
|
||||||
};
|
};
|
||||||
|
@ -2934,7 +2934,7 @@ IDE_Morph.prototype.userSetBlocksScale = function () {
|
||||||
function (num) {
|
function (num) {
|
||||||
myself.setBlocksScale(num);
|
myself.setBlocksScale(num);
|
||||||
}
|
}
|
||||||
).prompt(
|
).withKey('zoomBlocks').prompt(
|
||||||
'Zoom blocks',
|
'Zoom blocks',
|
||||||
SyntaxElementMorph.prototype.scale.toString(),
|
SyntaxElementMorph.prototype.scale.toString(),
|
||||||
this.world(),
|
this.world(),
|
||||||
|
@ -3006,7 +3006,7 @@ IDE_Morph.prototype.initializeCloud = function () {
|
||||||
myself.cloudError()
|
myself.cloudError()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
).promptCredentials(
|
).withKey('cloud').promptCredentials(
|
||||||
'Sign in',
|
'Sign in',
|
||||||
'login',
|
'login',
|
||||||
null,
|
null,
|
||||||
|
@ -3047,7 +3047,7 @@ IDE_Morph.prototype.createCloudAccount = function () {
|
||||||
myself.cloudError()
|
myself.cloudError()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
).promptCredentials(
|
).withKey('cloud').promptCredentials(
|
||||||
'Sign up',
|
'Sign up',
|
||||||
'signup',
|
'signup',
|
||||||
'http://snap.berkeley.edu/tos.html',
|
'http://snap.berkeley.edu/tos.html',
|
||||||
|
@ -3077,7 +3077,7 @@ IDE_Morph.prototype.changeCloudPassword = function () {
|
||||||
myself.cloudError()
|
myself.cloudError()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
).promptCredentials(
|
).withKey('cloud').promptCredentials(
|
||||||
'Change Password',
|
'Change Password',
|
||||||
'changePassword',
|
'changePassword',
|
||||||
null,
|
null,
|
||||||
|
@ -3334,7 +3334,7 @@ IDE_Morph.prototype.setCloudURL = function () {
|
||||||
function (url) {
|
function (url) {
|
||||||
SnapCloud.url = url;
|
SnapCloud.url = url;
|
||||||
}
|
}
|
||||||
).prompt(
|
).withKey('cloudURL').prompt(
|
||||||
'Cloud URL',
|
'Cloud URL',
|
||||||
SnapCloud.url,
|
SnapCloud.url,
|
||||||
this.world(),
|
this.world(),
|
||||||
|
@ -3384,8 +3384,8 @@ IDE_Morph.prototype.confirm = function (message, title, action) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.prompt = function (message, callback, choices) {
|
IDE_Morph.prototype.prompt = function (message, callback, choices, key) {
|
||||||
(new DialogBoxMorph(null, callback)).prompt(
|
(new DialogBoxMorph(null, callback)).withKey(key).prompt(
|
||||||
message,
|
message,
|
||||||
'',
|
'',
|
||||||
this.world(),
|
this.world(),
|
||||||
|
@ -3402,6 +3402,10 @@ ProjectDialogMorph.prototype = new DialogBoxMorph();
|
||||||
ProjectDialogMorph.prototype.constructor = ProjectDialogMorph;
|
ProjectDialogMorph.prototype.constructor = ProjectDialogMorph;
|
||||||
ProjectDialogMorph.uber = DialogBoxMorph.prototype;
|
ProjectDialogMorph.uber = DialogBoxMorph.prototype;
|
||||||
|
|
||||||
|
// ProjectDialogMorph constants:
|
||||||
|
|
||||||
|
ProjectDialogMorph.prototype.key = 'project';
|
||||||
|
|
||||||
// ProjectDialogMorph instance creation:
|
// ProjectDialogMorph instance creation:
|
||||||
|
|
||||||
function ProjectDialogMorph(ide, label) {
|
function ProjectDialogMorph(ide, label) {
|
||||||
|
@ -3584,8 +3588,7 @@ ProjectDialogMorph.prototype.buildContents = function () {
|
||||||
ProjectDialogMorph.prototype.popUp = function (wrrld) {
|
ProjectDialogMorph.prototype.popUp = function (wrrld) {
|
||||||
var world = wrrld || this.ide.world();
|
var world = wrrld || this.ide.world();
|
||||||
if (world) {
|
if (world) {
|
||||||
world.add(this);
|
ProjectDialogMorph.uber.popUp.call(this, world);
|
||||||
world.keyboardReceiver = this;
|
|
||||||
this.handle = new HandleMorph(
|
this.handle = new HandleMorph(
|
||||||
this,
|
this,
|
||||||
350,
|
350,
|
||||||
|
@ -3593,8 +3596,6 @@ ProjectDialogMorph.prototype.popUp = function (wrrld) {
|
||||||
this.corner,
|
this.corner,
|
||||||
this.corner
|
this.corner
|
||||||
);
|
);
|
||||||
this.setCenter(world.center());
|
|
||||||
this.edit();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4689,7 +4690,7 @@ CostumeIconMorph.prototype.editCostume = function () {
|
||||||
CostumeIconMorph.prototype.renameCostume = function () {
|
CostumeIconMorph.prototype.renameCostume = function () {
|
||||||
var costume = this.object,
|
var costume = this.object,
|
||||||
ide = this.parentThatIsA(IDE_Morph);
|
ide = this.parentThatIsA(IDE_Morph);
|
||||||
(new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (answer) {
|
function (answer) {
|
||||||
if (answer && (answer !== costume.name)) {
|
if (answer && (answer !== costume.name)) {
|
||||||
|
@ -4698,7 +4699,7 @@ CostumeIconMorph.prototype.renameCostume = function () {
|
||||||
ide.hasChangedMedia = true;
|
ide.hasChangedMedia = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)).prompt(
|
).prompt(
|
||||||
'rename costume',
|
'rename costume',
|
||||||
costume.name,
|
costume.name,
|
||||||
this.world()
|
this.world()
|
||||||
|
|
|
@ -4476,11 +4476,7 @@ Costume.prototype.edit = function (aWorld) {
|
||||||
dialog.fixLayout();
|
dialog.fixLayout();
|
||||||
dialog.drawNew();
|
dialog.drawNew();
|
||||||
dialog.fixLayout();
|
dialog.fixLayout();
|
||||||
if (aWorld) {
|
dialog.popUp(aWorld);
|
||||||
aWorld.add(dialog);
|
|
||||||
aWorld.keyboardReceiver = dialog;
|
|
||||||
dialog.setCenter(aWorld.center());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Costume thumbnail
|
// Costume thumbnail
|
||||||
|
|
68
widgets.js
68
widgets.js
|
@ -1475,6 +1475,11 @@ DialogBoxMorph.prototype.inform = function (
|
||||||
new Point(1, 1),
|
new Point(1, 1),
|
||||||
new Color(255, 255, 255)
|
new Color(255, 255, 255)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!this.key) {
|
||||||
|
this.key = 'information';
|
||||||
|
}
|
||||||
|
|
||||||
this.labelString = title;
|
this.labelString = title;
|
||||||
this.createLabel();
|
this.createLabel();
|
||||||
if (pic) {this.setPicture(pic); }
|
if (pic) {this.setPicture(pic); }
|
||||||
|
@ -1484,11 +1489,7 @@ DialogBoxMorph.prototype.inform = function (
|
||||||
this.addButton('ok', 'OK');
|
this.addButton('ok', 'OK');
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
if (world) {
|
this.popUp(world);
|
||||||
world.add(this);
|
|
||||||
world.keyboardReceiver = this;
|
|
||||||
this.setCenter(world.center());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.askYesNo = function (
|
DialogBoxMorph.prototype.askYesNo = function (
|
||||||
|
@ -1509,6 +1510,11 @@ DialogBoxMorph.prototype.askYesNo = function (
|
||||||
new Point(1, 1),
|
new Point(1, 1),
|
||||||
new Color(255, 255, 255)
|
new Color(255, 255, 255)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!this.key) {
|
||||||
|
this.key = 'prompt';
|
||||||
|
}
|
||||||
|
|
||||||
this.labelString = title;
|
this.labelString = title;
|
||||||
this.createLabel();
|
this.createLabel();
|
||||||
if (pic) {this.setPicture(pic); }
|
if (pic) {this.setPicture(pic); }
|
||||||
|
@ -1518,11 +1524,7 @@ DialogBoxMorph.prototype.askYesNo = function (
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
if (world) {
|
this.popUp(world);
|
||||||
world.add(this);
|
|
||||||
world.keyboardReceiver = this;
|
|
||||||
this.setCenter(world.center());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.prompt = function (
|
DialogBoxMorph.prototype.prompt = function (
|
||||||
|
@ -1612,6 +1614,10 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
this.labelString = title;
|
this.labelString = title;
|
||||||
this.createLabel();
|
this.createLabel();
|
||||||
|
|
||||||
|
if (!this.key) {
|
||||||
|
this.key = 'prompt';
|
||||||
|
}
|
||||||
|
|
||||||
this.addBody(txt);
|
this.addBody(txt);
|
||||||
txt.drawNew();
|
txt.drawNew();
|
||||||
this.addButton('ok', 'OK');
|
this.addButton('ok', 'OK');
|
||||||
|
@ -1619,11 +1625,7 @@ DialogBoxMorph.prototype.prompt = function (
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
if (world) {
|
this.popUp(world);
|
||||||
world.add(this);
|
|
||||||
this.setCenter(world.center());
|
|
||||||
this.edit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.promptCredentials = function (
|
DialogBoxMorph.prototype.promptCredentials = function (
|
||||||
|
@ -1980,11 +1982,11 @@ DialogBoxMorph.prototype.promptCredentials = function (
|
||||||
|
|
||||||
this.reactToChoice(); // initialize e-mail label
|
this.reactToChoice(); // initialize e-mail label
|
||||||
|
|
||||||
if (world) {
|
if (!this.key) {
|
||||||
world.add(this);
|
this.key = 'prompt';
|
||||||
this.setCenter(world.center());
|
|
||||||
this.edit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.popUp(world);
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.accept = function () {
|
DialogBoxMorph.prototype.accept = function () {
|
||||||
|
@ -2024,6 +2026,34 @@ DialogBoxMorph.prototype.accept = function () {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DialogBoxMorph.prototype.withKey = function (key) {
|
||||||
|
this.key = key;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
DialogBoxMorph.prototype.popUp = function (world) {
|
||||||
|
if (world) {
|
||||||
|
if (this.key) {
|
||||||
|
if ((world.dialogs || (world.dialogs = {}))[this.key]) {
|
||||||
|
world.dialogs[this.key].destroy();
|
||||||
|
}
|
||||||
|
world.dialogs[this.key] = this;
|
||||||
|
}
|
||||||
|
this.popUpWorld = world;
|
||||||
|
world.add(this);
|
||||||
|
world.keyboardReceiver = this;
|
||||||
|
this.setCenter(world.center());
|
||||||
|
this.edit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DialogBoxMorph.prototype.destroy = function () {
|
||||||
|
DialogBoxMorph.uber.destroy.call(this);
|
||||||
|
if (this.key && this.popUpWorld && this.popUpWorld.dialogs) {
|
||||||
|
this.popUpWorld.dialogs[this.key] = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
DialogBoxMorph.prototype.ok = function () {
|
DialogBoxMorph.prototype.ok = function () {
|
||||||
this.accept();
|
this.accept();
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue