zixun.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <title></title>
  7. <link href="../css/mui.min.css" rel="stylesheet" />
  8. <link rel="stylesheet" type="text/css" href="../css/app.css" />
  9. <link href="../css/mui.imageviewer.css" rel="stylesheet" />
  10. <style>
  11. html,
  12. body {
  13. height: 100%;
  14. margin: 0px;
  15. padding: 0px;
  16. overflow: hidden;
  17. -webkit-touch-callout: none;
  18. -webkit-user-select: none;
  19. }
  20. footer {
  21. position: fixed;
  22. width: 100%;
  23. height: 50px;
  24. min-height: 50px;
  25. border-top: solid 1px #bbb;
  26. left: 0px;
  27. bottom: 0px;
  28. overflow: hidden;
  29. padding: 0px 50px;
  30. background-color: #fafafa;
  31. }
  32. .footer-left {
  33. position: absolute;
  34. width: 50px;
  35. height: 50px;
  36. left: 0px;
  37. bottom: 0px;
  38. text-align: center;
  39. vertical-align: middle;
  40. line-height: 100%;
  41. padding: 12px 4px;
  42. }
  43. .footer-right {
  44. position: absolute;
  45. width: 50px;
  46. height: 50px;
  47. right: 0px;
  48. bottom: 0px;
  49. text-align: center;
  50. vertical-align: middle;
  51. line-height: 100%;
  52. padding: 12px 5px;
  53. display: inline-block;
  54. }
  55. .footer-center {
  56. height: 100%;
  57. padding: 5px 0px;
  58. }
  59. .footer-center [class*=input] {
  60. width: 100%;
  61. height: 100%;
  62. border-radius: 5px;
  63. }
  64. .footer-center .input-text {
  65. background: #fff;
  66. border: solid 1px #ddd;
  67. padding: 10px !important;
  68. font-size: 16px !important;
  69. line-height: 18px !important;
  70. font-family: verdana !important;
  71. overflow: hidden;
  72. }
  73. .footer-center .input-sound {
  74. background-color: #eee;
  75. }
  76. .mui-content {
  77. height: 100%;
  78. padding: 44px 0px 50px 0px;
  79. overflow: auto;
  80. background-color: #eaeaea;
  81. }
  82. #msg-list {
  83. height: 100%;
  84. overflow: auto;
  85. -webkit-overflow-scrolling: touch;
  86. }
  87. .msg-item {
  88. padding: 8px;
  89. clear: both;
  90. }
  91. .msg-item .mui-item-clear {
  92. clear: both;
  93. }
  94. .msg-item .msg-user {
  95. width: 38px;
  96. height: 38px;
  97. border: solid 1px #d3d3d3;
  98. display: inline-block;
  99. background: #fff;
  100. border-radius: 3px;
  101. vertical-align: top;
  102. text-align: center;
  103. float: left;
  104. padding: 3px;
  105. color: #ddd;
  106. }
  107. .msg-item .msg-user-img{
  108. width: 38px;
  109. height: 38px;
  110. display: inline-block;
  111. border-radius: 3px;
  112. vertical-align: top;
  113. text-align: center;
  114. float: left;
  115. color: #ddd;
  116. }
  117. .msg-item .msg-content {
  118. display: inline-block;
  119. border-radius: 5px;
  120. border: solid 1px #d3d3d3;
  121. background-color: #FFFFFF;
  122. color: #333;
  123. padding: 8px;
  124. vertical-align: top;
  125. font-size: 15px;
  126. position: relative;
  127. margin: 0px 8px;
  128. max-width: 75%;
  129. min-width: 35px;
  130. float: left;
  131. }
  132. .msg-item .msg-content .msg-content-inner {
  133. overflow-x: hidden;
  134. }
  135. .msg-item .msg-content .msg-content-arrow {
  136. position: absolute;
  137. border: solid 1px #d3d3d3;
  138. border-right: none;
  139. border-top: none;
  140. background-color: #FFFFFF;
  141. width: 10px;
  142. height: 10px;
  143. left: -5px;
  144. top: 12px;
  145. -webkit-transform: rotateZ(45deg);
  146. transform: rotateZ(45deg);
  147. }
  148. .msg-item-self .msg-user,
  149. .msg-item-self .msg-content {
  150. float: right;
  151. }
  152. .msg-item-self .msg-content .msg-content-arrow {
  153. left: auto;
  154. right: -5px;
  155. -webkit-transform: rotateZ(225deg);
  156. transform: rotateZ(225deg);
  157. }
  158. .msg-item-self .msg-content,
  159. .msg-item-self .msg-content .msg-content-arrow {
  160. background-color: #4CD964;
  161. color: #fff;
  162. border-color: #2AC845;
  163. }
  164. footer .mui-icon {
  165. color: #000;
  166. }
  167. footer .mui-icon:active {
  168. color: #007AFF !important;
  169. }
  170. footer .mui-icon-paperplane:before {
  171. content: "发送";
  172. }
  173. footer .mui-icon-paperplane {
  174. /*-webkit-transform: rotateZ(45deg);
  175. transform: rotateZ(45deg);*/
  176. font-size: 16px;
  177. word-break: keep-all;
  178. line-height: 100%;
  179. padding-top: 6px;
  180. color: rgba(0, 135, 250, 1);
  181. }
  182. #msg-sound {
  183. -webkit-user-select: none !important;
  184. user-select: none !important;
  185. }
  186. .rprogress {
  187. position: absolute;
  188. left: 50%;
  189. top: 50%;
  190. width: 140px;
  191. height: 140px;
  192. margin-left: -70px;
  193. margin-top: -70px;
  194. background-image: url(../images/arecord.png);
  195. background-repeat: no-repeat;
  196. background-position: center center;
  197. background-size: 30px 30px;
  198. background-color: rgba(0, 0, 0, 0.7);
  199. border-radius: 5px;
  200. display: none;
  201. -webkit-transition: .15s;
  202. }
  203. .rschedule {
  204. background-color: rgba(0, 0, 0, 0);
  205. border: 5px solid rgba(0, 183, 229, 0.9);
  206. opacity: .9;
  207. border-left: 5px solid rgba(0, 0, 0, 0);
  208. border-right: 5px solid rgba(0, 0, 0, 0);
  209. border-radius: 50px;
  210. box-shadow: 0 0 15px #2187e7;
  211. width: 46px;
  212. height: 46px;
  213. position: absolute;
  214. left: 50%;
  215. top: 50%;
  216. margin-left: -23px;
  217. margin-top: -23px;
  218. -webkit-animation: spin 1s infinite linear;
  219. animation: spin 1s infinite linear;
  220. }
  221. .r-sigh{
  222. display: none;
  223. border-radius: 50px;
  224. box-shadow: 0 0 15px #2187e7;
  225. width: 46px;
  226. height: 46px;
  227. position: absolute;
  228. left: 50%;
  229. top: 50%;
  230. margin-left: -23px;
  231. margin-top: -23px;
  232. text-align: center;
  233. line-height: 46px;
  234. font-size: 40px;
  235. font-weight: bold;
  236. color: #2187e7;
  237. }
  238. .rprogress-sigh{
  239. background-image: none !important;
  240. }
  241. .rprogress-sigh .rschedule{
  242. display: none !important;
  243. }
  244. .rprogress-sigh .r-sigh{
  245. display: block !important;
  246. }
  247. .rsalert {
  248. font-size: 12px;
  249. color: #bbb;
  250. text-align: center;
  251. position: absolute;
  252. border-radius: 5px;
  253. width: 130px;
  254. margin: 5px 5px;
  255. padding: 5px;
  256. left: 0px;
  257. bottom: 0px;
  258. }
  259. @-webkit-keyframes spin {
  260. 0% {
  261. -webkit-transform: rotate(0deg);
  262. }
  263. 100% {
  264. -webkit-transform: rotate(360deg);
  265. }
  266. }
  267. @keyframes spin {
  268. 0% {
  269. transform: rotate(0deg);
  270. }
  271. 100% {
  272. transform: rotate(360deg);
  273. }
  274. }
  275. #h {
  276. background: #fff;
  277. border: solid 1px #ddd;
  278. padding: 10px !important;
  279. font-size: 16px !important;
  280. font-family: verdana !important;
  281. line-height: 18px !important;
  282. overflow: visible;
  283. position: absolute;
  284. left: -1000px;
  285. right: 0px;
  286. word-break: break-all;
  287. word-wrap: break-word;
  288. }
  289. .cancel {
  290. background-color: darkred;
  291. }
  292. </style>
  293. </head>
  294. <body contextmenu="return false;">
  295. <header class="mui-bar mui-bar-nav">
  296. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  297. <h1 class="mui-title">咨询</h1>
  298. </header>
  299. <pre id='h'></pre>
  300. <script id='msg-template' type="text/template">
  301. <% for(var i in record){ var item=record[i]; %>
  302. <div class="msg-item <%= (item.sender=='self'?' msg-item-self':'') %>" msg-type='<%=(item.type)%>' msg-content='<%=(item.content)%>'>
  303. <% if(item.sender=='self' ) { %>
  304. <i class="msg-user mui-icon mui-icon-person"></i>
  305. <% } else { %>
  306. <img class="msg-user-img" src="../images/user-photo.png" alt="" />
  307. <% } %>
  308. <div class="msg-content">
  309. <div class="msg-content-inner">
  310. <% if(item.type=='text' ) { %>
  311. <%=( item.content|| '&nbsp;&nbsp;') %>
  312. <% } else if(item.type=='image' ) { %>
  313. <img class="msg-content-image" src="<%=(item.content)%>" style="max-width: 100px;" />
  314. <% } else if(item.type=='sound' ) { %>
  315. <span class="mui-icon mui-icon-mic" style="font-size: 18px;font-weight: bold;"></span>
  316. <span class="play-state">点击播放</span>
  317. <% } %>
  318. </div>
  319. <div class="msg-content-arrow"></div>
  320. </div>
  321. <div class="mui-item-clear"></div>
  322. </div>
  323. <% } %>
  324. </script>
  325. <div class="mui-content">
  326. <div id='msg-list'>
  327. </div>
  328. </div>
  329. <footer>
  330. <div class="footer-left">
  331. <i id='msg-image' class="mui-icon mui-icon-camera" style="font-size: 28px;"></i>
  332. </div>
  333. <div class="footer-center">
  334. <textarea id='msg-text' type="text" class='input-text'></textarea>
  335. <button id='msg-sound' type="button" class='input-sound' style="display: none;">按住说话</button>
  336. </div>
  337. <label for="" class="footer-right">
  338. <i id='msg-type' class="mui-icon mui-icon-mic"></i>
  339. </label>
  340. </footer>
  341. <div id='sound-alert' class="rprogress">
  342. <div class="rschedule"></div>
  343. <div class="r-sigh">!</div>
  344. <div id="audio_tips" class="rsalert">手指上滑,取消发送</div>
  345. </div>
  346. <script src="../js/mui.min.js"></script>
  347. <script src="../js/mui.imageViewer.js"></script>
  348. <script src="../js/arttmpl.js"></script>
  349. <script type="text/javascript" charset="utf-8">
  350. (function($, doc) {
  351. var MIN_SOUND_TIME = 800;
  352. $.init({
  353. gestureConfig: {
  354. tap: true, //默认为true
  355. doubletap: true, //默认为false
  356. longtap: true, //默认为false
  357. swipe: true, //默认为true
  358. drag: true, //默认为true
  359. hold: true, //默认为false,不监听
  360. release: true //默认为false,不监听
  361. }
  362. });
  363. template.config('escape', false);
  364. //$.plusReady=function(fn){fn();};
  365. $.plusReady(function() {
  366. plus.webview.currentWebview().setStyle({
  367. softinputMode: "adjustResize"
  368. });
  369. var showKeyboard = function() {
  370. if ($.os.ios) {
  371. var webView = plus.webview.currentWebview().nativeInstanceObject();
  372. webView.plusCallMethod({
  373. "setKeyboardDisplayRequiresUserAction": false
  374. });
  375. } else {
  376. var Context = plus.android.importClass("android.content.Context");
  377. var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
  378. var main = plus.android.runtimeMainActivity();
  379. var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
  380. imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
  381. //var view = ((ViewGroup)main.findViewById(android.R.id.content)).getChildAt(0);
  382. imm.showSoftInput(main.getWindow().getDecorView(), InputMethodManager.SHOW_IMPLICIT);
  383. //alert("ll");
  384. }
  385. };
  386. var record = [{
  387. sender: 'zs',
  388. type: 'text',
  389. content: 'Hi,我是大云益健老人服务小管家,请问有什么可以为您效劳的?'
  390. }];
  391. var ui = {
  392. body: doc.querySelector('body'),
  393. footer: doc.querySelector('footer'),
  394. footerRight: doc.querySelector('.footer-right'),
  395. footerLeft: doc.querySelector('.footer-left'),
  396. btnMsgType: doc.querySelector('#msg-type'),
  397. boxMsgText: doc.querySelector('#msg-text'),
  398. boxMsgSound: doc.querySelector('#msg-sound'),
  399. btnMsgImage: doc.querySelector('#msg-image'),
  400. areaMsgList: doc.querySelector('#msg-list'),
  401. boxSoundAlert: doc.querySelector('#sound-alert'),
  402. h: doc.querySelector('#h'),
  403. content: doc.querySelector('.mui-content')
  404. };
  405. ui.h.style.width = ui.boxMsgText.offsetWidth + 'px';
  406. //alert(ui.boxMsgText.offsetWidth );
  407. var footerPadding = ui.footer.offsetHeight - ui.boxMsgText.offsetHeight;
  408. var msgItemTap = function(msgItem, event) {
  409. var msgType = msgItem.getAttribute('msg-type');
  410. var msgContent = msgItem.getAttribute('msg-content')
  411. if (msgType == 'sound') {
  412. player = plus.audio.createPlayer(msgContent);
  413. var playState = msgItem.querySelector('.play-state');
  414. playState.innerText = '正在播放...';
  415. player.play(function() {
  416. playState.innerText = '点击播放';
  417. }, function(e) {
  418. playState.innerText = '点击播放';
  419. });
  420. }
  421. };
  422. var imageViewer = new $.ImageViewer('.msg-content-image', {
  423. dbl: false
  424. });
  425. var bindMsgList = function() {
  426. //绑定数据:
  427. /*tp.bind({
  428. template: 'msg-template',
  429. element: 'msg-list',
  430. model: record
  431. });*/
  432. ui.areaMsgList.innerHTML = template('msg-template', {
  433. "record": record
  434. });
  435. var msgItems = ui.areaMsgList.querySelectorAll('.msg-item');
  436. [].forEach.call(msgItems, function(item, index) {
  437. item.addEventListener('tap', function(event) {
  438. msgItemTap(item, event);
  439. }, false);
  440. });
  441. imageViewer.findAllImage();
  442. ui.areaMsgList.scrollTop = ui.areaMsgList.scrollHeight + ui.areaMsgList.offsetHeight;
  443. };
  444. bindMsgList();
  445. window.addEventListener('resize', function() {
  446. ui.areaMsgList.scrollTop = ui.areaMsgList.scrollHeight + ui.areaMsgList.offsetHeight;
  447. }, false);
  448. var send = function(msg) {
  449. record.push(msg);
  450. bindMsgList();
  451. toRobot(msg.content);
  452. };
  453. var toRobot = function(info) {
  454. var apiUrl = 'http://www.tuling123.com/openapi/api';
  455. $.getJSON(apiUrl, {
  456. "key": 'acfbca724ea1b5db96d2eef88ce677dc',
  457. "info": info,
  458. "userid": plus.device.uuid
  459. }, function(data) {
  460. //alert(JSON.stringify(data));
  461. record.push({
  462. sender: 'zs',
  463. type: 'text',
  464. content: data.text
  465. });
  466. bindMsgList();
  467. });
  468. };
  469. function msgTextFocus() {
  470. ui.boxMsgText.focus();
  471. setTimeout(function() {
  472. ui.boxMsgText.focus();
  473. }, 150);
  474. }
  475. //解决长按“发送”按钮,导致键盘关闭的问题;
  476. ui.footerRight.addEventListener('touchstart', function(event) {
  477. if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  478. msgTextFocus();
  479. event.preventDefault();
  480. }
  481. });
  482. //解决长按“发送”按钮,导致键盘关闭的问题;
  483. ui.footerRight.addEventListener('touchmove', function(event) {
  484. if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  485. msgTextFocus();
  486. event.preventDefault();
  487. }
  488. });
  489. // ui.footerRight.addEventListener('touchcancel', function(event) {
  490. // if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  491. // msgTextFocus();
  492. // event.preventDefault();
  493. // }
  494. // });
  495. // ui.footerRight.addEventListener('touchend', function(event) {
  496. // if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  497. // msgTextFocus();
  498. // event.preventDefault();
  499. // }
  500. // });
  501. ui.footerRight.addEventListener('release', function(event) {
  502. if (ui.btnMsgType.classList.contains('mui-icon-paperplane')) {
  503. //showKeyboard();
  504. ui.boxMsgText.focus();
  505. setTimeout(function() {
  506. ui.boxMsgText.focus();
  507. }, 150);
  508. // event.detail.gesture.preventDefault();
  509. send({
  510. sender: 'self',
  511. type: 'text',
  512. content: ui.boxMsgText.value.replace(new RegExp('\n', 'gm'), '<br/>')
  513. });
  514. ui.boxMsgText.value = '';
  515. $.trigger(ui.boxMsgText, 'input', null);
  516. } else if (ui.btnMsgType.classList.contains('mui-icon-mic')) {
  517. ui.btnMsgType.classList.add('mui-icon-compose');
  518. ui.btnMsgType.classList.remove('mui-icon-mic');
  519. ui.boxMsgText.style.display = 'none';
  520. ui.boxMsgSound.style.display = 'block';
  521. ui.boxMsgText.blur();
  522. document.body.focus();
  523. } else if (ui.btnMsgType.classList.contains('mui-icon-compose')) {
  524. ui.btnMsgType.classList.add('mui-icon-mic');
  525. ui.btnMsgType.classList.remove('mui-icon-compose');
  526. ui.boxMsgSound.style.display = 'none';
  527. ui.boxMsgText.style.display = 'block';
  528. //--
  529. //showKeyboard();
  530. ui.boxMsgText.focus();
  531. setTimeout(function() {
  532. ui.boxMsgText.focus();
  533. }, 150);
  534. }
  535. }, false);
  536. ui.footerLeft.addEventListener('tap', function(event) {
  537. var btnArray = [{
  538. title: "拍照"
  539. }, {
  540. title: "从相册选择"
  541. }];
  542. plus.nativeUI.actionSheet({
  543. title: "选择照片",
  544. cancel: "取消",
  545. buttons: btnArray
  546. }, function(e) {
  547. var index = e.index;
  548. switch (index) {
  549. case 0:
  550. break;
  551. case 1:
  552. var cmr = plus.camera.getCamera();
  553. cmr.captureImage(function(path) {
  554. send({
  555. sender: 'self',
  556. type: 'image',
  557. content: "file://" + plus.io.convertLocalFileSystemURL(path)
  558. });
  559. }, function(err) {});
  560. break;
  561. case 2:
  562. plus.gallery.pick(function(path) {
  563. send({
  564. sender: 'self',
  565. type: 'image',
  566. content: path
  567. });
  568. }, function(err) {}, null);
  569. break;
  570. }
  571. });
  572. }, false);
  573. var setSoundAlertVisable=function(show){
  574. if(show){
  575. ui.boxSoundAlert.style.display = 'block';
  576. ui.boxSoundAlert.style.opacity = 1;
  577. }else{
  578. ui.boxSoundAlert.style.opacity = 0;
  579. //fadeOut 完成再真正隐藏
  580. setTimeout(function(){
  581. ui.boxSoundAlert.style.display = 'none';
  582. },200);
  583. }
  584. };
  585. var recordCancel = false;
  586. var recorder = null;
  587. var audio_tips = document.getElementById("audio_tips");
  588. var startTimestamp = null;
  589. var stopTimestamp = null;
  590. var stopTimer = null;
  591. ui.boxMsgSound.addEventListener('hold', function(event) {
  592. recordCancel = false;
  593. if(stopTimer)clearTimeout(stopTimer);
  594. audio_tips.innerHTML = "手指上划,取消发送";
  595. ui.boxSoundAlert.classList.remove('rprogress-sigh');
  596. setSoundAlertVisable(true);
  597. recorder = plus.audio.getRecorder();
  598. if (recorder == null) {
  599. plus.nativeUI.toast("不能获取录音对象");
  600. return;
  601. }
  602. startTimestamp = (new Date()).getTime();
  603. recorder.record({
  604. filename: "_doc/audio/"
  605. }, function(path) {
  606. if (recordCancel) return;
  607. send({
  608. sender: 'self',
  609. type: 'sound',
  610. content: path
  611. });
  612. }, function(e) {
  613. plus.nativeUI.toast("录音时出现异常: " + e.message);
  614. });
  615. }, false);
  616. ui.body.addEventListener('drag', function(event) {
  617. //console.log('drag');
  618. if (Math.abs(event.detail.deltaY) > 50) {
  619. if (!recordCancel) {
  620. recordCancel = true;
  621. if (!audio_tips.classList.contains("cancel")) {
  622. audio_tips.classList.add("cancel");
  623. }
  624. audio_tips.innerHTML = "松开手指,取消发送";
  625. }
  626. } else {
  627. if (recordCancel) {
  628. recordCancel = false;
  629. if (audio_tips.classList.contains("cancel")) {
  630. audio_tips.classList.remove("cancel");
  631. }
  632. audio_tips.innerHTML = "手指上划,取消发送";
  633. }
  634. }
  635. }, false);
  636. ui.boxMsgSound.addEventListener('release', function(event) {
  637. //console.log('release');
  638. if (audio_tips.classList.contains("cancel")) {
  639. audio_tips.classList.remove("cancel");
  640. audio_tips.innerHTML = "手指上划,取消发送";
  641. }
  642. //
  643. stopTimestamp = (new Date()).getTime();
  644. if (stopTimestamp - startTimestamp < MIN_SOUND_TIME) {
  645. audio_tips.innerHTML = "录音时间太短";
  646. ui.boxSoundAlert.classList.add('rprogress-sigh');
  647. recordCancel = true;
  648. stopTimer=setTimeout(function(){
  649. setSoundAlertVisable(false);
  650. },800);
  651. }else{
  652. setSoundAlertVisable(false);
  653. }
  654. recorder.stop();
  655. }, false);
  656. ui.boxMsgSound.addEventListener("touchstart", function(e) {
  657. //console.log("start....");
  658. e.preventDefault();
  659. });
  660. ui.boxMsgText.addEventListener('input', function(event) {
  661. ui.btnMsgType.classList[ui.boxMsgText.value == '' ? 'remove' : 'add']('mui-icon-paperplane');
  662. ui.btnMsgType.setAttribute("for", ui.boxMsgText.value == '' ? '' : 'msg-text');
  663. ui.h.innerText = ui.boxMsgText.value.replace(new RegExp('\n', 'gm'), '\n-') || '-';
  664. ui.footer.style.height = (ui.h.offsetHeight + footerPadding) + 'px';
  665. ui.content.style.paddingBottom = ui.footer.style.height;
  666. });
  667. ui.boxMsgText.addEventListener('tap', function(event) {
  668. ui.boxMsgText.focus();
  669. setTimeout(function() {
  670. ui.boxMsgText.focus();
  671. }, 0);
  672. }, false);
  673. });
  674. }(mui, document));
  675. </script>
  676. </body>
  677. </html>