From 88ffc2db33c3c0a5a562b740f3bfba60584e13a6 Mon Sep 17 00:00:00 2001
From: Brendan Dahl <brendan.dahl@gmail.com>
Date: Wed, 25 Apr 2012 16:38:36 -0700
Subject: [PATCH] Don't disable outline.  Add some more style to outline.

---
 web/viewer.css  | 33 ++++++++++++++-------------------
 web/viewer.html |  2 +-
 web/viewer.js   | 14 ++++++++------
 3 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/web/viewer.css b/web/viewer.css
index 576207ae9..45f8a7253 100644
--- a/web/viewer.css
+++ b/web/viewer.css
@@ -530,10 +530,10 @@ body {
 
 #outlineView {
   position: fixed;
-  width: 188px;
+  width: 192px;
   top: 33px;
   bottom: 0;
-  padding: 16px 4px 0;
+  padding: 4px 4px 0;
   overflow: auto;
   -moz-user-select:none;
   -webkit-user-select:none;
@@ -542,8 +542,13 @@ body {
   display:none;
 }
 
-/*.outlineItem {
-  width: -moz-calc(100% - 8px);
+.outlineItem > .outlineItems {
+  margin-left: 20px;
+}
+
+.outlineItem > a {
+  text-decoration: none;
+  display: block;
   height: 20px;
   padding: 2px 0 0 10px;
   margin-bottom: 1px;
@@ -553,9 +558,10 @@ body {
   line-height: 15px;
   -moz-user-select:none;
   cursor: default;
+  white-space: nowrap;
 }
 
-.outlineItem:hover {
+.outlineItem > a:hover {
   background-color: hsla(0,0%,100%,.02);
   background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
   background-clip: padding-box;
@@ -574,22 +580,11 @@ body {
               0 0 1px hsla(0,0%,0%,.2);
   color: hsla(0,0%,100%,1);
 }
-*/
 
-
-.outlineItem > .outlineItems {
-  margin-left: 20px;
-}
-
-.outlineItem > a {
-  text-decoration: none;
-  color: hsla(0,0%,100%,.8);
+.noOutline {
   font-size: 12px;
-}
-
-.outlineItem > a:hover {
-  background-color: hsla(0,0%,100%,.1);
-  color: hsla(0,0%,100%,.9);
+  color: hsla(0,0%,100%,.8);
+  font-style: italic;
 }
 
 
diff --git a/web/viewer.html b/web/viewer.html
index 4ddf25756..04eb878d9 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -43,7 +43,7 @@
         <div id="toolbarSidebar">
           <div class="splitToolbarButton toggled">
             <button id="viewThumbnail" class="toolbarButton toggled" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')"></button>
-            <button id="viewOutline" class="toolbarButton" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" disabled></button>
+            <button id="viewOutline" class="toolbarButton" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')"></button>
           </div>
         </div>
         <div id="sidebarContent">
diff --git a/web/viewer.js b/web/viewer.js
index 05f8974a2..06b20c693 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -557,13 +557,7 @@ var PDFView = {
     // outline and initial view depends on destinations and pagesRefMap
     PDFJS.Promise.all([pagesPromise, destinationsPromise]).then(function() {
       pdfDocument.getOutline().then(function(outline) {
-        if (!outline)
-          return;
-
         self.outline = new DocumentOutlineView(outline);
-        var outlineSwitchButton = document.getElementById('viewOutline');
-        outlineSwitchButton.removeAttribute('disabled');
-        self.switchSidebarView('outline');
       });
 
       self.setInitialView(storedHash, scale);
@@ -1149,6 +1143,14 @@ var DocumentOutlineView = function documentOutlineView(outline) {
     };
   }
 
+  if (!outline) {
+    var noOutline = document.createElement('div');
+    noOutline.classList.add('noOutline');
+    noOutline.textContent = 'No Outline Available';
+    outlineView.appendChild(noOutline);
+    return;
+  }
+
   var queue = [{parent: outlineView, items: outline}];
   while (queue.length > 0) {
     var levelData = queue.shift();