index.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <extend name="Public:base" />
  2. <block name="content">
  3. <style>
  4. .message .frt{float:right;}
  5. .mar8{margin-right:8px;}
  6. </style>
  7. <div class="row">
  8. <div class="col-xs-12">
  9. <script id="template1" type="text/x-jquery-tmpl">
  10. <div class="message clearfix" id="${id}">
  11. <div class="user-logo">
  12. <img src="__PUBLIC__/img/head/2015.jpg">
  13. </div>
  14. <div class="wrap-text"><h5 class="clearfix">王旭</h5>
  15. <div>个的回复内容</div>
  16. </div>
  17. <div style="clear:both;"></div>
  18. </div>
  19. </script>
  20. <script id="template2" type="text/x-jquery-tmpl">
  21. <div class="message clearfix" id="${id}">
  22. <div class="user-logo frt">
  23. <img src="__PUBLIC__/img/head/2015.jpg">
  24. </div>
  25. <div class="wrap-text frt mar8" style="width:auto;">
  26. <h5 class="clearfix">黄旭</h5>
  27. <div>个的回复内容</div>
  28. </div>
  29. <div style="clear:both;"></div>
  30. </div>
  31. </script>
  32. <script id="template3" type="text/x-jquery-tmpl">
  33. <li {{if choosed==0}}class="choosed"{{/if}} id="user_${id}" data-name="${name}">
  34. {{if choosed==0}}<label class="offline"></label>{{else}}<label class="online"></label>{{/if}}
  35. <a href="javascript:;">
  36. <img src="${img}">
  37. </a>
  38. <a href="javascript:;" class="chat03_name">${name}</a>
  39. </li>
  40. </script>
  41. <script id="template4" type="text/x-jquery-tmpl">
  42. <div class="panel_box" id="${id}">
  43. <div class="chat01_title">
  44. <ul class="talkTo">
  45. <li><a href="javascript:;">${name}</a></li></ul>
  46. <a class="close_btn" href="javascript:;"></a>
  47. </div>
  48. <div class="chat01_content" id="chat01_content">
  49. </div>
  50. </div>
  51. </script>
  52. <style>
  53. .chat03_content ul li.cur_panel{background-color: #F99247;}
  54. .chat03_content ul li.new_msg{background: rgb(226, 167, 146);-webkit-animation: twinkling 1s 3 ease-in-out; }
  55. @-webkit-keyframes twinkling{ /*透明度由0到1*/
  56. 0%{
  57. opacity:0.2; /*透明度为0*/
  58. }
  59. 100%{
  60. opacity:1; /*透明度为1*/
  61. }
  62. }
  63. </style>
  64. <div class="content">
  65. <div class="chatBox">
  66. <div class="chatLeft">
  67. <div class="chat01" id="panel_box">
  68. <div class="panel_box" id="panel_nobody">
  69. <div class="chat01_title" >
  70. <ul class="talkTo">
  71. <li><a href="javascript:;">无</a></li></ul>
  72. <a class="close_btn" href="javascript:;"></a>
  73. </div>
  74. <div class="chat01_content" id="">
  75. </div>
  76. </div>
  77. </div>
  78. <div class="chat02">
  79. <div class="chat02_title">
  80. <a class="chat02_title_btn ctb02"
  81. href="javascript:;" title="选择文件">
  82. </a><a class="chat02_title_btn ctb03" href="javascript:;" title="选择附件">
  83. </a>
  84. </div>
  85. <div class="chat02_content">
  86. <textarea id="textarea"></textarea>
  87. </div>
  88. <div class="chat02_bar">
  89. <ul>
  90. <li style="right: 5px; top: 5px;">
  91. <a href="javascript:;" id="replay_msg">
  92. <img src="__PUBLIC__/img/send_btn.jpg">
  93. </a>
  94. </li>
  95. </ul>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="chatRight">
  100. <div class="chat03">
  101. <div class="chat03_title">
  102. <label class="chat03_title_t">
  103. 成员列表</label>
  104. </div>
  105. <div class="chat03_content" id="chat03_content">
  106. <ul>
  107. </ul>
  108. </div>
  109. </div>
  110. </div>
  111. <div style="clear: both;">
  112. </div>
  113. </div>
  114. </div>
  115. <div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
  116. <p></p>
  117. <p></p>
  118. </div>
  119. </div>
  120. </div>
  121. </block>
  122. <block name="javascript">
  123. <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/chat.css" />
  124. <script type="text/javascript" src="__PUBLIC__/js/jquery.tmpl.min.js"></script>
  125. <script>
  126. jQuery.fn.extend({
  127. /**
  128. * ctrl+enter提交表单
  129. * @param {Function} fn 操作后执行的函数
  130. * @param {Object} thisObj 指针作用域
  131. */
  132. ctrlSubmit:function(fn,thisObj){
  133. var obj = thisObj || this;
  134. var stat = false;
  135. return this.each(function(){
  136. $(this).keyup(function(event){
  137. //只按下ctrl情况,等待enter键的按下
  138. if(event.keyCode == 17){
  139. stat = true;
  140. //取消等待
  141. setTimeout(function(){
  142. stat = false;
  143. },300);
  144. }
  145. if(event.keyCode == 13 && (stat || event.ctrlKey)){
  146. fn.call(obj,event);
  147. }
  148. });
  149. });
  150. }
  151. });
  152. </script>
  153. <script>
  154. var s_id = 1;
  155. var user_info = [{id:1,img:'__PUBLIC__/img/head/2013.jpg',name:'gogo1',choosed:1},{id:2,img:'__PUBLIC__/img/head/2013.jpg',name:'gogo2',choosed:0}];
  156. var send_to_userid = '';
  157. $(function(){
  158. $('#template3').tmpl(user_info).appendTo('#chat03_content ul');
  159. $("#textarea").ctrlSubmit(function(event){
  160. send_replay_msg();
  161. });
  162. $('#replay_msg').click(function(){
  163. send_replay_msg();
  164. })
  165. $('#chat03_content li').click(function(){
  166. var panel_id = $(this).attr('id');
  167. var user_name = $(this).attr('data-name');
  168. if($('#panel_'+panel_id).length == 0)
  169. {
  170. var s_obj = {id:'panel_'+panel_id,name:user_name};
  171. $('#template4').tmpl(s_obj).appendTo('#panel_box');
  172. }
  173. send_to_userid = panel_id;
  174. $('#'+panel_id).removeClass('new_msg');
  175. //$('#'+panel_id).addClass('new_msg');
  176. $('#'+panel_id).addClass('cur_panel').siblings().removeClass('cur_panel');
  177. $('#panel_'+panel_id).show().siblings().hide();
  178. })
  179. $('.close_btn').live('click',function(){
  180. send_to_userid = '';
  181. $('#panel_nobody').show().siblings().hide();
  182. })
  183. })
  184. function send_replay_msg()
  185. {
  186. var s_uid = $('.cur_panel').attr('id');//user_2
  187. if(send_to_userid == '')
  188. {
  189. alert('请选择发送的会员');
  190. return false;
  191. }
  192. var link = { id:s_id,Text: 12, Link: 'http://www.cnblogs.com/xishuai/' };
  193. $('#template1').tmpl(link).appendTo('#panel_'+s_uid+' .chat01_content');
  194. $('#template2').tmpl(link).appendTo('#panel_'+s_uid+' .chat01_content');
  195. $('#template2').tmpl(link).appendTo('#panel_'+s_uid+' .chat01_content');
  196. //#s_uid chat01_content
  197. $('#textarea').val('');
  198. document.getElementById(s_id).scrollIntoView();
  199. s_id++;
  200. }
  201. </script>
  202. </block>