[Owncloud] Browser back button doesn't work properly with my new file preview feature.

Lloyd Harischandra ayubowan.ll at gmail.com
Thu Aug 22 01:33:54 UTC 2013


Hi All,

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.

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.

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 :

    function showPreview(dir,filename) {
if(!showPreview.shown) {
$("#editor").hide();
 $('#content table').hide();
$("#controls").hide();
oldcontent = $("#content").html();
 var viewer = getFilePath(dir, filename);

                // Append #preview to the url to preserve browser back
button
                //  functionality
window.location.hash = "#preview";

$("#content").html(oldcontent+'<iframe
style="width:100%;height:100%;display:block;" src="'+viewer+'" />');
 $("#pageWidthOption").attr("selected","selected");
}
    }

    // When user clicks on back button, show old content, i.e. content
table in the
    // folder from where user click on the .docx link to get preview
    $(window).on("hashchange", function() {
        if (!/#preview/.test(window.location.hash)) {
    $('#content').html(oldcontent);
 $("#editor").show();
$('#content table').show();
$("#controls").show();
 oldcontent = '';
        }
    });

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.

So does anyone know what's wrong here and how to get the normal behavior?

Thanks
-- 
~LLoyD~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/owncloud/attachments/20130822/18d7591b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot from 2013-08-22 11:20:56.png
Type: image/png
Size: 242593 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/owncloud/attachments/20130822/18d7591b/attachment.png>


More information about the Owncloud mailing list