Tuesday, November 25, 2014

Document viewer in DSpace with JSPUI


Open the [utils.js] file in any editor

sudo gedit /dspace/webapps/jspui/utils.js

copy the following code in utils.js file


-------------------copy bellow lines in utils.js at the end of all codes--------

var flag=0
$( document ).ready(function() {
jQuery(".standard").find("a[target='_blank']").each(function(){
  jQuery(this).attr('value',jQuery(this).attr('href'));
  jQuery(this).removeAttr('href');
  jQuery(this).css("text-decoration", "underline");
  jQuery(this).css("cursor", "pointer");

 
});
  jQuery(".metadataFieldLabel").each( function(index){     
if(jQuery(this).text().trim().replace(/:/g, '').replace(" ",'') == 'EnteredBy'){
$(this).next().remove();
$(this).remove();
} });
    jQuery(".standard").find("a[target='_blank']").on( "click", function() {   
if(flag==1){
jQuery( this ).parents('table').parents('table').eq(0).find('tr:last').remove();
jQuery( this ).parents('table').parents('table').eq(0).find('tr:last').remove();
jQuery( this ).parents('table').parents('table').eq(0).append("<tr><td><object style='overflow: auto;' data='"+jQuery( this ).attr('value')+"' type='application/pdf' width='100%' height='548px'></object><td><tr>");   
}else{
flag=1;
jQuery( this ).parents('table').parents('table').eq(0).append("<tr><td><object style='overflow: auto;' data='"+jQuery( this ).attr('value')+"' type='application/pdf' width='100%' height='548px'></object><td><tr>");   
}
 

});
}); 



---------------------end up the code-------------------------------------

Document viewer can look like bellow




Post a Comment

Dspace Demo