dgf 8 lat temu
rodzic
commit
a6ed4fb50a

+ 10 - 2
talkview/src/js/controller/messageController.js

@@ -1,4 +1,4 @@
-angular.module('appMessage').controller('MessageController', ['$scope', '$filter', function($scope, $filter) {
+angular.module('appMessage').controller('MessageController', ['$scope', '$filter', '$location', '$anchorScroll', function($scope, $filter, $location, $anchorScroll) {
         lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', '_Register', '', $scope);
         $scope.glued = true;
         $scope.count = true;
@@ -52,7 +52,15 @@ angular.module('appMessage').controller('MessageController', ['$scope', '$filter
             angular.element("#body").addClass("scrollGlue");
         };
         $scope.scrollShow = function() {
-            angular.element("#body").removeClass("scrollGlue");
+            if (angular.element("#body").hasClass("scrollGlue")) {
+                angular.element("#body").removeClass("scrollGlue");
+                gotoBottom();
+            } else angular.element("#body").removeClass("scrollGlue");
+        };
+
+        var gotoBottom = function() {
+            $location.hash("bottom");
+            $anchorScroll();
         };
 
     }])

+ 25 - 5
talkview/src/js/directive/currentmessage.js

@@ -5,12 +5,13 @@
         .module('appMessage')
         .directive('ngCurrentMsg', CurrentMsg);
 
-    CurrentMsg.inject = ['$location', '$anchorScroll', '$timeout'];
+    CurrentMsg.inject = ['$location', '$anchorScroll', '$compile'];
 
-    function CurrentMsg($location, $anchorScroll, $timeout) {
+    function CurrentMsg($location, $anchorScroll, $compile) {
         var directive = {
             link: link,
             restrict: 'A',
+            controller: ControllerController,
             scope: {
                 msg: '=ngCurrentMsg',
                 appContent: '=ngAppContent'
@@ -182,8 +183,8 @@
                     '<span>大小:' + getFileSize(content) + '</span>' +
                     '<div class="p-t-sm text-right">' +
                     '<span id="transinfo"><span style="color:green;" class="glyphicon glyphicon-ok"></span><span>传输完成</span></span>' +
-                    '<a class="text-primary" role="button"><span ng-click="OpenFile(content)">打开</span></a>&nbsp&nbsp' +
-                    '<a class="text-primary" role="button"><span ng-click="OpenDirectory(content)">打开文件夹</span></a>' +
+                    '<a class="text-primary" role="button"><span ng-click="OpenFile(msg.content)">打开</span></a>&nbsp&nbsp' +
+                    '<a class="text-primary" role="button"><span ng-click="OpenDirectory(msg.content)">打开文件夹</span></a>' +
                     '</div>' +
                     '</div>';
             } else if (scope.msg.contentType == 4) {
@@ -207,9 +208,28 @@
                     '</div>';
             }
             console.log(html_g);
-            var newElement = angular.element(html_g);
+
+            var compileFn = $compile(html_g);
+            // 传入scope,得到编译好的dom对象(已封装为jqlite对象)
+            // 也可以用$scope.$new()创建继承的作用域
+            var $dom = compileFn(scope);
+            // 添加到文档中
+            var newElement = angular.element($dom);
             element.append(newElement);
             message.addEventListener('load', gotoBottom());
         }
+    };
+    /* @ngInject */
+    function ControllerController($scope) {
+        $scope.OpenFile = function(item) {
+            var file = JSON.parse(item);
+            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenFile', JSON.stringify(file), $scope);
+        };
+        $scope.OpenDirectory = function(item) {
+            var file = JSON.parse(item);
+            console.log(JSON.stringify(file));
+            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenDirectory', JSON.stringify(file), $scope);
+
+        };
     }
 })();

+ 2 - 2
talkview/src/js/directive/historymessages.js

@@ -10,8 +10,8 @@
     function HistoryMsg($location, $anchorScroll, $filter, $compile) {
         var directive = {
             link: link,
-            controller: ControllerController,
             restrict: 'A',
+            controller: ControllerController,
             scope: {
                 msg: '=ngHistoryMsg',
                 appContent: '=ngAppContent',
@@ -204,6 +204,7 @@
                     '<div class="text-point"></div>' + html +
                     '</div></div></div>';
             }
+            console.log(html_g);
 
             var compileFn = $compile(html_g);
             // 传入scope,得到编译好的dom对象(已封装为jqlite对象)
@@ -211,7 +212,6 @@
             var $dom = compileFn(scope);
             // 添加到文档中
             angular.element("#loadmore").prepend($dom);
-            console.log(html_g);
             if (scope.count) {
                 message.addEventListener('load', gotoBottom());
             }

+ 3 - 0
talkview/src/less/app.main.less

@@ -24,6 +24,9 @@
     #sendmessage {
         margin-top: -10px;
     }
+    #bottom {
+        
+    }
 }
 
 .media-body {