Blame view
sources/apps/files_odfviewer/js/viewer.js
2.1 KB
|
03e52840d
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
function viewOdf(dir, file) {
OC.addStyle('files_odfviewer', 'webodf');
OC.addStyle('files_odfviewer', 'odfviewer');
OC.addScript('files_odfviewer','webodf').done(function(){
var location = fileDownloadPath(dir, file);
// fade out files menu and add odf menu
$('.actions,#file_action_panel').fadeOut('slow').promise().done(function() {
// odf action toolbar
var odfToolbarHtml =
'<div id="odf-toolbar">' +
'<button id="odf_close">'+t('files_odfviewer','Close')+
'</button></div>';
$('#controls').append(odfToolbarHtml);
});
// fade out file list and show pdf canvas
$('table').fadeOut('slow').promise().done(function(){;
var canvashtml = '<div id="odf-canvas"></div>';
$('table').after(canvashtml);
// in case we are on the public sharing page we shall display the odf into the preview tag
$('#preview').html(canvashtml);
var odfelement = document.getElementById("odf-canvas");
var odfcanvas = new odf.OdfCanvas(odfelement);
odfcanvas.load(location);
});
});
}
function closeOdfViewer(){
// Fade out odf-toolbar
$('#odf-toolbar').fadeOut('slow');
// Fade out editor
$('#odf-canvas').fadeOut('slow', function(){
$('#odf-toolbar').remove();
$('#odf-canvas').remove();
$('.actions,#file_access_panel').fadeIn('slow');
$('table').fadeIn('slow');
});
is_editor_shown = false;
}
$(document).ready(function() {
if(typeof FileActions!=='undefined'){
var supportedMimes = new Array(
'application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.graphics',
'application/vnd.oasis.opendocument.presentation');
for (var i = 0; i < supportedMimes.length; ++i){
var mime = supportedMimes[i];
FileActions.register(mime,'View',OC.PERMISSION_READ,'',function(filename){
viewOdf($('#dir').val(),filename);
});
FileActions.setDefault(mime,'View');
}
}
$('#odf_close').live('click',function() {
closeOdfViewer();
});
});
|