Commit faceab09 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Merged revision(s) r64258 from...

Merged revision(s) r64258 from AVS/Sources/TeamlabOffice/branches/OfficeWebUnion* Вынес инициализацию drag&drop в общие common

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64468 954022d7-b5bf-4e40-9824-e11837661b57
parent f14a4684
This diff is collapsed.
......@@ -179,10 +179,19 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.HtmlElement = document.getElementById(this.HtmlElementName);
this.topLineEditorElement = document.getElementById(this.topLineEditorName);
// init drag&drop
if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData) && null != this.HtmlElement) {
this.HtmlElement["ondragover"] = function (e) {t._onDragOverImage(e);};
this.HtmlElement["ondrop"] = function (e) {t._onDropImage(e);};
}
InitDragAndDrop(this.HtmlElement, function (error, files) {
if (c_oAscServerError.NoError !== error) {
t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
return;
}
t.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
UploadImageFiles(files, t.documentId, t.documentUserId, function (error) {
if (c_oAscServerError.NoError !== error) {
t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
});
});
this.formulasList = getFormulasInfo();
......@@ -191,50 +200,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
};
};
spreadsheet_api.prototype._onDragOverImage = function(e) {
e.preventDefault();
if(CanDropFiles(e))
e.dataTransfer.dropEffect = 'copy';
else
e.dataTransfer.dropEffect = 'none';
return false;
};
spreadsheet_api.prototype._onDropImage = function(e) {
var t = this;
e.preventDefault();
var files = e.dataTransfer.files;
var nError = ValidateUploadImage(files);
if (c_oAscServerError.NoError == nError) {
var worksheet = null;
if (null != this.wbModel)
worksheet = this.wbModel.getWorksheet(this.wbModel.getActive());
if (null != worksheet) {
this.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
var xhr = new XMLHttpRequest();
var fd = new FormData();
for(var i = 0, length = files.length; i < length; i++)
fd.append('file[' + i + ']', files[i]);
xhr.open('POST', g_sUploadServiceLocalUrl + '/' + this.documentId + '/' + this.documentUserId + '/' + g_oDocumentUrls.getMaxIndex());
xhr.onreadystatechange = function() {
if (4 == this.readyState) {
if((this.status == 200 || this.status == 1223)) {
var frameWindow = GetUploadIFrame();
var content = this.responseText;
frameWindow.document.open();
frameWindow.document.write(content);
frameWindow.document.close();
} else{
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
}
};
xhr.send(fd);
}
} else
this.handlers.trigger("asc_onError", g_fMapAscServerErrorToAscError(nError), c_oAscError.Level.NoCritical);
};
spreadsheet_api.prototype.asc_CheckGuiControlColors = function() {
// потом реализовать проверку на то, что нужно ли посылать
......
......@@ -181,55 +181,21 @@ function asc_docs_api(name)
window.addEventListener("message", function(){
oThis.OnHandleMessage.apply(oThis, arguments);
}, false);
if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData)) {
//var element = document.body;
var element = document.getElementById(this.HtmlElementName);
if(null != element)
{
element["ondragover"] = function(e) {
e.preventDefault();
if(CanDropFiles(e))
e.dataTransfer.dropEffect = 'copy';
else
e.dataTransfer.dropEffect = 'none';
return false;
};
element["ondrop"] = function(e) {
e.preventDefault();
var files = e.dataTransfer.files;
var nError = ValidateUploadImage(files);
if(c_oAscServerError.NoError == nError)
{
oThis.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
var xhr = new XMLHttpRequest();
var fd = new FormData();
for(var i = 0, length = files.length; i < length; i++)
fd.append('file[' + i + ']', files[i]);
xhr.open('POST', g_sUploadServiceLocalUrl + '/' + documentId + '/' + documentUserId + '/' + g_oDocumentUrls.getMaxIndex());
xhr.onreadystatechange = function(){
if(4 == this.readyState)
{
if((this.status == 200 || this.status == 1223))
{
var frameWindow = GetUploadIFrame();
var content = this.responseText;
frameWindow.document.open();
frameWindow.document.write(content);
frameWindow.document.close();
}
else{
oThis.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
oThis.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}
}
};
xhr.send(fd);
}
else
oThis.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(nError), c_oAscError.Level.NoCritical);
};
// init drag&drop
InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) {
if (c_oAscServerError.NoError !== error) {
oThis.asc_fireCallback("asc_onError", error, c_oAscError.Level.NoCritical);
return;
}
}
oThis.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
UploadImageFiles(files, documentId, documentUserId, function (error) {
if (c_oAscServerError.NoError !== error) {
oThis.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
oThis.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}
});
});
if (window.editor == undefined)
{
......
......@@ -530,55 +530,21 @@ function asc_docs_api(name)
window.addEventListener("message", function(){
oThis.OnHandleMessage.apply(oThis, arguments);
}, false);
if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData)) {
//var element = document.body;
var element = document.getElementById(this.HtmlElementName);
if(null != element)
{
element["ondragover"] = function(e) {
e.preventDefault();
if(CanDropFiles(e))
e.dataTransfer.dropEffect = 'copy';
else
e.dataTransfer.dropEffect = 'none';
return false;
};
element["ondrop"] = function(e) {
e.preventDefault();
var files = e.dataTransfer.files;
var nError = ValidateUploadImage(files);
if(c_oAscServerError.NoError == nError)
{
oThis.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
var xhr = new XMLHttpRequest();
var fd = new FormData();
for(var i = 0, length = files.length; i < length; i++)
fd.append('file[' + i + ']', files[i]);
xhr.open('POST', g_sUploadServiceLocalUrl+'/'+documentId+'/'+documentUserId+'/'+g_oDocumentUrls.getMaxIndex());
xhr.onreadystatechange = function(){
if(4 == this.readyState)
{
if((this.status == 200 || this.status == 1223))
{
var frameWindow = GetUploadIFrame();
var content = this.responseText;
frameWindow.document.open();
frameWindow.document.write(content);
frameWindow.document.close();
}
else{
oThis.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
oThis.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}
}
};
xhr.send(fd);
}
else
oThis.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(nError), c_oAscError.Level.NoCritical);
};
// init drag&drop
InitDragAndDrop(document.getElementById(this.HtmlElementName), function (error, files) {
if (c_oAscServerError.NoError !== error) {
oThis.asc_fireCallback("asc_onError", error, c_oAscError.Level.NoCritical);
return;
}
}
oThis.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
UploadImageFiles(files, documentId, documentUserId, function (error) {
if (c_oAscServerError.NoError !== error) {
oThis.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
oThis.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}
});
});
if (window.editor == undefined)
{
......
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