uiKit.min.js
7.2 KB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NIMUIKit=e():t.NIMUIKit=e()}(this,function(){return function(t){function e(n){if(a[n])return a[n].exports;var i=a[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var a={};return e.m=t,e.c=a,e.p="",e(0)}([function(t,e,a){"use strict";var n={};n.SessionList=a(1),n.FriendList=a(3),n.TeamList=a(4),t.exports=n},function(t,e,a){"use strict";var n=a(2),i=function(t){var e=t.parent,a=t.data,i=t.onclickitem||function(t,e){console.log("account:"+t+"---type:"+e)},o=t.onclickavatar||function(t,e){console.log("account:"+t+"---type:"+e)};this._body=document.createElement("ul"),this._body.className=t.clazz||"m-panel j-session",this.provider=t.infoprovider,n.addEvent(this._body,"click",function(t){for(var e,a,n=this,r=t||window.event,s=r.srcElement||r.target;n!==s;){if("img"===s.tagName.toLowerCase()){var c=s.parentNode.parentNode;return e=c.getAttribute("data-account"),a=c.getAttribute("data-scene"),void o(e,a)}if("li"===s.tagName.toLowerCase())return e=s.getAttribute("data-account"),a=s.getAttribute("data-scene"),void i(e,a);s=s.parentNode}}),this.update(a),e&&this.inject(e)};i.prototype.inject=function(t){var e=n.getNode(t);e.innerHTML="",e.appendChild(this._body)},i.prototype.update=function(t){var e,a,n,i="",o=t.sessions;if(0===o.length)i+='<p class="empty">暂无最近联系人哦</p>';else for(e=0;e<o.length;e++)if(n=this.provider(o[e],"session")){var r=n.account,s=t.personSubscribes,c="";if("p2p"===n.scene&&window.CONFIG&&window.CONFIG.openSubscription&&(c="离线",s[r]&&s[r][1]&&(c=s[r][1].multiPortStatus||"离线")),""!==c)var l="["+c+"] "+n.text;else l=n.text;a=['<li class="panel_item '+(n.crtSession===n.target?"active":"")+'" data-scene="'+n.scene+'" data-account="'+n.account+'">','<div class="panel_avatar"><img class="panel_image" src="'+n.avatar+'"/></div>','<div class="panel_text">','<p class="panel_multi-row">','<span class="panel_nick">'+n.nick+"</span>",'<b class="panel_time">'+n.time+"</b>","</p>",'<p class="panel_multi-row">','<span class="panel_lastMsg">'+l+"</span>",n.unread?'<b class="panel_count">'+n.unread+"</b>":"","</p>","</div>","</li>"].join(""),i+=a}this._body.innerHTML=i},i.prototype.destory=function(){},t.exports=i},function(t,e){"use strict";var a={getNode:function(t,e){return this.isString(t)?(e=e||document,e.querySelector(t)):this.isElement(t)?t:void console.error("输入参数必须为node||String")},getNodes:function(t){return document.querySelectorAll(t)},isString:function(t){return"string"==typeof t},isElement:function(t){return!(!t||1!==t.nodeType)},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},addEvent:function(t,e,a){window.addEventListener?t.addEventListener(e,a,!1):t.attachEvent("on"+e,a)},hasClass:function(t,e){return e=e||"",0===e.replace(/\s/g,"").length?!1:new RegExp(" "+e+" ").test(" "+t.className+" ")},addClass:function(t,e){t&&(this.hasClass(t,e)||(t.className+=" "+e))},removeClass:function(t,e){if(t&&this.hasClass(t,e)){for(var a=" "+t.className.replace(/[\t\r\n]/g,"")+" ";a.indexOf(" "+e+" ")>=0;)a=a.replace(" "+e+" "," ");t.className=a.replace(/^\s+|\s+$/g,"")}},safeHtml:function(){var t=/<br\/?>$/,e={r:/<|>|\&|\r|\n|\s|\'|\"/g,"<":"<",">":">","&":"&"," ":" ",'"':""","'":"'","\n":"<br/>","\r":""};return function(a){return a=n(e,a),a.replace(t,"<br/><br/>")}}()},n=function(t,e){return e=""+e,t&&e?e.replace(t.r,function(e){var a=t[t.i?e:e.toLowerCase()];return null!=a?a:e}):e||""};t.exports=a},function(t,e,a){"use strict";var n,i=a(2),o=function(t){var e=t.parent,a=t.data,o=t.onclickitem||function(t,e){console.log("account:"+t+"---type:"+e)},r=t.onclickavatar||function(t,e){console.log("account:"+t+"---type:"+e)};n=t.account,this.provider=t.infoprovider,this._body=document.createElement("ul"),this._body.className=t.clazz||"m-panel j-friend",i.addEvent(this._body,"click",function(t){for(var e,a,n=this,i=t||window.event,s=i.srcElement||i.target;n!==s;){if("img"===s.tagName.toLowerCase()){var c=s.parentNode.parentNode;return e=c.getAttribute("data-account"),a=c.getAttribute("data-scene"),void r(e,a)}if("li"===s.tagName.toLowerCase())return e=s.getAttribute("data-account"),a=s.getAttribute("data-scene"),void o(e,a);s=s.parentNode}}),this.update(a),e&&this.inject(e)};o.prototype.inject=function(t){var e=i.getNode(t);e.innerHTML="",e.appendChild(this._body)},o.prototype.update=function(t){for(var e,a="",i=t.friends,o=0;o<i.length;o++)if(e=this.provider(i[o],"friend"),i[o].account!==n){var r=i[o].account,s=t.personSubscribes,c="";window.CONFIG&&window.CONFIG.openSubscription&&(c="[离线]",s[r]&&s[r][1]&&(c=s[r][1].multiPortStatus||"离线",c="["+c+"]")),a+=['<li class="panel_item '+(e.crtSession===e.target?"active":"")+'" data-scene="p2p" data-account="'+e.account+'">','<div class="panel_avatar"><img class="panel_image" src="'+e.avatar+'"/></div>','<div class="panel_text">','<p class="panel_single-row">'+e.nick+" "+c+"</p>","</div>","</li>"].join("")}this._body.innerHTML=a},o.prototype.destory=function(){},t.exports=o},function(t,e,a){"use strict";var n=a(2),i=function(t){var e=this,a=t.parent,i=t.data,o=t.onclickitem||function(t,e){console.log("account:"+t+"---type:"+e)},r=t.onclickavatar||function(t,e){console.log("account:"+t+"---type:"+e)};this._body=document.createElement("ul"),this._body.className=(t.clazz||"m-panel")+" j-team",this.provider=t.infoprovider,n.addEvent(this._body,"click",function(t){for(var a,i,s=this,c=t||window.event,l=c.srcElement||c.target;s!==l;){if("img"===l.tagName.toLowerCase()){var d=l.parentNode.parentNode;return a=d.getAttribute("data-account"),i=d.getAttribute("data-type"),void r(a,i)}if("li"===l.tagName.toLowerCase())return a=l.getAttribute("data-account"),i=l.getAttribute("data-type"),n.removeClass(n.getNode(".j-team li.active",e._body),"active"),n.addClass(l,"active"),void o(a,i);l=l.parentNode}}),this.update(i),a&&this.inject(a)};i.prototype.inject=function(t){var e=n.getNode(t);e.innerHTML="",e.appendChild(this._body)},i.prototype.update=function(t){var e,a='<div class="panel_team"><div class="panel_team-title">讨论组</div><ul class="j-normalTeam">',n='<div class=" panel_team"><div class="panel_team-title">高级群</div><ul class="j-advanceTeam">',i=!1,o=!1,r="",s=t.teams;if(s&&s.length>0){for(var c=0,l=s.length;l>c;++c)e=this.provider(s[c],"team"),"normal"===e.type?(i=!0,a+=['<li class="panel_item '+(e.crtSession===e.target?"active":"")+'" data-gtype="normal" data-type="team" data-account="'+e.teamId+'">','<div class="panel_avatar"><img class="panel_image" src="'+e.avatar+'"/></div>','<div class="panel_text">','<p class="panel_single-row">'+e.nick+"</p>","</div>","</li>"].join("")):"advanced"===e.type&&(o=!0,n+=['<li class="panel_item '+(e.crtSession===e.target?"active":"")+'" data-gtype="advanced" data-type="team" data-account="'+e.teamId+'">','<div class="panel_avatar"><img class="panel_image" src="'+e.avatar+'"/></div>','<div class="panel_text">','<p class="panel_single-row">'+e.nick+"</p>","</div>","</li>"].join(""));a+="</ul></div>",n+="</ul></div>",r=i&&o?n+a:i&&!o?a:!i&&o?n:"<p>暂时还没有群哦</p>"}else r="<p>暂时还没有群哦</p>";this._body.innerHTML=r},i.prototype.destory=function(){},t.exports=i}])});