Commit 97e14bf6 authored by Alexander.Trofimov's avatar Alexander.Trofimov

common/docscoapicommon and common/docscoapi to function-closure

parent b4323f09
...@@ -1592,7 +1592,7 @@ var editor; ...@@ -1592,7 +1592,7 @@ var editor;
this.collaborativeEditing.sendChanges(this.IsUserSave); this.collaborativeEditing.sendChanges(this.IsUserSave);
} else { } else {
nState = t.CoAuthoringApi.get_state(); nState = t.CoAuthoringApi.get_state();
if (ConnectionState.Close === nState) { if (AscCommon.ConnectionState.Close === nState) {
// Отключаемся от сохранения, соединение потеряно // Отключаемся от сохранения, соединение потеряно
if (this.IsUserSave) { if (this.IsUserSave) {
this.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save); this.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
...@@ -3103,7 +3103,7 @@ var editor; ...@@ -3103,7 +3103,7 @@ var editor;
this.SpellCheckUrl = ''; this.SpellCheckUrl = '';
this.User = new asc.asc_CUser(); this.User = new AscCommon.asc_CUser();
this.User.setId("TM"); this.User.setId("TM");
this.User.setUserName("native"); this.User.setUserName("native");
......
...@@ -46,12 +46,15 @@ var History = {}; ...@@ -46,12 +46,15 @@ var History = {};
window["Asc"] = {}; window["Asc"] = {};
var Asc = window["Asc"]; var Asc = window["Asc"];
window["AscCommonExcel"] = {};
var AscCommonExcel = window["AscCommonExcel"];
window["AscBrowser"] = {}; window["AscBrowser"] = {};
var AscBrowser = window["AscBrowser"]; var AscBrowser = window["AscBrowser"];
window["AscCommon"] = {};
var AscCommon = window["AscCommon"];
window["AscCommonExcel"] = {};
var AscCommonExcel = window["AscCommonExcel"];
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
aStandartNumFormats = []; aStandartNumFormats = [];
aStandartNumFormats[0] = "General"; aStandartNumFormats[0] = "General";
......
...@@ -191,11 +191,11 @@ function DesktopOfflineUpdateLocalName(_api) ...@@ -191,11 +191,11 @@ function DesktopOfflineUpdateLocalName(_api)
window["AscDesktopEditor"]["SetDocumentName"](_name); window["AscDesktopEditor"]["SetDocumentName"](_name);
} }
Asc.CDocsCoApi.prototype.askSaveChanges = function(callback) AscCommon.CDocsCoApi.prototype.askSaveChanges = function(callback)
{ {
callback({"saveLock": false}); callback({"saveLock": false});
}; };
Asc.CDocsCoApi.prototype.saveChanges = function(arrayChanges, deleteIndex, excelAdditionalInfo) AscCommon.CDocsCoApi.prototype.saveChanges = function(arrayChanges, deleteIndex, excelAdditionalInfo)
{ {
window["AscDesktopEditor"]["LocalFileSaveChanges"](arrayChanges.join("\",\""), deleteIndex, arrayChanges.length); window["AscDesktopEditor"]["LocalFileSaveChanges"](arrayChanges.join("\",\""), deleteIndex, arrayChanges.length);
//this.onUnSaveLock(); //this.onUnSaveLock();
......
...@@ -186,8 +186,9 @@ native_canvas.prototype = ...@@ -186,8 +186,9 @@ native_canvas.prototype =
}; };
window["Asc"] = {}; window["Asc"] = {};
window["AscCommonExcel"] = {};
window["AscBrowser"] = {}; window["AscBrowser"] = {};
window["AscCommon"] = {};
window["AscCommonExcel"] = {};
var _null_object = {}; var _null_object = {};
_null_object.length = 0; _null_object.length = 0;
...@@ -281,8 +282,9 @@ function GetNativeEngine() ...@@ -281,8 +282,9 @@ function GetNativeEngine()
var native_renderer = null; var native_renderer = null;
var _api = null; var _api = null;
var Asc = window["Asc"]; var Asc = window["Asc"];
var AscCommonExcel = window["AscCommonExcel"];
var AscBrowser = window["AscBrowser"]; var AscBrowser = window["AscBrowser"];
var AscCommon = window["AscCommon"];
var AscCommonExcel = window["AscCommonExcel"];
function NativeOpenFileData(data, version) function NativeOpenFileData(data, version)
{ {
......
...@@ -92,7 +92,7 @@ function baseEditorsApi(name) { ...@@ -92,7 +92,7 @@ function baseEditorsApi(name) {
// CoAuthoring and Chat // CoAuthoring and Chat
this.User = undefined; this.User = undefined;
this.CoAuthoringApi = new Asc.CDocsCoApi(); this.CoAuthoringApi = new AscCommon.CDocsCoApi();
this.isCoAuthoringEnable = true; this.isCoAuthoringEnable = true;
// Массив lock-ов, которые были на открытии документа // Массив lock-ов, которые были на открытии документа
this.arrPreOpenLocksObjects = []; this.arrPreOpenLocksObjects = [];
...@@ -190,7 +190,7 @@ baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo) { ...@@ -190,7 +190,7 @@ baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo) {
this.documentOpenOptions = this.DocInfo.asc_getOptions(); this.documentOpenOptions = this.DocInfo.asc_getOptions();
this.User = new Asc.asc_CUser(); this.User = new AscCommon.asc_CUser();
this.User.setId(this.DocInfo.get_UserId()); this.User.setId(this.DocInfo.get_UserId());
this.User.setUserName(this.DocInfo.get_UserName()); this.User.setUserName(this.DocInfo.get_UserName());
} }
...@@ -395,7 +395,7 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -395,7 +395,7 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
var t = this; var t = this;
//Если User не задан, отключаем коавторинг. //Если User не задан, отключаем коавторинг.
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 AscCommon.asc_CUser();
this.User.setId("Unknown"); this.User.setId("Unknown");
this.User.setUserName("Unknown"); this.User.setUserName("Unknown");
} }
...@@ -443,7 +443,7 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -443,7 +443,7 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
* @param {Bool} isCloseCoAuthoring * @param {Bool} isCloseCoAuthoring
*/ */
this.CoAuthoringApi.onDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring) { this.CoAuthoringApi.onDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring) {
if (ConnectionState.None === t.CoAuthoringApi.get_state()) { if (AscCommon.ConnectionState.None === t.CoAuthoringApi.get_state()) {
t.asyncServerIdEndLoaded(); t.asyncServerIdEndLoaded();
} }
if (isDisconnectAtAll) { if (isDisconnectAtAll) {
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
(function(window, undefined) { (function(window, undefined) {
'use strict'; 'use strict';
var asc = window["Asc"];
var asc_coAuthV = '3.0.9'; var asc_coAuthV = '3.0.9';
var ConnectionState = AscCommon.ConnectionState;
// Класс надстройка, для online и offline работы // Класс надстройка, для online и offline работы
function CDocsCoApi(options) { function CDocsCoApi(options) {
...@@ -1019,7 +1019,7 @@ ...@@ -1019,7 +1019,7 @@
if (participants) { if (participants) {
var tmpUser; var tmpUser;
for (var i = 0; i < participants.length; ++i) { for (var i = 0; i < participants.length; ++i) {
tmpUser = new asc.asc_CUser(participants[i]); tmpUser = new AscCommon.asc_CUser(participants[i]);
this._participants[tmpUser.asc_getId()] = tmpUser; this._participants[tmpUser.asc_getId()] = tmpUser;
// Считаем только число редакторов // Считаем только число редакторов
if (!tmpUser.asc_getView()) { if (!tmpUser.asc_getView()) {
...@@ -1044,7 +1044,7 @@ ...@@ -1044,7 +1044,7 @@
DocsCoApi.prototype._onConnectionStateChanged = function(data) { DocsCoApi.prototype._onConnectionStateChanged = function(data) {
var userStateChanged = null, userId, stateChanged = false, isEditUser = true; var userStateChanged = null, userId, stateChanged = false, isEditUser = true;
if (this.onConnectionStateChanged) { if (this.onConnectionStateChanged) {
userStateChanged = new asc.asc_CUser(data['user']); userStateChanged = new AscCommon.asc_CUser(data['user']);
userStateChanged.setState(data["state"]); userStateChanged.setState(data["state"]);
userId = userStateChanged.asc_getId(); userId = userStateChanged.asc_getId();
...@@ -1336,5 +1336,7 @@ ...@@ -1336,5 +1336,7 @@
return window['SockJS'] ? window['SockJS'] : require('sockjs'); return window['SockJS'] ? window['SockJS'] : require('sockjs');
}; };
asc.CDocsCoApi = CDocsCoApi; //----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].CDocsCoApi = CDocsCoApi;
})(window); })(window);
\ No newline at end of file
...@@ -34,13 +34,6 @@ ...@@ -34,13 +34,6 @@
* @param {undefined} undefined * @param {undefined} undefined
*/ */
function(window, undefined) { function(window, undefined) {
/*
* Import
* -----------------------------------------------------------------------------
*/
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
var prot;
/** /**
* Класс user для совместного редактирования/просмотра документа * Класс user для совместного редактирования/просмотра документа
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
...@@ -96,26 +89,30 @@ ...@@ -96,26 +89,30 @@
this.state = val; this.state = val;
}; };
var ConnectionState = {
Reconnect: -1, // reconnect state
None: 0, // not initialized
WaitAuth: 1, // waiting session id
Authorized: 2, // authorized
ClosedCoAuth: 3, // closed coauthoring
ClosedAll: 4, // closed all
SaveChanges: 10 // save
};
/* /*
* Export * Export
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
window["Asc"].asc_CUser = asc_CUser; var prot;
window['AscCommon'] = window['AscCommon'] || {};
window["AscCommon"].asc_CUser = asc_CUser;
prot = asc_CUser.prototype; prot = asc_CUser.prototype;
prot["asc_getId"] = prot.asc_getId; prot["asc_getId"] = prot.asc_getId;
prot["asc_getUserName"] = prot.asc_getUserName; prot["asc_getUserName"] = prot.asc_getUserName;
prot["asc_getState"] = prot.asc_getState; prot["asc_getState"] = prot.asc_getState;
prot["asc_getColor"] = prot.asc_getColor; prot["asc_getColor"] = prot.asc_getColor;
prot["asc_getView"] = prot.asc_getView; prot["asc_getView"] = prot.asc_getView;
})(window);
var ConnectionState = {
Reconnect: -1, // reconnect state
None: 0, // not initialized
WaitAuth: 1, // waiting session id
Authorized: 2, // authorized
ClosedCoAuth: 3, // closed coauthoring
ClosedAll: 4, // closed all
SaveChanges: 10 // save window["AscCommon"].ConnectionState = ConnectionState;
}; })(window);
\ No newline at end of file
...@@ -1195,7 +1195,7 @@ function OnSave_Callback(e) { ...@@ -1195,7 +1195,7 @@ function OnSave_Callback(e) {
CollaborativeEditing.Send_Changes(editor.IsUserSave, {UserId: editor.CoAuthoringApi.getUserConnectionId(), UserShortId : editor.DocInfo.get_UserId(), CursorInfo: CursorInfo}); CollaborativeEditing.Send_Changes(editor.IsUserSave, {UserId: editor.CoAuthoringApi.getUserConnectionId(), UserShortId : editor.DocInfo.get_UserId(), CursorInfo: CursorInfo});
} else { } else {
var nState = editor.CoAuthoringApi.get_state(); var nState = editor.CoAuthoringApi.get_state();
if (ConnectionState.Close === nState) { if (AscCommon.ConnectionState.Close === nState) {
// Отключаемся от сохранения, соединение потеряно // Отключаемся от сохранения, соединение потеряно
editor.canSave = true; editor.canSave = true;
editor.IsUserSave = false; editor.IsUserSave = false;
...@@ -4795,7 +4795,7 @@ window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, ve ...@@ -4795,7 +4795,7 @@ window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, ve
{ {
this.SpellCheckUrl = ''; this.SpellCheckUrl = '';
this.User = new Asc.asc_CUser(); this.User = new AscCommon.asc_CUser();
this.User.setId("TM"); this.User.setId("TM");
this.User.setUserName("native"); this.User.setUserName("native");
......
...@@ -1986,7 +1986,7 @@ function OnSave_Callback(e) { ...@@ -1986,7 +1986,7 @@ function OnSave_Callback(e) {
CollaborativeEditing.Send_Changes(editor.IsUserSave, {UserId: editor.CoAuthoringApi.getUserConnectionId(), UserShortId : editor.DocInfo.get_UserId(), CursorInfo: CursorInfo}, HaveOtherChanges); CollaborativeEditing.Send_Changes(editor.IsUserSave, {UserId: editor.CoAuthoringApi.getUserConnectionId(), UserShortId : editor.DocInfo.get_UserId(), CursorInfo: CursorInfo}, HaveOtherChanges);
} else { } else {
var nState = editor.CoAuthoringApi.get_state(); var nState = editor.CoAuthoringApi.get_state();
if (ConnectionState.Close === nState) { if (AscCommon.ConnectionState.Close === nState) {
// Отключаемся от сохранения, соединение потеряно // Отключаемся от сохранения, соединение потеряно
editor.canSave = true; editor.canSave = true;
editor.IsUserSave = false; editor.IsUserSave = false;
...@@ -7145,7 +7145,7 @@ window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, ve ...@@ -7145,7 +7145,7 @@ window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, ve
{ {
this.SpellCheckUrl = ''; this.SpellCheckUrl = '';
this.User = new Asc.asc_CUser(); this.User = new AscCommon.asc_CUser();
this.User.setId("TM"); this.User.setId("TM");
this.User.setUserName("native"); this.User.setUserName("native");
...@@ -7189,11 +7189,11 @@ window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, ve ...@@ -7189,11 +7189,11 @@ window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, ve
if (window["NATIVE_EDITOR_ENJINE"] === true && undefined != window["native"]) if (window["NATIVE_EDITOR_ENJINE"] === true && undefined != window["native"])
{ {
Asc.CDocsCoApi.prototype.askSaveChanges = function(callback) AscCommon.CDocsCoApi.prototype.askSaveChanges = function(callback)
{ {
callback({"saveLock": false}); callback({"saveLock": false});
}; };
Asc.CDocsCoApi.prototype.saveChanges = function(arrayChanges, deleteIndex, excelAdditionalInfo) AscCommon.CDocsCoApi.prototype.saveChanges = function(arrayChanges, deleteIndex, excelAdditionalInfo)
{ {
if (window["native"]["SaveChanges"]) if (window["native"]["SaveChanges"])
window["native"]["SaveChanges"](arrayChanges.join("\",\""), deleteIndex, arrayChanges.length); window["native"]["SaveChanges"](arrayChanges.join("\",\""), deleteIndex, arrayChanges.length);
......
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