Commit d6cfdcb0 authored by Boris Kocherov's avatar Boris Kocherov

merge Local/api_jio.js with new api in Local/api.js

parent aa4ba803
/* /*
* (c) Copyright Ascensio System SIA 2010-2016 * (c) Copyright Ascensio System SIA 2010-2017
* *
* This program is a free software product. You can redistribute it and/or * This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL) * modify it under the terms of the GNU Affero General Public License (AGPL)
...@@ -53,7 +53,10 @@ var c_oAscError = Asc.c_oAscError; ...@@ -53,7 +53,10 @@ var c_oAscError = Asc.c_oAscError;
{ {
this.asc_registerCallback('asc_onDocumentContentReady', function(){ this.asc_registerCallback('asc_onDocumentContentReady', function(){
DesktopOfflineUpdateLocalName(window["Asc"]["editor"]); DesktopOfflineUpdateLocalName(window["Asc"]["editor"]);
//setTimeout(function(){window["UpdateInstallPlugins"]();}, 10);
}); });
this.jio_open(); this.jio_open();
}; };
...@@ -62,7 +65,7 @@ var c_oAscError = Asc.c_oAscError; ...@@ -62,7 +65,7 @@ var c_oAscError = Asc.c_oAscError;
//AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"](); //AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "") if (_data == "")
{ {
this.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.Critical); this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
return; return;
} }
...@@ -71,27 +74,39 @@ var c_oAscError = Asc.c_oAscError; ...@@ -71,27 +74,39 @@ var c_oAscError = Asc.c_oAscError;
DesktopOfflineUpdateLocalName(this); DesktopOfflineUpdateLocalName(this);
this.onUpdateDocumentModified(AscCommon.History.Is_Modified()); this.onUpdateDocumentModified(AscCommon.History.Have_Changes());
}; };
asc['spreadsheet_api'].prototype._onNeedParams = function(data) asc['spreadsheet_api'].prototype._onNeedParams = function(data, opt_isPassword)
{ {
var cp = JSON.parse("{\"codepage\":46,\"delimiter\":1}"); var options;
cp['encodings'] = AscCommon.getEncodingParams(); if(opt_isPassword){
this.handlers.trigger("asc_onAdvancedOptions", new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, cp), AscCommon.c_oAscAdvancedOptionsAction.Open); options = new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.DRM);
} else {
var cp = JSON.parse("{\"codepage\":46,\"delimiter\":1}");
cp['encodings'] = AscCommon.getEncodingParams();
options = new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, cp);
}
this.handlers.trigger("asc_onAdvancedOptions", options, AscCommon.c_oAscAdvancedOptionsAction.Open);
}; };
})(jQuery, window); })(jQuery, window);
window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions = function(idOption, option) window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{ {
window["AscDesktopEditor"]["SetAdvancedOptions"]("" + option.asc_getCodePage(), "" + option.asc_getDelimiter()); if (window["Asc"].c_oAscAdvancedOptionsID.CSV === idOption) {
}; var _param = "";
window["Asc"]['spreadsheet_api'].prototype["asc_setAdvancedOptions"] = window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions; _param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
_param += ("<m_nCsvDelimiter>" + option.asc_getDelimiter() + "</m_nCsvDelimiter>");
window["asc_initAdvancedOptions"] = function() window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
{ }
window["Asc"]["editor"]._onNeedParams(undefined); else if (window["Asc"].c_oAscAdvancedOptionsID.DRM === idOption) {
var _param = "";
_param += ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(option.asc_getPassword()) + "</m_sPassword>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
}; };
window["Asc"]['spreadsheet_api'].prototype["asc_setAdvancedOptions"] = window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions;
window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data) window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data)
{ {
...@@ -111,9 +126,9 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data) ...@@ -111,9 +126,9 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data)
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
{ {
this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index);
if (true === this.Is_UserSaveMode()) if (true === this.Is_UserSaveMode())
{ {
this.SavedIndex = this.Index;
if (true === IsUserSave) if (true === IsUserSave)
{ {
this.UserSavedIndex = this.Index; this.UserSavedIndex = this.Index;
...@@ -122,12 +137,11 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) ...@@ -122,12 +137,11 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
} }
else else
{ {
this.SavedIndex = this.Index;
this.ForceSave = false; this.ForceSave = false;
} }
}; };
AscCommon.CHistory.prototype.Is_Modified = function(IsNotUserSave, IsNoSavedNoModifyed) AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoModifyed)
{ {
var checkIndex = (this.Is_UserSaveMode() && !IsNotUserSave) ? this.UserSavedIndex : this.SavedIndex; var checkIndex = (this.Is_UserSaveMode() && !IsNotUserSave) ? this.UserSavedIndex : this.SavedIndex;
if (-1 === this.Index && null === checkIndex && false === this.ForceSave) if (-1 === this.Index && null === checkIndex && false === this.ForceSave)
...@@ -155,7 +169,6 @@ window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes) ...@@ -155,7 +169,6 @@ window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes)
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
//////////////// SAVE ////////////////////// //////////////// SAVE //////////////////////
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
window["Asc"]['spreadsheet_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) window["Asc"]['spreadsheet_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{ {
this.asc_Save(false, true); this.asc_Save(false, true);
...@@ -186,11 +199,11 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error) ...@@ -186,11 +199,11 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
else else
AscCommon.History.UserSavedIndex = window["Asc"]["editor"].LastUserSavedIndex; AscCommon.History.UserSavedIndex = window["Asc"]["editor"].LastUserSavedIndex;
window["Asc"]["editor"].onUpdateDocumentModified(AscCommon.History.Is_Modified()); window["Asc"]["editor"].onUpdateDocumentModified(AscCommon.History.Have_Changes());
window["Asc"]["editor"].LastUserSavedIndex = undefined; window["Asc"]["editor"].LastUserSavedIndex = undefined;
if (2 == error) if (2 == error)
window["Asc"]["editor"].sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.NoCritical); window["Asc"]["editor"].sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.NoCritical);
}; };
window["Asc"]['spreadsheet_api'].prototype["asc_addImageDrawingObject"] = window["Asc"]['spreadsheet_api'].prototype.asc_addImageDrawingObject; window["Asc"]['spreadsheet_api'].prototype["asc_addImageDrawingObject"] = window["Asc"]['spreadsheet_api'].prototype.asc_addImageDrawingObject;
......
/* /*
* (c) Copyright Ascensio System SIA 2010-2016 * (c) Copyright Ascensio System SIA 2010-2017
* *
* This program is a free software product. You can redistribute it and/or * This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL) * modify it under the terms of the GNU Affero General Public License (AGPL)
...@@ -42,6 +42,8 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function() ...@@ -42,6 +42,8 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function()
{ {
this.asc_registerCallback('asc_onDocumentContentReady', function(){ this.asc_registerCallback('asc_onDocumentContentReady', function(){
DesktopOfflineUpdateLocalName(editor); DesktopOfflineUpdateLocalName(editor);
//setTimeout(function(){window["UpdateInstallPlugins"]();}, 10);
}); });
AscCommon.History.UserSaveMode = true; AscCommon.History.UserSaveMode = true;
...@@ -52,7 +54,7 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data) ...@@ -52,7 +54,7 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data)
//AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"](); //AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "") if (_data == "")
{ {
this.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.Critical); this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
return; return;
} }
...@@ -79,9 +81,9 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data) ...@@ -79,9 +81,9 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data)
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
{ {
this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index);
if (true === this.Is_UserSaveMode()) if (true === this.Is_UserSaveMode())
{ {
this.SavedIndex = this.Index;
if (true === IsUserSave) if (true === IsUserSave)
{ {
this.UserSavedIndex = this.Index; this.UserSavedIndex = this.Index;
...@@ -90,7 +92,6 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) ...@@ -90,7 +92,6 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
} }
else else
{ {
this.SavedIndex = this.Index;
this.ForceSave = false; this.ForceSave = false;
} }
}; };
...@@ -140,7 +141,7 @@ window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes) ...@@ -140,7 +141,7 @@ window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes)
Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue) Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue)
{ {
this.isDocumentModify = bValue; this.isDocumentModify = bValue;
this.asc_fireCallback("asc_onDocumentModifiedChanged"); this.sendEvent("asc_onDocumentModifiedChanged");
if (undefined !== window["AscDesktopEditor"]) if (undefined !== window["AscDesktopEditor"])
{ {
...@@ -172,7 +173,7 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error) ...@@ -172,7 +173,7 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
editor.LastUserSavedIndex = undefined; editor.LastUserSavedIndex = undefined;
if (2 == error) if (2 == error)
editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.Critical); editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.Critical);
}; };
Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{ {
......
/* /*
* (c) Copyright Ascensio System SIA 2010-2016 * (c) Copyright Ascensio System SIA 2010-2017
* *
* This program is a free software product. You can redistribute it and/or * This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL) * modify it under the terms of the GNU Affero General Public License (AGPL)
...@@ -54,7 +54,7 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data) ...@@ -54,7 +54,7 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data)
//AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"](); //AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "") if (_data == "")
{ {
this.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.Critical); this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
return; return;
} }
if (AscCommon.c_oSerFormat.Signature !== _data.substring(0, AscCommon.c_oSerFormat.Signature.length)) if (AscCommon.c_oSerFormat.Signature !== _data.substring(0, AscCommon.c_oSerFormat.Signature.length))
...@@ -83,23 +83,27 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data) ...@@ -83,23 +83,27 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data)
Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option) Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{ {
window["AscDesktopEditor"]["SetAdvancedOptions"]("" + option.asc_getCodePage()); if (window["Asc"].c_oAscAdvancedOptionsID.TXT === idOption) {
var _param = "";
_param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
else if (window["Asc"].c_oAscAdvancedOptionsID.DRM === idOption) {
var _param = "";
_param += ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(option.asc_getPassword()) + "</m_sPassword>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
}; };
Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions; Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions;
window["asc_initAdvancedOptions"] = function()
{
editor._onNeedParams(undefined);
};
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
////////////// CHANGES ///////////////////// ////////////// CHANGES /////////////////////
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
{ {
this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index);
if (true === this.Is_UserSaveMode()) if (true === this.Is_UserSaveMode())
{ {
this.SavedIndex = this.Index;
if (true === IsUserSave) if (true === IsUserSave)
{ {
this.UserSavedIndex = this.Index; this.UserSavedIndex = this.Index;
...@@ -108,7 +112,6 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) ...@@ -108,7 +112,6 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
} }
else else
{ {
this.SavedIndex = this.Index;
this.ForceSave = false; this.ForceSave = false;
} }
}; };
...@@ -179,7 +182,7 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error) ...@@ -179,7 +182,7 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
editor.LastUserSavedIndex = undefined; editor.LastUserSavedIndex = undefined;
if (2 == error) if (2 == error)
editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.NoCritical); editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.NoCritical);
}; };
Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{ {
......
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