|
@@ -656,31 +656,6 @@ if (urlParams['embed'] != '1')
|
|
App.prototype.init = function()
|
|
App.prototype.init = function()
|
|
{
|
|
{
|
|
EditorUi.prototype.init.apply(this, arguments);
|
|
EditorUi.prototype.init.apply(this, arguments);
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Overrides export dialog for using cloud storage save.
|
|
|
|
- */
|
|
|
|
- if (this.isLocalFileSave())
|
|
|
|
- {
|
|
|
|
- var ui = this;
|
|
|
|
-
|
|
|
|
- ExportDialog.saveLocalFile = function(data, filename, format)
|
|
|
|
- {
|
|
|
|
- var mime = 'text/xml';
|
|
|
|
-
|
|
|
|
- if (format === 'svg')
|
|
|
|
- {
|
|
|
|
- mime = 'image/svg+xml';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ui.saveLocalFile(data, filename, mime);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ExportDialog.saveRequest = function(data, filename, format, fn)
|
|
|
|
- {
|
|
|
|
- ui.saveRequest(data, filename, format, fn);
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Specifies the default filename.
|
|
* Specifies the default filename.
|
|
@@ -2909,21 +2884,16 @@ App.prototype.createFile = function(title, data, libs, mode, done, replace, fold
|
|
|
|
|
|
if (title != null && this.spinner.spin(document.body, mxResources.get('inserting')))
|
|
if (title != null && this.spinner.spin(document.body, mxResources.get('inserting')))
|
|
{
|
|
{
|
|
- var bg = this.createBackground();
|
|
|
|
- bg.style.zIndex = mxPopupMenu.prototype.zIndex;
|
|
|
|
- mxUtils.setOpacity(bg, 50);
|
|
|
|
- document.body.appendChild(bg);
|
|
|
|
-
|
|
|
|
data = (data != null) ? data : this.emptyDiagramXml;
|
|
data = (data != null) ? data : this.emptyDiagramXml;
|
|
|
|
|
|
- var error = mxUtils.bind(this, function(resp)
|
|
|
|
|
|
+ var complete = mxUtils.bind(this, function()
|
|
{
|
|
{
|
|
- if (bg.parentNode != null)
|
|
|
|
- {
|
|
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
this.spinner.stop();
|
|
this.spinner.stop();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var error = mxUtils.bind(this, function(resp)
|
|
|
|
+ {
|
|
|
|
+ complete();
|
|
|
|
|
|
if (resp == null && this.getCurrentFile() == null && this.dialog == null)
|
|
if (resp == null && this.getCurrentFile() == null && this.dialog == null)
|
|
{
|
|
{
|
|
@@ -2941,8 +2911,7 @@ App.prototype.createFile = function(title, data, libs, mode, done, replace, fold
|
|
|
|
|
|
this.drive.insertFile(title, data, folderId, mxUtils.bind(this, function(file)
|
|
this.drive.insertFile(title, data, folderId, mxUtils.bind(this, function(file)
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- this.spinner.stop();
|
|
|
|
|
|
+ complete();
|
|
this.fileCreated(file, libs, replace, done);
|
|
this.fileCreated(file, libs, replace, done);
|
|
}), error);
|
|
}), error);
|
|
}
|
|
}
|
|
@@ -2950,8 +2919,7 @@ App.prototype.createFile = function(title, data, libs, mode, done, replace, fold
|
|
{
|
|
{
|
|
this.dropbox.insertFile(title, data, mxUtils.bind(this, function(file)
|
|
this.dropbox.insertFile(title, data, mxUtils.bind(this, function(file)
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- this.spinner.stop();
|
|
|
|
|
|
+ complete();
|
|
this.fileCreated(file, libs, replace, done);
|
|
this.fileCreated(file, libs, replace, done);
|
|
}), error);
|
|
}), error);
|
|
}
|
|
}
|
|
@@ -2959,15 +2927,13 @@ App.prototype.createFile = function(title, data, libs, mode, done, replace, fold
|
|
{
|
|
{
|
|
this.oneDrive.insertFile(title, data, mxUtils.bind(this, function(file)
|
|
this.oneDrive.insertFile(title, data, mxUtils.bind(this, function(file)
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- this.spinner.stop();
|
|
|
|
|
|
+ complete();
|
|
this.fileCreated(file, libs, replace, done);
|
|
this.fileCreated(file, libs, replace, done);
|
|
}), error, false, folderId);
|
|
}), error, false, folderId);
|
|
}
|
|
}
|
|
else if (mode == App.MODE_BROWSER)
|
|
else if (mode == App.MODE_BROWSER)
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- this.spinner.stop();
|
|
|
|
|
|
+ complete();
|
|
|
|
|
|
var fn = mxUtils.bind(this, function()
|
|
var fn = mxUtils.bind(this, function()
|
|
{
|
|
{
|
|
@@ -2997,8 +2963,7 @@ App.prototype.createFile = function(title, data, libs, mode, done, replace, fold
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- this.spinner.stop();
|
|
|
|
|
|
+ complete();
|
|
this.fileCreated(new LocalFile(this, data, title), libs, replace, done);
|
|
this.fileCreated(new LocalFile(this, data, title), libs, replace, done);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3031,20 +2996,19 @@ App.prototype.fileCreated = function(file, libs, replace, done)
|
|
// to save the file again since it needs the newly created file ID for redirecting in HTML
|
|
// to save the file again since it needs the newly created file ID for redirecting in HTML
|
|
if (this.spinner.spin(document.body, mxResources.get('inserting')))
|
|
if (this.spinner.spin(document.body, mxResources.get('inserting')))
|
|
{
|
|
{
|
|
- var bg = this.createBackground();
|
|
|
|
- bg.style.zIndex = mxPopupMenu.prototype.zIndex;
|
|
|
|
- mxUtils.setOpacity(bg, 50);
|
|
|
|
- document.body.appendChild(bg);
|
|
|
|
-
|
|
|
|
var data = file.getData();
|
|
var data = file.getData();
|
|
file.setData(this.createFileData((data.length > 0) ?
|
|
file.setData(this.createFileData((data.length > 0) ?
|
|
this.editor.extractGraphModel(mxUtils.parseXml(data).documentElement, true) : null,
|
|
this.editor.extractGraphModel(mxUtils.parseXml(data).documentElement, true) : null,
|
|
null, file, window.location.protocol + '//' + window.location.hostname + url));
|
|
null, file, window.location.protocol + '//' + window.location.hostname + url));
|
|
-
|
|
|
|
- var fn = mxUtils.bind(this, function()
|
|
|
|
|
|
+
|
|
|
|
+ var complete = mxUtils.bind(this, function()
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
this.spinner.stop();
|
|
this.spinner.stop();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var fn = mxUtils.bind(this, function()
|
|
|
|
+ {
|
|
|
|
+ complete();
|
|
|
|
|
|
var fn2 = mxUtils.bind(this, function()
|
|
var fn2 = mxUtils.bind(this, function()
|
|
{
|
|
{
|
|
@@ -3097,8 +3061,7 @@ App.prototype.fileCreated = function(file, libs, replace, done)
|
|
fn();
|
|
fn();
|
|
}), mxUtils.bind(this, function(resp)
|
|
}), mxUtils.bind(this, function(resp)
|
|
{
|
|
{
|
|
- bg.parentNode.removeChild(bg);
|
|
|
|
- this.spinner.stop();
|
|
|
|
|
|
+ complete();
|
|
this.handleError(resp);
|
|
this.handleError(resp);
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
@@ -3436,136 +3399,6 @@ App.prototype.restoreLibraries = function()
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-/**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-App.prototype.exportImage = function(scale, transparentBackground, ignoreSelection, addShadow, editable)
|
|
|
|
-{
|
|
|
|
- if (this.spinner.spin(document.body, mxResources.get('exporting')))
|
|
|
|
- {
|
|
|
|
- var selectionEmpty = this.editor.graph.isSelectionEmpty();
|
|
|
|
- ignoreSelection = (ignoreSelection != null) ? ignoreSelection : selectionEmpty;
|
|
|
|
-
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- this.exportToCanvas(mxUtils.bind(this, function(canvas)
|
|
|
|
- {
|
|
|
|
- this.spinner.stop();
|
|
|
|
-
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- // TODO: Should call App.getFileData here
|
|
|
|
- this.saveCanvas(canvas, (editable) ? this.getFileData(true, null, null, null, ignoreSelection) : null);
|
|
|
|
- }
|
|
|
|
- catch (e)
|
|
|
|
- {
|
|
|
|
- // Fallback to server-side image export
|
|
|
|
- if (e.message == 'Invalid image')
|
|
|
|
- {
|
|
|
|
- this.downloadFile('png');
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- this.handleError(e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }), null, null, null, mxUtils.bind(this, function(e)
|
|
|
|
- {
|
|
|
|
- this.spinner.stop();
|
|
|
|
- this.handleError(e);
|
|
|
|
- }), null, ignoreSelection, scale || 1, transparentBackground, addShadow);
|
|
|
|
- }
|
|
|
|
- catch (e)
|
|
|
|
- {
|
|
|
|
- this.spinner.stop();
|
|
|
|
- this.handleError(e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-EditorUi.prototype.exportSvg = function(scale, transparentBackground, ignoreSelection, addShadow, editable, embedImages)
|
|
|
|
-{
|
|
|
|
- var selectionEmpty = this.editor.graph.isSelectionEmpty();
|
|
|
|
- ignoreSelection = (ignoreSelection != null) ? ignoreSelection : selectionEmpty;
|
|
|
|
- var bg = (transparentBackground) ? null : this.editor.graph.background;
|
|
|
|
-
|
|
|
|
- if (bg == mxConstants.NONE)
|
|
|
|
- {
|
|
|
|
- bg = null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Handles special case where background is null but transparent is false
|
|
|
|
- if (bg == null && transparentBackground == false)
|
|
|
|
- {
|
|
|
|
- bg = '#ffffff';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Sets or disables alternate text for foreignObjects. Disabling is needed
|
|
|
|
- // because PhantomJS seems to ignore switch statements and paint all text.
|
|
|
|
- var svgRoot = this.editor.graph.getSvg(bg, scale, null, null, null, ignoreSelection);
|
|
|
|
-
|
|
|
|
- if (addShadow)
|
|
|
|
- {
|
|
|
|
- this.editor.addSvgShadow(svgRoot);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var file = this.getCurrentFile();
|
|
|
|
- var filename = (file != null && file.getTitle() != null) ? file.getTitle() : this.defaultFilename;
|
|
|
|
-
|
|
|
|
- var dot = filename.lastIndexOf('.');
|
|
|
|
-
|
|
|
|
- if (dot > 0)
|
|
|
|
- {
|
|
|
|
- filename = filename.substring(0, dot);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- filename += '.svg';
|
|
|
|
-
|
|
|
|
- if (this.spinner.spin(document.body, mxResources.get('export')))
|
|
|
|
- {
|
|
|
|
- var doSave = mxUtils.bind(this, function(svgRoot)
|
|
|
|
- {
|
|
|
|
- this.spinner.stop();
|
|
|
|
-
|
|
|
|
- if (editable)
|
|
|
|
- {
|
|
|
|
- svgRoot.setAttribute('content', this.getFileData(true, null, null, null, ignoreSelection));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var svg = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
|
|
|
- mxUtils.getXml(svgRoot);
|
|
|
|
-
|
|
|
|
- // TODO: Depends on App
|
|
|
|
- if (this.isLocalFileSave() || svg.length <= MAX_REQUEST_SIZE)
|
|
|
|
- {
|
|
|
|
- this.saveData(filename, 'svg', svg, 'image/svg+xml');
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- this.handleError({message: mxResources.get('drawingTooLarge')}, mxResources.get('error'), mxUtils.bind(this, function()
|
|
|
|
- {
|
|
|
|
- mxUtils.popup(svg);
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- this.convertMath(this.editor.graph, svgRoot, false, mxUtils.bind(this, function()
|
|
|
|
- {
|
|
|
|
- if (embedImages)
|
|
|
|
- {
|
|
|
|
- this.convertImages(svgRoot, doSave);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- doSave(svgRoot);
|
|
|
|
- }
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Translates this point by the given vector.
|
|
* Translates this point by the given vector.
|
|
*
|
|
*
|
|
@@ -3718,18 +3551,6 @@ App.prototype.base64ToBlob = function(base64Data, contentType)
|
|
return new Blob(byteArrays, {type: contentType});
|
|
return new Blob(byteArrays, {type: contentType});
|
|
};
|
|
};
|
|
|
|
|
|
-/**
|
|
|
|
- * Returns true if files should be saved using <saveLocalFile>.
|
|
|
|
- */
|
|
|
|
-App.prototype.isLocalFileSave = function()
|
|
|
|
-{
|
|
|
|
- return (urlParams['save'] != 'remote' && (mxClient.IS_IE ||
|
|
|
|
- (typeof window.Blob !== 'undefined' && typeof window.URL !== 'undefined')) &&
|
|
|
|
- document.documentMode != 9 && document.documentMode != 8 &&
|
|
|
|
- document.documentMode != 7 && !mxClient.IS_QUIRKS) ||
|
|
|
|
- this.isOfflineApp() || mxClient.IS_IOS;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Translates this point by the given vector.
|
|
* Translates this point by the given vector.
|
|
*
|
|
*
|
|
@@ -3840,7 +3661,7 @@ App.prototype.pickFolder = function(mode, fn, enabled)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- fn(null);
|
|
|
|
|
|
+ EditorUi.prototype.pickFolder.apply(this, arguments);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -3924,199 +3745,6 @@ App.prototype.exportFile = function(data, filename, mimeType, base64Encoded, mod
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-/**
|
|
|
|
- * Translates this point by the given vector.
|
|
|
|
- *
|
|
|
|
- * @param {number} dx X-coordinate of the translation.
|
|
|
|
- * @param {number} dy Y-coordinate of the translation.
|
|
|
|
- */
|
|
|
|
-App.prototype.doSaveLocalFile = function(data, filename, mimeType, base64Encoded)
|
|
|
|
-{
|
|
|
|
- // Newer versions of IE
|
|
|
|
- if (window.MSBlobBuilder && navigator.msSaveOrOpenBlob)
|
|
|
|
- {
|
|
|
|
- var builder = new MSBlobBuilder();
|
|
|
|
- builder.append(data);
|
|
|
|
- var blob = builder.getBlob(mimeType);
|
|
|
|
- navigator.msSaveOrOpenBlob(blob, filename);
|
|
|
|
- }
|
|
|
|
- // Older versions of IE (binary not supported)
|
|
|
|
- else if (mxClient.IS_IE)
|
|
|
|
- {
|
|
|
|
- var win = window.open('about:blank', '_blank');
|
|
|
|
-
|
|
|
|
- if (win == null)
|
|
|
|
- {
|
|
|
|
- mxUtils.popup(data, true);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- win.document.write(data);
|
|
|
|
- win.document.close();
|
|
|
|
- win.document.execCommand('SaveAs', true, filename);
|
|
|
|
- win.close();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if (mxClient.IS_IOS)
|
|
|
|
- {
|
|
|
|
- // Poor man's saveAs in iOS via context menu of selected output
|
|
|
|
- var dlg = new TextareaDialog(this, filename + ':', data, null, null, mxResources.get('close'));
|
|
|
|
- dlg.textarea.style.width = '600px';
|
|
|
|
- dlg.textarea.style.height = '380px';
|
|
|
|
- this.showDialog(dlg.container, 620, 460, true, true);
|
|
|
|
- dlg.init();
|
|
|
|
- document.execCommand('selectall', false, null);
|
|
|
|
- }
|
|
|
|
- else if (!this.isOffline() && mxClient.IS_SF)
|
|
|
|
- {
|
|
|
|
- var param = (typeof(pako) === 'undefined') ? '&xml=' + encodeURIComponent(data) :
|
|
|
|
- '&data=' + encodeURIComponent(this.editor.graph.compress(data));
|
|
|
|
-
|
|
|
|
- new mxXmlRequest(SAVE_URL, 'mime=' + mimeType + '&filename=' +
|
|
|
|
- encodeURIComponent(filename) +
|
|
|
|
- param).simulate(document, '_blank');
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var a = document.createElement('a');
|
|
|
|
- a.href = URL.createObjectURL((base64Encoded) ?
|
|
|
|
- this.base64ToBlob(data, mimeType) :
|
|
|
|
- new Blob([data], {type: mimeType}));
|
|
|
|
- a.download = filename;
|
|
|
|
- document.body.appendChild(a);
|
|
|
|
-
|
|
|
|
- // Workaround for link opens in same window in Safari
|
|
|
|
- if (mxClient.IS_SF)
|
|
|
|
- {
|
|
|
|
- a.setAttribute('target', '_blank');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- a.click();
|
|
|
|
-
|
|
|
|
- window.setTimeout(function()
|
|
|
|
- {
|
|
|
|
- URL.revokeObjectURL(a.href);
|
|
|
|
- }, 0);
|
|
|
|
- a.parentNode.removeChild(a);
|
|
|
|
- }
|
|
|
|
- catch (e)
|
|
|
|
- {
|
|
|
|
- // ignore
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Translates this point by the given vector.
|
|
|
|
- *
|
|
|
|
- * @param {number} dx X-coordinate of the translation.
|
|
|
|
- * @param {number} dy Y-coordinate of the translation.
|
|
|
|
- */
|
|
|
|
-App.prototype.saveLocalFile = function(data, filename, mimeType, base64Encoded)
|
|
|
|
-{
|
|
|
|
- if (this.isOfflineApp() || this.isOffline())
|
|
|
|
- {
|
|
|
|
- this.doSaveLocalFile(data, filename, mimeType, base64Encoded);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var allowTab = !mxClient.IS_IOS || !navigator.standalone;
|
|
|
|
-
|
|
|
|
- var dlg = new CreateDialog(this, filename, mxUtils.bind(this, function(newTitle, mode)
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- // Opens a new window
|
|
|
|
- if (mode == '_blank')
|
|
|
|
- {
|
|
|
|
- // Workaround for "Access denied" after URL.createObjectURL
|
|
|
|
- // and blank window for window.open with data URI in MS Edge
|
|
|
|
- // and empty window for IE 11 and 10
|
|
|
|
- if (mxClient.IS_EDGE || document.documentMode == 11 || document.documentMode == 10)
|
|
|
|
- {
|
|
|
|
- var param = (typeof(pako) === 'undefined') ? '&xml=' + encodeURIComponent(data) :
|
|
|
|
- '&data=' + encodeURIComponent(this.editor.graph.compress(data));
|
|
|
|
-
|
|
|
|
- new mxXmlRequest(SAVE_URL, 'mime=' + mimeType + param).simulate(document, '_blank');
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- // Cannot use URL.createObjectURL since it kills gradients in FF
|
|
|
|
- window.open('data:' + mimeType + ((base64Encoded) ? ';base64,' +
|
|
|
|
- data : ';charset=utf8,' + encodeURIComponent(data)));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if (mode == App.MODE_DEVICE)
|
|
|
|
- {
|
|
|
|
- this.doSaveLocalFile(data, newTitle, mimeType, base64Encoded);
|
|
|
|
- }
|
|
|
|
- else if (newTitle != null && newTitle.length > 0)
|
|
|
|
- {
|
|
|
|
- this.pickFolder(mode, mxUtils.bind(this, function(folderId)
|
|
|
|
- {
|
|
|
|
- this.exportFile(data, newTitle, mimeType, base64Encoded, mode, folderId);
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- catch (e)
|
|
|
|
- {
|
|
|
|
- this.handleError(e);
|
|
|
|
- }
|
|
|
|
- }), mxUtils.bind(this, function()
|
|
|
|
- {
|
|
|
|
- this.hideDialog();
|
|
|
|
- }), mxResources.get('saveAs'), mxResources.get('download'), false, false, allowTab);
|
|
|
|
- this.showDialog(dlg.container, 380, 280, true, true);
|
|
|
|
- dlg.init();
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Translates this point by the given vector.
|
|
|
|
- *
|
|
|
|
- * @param {number} dx X-coordinate of the translation.
|
|
|
|
- * @param {number} dy Y-coordinate of the translation.
|
|
|
|
- */
|
|
|
|
-App.prototype.saveData = function(filename, format, data, mime)
|
|
|
|
-{
|
|
|
|
- if (this.isLocalFileSave())
|
|
|
|
- {
|
|
|
|
- this.saveLocalFile(data, filename, mime);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- this.saveRequest(data, filename, format, mxUtils.bind(this, function(newTitle, base64)
|
|
|
|
- {
|
|
|
|
- var param = (typeof(pako) === 'undefined') ? '&xml=' + encodeURIComponent(data) :
|
|
|
|
- '&data=' + encodeURIComponent(this.editor.graph.compress(data));
|
|
|
|
-
|
|
|
|
- return new mxXmlRequest(SAVE_URL, 'format=' + format + ((newTitle != null) ?
|
|
|
|
- '&filename=' + encodeURIComponent(newTitle) : '') + param);
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Translates this point by the given vector.
|
|
|
|
- *
|
|
|
|
- * @param {number} dx X-coordinate of the translation.
|
|
|
|
- * @param {number} dy Y-coordinate of the translation.
|
|
|
|
- */
|
|
|
|
-App.prototype.formatFileSize = function(size)
|
|
|
|
-{
|
|
|
|
- var units = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
|
|
- var i = -1;
|
|
|
|
- do
|
|
|
|
- {
|
|
|
|
- size = size / 1024;
|
|
|
|
- i++;
|
|
|
|
- } while (size > 1024);
|
|
|
|
-
|
|
|
|
- return Math.max(size, 0.1).toFixed(1) + units[i];
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Translates this point by the given vector.
|
|
* Translates this point by the given vector.
|
|
*
|
|
*
|