Post WOPI url iframe

This commit is contained in:
Henry Castro 2016-04-07 17:53:15 -04:00
parent 157719b5f3
commit a27950d617

View File

@ -192,21 +192,22 @@ var documentsMain = {
} }
var urlsrc = $('li[data-id='+ documentsMain.fileId +']>a').attr('urlsrc'); var urlsrc = $('li[data-id='+ documentsMain.fileId +']>a').attr('urlsrc');
var url = OC.generateUrl('apps/richdocuments/wopi/files/{file_id}?access_token={token}', var token = encodeURIComponent(result.token);
{file_id: documentsMain.fileId, token: encodeURIComponent(result.token)}); var url = OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: documentsMain.fileId});
documentsMain.url = window.location.protocol + '//' + window.location.host + url; documentsMain.url = window.location.protocol + '//' + window.location.host + url;
var viewer = urlsrc + var wopisrc = encodeURIComponent(documentsMain.url);
'WOPISrc=' + encodeURIComponent(documentsMain.url) + var form = '<form id="loleafletform" name="loleafletform" target="loleafletframe" action="' + urlsrc + '" method="post">' +
'&host=' + $('#wopi-url').val() + '<input name="WOPISrc" value="' + wopisrc + '" type="hidden"/>' +
'&title=' + title + '<input name="title" value="' + title + '" type="hidden"/>' +
'&permission=' + 'view' + '<input name="permission" value="view" type="hidden"/>' +
'&timestamp=' + '' + '<input name="timestamp" value="" type="hidden"/>' +
'&closebutton=1'; '<input name="closebutton" value="1" type="hidden"/>' +
'<input name="access_token" value="' + token + '" type="hidden"/></form>';
var frame = '<iframe id="loleafletframe" name= "loleafletframe" allowfullscreen style="width:100%;height:100%;position:absolute;"/>';
var frame = '<iframe id="loleafletframe" allowfullscreen style="width:100%;height:100%;position:absolute;" src="' + viewer + '" sandbox="allow-scripts allow-same-origin allow-popups allow-modals"/>'; $('#mainContainer').append(form);
$('#mainContainer').append(frame); $('#mainContainer').append(frame);
$('#loleafletframe').load(function(){ $('#loleafletframe').load(function(){
documentsMain.overlay.documentOverlay('hide'); documentsMain.overlay.documentOverlay('hide');
window.addEventListener('message', function(e){ window.addEventListener('message', function(e){
@ -215,6 +216,8 @@ var documentsMain = {
} }
}); });
}); });
$('#loleafletform').submit();
}); });
}, },