Merge pull request #29 from pranavk/master
Use window.postMessage API for cross-domain frame communication
This commit is contained in:
commit
0ab25bcfbc
@ -199,28 +199,21 @@ var documentsMain = {
|
|||||||
var viewer = urlsrc +
|
var viewer = urlsrc +
|
||||||
'WOPISrc=' + encodeURIComponent(documentsMain.url) +
|
'WOPISrc=' + encodeURIComponent(documentsMain.url) +
|
||||||
'&host=' + $('#wopi-url').val() +
|
'&host=' + $('#wopi-url').val() +
|
||||||
|
'&filename=' + title +
|
||||||
'&permission=' + 'view' +
|
'&permission=' + 'view' +
|
||||||
'×tamp=' + '';
|
'×tamp=' + '' +
|
||||||
|
'&closebutton=1';
|
||||||
|
|
||||||
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"/>';
|
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(frame);
|
$('#mainContainer').append(frame);
|
||||||
|
|
||||||
$('#loleafletframe').load(function(){
|
$('#loleafletframe').load(function(){
|
||||||
documentsMain.overlay.documentOverlay('hide');
|
documentsMain.overlay.documentOverlay('hide');
|
||||||
var iframe = $('#loleafletframe').contents();
|
window.addEventListener('message', function(e){
|
||||||
iframe.find('#tb_toolbar-up_item_close').click(function() {
|
if (e.data === 'close') {
|
||||||
documentsMain.onClose();
|
documentsMain.onClose();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var frameWindow = $('#loleafletframe')[0].contentWindow;
|
|
||||||
(function() {
|
|
||||||
cloudSuiteOnClick = frameWindow.onClick;
|
|
||||||
frameWindow.onClick = function() {
|
|
||||||
fileName = encodeURIComponent(title.substr(0, title.lastIndexOf('.')) || title);
|
|
||||||
frameWindow.map.options.doc = fileName;
|
|
||||||
cloudSuiteOnClick.apply(this, arguments);
|
|
||||||
frameWindow.map.options.doc = documentsMain.url;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user