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() { ...@@ -949,12 +949,6 @@ function DrawingObjects() {
_this.recalculate(true); _this.recalculate(true);
// Upload event
if (window.addEventListener) {
window.addEventListener("message", _this._uploadMessage, false);
}
_this.shiftMap = {}; _this.shiftMap = {};
worksheet.model.Drawings = aObjects; worksheet.model.Drawings = aObjects;
}; };
...@@ -1076,44 +1070,6 @@ function DrawingObjects() { ...@@ -1076,44 +1070,6 @@ function DrawingObjects() {
return worksheet.model; 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) { _this.callTrigger = function(triggerName, param) {
if ( triggerName ) if ( triggerName )
worksheet.model.workbook.handlers.trigger(triggerName, param); worksheet.model.workbook.handlers.trigger(triggerName, param);
......
...@@ -554,6 +554,36 @@ function GetFileExtension (sName) { ...@@ -554,6 +554,36 @@ function GetFileExtension (sName) {
return sName.substring(nIndex + 1).toLowerCase(); return sName.substring(nIndex + 1).toLowerCase();
return null; 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) { function InitDragAndDrop (oHtmlElement, callback) {
if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData) && null != oHtmlElement) { if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData) && null != oHtmlElement) {
oHtmlElement["ondragover"] = function (e) { oHtmlElement["ondragover"] = function (e) {
......
...@@ -178,6 +178,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -178,6 +178,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var t = this; var t = this;
this.HtmlElement = document.getElementById(this.HtmlElementName); this.HtmlElement = document.getElementById(this.HtmlElementName);
this.topLineEditorElement = document.getElementById(this.topLineEditorName); 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 // init drag&drop
InitDragAndDrop(this.HtmlElement, function (error, files) { InitDragAndDrop(this.HtmlElement, function (error, files) {
if (c_oAscServerError.NoError !== error) { if (c_oAscServerError.NoError !== error) {
......
...@@ -165,7 +165,6 @@ function asc_docs_api(name) ...@@ -165,7 +165,6 @@ function asc_docs_api(name)
this._gui_fonts = null; this._gui_fonts = null;
this._gui_editor_themes = null; this._gui_editor_themes = null;
this._gui_document_themes = null; this._gui_document_themes = null;
this.tableStylesIdCounter = 0;
//выставляем тип copypaste //выставляем тип copypaste
g_bIsDocumentCopyPaste = false; g_bIsDocumentCopyPaste = false;
...@@ -177,11 +176,15 @@ function asc_docs_api(name) ...@@ -177,11 +176,15 @@ function asc_docs_api(name)
this.fCurCallback = null; this.fCurCallback = null;
var oThis = this; var oThis = this;
if(window.addEventListener) // init OnMessage
window.addEventListener("message", function(){ InitOnMessage(function (error, url) {
oThis.OnHandleMessage.apply(oThis, arguments); if (c_oAscServerError.NoError !== error)
}, false); oThis.sync_ErrorCallback(error, c_oAscError.Level.NoCritical);
else
oThis.AddImageUrl(url);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
// init drag&drop // init drag&drop
InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) { InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) {
if (c_oAscServerError.NoError !== error) { if (c_oAscServerError.NoError !== error) {
...@@ -4794,40 +4797,7 @@ asc_docs_api.prototype.OnMouseUp = function(x, y) ...@@ -4794,40 +4797,7 @@ asc_docs_api.prototype.OnMouseUp = function(x, y)
//this.WordControl.onMouseUpExternal(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.asyncImageEndLoaded2 = null;
asc_docs_api.prototype.ChangeTheme = function(indexTheme) asc_docs_api.prototype.ChangeTheme = function(indexTheme)
......
...@@ -526,11 +526,15 @@ function asc_docs_api(name) ...@@ -526,11 +526,15 @@ function asc_docs_api(name)
this.fCurCallback = null; this.fCurCallback = null;
var oThis = this; var oThis = this;
if(window.addEventListener) // init OnMessage
window.addEventListener("message", function(){ InitOnMessage(function (error, url) {
oThis.OnHandleMessage.apply(oThis, arguments); if (c_oAscServerError.NoError !== error)
}, false); oThis.sync_ErrorCallback(error, c_oAscError.Level.NoCritical);
else
oThis.AddImageUrl(url);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
// init drag&drop // init drag&drop
InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) { InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) {
if (c_oAscServerError.NoError !== error) { if (c_oAscServerError.NoError !== error) {
...@@ -6933,46 +6937,7 @@ asc_docs_api.prototype.OnMouseUp = function(x, y) ...@@ -6933,46 +6937,7 @@ asc_docs_api.prototype.OnMouseUp = function(x, y)
{ {
this.WordControl.onMouseUpExternal(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.asyncImageEndLoaded2 = null;
asc_docs_api.prototype.OfflineAppDocumentStartLoad = function() 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