From 821ae624d284712ccd6a5b01ecc4b1a24fc609db Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Mon, 28 Jan 2013 22:11:42 +0800 Subject: [PATCH] auto hide sidebar if empty --- share/manifest | 2 +- share/pdf2htmlEX.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/share/manifest b/share/manifest index 962e4fe..c21a58e 100644 --- a/share/manifest +++ b/share/manifest @@ -33,7 +33,7 @@ $css """ diff --git a/share/pdf2htmlEX.js b/share/pdf2htmlEX.js index cd850d8..5f9f339 100644 --- a/share/pdf2htmlEX.js +++ b/share/pdf2htmlEX.js @@ -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..) */