<div dir="ltr">Hi All,<div><br></div><div>I am trying to add a new preview functionality to own cloud mainly for office documents where when a user clicks on for example a word document, it shows an html preview just like how pdf viewer shows pdfs in owncloud.</div>
<div><br></div><div>But I encountered a problem in which user isn't taken to the previous page when browser back button is clicked from the preview window. Instead user is taken to the parent folder. This issue exists in the pdf_viewer app too. </div>
<div><br></div><div>New feature is implemented very similar to the pdf_viewer app with my additions to fix the above problem. I have a javascript file using which I show the html preview when user clicks on a .docx file like this :</div>
<div><br></div><div> function showPreview(dir,filename) {<div><span style="white-space:pre-wrap"> </span>if(!showPreview.shown) {</div><div><span style="white-space:pre-wrap"> </span>$("#editor").hide();</div>
<div><span style="white-space:pre-wrap"> </span>$('#content table').hide();</div><div><span style="white-space:pre-wrap"> </span>$("#controls").hide();</div><div><span style="white-space:pre-wrap"> </span>oldcontent = $("#content").html();</div>
<div><span style="white-space:pre-wrap"> </span>var viewer = getFilePath(dir, filename);</div><div><br></div><div> // Append #preview to the url to preserve browser back button </div><div>
// functionality</div><div><span style="white-space:pre-wrap"> </span>window.location.hash = "#preview";</div><div><br></div><div><span style="white-space:pre-wrap"> </span>$("#content").html(oldcontent+'<iframe style="width:100%;height:100%;display:block;" src="'+viewer+'" />');</div>
<div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>$("#pageWidthOption").attr("selected","selected");</div><div><span style="white-space:pre-wrap"> </span>}</div>
<div> }</div><div><br></div><div> // When user clicks on back button, show old content, i.e. content table in the </div><div> // folder from where user click on the .docx link to get preview </div><div>
$(window).on("hashchange", function() {</div><div> if (!/#preview/.test(window.location.hash)) {</div><div> <span style="white-space:pre-wrap"> </span>$('#content').html(oldcontent);</div>
<div><span style="white-space:pre-wrap"> </span>$("#editor").show();</div><div><span style="white-space:pre-wrap"> </span>$('#content table').show();</div><div><span style="white-space:pre-wrap"> </span>$("#controls").show();</div>
<div><span style="white-space:pre-wrap"> </span>oldcontent = '';</div><div> }</div><div> });</div><div><br></div><div>Now I can go back to the current folder from preview window, but the problem is all the buttons( Rename, Download, Versions, Share etc. ) that are supposed to show towards the right side of the files are shown just after the file name as shown in the attachment. </div>
<div><br></div><div style>So does anyone know what's wrong here and how to get the normal behavior? </div><div style><br></div><div style>Thanks</div>
-- <br>~LLoyD~
</div></div>