dgf před 8 roky
rodič
revize
17883d6bba

+ 1 - 0
talkview/src/html/index.html

@@ -12,6 +12,7 @@
     <!--<script src="js/jquery.min.js"></script>-->
     <script src="../bower_components/lodash/dist/lodash.js"></script>
     <script src="../bower_components/jquery/dist/jquery.min.js"></script>
+    <script src="../bower_components/jquery-lazyload/jquery.lazyload.min.js"></script>
     <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
     <script src="../bower_components/jquery-qrcode/jquery.qrcode.min.js"></script>
     <script src="../bower_components/angular/angular.js"></script>

+ 8 - 8
talkview/src/js/directive/currentmessage.js

@@ -68,19 +68,23 @@
                         scope.imgWidth = 715;
                         scope.imgHeight = 395;
                         var html = '<a class="thumbnail"' + '>' +
-                            '<img onclick="javascript:window.open(this.src,\'\',\'height=' + scope.imgHeight + ',width=' + scope.imgWidth + ',top=200,left=200,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no\')" style="max-width:270px;max-height:250px;" src="local://' + scope.appContent.directory.received + g[1] + '.png' + '" onError= "this.src = \'../img/loading.gif\'" alt="截图缩略图" >' +
+                            '<img onclick="javascript:window.open(this.src,\'\',\'height=' + scope.imgHeight + ',width=' + scope.imgWidth + ',top=200,left=200,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no\')" style="max-width:270px;max-height:250px;" src="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" onError= "this.src = \'../img/loading.gif\'" alt="截图缩略图" >' +
                             '</a>';
                         // '<div class="bigImg">' +
                         // '<img ng-click="hover = false" ng-show="hover" src="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="" >' +
                         // '</div>';
 
-                        loadImg("local://" + scope.appContent.directory.received + g[1] + ".png", addImg, error);
+                        var imgSize = loadImg("local://" + scope.appContent.directory.received + g[1] + ".JPG", addImg, errorImg);
+                        console.log(imgSize);
 
-                        function loadImg(url, callback) {
+                        function loadImg(url, callback, error) {
                             var img = new Image();
                             img.onload = function() {
                                 img.onload = null;
                                 callback(img);
+                                var imgSize = { height: img.height, width: img.width };
+                                console.log(imgSize);
+                                return imgSize;
                             }
                             img.onerror = function() {
                                 //alert("error!");
@@ -91,16 +95,12 @@
                             angular.element("img").attr("defaulturl", "../img/loading.jpg");
                         }
 
-                        function error(img) {
+                        function errorImg(img) {
                             gotoBottom();
                         }
 
                         function addImg(img) {
                             //$(img).appendTo($(".image"));
-                            scope.imgWidth = img.width;
-                            scope.imgHeight = img.height;
-                            console.log(scope.imgHeight);
-                            console.log(scope.imgWidth);
                             gotoBottom();
                         }
                         return html;

+ 12 - 6
talkview/src/js/directive/historymessages.js

@@ -70,9 +70,9 @@
                 var g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
                 while (g !== null) {
                     content = content.replace(g[0],
-                        '<a href="#" class="thumbnail"' + '>' +
-                        // '<img class="lazy" style="max-width:270px;max-height:250px;" src="../img/loading.jpg" data-original="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="" >' +
-                        '<img class="lazy" style="max-width:270px;max-height:250px;" src="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="" >' +
+                        '<a class="thumbnail"' + '>' +
+                        '<img onclick="javascript:window.open(this.src,\'\',\'height=600,width=800,top=200,left=200\')" class="lazy" style="max-width:270px;max-height:250px;" src="../img/loading.gif" data-original="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="截图缩略图" >' +
+                        // '<img onclick="javascript:window.open(this.src,\'\',\'height=600,width=800,top=200,left=200,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no\')" style="max-width:270px;max-height:250px;" src="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="截图缩略图" >' +
                         '</a>'
                     );
                     g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
@@ -212,9 +212,15 @@
             var $dom = compileFn(scope);
             // 添加到文档中
             angular.element("#loadmore").prepend($dom);
-            if (scope.count) {
-                message.addEventListener('load', gotoBottom());
-            }
+            if (scope.count && angular.element("img").hasClass("lazy")) {
+                angular.element("img.lazy").lazyload();
+                gotoBottom();
+                console.log("1");
+            } else if (scope.count) {
+                gotoBottom();
+                console.log("0");
+            } else
+                angular.element("img.lazy").lazyload();
         }
     };
     /* @ngInject */