fix: 【文件】流程图去掉ctr+s提示框

This commit is contained in:
韦荣超 2022-02-14 18:13:16 +08:00
parent 84116e531b
commit 259351cdd2
8 changed files with 250 additions and 250 deletions

View File

@ -3769,6 +3769,7 @@ App.prototype.loadFileSystemEntry = function(fileHandle, success, error)
reader.onload = mxUtils.bind(this, function(e) reader.onload = mxUtils.bind(this, function(e)
{ {
try try
{ {
if (success != null) if (success != null)
@ -3912,7 +3913,6 @@ App.prototype.pickFile = function(mode)
else else
{ {
var peer = this.getPeerForMode(mode); var peer = this.getPeerForMode(mode);
if (peer != null) if (peer != null)
{ {
peer.pickFile(); peer.pickFile();
@ -4548,7 +4548,7 @@ App.prototype.saveFile = function(forceDialog, success)
this.hideDialog(); this.hideDialog();
}), mxResources.get('saveAs'), mxResources.get('download'), null, null, allowTab, }), mxResources.get('saveAs'), mxResources.get('download'), null, null, allowTab,
null, true, rowLimit, null, null, null, this.editor.fileExtensions, false); null, true, rowLimit, null, null, null, this.editor.fileExtensions, false);
this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true); // this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true);
dlg.init(); dlg.init();
} }
} }

View File

