Remove remaing code for opening exports in a new window

upd4.1
Michael Ball 2017-08-26 18:05:37 -07:00
rodzic d4c3709d4a
commit e8c0385719
4 zmienionych plików z 12 dodań i 55 usunięć

Wyświetl plik

@ -65,7 +65,7 @@
BoxMorph*
CommentMorph
ScriptFocusMorph
* from morphic.js
@ -1972,8 +1972,7 @@ SyntaxElementMorph.prototype.exportPictureWithResult = function (aBubble) {
// request to open pic in new window.
ide.saveCanvasAs(
pic,
ide.projetName || localize('Untitled') + ' ' + localize('script pic'),
false
ide.projetName || localize('Untitled') + ' ' + localize('script pic')
);
};
@ -2552,8 +2551,7 @@ BlockMorph.prototype.userMenu = function () {
ide.saveCanvasAs(
myself.topBlock().scriptPic(),
ide.projetName || localize('Untitled') + ' ' +
localize('script pic'),
false // request new window
localize('script pic')
);
},
'open a new window\nwith a picture of this script'
@ -3315,7 +3313,7 @@ BlockMorph.prototype.doRefactorSpriteVar = function (
newName,
justTheTemplate
) {
var receiver = this.scriptTarget(),
var receiver = this.scriptTarget(),
ide = receiver.parentThatIsA(IDE_Morph),
oldWatcher = receiver.findVariableWatcher(oldName),
oldValue, newWatcher;
@ -3364,7 +3362,7 @@ BlockMorph.prototype.doRefactorGlobalVar = function (
newName,
justTheTemplate
) {
var receiver = this.scriptTarget(),
var receiver = this.scriptTarget(),
ide = receiver.parentThatIsA(IDE_Morph),
stage = ide ? ide.stage : null,
oldWatcher = receiver.findVariableWatcher(oldName),
@ -6307,8 +6305,7 @@ ScriptsMorph.prototype.exportScriptsPicture = function () {
ide.saveCanvasAs(
pic,
ide.projetName || localize('Untitled') + ' ' +
localize('script pic'),
false // request new window
localize('script pic')
);
}
};
@ -11656,8 +11653,7 @@ CommentMorph.prototype.userMenu = function () {
ide.saveCanvasAs(
myself.fullImageClassic(),
ide.projetName || localize('Untitled') + ' ' +
localize('comment pic'),
false // request new window
localize('comment pic')
);
},
'open a new window\nwith a picture of this comment'

Wyświetl plik

@ -931,8 +931,7 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
ide.saveCanvasAs(
this.topBlock().scriptPic(),
ide.projectName || localize('Untitled') + ' ' +
localize('script pic'),
true // request opening a new window
localize('script pic')
);
},
'open a new window\nwith a picture of this script'

43
gui.js
Wyświetl plik

@ -4129,15 +4129,11 @@ IDE_Morph.prototype.setURL = function (str) {
IDE_Morph.prototype.saveFileAs = function (
contents,
fileType,
fileName,
newWindow // (optional) defaults to false.
fileName
) {
/** Allow for downloading a file to a disk or open in a new tab.
/** Allow for downloading a file to a disk.
This relies the FileSaver.js library which exports saveAs()
Two utility methods saveImageAs and saveXMLAs should be used first.
1. Opening a new window uses standard URI encoding.
2. downloading a file uses Blobs.
- every other combo is unsupposed.
*/
var blobIsSupported = false,
world = this.world(),
@ -4149,13 +4145,6 @@ IDE_Morph.prototype.saveFileAs = function (
// handle text/plain as a .txt file
fileExt = '.' + (fileExt === 'plain' ? 'txt' : fileExt);
// This is a workaround for a known Chrome crash with large URLs
function exhibitsChomeBug(contents) {
var MAX_LENGTH = 2e6,
isChrome = navigator.userAgent.indexOf('Chrome') !== -1;
return isChrome && contents.length > MAX_LENGTH;
}
function dataURItoBlob(text, mimeType) {
var i,
data = text,
@ -4173,37 +4162,11 @@ IDE_Morph.prototype.saveFileAs = function (
return new Blob([data], {type: mimeType });
}
function dataURLFormat(text) {
var hasTypeStr = text.indexOf('data:') === 0;
if (hasTypeStr) {return text; }
return 'data:' + fileType + ',' + encodeURIComponent(text);
}
try {
blobIsSupported = !!new Blob();
} catch (e) {}
if (newWindow) {
// Blob URIs need a custom URL to be displayed in a new window
if (contents instanceof Blob) {
dataURI = URL.createObjectURL(contents);
} else {
dataURI = dataURLFormat(contents);
}
// Detect crashing errors - fallback to downloading if necessary
if (!exhibitsChomeBug(dataURI)) {
window.open(dataURI, fileName);
// Blob URIs should be "cleaned up" to reduce memory.
if (contents instanceof Blob) {
URL.revokeObjectURL(dataURI);
}
} else {
// (recursively) call this defauling newWindow to false
this.showMessage('download to disk text');
this.saveFileAs(contents, fileType, fileName);
}
} else if (blobIsSupported) {
if (blobIsSupported) {
if (!(contents instanceof Blob)) {
contents = dataURItoBlob(contents, fileType);
}

Wyświetl plik

@ -7235,8 +7235,7 @@ StageMorph.prototype.userMenu = function () {
function () {
ide.saveCanvasAs(
myself.fullImageClassic(),
myself.name,
true // open as new window
myself.name
);
},
'open a new window\nwith a picture of the stage'