Commit 75b93ee2 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Merged revision(s) r64263 from...

Merged revision(s) r64263 from AVS/Sources/TeamlabOffice/branches/OfficeWebUnion* Сделал общую функцию подписки на сообщение о загрузке изображения.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64469 954022d7-b5bf-4e40-9824-e11837661b57
parent faceab09
......@@ -949,12 +949,6 @@ function DrawingObjects() {
_this.recalculate(true);
// Upload event
if (window.addEventListener) {
window.addEventListener("message", _this._uploadMessage, false);
}
_this.shiftMap = {};
worksheet.model.Drawings = aObjects;
};
......@@ -1076,44 +1070,6 @@ function DrawingObjects() {
return worksheet.model;
};
_this._uploadMessage = function(event) {
if ( null != event && null != event.data ) {
try {
var data = JSON.parse(event.data);
if ((null != data) && (null != data["type"]))
{
if (PostMessageType.UploadImage == data["type"]) {
if (c_oAscServerError.NoError == data["error"]) {
var urls = data["urls"];
if(urls){
g_oDocumentUrls.addUrls(urls);
var firstUrl;
for(var i in urls){
if(urls.hasOwnProperty(i)){
firstUrl = urls[i];
break;
}
}
if(firstUrl){
if ( api.isImageChangeUrl || api.isShapeImageChangeUrl || api.isTextArtChangeUrl)
_this.editImageDrawingObject(firstUrl);
else
_this.addImageDrawingObject(firstUrl, null);
}
}
}
else {
worksheet.model.workbook.handlers.trigger("asc_onError", g_fMapAscServerErrorToAscError(data["error"]), c_oAscError.Level.NoCritical);
}
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
}
}
catch(e) {
}
}
};
_this.callTrigger = function(triggerName, param) {
if ( triggerName )
worksheet.model.workbook.handlers.trigger(triggerName, param);
......
......@@ -554,6 +554,36 @@ function GetFileExtension (sName) {
return sName.substring(nIndex + 1).toLowerCase();
return null;
}
function InitOnMessage (callback) {
if (window.addEventListener) {
window.addEventListener("message", function (event) {
if (null != event && null != event.data) {
try {
var data = JSON.parse(event.data);
if (null != data && null != data["type"] && PostMessageType.UploadImage == data["type"]) {
if (c_oAscServerError.NoError == data["error"]) {
var urls = data["urls"];
if (urls) {
g_oDocumentUrls.addUrls(urls);
var firstUrl;
for (var i in urls) {
if (urls.hasOwnProperty(i)) {
firstUrl = urls[i];
break;
}
}
callback(c_oAscServerError.NoError, firstUrl);
}
} else
callback(g_fMapAscServerErrorToAscError(data["error"]));
}
} catch (err) {
}
}
}, false);
}
}
function InitDragAndDrop (oHtmlElement, callback) {
if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData) && null != oHtmlElement) {
oHtmlElement["ondragover"] = function (e) {
......
......@@ -178,6 +178,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var t = this;
this.HtmlElement = document.getElementById(this.HtmlElementName);
this.topLineEditorElement = document.getElementById(this.topLineEditorName);
// init OnMessage
InitOnMessage(function (error, url) {
if (c_oAscServerError.NoError !== error)
t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
else {
var ws = t.wb.getWorksheet();
if (ws) {
if (t.isImageChangeUrl || t.isShapeImageChangeUrl || t.isTextArtChangeUrl)
ws.objectRender.editImageDrawingObject(url);
else
ws.objectRender.addImageDrawingObject(url, null);
}
}
t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
});
// init drag&drop
InitDragAndDrop(this.HtmlElement, function (error, files) {
if (c_oAscServerError.NoError !== error) {
......
......@@ -165,7 +165,6 @@ function asc_docs_api(name)
this._gui_fonts = null;
this._gui_editor_themes = null;
this._gui_document_themes = null;
this.tableStylesIdCounter = 0;
//выставляем тип copypaste
g_bIsDocumentCopyPaste = false;
......@@ -177,11 +176,15 @@ function asc_docs_api(name)
this.fCurCallback = null;
var oThis = this;
if(window.addEventListener)
window.addEventListener("message", function(){
oThis.OnHandleMessage.apply(oThis, arguments);
}, false);
// init OnMessage
InitOnMessage(function (error, url) {
if (c_oAscServerError.NoError !== error)
oThis.sync_ErrorCallback(error, c_oAscError.Level.NoCritical);
else
oThis.AddImageUrl(url);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
// init drag&drop
InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) {
if (c_oAscServerError.NoError !== error) {
......@@ -4794,40 +4797,7 @@ asc_docs_api.prototype.OnMouseUp = function(x, y)
//this.WordControl.onMouseUpExternal(x, y);
};
asc_docs_api.prototype.OnHandleMessage = function(event)
{
if (null != event && null != event.data)
{
var data = JSON.parse(event.data);
if(null != data && null != data["type"])
{
if(PostMessageType.UploadImage == data["type"])
{
if(c_oAscServerError.NoError == data["error"])
{
var urls = data["urls"];
if(urls){
g_oDocumentUrls.addUrls(urls);
var firstUrl;
for(var i in urls){
if(urls.hasOwnProperty(i)){
firstUrl = urls[i];
break;
}
}
if(firstUrl){
this.AddImageUrl(firstUrl);
}
}
}
else
this.sync_ErrorCallback(g_fMapAscServerErrorToAscError(data["error"]), c_oAscError.Level.NoCritical);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}
}
}
};
asc_docs_api.prototype.asyncImageEndLoaded2 = null;
asc_docs_api.prototype.ChangeTheme = function(indexTheme)
......
......@@ -526,11 +526,15 @@ function asc_docs_api(name)
this.fCurCallback = null;
var oThis = this;
if(window.addEventListener)
window.addEventListener("message", function(){
oThis.OnHandleMessage.apply(oThis, arguments);
}, false);
// init OnMessage
InitOnMessage(function (error, url) {
if (c_oAscServerError.NoError !== error)
oThis.sync_ErrorCallback(error, c_oAscError.Level.NoCritical);
else
oThis.AddImageUrl(url);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
// init drag&drop
InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) {
if (c_oAscServerError.NoError !== error) {
......@@ -6933,46 +6937,7 @@ asc_docs_api.prototype.OnMouseUp = function(x, y)
{
this.WordControl.onMouseUpExternal(x, y);
};
asc_docs_api.prototype.OnHandleMessage = function(event)
{
if (null != event && null != event.data)
{
try
{
var data = JSON.parse(event.data);
if(null != data && null != data["type"])
{
if(PostMessageType.UploadImage == data["type"])
{
if(c_oAscServerError.NoError == data["error"])
{
var urls = data["urls"];
if(urls){
g_oDocumentUrls.addUrls(urls);
var firstUrl;
for(var i in urls){
if(urls.hasOwnProperty(i)){
firstUrl = urls[i];
break;
}
}
if(firstUrl){
this.AddImageUrl(firstUrl);
}
}
}
else
this.sync_ErrorCallback(g_fMapAscServerErrorToAscError(data["error"]), c_oAscError.Level.NoCritical);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}
}
}
catch (err)
{
}
}
};
asc_docs_api.prototype.asyncImageEndLoaded2 = null;
asc_docs_api.prototype.OfflineAppDocumentStartLoad = function()
......
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