Commit 72b8ff05 authored by Alexander.Trofimov's avatar Alexander.Trofimov

delete rData

добавил onFirstConnect callback на первое соединение с сервером (на этой функции мы вызываем getPermissions)


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64742 954022d7-b5bf-4e40-9824-e11837661b57
parent e76d89ef
......@@ -28,10 +28,11 @@
this.onUnSaveLock = options.onUnSaveLock;
this.onRecalcLocks = options.onRecalcLocks;
this.onDocumentOpen = options.onDocumentOpen;
this.onFirstConnect = options.onFirstConnect;
}
}
CDocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, callback, editorType, documentFormatSave, isViewer) {
CDocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, isViewer) {
if (this._CoAuthoringApi && this._CoAuthoringApi.isRightURL()) {
var t = this;
this._CoAuthoringApi.onAuthParticipantsChanged = function(e, count) {
......@@ -83,11 +84,15 @@
this._CoAuthoringApi.onDocumentOpen = function(data) {
t.callback_OnDocumentOpen(data);
};
this._CoAuthoringApi.onFirstConnect = function() {
t.callback_OnFirstConnect();
};
this._CoAuthoringApi.init(user, docid, documentCallbackUrl, token, callback, editorType, documentFormatSave, isViewer);
this._CoAuthoringApi.init(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, isViewer);
this._onlineWork = true;
} else {
// Фиктивные вызовы
this.onFirstConnect();
this.callback_OnSetIndexUser("123");
this.onFirstLoadChangesEnd();
callback();
......@@ -335,6 +340,11 @@
this.onDocumentOpen(e);
}
};
CDocsCoApi.prototype.callback_OnFirstConnect = function() {
if (this.onFirstConnect) {
this.onFirstConnect();
}
};
function LockBufferElement(arrayBlockId, callback) {
this._arrayBlockId = arrayBlockId;
......@@ -351,13 +361,13 @@
this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks
this.onRelockFailed = options.onRelockFailed;
this.onDisconnect = options.onDisconnect;
this.onConnect = options.onConnect;
this.onSaveChanges = options.onSaveChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged;
this.onUnSaveLock = options.onUnSaveLock;
this.onRecalcLocks = options.onRecalcLocks;
this.onDocumentOpen = options.onDocumentOpen;
this.onFirstConnect = options.onFirstConnect;
}
this._state = ConnectionState.None;
// Online-пользователи в документе
......@@ -408,7 +418,6 @@
this._token = null;
this._user = null;
this._userId = "Anonymous";
this._initCallback = null;
this.ownedLockBlocks = [];
this.sockjs_url = null;
this.sockjs = null;
......@@ -1050,17 +1059,14 @@
this._sendPrebuffered();
}
//TODO: Add errors
if (this._initCallback) {
this._initCallback({result: data["result"]});
}
this.onFirstConnect();
};
DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, callback, editorType, documentFormatSave, isViewer) {
DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, isViewer) {
this._user = user;
this._docid = docid;
this._documentCallbackUrl = documentCallbackUrl;
this._token = token;
this._initCallback = callback;
this.ownedLockBlocks = [];
this.sockjs_url = '/doc/' + docid + '/c';
this.editorType = editorType;
......@@ -1089,9 +1095,6 @@
}
t._state = ConnectionState.WaitAuth;
if (t.onConnect) {
t.onConnect();
}
if (t._locks) {
t.ownedLockBlocks = [];
//If we already have locks
......
......@@ -547,26 +547,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
};
spreadsheet_api.prototype.asc_getEditorPermissions = function() {
var t = this;
this._coAuthoringInit(function() {
if (t.DocInfo && t.DocInfo["Id"] && t.DocInfo["Url"]) {
var rdata = {
"c": "getsettings",
"id": t.DocInfo["Id"],
"userid": t.DocInfo["UserId"],
"format": t.DocInfo["Format"],
"vkey": t.DocInfo["VKey"],
"editorid": c_oEditorId.Spreadsheet
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rdata);
} else {
// Фиктивный режим, фактически без документа
t.handlers.trigger("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
}
});
this._coAuthoringInit();
};
spreadsheet_api.prototype.asc_getLicense = function() {
......@@ -1399,7 +1380,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
/////////////////////////////////////////////////////////////////////////
///////////////////CoAuthoring and Chat api//////////////////////////////
/////////////////////////////////////////////////////////////////////////
spreadsheet_api.prototype._coAuthoringInit = function(fCallback) {
spreadsheet_api.prototype._coAuthoringInit = function() {
var t = this;
//Если User не задан, отключаем коавторинг.
......@@ -1649,6 +1630,25 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.CoAuthoringApi.onEndCoAuthoring = function(isStartEvent) {
t.endCollaborationEditing();
};
this.CoAuthoringApi.onFirstConnect = function() {
if (t.DocInfo && t.DocInfo["Id"] && t.DocInfo["Url"]) {
var rdata = {
"c": "getsettings",
"id": t.DocInfo["Id"],
"userid": t.DocInfo["UserId"],
"format": t.DocInfo["Format"],
"vkey": t.DocInfo["VKey"],
"editorid": c_oEditorId.Spreadsheet
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rdata);
} else {
// Фиктивный режим, фактически без документа
t.handlers.trigger("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
}
};
/**
* Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной
......@@ -1719,7 +1719,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (!(window["NATIVE_EDITOR_ENJINE"] || !this.documentId || !this.documentUrl)) {
this.CoAuthoringApi.set_url(null);
}
this.CoAuthoringApi.init(t.User, t.documentId, t.documentCallbackUrl, 'fghhfgsjdgfjs', fCallback, c_oEditorId.Spreadsheet, t.documentFormatSave, t.asc_getViewerMode());
this.CoAuthoringApi.init(t.User, t.documentId, t.documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Spreadsheet, t.documentFormatSave, t.asc_getViewerMode());
};
spreadsheet_api.prototype._onSaveChanges = function(recalcIndexColumns, recalcIndexRows) {
......@@ -3477,8 +3477,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
g_oIdCounter.Set_Load(false);
this._coAuthoringInit(function() {
});
this._coAuthoringInit();
this.wb = new asc.WorkbookView(this.wbModel, this.controller, this.handlers, window["_null_object"], window["_null_object"], this, this.collaborativeEditing, this.fontRenderingMode);
};
......
......@@ -235,7 +235,7 @@ CChatMessage.prototype.get_Message = function() { return this.Message; };
ToDo Register Callback OnCoAuthoringDisconnectUser возвращается userId
*/
// Init CoAuthoring
asc_docs_api.prototype._coAuthoringInit = function (fCallback) {
asc_docs_api.prototype._coAuthoringInit = function () {
if (null == this.User || null == this.User.asc_getId()) {
this.User = new Asc.asc_CUser();
this.User.asc_setId("Unknown");
......@@ -465,6 +465,27 @@ asc_docs_api.prototype._coAuthoringInit = function (fCallback) {
t.WordControl.m_oLogicDocument.DrawingDocument.FirePaint();
}
};
this.CoAuthoringApi.onFirstConnect = function() {
if (t.DocInfo && t.DocInfo.get_Id()) {
var rData = {
"c": "getsettings",
"id": t.DocInfo.get_Id(),
"userid": t.DocInfo.get_UserId(),
"format": t.DocInfo.get_Format(),
"vkey": t.DocInfo.get_VKey(),
"editorid": c_oEditorId.Presentation
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
}
};
/**
* Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной
......@@ -527,8 +548,7 @@ asc_docs_api.prototype._coAuthoringInit = function (fCallback) {
if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){
this.CoAuthoringApi.set_url(null);
}
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', fCallback, c_oEditorId.Presentation,
documentFormatSave, this.isViewMode);
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Presentation, documentFormatSave);
// ToDo init other callbacks
};
......@@ -696,28 +716,7 @@ asc_docs_api.prototype.Init = function()
this.WordControl.Init();
};
asc_docs_api.prototype.asc_getEditorPermissions = function() {
var t = this;
this._coAuthoringInit(function(){
if (t.DocInfo && t.DocInfo.get_Id()) {
var rData = {
"c": "getsettings",
"id": t.DocInfo.get_Id(),
"userid": t.DocInfo.get_UserId(),
"format": t.DocInfo.get_Format(),
"vkey": t.DocInfo.get_VKey(),
"editorid": c_oEditorId.Presentation
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
}
});
this._coAuthoringInit();
};
asc_docs_api.prototype.asc_getLicense = function () {
......@@ -4582,7 +4581,7 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard)
editor.WordControl.IsFocus = false;
return ret;
}
}
};
window.ID_KEYBOARD_AREA.onkeydown = function(e){
if (false === editor.WordControl.IsFocus)
{
......@@ -4591,7 +4590,7 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard)
editor.WordControl.IsFocus = false;
return ret;
}
}
};
}
window.ID_KEYBOARD_AREA.focus();
};
......@@ -5081,7 +5080,6 @@ function _sendCommandCallback (fCallback, error, result) {
return;
}
var rData;
switch(result["type"]){
case "updateversion":
if (editor.isViewMode)
......
......@@ -726,29 +726,7 @@ asc_docs_api.prototype.Init = function()
this.WordControl.Init();
};
asc_docs_api.prototype.asc_getEditorPermissions = function() {
var t = this;
this._coAuthoringInit(function() {
if (t.DocInfo && t.DocInfo.get_Id()) {
var rData = {
"c": "getsettings",
"id": t.DocInfo.get_Id(),
"userid": t.DocInfo.get_UserId(),
"format": t.DocInfo.get_Format(),
"vkey": t.DocInfo.get_VKey(),
"editorid": c_oEditorId.Word
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
t._coSpellCheckInit();
}
});
this._coAuthoringInit();
};
asc_docs_api.prototype.asc_getLicense = function ()
......@@ -1289,7 +1267,7 @@ asc_docs_api.prototype._coAuthoringSetChanges = function(e, oColor)
this._coAuthoringSetChange(e[Index], oColor);
};
asc_docs_api.prototype._coAuthoringInit = function(fCallback)
asc_docs_api.prototype._coAuthoringInit = function()
{
//Если User не задан, отключаем коавторинг.
if (null == this.User || null == this.User.asc_getId()) {
......@@ -1434,6 +1412,28 @@ asc_docs_api.prototype._coAuthoringInit = function(fCallback)
CollaborativeEditing.End_CollaborationEditing();
editor.asc_setDrawCollaborationMarks(false);
};
this.CoAuthoringApi.onFirstConnect = function() {
if (t.DocInfo && t.DocInfo.get_Id()) {
var rData = {
"c": "getsettings",
"id": t.DocInfo.get_Id(),
"userid": t.DocInfo.get_UserId(),
"format": t.DocInfo.get_Format(),
"vkey": t.DocInfo.get_VKey(),
"editorid": c_oEditorId.Word
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
t._coSpellCheckInit();
}
};
/**
* Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной
......@@ -1495,7 +1495,7 @@ asc_docs_api.prototype._coAuthoringInit = function(fCallback)
if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){
this.CoAuthoringApi.set_url(null);
}
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', fCallback,
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs',
c_oEditorId.Word, documentFormatSave, this.isViewMode);
// ToDo init other callbacks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment