[SSE] Use sdk protect functions
This commit is contained in:
parent
05099e883c
commit
8bb87afdee
|
@ -82,6 +82,7 @@ define([
|
||||||
setApi: function (api) {
|
setApi: function (api) {
|
||||||
if (api) {
|
if (api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this));
|
||||||
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
|
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -108,38 +109,60 @@ define([
|
||||||
onWorkbookClick: function(state) {
|
onWorkbookClick: function(state) {
|
||||||
if (state) {
|
if (state) {
|
||||||
var me = this,
|
var me = this,
|
||||||
|
btn,
|
||||||
win = new SSE.Views.ProtectDialog({
|
win = new SSE.Views.ProtectDialog({
|
||||||
title: me.view.txtWBTitle,
|
title: me.view.txtWBTitle,
|
||||||
txtDescription: me.view.txtWBDescription,
|
txtDescription: me.view.txtWBDescription,
|
||||||
height: 306,
|
height: 306,
|
||||||
handler: function(result, props) {
|
handler: function(result, value) {
|
||||||
|
btn = result;
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook());
|
var props = new Asc.CWorkbookProtection();
|
||||||
|
props.asc_setLockStructure(true);
|
||||||
|
value && props.asc_setPassword(value);
|
||||||
|
me.api.asc_setProtectedWorkbook(props);
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete');
|
Common.NotificationCenter.trigger('edit:complete');
|
||||||
}
|
}
|
||||||
|
}).on('close', function() {
|
||||||
|
if (btn!=='ok')
|
||||||
|
me.view.btnProtectWB.toggle(false, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
win.show();
|
win.show();
|
||||||
} else {
|
} else {
|
||||||
var me = this,
|
var me = this,
|
||||||
win = new Common.Views.OpenDialog({
|
btn,
|
||||||
title: me.view.txtWBUnlockTitle,
|
props = me.api.asc_getProtectedWorkbook();
|
||||||
closable: true,
|
if (props.asc_isPassword()) {
|
||||||
type: Common.Utils.importTextType.DRM,
|
var win = new Common.Views.OpenDialog({
|
||||||
txtOpenFile: me.view.txtWBUnlockDescription,
|
title: me.view.txtWBUnlockTitle,
|
||||||
validatePwd: false,
|
closable: true,
|
||||||
handler: function (result, value) {
|
type: Common.Utils.importTextType.DRM,
|
||||||
if (result == 'ok') {
|
txtOpenFile: me.view.txtWBUnlockDescription,
|
||||||
if (me.api) {
|
validatePwd: false,
|
||||||
me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook());
|
handler: function (result, value) {
|
||||||
|
btn = result;
|
||||||
|
if (result == 'ok') {
|
||||||
|
if (me.api) {
|
||||||
|
props = new Asc.CWorkbookProtection();
|
||||||
|
props.asc_setLockStructure(false, value);
|
||||||
|
me.api.asc_setProtectedWorkbook(props);
|
||||||
|
}
|
||||||
|
Common.NotificationCenter.trigger('edit:complete');
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete');
|
|
||||||
}
|
}
|
||||||
}
|
}).on('close', function() {
|
||||||
});
|
if (btn!=='ok')
|
||||||
|
me.view.btnProtectWB.toggle(true, true);
|
||||||
|
});
|
||||||
|
|
||||||
win.show();
|
win.show();
|
||||||
|
} else {
|
||||||
|
props = new Asc.CWorkbookProtection();
|
||||||
|
props.asc_setLockStructure(false);
|
||||||
|
me.api.asc_setProtectedWorkbook(props);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -194,6 +217,10 @@ define([
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onChangeProtectWorkbook: function() {
|
||||||
|
this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true);
|
||||||
|
},
|
||||||
|
|
||||||
onCoAuthoringDisconnect: function() {
|
onCoAuthoringDisconnect: function() {
|
||||||
this.SetDisabled(true);
|
this.SetDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue