1/** 2 * description: ç§ä¿¡å¼¹åºå± 3 * author: Pollux 4 * create: 2015-11-01 5 */ 6angular.module('privateMsg.module', []) 7 .directive('privateMsg', ['courseService', '$filter', function (courseService, $filter) { 8 return { 9 restrict: 'AE', 10 templateUrl: '/tpl/common/privatemsg-0d88593966.html', 11 scope: { 12 uid: "=", // å½åç»å½ç¨æ·çid 13 privateClose: "&" // å ³éå¼¹åºå± 14 }, 15 controller: ['$scope', '$attrs', function ($scope, $attrs) { 16 17 }], 18 link: function (scope, element, attrs) { 19 20 // 坿æ¬ç¼è¾å¨èç¹ 21 var outer = angular.element(element), // ç§ä¿¡èç¹ 22 editorEle = angular.element(element).find('.chatEditor-area'), 23 hisContener = outer.find(".chatContainer"), // è天记å½èç¹ 24 ueditor; // Ueditor 25 26 // å¼¹åºå±æ¯å¦ä¸ºå¯è§ 27 scope.layerVisible = false; 28 29 // å页 30 scope.pager = { 31 page: 1, 32 pagesize: 15, 33 pages: 1 34 }; 35 36 // åå²èå¤©æ°æ® 37 scope.historyList = []; 38 39 // ç§ä¿¡è¯¦ç»ä¿¡æ¯ 40 scope.myInfo = {}; 41 42 // æ»å ±èå¤©æ»æ° 43 scope.historyTotal = 0; 44 45 // å建åéeditor 46 scope.ceateUeditor = function (content) { 47 48 // åå¨existEditorå表示已ç»å建äºeditor 49 var existEditor = editorEle.attr('existEditor'); 50 if (existEditor) { // åå¨eidtor 51 52 // 设置editor为content 53 ueditor.ready(function () { 54 ueditor.setContent(content + '' || ''); 55 }); 56 57 } else { // ä¸åå¨eidtor, åå建editor 58 59 var editorId = 'editor_' + (new Date().getTime()); 60 editorEle.append('<div id=' + editorId + ' style="width: 100%"></div>'); 61 62 // æ°å»ºueditor 63 ueditor = UE.getEditor(editorId, { 64 initialFrameHeight: '100', 65 saveInterval: 5000000000, 66 zIndex: 1800, 67 wordCount: false, 68 // pasteplain: true, 69 retainOnlyLabelPasted: true, 70 toolbars: [ 71 ['insertimage', 'link'] 72 ] 73 }); 74 75 // æ è®°å·²åå¨editor 76 ueditor.ready(function () { 77 editorEle.attr('existEditor', 1); 78 }); 79 }; 80 }; 81 82 // åå§åueditor 83 scope.ceateUeditor(); 84 85 // è·åèå¤©è®°å½ 86 scope.getMsgList = function (mobj, page, callback) { 87 88 var cdata = angular.extend({ 89 page: scope.pager.page, 90 pagesize: scope.pager.pagesize, 91 cate: 50, 92 order: 'DESC' 93 }, mobj); 94 95 courseService.getPriDetails(cdata, function (returnData) { 96 97 var list = []; 98 99 if (returnData.data) { // åå¨data 100 var ndata = returnData.data; 101 scope.myInfo = ndata.My; 102 scope.historyTotal = ndata.data.page ? ndata.data.page.total : 0; 103 scope.pager.pages = ndata.data.page ? ndata.data.page.pages : 0; 104 list = ndata.data.data || []; 105 } else { 106 scope.myInfo = mobj; 107 scope.historyTotal = 0; 108 } 109 110 callback(list) 111 }); 112 } 113 114 // çå¬ç¶çº§äºä»¶ layrPrivateMsg 115 // åæ° mobj {to: tid} æ {msgid: msgid} 116 scope.$on('layrPrivateMsg', function (e, mobj) { 117 if (!mobj.to_uid && !mobj.dialog_id) { // ä¸åå¨to_uid && ä¸åå¨dialog_id 为å¿åç¨æ· 118 return; 119 }; 120 121 // 妿å®ä¹äºuid && å½åçuidçäºè¦åéçid 122 // åæç¤ºä¸è½åç»èªå·± 123 if (angular.isDefined(attrs.uid) && scope.uid == mobj.to_uid) { 124 layer.msg("åå¦ä¸è½ç»èªå·±åç§ä¿¡"); 125 return; 126 }; 127 128 var avalidHeight = angular.element(window).height(), // å±å¹é«åº¦ 129 layerHeight = avalidHeight >= 600 ? 600 : avalidHeight; // å¼¹åºå±é«åº¦ æé«ä¸º600 130 scope.mobj = mobj; // æ¶æ¯id 131 132 // å¼¹åºpageæ¹ä¸º1 133 scope.pager.page = 1; 134 135 // 设置弹åºå±åå²è®°å½é«åº¦ 136 hisContener.height(layerHeight - 210 - 43); 137 138 // 设置弹åºå±å 容为å¯è§ 139 scope.layerVisible = false; // éèå¼¹åºå±å 容 140 scope.loadding = true; // æ¾ç¤ºå è½½å± 141 142 // è·å第1页颿¶æ¯ 143 scope.getMsgList(mobj, 1, function (list) { 144 scope.historyList = list; 145 scope.layerVisible = true; 146 scope.loadding = false;
147 }); 148 149 // æ¾ç¤ºå¼¹åºå± 150 const isExist = document.getElementById('privateMsgLayer_layui_' + mobj.to_uid); 151 !isExist && layer.open({ 152 id: 'privateMsgLayer_layui_' + mobj.to_uid, 153 title: '对è¯è®°å½', 154 move: false, 155 zIndex: 998, 156 type: 1, 157 scrollbar: false, 158 shadeClose: true, 159 content: angular.element(element), 160 area: ['765px', layerHeight + 'px', 'no'], 161 zIndex: 1000, //éç¹1 162 // success: function (layero) { 163 // layer.setTop(layero); //éç¹2 164 // }, 165 end: function () { 166 if (scope.privateClose) scope.privateClose(); 167 scope.$emit('privateClose', true); 168 } 169 }); 170 }); 171 172 // å è½½æ´å¤åå²è®°å½ 173 scope.addMoreHistory = function () { 174 175 // å è½½ä¸ä¸é¡µ 176 scope.pager.page++; 177 178 // å¤§äºæ»é¡µå return; 179 if (scope.pager.page > scope.pager.pages) { 180 return; 181 }; 182 183 scope.getMsgList(scope.mobj, scope.pager.page, function (list) { 184 185 scope.historyList = scope.historyList || []; 186 187 // æ·»å å°å½å页ç»å°¾ 188 for (var i = 0; i < list.length; i++) { 189 scope.historyList.push(list[i]) 190 }; 191 192 }); 193 }; 194 195 // ååå²è®°å½æ·»å msg 196 scope.addMsgToHistory = function (msg, ueditor) { 197 198 scope.loadding = false; // éèå è½½å± 199 hisContener.scrollTop(0); // æ»å¨å°é¡¶é¨ 200 201 // 为空ä¸è½æäº¤ 202 if (!msg) return; 203 204 // ç»è£ å½åçmsg 205 var newMsg = angular.extend({ 206 avatar: scope.myInfo.from_avatar, 207 from: scope.myInfo.from_uid, 208 to: scope.myInfo.to_uid, 209 content: msg, 210 isNew: true, // æ°æ·»å æ¶æ¯ 211 created_time: (new Date()).getTime() 212 }, scope.myInfo); 213 214 // ååå²è®°å½æ·»å æ¶æ¯ 215 scope.historyList.unshift(newMsg); 216 217 // æ»æ°+1 218 scope.historyTotal++; 219 220 // æ¸ ç©ºeditor 221 ueditor.ready(function () { // è·å坿æ¬å 容 222 ueditor.setContent(''); 223 }); 224 }; 225 226 // åéç§ä¿¡ 227 scope.addPriMsg = function () { 228 229 var content_; 230 231 // è·å坿æ¬å 容 232 ueditor.ready(function () { 233 content_ = ueditor.getContent(); 234 }); 235 236 // å¦æä¸ºç©ºåä¸æäº¤ 237 if (!content_) return; 238 239 // æ¾ç¤ºå è½½å± 240 scope.loadding = true; 241 242 // åéç§ä¿¡ 243 courseService.sendPriMsg({ 244 content: content_, 245 to_uid: scope.myInfo.to_uid 246 }, function () { 247 248 // æ·»å å°å½ååå²è®°å½ 249 scope.addMsgToHistory(content_, ueditor); 250 }).catch(function () { 251 scope.loadding = false; 252 }); 253 }; 254 } 255 }; 256 }]) 257 // å½å人æ¯å¦çäºåé人 258 .filter('isFromMe', function () { 259 return function (fid, mid) { // fid: å½åçitemçid, æçid 260 return fid == mid; 261 } 262 })
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.