dever 7 years ago
parent
commit
657c9bfd2e
1 changed files with 39 additions and 5 deletions
  1. 39 5
      front/static/document.js

+ 39 - 5
front/static/document.js

@@ -26,6 +26,8 @@ var Document =
     show : 1,
     page : 0,
     width : 0,
+    left : 0,
+    zoom : 11,
     Init : function(option)
     {
         var self = this;
@@ -62,13 +64,33 @@ var Document =
         {
             doc.prop('outerHTML', t.msg).show();
             var e = $('.pf').eq(i);
-            var w = e.find('.w0').width();
+            var c = e.find('.w0');
+            var w = c.width();
             if (w > self.width) {
-                var z = 100 - ((w - self.width)/10);
+                var z = 100 - ((w - self.width)/self.zoom);
                 $(self.option.reader).css('zoom', z + '%');
+                if (self.left) {
+                    c = c.children().eq(0);
+                    e = c.children().eq(0);
+                    if (!e.length) {
+                        e = c;
+                    }
+                    var left = parseInt(e.css('left'));
+                    if (left <= 0) {
+                        self.left = 0;
+                    } else {
+                        var e = c.children().eq(3);
+                        if (e.length) {
+                            var left = parseInt(e.css('left'));
+                        }
+                    }
+                    
+                    self.left = left * -1;
+                    $(self.option.reader).css('margin-left', self.left);
+                }
+                
                 self.width = w;
             }
-            
         });
     }
 
@@ -86,6 +108,14 @@ var Document =
         if (this.option.show) {
             this.show = this.option.show;
         }
+
+        if (this.option.left) {
+            this.left = this.option.left;
+        }
+
+        if (this.option.zoom) {
+            this.zoom = this.option.zoom;
+        }
     }
 
     ,Border : function() {
@@ -117,8 +147,10 @@ var Document =
                     var p = self.page;
                     for (var i = 1; i <= self.show; i++) {
                         var page = p + i;
-                        self.MorePage(total-1, page);
-                        self.Load(page);
+                        var state = self.MorePage(total-1, page);
+                        if (state) {
+                            self.Load(page);
+                        }
                     }
                 });
                 self.MorePage(total, self.show);
@@ -140,8 +172,10 @@ var Document =
         var num = total-page;
         if (num <= 0) {
             $(this.option.more).hide();
+            return false;
         }
         $(this.option.more + '_page').html(num);
+        return true;
     }
 
     ,Height : function()