From 9d12c920b598987f1478ff931bd75095d0e3a67e Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 19 May 2014 10:39:37 +0200 Subject: [PATCH] Set viewer mode to filelist when viewing ODF file Now calling FileList.setViewerMode() to properly toggle viewer mode. This will hide the sidebar and actions automatically. --- js/viewer/viewer.js | 57 +++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/js/viewer/viewer.js b/js/viewer/viewer.js index 0a40bc26..9fdf40a6 100644 --- a/js/viewer/viewer.js +++ b/js/viewer/viewer.js @@ -1,3 +1,4 @@ +/* globals FileList, FileActions, oc_debug */ var odfViewer = { isDocuments : false, supportedMimesRead: [ @@ -71,45 +72,35 @@ var odfViewer = { OC.addStyle('documents', 'viewer/odfviewer'); OC.addScript('documents', '3rdparty/webodf/' + webodfSource, function() { - // fade out files menu and add odf menu - $('#controls div').fadeOut('slow').promise().done(function() { - // odf action toolbar - var odfToolbarHtml = - '
' + - '
'; - if (odfViewer.isDocuments){ - $(attachToolbarTo).prepend(odfToolbarHtml); - $('#odf-toolbar').css({position:'fixed'}); - } else { - $(attachToolbarTo).append(odfToolbarHtml); - } - }); + FileList.setViewerMode(true); - // fade out file list and show pdf canvas - $('table, #documents-content').fadeOut('slow').promise().done(function() { - var canvashtml = '
'; - $(attachTo).after(canvashtml); - // in case we are on the public sharing page we shall display the odf into the preview tag - $('#preview').html(canvashtml); + // odf action toolbar + var odfToolbarHtml = + '
' + + '
'; + if (odfViewer.isDocuments){ + $(attachToolbarTo).prepend(odfToolbarHtml); + $('#odf-toolbar').css({position:'fixed'}); + } else { + $(attachToolbarTo).append(odfToolbarHtml); + } - var odfelement = document.getElementById("odf-canvas"); - var odfcanvas = new odf.OdfCanvas(odfelement); - odfcanvas.load(location); - }); + var canvashtml = '
'; + $(attachTo).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); }); }, onClose: function() { - // Fade out odf-toolbar - $('#odf-toolbar').fadeOut('slow'); - // Fade out editor - $('#odf-canvas').fadeOut('slow', function() { - $('#odf-toolbar').remove(); - $('#odf-canvas').remove(); - $('#controls div').not('.hidden').fadeIn('slow'); - $('table, #documents-content').fadeIn('slow'); - }); + FileList.setViewerMode(false); + $('#odf-toolbar').remove(); + $('#odf-canvas').remove(); } };