Opinion.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. MWF.xDesktop.requireApp("process.Xform", "$Input", null, false);
  2. MWF.xDesktop.requireApp("process.Work", "lp." + o2.language, null, false);
  3. /** @class Opinion 意见输入框。
  4. * @o2cn 意见输入框
  5. * @example
  6. * //可以在脚本中获取该组件
  7. * //方法1:
  8. * var field = this.form.get("fieldId"); //获取组件对象
  9. * //方法2
  10. * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
  11. *
  12. * var data = field.getData(); //获取值
  13. * field.setData("字符串值"); //设置值
  14. * field.hide(); //隐藏字段
  15. * var id = field.json.id; //获取字段标识
  16. * var flag = field.isEmpty(); //字段是否为空
  17. * @extends MWF.xApplication.process.Xform.$Input
  18. * @o2category FormComponents
  19. * @o2range {Process}
  20. * @hideconstructor
  21. */
  22. MWF.xApplication.process.Xform.Opinion = MWF.APPOpinion = new Class(
  23. /** @lends MWF.xApplication.process.Xform.Opinion# */
  24. {
  25. Implements: [Events],
  26. Extends: MWF.APP$Input,
  27. _loadUserInterface: function () {
  28. this._loadNode();
  29. if (this.json.compute == "show") {
  30. this._setValue(this._computeValue());
  31. } else {
  32. this._loadValue();
  33. }
  34. },
  35. _loadNode: function () {
  36. if (this.readonly) {
  37. this._loadNodeRead();
  38. } else {
  39. this._loadNodeEdit();
  40. }
  41. },
  42. _loadNodeRead: function () {
  43. this.node.empty();
  44. this.node.set({
  45. "nodeId": this.json.id,
  46. "MWFType": this.json.type
  47. });
  48. this.node.setStyle("display", "none");
  49. },
  50. validationConfigItem: function (routeName, data) {
  51. var flag = (data.status === "all") ? true : (routeName === data.decision);
  52. if (flag) {
  53. var n = this.getInputData();
  54. var v = (data.valueType === "value") ? n : n.length;
  55. switch (data.operateor) {
  56. case "isnull":
  57. if (!v && !(this.handwritingFile && this.handwritingFile[layout.session.user.distinguishedName])) {
  58. this.notValidationMode(data.prompt);
  59. return false;
  60. }
  61. break;
  62. case "notnull":
  63. if (v) {
  64. this.notValidationMode(data.prompt);
  65. return false;
  66. }
  67. break;
  68. case "gt":
  69. if (v > data.value) {
  70. this.notValidationMode(data.prompt);
  71. return false;
  72. }
  73. break;
  74. case "lt":
  75. if (v < data.value) {
  76. this.notValidationMode(data.prompt);
  77. return false;
  78. }
  79. break;
  80. case "equal":
  81. if (v == data.value) {
  82. this.notValidationMode(data.prompt);
  83. return false;
  84. }
  85. break;
  86. case "neq":
  87. if (v != data.value) {
  88. this.notValidationMode(data.prompt);
  89. return false;
  90. }
  91. break;
  92. case "contain":
  93. if (v.indexOf(data.value) != -1) {
  94. this.notValidationMode(data.prompt);
  95. return false;
  96. }
  97. break;
  98. case "notcontain":
  99. if (v.indexOf(data.value) == -1) {
  100. this.notValidationMode(data.prompt);
  101. return false;
  102. }
  103. break;
  104. }
  105. }
  106. return true;
  107. },
  108. _resetNodeEdit: function () {
  109. var input = new Element("textarea", {
  110. "styles": {
  111. "background": "transparent",
  112. "width": "100%",
  113. "border": "0px"
  114. }
  115. });
  116. input.set(this.json.properties);
  117. this.textarea = input;
  118. var node = new Element("div", {
  119. "styles": {
  120. "ovwrflow": "hidden",
  121. "position": "relative",
  122. "padding-right": "2px"
  123. }
  124. }).inject(this.node, "after");
  125. input.inject(node);
  126. this.node.destroy();
  127. this.node = node;
  128. },
  129. _loadNodeEdit: function () {
  130. if (!this.json.preprocessing) {
  131. this._resetNodeEdit();
  132. }else{
  133. this.textarea = this.node.getElement("textarea");
  134. }
  135. var input = this.node.getFirst();
  136. if( !input && this.nodeHtml ){
  137. this.node.set("html", this.nodeHtml);
  138. input = this.node.getFirst();
  139. }
  140. input.set(this.json.properties);
  141. //this.node = input;
  142. this.node.set({
  143. "id": this.json.id,
  144. "MWFType": this.json.type
  145. });
  146. this.input = input;
  147. if( this.json.isSelectIdea === "yes" ){
  148. this.selectIdeaNode = new Element("div", {"styles": this.form.css.selectIdeaNode}).inject(this.node);
  149. this.underLineNode = new Element("div", {"styles": {
  150. "border-top": "1px solid #ccc",
  151. "clear": "both"
  152. }}).inject(this.node);
  153. this.loadSelectIdea()
  154. }
  155. this.mediaActionArea = new Element("div", {"styles": this.form.css.inputOpinionMediaActionArea}).inject(this.node);
  156. if (this.json.isHandwriting !== "no") {
  157. /**
  158. * @summary 手写意见按钮按钮。
  159. * @member {Element}
  160. */
  161. this.handwritingAction = new Element("div", {
  162. "styles": this.form.css.inputOpinionHandwritingAction,
  163. "text": MWF.xApplication.process.Work.LP.handwriting
  164. }).inject(this.mediaActionArea);
  165. this.handwritingAction.addEvent("click", function () {
  166. this.handwriting();
  167. }.bind(this));
  168. }
  169. if (this.json.isAudio !== "no") {
  170. if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia) {
  171. /**
  172. * @summary 音频按钮.在浏览器支持HTML5的getUserMedia才可用。
  173. * @member {Element}
  174. */
  175. this.audioRecordAction = new Element("div", {
  176. "styles": this.form.css.inputOpinionAudioRecordAction,
  177. "text": MWF.xApplication.process.Work.LP.audioRecord
  178. }).inject(this.mediaActionArea);
  179. this.audioRecordAction.addEvent("click", function () {
  180. this.audioRecord();
  181. }.bind(this));
  182. }
  183. }
  184. this.node.addEvent("change", function () {
  185. this._setBusinessData(this.getInputData());
  186. this.fireEvent("change");
  187. }.bind(this));
  188. this.node.getFirst().addEvent("blur", function () {
  189. this.validation();
  190. this.hideSelectOpinionNode();
  191. }.bind(this));
  192. this.node.getFirst().addEvent("keyup", function () {
  193. this.validationMode();
  194. }.bind(this));
  195. this.node.getFirst().addEvent("keydown", function (e) {
  196. if (this.selectOpinionNode && (this.selectOpinionNode.getStyle("display") != "none") && this.selectOpinionNode.getFirst()) {
  197. if (e.code == 38) { //up
  198. if (this.selectedOpinionNode) {
  199. var node = this.selectedOpinionNode.getPrevious();
  200. if (!node) node = this.selectOpinionNode.getLast();
  201. this.unselectedOpinion(this.selectedOpinionNode);
  202. this.selectedOpinion(node)
  203. } else {
  204. node = this.selectOpinionNode.getLast();
  205. this.selectedOpinion(node)
  206. }
  207. }
  208. if (e.code == 40) { //down
  209. if (this.selectedOpinionNode) {
  210. var node = this.selectedOpinionNode.getNext();
  211. if (!node) node = this.selectOpinionNode.getFirst();
  212. this.unselectedOpinion(this.selectedOpinionNode);
  213. this.selectedOpinion(node)
  214. } else {
  215. node = this.selectOpinionNode.getFirst();
  216. this.selectedOpinion(node)
  217. }
  218. }
  219. if (e.code == 27) { //esc
  220. this.hideSelectOpinionNode();
  221. e.preventDefault();
  222. }
  223. if (e.code == 32 || e.code == 13) { //space
  224. if (this.selectedOpinionNode) {
  225. this.setOpinion(this.selectedOpinionNode.get("text"));
  226. e.preventDefault();
  227. }
  228. }
  229. }
  230. }.bind(this));
  231. if (!this.form.json.notLoadUserOpinion) {
  232. MWF.UD.getDataJson("userOpinion", function (json) {
  233. this.userOpinions = json;
  234. }.bind(this), false);
  235. }
  236. this.node.getFirst().addEvent("input", function (e) {
  237. this.startSearchOpinion();
  238. }.bind(this));
  239. this.node.getFirst().addEvent("focus", function () {
  240. this.startSearchOpinion();
  241. }.bind(this));
  242. },
  243. _afterLoaded: function(){
  244. if (!this.isReadonly()){
  245. this.setNodeSize();
  246. this.loadDescription();
  247. }
  248. },
  249. setNodeSize: function(){
  250. if( this.textarea ){
  251. var x = 0;
  252. if( this.selectIdeaNode ){
  253. var size = this.selectIdeaNode.getSize();
  254. x = size.x + 5;
  255. this.textarea.setStyles({
  256. "height": ( size.y - 6 ) + "px",
  257. "resize":"none",
  258. "border-bottom": "0px",
  259. "padding-right": "0px",
  260. "width": "calc( 100% - "+ x +"px )"
  261. });
  262. this.node.setStyles({
  263. "min-height": size.y + "px",
  264. "height": "auto",
  265. "overflow":"hidden",
  266. "width": "100%"
  267. });
  268. this.mediaActionArea.setStyle("right", x+"px");
  269. }
  270. }
  271. },
  272. loadSelectIdea: function(){
  273. this.selectIdeaScrollNode = new Element("div", {"styles": this.form.css.selectIdeaScrollNode}).inject(this.selectIdeaNode);
  274. this.selectIdeaAreaNode = new Element("div", {
  275. "styles": {
  276. "overflow": "hidden"
  277. }
  278. }).inject(this.selectIdeaScrollNode);
  279. MWF.require("MWF.widget.ScrollBar", function () {
  280. new MWF.widget.ScrollBar(this.selectIdeaScrollNode, {
  281. "style": "small",
  282. "where": "before",
  283. "distance": 30,
  284. "friction": 4,
  285. "indent": false,
  286. "axis": {"x": false, "y": true}
  287. });
  288. }.bind(this));
  289. MWF.UD.getDataJson("idea", function (json) {
  290. if (json) {
  291. if (json.ideas) {
  292. this.setIdeaList(json.ideas);
  293. }
  294. } else {
  295. MWF.UD.getPublicData("idea", function (pjson) {
  296. if (pjson) {
  297. if (pjson.ideas) {
  298. this.setIdeaList(pjson.ideas);
  299. }
  300. }
  301. }.bind(this));
  302. }
  303. }.bind(this));
  304. },
  305. setIdeaList: function (ideas) {
  306. var _self = this;
  307. ideas.each(function (idea) {
  308. if (!idea) return;
  309. new Element("div", {
  310. "styles": this.form.css.selectIdeaItemNode,
  311. "text": idea,
  312. "events": {
  313. "click": function () {
  314. if(_self.descriptionNode)_self.descriptionNode.setStyle("display", "none");
  315. if ( !_self.textarea.get("value") ) {
  316. _self.textarea.set("value", this.get("text"));
  317. } else {
  318. _self.textarea.set("value", _self.textarea.get("value") + ", " + this.get("text"));
  319. }
  320. },
  321. "mouseover": function () {
  322. this.setStyles(_self.form.css.selectIdeaItemNode_over);
  323. },
  324. "mouseout": function () {
  325. this.setStyles(_self.form.css.selectIdeaItemNode);
  326. }
  327. }
  328. }).inject(this.selectIdeaAreaNode);
  329. }.bind(this));
  330. },
  331. audioRecord: function () {
  332. if (!this.audioRecordNode) this.createAudioRecordNode();
  333. this.audioRecordNode.show();
  334. this.audioRecordNode.position({
  335. "relativeTo": this.node,
  336. "position": "center",
  337. "edge": "center"
  338. });
  339. var p = this.audioRecordNode.getPosition(this.form.app.content);
  340. var top = p.y;
  341. var left = p.x;
  342. if (p.y < 0) top = 10;
  343. if (p.x < 0) left = 10;
  344. this.audioRecordNode.setStyles({
  345. "top": "" + top + "px",
  346. "left": "" + left + "px"
  347. });
  348. this.soundFile = {};
  349. MWF.require("MWF.widget.AudioRecorder", function () {
  350. /**
  351. * @summary 音频意见组件.
  352. * @member {o2.widget.AudioRecorder}
  353. */
  354. this.audioRecorder = new MWF.widget.AudioRecorder(this.audioRecordNode, {
  355. "onSave": function (audioFile) {
  356. this.soundFile[layout.session.user.distinguishedName] = audioFile;
  357. if (this.previewNode) {
  358. this.previewNode.destroy();
  359. this.previewNode = null;
  360. }
  361. this.previewNode = new Element("audio", {
  362. "controls": true,
  363. "src": window.URL.createObjectURL(audioFile)
  364. }).inject(this.node);
  365. this.audioRecordNode.hide();
  366. // this.page.get("div_image").node.set("src",base64Image);
  367. }.bind(this),
  368. "onCancel": function () {
  369. this.soundFile[layout.session.user.distinguishedName] = null;
  370. delete this.soundFile[layout.session.user.distinguishedName];
  371. if (this.previewNode) {
  372. this.previewNode.destroy();
  373. this.previewNode = null;
  374. }
  375. this.audioRecordNode.hide();
  376. }.bind(this)
  377. }, null);
  378. }.bind(this));
  379. },
  380. createAudioRecordNode: function () {
  381. this.audioRecordNode = new Element("div", {"styles": this.form.css.handwritingNode}).inject(this.node, "after");
  382. var size = this.node.getSize();
  383. var y = Math.max(size.y, 320);
  384. var x = Math.max(size.x, 400);
  385. x = Math.min(x, 600);
  386. y = 320;
  387. x = 500;
  388. var zidx = this.node.getStyle("z-index").toInt() || 0;
  389. zidx = (zidx < 1000) ? 1000 : zidx;
  390. this.audioRecordNode.setStyles({
  391. "height": "" + y + "px",
  392. "width": "" + x + "px",
  393. "z-index": zidx + 1
  394. });
  395. // this.audioRecordNode.position({
  396. // "relativeTo": this.node,
  397. // "position": "center",
  398. // "edge": "center"
  399. // });
  400. },
  401. /**
  402. * @summary 弹出手写板.
  403. * @example
  404. * this.form.get("fieldId").handwriting();
  405. */
  406. handwriting: function () {
  407. if (!this.handwritingNode) this.createHandwriting();
  408. this.handwritingNode.show();
  409. if (layout.mobile) {
  410. this.handwritingNode.setStyles({
  411. "top": "0px",
  412. "left": "0px"
  413. });
  414. } else {
  415. this.handwritingNode.position({
  416. "relativeTo": this.form.app.content || this.form.container,
  417. "position": "center",
  418. "edge": "center"
  419. });
  420. //var p = this.handwritingNode.getPosition(this.form.app.content);
  421. var p = this.handwritingNode.getPosition(this.handwritingNode.getOffsetParent());
  422. var top = p.y;
  423. var left = p.x;
  424. if (p.y < 0) top = 10;
  425. if (p.x < 0) left = 10;
  426. this.handwritingNode.setStyles({
  427. "top": "" + top + "px",
  428. "left": "" + left + "px"
  429. });
  430. }
  431. },
  432. createHandwriting: function () {
  433. /**
  434. * @summary 手写板容器.
  435. * @member {Element}
  436. */
  437. this.handwritingNode = new Element("div", {"styles": this.form.css.handwritingNode}).inject(this.node, "after");
  438. var x, y;
  439. if (layout.mobile) {
  440. var bodySize = $(document.body).getSize();
  441. x = bodySize.x;
  442. y = bodySize.y;
  443. this.json.tabletWidth = 0;
  444. this.json.tabletHeight = 0;
  445. } else {
  446. var size = this.node.getSize();
  447. x = Math.max(this.json.tabletWidth || size.x, 600);
  448. this.json.tabletWidth = x;
  449. y = Math.max(this.json.tabletHeight ? (parseInt(this.json.tabletHeight) + 110) : size.y, 320);
  450. }
  451. var zidx = this.node.getStyle("z-index").toInt() || 0;
  452. zidx = (zidx < 1000) ? 1000 : zidx;
  453. this.handwritingNode.setStyles({
  454. "height": "" + y + "px",
  455. "width": "" + x + "px",
  456. "z-index": zidx + 1
  457. });
  458. if (layout.mobile) {
  459. this.handwritingNode.addEvent('touchmove', function (e) {
  460. e.preventDefault();
  461. });
  462. this.handwritingNode.setStyles({
  463. "top": "0px",
  464. "left": "0px"
  465. }).inject($(document.body));
  466. } else {
  467. this.handwritingNode.position({
  468. "relativeTo": this.node,
  469. "position": "center",
  470. "edge": "center"
  471. });
  472. }
  473. this.handwritingAreaNode = new Element("div", {"styles": this.form.css.handwritingAreaNode}).inject(this.handwritingNode);
  474. if (!layout.mobile) {
  475. this.handwritingActionNode = new Element("div", {
  476. "styles": this.form.css.handwritingActionNode,
  477. "text": MWF.xApplication.process.Work.LP.saveWrite
  478. }).inject(this.handwritingNode);
  479. var h = this.handwritingActionNode.getSize().y + this.handwritingActionNode.getStyle("margin-top").toInt() + this.handwritingActionNode.getStyle("margin-bottom").toInt();
  480. h = y - h;
  481. this.handwritingAreaNode.setStyle("height", "" + h + "px");
  482. } else {
  483. this.handwritingAreaNode.setStyle("height", "" + y + "px");
  484. }
  485. this.handwritingFile = {};
  486. MWF.require("MWF.widget.Tablet", function () {
  487. /**
  488. * @summary 手写板组件.
  489. * @member {o2.widget.Tablet}
  490. */
  491. this.tablet = new MWF.widget.Tablet(this.handwritingAreaNode, {
  492. "style": "default",
  493. "toolHidden": this.json.toolHidden || [],
  494. "contentWidth": this.json.tabletWidth || 0,
  495. "contentHeight": this.json.tabletHeight || 0,
  496. "onSave": function (base64code, base64Image, imageFile) {
  497. this.handwritingFile[layout.session.user.distinguishedName] = imageFile;
  498. if (this.previewNode) {
  499. this.previewNode.destroy();
  500. this.previewNode = null;
  501. }
  502. if (this.json.isHandwritingPreview !== "no") {
  503. this.previewNode = new Element("img", {"src": base64Image}).inject(this.node);
  504. this.previewNode.setStyles({
  505. "max-width": "90%"
  506. })
  507. }
  508. this.handwritingNode.hide();
  509. this.validation();
  510. this.fireEvent("change");
  511. // this.page.get("div_image").node.set("src",base64Image);
  512. }.bind(this),
  513. "onCancel": function () {
  514. this.handwritingFile[layout.session.user.distinguishedName] = null;
  515. delete this.handwritingFile[layout.session.user.distinguishedName];
  516. if (this.previewNode) {
  517. this.previewNode.destroy();
  518. this.previewNode = null;
  519. }
  520. this.handwritingNode.hide();
  521. }.bind(this)
  522. }, null);
  523. this.tablet.load();
  524. }.bind(this));
  525. if (layout.mobile) {
  526. opt.tools = [
  527. "save", "|",
  528. "undo",
  529. "redo", "|",
  530. "reset", "|",
  531. "cancel"
  532. ]
  533. }
  534. if (this.handwritingActionNode) {
  535. this.handwritingActionNode.addEvent("click", function () {
  536. //this.handwritingNode.hide();
  537. if (this.tablet) this.tablet.save();
  538. }.bind(this));
  539. }
  540. },
  541. unselectedOpinion: function (node) {
  542. node.setStyle("background-color", "#ffffff");
  543. this.selectedOpinionNode = null;
  544. },
  545. selectedOpinion: function (node) {
  546. node.setStyle("background-color", "#d2ddf5");
  547. this.selectedOpinionNode = node;
  548. },
  549. startSearchOpinion: function () {
  550. var t = this.input.get("value");
  551. var arr = t.split(/(,\s*){1}|(;\s*){1}|\s+/g);
  552. t = arr[arr.length - 1];
  553. if (t.length) {
  554. this.clearSearcheOpinionId();
  555. this.searcheOpinionId = window.setTimeout(function () {
  556. this.searchOpinions(t);
  557. }.bind(this), 500);
  558. } else {
  559. this.clearSearcheOpinionId();
  560. }
  561. },
  562. clearSearcheOpinionId: function () {
  563. if (this.searcheOpinionId) {
  564. window.clearTimeout(this.searcheOpinionId);
  565. this.searcheOpinionId = "";
  566. }
  567. },
  568. searchOpinions: function (t) {
  569. var value = this.input.get("value");
  570. var arr = value.split(/[\n\r]/g);
  571. lines = arr.length;
  572. value = arr[arr.length - 1];
  573. var offsetValue = value;
  574. //var offsetValue = value.substr(0, value.length-t.length);
  575. if (this.userOpinions) {
  576. var ops = this.userOpinions.filter(function (v, i) {
  577. return v.contains(t) && (v != t);
  578. }.bind(this));
  579. if (ops.length) {
  580. this.showSelectOpinionNode(ops, offsetValue, lines);
  581. } else {
  582. this.hideSelectOpinionNode(ops);
  583. }
  584. }
  585. },
  586. hideSelectOpinionNode: function () {
  587. if (this.selectOpinionNode) this.selectOpinionNode.setStyle("display", "none");
  588. },
  589. showSelectOpinionNode: function (ops, offsetValue, lines) {
  590. if (!this.selectOpinionNode) this.createSelectOpinionNode();
  591. this.selectOpinionNode.empty();
  592. ops.each(function (op) {
  593. this.createSelectOpinionOption(op);
  594. }.bind(this));
  595. var inputSize = this.input.getSize();
  596. var size = MWF.getTextSize(offsetValue, this.json.inputStyles);
  597. var offY = ((size.y - 3) * lines) + 3;
  598. if (offY > inputSize.y) offY = inputSize.y;
  599. this.selectOpinionNode.setStyle("display", "block");
  600. this.selectOpinionNode.position({
  601. "relativeTo": this.node,
  602. "position": "leftTop",
  603. "edge": "leftTop",
  604. "offset": {"x": size.x, "y": offY}
  605. });
  606. },
  607. createSelectOpinionNode: function () {
  608. this.selectOpinionNode = new Element("div", {"styles": this.form.css.opinionSelectNode}).inject(this.node);
  609. },
  610. createSelectOpinionOption: function (op) {
  611. var option = new Element("div", {
  612. "styles": this.form.css.opinionSelectOption,
  613. "text": op
  614. }).inject(this.selectOpinionNode);
  615. if (this.json.selectItemStyles) option.setStyles(this.json.selectItemStyles);
  616. option.addEvents({
  617. "mouseover": function () {
  618. this.setStyle("background-color", "#d2ddf5")
  619. },
  620. "mouseout": function () {
  621. this.setStyle("background-color", "#ffffff")
  622. },
  623. "mousedown": function () {
  624. this.setOpinion(op)
  625. }.bind(this)
  626. });
  627. },
  628. setOpinion: function (op) {
  629. var v = this.input.get("value");
  630. var arr = v.split(/(,\s*){1}|(;\s*){1}|\s+/g);
  631. t = arr[arr.length - 1];
  632. var leftStr = v.substr(0, v.length - t.length);
  633. this.input.set("value", leftStr + op);
  634. this.hideSelectOpinionNode();
  635. this._setBusinessData(this.getInputData());
  636. },
  637. loadDescription: function () {
  638. if (this.isReadonly()) return;
  639. var v = this._getBusinessData();
  640. if (!v) {
  641. if (this.json.description) {
  642. var size = this.node.getFirst().getSize();
  643. var w = size.x - 3
  644. if (this.json.showIcon != 'no' && !this.form.json.hideModuleIcon) {
  645. w = size.x - 23;
  646. }
  647. if( this.handwritingAction ){
  648. w = w - this.handwritingAction.getSize().x
  649. }
  650. if( this.audioRecordAction ){
  651. w = w - this.audioRecordAction.getSize().x
  652. }
  653. this.descriptionNode = new Element("div", {
  654. "styles": this.form.css.descriptionNode,
  655. "text": this.json.description
  656. }).inject(this.node);
  657. this.descriptionNode.setStyles({
  658. "width": "" + w + "px",
  659. "height": "" + size.y + "px",
  660. "line-height": "" + size.y + "px"
  661. });
  662. this.setDescriptionEvent();
  663. }
  664. }
  665. },
  666. setDescriptionEvent: function () {
  667. if (this.descriptionNode) {
  668. if (COMMON.Browser.Platform.name === "ios") {
  669. this.descriptionNode.addEvents({
  670. "click": function () {
  671. this.descriptionNode.setStyle("display", "none");
  672. this.node.getFirst().focus();
  673. }.bind(this)
  674. });
  675. } else if (COMMON.Browser.Platform.name === "android") {
  676. this.descriptionNode.addEvents({
  677. "click": function () {
  678. this.descriptionNode.setStyle("display", "none");
  679. this.node.getFirst().focus();
  680. }.bind(this)
  681. });
  682. } else {
  683. this.descriptionNode.addEvents({
  684. "click": function () {
  685. this.descriptionNode.setStyle("display", "none");
  686. this.node.getFirst().focus();
  687. }.bind(this)
  688. });
  689. }
  690. this.node.getFirst().addEvents({
  691. "focus": function () {
  692. this.descriptionNode.setStyle("display", "none");
  693. }.bind(this),
  694. "blur": function () {
  695. if (!this.node.getFirst().get("value")) this.descriptionNode.setStyle("display", "block");
  696. }.bind(this)
  697. });
  698. }
  699. }
  700. });