dever 7 years ago
parent
commit
c3b351476d
2 changed files with 28 additions and 4 deletions
  1. 1 1
      front/api/main.py
  2. 27 3
      front/static/document.js

+ 1 - 1
front/api/main.py

@@ -293,7 +293,7 @@ class view_path(Load):
 		for i in style:
 			content = content + '<link rel="stylesheet" href="'+static+i+'"/>'
 
-		content = content + '<link rel="stylesheet" href="'+assets+file['key']+'.css"/>'
+		#content = content + '<link rel="stylesheet" href="'+assets+file['key']+'.css"/>'
 		#content = content + '<style>' + File.readContent(file['path'], file['key']+'.css') + '</style>'
 
 		for i in script:

+ 27 - 3
front/static/document.js

@@ -83,6 +83,26 @@ var Document =
         }
     }
 
+    ,Css : function(name, callback)
+    {
+        var self = this;
+        var link = document.createElement("link");
+        link.rel = 'stylesheet';
+        link.type = 'text/css';
+        link.href = name;
+        document.getElementsByTagName('head')[0].appendChild(link);
+        if (link.readyState) {
+            link.onreadystatechange=function() {
+                if (link.readyState == 'complete'|| link.readyState == 'loaded') {
+                    link.onreadystatechange = null;
+                    callback();
+                }
+            }
+        } else {
+            link.onload = function(){callback();}
+        }
+    }
+
     ,Sleep : function(n)
     {
         var start = new Date().getTime();
@@ -96,7 +116,9 @@ var Document =
         
         $.getJSON(self.option.document + '&callback=?', function(t)
         {
-            $(self.option.reader).html(t.msg).ready(function()
+            $(self.option.reader).html(t.msg);
+            var css = $('#page-container').attr('load-css');
+            var callback = function()
             {
                 layer.close(index);
 
@@ -114,7 +136,10 @@ var Document =
                         self.Load(i);
                     }
                 });
-            });
+            };
+
+            self.Css(css, callback);
+
         });
     }
 
@@ -150,7 +175,6 @@ var Document =
         var e = $('.pf');
         var c = e.find('.w0');
         var w = c.width();
-        var w = c.get(0).offsetWidth;
         if (w - self.width > 10) {
             var z = 100 - ((w - self.width)/self.zoom);
             $(self.option.reader).css('zoom', z + '%');