function docPreview_set_link() { $('a[href]').each(function() { var url = $(this).attr('href'); if(url.indexOf('document.php?')!=-1 && url.indexOf('action=delete')==-1 && (url.toLowerCase().indexOf('.pdf')!=-1 || url.toLowerCase().indexOf('.odt')!=-1) ) { filename = $(this).text(); if(filename == '') filename = $(this).find('img').attr('alt'); url = "javascript:docPreview_pop('/dolibarr/htdocs/docpreview/Viewer.js/v.html#"+encodeURIComponent(url)+"', '"+filename.replace(/'/g, "\\'")+"')"; link = ' '; $(this).after(link); } }); } function docPreview_pop(url, filename) { $('#docpreview').remove(); if($('#docpreview').length==0) { $('body').append('
'); } $('#docpreview').dialog({ title: "Aperçu de " + filename ,width:'80%' ,height:600 ,modal:true ,resizable: false ,close:function() { $('#docpreview iframe').attr('src', '#'); } }); $('#docpreview iframe').attr('src', url); } $(document).ready(function() { docPreview_set_link(); });