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 @@ ...@@ -28,10 +28,11 @@
this.onUnSaveLock = options.onUnSaveLock; this.onUnSaveLock = options.onUnSaveLock;
this.onRecalcLocks = options.onRecalcLocks; this.onRecalcLocks = options.onRecalcLocks;
this.onDocumentOpen = options.onDocumentOpen; 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()) { if (this._CoAuthoringApi && this._CoAuthoringApi.isRightURL()) {
var t = this; var t = this;
this._CoAuthoringApi.onAuthParticipantsChanged = function(e, count) { this._CoAuthoringApi.onAuthParticipantsChanged = function(e, count) {
...@@ -83,11 +84,15 @@ ...@@ -83,11 +84,15 @@
this._CoAuthoringApi.onDocumentOpen = function(data) { this._CoAuthoringApi.onDocumentOpen = function(data) {
t.callback_OnDocumentOpen(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; this._onlineWork = true;
} else { } else {
// Фиктивные вызовы // Фиктивные вызовы
this.onFirstConnect();
this.callback_OnSetIndexUser("123"); this.callback_OnSetIndexUser("123");
this.onFirstLoadChangesEnd(); this.onFirstLoadChangesEnd();
callback(); callback();
...@@ -335,6 +340,11 @@ ...@@ -335,6 +340,11 @@
this.onDocumentOpen(e); this.onDocumentOpen(e);
} }
}; };
CDocsCoApi.prototype.callback_OnFirstConnect = function() {
if (this.onFirstConnect) {
this.onFirstConnect();
}
};
function LockBufferElement(arrayBlockId, callback) { function LockBufferElement(arrayBlockId, callback) {
this._arrayBlockId = arrayBlockId; this._arrayBlockId = arrayBlockId;
...@@ -351,13 +361,13 @@ ...@@ -351,13 +361,13 @@
this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks
this.onRelockFailed = options.onRelockFailed; this.onRelockFailed = options.onRelockFailed;
this.onDisconnect = options.onDisconnect; this.onDisconnect = options.onDisconnect;
this.onConnect = options.onConnect;
this.onSaveChanges = options.onSaveChanges; this.onSaveChanges = options.onSaveChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd; this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged; this.onConnectionStateChanged = options.onConnectionStateChanged;
this.onUnSaveLock = options.onUnSaveLock; this.onUnSaveLock = options.onUnSaveLock;
this.onRecalcLocks = options.onRecalcLocks; this.onRecalcLocks = options.onRecalcLocks;
this.onDocumentOpen = options.onDocumentOpen; this.onDocumentOpen = options.onDocumentOpen;
this.onFirstConnect = options.onFirstConnect;
} }
this._state = ConnectionState.None; this._state = ConnectionState.None;
// Online-пользователи в документе // Online-пользователи в документе
...@@ -408,7 +418,6 @@ ...@@ -408,7 +418,6 @@
this._token = null; this._token = null;
this._user = null; this._user = null;
this._userId = "Anonymous"; this._userId = "Anonymous";
this._initCallback = null;
this.ownedLockBlocks = []; this.ownedLockBlocks = [];
this.sockjs_url = null; this.sockjs_url = null;
this.sockjs = null; this.sockjs = null;
...@@ -1050,17 +1059,14 @@ ...@@ -1050,17 +1059,14 @@
this._sendPrebuffered(); this._sendPrebuffered();
} }
//TODO: Add errors //TODO: Add errors
if (this._initCallback) { this.onFirstConnect();
this._initCallback({result: data["result"]});
}
}; };
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._user = user;
this._docid = docid; this._docid = docid;
this._documentCallbackUrl = documentCallbackUrl; this._documentCallbackUrl = documentCallbackUrl;
this._token = token; this._token = token;
this._initCallback = callback;
this.ownedLockBlocks = []; this.ownedLockBlocks = [];
this.sockjs_url = '/doc/' + docid + '/c'; this.sockjs_url = '/doc/' + docid + '/c';
this.editorType = editorType; this.editorType = editorType;
...@@ -1089,9 +1095,6 @@ ...@@ -1089,9 +1095,6 @@
} }
t._state = ConnectionState.WaitAuth; t._state = ConnectionState.WaitAuth;
if (t.onConnect) {
t.onConnect();
}
if (t._locks) { if (t._locks) {
t.ownedLockBlocks = []; t.ownedLockBlocks = [];
//If we already have locks //If we already have locks
......
...@@ -547,26 +547,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -547,26 +547,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}; };
spreadsheet_api.prototype.asc_getEditorPermissions = function() { spreadsheet_api.prototype.asc_getEditorPermissions = function() {
var t = this; this._coAuthoringInit();
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'] : '';
}
});
}; };
spreadsheet_api.prototype.asc_getLicense = function() { spreadsheet_api.prototype.asc_getLicense = function() {
...@@ -1399,7 +1380,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1399,7 +1380,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
///////////////////CoAuthoring and Chat api////////////////////////////// ///////////////////CoAuthoring and Chat api//////////////////////////////
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
spreadsheet_api.prototype._coAuthoringInit = function(fCallback) { spreadsheet_api.prototype._coAuthoringInit = function() {
var t = this; var t = this;
//Если User не задан, отключаем коавторинг. //Если User не задан, отключаем коавторинг.
...@@ -1649,6 +1630,25 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1649,6 +1630,25 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.CoAuthoringApi.onEndCoAuthoring = function(isStartEvent) { this.CoAuthoringApi.onEndCoAuthoring = function(isStartEvent) {
t.endCollaborationEditing(); 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 об отсоединении от сервера * Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной * @param {jQuery} e event об отсоединении с причиной
...@@ -1719,7 +1719,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -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)) { if (!(window["NATIVE_EDITOR_ENJINE"] || !this.documentId || !this.documentUrl)) {
this.CoAuthoringApi.set_url(null); 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) { spreadsheet_api.prototype._onSaveChanges = function(recalcIndexColumns, recalcIndexRows) {
...@@ -3477,8 +3477,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -3477,8 +3477,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
} }
g_oIdCounter.Set_Load(false); 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); 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; }; ...@@ -235,7 +235,7 @@ CChatMessage.prototype.get_Message = function() { return this.Message; };
ToDo Register Callback OnCoAuthoringDisconnectUser возвращается userId ToDo Register Callback OnCoAuthoringDisconnectUser возвращается userId
*/ */
// Init CoAuthoring // Init CoAuthoring
asc_docs_api.prototype._coAuthoringInit = function (fCallback) { asc_docs_api.prototype._coAuthoringInit = function () {
if (null == this.User || null == this.User.asc_getId()) { if (null == this.User || null == this.User.asc_getId()) {
this.User = new Asc.asc_CUser(); this.User = new Asc.asc_CUser();
this.User.asc_setId("Unknown"); this.User.asc_setId("Unknown");
...@@ -465,6 +465,27 @@ asc_docs_api.prototype._coAuthoringInit = function (fCallback) { ...@@ -465,6 +465,27 @@ asc_docs_api.prototype._coAuthoringInit = function (fCallback) {
t.WordControl.m_oLogicDocument.DrawingDocument.FirePaint(); 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 об отсоединении от сервера * Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной * @param {jQuery} e event об отсоединении с причиной
...@@ -527,8 +548,7 @@ asc_docs_api.prototype._coAuthoringInit = function (fCallback) { ...@@ -527,8 +548,7 @@ asc_docs_api.prototype._coAuthoringInit = function (fCallback) {
if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){ if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){
this.CoAuthoringApi.set_url(null); this.CoAuthoringApi.set_url(null);
} }
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', fCallback, c_oEditorId.Presentation, this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Presentation, documentFormatSave);
documentFormatSave, this.isViewMode);
// ToDo init other callbacks // ToDo init other callbacks
}; };
...@@ -696,28 +716,7 @@ asc_docs_api.prototype.Init = function() ...@@ -696,28 +716,7 @@ asc_docs_api.prototype.Init = function()
this.WordControl.Init(); this.WordControl.Init();
}; };
asc_docs_api.prototype.asc_getEditorPermissions = function() { asc_docs_api.prototype.asc_getEditorPermissions = function() {
var t = this; this._coAuthoringInit();
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'] : '';
}
});
}; };
asc_docs_api.prototype.asc_getLicense = function () { asc_docs_api.prototype.asc_getLicense = function () {
...@@ -4582,7 +4581,7 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard) ...@@ -4582,7 +4581,7 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard)
editor.WordControl.IsFocus = false; editor.WordControl.IsFocus = false;
return ret; return ret;
} }
} };
window.ID_KEYBOARD_AREA.onkeydown = function(e){ window.ID_KEYBOARD_AREA.onkeydown = function(e){
if (false === editor.WordControl.IsFocus) if (false === editor.WordControl.IsFocus)
{ {
...@@ -4591,7 +4590,7 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard) ...@@ -4591,7 +4590,7 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard)
editor.WordControl.IsFocus = false; editor.WordControl.IsFocus = false;
return ret; return ret;
} }
} };
} }
window.ID_KEYBOARD_AREA.focus(); window.ID_KEYBOARD_AREA.focus();
}; };
...@@ -5081,7 +5080,6 @@ function _sendCommandCallback (fCallback, error, result) { ...@@ -5081,7 +5080,6 @@ function _sendCommandCallback (fCallback, error, result) {
return; return;
} }
var rData;
switch(result["type"]){ switch(result["type"]){
case "updateversion": case "updateversion":
if (editor.isViewMode) if (editor.isViewMode)
......
...@@ -726,29 +726,7 @@ asc_docs_api.prototype.Init = function() ...@@ -726,29 +726,7 @@ asc_docs_api.prototype.Init = function()
this.WordControl.Init(); this.WordControl.Init();
}; };
asc_docs_api.prototype.asc_getEditorPermissions = function() { asc_docs_api.prototype.asc_getEditorPermissions = function() {
var t = this; this._coAuthoringInit();
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();
}
});
}; };
asc_docs_api.prototype.asc_getLicense = function () asc_docs_api.prototype.asc_getLicense = function ()
...@@ -1289,7 +1267,7 @@ asc_docs_api.prototype._coAuthoringSetChanges = function(e, oColor) ...@@ -1289,7 +1267,7 @@ asc_docs_api.prototype._coAuthoringSetChanges = function(e, oColor)
this._coAuthoringSetChange(e[Index], oColor); this._coAuthoringSetChange(e[Index], oColor);
}; };
asc_docs_api.prototype._coAuthoringInit = function(fCallback) asc_docs_api.prototype._coAuthoringInit = function()
{ {
//Если User не задан, отключаем коавторинг. //Если User не задан, отключаем коавторинг.
if (null == this.User || null == this.User.asc_getId()) { if (null == this.User || null == this.User.asc_getId()) {
...@@ -1434,6 +1412,28 @@ asc_docs_api.prototype._coAuthoringInit = function(fCallback) ...@@ -1434,6 +1412,28 @@ asc_docs_api.prototype._coAuthoringInit = function(fCallback)
CollaborativeEditing.End_CollaborationEditing(); CollaborativeEditing.End_CollaborationEditing();
editor.asc_setDrawCollaborationMarks(false); 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 об отсоединении от сервера * Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной * @param {jQuery} e event об отсоединении с причиной
...@@ -1495,7 +1495,7 @@ asc_docs_api.prototype._coAuthoringInit = function(fCallback) ...@@ -1495,7 +1495,7 @@ asc_docs_api.prototype._coAuthoringInit = function(fCallback)
if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){ if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){
this.CoAuthoringApi.set_url(null); 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); c_oEditorId.Word, documentFormatSave, this.isViewMode);
// ToDo init other callbacks // 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