Browse Source

软文手机详情页调整js代码

huangct 8 years ago
parent
commit
03971ae60b

+ 32 - 2
jpress-web-template-usoftchina/src/main/webapp/templates/usoftchina/content_uuhelper.html

@@ -4,6 +4,7 @@
 <head lang="en">
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0, user-scalable=no">
+    <script type="text/javascript" src="${CTPATH}/assets/js/jquery.min.js"></script>
     <title></title>
     <style>
         .main{
@@ -168,6 +169,7 @@
             <div><span>${(content.getMetadataByKey("push_time"))!}</span><span>${content.author!}</span></div>
         </div>
         <div class="section">
+            ${content.text!}
             <!--&lt;!&ndash;音频&ndash;&gt;-->
             <!--<div class="audio">-->
                 <!--<audio controls="controls">-->
@@ -185,7 +187,7 @@
                 <!--</video>-->
             <!--</div>-->
             <!--文本-->
-            <p>${content.text!}</p>
+            <!--<p></p>-->
             <div class="readCount"><div><span>阅读 <em>${content.view_count!'0'}</em></span><span><i class="fa fa-thumbs-up"></i><em>${content.vote_up!'0'}</em></span></div><p>${(content.getMetadataByKey("copy_right"))!}</p></div>
         </div>
         <div class="footer">
@@ -252,6 +254,34 @@
 </div>
 </body>
 <script>
-    $('html').css('fontSize',$(window).width()/640 * 30);
+    jQuery('html').css('fontSize',$(window).width()/640 * 30);
+    jQuery(window).load(function () {
+        jQuery("img").each(function () {
+            DrawImage(this, 100, 100);
+        });
+    });
+    function DrawImage(ImgD, FitWidth, FitHeight) {
+        var image = new Image();
+        image.src = ImgD.src;
+        if (image.width > 0 && image.height > 0) {
+            if (image.width / image.height >= FitWidth / FitHeight) {
+                if (image.width > FitWidth) {
+                    ImgD.width = FitWidth;
+                    ImgD.height = (image.height * FitWidth) / image.width;
+                } else {
+                    ImgD.width = image.width;
+                    ImgD.height = image.height;
+                }
+            } else {
+                if (image.height > FitHeight) {
+                    ImgD.height = FitHeight;
+                    ImgD.width = (image.width * FitHeight) / image.height;
+                } else {
+                    ImgD.width = image.width;
+                    ImgD.height = image.height;
+                }
+            }
+        }
+    }
 </script>
 </html>