1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-01 07:59:00 +00:00

auto hide sidebar if empty

This commit is contained in:
Lu Wang 2013-01-28 22:11:42 +08:00
parent f16e346e65
commit 821ae624d2
2 changed files with 14 additions and 2 deletions

View File

@ -33,7 +33,7 @@ $css
"""
<script type="text/javascript">
new pdf2htmlEX.Viewer('pdf-main');
new pdf2htmlEX.Viewer('pdf-main', 'pdf-outline');
</script>
<title></title>

View File

@ -94,8 +94,9 @@ var pdf2htmlEX = (function(){
}
});
pdf2htmlEX.Viewer = function(container_id) {
pdf2htmlEX.Viewer = function(container_id, outline_id) {
this.container_id = container_id;
this.outline_id = outline_id;
this.init_before_loading_content();
var _ = this;
@ -115,6 +116,17 @@ var pdf2htmlEX = (function(){
init_after_loading_content : function() {
this.container = $('#'+this.container_id);
// hide sidebar if there is no outline items
{
// need a better design
// e.g. class for sidebar on/off & selector rule for pdf-main
var sidebar = $('#'+this.outline_id);
if(sidebar.children().length == 0) {
sidebar.hide();
this.container.offset({left:0});
}
}
var new_pages = new Array();
var pl= $('.p', this.container);
/* don't use for(..in..) */