Update nav bar in response to jumpToIndex
authorMichael Ang <mang@archive.org>
Sat, 9 Oct 2010 00:28:54 +0000 (00:28 +0000)
committerMichael Ang <mang@archive.org>
Sat, 9 Oct 2010 00:28:54 +0000 (00:28 +0000)
BookReader/BookReader.js

index 18a3aa9..858ebe0 100644 (file)
@@ -1198,6 +1198,8 @@ BookReader.prototype.jumpToPage = function(pageNum) {
 //______________________________________________________________________________
 BookReader.prototype.jumpToIndex = function(index, pageX, pageY) {
 
+    this.updateNavIndex(index);
+
     if (this.constMode2up == this.mode) {
         this.autoStop();
         
@@ -3294,7 +3296,13 @@ BookReader.prototype.initNavbar = function() {
     })
     .bind('slidechange', function(event, ui) {
         $("#pagenum").hide();
-        self.jumpToIndex(ui.value);
+        
+        // recursion prevention for jumpToIndex
+        if ( $(this).data('swallowchange') ) {
+            $(this).data('swallowchange', false);
+        } else {
+            self.jumpToIndex(ui.value);
+        }
         return true;
     })
     .hover(function() {
@@ -3327,8 +3335,15 @@ BookReader.prototype.updateNavPageNum = function(index) {
     
     $('#pagenum .currentpage').text(pageStr);
 }
-        
 
+/*
+ * Update the nav bar display - does not cause navigation.
+ */
+BookReader.prototype.updateNavIndex = function(index) {
+    // We want to update the value, but normally moving the slider
+    // triggers jumpToIndex which triggers this method
+    $('#BRpager').data('swallowchange', true).slider('value', index);
+}
 
 BookReader.prototype.addSearchResult = function(queryString, pageNumber, pageIndex) {
     var uiStringSearch = "Search result"; // i18n