@ -5,7 +5,7 @@
DriveFile = function(ui, data, desc) DriveFile = function(ui, data, desc)
{ {
DrawioFile.call(this, ui, data); DrawioFile.call(this, ui, data);
this.desc = desc; this.desc = desc;
}; };
@ -57,7 +57,7 @@ DriveFile.prototype.getCurrentUser = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -73,7 +73,7 @@ DriveFile.prototype.getPublicUrl = function(fn)
{ {
this.ui.drive.executeRequest({ this.ui.drive.executeRequest({
url: '/files/' + this.desc.id + '/permissions?supportsAllDrives=true' url: '/files/' + this.desc.id + '/permissions?supportsAllDrives=true'
}, },
mxUtils.bind(this, function(resp) mxUtils.bind(this, function(resp)
{ {
if (resp != null && resp.items != null) if (resp != null && resp.items != null)
@ -84,12 +84,12 @@ DriveFile.prototype.getPublicUrl = function(fn)
resp.items[i].id === 'anyone') resp.items[i].id === 'anyone')
{ {
fn(this.desc.webContentLink); fn(this.desc.webContentLink);
return; return;
} }
} }
} }
fn(null); fn(null);
}), mxUtils.bind(this, function() }), mxUtils.bind(this, function()
{ {
@ -108,7 +108,7 @@ DriveFile.prototype.isAutosaveOptional = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -119,7 +119,7 @@ DriveFile.prototype.isRenamable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -130,7 +130,7 @@ DriveFile.prototype.isMovable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -141,7 +141,7 @@ DriveFile.prototype.isTrashed = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -155,7 +155,7 @@ DriveFile.prototype.save = function(revision, success, error, unloading, overwri
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -184,31 +184,31 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
try try
{ {
var lastDesc = this.desc; var lastDesc = this.desc;
this.ui.drive.saveFile(this, realRevision, mxUtils.bind(this, function(resp, savedData) this.ui.drive.saveFile(this, realRevision, mxUtils.bind(this, function(resp, savedData)
{ {
try try
{ {
this.savingFile = false; this.savingFile = false;
// Handles special case where resp is false eg // Handles special case where resp is false eg
// if the old file was converted to realtime // if the old file was converted to realtime
if (resp != false) if (resp != false)
{ {
// Checks for changes during save // Checks for changes during save
this.setModified(this.getShadowModified()); this.setModified(this.getShadowModified());
if (revision) if (revision)
{ {
this.lastAutosaveRevision = new Date().getTime(); this.lastAutosaveRevision = new Date().getTime();
} }
// Adaptive autosave delay // Adaptive autosave delay
this.autosaveDelay = Math.round(Math.min(10000, this.autosaveDelay = Math.round(Math.min(10000,
Math.max(DriveFile.prototype.autosaveDelay, Math.max(DriveFile.prototype.autosaveDelay,
this.saveDelay))); this.saveDelay)));
this.desc = resp; this.desc = resp;
// Shows possible errors but keeps the modified flag as the // Shows possible errors but keeps the modified flag as the
// file was saved but the cache entry could not be written // file was saved but the cache entry could not be written
if (token != null) if (token != null)
@ -216,7 +216,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
this.fileSaved(savedData, lastDesc, mxUtils.bind(this, function() this.fileSaved(savedData, lastDesc, mxUtils.bind(this, function()
{ {
this.contentChanged(); this.contentChanged();
if (success != null) if (success != null)
{ {
success(resp); success(resp);
@ -236,7 +236,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
catch (e) catch (e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(e); error(e);
@ -251,15 +251,15 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
try try
{ {
this.savingFile = false; this.savingFile = false;
if (this.isConflict(err)) if (this.isConflict(err))
{ {
this.inConflictState = true; this.inConflictState = true;
if (this.sync != null) if (this.sync != null)
{ {
this.savingFile = true; this.savingFile = true;
this.sync.fileConflict(desc, mxUtils.bind(this, function() this.sync.fileConflict(desc, mxUtils.bind(this, function()
{ {
// Adds random cool-off // Adds random cool-off
@ -272,7 +272,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
}), mxUtils.bind(this, function() }), mxUtils.bind(this, function()
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(); error();
@ -292,7 +292,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
catch (e) catch (e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(e); error(e);
@ -307,7 +307,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
catch (e) catch (e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(e); error(e);
@ -318,8 +318,8 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
} }
} }
}); });
doSave(overwrite, revision); doSave(overwrite, revision);
})); }));
} }
} }
@ -361,7 +361,7 @@ DriveFile.prototype.copyFile = function(success, error)
else else
{ {
DrawioFile.prototype.copyFile.apply(this, arguments); DrawioFile.prototype.copyFile.apply(this, arguments);
} }
}; };
/** /**
@ -379,17 +379,17 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp)
this.desc = resp; this.desc = resp;
this.ui.spinner.stop(); this.ui.spinner.stop();
this.setModified(false); this.setModified(false);
this.backupPatch = null; this.backupPatch = null;
this.invalidChecksum = false; this.invalidChecksum = false;
this.inConflictState = false; this.inConflictState = false;
this.descriptorChanged(); this.descriptorChanged();
success(); success();
}), mxUtils.bind(this, function() }), mxUtils.bind(this, function()
{ {
this.ui.spinner.stop(); this.ui.spinner.stop();
if (error != null) if (error != null)
{ {
error(); error();
@ -400,7 +400,7 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -411,14 +411,14 @@ DriveFile.prototype.saveAs = function(filename, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
DriveFile.prototype.rename = function(title, success, error) DriveFile.prototype.rename = function(title, success, error)
{ {
var etag = this.getCurrentEtag(); var etag = this.getCurrentEtag();
this.ui.drive.renameFile(this.getId(), title, mxUtils.bind(this, function(desc) this.ui.drive.renameFile(this.getId(), title, mxUtils.bind(this, function(desc)
{ {
if (!this.hasSameExtension(title, this.getTitle())) if (!this.hasSameExtension(title, this.getTitle()))
@ -429,19 +429,19 @@ DriveFile.prototype.rename = function(title, success, error)
{ {
this.sync.descriptorChanged(etag); this.sync.descriptorChanged(etag);
} }
this.save(true, success, error); this.save(true, success, error);
} }
else else
{ {
this.desc = desc; this.desc = desc;
this.descriptorChanged(); this.descriptorChanged();
if (this.sync != null) if (this.sync != null)
{ {
this.sync.descriptorChanged(etag); this.sync.descriptorChanged(etag);
} }
if (success != null) if (success != null)
{ {
success(desc); success(desc);
@ -452,7 +452,7 @@ DriveFile.prototype.rename = function(title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -462,7 +462,7 @@ DriveFile.prototype.move = function(folderId, success, error)
{ {
this.desc = resp; this.desc = resp;
this.descriptorChanged(); this.descriptorChanged();
if (success != null) if (success != null)
{ {
success(resp); success(resp);
@ -472,7 +472,7 @@ DriveFile.prototype.move = function(folderId, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -483,7 +483,7 @@ DriveFile.prototype.share = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -494,7 +494,7 @@ DriveFile.prototype.getTitle = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -505,7 +505,7 @@ DriveFile.prototype.getHash = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -516,7 +516,7 @@ DriveFile.prototype.getId = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -560,7 +560,7 @@ DriveFile.prototype.getRevisions = function(success, error)
// Redirects title to originalFilename to // Redirects title to originalFilename to
// match expected descriptor interface // match expected descriptor interface
item.title = item.originalFilename; item.title = item.originalFilename;
item.getXml = mxUtils.bind(this, function(itemSuccess, itemError) item.getXml = mxUtils.bind(this, function(itemSuccess, itemError)
{ {
this.ui.drive.getXmlFile(item, mxUtils.bind(this, function(file) this.ui.drive.getXmlFile(item, mxUtils.bind(this, function(file)
@ -568,7 +568,7 @@ DriveFile.prototype.getRevisions = function(success, error)
itemSuccess(file.getData()); itemSuccess(file.getData());
}), itemError); }), itemError);
}); });
item.getUrl = mxUtils.bind(this, function(page) item.getUrl = mxUtils.bind(this, function(page)
{ {
return this.ui.getUrl(window.location.pathname + '?rev=' + item.id + return this.ui.getUrl(window.location.pathname + '?rev=' + item.id +
@ -577,7 +577,7 @@ DriveFile.prototype.getRevisions = function(success, error)
}); });
}))(resp.items[i]); }))(resp.items[i]);
} }
success(resp.items); success(resp.items);
}), error); }), error);
}; };
@ -596,12 +596,12 @@ DriveFile.prototype.getLatestVersion = function(success, error)
DriveFile.prototype.getChannelId = function() DriveFile.prototype.getChannelId = function()
{ {
var chan = this.ui.drive.getCustomProperty(this.desc, 'channel'); var chan = this.ui.drive.getCustomProperty(this.desc, 'channel');
if (chan != null) if (chan != null)
{ {
chan = 'G-' + this.getId() + '.' + chan; chan = 'G-' + this.getId() + '.' + chan;
} }
return chan; return chan;
}; };
@ -683,7 +683,7 @@ DriveFile.prototype.setDescriptorEtag = function(desc, etag)
DriveFile.prototype.loadPatchDescriptor = function(success, error) DriveFile.prototype.loadPatchDescriptor = function(success, error)
{ {
this.ui.drive.executeRequest( this.ui.drive.executeRequest(
{ {
url: '/files/' + this.getId() + '?supportsAllDrives=true&fields=' + this.ui.drive.catchupFields url: '/files/' + this.getId() + '?supportsAllDrives=true&fields=' + this.ui.drive.catchupFields
}, },
mxUtils.bind(this, function(desc) mxUtils.bind(this, function(desc)
@ -699,7 +699,7 @@ DriveFile.prototype.patchDescriptor = function(desc, patch)
{ {
desc.headRevisionId = patch.headRevisionId; desc.headRevisionId = patch.headRevisionId;
desc.modifiedDate = patch.modifiedDate; desc.modifiedDate = patch.modifiedDate;
DrawioFile.prototype.patchDescriptor.apply(this, arguments); DrawioFile.prototype.patchDescriptor.apply(this, arguments);
}; };
@ -725,25 +725,25 @@ DriveFile.prototype.commentsSupported = function()
DriveFile.prototype.getComments = function(success, error) DriveFile.prototype.getComments = function(success, error)
{ {
var currentUser = this.ui.getCurrentUser(); var currentUser = this.ui.getCurrentUser();
function driveCommentToDrawio(file, gComment, pCommentId) function driveCommentToDrawio(file, gComment, pCommentId)
{ {
if (gComment.deleted) return null; //skip deleted comments if (gComment.deleted) return null; //skip deleted comments
var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content, var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content,
gComment.modifiedDate, gComment.createdDate, gComment.status == 'resolved', gComment.modifiedDate, gComment.createdDate, gComment.status == 'resolved',
gComment.author.isAuthenticatedUser? currentUser : gComment.author.isAuthenticatedUser? currentUser :
new DrawioUser(gComment.author.permissionId, gComment.author.emailAddress, new DrawioUser(gComment.author.permissionId, gComment.author.emailAddress,
gComment.author.displayName, gComment.author.picture.url), pCommentId); gComment.author.displayName, gComment.author.picture.url), pCommentId);
for (var i = 0; gComment.replies != null && i < gComment.replies.length; i++) for (var i = 0; gComment.replies != null && i < gComment.replies.length; i++)
{ {
comment.addReplyDirect(driveCommentToDrawio(file, gComment.replies[i], gComment.commentId)); comment.addReplyDirect(driveCommentToDrawio(file, gComment.replies[i], gComment.commentId));
} }
return comment; return comment;
}; };
this.ui.drive.executeRequest( this.ui.drive.executeRequest(
{ {
url: '/files/' + this.getId() + '/comments' url: '/files/' + this.getId() + '/comments'
@ -751,14 +751,14 @@ DriveFile.prototype.getComments = function(success, error)
mxUtils.bind(this, function(resp) mxUtils.bind(this, function(resp)
{ {
var comments = []; var comments = [];
for (var i = 0; i < resp.items.length; i++) for (var i = 0; i < resp.items.length; i++)
{ {
var comment = driveCommentToDrawio(this, resp.items[i]); var comment = driveCommentToDrawio(this, resp.items[i]);
if (comment != null) comments.push(comment); if (comment != null) comments.push(comment);
} }
success(comments); success(comments);
}), error); }), error);
}; };
@ -769,7 +769,7 @@ DriveFile.prototype.getComments = function(success, error)
DriveFile.prototype.addComment = function(comment, success, error) DriveFile.prototype.addComment = function(comment, success, error)
{ {
var body = {'content': comment.content}; var body = {'content': comment.content};
this.ui.drive.executeRequest( this.ui.drive.executeRequest(
{ {
url: '/files/' + this.getId() + '/comments', url: '/files/' + this.getId() + '/comments',

View File

@ -11,7 +11,7 @@
LocalFile = function(ui, data, title, temp, fileHandle, desc) LocalFile = function(ui, data, title, temp, fileHandle, desc)
{ {
DrawioFile.call(this, ui, data); DrawioFile.call(this, ui, data);
this.title = title; this.title = title;
this.mode = (temp) ? null : App.MODE_DEVICE; this.mode = (temp) ? null : App.MODE_DEVICE;
this.fileHandle = fileHandle; this.fileHandle = fileHandle;
@ -23,7 +23,7 @@ mxUtils.extend(LocalFile, DrawioFile);
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -43,7 +43,7 @@ LocalFile.prototype.isAutosaveOptional = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -54,7 +54,7 @@ LocalFile.prototype.getMode = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -65,7 +65,7 @@ LocalFile.prototype.getTitle = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -76,7 +76,7 @@ LocalFile.prototype.isRenamable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -87,7 +87,7 @@ LocalFile.prototype.save = function(revision, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -98,7 +98,7 @@ LocalFile.prototype.saveAs = function(title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -125,7 +125,7 @@ LocalFile.prototype.setDescriptor = function(desc)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -143,7 +143,7 @@ LocalFile.prototype.getLatestVersion = function(success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -154,7 +154,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
this.fileHandle = null; this.fileHandle = null;
this.desc = null; this.desc = null;
} }
this.title = title; this.title = title;
// Updates data after changing file name // Updates data after changing file name
@ -162,22 +162,22 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
{ {
this.updateFileData(); this.updateFileData();
} }
var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle());
this.setShadowModified(false); this.setShadowModified(false);
var savedData = this.getData(); var savedData = this.getData();
var done = mxUtils.bind(this, function() var done = mxUtils.bind(this, function()
{ {
this.setModified(this.getShadowModified()); this.setModified(this.getShadowModified());
this.contentChanged(); this.contentChanged();
if (success != null) if (success != null)
{ {
success(); success();
} }
}); });
var doSave = mxUtils.bind(this, function(data) var doSave = mxUtils.bind(this, function(data)
{ {
if (this.fileHandle != null) if (this.fileHandle != null)
@ -187,27 +187,27 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
{ {
this.savingFileTime = new Date(); this.savingFileTime = new Date();
this.savingFile = true; this.savingFile = true;
var errorWrapper = mxUtils.bind(this, function(e) var errorWrapper = mxUtils.bind(this, function(e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
// Wraps error object to offer save status option // Wraps error object to offer save status option
error({error: e}); error({error: e});
} }
}); });
// Saves a copy as a draft while saving // Saves a copy as a draft while saving
this.saveDraft(); this.saveDraft();
this.fileHandle.createWritable().then(mxUtils.bind(this, function(writable) this.fileHandle.createWritable().then(mxUtils.bind(this, function(writable)
{ {
this.fileHandle.getFile().then(mxUtils.bind(this, function(newDesc) this.fileHandle.getFile().then(mxUtils.bind(this, function(newDesc)
{ {
this.invalidFileHandle = null; this.invalidFileHandle = null;
if (this.desc.lastModified == newDesc.lastModified) if (this.desc.lastModified == newDesc.lastModified)
{ {
writable.write((binary) ? this.ui.base64ToBlob(data, 'image/png') : data).then(mxUtils.bind(this, function() writable.write((binary) ? this.ui.base64ToBlob(data, 'image/png') : data).then(mxUtils.bind(this, function()
@ -222,7 +222,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
this.savingFile = false; this.savingFile = false;
this.desc = desc; this.desc = desc;
this.fileSaved(savedData, lastDesc, done, errorWrapper); this.fileSaved(savedData, lastDesc, done, errorWrapper);
// Deletes draft after saving // Deletes draft after saving
this.removeDraft(); this.removeDraft();
} }
@ -260,7 +260,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
{ {
var dot = title.lastIndexOf('.'); var dot = title.lastIndexOf('.');
var format = (dot > 0) ? title.substring(dot + 1) : 'xml'; var format = (dot > 0) ? title.substring(dot + 1) : 'xml';
// Do not update modified flag // Do not update modified flag
new mxXmlRequest(SAVE_URL, 'format=' + format + new mxXmlRequest(SAVE_URL, 'format=' + format +
'&xml=' + encodeURIComponent(data) + '&xml=' + encodeURIComponent(data) +
@ -276,11 +276,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
})); }));
} }
} }
done(); done();
} }
}); });
if (binary) if (binary)
{ {
var p = this.ui.getPngFileProperties(this.ui.fileNode); var p = this.ui.getPngFileProperties(this.ui.fileNode);
@ -299,7 +299,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -307,7 +307,7 @@ LocalFile.prototype.rename = function(title, success, error)
{ {
this.title = title; this.title = title;
this.descriptorChanged(); this.descriptorChanged();
if (success != null) if (success != null)
{ {
success(); success();

View File

@ -13,7 +13,7 @@
StorageFile = function(ui, data, title) StorageFile = function(ui, data, title)
{ {
DrawioFile.call(this, ui, data); DrawioFile.call(this, ui, data);
this.title = title; this.title = title;
}; };
@ -37,7 +37,7 @@ StorageFile.prototype.type = 'F';
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -56,7 +56,7 @@ StorageFile.prototype.isAutosaveOptional = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -67,7 +67,7 @@ StorageFile.prototype.getHash = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -78,7 +78,7 @@ StorageFile.prototype.getTitle = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -89,7 +89,7 @@ StorageFile.prototype.isRenamable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -100,7 +100,7 @@ StorageFile.prototype.save = function(revision, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -112,7 +112,7 @@ StorageFile.prototype.saveAs = function(title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -123,7 +123,7 @@ StorageFile.insertFile = function(ui, title, data, success, error)
var fn = function() var fn = function()
{ {
var file = new StorageFile(ui, data, title); var file = new StorageFile(ui, data, title);
// Inserts data into local storage // Inserts data into local storage
file.saveFile(title, false, function() file.saveFile(title, false, function()
{ {
@ -140,7 +140,7 @@ StorageFile.insertFile = function(ui, title, data, success, error)
fn(); fn();
} }
}); });
StorageFile.getFileContent(ui, title, function(data) StorageFile.getFileContent(ui, title, function(data)
{ {
createStorageFile(data != null); createStorageFile(data != null);
@ -152,7 +152,7 @@ StorageFile.insertFile = function(ui, title, data, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -161,7 +161,7 @@ StorageFile.getFileContent = function(ui, title, success, error)
ui.getDatabaseItem(title, function(obj) ui.getDatabaseItem(title, function(obj)
{ {
success(obj != null? obj.data : null); success(obj != null? obj.data : null);
}, },
mxUtils.bind(this, function() mxUtils.bind(this, function()
{ {
if (ui.database == null) //fallback to localstorage if (ui.database == null) //fallback to localstorage
@ -177,7 +177,7 @@ StorageFile.getFileContent = function(ui, title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -186,7 +186,7 @@ StorageFile.getFileInfo = function(ui, title, success, error)
ui.getDatabaseItem(title, function(obj) ui.getDatabaseItem(title, function(obj)
{ {
success(obj); success(obj);
}, },
mxUtils.bind(this, function() mxUtils.bind(this, function()
{ {
if (ui.database == null) //fallback to localstorage if (ui.database == null) //fallback to localstorage
@ -205,7 +205,7 @@ StorageFile.getFileInfo = function(ui, title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -226,23 +226,23 @@ StorageFile.prototype.saveFile = function(title, revision, success, error)
{ {
this.title = title; this.title = title;
} }
try try
{ {
var saveDone = mxUtils.bind(this, function() var saveDone = mxUtils.bind(this, function()
{ {
this.setModified(this.getShadowModified()); this.setModified(this.getShadowModified());
this.contentChanged(); this.contentChanged();
if (success != null) if (success != null)
{ {
success(); success();
} }
}); });
this.setShadowModified(false); this.setShadowModified(false);
var data = this.getData(); var data = this.getData();
this.ui.setDatabaseItem(null, [{ this.ui.setDatabaseItem(null, [{
title: this.title, title: this.title,
size: data.length, size: data.length,
@ -271,7 +271,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error)
} }
} }
}); });
// Checks for trailing dots // Checks for trailing dots
if (this.isRenamable() && title.charAt(0) == '.' && error != null) if (this.isRenamable() && title.charAt(0) == '.' && error != null)
{ {
@ -296,7 +296,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -311,19 +311,19 @@ StorageFile.prototype.rename = function(title, success, error)
var fn = mxUtils.bind(this, function() var fn = mxUtils.bind(this, function()
{ {
this.title = title; this.title = title;
// Updates the data if the extension has changed // Updates the data if the extension has changed
if (!this.hasSameExtension(oldTitle, title)) if (!this.hasSameExtension(oldTitle, title))
{ {
this.setData(this.ui.getFileData()); this.setData(this.ui.getFileData());
} }
this.saveFile(title, false, mxUtils.bind(this, function() this.saveFile(title, false, mxUtils.bind(this, function()
{ {
this.ui.removeLocalData(oldTitle, success); this.ui.removeLocalData(oldTitle, success);
}), error); }), error);
}); });
if (data != null) if (data != null)
{ {
this.ui.confirm(mxResources.get('replaceIt', [title]), fn, error); this.ui.confirm(mxResources.get('replaceIt', [title]), fn, error);
@ -369,7 +369,7 @@ StorageFile.prototype.getLatestVersion = function(success, error)
StorageFile.prototype.destroy = function() StorageFile.prototype.destroy = function()
{ {
DrawioFile.prototype.destroy.apply(this, arguments); DrawioFile.prototype.destroy.apply(this, arguments);
if (this.storageListener != null) if (this.storageListener != null)
{ {
mxEvent.removeListener(window, 'storage', this.storageListener); mxEvent.removeListener(window, 'storage', this.storageListener);
@ -379,19 +379,19 @@ StorageFile.prototype.destroy = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
StorageFile.listLocalStorageFiles = function(type) StorageFile.listLocalStorageFiles = function(type)
{ {
var filesInfo = []; var filesInfo = [];
for (var i = 0; i < localStorage.length; i++) for (var i = 0; i < localStorage.length; i++)
{ {
var key = localStorage.key(i); var key = localStorage.key(i);
var value = localStorage.getItem(key); var value = localStorage.getItem(key);
if (key.length > 0 && key.charAt(0) != '.' && value.length > 0) if (key.length > 0 && key.charAt(0) != '.' && value.length > 0)
{ {
var isFile = (type == null || type == 'F') && (value.substring(0, 8) === '<mxfile ' || var isFile = (type == null || type == 'F') && (value.substring(0, 8) === '<mxfile ' ||
@ -406,27 +406,27 @@ StorageFile.listLocalStorageFiles = function(type)
size: value.length, size: value.length,
lastModified: Date.now() lastModified: Date.now()
}); });
} }
} }
} }
return filesInfo; return filesInfo;
}; };
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
StorageFile.migrate = function(db) StorageFile.migrate = function(db)
{ {
var lsFilesInfo = StorageFile.listLocalStorageFiles(); var lsFilesInfo = StorageFile.listLocalStorageFiles();
lsFilesInfo.push({title: '.scratchpad', type: 'L'}); //Adding scratchpad also since it is a library (storage file) lsFilesInfo.push({title: '.scratchpad', type: 'L'}); //Adding scratchpad also since it is a library (storage file)
var tx = db.transaction(['files', 'filesInfo'], 'readwrite'); var tx = db.transaction(['files', 'filesInfo'], 'readwrite');
var files = tx.objectStore('files'); var files = tx.objectStore('files');
var filesInfo = tx.objectStore('filesInfo'); var filesInfo = tx.objectStore('filesInfo');
for (var i = 0; i < lsFilesInfo.length; i++) for (var i = 0; i < lsFilesInfo.length; i++)
{ {
var lsFileInfo = lsFilesInfo[i]; var lsFileInfo = lsFilesInfo[i];
@ -441,7 +441,7 @@ StorageFile.migrate = function(db)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -450,7 +450,7 @@ StorageFile.listFiles = function(ui, type, success, error)
ui.getDatabaseItems(function(filesInfo) ui.getDatabaseItems(function(filesInfo)
{ {
var files = []; var files = [];
if (filesInfo != null) if (filesInfo != null)
{ {
for (var i = 0; i < filesInfo.length; i++) for (var i = 0; i < filesInfo.length; i++)
@ -461,7 +461,7 @@ StorageFile.listFiles = function(ui, type, success, error)
} }
} }
} }
success(files); success(files);
}, function() }, function()
{ {
@ -478,7 +478,7 @@ StorageFile.listFiles = function(ui, type, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -496,4 +496,4 @@ StorageFile.deleteFile = function(ui, title, success, error)
error(); error();
} }
}, ['files', 'filesInfo']); }, ['files', 'filesInfo']);
}; };

View File

@ -3769,6 +3769,7 @@ App.prototype.loadFileSystemEntry = function(fileHandle, success, error)
reader.onload = mxUtils.bind(this, function(e) reader.onload = mxUtils.bind(this, function(e)
{ {
try try
{ {
if (success != null) if (success != null)
@ -3912,7 +3913,6 @@ App.prototype.pickFile = function(mode)
else else
{ {
var peer = this.getPeerForMode(mode); var peer = this.getPeerForMode(mode);
if (peer != null) if (peer != null)
{ {
peer.pickFile(); peer.pickFile();
@ -4548,7 +4548,7 @@ App.prototype.saveFile = function(forceDialog, success)
this.hideDialog(); this.hideDialog();
}), mxResources.get('saveAs'), mxResources.get('download'), null, null, allowTab, }), mxResources.get('saveAs'), mxResources.get('download'), null, null, allowTab,
null, true, rowLimit, null, null, null, this.editor.fileExtensions, false); null, true, rowLimit, null, null, null, this.editor.fileExtensions, false);
this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true); // this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true);
dlg.init(); dlg.init();
} }
} }

View File

@ -5,7 +5,7 @@
DriveFile = function(ui, data, desc) DriveFile = function(ui, data, desc)
{ {
DrawioFile.call(this, ui, data); DrawioFile.call(this, ui, data);
this.desc = desc; this.desc = desc;
}; };
@ -57,7 +57,7 @@ DriveFile.prototype.getCurrentUser = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -73,7 +73,7 @@ DriveFile.prototype.getPublicUrl = function(fn)
{ {
this.ui.drive.executeRequest({ this.ui.drive.executeRequest({
url: '/files/' + this.desc.id + '/permissions?supportsAllDrives=true' url: '/files/' + this.desc.id + '/permissions?supportsAllDrives=true'
}, },
mxUtils.bind(this, function(resp) mxUtils.bind(this, function(resp)
{ {
if (resp != null && resp.items != null) if (resp != null && resp.items != null)
@ -84,12 +84,12 @@ DriveFile.prototype.getPublicUrl = function(fn)
resp.items[i].id === 'anyone') resp.items[i].id === 'anyone')
{ {
fn(this.desc.webContentLink); fn(this.desc.webContentLink);
return; return;
} }
} }
} }
fn(null); fn(null);
}), mxUtils.bind(this, function() }), mxUtils.bind(this, function()
{ {
@ -108,7 +108,7 @@ DriveFile.prototype.isAutosaveOptional = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -119,7 +119,7 @@ DriveFile.prototype.isRenamable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -130,7 +130,7 @@ DriveFile.prototype.isMovable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -141,7 +141,7 @@ DriveFile.prototype.isTrashed = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -155,7 +155,7 @@ DriveFile.prototype.save = function(revision, success, error, unloading, overwri
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -184,31 +184,31 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
try try
{ {
var lastDesc = this.desc; var lastDesc = this.desc;
this.ui.drive.saveFile(this, realRevision, mxUtils.bind(this, function(resp, savedData) this.ui.drive.saveFile(this, realRevision, mxUtils.bind(this, function(resp, savedData)
{ {
try try
{ {
this.savingFile = false; this.savingFile = false;
// Handles special case where resp is false eg // Handles special case where resp is false eg
// if the old file was converted to realtime // if the old file was converted to realtime
if (resp != false) if (resp != false)
{ {
// Checks for changes during save // Checks for changes during save
this.setModified(this.getShadowModified()); this.setModified(this.getShadowModified());
if (revision) if (revision)
{ {
this.lastAutosaveRevision = new Date().getTime(); this.lastAutosaveRevision = new Date().getTime();
} }
// Adaptive autosave delay // Adaptive autosave delay
this.autosaveDelay = Math.round(Math.min(10000, this.autosaveDelay = Math.round(Math.min(10000,
Math.max(DriveFile.prototype.autosaveDelay, Math.max(DriveFile.prototype.autosaveDelay,
this.saveDelay))); this.saveDelay)));
this.desc = resp; this.desc = resp;
// Shows possible errors but keeps the modified flag as the // Shows possible errors but keeps the modified flag as the
// file was saved but the cache entry could not be written // file was saved but the cache entry could not be written
if (token != null) if (token != null)
@ -216,7 +216,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
this.fileSaved(savedData, lastDesc, mxUtils.bind(this, function() this.fileSaved(savedData, lastDesc, mxUtils.bind(this, function()
{ {
this.contentChanged(); this.contentChanged();
if (success != null) if (success != null)
{ {
success(resp); success(resp);
@ -236,7 +236,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
catch (e) catch (e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(e); error(e);
@ -251,15 +251,15 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
try try
{ {
this.savingFile = false; this.savingFile = false;
if (this.isConflict(err)) if (this.isConflict(err))
{ {
this.inConflictState = true; this.inConflictState = true;
if (this.sync != null) if (this.sync != null)
{ {
this.savingFile = true; this.savingFile = true;
this.sync.fileConflict(desc, mxUtils.bind(this, function() this.sync.fileConflict(desc, mxUtils.bind(this, function()
{ {
// Adds random cool-off // Adds random cool-off
@ -272,7 +272,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
}), mxUtils.bind(this, function() }), mxUtils.bind(this, function()
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(); error();
@ -292,7 +292,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
catch (e) catch (e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(e); error(e);
@ -307,7 +307,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
catch (e) catch (e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
error(e); error(e);
@ -318,8 +318,8 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi
} }
} }
}); });
doSave(overwrite, revision); doSave(overwrite, revision);
})); }));
} }
} }
@ -361,7 +361,7 @@ DriveFile.prototype.copyFile = function(success, error)
else else
{ {
DrawioFile.prototype.copyFile.apply(this, arguments); DrawioFile.prototype.copyFile.apply(this, arguments);
} }
}; };
/** /**
@ -379,17 +379,17 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp)
this.desc = resp; this.desc = resp;
this.ui.spinner.stop(); this.ui.spinner.stop();
this.setModified(false); this.setModified(false);
this.backupPatch = null; this.backupPatch = null;
this.invalidChecksum = false; this.invalidChecksum = false;
this.inConflictState = false; this.inConflictState = false;
this.descriptorChanged(); this.descriptorChanged();
success(); success();
}), mxUtils.bind(this, function() }), mxUtils.bind(this, function()
{ {
this.ui.spinner.stop(); this.ui.spinner.stop();
if (error != null) if (error != null)
{ {
error(); error();
@ -400,7 +400,7 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -411,14 +411,14 @@ DriveFile.prototype.saveAs = function(filename, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
DriveFile.prototype.rename = function(title, success, error) DriveFile.prototype.rename = function(title, success, error)
{ {
var etag = this.getCurrentEtag(); var etag = this.getCurrentEtag();
this.ui.drive.renameFile(this.getId(), title, mxUtils.bind(this, function(desc) this.ui.drive.renameFile(this.getId(), title, mxUtils.bind(this, function(desc)
{ {
if (!this.hasSameExtension(title, this.getTitle())) if (!this.hasSameExtension(title, this.getTitle()))
@ -429,19 +429,19 @@ DriveFile.prototype.rename = function(title, success, error)
{ {
this.sync.descriptorChanged(etag); this.sync.descriptorChanged(etag);
} }
this.save(true, success, error); this.save(true, success, error);
} }
else else
{ {
this.desc = desc; this.desc = desc;
this.descriptorChanged(); this.descriptorChanged();
if (this.sync != null) if (this.sync != null)
{ {
this.sync.descriptorChanged(etag); this.sync.descriptorChanged(etag);
} }
if (success != null) if (success != null)
{ {
success(desc); success(desc);
@ -452,7 +452,7 @@ DriveFile.prototype.rename = function(title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -462,7 +462,7 @@ DriveFile.prototype.move = function(folderId, success, error)
{ {
this.desc = resp; this.desc = resp;
this.descriptorChanged(); this.descriptorChanged();
if (success != null) if (success != null)
{ {
success(resp); success(resp);
@ -472,7 +472,7 @@ DriveFile.prototype.move = function(folderId, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -483,7 +483,7 @@ DriveFile.prototype.share = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -494,7 +494,7 @@ DriveFile.prototype.getTitle = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -505,7 +505,7 @@ DriveFile.prototype.getHash = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -516,7 +516,7 @@ DriveFile.prototype.getId = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -560,7 +560,7 @@ DriveFile.prototype.getRevisions = function(success, error)
// Redirects title to originalFilename to // Redirects title to originalFilename to
// match expected descriptor interface // match expected descriptor interface
item.title = item.originalFilename; item.title = item.originalFilename;
item.getXml = mxUtils.bind(this, function(itemSuccess, itemError) item.getXml = mxUtils.bind(this, function(itemSuccess, itemError)
{ {
this.ui.drive.getXmlFile(item, mxUtils.bind(this, function(file) this.ui.drive.getXmlFile(item, mxUtils.bind(this, function(file)
@ -568,7 +568,7 @@ DriveFile.prototype.getRevisions = function(success, error)
itemSuccess(file.getData()); itemSuccess(file.getData());
}), itemError); }), itemError);
}); });
item.getUrl = mxUtils.bind(this, function(page) item.getUrl = mxUtils.bind(this, function(page)
{ {
return this.ui.getUrl(window.location.pathname + '?rev=' + item.id + return this.ui.getUrl(window.location.pathname + '?rev=' + item.id +
@ -577,7 +577,7 @@ DriveFile.prototype.getRevisions = function(success, error)
}); });
}))(resp.items[i]); }))(resp.items[i]);
} }
success(resp.items); success(resp.items);
}), error); }), error);
}; };
@ -596,12 +596,12 @@ DriveFile.prototype.getLatestVersion = function(success, error)
DriveFile.prototype.getChannelId = function() DriveFile.prototype.getChannelId = function()
{ {
var chan = this.ui.drive.getCustomProperty(this.desc, 'channel'); var chan = this.ui.drive.getCustomProperty(this.desc, 'channel');
if (chan != null) if (chan != null)
{ {
chan = 'G-' + this.getId() + '.' + chan; chan = 'G-' + this.getId() + '.' + chan;
} }
return chan; return chan;
}; };
@ -683,7 +683,7 @@ DriveFile.prototype.setDescriptorEtag = function(desc, etag)
DriveFile.prototype.loadPatchDescriptor = function(success, error) DriveFile.prototype.loadPatchDescriptor = function(success, error)
{ {
this.ui.drive.executeRequest( this.ui.drive.executeRequest(
{ {
url: '/files/' + this.getId() + '?supportsAllDrives=true&fields=' + this.ui.drive.catchupFields url: '/files/' + this.getId() + '?supportsAllDrives=true&fields=' + this.ui.drive.catchupFields
}, },
mxUtils.bind(this, function(desc) mxUtils.bind(this, function(desc)
@ -699,7 +699,7 @@ DriveFile.prototype.patchDescriptor = function(desc, patch)
{ {
desc.headRevisionId = patch.headRevisionId; desc.headRevisionId = patch.headRevisionId;
desc.modifiedDate = patch.modifiedDate; desc.modifiedDate = patch.modifiedDate;
DrawioFile.prototype.patchDescriptor.apply(this, arguments); DrawioFile.prototype.patchDescriptor.apply(this, arguments);
}; };
@ -725,25 +725,25 @@ DriveFile.prototype.commentsSupported = function()
DriveFile.prototype.getComments = function(success, error) DriveFile.prototype.getComments = function(success, error)
{ {
var currentUser = this.ui.getCurrentUser(); var currentUser = this.ui.getCurrentUser();
function driveCommentToDrawio(file, gComment, pCommentId) function driveCommentToDrawio(file, gComment, pCommentId)
{ {
if (gComment.deleted) return null; //skip deleted comments if (gComment.deleted) return null; //skip deleted comments
var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content, var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content,
gComment.modifiedDate, gComment.createdDate, gComment.status == 'resolved', gComment.modifiedDate, gComment.createdDate, gComment.status == 'resolved',
gComment.author.isAuthenticatedUser? currentUser : gComment.author.isAuthenticatedUser? currentUser :
new DrawioUser(gComment.author.permissionId, gComment.author.emailAddress, new DrawioUser(gComment.author.permissionId, gComment.author.emailAddress,
gComment.author.displayName, gComment.author.picture.url), pCommentId); gComment.author.displayName, gComment.author.picture.url), pCommentId);
for (var i = 0; gComment.replies != null && i < gComment.replies.length; i++) for (var i = 0; gComment.replies != null && i < gComment.replies.length; i++)
{ {
comment.addReplyDirect(driveCommentToDrawio(file, gComment.replies[i], gComment.commentId)); comment.addReplyDirect(driveCommentToDrawio(file, gComment.replies[i], gComment.commentId));
} }
return comment; return comment;
}; };
this.ui.drive.executeRequest( this.ui.drive.executeRequest(
{ {
url: '/files/' + this.getId() + '/comments' url: '/files/' + this.getId() + '/comments'
@ -751,14 +751,14 @@ DriveFile.prototype.getComments = function(success, error)
mxUtils.bind(this, function(resp) mxUtils.bind(this, function(resp)
{ {
var comments = []; var comments = [];
for (var i = 0; i < resp.items.length; i++) for (var i = 0; i < resp.items.length; i++)
{ {
var comment = driveCommentToDrawio(this, resp.items[i]); var comment = driveCommentToDrawio(this, resp.items[i]);
if (comment != null) comments.push(comment); if (comment != null) comments.push(comment);
} }
success(comments); success(comments);
}), error); }), error);
}; };
@ -769,7 +769,7 @@ DriveFile.prototype.getComments = function(success, error)
DriveFile.prototype.addComment = function(comment, success, error) DriveFile.prototype.addComment = function(comment, success, error)
{ {
var body = {'content': comment.content}; var body = {'content': comment.content};
this.ui.drive.executeRequest( this.ui.drive.executeRequest(
{ {
url: '/files/' + this.getId() + '/comments', url: '/files/' + this.getId() + '/comments',

View File

@ -11,7 +11,7 @@
LocalFile = function(ui, data, title, temp, fileHandle, desc) LocalFile = function(ui, data, title, temp, fileHandle, desc)
{ {
DrawioFile.call(this, ui, data); DrawioFile.call(this, ui, data);
this.title = title; this.title = title;
this.mode = (temp) ? null : App.MODE_DEVICE; this.mode = (temp) ? null : App.MODE_DEVICE;
this.fileHandle = fileHandle; this.fileHandle = fileHandle;
@ -23,7 +23,7 @@ mxUtils.extend(LocalFile, DrawioFile);
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -43,7 +43,7 @@ LocalFile.prototype.isAutosaveOptional = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -54,7 +54,7 @@ LocalFile.prototype.getMode = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -65,7 +65,7 @@ LocalFile.prototype.getTitle = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -76,7 +76,7 @@ LocalFile.prototype.isRenamable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -87,7 +87,7 @@ LocalFile.prototype.save = function(revision, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -98,7 +98,7 @@ LocalFile.prototype.saveAs = function(title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -125,7 +125,7 @@ LocalFile.prototype.setDescriptor = function(desc)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -143,7 +143,7 @@ LocalFile.prototype.getLatestVersion = function(success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -154,7 +154,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
this.fileHandle = null; this.fileHandle = null;
this.desc = null; this.desc = null;
} }
this.title = title; this.title = title;
// Updates data after changing file name // Updates data after changing file name
@ -162,22 +162,22 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
{ {
this.updateFileData(); this.updateFileData();
} }
var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle());
this.setShadowModified(false); this.setShadowModified(false);
var savedData = this.getData(); var savedData = this.getData();
var done = mxUtils.bind(this, function() var done = mxUtils.bind(this, function()
{ {
this.setModified(this.getShadowModified()); this.setModified(this.getShadowModified());
this.contentChanged(); this.contentChanged();
if (success != null) if (success != null)
{ {
success(); success();
} }
}); });
var doSave = mxUtils.bind(this, function(data) var doSave = mxUtils.bind(this, function(data)
{ {
if (this.fileHandle != null) if (this.fileHandle != null)
@ -187,27 +187,27 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
{ {
this.savingFileTime = new Date(); this.savingFileTime = new Date();
this.savingFile = true; this.savingFile = true;
var errorWrapper = mxUtils.bind(this, function(e) var errorWrapper = mxUtils.bind(this, function(e)
{ {
this.savingFile = false; this.savingFile = false;
if (error != null) if (error != null)
{ {
// Wraps error object to offer save status option // Wraps error object to offer save status option
error({error: e}); error({error: e});
} }
}); });
// Saves a copy as a draft while saving // Saves a copy as a draft while saving
this.saveDraft(); this.saveDraft();
this.fileHandle.createWritable().then(mxUtils.bind(this, function(writable) this.fileHandle.createWritable().then(mxUtils.bind(this, function(writable)
{ {
this.fileHandle.getFile().then(mxUtils.bind(this, function(newDesc) this.fileHandle.getFile().then(mxUtils.bind(this, function(newDesc)
{ {
this.invalidFileHandle = null; this.invalidFileHandle = null;
if (this.desc.lastModified == newDesc.lastModified) if (this.desc.lastModified == newDesc.lastModified)
{ {
writable.write((binary) ? this.ui.base64ToBlob(data, 'image/png') : data).then(mxUtils.bind(this, function() writable.write((binary) ? this.ui.base64ToBlob(data, 'image/png') : data).then(mxUtils.bind(this, function()
@ -222,7 +222,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
this.savingFile = false; this.savingFile = false;
this.desc = desc; this.desc = desc;
this.fileSaved(savedData, lastDesc, done, errorWrapper); this.fileSaved(savedData, lastDesc, done, errorWrapper);
// Deletes draft after saving // Deletes draft after saving
this.removeDraft(); this.removeDraft();
} }
@ -260,7 +260,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
{ {
var dot = title.lastIndexOf('.'); var dot = title.lastIndexOf('.');
var format = (dot > 0) ? title.substring(dot + 1) : 'xml'; var format = (dot > 0) ? title.substring(dot + 1) : 'xml';
// Do not update modified flag // Do not update modified flag
new mxXmlRequest(SAVE_URL, 'format=' + format + new mxXmlRequest(SAVE_URL, 'format=' + format +
'&xml=' + encodeURIComponent(data) + '&xml=' + encodeURIComponent(data) +
@ -276,11 +276,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
})); }));
} }
} }
done(); done();
} }
}); });
if (binary) if (binary)
{ {
var p = this.ui.getPngFileProperties(this.ui.fileNode); var p = this.ui.getPngFileProperties(this.ui.fileNode);
@ -299,7 +299,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -307,7 +307,7 @@ LocalFile.prototype.rename = function(title, success, error)
{ {
this.title = title; this.title = title;
this.descriptorChanged(); this.descriptorChanged();
if (success != null) if (success != null)
{ {
success(); success();

View File

@ -13,7 +13,7 @@
StorageFile = function(ui, data, title) StorageFile = function(ui, data, title)
{ {
DrawioFile.call(this, ui, data); DrawioFile.call(this, ui, data);
this.title = title; this.title = title;
}; };
@ -37,7 +37,7 @@ StorageFile.prototype.type = 'F';
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -56,7 +56,7 @@ StorageFile.prototype.isAutosaveOptional = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -67,7 +67,7 @@ StorageFile.prototype.getHash = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -78,7 +78,7 @@ StorageFile.prototype.getTitle = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -89,7 +89,7 @@ StorageFile.prototype.isRenamable = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -100,7 +100,7 @@ StorageFile.prototype.save = function(revision, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -112,7 +112,7 @@ StorageFile.prototype.saveAs = function(title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -123,7 +123,7 @@ StorageFile.insertFile = function(ui, title, data, success, error)
var fn = function() var fn = function()
{ {
var file = new StorageFile(ui, data, title); var file = new StorageFile(ui, data, title);
// Inserts data into local storage // Inserts data into local storage
file.saveFile(title, false, function() file.saveFile(title, false, function()
{ {
@ -140,7 +140,7 @@ StorageFile.insertFile = function(ui, title, data, success, error)
fn(); fn();
} }
}); });
StorageFile.getFileContent(ui, title, function(data) StorageFile.getFileContent(ui, title, function(data)
{ {
createStorageFile(data != null); createStorageFile(data != null);
@ -152,7 +152,7 @@ StorageFile.insertFile = function(ui, title, data, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -161,7 +161,7 @@ StorageFile.getFileContent = function(ui, title, success, error)
ui.getDatabaseItem(title, function(obj) ui.getDatabaseItem(title, function(obj)
{ {
success(obj != null? obj.data : null); success(obj != null? obj.data : null);
}, },
mxUtils.bind(this, function() mxUtils.bind(this, function()
{ {
if (ui.database == null) //fallback to localstorage if (ui.database == null) //fallback to localstorage
@ -177,7 +177,7 @@ StorageFile.getFileContent = function(ui, title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -186,7 +186,7 @@ StorageFile.getFileInfo = function(ui, title, success, error)
ui.getDatabaseItem(title, function(obj) ui.getDatabaseItem(title, function(obj)
{ {
success(obj); success(obj);
}, },
mxUtils.bind(this, function() mxUtils.bind(this, function()
{ {
if (ui.database == null) //fallback to localstorage if (ui.database == null) //fallback to localstorage
@ -205,7 +205,7 @@ StorageFile.getFileInfo = function(ui, title, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -226,23 +226,23 @@ StorageFile.prototype.saveFile = function(title, revision, success, error)
{ {
this.title = title; this.title = title;
} }
try try
{ {
var saveDone = mxUtils.bind(this, function() var saveDone = mxUtils.bind(this, function()
{ {
this.setModified(this.getShadowModified()); this.setModified(this.getShadowModified());
this.contentChanged(); this.contentChanged();
if (success != null) if (success != null)
{ {
success(); success();
} }
}); });
this.setShadowModified(false); this.setShadowModified(false);
var data = this.getData(); var data = this.getData();
this.ui.setDatabaseItem(null, [{ this.ui.setDatabaseItem(null, [{
title: this.title, title: this.title,
size: data.length, size: data.length,
@ -271,7 +271,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error)
} }
} }
}); });
// Checks for trailing dots // Checks for trailing dots
if (this.isRenamable() && title.charAt(0) == '.' && error != null) if (this.isRenamable() && title.charAt(0) == '.' && error != null)
{ {
@ -296,7 +296,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -311,19 +311,19 @@ StorageFile.prototype.rename = function(title, success, error)
var fn = mxUtils.bind(this, function() var fn = mxUtils.bind(this, function()
{ {
this.title = title; this.title = title;
// Updates the data if the extension has changed // Updates the data if the extension has changed
if (!this.hasSameExtension(oldTitle, title)) if (!this.hasSameExtension(oldTitle, title))
{ {
this.setData(this.ui.getFileData()); this.setData(this.ui.getFileData());
} }
this.saveFile(title, false, mxUtils.bind(this, function() this.saveFile(title, false, mxUtils.bind(this, function()
{ {
this.ui.removeLocalData(oldTitle, success); this.ui.removeLocalData(oldTitle, success);
}), error); }), error);
}); });
if (data != null) if (data != null)
{ {
this.ui.confirm(mxResources.get('replaceIt', [title]), fn, error); this.ui.confirm(mxResources.get('replaceIt', [title]), fn, error);
@ -369,7 +369,7 @@ StorageFile.prototype.getLatestVersion = function(success, error)
StorageFile.prototype.destroy = function() StorageFile.prototype.destroy = function()
{ {
DrawioFile.prototype.destroy.apply(this, arguments); DrawioFile.prototype.destroy.apply(this, arguments);
if (this.storageListener != null) if (this.storageListener != null)
{ {
mxEvent.removeListener(window, 'storage', this.storageListener); mxEvent.removeListener(window, 'storage', this.storageListener);
@ -379,19 +379,19 @@ StorageFile.prototype.destroy = function()
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
StorageFile.listLocalStorageFiles = function(type) StorageFile.listLocalStorageFiles = function(type)
{ {
var filesInfo = []; var filesInfo = [];
for (var i = 0; i < localStorage.length; i++) for (var i = 0; i < localStorage.length; i++)
{ {
var key = localStorage.key(i); var key = localStorage.key(i);
var value = localStorage.getItem(key); var value = localStorage.getItem(key);
if (key.length > 0 && key.charAt(0) != '.' && value.length > 0) if (key.length > 0 && key.charAt(0) != '.' && value.length > 0)
{ {
var isFile = (type == null || type == 'F') && (value.substring(0, 8) === '<mxfile ' || var isFile = (type == null || type == 'F') && (value.substring(0, 8) === '<mxfile ' ||
@ -406,27 +406,27 @@ StorageFile.listLocalStorageFiles = function(type)
size: value.length, size: value.length,
lastModified: Date.now() lastModified: Date.now()
}); });
} }
} }
} }
return filesInfo; return filesInfo;
}; };
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
StorageFile.migrate = function(db) StorageFile.migrate = function(db)
{ {
var lsFilesInfo = StorageFile.listLocalStorageFiles(); var lsFilesInfo = StorageFile.listLocalStorageFiles();
lsFilesInfo.push({title: '.scratchpad', type: 'L'}); //Adding scratchpad also since it is a library (storage file) lsFilesInfo.push({title: '.scratchpad', type: 'L'}); //Adding scratchpad also since it is a library (storage file)
var tx = db.transaction(['files', 'filesInfo'], 'readwrite'); var tx = db.transaction(['files', 'filesInfo'], 'readwrite');
var files = tx.objectStore('files'); var files = tx.objectStore('files');
var filesInfo = tx.objectStore('filesInfo'); var filesInfo = tx.objectStore('filesInfo');
for (var i = 0; i < lsFilesInfo.length; i++) for (var i = 0; i < lsFilesInfo.length; i++)
{ {
var lsFileInfo = lsFilesInfo[i]; var lsFileInfo = lsFilesInfo[i];
@ -441,7 +441,7 @@ StorageFile.migrate = function(db)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -450,7 +450,7 @@ StorageFile.listFiles = function(ui, type, success, error)
ui.getDatabaseItems(function(filesInfo) ui.getDatabaseItems(function(filesInfo)
{ {
var files = []; var files = [];
if (filesInfo != null) if (filesInfo != null)
{ {
for (var i = 0; i < filesInfo.length; i++) for (var i = 0; i < filesInfo.length; i++)
@ -461,7 +461,7 @@ StorageFile.listFiles = function(ui, type, success, error)
} }
} }
} }
success(files); success(files);
}, function() }, function()
{ {
@ -478,7 +478,7 @@ StorageFile.listFiles = function(ui, type, success, error)
/** /**
* Translates this point by the given vector. * Translates this point by the given vector.
* *
* @param {number} dx X-coordinate of the translation. * @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation. * @param {number} dy Y-coordinate of the translation.
*/ */
@ -496,4 +496,4 @@ StorageFile.deleteFile = function(ui, title, success, error)
error(); error();
} }
}, ['files', 'filesInfo']); }, ['files', 'filesInfo']);
}; };