~pvigo/+junk/owncloud-14.04

« back to all changes in this revision

Viewing changes to share/owncloud/apps/files_pdfviewer/js/loader.js

  • Committer: Pablo Vigo
  • Date: 2014-12-15 13:36:46 UTC
  • Revision ID: pvigo@xtec.cat-20141215133646-7d6it90e1dbsijc2
2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function hidePDFviewer() {
 
2
        $('#content table').show();
 
3
        $("#controls").show();
 
4
        $("#editor").show();
 
5
        $('#pdframe, #pdfbar').remove();
 
6
        if ($('#isPublic').val()){
 
7
                $('#preview').css({height: null});
 
8
        }
 
9
}
 
10
 
 
11
function showPDFviewer(dir,filename){
 
12
        if(!showPDFviewer.shown){
 
13
                var $iframe;
 
14
                $("#editor").hide();
 
15
                $('#content table').hide();
 
16
                $("#controls").hide();
 
17
                var oldcontent = $("#content").html();
 
18
                var viewer = OC.linkTo('files_pdfviewer', 'viewer.php')+'?dir='+encodeURIComponent(dir).replace(/%2F/g, '/')+'&file='+encodeURIComponent(filename.replace('&', '%26'));
 
19
                $iframe = $('<iframe id="pdframe" style="width:100%;height:100%;display:block;" src="'+viewer+'" /><div id="pdfbar"><a id="close" title="Close">X</a></div>');
 
20
                if ($('#isPublic').val()){
 
21
                        // force the preview to adjust its height
 
22
                        $('#preview').append($iframe).css({height: '100%'});
 
23
                }
 
24
                else{
 
25
                        $('#content').append($iframe);
 
26
                }
 
27
                $("#pageWidthOption").attr("selected","selected");      
 
28
                $('#pdfbar').css({position:'absolute',top:'5px',right:'5px'});
 
29
                // if a filelist is present, the PDF viewer can be closed to go back there
 
30
                if ($('#fileList').length){
 
31
                        $('#close').css({display:'block',padding:'0 5px',color:'#BBBBBB','font-weight':'900',height:'18px',background:'transparent'}).click(function(){
 
32
                                hidePDFviewer();
 
33
                        });
 
34
                }
 
35
                else{
 
36
                        $('#close').css({display:'none'});
 
37
                }
 
38
        }
 
39
 
 
40
}
 
41
showPDFviewer.oldCode='';
 
42
showPDFviewer.lastTitle='';
 
43
 
 
44
$(document).ready(function(){
 
45
        // doesn't work in IE or public link mode
 
46
        if(!$.browser.msie && !$('#isPublic').val()){
 
47
                if ($('#filesApp').val() && typeof FileActions!=='undefined'){
 
48
                        FileActions.register('application/pdf','Edit', OC.PERMISSION_READ, '',function(filename){
 
49
                                showPDFviewer($('#dir').val(),filename);
 
50
                        });
 
51
                        FileActions.setDefault('application/pdf','Edit');
 
52
                }
 
53
        }
 
54
});