dever 7 years ago
parent
commit
a331b32ef1
1 changed files with 32 additions and 29 deletions
  1. 32 29
      front/static/document.js

+ 32 - 29
front/static/document.js

@@ -32,25 +32,26 @@ var Document =
     Init : function(option)
     {
         var self = this;
-        var callback = function() {
-            var cb = function() {
-                var index = layer.load(0, {shade: false});
-                $(window).load(function()
-                {
+
+        $(window).load(function()
+        {
+            var callback = function() {
+                var cb = function() {
+                    var index = layer.load(0, {shade: false});
                     self.Onload(index);
-                });
+                }
+                if (typeof(layer) != 'object') {
+                    self.Script('layer/layer', cb);
+                } else {
+                    cb();
+                }
             }
-            if (typeof(layer) != 'object') {
-                self.Script('layer/layer', cb);
+            if (typeof($) != 'object') {
+                self.Script('jquery', callback);
             } else {
-                cb();
+                callback();
             }
-        }
-        if (typeof($) != 'object') {
-            self.Script('jquery', callback);
-        } else {
-            callback();
-        }
+        });
     }
 
     ,Script : function(name, callback)
@@ -73,7 +74,7 @@ var Document =
         if (script.readyState) {
             script.onreadystatechange=function() {
                 if (script.readyState == 'complete'|| script.readyState == 'loaded') {
-                    script.onreadystatechange=null;
+                    script.onreadystatechange = null;
                     callback();
                 }
             }
@@ -95,22 +96,24 @@ var Document =
         
         $.getJSON(self.option.document + '&callback=?', function(t)
         {
-            $(self.option.reader).html(t.msg);
-            layer.close(index);
+            $(self.option.reader).html(t.msg).ready(function()
+            {
+                layer.close(index);
 
-            self.width = $(self.option.reader).width();
-            if (self.option.tool) {
-                self.Tool();
-            }
+                self.width = $(self.option.reader).width();
+                if (self.option.tool) {
+                    self.Tool();
+                }
 
-            self.Border();
-            self.Scroll();
+                self.Border();
+                self.Scroll();
 
-            $('.demeter_document').each(function(i)
-            {
-                if (i < self.show) {
-                    self.Load(i);
-                }
+                $('.demeter_document').each(function(i)
+                {
+                    if (i < self.show) {
+                        self.Load(i);
+                    }
+                });
             });
         });
     }