[DE forms] Add onDocumentStateChange event
This commit is contained in:
parent
269d3a0b9a
commit
ed471509c5
|
@ -53,7 +53,7 @@ define([
|
|||
weakCompare : function(obj1, obj2){return obj1.type === obj2.type;}
|
||||
});
|
||||
|
||||
this._state = {isDisconnected: false, licenseType: false};
|
||||
this._state = {isDisconnected: false, licenseType: false, isDocModified: false};
|
||||
|
||||
this.view = this.createView('ApplicationView').render();
|
||||
|
||||
|
@ -102,6 +102,7 @@ define([
|
|||
this.api.asc_registerCallback('asc_onAdvancedOptions', this.onAdvancedOptions.bind(this));
|
||||
this.api.asc_registerCallback('asc_onCountPages', this.onCountPages.bind(this));
|
||||
this.api.asc_registerCallback('asc_onCurrentPage', this.onCurrentPage.bind(this));
|
||||
this.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(this.onDocumentModifiedChanged, this));
|
||||
|
||||
// Initialize api gateway
|
||||
Common.Gateway.on('init', this.loadConfig.bind(this));
|
||||
|
@ -361,6 +362,23 @@ define([
|
|||
this.view.txtGoToPage.setValue(number + 1);
|
||||
},
|
||||
|
||||
updateWindowTitle: function(force) {
|
||||
var isModified = this.api.isDocumentModified();
|
||||
if (this._state.isDocModified !== isModified || force) {
|
||||
this._isDocReady && (this._state.isDocModified !== isModified) && Common.Gateway.setDocumentModified(isModified);
|
||||
this._state.isDocModified = isModified;
|
||||
}
|
||||
},
|
||||
|
||||
onDocumentModifiedChanged: function() {
|
||||
var isModified = this.api.asc_isDocumentCanSave();
|
||||
if (this._state.isDocModified !== isModified) {
|
||||
this._isDocReady && Common.Gateway.setDocumentModified(this.api.isDocumentModified());
|
||||
}
|
||||
|
||||
this.updateWindowTitle();
|
||||
},
|
||||
|
||||
loadConfig: function(data) {
|
||||
this.editorConfig = $.extend(this.editorConfig, data.config);
|
||||
this.embedConfig = $.extend(this.embedConfig, data.config.embedded);
|
||||
|
@ -718,6 +736,8 @@ define([
|
|||
var action = {id: id, type: type};
|
||||
this.stackLongActions.pop(action);
|
||||
|
||||
this.updateWindowTitle(true);
|
||||
|
||||
action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.Information});
|
||||
action && this.setLongActionView(action);
|
||||
action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.BlockInteraction});
|
||||
|
@ -1265,8 +1285,11 @@ define([
|
|||
},
|
||||
|
||||
onDocumentContentReady: function() {
|
||||
var me = this;
|
||||
if (this._isDocReady)
|
||||
return;
|
||||
|
||||
var me = this;
|
||||
me._isDocReady = true;
|
||||
this.hidePreloader();
|
||||
this.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
|
||||
|
||||
|
@ -1295,6 +1318,8 @@ define([
|
|||
Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this)); // set loaded image to control
|
||||
}
|
||||
|
||||
this.updateWindowTitle(true);
|
||||
|
||||
if (this.editorConfig.mode !== 'view') // if want to open editor, but viewer is loaded
|
||||
this.applyLicense();
|
||||
|
||||
|
|
Loading…
Reference in a new issue