1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 18:30:53 +00:00

[dir view] show 'leaving page' confirm popup when a file is uploading (#2612)

This commit is contained in:
llj
2018-12-19 14:49:25 +08:00
committed by Daniel Pan
parent 34f13fc40d
commit f22a6715a3
3 changed files with 61 additions and 14 deletions

View File

@@ -130,10 +130,19 @@ define([
this.currentView = newView; this.currentView = newView;
} else { } else {
if (this.currentView != newView) { if (this.currentView != newView) {
if (this.currentView == this.dirView) {
if ($('#upload-file-dialog').is(':visible') &&
$('#upload-file-dialog .status').text() == window.fileuploading) {
if (!window.confirm('A file is being uploaded. Are you sure you want to leave this page?')) {
return false;
}
}
}
this.currentView.hide(); this.currentView.hide();
this.currentView = newView; this.currentView = newView;
} }
} }
return true;
}, },
showRepos: function() { showRepos: function() {
@@ -145,19 +154,25 @@ define([
}, },
showMyRepos: function() { showMyRepos: function() {
this.switchCurrentView(this.myReposView); if (!this.switchCurrentView(this.myReposView)) {
return false;
};
this.myReposView.show(); this.myReposView.show();
this.sideNavView.setCurTab('mine'); this.sideNavView.setCurTab('mine');
}, },
showMyDeletedRepos: function() { showMyDeletedRepos: function() {
this.switchCurrentView(this.myDeletedReposView); if (!this.switchCurrentView(this.myDeletedReposView)) {
return false;
};
this.myDeletedReposView.show(); this.myDeletedReposView.show();
this.sideNavView.setCurTab('mine'); this.sideNavView.setCurTab('mine');
}, },
showSharedRepos: function() { showSharedRepos: function() {
this.switchCurrentView(this.sharedReposView); if (!this.switchCurrentView(this.sharedReposView)) {
return false;
}
this.sharedReposView.show(); this.sharedReposView.show();
this.sideNavView.setCurTab('shared'); this.sideNavView.setCurTab('shared');
}, },
@@ -196,7 +211,9 @@ define([
}, },
showGroups: function () { showGroups: function () {
this.switchCurrentView(this.groupsView); if (!this.switchCurrentView(this.groupsView)) {
return false;
}
this.groupsView.show(); this.groupsView.show();
this.sideNavView.setCurTab('group', { this.sideNavView.setCurTab('group', {
'cur_group_tab': 'groups', 'cur_group_tab': 'groups',
@@ -205,7 +222,9 @@ define([
}, },
showGroup: function(group_id, options) { showGroup: function(group_id, options) {
this.switchCurrentView(this.groupView); if (!this.switchCurrentView(this.groupView)) {
return false;
}
this.groupView.show(group_id, options); this.groupView.show(group_id, options);
this.sideNavView.setCurTab('group', { this.sideNavView.setCurTab('group', {
'cur_group_tab': '', 'cur_group_tab': '',
@@ -247,7 +266,9 @@ define([
}, },
showOrgRepos: function() { showOrgRepos: function() {
this.switchCurrentView(this.orgView); if (!this.switchCurrentView(this.orgView)) {
return false;
}
this.orgView.show(); this.orgView.show();
this.sideNavView.setCurTab('org'); this.sideNavView.setCurTab('org');
}, },
@@ -264,49 +285,65 @@ define([
}, },
showStarredFile: function() { showStarredFile: function() {
this.switchCurrentView(this.starredFileView); if (!this.switchCurrentView(this.starredFileView)) {
return false;
}
this.starredFileView.show(); this.starredFileView.show();
this.sideNavView.setCurTab('starred'); this.sideNavView.setCurTab('starred');
}, },
showActivities: function() { showActivities: function() {
this.switchCurrentView(this.activitiesView); if (!this.switchCurrentView(this.activitiesView)) {
return false;
}
this.activitiesView.show(); this.activitiesView.show();
this.sideNavView.setCurTab('activities'); this.sideNavView.setCurTab('activities');
}, },
showDevices: function() { showDevices: function() {
this.switchCurrentView(this.devicesView); if (!this.switchCurrentView(this.devicesView)) {
return false;
}
this.devicesView.show(); this.devicesView.show();
this.sideNavView.setCurTab('devices'); this.sideNavView.setCurTab('devices');
}, },
showInvitations: function() { showInvitations: function() {
this.switchCurrentView(this.invitationsView); if (!this.switchCurrentView(this.invitationsView)) {
return false;
}
this.invitationsView.show(); this.invitationsView.show();
this.sideNavView.setCurTab('invitations'); this.sideNavView.setCurTab('invitations');
}, },
showShareAdminRepos: function() { showShareAdminRepos: function() {
this.switchCurrentView(this.shareAdminReposView); if (!this.switchCurrentView(this.shareAdminReposView)) {
return false;
}
this.shareAdminReposView.show(); this.shareAdminReposView.show();
this.sideNavView.setCurTab('share-admin-repos', {'show_share_admin': true}); this.sideNavView.setCurTab('share-admin-repos', {'show_share_admin': true});
}, },
showShareAdminFolders: function() { showShareAdminFolders: function() {
this.switchCurrentView(this.shareAdminFoldersView); if (!this.switchCurrentView(this.shareAdminFoldersView)) {
return false;
}
this.shareAdminFoldersView.show(); this.shareAdminFoldersView.show();
this.sideNavView.setCurTab('share-admin-folders', {'show_share_admin': true}); this.sideNavView.setCurTab('share-admin-folders', {'show_share_admin': true});
}, },
showShareAdminShareLinks: function() { showShareAdminShareLinks: function() {
this.switchCurrentView(this.shareAdminShareLinksView); if (!this.switchCurrentView(this.shareAdminShareLinksView)) {
return false;
}
this.shareAdminShareLinksView.show(); this.shareAdminShareLinksView.show();
this.sideNavView.setCurTab('share-admin-links', {'show_share_admin': true}); this.sideNavView.setCurTab('share-admin-links', {'show_share_admin': true});
}, },
showShareAdminUploadLinks: function() { showShareAdminUploadLinks: function() {
this.switchCurrentView(this.shareAdminUploadLinksView); if (!this.switchCurrentView(this.shareAdminUploadLinksView)) {
return false;
}
this.shareAdminUploadLinksView.show(); this.shareAdminUploadLinksView.show();
this.sideNavView.setCurTab('share-admin-links', {'show_share_admin': true}); this.sideNavView.setCurTab('share-admin-links', {'show_share_admin': true});
} }

View File

@@ -104,6 +104,14 @@ define([
} }
}); });
// confirm leaving the page when file is uploading
window.onbeforeunload = function(e) {
if ($('#upload-file-dialog').is(':visible') &&
$('#upload-file-dialog .status').text() == window.fileuploading) {
return '';
}
};
}, },
renderMainCon: function() { renderMainCon: function() {

View File

@@ -49,6 +49,8 @@ define([
'canceled': gettext("File Upload canceled"), 'canceled': gettext("File Upload canceled"),
'failed': gettext("File Upload failed") 'failed': gettext("File Upload failed")
}; };
// for the leaving page confirm popup
window.fileuploading = fu_status.uploading;
var uploaded_files = []; var uploaded_files = [];
var updated_files = []; var updated_files = [];