Commit 3cb7332a authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Merged revision(s) r64280 from...

Merged revision(s) r64280 from AVS/Sources/TeamlabOffice/branches/OfficeWebUnion* Показ диалога выбора файла перенес в common

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64472 954022d7-b5bf-4e40-9824-e11837661b57
parent ccfbfea1
...@@ -2975,53 +2975,6 @@ function DrawingObjects() { ...@@ -2975,53 +2975,6 @@ function DrawingObjects() {
return info; return info;
}; };
//-----------------------------------------------------------------------------------
// File Dialog
//-----------------------------------------------------------------------------------
_this.showImageFileDialog = function(documentId, documentUserId) {
if ( _this.isViewerMode() )
return;
var frameWindow = GetUploadIFrame();
var content = '<html><head></head><body><form action="' + g_sUploadServiceLocalUrl + '/' + documentId + '/' + documentUserId + '/' + g_oDocumentUrls.getMaxIndex() + '" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="apiiuFile" type="file" accept="image/*" size="1"><input id="apiiuSubmit" name="apiiuSubmit" type="submit" style="display:none;"></form></body></html>';
frameWindow.document.open();
frameWindow.document.write(content);
frameWindow.document.close();
var fileName = frameWindow.document.getElementById("apiiuFile");
var fileSubmit = frameWindow.document.getElementById("apiiuSubmit");
fileName.onchange = function(e) {
var bNeedSubmit = true;
if(e && e.target && e.target.files)
{
var nError = ValidateUploadImage(e.target.files);
if(c_oAscServerError.NoError != nError)
{
bNeedSubmit = false;
worksheet.model.workbook.handlers.trigger("asc_onError", g_fMapAscServerErrorToAscError(nError), c_oAscError.Level.NoCritical);
}
}
if(bNeedSubmit)
{
worksheet.model.workbook.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
fileSubmit.click();
}
};
if (AscBrowser.isOpera)
setTimeout(function() { fileName.click(); }, 0);
else
fileName.click();
};
//-----------------------------------------------------------------------------------
// Shapes controller
//-----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Private Misc Methods // Private Misc Methods
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -3030,11 +2983,6 @@ function DrawingObjects() { ...@@ -3030,11 +2983,6 @@ function DrawingObjects() {
return asc.getCvtRatio( fromUnits, toUnits, drawingCtx.getPPIX() ); return asc.getCvtRatio( fromUnits, toUnits, drawingCtx.getPPIX() );
} }
function setCanvasZIndex(canvas, value) {
if (canvas && (value >= 0) && (value <= 1))
canvas.globalAlpha = value;
}
function emuToPx(emu) { function emuToPx(emu) {
return emu * 20 * 96 / 2.54 / 72 / 100 / 1000; return emu * 20 * 96 / 2.54 / 72 / 100 / 1000;
} }
......
...@@ -584,6 +584,34 @@ function InitOnMessage (callback) { ...@@ -584,6 +584,34 @@ function InitOnMessage (callback) {
}, false); }, false);
} }
} }
function ShowImageFileDialog (documentId, documentUserId, callback) {
var frameWindow = GetUploadIFrame();
var content = '<html><head></head><body><form action="'+g_sUploadServiceLocalUrl+'/'+documentId+'/'+documentUserId+'/'+g_oDocumentUrls.getMaxIndex()+'" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="apiiuFile" type="file" accept="image/*" size="1"><input id="apiiuSubmit" name="apiiuSubmit" type="submit" style="display:none;"></form></body></html>';
frameWindow.document.open();
frameWindow.document.write(content);
frameWindow.document.close();
var fileName = frameWindow.document.getElementById("apiiuFile");
var fileSubmit = frameWindow.document.getElementById("apiiuSubmit");
fileName.onchange = function (e) {
if (e && e.target && e.target.files) {
var nError = ValidateUploadImage(e.target.files);
if (c_oAscServerError.NoError != nError) {
callback(g_fMapAscServerErrorToAscError(nError));
return;
}
}
callback(c_oAscServerError.NoError);
fileSubmit.click();
};
//todo пересмотреть opera
if (AscBrowser.isOpera)
setTimeout( function(){fileName.click();}, 0);
else
fileName.click();
}
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) {
......
...@@ -192,7 +192,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -192,7 +192,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
} }
} }
t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}); });
// init drag&drop // init drag&drop
InitDragAndDrop(this.HtmlElement, function (error, files) { InitDragAndDrop(this.HtmlElement, function (error, files) {
...@@ -200,11 +200,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -200,11 +200,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical); t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
return; return;
} }
t.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); t.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
UploadImageFiles(files, t.documentId, t.documentUserId, function (error) { UploadImageFiles(files, t.documentId, t.documentUserId, function (error) {
if (c_oAscServerError.NoError !== error) { if (c_oAscServerError.NoError !== error) {
t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical); t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); t.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
} }
}); });
}); });
...@@ -2592,7 +2592,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2592,7 +2592,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
"data": imageUrl}; "data": imageUrl};
var oThis = this; var oThis = this;
this.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); this.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input) { this.fCurCallback = function(input) {
if(null != input && "imgurl" == input["type"]){ if(null != input && "imgurl" == input["type"]){
if("ok" ==input["status"]) { if("ok" ==input["status"]) {
...@@ -2621,19 +2621,18 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2621,19 +2621,18 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
} else { } else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical); t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown,c_oAscError.Level.NoCritical);
} }
oThis.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); oThis.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}; };
sendCommand2(this, null, rData); sendCommand2(this, null, rData);
}; };
spreadsheet_api.prototype.asc_showImageFileDialog = function () { spreadsheet_api.prototype.asc_showImageFileDialog = function () {
if (undefined != window['appBridge']) { var t = this;
window['appBridge']['dummyCommandAddImage'] (); ShowImageFileDialog(this.documentId, this.documentUserId, function (error) {
return; if (c_oAscServerError.NoError !== error)
} t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
t.handlers.trigger("asc_onStartAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
var ws = this.wb.getWorksheet(); });
ws.objectRender.showImageFileDialog(this.documentId, this.documentUserId);
}; };
spreadsheet_api.prototype.asc_setSelectedDrawingObjectLayer = function(layerType) { spreadsheet_api.prototype.asc_setSelectedDrawingObjectLayer = function(layerType) {
......
...@@ -3094,38 +3094,12 @@ asc_docs_api.prototype.ChangeArtImageFromFile = function() ...@@ -3094,38 +3094,12 @@ asc_docs_api.prototype.ChangeArtImageFromFile = function()
}; };
asc_docs_api.prototype.AddImage = function(){ asc_docs_api.prototype.AddImage = function(){
var frameWindow = GetUploadIFrame(); var t = this;
var content = '<html><head></head><body><form action="' + g_sUploadServiceLocalUrl + '/' + documentId + '/' + documentUserId + '/' + g_oDocumentUrls.getMaxIndex() + '" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="apiiuFile" type="file" accept="image/*" size="1"><input id="apiiuSubmit" name="apiiuSubmit" type="submit" style="display:none;"></form></body></html>'; ShowImageFileDialog(documentId, documentUserId, function (error) {
frameWindow.document.open(); if (c_oAscServerError.NoError !== error)
frameWindow.document.write(content); t.asc_fireCallback("asc_onError", error, c_oAscError.Level.NoCritical);
frameWindow.document.close(); t.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
var fileName = frameWindow.document.getElementById("apiiuFile");
var fileSubmit = frameWindow.document.getElementById("apiiuSubmit");
var oThis = this;
fileName.onchange = function(e)
{
var bNeedSubmit = true;
if(e && e.target && e.target.files)
{
var nError = ValidateUploadImage(e.target.files);
if(c_oAscServerError.NoError != nError)
{
bNeedSubmit = false;
oThis.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(nError), c_oAscError.Level.NoCritical);
}
}
if(bNeedSubmit)
{
oThis.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
fileSubmit.click();
}
};
//todo пересмотреть opera
if (window.opera != undefined)
setTimeout( function(){fileName.click();}, 0);
else
fileName.click();
}; };
asc_docs_api.prototype.StartAddShape = function(prst, is_apply) asc_docs_api.prototype.StartAddShape = function(prst, is_apply)
......
...@@ -1220,7 +1220,7 @@ asc_docs_api.prototype.asc_unregisterCallback = function(name, callback) { ...@@ -1220,7 +1220,7 @@ asc_docs_api.prototype.asc_unregisterCallback = function(name, callback) {
_callbacks[name].splice(i, 1); _callbacks[name].splice(i, 1);
} }
} }
_callbacks[name] = [] _callbacks[name] = [];
_callbacks[name].push(callback); _callbacks[name].push(callback);
}; };
...@@ -4810,46 +4810,12 @@ asc_docs_api.prototype.ChangeShapeImageFromFile = function() ...@@ -4810,46 +4810,12 @@ asc_docs_api.prototype.ChangeShapeImageFromFile = function()
}; };
asc_docs_api.prototype.AddImage = function(){ asc_docs_api.prototype.AddImage = function(){
if (undefined != window['qtDocBridge']) var t = this;
{ ShowImageFileDialog(documentId, documentUserId, function (error) {
// call native QT code if (c_oAscServerError.NoError !== error)
window['qtDocBridge']['addedImage'] (); t.asc_fireCallback("asc_onError", error, c_oAscError.Level.NoCritical);
} t.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
else });
{
var frameWindow = GetUploadIFrame();
var content = '<html><head></head><body><form action="'+g_sUploadServiceLocalUrl+'/'+documentId+'/'+documentUserId+'/'+g_oDocumentUrls.getMaxIndex()+'" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="apiiuFile" type="file" accept="image/*" size="1"><input id="apiiuSubmit" name="apiiuSubmit" type="submit" style="display:none;"></form></body></html>';
frameWindow.document.open();
frameWindow.document.write(content);
frameWindow.document.close();
var fileName = frameWindow.document.getElementById("apiiuFile");
var fileSubmit = frameWindow.document.getElementById("apiiuSubmit");
var oThis = this;
fileName.onchange = function(e)
{
var bNeedSubmit = true;
if(e && e.target && e.target.files)
{
var nError = ValidateUploadImage(e.target.files);
if(c_oAscServerError.NoError != nError)
{
bNeedSubmit = false;
oThis.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(nError), c_oAscError.Level.NoCritical);
}
}
if(bNeedSubmit)
{
oThis.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
fileSubmit.click();
}
};
//todo пересмотреть opera
if (window.opera != undefined)
setTimeout( function(){fileName.click();}, 0);
else
fileName.click();
}
}; };
asc_docs_api.prototype.AddImageUrl2 = function(url) asc_docs_api.prototype.AddImageUrl2 = function(url)
......
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