Add method requestClose (show warning on unsaved changes)
This commit is contained in:
parent
0e52ef704b
commit
84d357560e
|
@ -657,6 +657,13 @@
|
|||
});
|
||||
};
|
||||
|
||||
var _requestClose = function(data) {
|
||||
_sendCommand({
|
||||
command: 'requestClose',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
var _processMouse = function(evt) {
|
||||
var r = iframe.getBoundingClientRect();
|
||||
var data = {
|
||||
|
@ -703,7 +710,8 @@
|
|||
insertImage : _insertImage,
|
||||
setMailMergeRecipients: _setMailMergeRecipients,
|
||||
setRevisedFile : _setRevisedFile,
|
||||
setFavorite : _setFavorite
|
||||
setFavorite : _setFavorite,
|
||||
requestClose : _requestClose
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -126,6 +126,10 @@ if (Common === undefined) {
|
|||
|
||||
'setFavorite': function(data) {
|
||||
$me.trigger('setfavorite', data);
|
||||
},
|
||||
|
||||
'requestClose': function(data) {
|
||||
$me.trigger('requestclose', data);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -265,6 +265,7 @@ DE.ApplicationController = new(function(){
|
|||
|
||||
Common.Gateway.on('processmouse', onProcessMouse);
|
||||
Common.Gateway.on('downloadas', onDownloadAs);
|
||||
Common.Gateway.on('requestclose', onRequestClose);
|
||||
|
||||
DE.ApplicationView.tools.get('#idt-fullscreen')
|
||||
.on('click', function(){
|
||||
|
@ -493,6 +494,10 @@ DE.ApplicationController = new(function(){
|
|||
}
|
||||
}
|
||||
|
||||
function onRequestClose() {
|
||||
Common.Gateway.requestClose();
|
||||
}
|
||||
|
||||
function onDownloadAs() {
|
||||
if ( permissions.download === false) {
|
||||
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
|
||||
|
|
|
@ -706,32 +706,36 @@ define([
|
|||
app.getController('Viewport').SetDisabled(disable);
|
||||
},
|
||||
|
||||
onRequestClose: function() {
|
||||
var me = this;
|
||||
if (this.api.isDocumentModified()) {
|
||||
this.api.asc_stopSaving();
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
width: 500,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.leavePageTextOnClose,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_undoAllChanges();
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
} else
|
||||
me.api.asc_continueSaving();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
}
|
||||
},
|
||||
|
||||
goBack: function(current) {
|
||||
if ( !Common.Controllers.Desktop.process('goback') ) {
|
||||
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
|
||||
if (this.api.isDocumentModified()) {
|
||||
var me = this;
|
||||
this.api.asc_stopSaving();
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
width: 500,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.leavePageTextOnClose,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_undoAllChanges();
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
} else
|
||||
me.api.asc_continueSaving();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
}
|
||||
this.onRequestClose();
|
||||
} else {
|
||||
var href = this.appOptions.customization.goback.url;
|
||||
if (!current && this.appOptions.customization.goback.blank!==false) {
|
||||
|
@ -1167,6 +1171,7 @@ define([
|
|||
Common.Gateway.on('refreshhistory', _.bind(me.onRefreshHistory, me));
|
||||
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
|
||||
Common.Gateway.on('setfavorite', _.bind(me.onSetFavorite, me));
|
||||
Common.Gateway.on('requestclose', _.bind(me.onRequestClose, me));
|
||||
|
||||
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});
|
||||
|
||||
|
|
|
@ -368,6 +368,10 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onRequestClose: function() {
|
||||
Common.Gateway.requestClose();
|
||||
},
|
||||
|
||||
goBack: function(current) {
|
||||
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
|
||||
Common.Gateway.requestClose();
|
||||
|
@ -633,6 +637,7 @@ define([
|
|||
Common.Gateway.on('processsaveresult', _.bind(me.onProcessSaveResult, me));
|
||||
Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me));
|
||||
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
|
||||
Common.Gateway.on('requestclose', _.bind(me.onRequestClose, me));
|
||||
|
||||
Common.Gateway.sendInfo({
|
||||
mode: me.appOptions.isEdit ? 'edit' : 'view'
|
||||
|
|
|
@ -273,6 +273,7 @@ PE.ApplicationController = new(function(){
|
|||
|
||||
Common.Gateway.on('processmouse', onProcessMouse);
|
||||
Common.Gateway.on('downloadas', onDownloadAs);
|
||||
Common.Gateway.on('requestclose', onRequestClose);
|
||||
|
||||
PE.ApplicationView.tools.get('#idt-fullscreen')
|
||||
.on('click', function(){
|
||||
|
@ -593,6 +594,10 @@ PE.ApplicationController = new(function(){
|
|||
}
|
||||
}
|
||||
|
||||
function onRequestClose() {
|
||||
Common.Gateway.requestClose();
|
||||
}
|
||||
|
||||
function onDownloadAs() {
|
||||
if ( permissions.download === false) {
|
||||
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
|
||||
|
|
|
@ -485,32 +485,37 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onRequestClose: function() {
|
||||
var me = this;
|
||||
if (this.api.isDocumentModified()) {
|
||||
this.api.asc_stopSaving();
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
width: 500,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.leavePageTextOnClose,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_undoAllChanges();
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
} else
|
||||
me.api.asc_continueSaving();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
}
|
||||
},
|
||||
|
||||
goBack: function(current) {
|
||||
var me = this;
|
||||
if ( !Common.Controllers.Desktop.process('goback') ) {
|
||||
if (me.appOptions.customization.goback.requestClose && me.appOptions.canRequestClose) {
|
||||
if (this.api.isDocumentModified()) {
|
||||
this.api.asc_stopSaving();
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
width: 500,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.leavePageTextOnClose,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_undoAllChanges();
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
} else
|
||||
me.api.asc_continueSaving();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
}
|
||||
me.onRequestClose();
|
||||
} else {
|
||||
var href = me.appOptions.customization.goback.url;
|
||||
if (!current && me.appOptions.customization.goback.blank!==false) {
|
||||
|
@ -889,7 +894,8 @@ define([
|
|||
Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me));
|
||||
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
|
||||
Common.Gateway.on('setfavorite', _.bind(me.onSetFavorite, me));
|
||||
|
||||
Common.Gateway.on('requestclose', _.bind(me.onRequestClose, me));
|
||||
|
||||
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});
|
||||
|
||||
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
|
||||
|
|
|
@ -351,6 +351,10 @@ define([
|
|||
this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, true));
|
||||
},
|
||||
|
||||
onRequestClose: function() {
|
||||
Common.Gateway.requestClose();
|
||||
},
|
||||
|
||||
goBack: function(current) {
|
||||
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
|
||||
Common.Gateway.requestClose();
|
||||
|
@ -579,6 +583,7 @@ define([
|
|||
Common.Gateway.on('processsaveresult', _.bind(me.onProcessSaveResult, me));
|
||||
Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me));
|
||||
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
|
||||
Common.Gateway.on('requestclose', _.bind(me.onRequestClose, me));
|
||||
|
||||
Common.Gateway.sendInfo({
|
||||
mode: me.appOptions.isEdit ? 'edit' : 'view'
|
||||
|
|
|
@ -210,6 +210,7 @@ SSE.ApplicationController = new(function(){
|
|||
|
||||
Common.Gateway.on('processmouse', onProcessMouse);
|
||||
Common.Gateway.on('downloadas', onDownloadAs);
|
||||
Common.Gateway.on('requestclose', onRequestClose);
|
||||
|
||||
SSE.ApplicationView.tools.get('#idt-fullscreen')
|
||||
.on('click', function(){
|
||||
|
@ -499,6 +500,10 @@ SSE.ApplicationController = new(function(){
|
|||
}
|
||||
}
|
||||
|
||||
function onRequestClose() {
|
||||
Common.Gateway.requestClose();
|
||||
}
|
||||
|
||||
function onDownloadAs() {
|
||||
if ( permissions.download === false) {
|
||||
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
|
||||
|
|
|
@ -548,32 +548,37 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onRequestClose: function() {
|
||||
var me = this;
|
||||
if (this.api.asc_isDocumentModified()) {
|
||||
this.api.asc_stopSaving();
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
width: 500,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.leavePageTextOnClose,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_undoAllChanges();
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
} else
|
||||
me.api.asc_continueSaving();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
}
|
||||
},
|
||||
|
||||
goBack: function(current) {
|
||||
var me = this;
|
||||
if ( !Common.Controllers.Desktop.process('goback') ) {
|
||||
if (me.appOptions.customization.goback.requestClose && me.appOptions.canRequestClose) {
|
||||
if (this.api.asc_isDocumentModified()) {
|
||||
this.api.asc_stopSaving();
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
width: 500,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.leavePageTextOnClose,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_undoAllChanges();
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
} else
|
||||
me.api.asc_continueSaving();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Common.Gateway.requestClose();
|
||||
// Common.Controllers.Desktop.requestClose();
|
||||
}
|
||||
me.onRequestClose();
|
||||
} else {
|
||||
var href = me.appOptions.customization.goback.url;
|
||||
if (!current && me.appOptions.customization.goback.blank!==false) {
|
||||
|
@ -944,6 +949,7 @@ define([
|
|||
Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me));
|
||||
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
|
||||
Common.Gateway.on('setfavorite', _.bind(me.onSetFavorite, me));
|
||||
Common.Gateway.on('requestclose', _.bind(me.onRequestClose, me));
|
||||
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});
|
||||
|
||||
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
|
||||
|
|
|
@ -362,6 +362,10 @@ define([
|
|||
this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.XLSX, true));
|
||||
},
|
||||
|
||||
onRequestClose: function() {
|
||||
Common.Gateway.requestClose();
|
||||
},
|
||||
|
||||
goBack: function(current) {
|
||||
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
|
||||
Common.Gateway.requestClose();
|
||||
|
@ -600,6 +604,7 @@ define([
|
|||
Common.Gateway.on('processsaveresult', _.bind(me.onProcessSaveResult, me));
|
||||
Common.Gateway.on('processrightschange', _.bind(me.onProcessRightsChange, me));
|
||||
Common.Gateway.on('downloadas', _.bind(me.onDownloadAs, me));
|
||||
Common.Gateway.on('requestclose', _.bind(me.onRequestClose, me));
|
||||
|
||||
Common.Gateway.sendInfo({
|
||||
mode: me.appOptions.isEdit ? 'edit' : 'view'
|
||||
|
|
Loading…
Reference in a new issue