Hide mode and autoplay buttons if 2up is not available. See https://bugs.edge.launch...
authorMichael Ang <mang@archive.org>
Thu, 9 Jul 2009 22:07:12 +0000 (22:07 +0000)
committerMichael Ang <mang@archive.org>
Thu, 9 Jul 2009 22:07:12 +0000 (22:07 +0000)
GnuBook/GnuBook.js

index f566895..fbfe1e3 100644 (file)
@@ -1908,20 +1908,14 @@ GnuBook.prototype.jumpIndexForRightEdgePageX = function(pageX) {
 }
 
 GnuBook.prototype.initToolbar = function(mode, ui) {
-    var modeButtons = '';
-    
-    // $$$ workaround for not displaying short books in 2up
-    if (this.canSwitchToMode(this.constMode1up) && this.canSwitchToMode(this.constMode2up)) {
-        modeButtons = " <button class='GBicon rollover one_page_mode' onclick='gb.switchMode(1); return false;'/>"
-                      + " <button class='GBicon rollover two_page_mode' onclick='gb.switchMode(2); return false;'/>";
-    }
 
     $("#GnuBook").append("<div id='GBtoolbar'><span style='float:left;'>"
         + "<a class='GBicon logo rollover' href='" + this.logoURL + "'>&nbsp;</a>"
         + " <button class='GBicon rollover zoom_out' onclick='gb.zoom1up(-1); return false;'/>" 
         + "<button class='GBicon rollover zoom_in' onclick='gb.zoom1up(1); return false;'/>"
         + " <span class='label'>Zoom: <span id='GBzoom'>25</span>%</span>"
-        + modeButtons
+        + " <button class='GBicon rollover one_page_mode' onclick='gb.switchMode(1); return false;'/>"
+        + " <button class='GBicon rollover two_page_mode' onclick='gb.switchMode(2); return false;'/>"
         + "&nbsp;&nbsp;<a class='GBblack title' href='"+this.bookUrl+"' target='_blank'>"+this.shortTitle(50)+"</a>"
         + "</span></div>");
         
@@ -1969,6 +1963,12 @@ GnuBook.prototype.initToolbar = function(mode, ui) {
     for (var icon in titles) {
         jToolbar.find(icon).attr('title', titles[icon]);
     }
+    
+    // Hide mode buttons and autoplay if 2up is not available
+    // $$$ if we end up with more than two modes we should show the applicable buttons
+    if ( !this.canSwitchToMode(this.constMode2up) ) {
+        jToolbar.find('.one_page_mode, .two_page_mode, .play, .pause').hide();
+    }
 
     // Switch to requested mode -- binds other click handlers
     this.switchToolbarMode(mode);
@@ -2353,6 +2353,9 @@ GnuBook.prototype.getEmbedCode = function() {
     return "<iframe src='" + this.getEmbedURL() + "' width='480px' height='430px'></iframe>";
 }
 
+// canSwitchToMode
+//________
+// Returns true if we can switch to the requested mode
 GnuBook.prototype.canSwitchToMode = function(mode) {
     if (mode == this.constMode2up) {
         // check there are enough pages to display