Documenteditor.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Class({
  3. Extends: MWF.APP$Module,
  4. options: {
  5. "moduleEvents": ["load", "postLoad", "afterLoad"],
  6. "docPageHeight": 850.4,
  7. "docPageFullWidth": 794,
  8. "pageShow": "double"
  9. },
  10. initialize: function(node, json, form, options){
  11. this.node = $(node);
  12. this.node.store("module", this);
  13. this.json = json;
  14. this.form = form;
  15. this.field = true;
  16. },
  17. _loadCss: function(reload){
  18. var key = encodeURIComponent(this.cssPath);
  19. if (!reload && o2.widget.css[key]){
  20. this.css = o2.widget.css[key];
  21. }else{
  22. this.cssPath = (this.cssPath.indexOf("?")!=-1) ? this.cssPath+"&v="+o2.version.v : this.cssPath+"?v="+o2.version.v;
  23. var r = new Request.JSON({
  24. url: this.cssPath,
  25. secure: false,
  26. async: false,
  27. method: "get",
  28. noCache: false,
  29. onSuccess: function(responseJSON, responseText){
  30. this.css = responseJSON;
  31. o2.widget.css[key] = responseJSON;
  32. }.bind(this),
  33. onError: function(text, error){
  34. console.log(error + text);
  35. }
  36. });
  37. r.send();
  38. }
  39. },
  40. load: function(){
  41. if (this.fireEvent("queryLoad")){
  42. this.cssPath = this.form.path+this.form.options.style+"/doc.wcss";
  43. this._loadCss();
  44. this._queryLoaded();
  45. this._loadUserInterface();
  46. this._loadStyles();
  47. this._afterLoaded();
  48. this.fireEvent("postLoad");
  49. this.fireEvent("load");
  50. }
  51. },
  52. _createNewPage: function(){
  53. var pageNode = new Element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.contentNode);
  54. var pageContentNode = new Element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pageNode);
  55. pageNode.set("data-pagecount", this.pages.length+1);
  56. this.pages.push(pageNode);
  57. return pageNode;
  58. },
  59. _getShow(name, typeItem, scriptItem){
  60. switch (this.json[typeItem]) {
  61. case "y":
  62. return true;
  63. case "n":
  64. return false;
  65. case "a":
  66. if (["copies", "secret", "priority", "attachment", "annotation", "copyto"].indexOf(name!=-1)){
  67. return !!this.data[name];
  68. }
  69. return true;
  70. case "s":
  71. if (this.json[scriptItem] && this.json[scriptItem].code){
  72. return !!this.form.Macro.exec(this.json[scriptItem].code, this);
  73. }
  74. return true;
  75. }
  76. },
  77. _createPage: function(){
  78. var pageContentNode = this._createNewPage().getFirst();
  79. var html = '<div class="doc_block doc_layout_copiesSecretPriority">';
  80. if (this._getShow("copies", "copiesShow", "copiesShowScript")) html += ' <div class="doc_layout_copies"></div>';
  81. if (this._getShow("secret", "secretShow", "secretShowScript")) html += ' <div class="doc_layout_secret"></div>';
  82. if (this._getShow("priority", "priorityShow", "priorityShowScript")) html += ' <div class="doc_layout_priority"></div>';
  83. html += '</div>'
  84. if (this._getShow("redHeader", "redHeaderShow", "redHeaderShowScript")) html += '<div class="doc_block doc_layout_redHeader"></div>';
  85. //@todo
  86. // '<table class="doc_block doc_layout_filenoup" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  87. // ' <tr><td class="doc_layout_filenoup_fileno_td">' +
  88. // ' <span> </span><span class="doc_layout_filenoup_fileno">浙移发〔2019〕20号</span>' +
  89. // ' </td><td class="doc_layout_filenoup_signer_td">' +
  90. // ' <table class="doc_layout_filenoup_signer_table" cellpadding="0" cellspacing="0" border="0">' +
  91. // ' <tr><td class="doc_layout_filenoup_signerTitle_td">' +
  92. // ' <span class="doc_layout_filenoup_signer">签发人:</span>' +
  93. // ' </td><td class="doc_layout_filenoup_signerContent_td">' +
  94. // ' <span class="doc_layout_filenoup_signerContent"></span><span> </span>' +
  95. // ' </td></tr>' +
  96. // ' </table>' +
  97. // ' </td></tr>' +
  98. // '</table>'+
  99. "<div class=\"doc_block doc_layout_fileno\"></div>" +
  100. "<div color=\"#ff0000\" class=\"doc_block doc_layout_redline\"></div>" +
  101. "<div class=\"doc_block doc_layout_subject\"></div>" +
  102. "<div class=\"doc_block doc_layout_mainSend\">:</div>"+
  103. "<div class=\"doc_block doc_layout_filetext\"></div>" +
  104. '<table class="doc_block doc_layout_attachment" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  105. ' <tr><td class="doc_layout_attachment_title_td">' +
  106. ' <span>  </span><span class="doc_layout_attachment_title"></span>' +
  107. ' </td><td class="doc_layout_attachment_content_td">' +
  108. ' <span class="doc_layout_attachment_content"></span>' +
  109. ' </td></tr>' +
  110. '</table>' +
  111. '<table class="doc_block doc_layout_issuance" cellpadding="0" cellspacing="0" border="0">' +
  112. ' <tr><td class="doc_layout_issuanceUnit"></td></tr>' +
  113. ' <tr><td class="doc_layout_issuanceDate"></td></tr>' +
  114. '</table>' +
  115. '<div class="doc_block doc_layout_annotation"></div>'+
  116. // pageContentNode.set("html", html);
  117. //
  118. // pageContentNode = this._createNewPage().getFirst();
  119. // html = '' +
  120. '<table class="doc_block doc_layout_edition" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  121. ' <tr><td class="doc_layout_edition_copyto">' +
  122. ' <table class="doc_layout_edition_copyto_table" align="center" cellpadding="0" cellspacing="0" border="0">' +
  123. ' <tr>' +
  124. ' <td class="doc_layout_edition_copyto_title"></td>' +
  125. ' <td class="doc_layout_edition_copyto_content"></td>' +
  126. ' </tr>' +
  127. ' </table>' +
  128. ' </td></tr>' +
  129. ' <tr><td class="doc_layout_edition_issuance">' +
  130. ' <table class="doc_layout_edition_issuance_table" align="center" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  131. ' <tr>' +
  132. ' <td class="doc_layout_edition_issuance_unit"></td>' +
  133. ' <td class="doc_layout_edition_issuance_date"></td>' +
  134. ' </tr>' +
  135. ' </table>' +
  136. ' </td></tr>' +
  137. '</table>';
  138. pageContentNode.set("html", html);
  139. },
  140. //份数 密级 紧急程度
  141. _loadCopiesSecretPriority: function(){
  142. this.layout_copiesSecretPriority = this.contentNode.getElement(".doc_layout_copiesSecretPriority");
  143. if (this.layout_copiesSecretPriority) this.layout_copiesSecretPriority.setStyles(this.css.doc_layout_copiesSecretPriority);
  144. this.layout_copies = this.contentNode.getElement(".doc_layout_copies");
  145. if (this.layout_copies) this.layout_copies.setStyles(this.css.doc_layout_copies);
  146. this.layout_secret = this.contentNode.getElement(".doc_layout_secret");
  147. if (this.layout_secret) this.layout_secret.setStyles(this.css.doc_layout_secret);
  148. this.layout_priority = this.contentNode.getElement(".doc_layout_priority");
  149. if (this.layout_priority) this.layout_priority.setStyles(this.css.doc_layout_priority);
  150. },
  151. //红头
  152. _loadRedHeader: function(){
  153. this.layout_redHeader = this.contentNode.getElement(".doc_layout_redHeader");
  154. if (this.layout_redHeader) this.layout_redHeader.setStyles(this.css.doc_layout_redHeader);
  155. },
  156. //文号签发人(上行文)
  157. _loadFileNoUp: function(){
  158. this.layout_fileNoUpTable = this.contentNode.getElement(".doc_layout_filenoup");
  159. if (this.layout_fileNoUpTable) this.layout_redHeader.setStyles(this.css.doc_layout_filenoup);
  160. var td = this.contentNode.getElement(".doc_layout_filenoup_fileno_td");
  161. if (td) this.layout_redHeader.setStyles(this.css.doc_layout_filenoup_fileno_td);
  162. this.layout_fileno = this.contentNode.getElement(".doc_layout_filenoup_fileno");
  163. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_filenoup_fileno);
  164. td = this.contentNode.getElement(".doc_layout_filenoup_signer_td");
  165. if (td) this.layout_redHeader.setStyles(this.css.doc_layout_filenoup_signer_td);
  166. var node = this.contentNode.getElement(".doc_layout_filenoup_signer_table");
  167. if (node) node.setStyles(this.css.doc_layout_filenoup_signer_table);
  168. node = this.contentNode.getElement(".doc_layout_filenoup_signerTitle_td").setStyles(this.css.doc_layout_filenoup_signerTitle_td);
  169. if (node) node.setStyles(this.css.doc_layout_filenoup_signerTitle_td);
  170. this.layout_signerTitle = this.contentNode.getElement(".doc_layout_filenoup_signer").setStyles(this.css.doc_layout_filenoup_signer);
  171. if (node) node.setStyles(this.css.doc_layout_filenoup_signer);
  172. node = this.contentNode.getElement(".doc_layout_filenoup_signerContent_td").setStyles(this.css.doc_layout_filenoup_signerContent_td);
  173. if (node) node.setStyles(this.css.doc_layout_filenoup_signerContent_td);
  174. this.layout_signer = this.contentNode.getElement(".doc_layout_filenoup_signerContent");
  175. if (this.layout_signer) this.layout_signer.setStyles(this.css.doc_layout_filenoup_signerContent);
  176. },
  177. //文号
  178. _loadFileNo: function(){
  179. this.layout_fileno = this.contentNode.getElement(".doc_layout_fileno");
  180. if (this.layout_fileno) this.layout_fileno.setStyles(this.css.doc_layout_fileno);
  181. },
  182. //红线
  183. _loadRedLine: function(){
  184. this.layout_redLine = this.contentNode.getElement(".doc_layout_redline");
  185. if (this.layout_redLine) this.layout_redLine.setStyles(this.css.doc_layout_redline);
  186. },
  187. //标题
  188. _loadSubject:function(){
  189. this.layout_subject = this.contentNode.getElement(".doc_layout_subject");
  190. if (this.layout_subject) this.layout_subject.setStyles(this.css.doc_layout_subject);
  191. },
  192. //主送
  193. _loadMainSend: function(){
  194. this.layout_mainSend = this.contentNode.getElement(".doc_layout_mainSend");
  195. if (this.layout_mainSend) this.layout_mainSend.setStyles(this.css.doc_layout_mainSend);
  196. },
  197. //正文
  198. // _createFiletext: function(filetextNode, node, where){
  199. // if (!filetextNode){
  200. // var filetextNode = new Element("div.doc_layout_filetext").inject(node, where);
  201. // filetextNode.addClass("doc_block");
  202. // filetextNode.setAttribute('contenteditable', true);
  203. // }
  204. // CKEDITOR.disableAutoInline = true;
  205. // var filetextEditor = CKEDITOR.inline(filetextNode, this._getEditorConfig());
  206. // filetextNode.store("editor", filetextEditor);
  207. // if (!this.filetextEditors) this.filetextEditors = [];
  208. // this.filetextEditors.push(filetextEditor);
  209. //
  210. // filetextEditor.on( 'blur', function(e) {
  211. // // var filetextNode = e.editor.container.$;
  212. // // var pageNode = filetextNode.getParent(".doc_layout_page");
  213. // // this._checkSplitPage(pageNode);
  214. // // this._repage();
  215. // }.bind(this));
  216. //
  217. // return filetextNode;
  218. // },
  219. _loadFiletext: function(){
  220. this.layout_filetext = this.contentNode.getElement(".doc_layout_filetext");
  221. this.layout_filetext.setStyles(this.css.doc_layout_filetext);
  222. //this.layout_filetext = this.contentNode.getElement(".doc_layout_filetext");
  223. // if (this.layout_filetexts.length){
  224. // this.layout_filetexts.each(function(layout_filetext){
  225. // layout_filetext.setStyles(this.css.doc_layout_filetext);
  226. // }.bind(this));
  227. // }
  228. },
  229. //附件
  230. _loadAttachment: function(){
  231. this.layout_attachmentTable = this.contentNode.getElement(".doc_layout_attachment");
  232. if (this.layout_attachmentTable) this.layout_attachmentTable.setStyles(this.css.doc_layout_attachment);
  233. var node = this.contentNode.getElement(".doc_layout_attachment_title_td");
  234. if (node) node.setStyles(this.css.doc_layout_attachment_title_td);
  235. this.layout_attachmentTitle = this.contentNode.getElement(".doc_layout_attachment_title");
  236. if (node) node.setStyles(this.css.doc_layout_attachment_title);
  237. node = this.contentNode.getElement(".doc_layout_attachment_content_td");
  238. if (node) node.setStyles(this.css.doc_layout_attachment_content_td);
  239. this.layout_attachment = this.contentNode.getElement(".doc_layout_attachment_content");
  240. if (this.layout_attachment) this.layout_attachment.setStyles(this.css.doc_layout_attachment_content);
  241. },
  242. //发布单位
  243. _loadIssuance: function(){
  244. this.layout_issuanceTable = this.contentNode.getElement(".doc_layout_issuance");
  245. this.layout_issuanceUnit = this.contentNode.getElement(".doc_layout_issuanceUnit");
  246. this.layout_issuanceDate = this.contentNode.getElement(".doc_layout_issuanceDate");
  247. this.layout_issuanceTable.setStyles(this.css.doc_layout_issuance);
  248. this.layout_issuanceUnit.setStyles(this.css.doc_layout_issuanceUnit);
  249. this.layout_issuanceDate.setStyles(this.css.doc_layout_issuanceDate);
  250. },
  251. //附注
  252. _loadAnnotation: function(){
  253. this.layout_annotation = this.contentNode.getElement(".doc_layout_annotation");
  254. this.layout_annotation.setStyles(this.css.doc_layout_annotation);
  255. },
  256. //版记
  257. _loadEdition: function(){
  258. this.layout_edition = this.contentNode.getElement(".doc_layout_edition").setStyles(this.css.doc_layout_edition);
  259. this.contentNode.getElement(".doc_layout_edition_copyto").setStyles(this.css.doc_layout_edition_copyto);
  260. this.contentNode.getElement(".doc_layout_edition_copyto_table").setStyles(this.css.doc_layout_edition_copyto_table);
  261. this.layout_copytoTitle = this.contentNode.getElement(".doc_layout_edition_copyto_title").setStyles(this.css.doc_layout_edition_copyto_title);
  262. this.layout_copytoContent = this.contentNode.getElement(".doc_layout_edition_copyto_content").setStyles(this.css.doc_layout_edition_copyto_content);
  263. var issuance = this.contentNode.getElement(".doc_layout_edition_issuance").setStyles(this.css.doc_layout_edition_issuance);
  264. var issuance_table = this.contentNode.getElement(".doc_layout_edition_issuance_table").setStyles(this.css.doc_layout_edition_issuance_table);
  265. this.layout_edition_issuance_unit = this.contentNode.getElement(".doc_layout_edition_issuance_unit").setStyles(this.css.doc_layout_edition_issuance_unit);
  266. this.layout_edition_issuance_date = this.contentNode.getElement(".doc_layout_edition_issuance_date").setStyles(this.css.doc_layout_edition_issuance_date);
  267. },
  268. _loadPageLayout: function(){
  269. this._loadCopiesSecretPriority();
  270. this._loadRedHeader();
  271. if (this.json.fileup){
  272. this._loadFileNoUp();
  273. }else{
  274. this._loadFileNo();
  275. }
  276. this._loadRedLine();
  277. this._loadSubject();
  278. this._loadMainSend();
  279. this._loadFiletext();
  280. this._loadAttachment();
  281. this._loadIssuance();
  282. this._loadAnnotation();
  283. this._loadEdition();
  284. // 份数: this.layout_copies
  285. // 密级: this.layout_secret
  286. // 紧急程度: this.layout_priority
  287. // 红头: this.layout_redHeader
  288. // 上行文编号签发: this.layout_fileNoUpTable
  289. // 文号: this.layout_fileno
  290. // 签发: this.layout_signerTitle
  291. // 签发人: this.layout_signer
  292. // 文号: this.layout_fileno
  293. // 红线: this.layout_redLine
  294. // 标题: this.layout_subject
  295. // 主送单位: this.layout_mainSend
  296. // 正文: this.layout_filetexts
  297. // 附件: this.layout_attachmentTitle
  298. // 附件: this.layout_attachment
  299. // 单位: this.layout_issuanceUnit
  300. // 签发时间: this.layout_issuanceDate
  301. // 附注: this.layout_annotation
  302. // 抄送: this.layout_copytoTitle
  303. // 抄送: this.layout_copytoContent
  304. // 版记单位 this.layout_edition_issuance_unit
  305. // 版记日期 this.layout_edition_issuance_date
  306. },
  307. _loadUserInterface: function(){
  308. this.node.empty();
  309. this.node.setStyles(this.form.css.documentEditorNode);
  310. this.pages = [];
  311. this.toolNode = new Element("div", {"styles": this.css.doc_toolbar}).inject(this.node);
  312. this.contentNode = new Element("div", {"styles": this.css.doc_content}).inject(this.node);
  313. this._loadToolbars();
  314. this._loadFiletextPage();
  315. if (this.options.pageShow==="single"){
  316. this._singlePage();
  317. }else{
  318. this._doublePage();
  319. }
  320. },
  321. _switchReadOrEdit: function(){
  322. if (this.eiitMode){
  323. this._readFiletext();
  324. this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdoc);
  325. this.eiitMode = false;
  326. }else{
  327. this._editFiletext();
  328. this.toolbar.childrenButton[0].setText(MWF.xApplication.process.Xform.LP.editdocCompleted)
  329. this.eiitMode = true;
  330. }
  331. },
  332. _readFiletext: function(){
  333. if (this.filetextEditor) this.filetextEditor.destroy();
  334. this.layout_filetext.setAttribute('contenteditable', false);
  335. this.data = this.getData();
  336. this._checkSplitPage(this.pages[0]);
  337. this._repage();
  338. },
  339. _editFiletext: function(){
  340. this.pages = [];
  341. this.contentNode.empty();
  342. this._createPage();
  343. this._loadPageLayout();
  344. // var docData = this._getBusinessData();
  345. // if (!docData) docData = this._getDefaultData();
  346. this.setData(this.data);
  347. this.loadCkeditorFiletext(function(e){
  348. e.editor.focus();
  349. e.editor.getSelection().scrollIntoView();
  350. }.bind(this));
  351. },
  352. _loadToolbars: function(){
  353. var html ="";
  354. if (!this.readonly) html += "<span MWFnodetype=\"MWFToolBarButton\" MWFButtonImage=\"/x_component_process_Xform/$Form/default/icon/editdoc.png\" title=\""+MWF.xApplication.process.Xform.LP.editdoc+"\" MWFButtonAction=\"_switchReadOrEdit\" MWFButtonText=\""+MWF.xApplication.process.Xform.LP.editdoc+"\"></span>";
  355. this.toolNode.set("html", html);
  356. MWF.require("MWF.widget.Toolbar", function() {
  357. this.toolbar = new MWF.widget.Toolbar(this.toolNode, {"style": "documentEdit"}, this);
  358. this.toolbar.load();
  359. }.bind(this));
  360. this.doublePageAction = new Element("div", {"styles": this.css.doc_toolbar_doublePage, "text": MWF.xApplication.process.Xform.LP.doublePage}).inject(this.toolNode);
  361. this.doublePageAction.addEvent("click", function(){
  362. if (this.options.pageShow==="single"){
  363. this._doublePage();
  364. }else{
  365. this._singlePage();
  366. }
  367. }.bind(this));
  368. },
  369. _repage: function(){
  370. if (this.options.pageShow==="single"){
  371. this._singlePage();
  372. }else{
  373. this._doublePage();
  374. }
  375. },
  376. _singlePage: function(){
  377. var w = this.contentNode.getSize().x;
  378. var count = 1;
  379. var pageWidth = count * this.options.docPageFullWidth;
  380. var margin = (w-pageWidth)/(count+1);
  381. this.pages.each(function(page, i){
  382. page.setStyles({
  383. "float": "left",
  384. "margin-left": ""+margin+"px"
  385. });
  386. });
  387. // this.pages.each(function(page){
  388. // page.setStyle("float", "none");
  389. // });
  390. this.options.pageShow="single";
  391. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.doublePage);
  392. },
  393. _doublePage: function(){
  394. var w = this.contentNode.getSize().x;
  395. var count = (w/this.options.docPageFullWidth).toInt();
  396. var pages = this.contentNode.getElements(".doc_layout_page");
  397. count = Math.min(pages.length, count);
  398. var pageWidth = count * this.options.docPageFullWidth;
  399. var margin = (w-pageWidth)/(count+1);
  400. this.pages.each(function(page, i){
  401. page.setStyles({
  402. "float": "left",
  403. "margin-left": ""+margin+"px"
  404. });
  405. });
  406. // this.pages.each(function(page, i){
  407. // if ((i % 2)===0){
  408. // page.setStyle("float", "left");
  409. // }else{
  410. // page.setStyle("float", "right");
  411. // }
  412. // });
  413. this.options.pageShow="double";
  414. this.doublePageAction.set("text", MWF.xApplication.process.Xform.LP.singlePage);
  415. },
  416. _getDefaultData: function(){
  417. return Object.clone(MWF.xApplication.process.Xform.LP.documentEditor);
  418. },
  419. _loadFiletextPage: function(){
  420. this._computeData();
  421. this._createPage();
  422. this._loadPageLayout();
  423. // this.data = this._getBusinessData();
  424. // if (!this.data) this.data = this._getDefaultData();
  425. this.setData(this.data);
  426. this._checkSplitPage(this.pages[0]);
  427. this._repage();
  428. //this.loadCkeditorFiletext();
  429. if (!this.readonly){
  430. //if (this.json.allowEditFiletext!==false) this.loadCkeditorFiletext();
  431. // if (this.json.allowEditRedheader) this.loadCkeditorRedheader();
  432. // if (this.json.allowEditSubject) this.loadCkeditorSubject();
  433. // if (this.json.allowEditMainSend) this.loadCkeditorMainSend();
  434. // if (this.json.allowEditFileNo) this.loadCkeditorFileNo();
  435. // if (this.json.allowEditSigner) this.loadCkeditorSigner();
  436. // if (this.json.allowEditAttachment) this.loadCkeditorAttachment();
  437. }
  438. },
  439. _getEditorConfig: function(){
  440. var editorConfig = {};
  441. editorConfig.toolbarGroups = [
  442. { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
  443. { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  444. { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  445. { name: 'forms', groups: [ 'forms' ] },
  446. //{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  447. { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  448. { name: 'links', groups: [ 'links' ] },
  449. "/",
  450. { name: 'insert', groups: [ 'insert' ] },
  451. { name: 'styles', groups: [ 'styles' ] },
  452. { name: 'colors', groups: [ 'colors' ] },
  453. { name: 'tools', groups: [ 'tools' ] },
  454. { name: 'others', groups: [ 'others' ] },
  455. { name: 'about', groups: [ 'about' ] }
  456. ];
  457. editorConfig.removeButtons = 'NewPage,Templates,Scayt,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Bold,Italic,Underline,Strike,Subscript,Superscript,Blockquote,CreateDiv,BidiLtr,BidiRtl,Language,Link,Unlink,Anchor,Image,Flash,HorizontalRule,Smiley,SpecialChar,Iframe,Styles,Font,FontSize,TextColor,BGColor,ShowBlocks,About';
  458. editorConfig.enterMode = 3;
  459. editorConfig.extraPlugins = ['ecnet','mathjax'];
  460. editorConfig.removePlugins = ['magicline'];
  461. editorConfig.mathJaxLib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML';
  462. return editorConfig;
  463. },
  464. _checkSplitPage: function(pageNode){
  465. if (this.layout_edition) this.layout_edition.setStyles({ "position": "static"});
  466. var contentNode = pageNode.getFirst();
  467. if (contentNode.getSize().y>this.options.docPageHeight){
  468. this._splitPage(pageNode);
  469. }
  470. var i = pageNode.get("data-pagecount").toInt();
  471. if (i && this.pages.length-1>=i){
  472. this._checkSplitPage(this.pages[i]);
  473. }
  474. if (this.layout_edition) this.layout_edition.setStyles({ "position": "absolute", "bottom": "0px" });
  475. },
  476. _splitFiletextNodeOneWord:function(lnode, nextPageNode){
  477. var text = lnode.textContent;
  478. var len = text.length;
  479. var left = text.substring(0, len-1);
  480. var right = text.substring(len-1, len);
  481. lnode.textContent = left;
  482. nextPageNode.textContent = right+nextPageNode.textContent;
  483. //nextPageNode.appendText(right, "top");
  484. },
  485. _splitFiletext: function(node, nextPageNode, nextFiletextNode, pageNode){
  486. var contentNode = pageNode.getFirst();
  487. var lnode = node.lastChild;
  488. if (!lnode){
  489. if (node.parentNode) node.parentNode.removeChild(node);
  490. //node.remove();
  491. }else{
  492. while (contentNode.getSize().y>this.options.docPageHeight && lnode) {
  493. var tmpnode = lnode.previousSibling;
  494. var nodeType = lnode.nodeType;
  495. if (!nextPageNode) nextPageNode = nextFiletextNode;
  496. if (nodeType == Node.ELEMENT_NODE) {
  497. if (lnode.tagName == "table") {
  498. lnode.inject(nextPageNode);
  499. } else if (lnode.tagName == "BR") {
  500. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  501. } else {
  502. var id = lnode.get("data-pagePart");
  503. if (!id){
  504. id = (new o2.widget.UUID()).toString();
  505. lnode.set("data-pagePart", id);
  506. }
  507. var tmpNode = nextPageNode.getFirst();
  508. if (tmpNode && tmpNode.get("data-pagePart")==id){
  509. nextPageNode = tmpNode;
  510. }else{
  511. nextPageNode = lnode.clone(false).inject(nextPageNode, "top");
  512. }
  513. //var subnode = lnode.getLast();
  514. this._splitFiletext(lnode, nextPageNode, nextFiletextNode, pageNode);
  515. if (!lnode.firstChild) if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  516. nextPageNode = nextPageNode.getParent();
  517. }
  518. } else if (nodeType == Node.TEXT_NODE) {
  519. var nextPageTextNode = nextPageNode.insertBefore(document.createTextNode(""), nextPageNode.firstChild);
  520. while ((contentNode.getSize().y > this.options.docPageHeight) && lnode.textContent) {
  521. //console.log(contentNode.getSize().y);
  522. this._splitFiletextNodeOneWord(lnode, nextPageTextNode)
  523. }
  524. if (!lnode.textContent) if (lnode.parentNode) lnode.parentNode.removeChild(lnode); //lnode.remove();
  525. } else {
  526. //lnode.remove();
  527. if (lnode.parentNode) lnode.parentNode.removeChild(lnode);
  528. }
  529. lnode = tmpnode;
  530. }
  531. if (!node.lastChild) if (node.parentNode) node.parentNode.removeChild(node); //node.remove();
  532. }
  533. //this._checkSplitPage(pageNode);
  534. },
  535. _splitPage: function(pageNode){
  536. var contentNode = pageNode.getFirst();
  537. var blockNodes = pageNode.getElements(".doc_block");
  538. if (blockNodes.length){
  539. var blockNode = blockNodes[blockNodes.length-1];
  540. var idx = this.pages.indexOf(pageNode);
  541. if (this.pages.length<=idx+1) this._createNewPage();
  542. var nextPage = this.pages[idx+1];
  543. if (blockNode.hasClass("doc_layout_filetext")){
  544. var filetextNode = nextPage.getElement(".doc_layout_filetext");
  545. if (!filetextNode){
  546. filetextNode = new Element("div.doc_layout_filetext").inject(nextPage.getFirst(), "top");
  547. //filetextNode.setAttribute('contenteditable', true);
  548. }
  549. if (!filetextNode.hasClass("doc_block"))filetextNode.addClass("doc_block");
  550. //var nextEditor = filetextNode.retrieve("editor");
  551. var node = blockNode;
  552. var nextPageNode = filetextNode;
  553. this._splitFiletext(node, nextPageNode, filetextNode, pageNode);
  554. }else{
  555. blockNode.inject(nextPage.getFirst(), "top");
  556. var contentNode = pageNode.getFirst();
  557. if (contentNode.getSize().y>this.options.docPageHeight){
  558. this._splitPage(pageNode);
  559. }
  560. }
  561. }
  562. },
  563. // _checkStartBoundary: function(editor){
  564. // var sel = editor.getSelection();
  565. // var range = sel.getRanges(true)[0];
  566. // if (range.collapsed && range.startOffset==0){
  567. // var o = range.getBoundaryNodes();
  568. // var n = o.startNode.getPrevious();
  569. // if (n && n.textContent) return false;
  570. //
  571. // var els = range.startPath().elements;
  572. // for (var i=0; i<els.length; i++){
  573. // if (els[i].getPrevious()) return false;
  574. // }
  575. // return true;
  576. // }
  577. // return false;
  578. // },
  579. // _moveToPrevEditor: function(editor){
  580. // var filetextNode = editor.container.$;
  581. // var pageNode = filetextNode.getParent(".doc_layout_page");
  582. // var prevPageNode = pageNode.getPrevious();
  583. // if (prevPageNode && prevPageNode.hasClass("doc_layout_page")){
  584. // var node = prevPageNode.getElement(".doc_layout_filetext");
  585. // if (node){
  586. // var prevEditor = node.retrieve("editor");
  587. // if (prevEditor){
  588. // prevEditor.focus();
  589. // var range = prevEditor.createRange();
  590. // range.moveToPosition(prevEditor.editable(), CKEDITOR.POSITION_BEFORE_END);
  591. // range.select();
  592. // range.scrollIntoView();
  593. // }
  594. // }
  595. // }
  596. // },
  597. // _backFromNextEditorWord:function(lastNode, nextNode, contentNode){
  598. // var text = nextNode.textContent;
  599. // var len = text.length;
  600. // var left = text.substring(0, 1);
  601. // var right = text.substring(1, len);
  602. // var oldContent = lastNode.textContent;
  603. // lastNode.textContent = oldContent+left;
  604. //
  605. // if (contentNode.getSize().y<=this.options.docPageHeight){
  606. // nextNode.textContent = right;
  607. // if (right) this._backFromNextEditorWord(lastNode, nextNode, contentNode);
  608. // }else{
  609. // lastNode.textContent = oldContent;
  610. // }
  611. // },
  612. // _checkBackFromNextEditor: function(editor){
  613. // var filetextNode = editor.container.$;
  614. // var pageNode = filetextNode.getParent(".doc_layout_page");
  615. // var contentNode = pageNode.getFirst();
  616. // var nextPageNode = pageNode.getNext();
  617. //
  618. // if (nextPageNode && nextPageNode.hasClass("doc_layout_page")){
  619. // var node = nextPageNode.getElement(".doc_layout_filetext");
  620. // if (node){
  621. // var nextEditor = node.retrieve("editor");
  622. // if (nextEditor){
  623. // var range = editor.createRange();
  624. // range.moveToPosition(editor.editable(), CKEDITOR.POSITION_BEFORE_END);
  625. // var boundaryNodes = range.getBoundaryNodes();
  626. // var id = boundaryNodes.endNode.getParent().$.get("data-pagepart");
  627. //
  628. // var nextRange = nextEditor.createRange();
  629. // nextEditor.moveToPosition(nextEditor.editable(), CKEDITOR.POSITION_AFTER_START);
  630. // var nextBoundaryNodes = nextEditor.getBoundaryNodes();
  631. // var nextId = nextBoundaryNodes.startNode.getParent().$.get("data-pagepart");
  632. //
  633. // if (id==nextId){
  634. // var lastNode = boundaryNodes.endNode.$.lastChild;
  635. // var nextNode = nextBoundaryNodes.startNode.$.firstChild;
  636. // if (!lastNode) lastNode = boundaryNodes.endNode.$.appendChild(document.createTextNode(""));
  637. // if (lastNode && nextNode) this._backFromNextEditorWord(lastNode, nextNode, contentNode);
  638. // if (!nextNode.textContent) if (nextNode.parentNode) {
  639. // nextNode.parentNode.removeChild(nextNode);
  640. // }
  641. // if ()
  642. //
  643. //
  644. // }else{
  645. //
  646. // }
  647. // }
  648. // }
  649. // }
  650. // },
  651. // _checkMergePage: function(pageNode){
  652. // var contentNode = pageNode.getFirst();
  653. // if (contentNode.getSize().y<=this.options.docPageHeight){
  654. // var i = pageNode.get("data-pagecount").toInt();
  655. // if (i && this.pages.length-1>=i){
  656. // var nextPageNode = this.pages[i];
  657. // this._mergepage(pageNode, nextPageNode);
  658. // }
  659. // }
  660. // var n = pageNode.get("data-pagecount").toInt();
  661. // if (n && this.pages.length-1>=n){
  662. // this._checkMergePage(this.pages[n]);
  663. // }
  664. // },
  665. // _checkPageHeight: function(pageNode){
  666. // var contentNode = pageNode.getFirst();
  667. // return (contentNode.getSize().y<=this.options.docPageHeight);
  668. // },
  669. // _mergeFiletextNodeOneWord:function(nextNode, prevNode, contentNode){
  670. // var text = nextNode.textContent;
  671. // var len = text.length;
  672. // var left = text.substring(0, 1);
  673. // var right = text.substring(1, len);
  674. // var oldContent = prevNode.textContent;
  675. // prevNode.textContent = oldContent+left;
  676. //
  677. // if (contentNode.getSize().y<=this.options.docPageHeight){
  678. // nextNode.textContent = right;
  679. // if (right) return this._mergeFiletextNodeOneWord(nextNode, prevNode, contentNode);
  680. // return true;
  681. // }else{
  682. // prevNode.textContent = oldContent;
  683. // return false;
  684. // }
  685. // },
  686. // _getLastTextNode:function(node){
  687. // var n = node.lastChild;
  688. // while (n && n.nodeType!==Node.TEXT_NODE){
  689. // var tmp = this._getLastTextNode(n);
  690. // if (tmp) return tmp;
  691. // n = n.previousSibling;
  692. // }
  693. // return n;
  694. // },
  695. // _mergeFiletext: function(node, prevPageNode, prevFiletextNode, pageNode, continueMerge){
  696. // var contentNode = pageNode.getFirst();
  697. // var fnode = node.firstChild;
  698. // if (!fnode){
  699. // if (node.parentNode) node.parentNode.removeChild(node);
  700. // }else{
  701. // while (this._checkPageHeight(pageNode) && fnode) {
  702. // var tmpnode = fnode.nextSibling;
  703. // var nodeType = fnode.nodeType;
  704. // if (!prevPageNode) prevPageNode = prevFiletextNode;
  705. //
  706. // if (nodeType == Node.ELEMENT_NODE) {
  707. // if (fnode.tagName == "table") {
  708. // var tNode = fnode.clone().inject(prevPageNode);
  709. // if (this._checkPageHeight(pageNode)){
  710. // fnode.destroy();
  711. // this._mergepage(pageNode, nextPageNode);
  712. // }else{
  713. // tNode.destroy();
  714. // }
  715. // } else if (fnode.tagName == "BR") {
  716. // if (fnode.parentNode) fnode.parentNode.removeChild(fnode);
  717. // } else {
  718. // var id = fnode.get("data-pagePart");
  719. // if (!id){
  720. // id = (new o2.widget.UUID()).toString();
  721. // fnode.set("data-pagePart", id);
  722. // }
  723. // var tmpNode = prevPageNode.getLast();
  724. // if (tmpNode && tmpNode.get("data-pagePart")==id){
  725. // prevPageNode = tmpNode;
  726. // }else{
  727. // prevPageNode = fnode.clone(false).inject(prevPageNode);
  728. // }
  729. // //var subnode = lnode.getLast();
  730. // continueMerge = this._mergeFiletext(fnode, prevPageNode, prevFiletextNode, pageNode, continueMerge);
  731. // prevPageNode = prevPageNode.getParent();
  732. // }
  733. // } else if (nodeType == Node.TEXT_NODE) {
  734. // var prevPageTextNode = this._getLastTextNode(prevPageNode);
  735. // if (!prevPageTextNode) prevPageTextNode = prevPageNode.appendChild(document.createTextNode(""));
  736. //
  737. // var flag = this._mergeFiletextNodeOneWord(fnode, prevPageTextNode, contentNode);
  738. //
  739. // if (!fnode.textContent) if (fnode.parentNode) fnode.parentNode.removeChild(fnode);
  740. // if (!prevPageTextNode.textContent) if (prevPageTextNode.parentNode) prevPageTextNode.parentNode.removeChild(prevPageTextNode);
  741. //
  742. // if (flag){
  743. // while ((contentNode.getSize().y <= this.options.docPageHeight) && continueMerge) {
  744. // continueMerge = this._mergeFiletext(node, prevPageNode, prevFiletextNode, pageNode, continueMerge);
  745. // }
  746. // } else {
  747. // return false;
  748. // }
  749. // } else {
  750. // //lnode.remove();
  751. // if (fnode.parentNode) fnode.parentNode.removeChild(fnode);
  752. // }
  753. //
  754. // if (continueMerge) {
  755. // fnode = tmpnode;
  756. // }else{
  757. // fnode = null;
  758. // }
  759. // }
  760. // if (!node.lastChild) if (node.parentNode) node.parentNode.removeChild(node); //node.remove();
  761. // }
  762. // return true;
  763. // //this._checkSplitPage(pageNode);
  764. // },
  765. // _mergepage: function(pageNode, nextPageNode){
  766. // var contentNode = pageNode.getFirst();
  767. // var nextContentNode = nextPageNode.getFirst();
  768. // var nextBlockNodes = nextPageNode.getElements(".doc_block");
  769. //
  770. // if (nextBlockNodes.length){
  771. // var nextBlockNode = nextBlockNodes[0];
  772. // if (nextBlockNode.hasClass("doc_layout_filetext")){
  773. // var filetextNode = pageNode.getElement(".doc_layout_filetext");
  774. // if (!filetextNode){
  775. // filetextNode = new Element("div.doc_layout_filetext").inject(contentNode);
  776. // filetextNode.setAttribute('contenteditable', true);
  777. // }
  778. // if (!filetextNode.hasClass("doc_block"))filetextNode.addClass("doc_block");
  779. // var nextEditor = filetextNode.retrieve("editor");
  780. //
  781. // var nextNode = nextBlockNode;
  782. // var nextPageNode = filetextNode;
  783. // this._mergeFiletext(nextNode, filetextNode, filetextNode, pageNode, true);
  784. //
  785. // }else{
  786. // var tmpNode = nextBlockNode.clone().inject(contentNode);
  787. // if (this._checkPageHeight(pageNode)){
  788. // nextBlockNode.destroy();
  789. // this._mergepage(pageNode, nextPageNode);
  790. // }else{
  791. // tmpNode.destroy();
  792. // }
  793. // }
  794. // }
  795. // },
  796. loadCkeditorFiletext: function(callback){
  797. debugger;
  798. if (this.layout_filetext){
  799. o2.load("ckeditor", function(){
  800. CKEDITOR.disableAutoInline = true;
  801. //if (!this.layout_filetext.retrieve("editor", null)) {
  802. this.layout_filetext.setAttribute('contenteditable', true);
  803. this.filetextEditor = CKEDITOR.inline(this.layout_filetext, this._getEditorConfig());
  804. this.filetextEditor.on("instanceReady", function(e){
  805. if (callback) callback(e);
  806. }.bind(this));
  807. //this.layout_filetext.store("editor", this.filetextEditor);
  808. //}
  809. }.bind(this));
  810. }
  811. //
  812. // this.layout_filetexts = this.contentNode.getElements(".doc_layout_filetext");
  813. // if (this.layout_filetexts && this.layout_filetexts.length){
  814. // this.filetextEditors = [];
  815. // o2.load("ckeditor", function(){
  816. // CKEDITOR.disableAutoInline = true;
  817. // this.layout_filetexts.each(function(layout_filetext){
  818. //
  819. // if (!layout_filetext.retrieve("editor")){
  820. // layout_filetext.setAttribute('contenteditable', true);
  821. // var filetextEditor = CKEDITOR.inline(layout_filetext, this._getEditorConfig());
  822. // layout_filetext.store("editor", filetextEditor);
  823. // this.filetextEditors.push(filetextEditor);
  824. // // filetextEditor.on( 'blur', function(e) {
  825. // // // var filetextNode = e.editor.container.$;
  826. // // // var pageNode = filetextNode.getParent(".doc_layout_page");
  827. // // // this._checkSplitPage(pageNode);
  828. // // // this._repage();
  829. // // // //debugger;
  830. // // // this.loadCkeditorFiletext();
  831. // // }.bind(this));
  832. // //
  833. // // filetextEditor.on( 'key', function(e) {
  834. // // if (e.data.keyCode == 8){
  835. // // if (this._checkStartBoundary(e.editor)) this._moveToPrevEditor(e.editor);
  836. // // var pageNode = e.editor.container.$.getParent(".doc_layout_page");
  837. // // debugger;
  838. // // this._checkMergePage(pageNode);
  839. // //
  840. // // if (!e.editor.getData()){
  841. // // e.cancel();
  842. // // var filetextNode = e.editor.container.$;
  843. // // e.editor.destroy();
  844. // // filetextNode.destroy();
  845. // // }else{
  846. // //
  847. // // }
  848. // // }
  849. // // debugger;
  850. // // }.bind(this));
  851. // }
  852. //
  853. // }.bind(this));
  854. // }.bind(this));
  855. // }
  856. },
  857. _loadEvents: function(editorConfig){
  858. Object.each(this.json.events, function(e, key){
  859. if (e.code){
  860. this.editor.on(key, function(event){
  861. return this.form.Macro.fire(e.code, this, event);
  862. }.bind(this), this);
  863. }
  864. }.bind(this));
  865. },
  866. _computeItemData: function(name, typeItem, dataItem, scriptItem){
  867. switch (this.json[typeItem]) {
  868. case "data":
  869. if (this.form.businessData.data[this.json[dataItem]]!=undefined) this.data[name] = this.form.businessData.data[this.json[dataItem]];
  870. break;
  871. case "script":
  872. if (this.json[scriptItem] && this.json[scriptItem].code){
  873. var v = this.form.Macro.exec(this.json[scriptItem].code, this);
  874. if (name=="attachment") this.data[name] = (typeOf(v)=="array") ? v.join("<br/>") : v;
  875. if (name=="issuanceDate" || name=="editionDate"){
  876. var d = Date.parse(v);
  877. this.data[name] = (d.isValid()) ? d.format("“%Y年%m月%d%日") : v;
  878. }
  879. }
  880. break;
  881. }
  882. },
  883. _computeData: function(){
  884. this.data = this._getBusinessData();
  885. if (!this.data) this.data = this._getDefaultData();
  886. this._computeItemData("copies", "copiesValueType", "copiesValueData", "copiesValueScript");
  887. this._computeItemData("secret", "secretValueType", "secretValueData", "secretValueScript");
  888. this._computeItemData("priority", "priorityValueType", "priorityValueData", "priorityValueScript");
  889. this._computeItemData("redHeader", "redHeaderValueType", "redHeaderValueData", "redHeaderValueScript");
  890. this._computeItemData("fileno", "filenoValueType", "filenoValueData", "filenoValueScript");
  891. this._computeItemData("signer", "signerValueType", "signerValueData", "signerValueScript");
  892. this._computeItemData("subject", "subjectValueType", "subjectValueData", "subjectValueScript");
  893. this._computeItemData("mainSend", "mainSendValueType", "mainSendValueData", "mainSendValueScript");
  894. this._computeItemData("attachment", "attachmentValueType", "attachmentValueData", "attachmentValueScript");
  895. this._computeItemData("issuanceUnit", "issuanceUnitValueType", "issuanceUnitValueData", "issuanceUnitValueScript");
  896. this._computeItemData("issuanceDate", "issuanceDateValueType", "issuanceDateValueData", "issuanceDateValueScript");
  897. this._computeItemData("annotation", "annotationValueType", "annotationValueData", "annotationValueScript");
  898. this._computeItemData("copyto", "copytoValueType", "copytoValueData", "copytoValueScript");
  899. this._computeItemData("editionUnit", "editionUnitValueType", "editionUnitValueData", "editionUnitValueScript");
  900. this._computeItemData("editionDate", "editionDateValueType", "editionDateValueData", "editionDateValueScript");
  901. },
  902. _loadValue: function(){
  903. var data = this._getBusinessData();
  904. },
  905. resetData: function(){
  906. this.setData(this._getBusinessData());
  907. },
  908. getData: function(){
  909. if (this.eiitMode){
  910. if (this.layout_copies) this.data.copies = this.layout_copies.get("text");
  911. if (this.layout_secret) this.data.secret = this.layout_secret.get("text");
  912. if (this.layout_priority) this.data.priority = this.layout_priority.get("text");
  913. if (this.layout_redHeader) this.data.redHeader = this.layout_redHeader.get("html");
  914. if (this.layout_fileno) this.data.fileno = this.layout_fileno.get("text");
  915. if (this.layout_signerTitle) this.data.signerTitle = this.layout_signerTitle.get("text");
  916. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  917. if (this.layout_subject) this.data.subject = this.layout_subject.get("text");
  918. if (this.layout_mainSend) this.data.mainSend = this.layout_mainSend.get("text");
  919. if (this.layout_filetext) this.data.filetext = this.layout_filetext.get("html");
  920. if (this.layout_signer) this.data.signer = this.layout_signer.get("text");
  921. if (this.layout_attachmentTitle) this.data.attachmentTitle = this.layout_attachmentTitle.get("text");
  922. if (this.layout_attachment) this.data.attachment = this.layout_attachment.get("html");
  923. if (this.layout_issuanceUnit) this.data.issuanceUnit = this.layout_issuanceUnit.get("text");
  924. if (this.layout_issuanceDate) this.data.issuanceDate = this.layout_issuanceDate.get("text");
  925. if (this.layout_annotation) this.data.annotation = this.layout_annotation.get("text");
  926. if (this.layout_copytoTitle) this.data.copytoTitle = this.layout_copytoTitle.get("text");
  927. if (this.layout_copytoContent) this.data.copyto = this.layout_copytoContent.get("text");
  928. if (this.layout_edition_issuance_unit) this.data.editionUnit = this.layout_edition_issuance_unit.get("text");
  929. if (this.layout_edition_issuance_date) this.data.editionDate = this.layout_edition_issuance_date.get("text");
  930. }
  931. return this.data;
  932. },
  933. setData: function(data){
  934. if (data){
  935. this.data = data;
  936. this._setBusinessData(data);
  937. if (this.layout_copies) this.layout_copies.set("text", data.copies || " ");
  938. if (this.layout_secret) this.layout_secret.set("text", data.secret || " ");
  939. if (this.layout_priority) this.layout_priority.set("text", data.priority || " ");
  940. if (this.layout_redHeader) this.layout_redHeader.set("html", data.redHeader || "");
  941. if (this.layout_fileno) this.layout_fileno.set("text", data.fileno || " ");
  942. if (this.layout_signerTitle) this.layout_signerTitle.set("text", data.signerTitle || " ");
  943. if (this.layout_signer) this.layout_signer.set("text", data.signer || " ");
  944. if (this.layout_subject) this.layout_subject.set("text", data.subject || " ");
  945. if (this.layout_mainSend) this.layout_mainSend.set("text", data.mainSend || " ");
  946. if (this.layout_filetext) this.layout_filetext.set("html", data.filetext || "");
  947. if (this.layout_signer) this.layout_signer.set("text", data.signer || "");
  948. if (this.layout_attachmentTitle) this.layout_attachmentTitle.set("text", data.attachmentTitle || " ");
  949. if (this.layout_attachment) this.layout_attachment.set("html", data.attachment || " ");
  950. if (this.layout_issuanceUnit) this.layout_issuanceUnit.set("text", data.issuanceUnit || " ");
  951. if (this.layout_issuanceDate) this.layout_issuanceDate.set("text", data.issuanceDate || " ");
  952. if (this.layout_annotation) this.layout_annotation.set("text", data.annotation || " ");
  953. if (this.layout_copytoTitle) this.layout_copytoTitle.set("text", data.copytoTitle || " ");
  954. if (this.layout_copytoContent) this.layout_copytoContent.set("text", data.copyto || " ");
  955. if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.set("text", data.editionUnit || " ");
  956. if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.set("text", data.editionDate || " ");
  957. }
  958. },
  959. createErrorNode: function(text){
  960. var node = new Element("div");
  961. var iconNode = new Element("div", {
  962. "styles": {
  963. "width": "20px",
  964. "height": "20px",
  965. "float": "left",
  966. "background": "url("+"/x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  967. }
  968. }).inject(node);
  969. var textNode = new Element("div", {
  970. "styles": {
  971. "line-height": "20px",
  972. "margin-left": "20px",
  973. "color": "red",
  974. "word-break": "keep-all"
  975. },
  976. "text": text
  977. }).inject(node);
  978. return node;
  979. },
  980. notValidationMode: function(text){
  981. if (!this.isNotValidationMode){
  982. this.isNotValidationMode = true;
  983. this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  984. this.node.setStyle("border", "1px solid red");
  985. this.errNode = this.createErrorNode(text).inject(this.node, "after");
  986. this.showNotValidationMode(this.node);
  987. }
  988. },
  989. showNotValidationMode: function(node){
  990. var p = node.getParent("div");
  991. if (p){
  992. if (p.get("MWFtype") == "tab$Content"){
  993. if (p.getParent("div").getStyle("display")=="none"){
  994. var contentAreaNode = p.getParent("div").getParent("div");
  995. var tabAreaNode = contentAreaNode.getPrevious("div");
  996. var idx = contentAreaNode.getChildren().indexOf(p.getParent("div"));
  997. var tabNode = tabAreaNode.getLast().getFirst().getChildren()[idx];
  998. tabNode.click();
  999. p = tabAreaNode.getParent("div");
  1000. }
  1001. }
  1002. this.showNotValidationMode(p);
  1003. }
  1004. },
  1005. validationMode: function(){
  1006. if (this.isNotValidationMode){
  1007. this.isNotValidationMode = false;
  1008. this.node.setStyles(this.node.retrieve("borderStyle"));
  1009. if (this.errNode){
  1010. this.errNode.destroy();
  1011. this.errNode = null;
  1012. }
  1013. }
  1014. },
  1015. validationConfigItem: function(routeName, data){
  1016. var flag = (data.status=="all") ? true: (routeName == data.decision);
  1017. if (flag){
  1018. var n = this.getData();
  1019. var v = (data.valueType=="value") ? n : n.length;
  1020. switch (data.operateor){
  1021. case "isnull":
  1022. if (!v){
  1023. this.notValidationMode(data.prompt);
  1024. return false;
  1025. }
  1026. break;
  1027. case "notnull":
  1028. if (v){
  1029. this.notValidationMode(data.prompt);
  1030. return false;
  1031. }
  1032. break;
  1033. case "gt":
  1034. if (v>data.value){
  1035. this.notValidationMode(data.prompt);
  1036. return false;
  1037. }
  1038. break;
  1039. case "lt":
  1040. if (v<data.value){
  1041. this.notValidationMode(data.prompt);
  1042. return false;
  1043. }
  1044. break;
  1045. case "equal":
  1046. if (v==data.value){
  1047. this.notValidationMode(data.prompt);
  1048. return false;
  1049. }
  1050. break;
  1051. case "neq":
  1052. if (v!=data.value){
  1053. this.notValidationMode(data.prompt);
  1054. return false;
  1055. }
  1056. break;
  1057. case "contain":
  1058. if (v.indexOf(data.value)!=-1){
  1059. this.notValidationMode(data.prompt);
  1060. return false;
  1061. }
  1062. break;
  1063. case "notcontain":
  1064. if (v.indexOf(data.value)==-1){
  1065. this.notValidationMode(data.prompt);
  1066. return false;
  1067. }
  1068. break;
  1069. }
  1070. }
  1071. return true;
  1072. },
  1073. validationConfig: function(routeName, opinion){
  1074. if (this.json.validationConfig){
  1075. if (this.json.validationConfig.length){
  1076. for (var i=0; i<this.json.validationConfig.length; i++) {
  1077. var data = this.json.validationConfig[i];
  1078. if (!this.validationConfigItem(routeName, data)) return false;
  1079. }
  1080. }
  1081. return true;
  1082. }
  1083. return true;
  1084. },
  1085. validation: function(routeName, opinion){
  1086. if (!this.validationConfig(routeName, opinion)) return false;
  1087. if (!this.json.validation) return true;
  1088. if (!this.json.validation.code) return true;
  1089. var flag = this.form.Macro.exec(this.json.validation.code, this);
  1090. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1091. if (flag.toString()!="true"){
  1092. this.notValidationMode(flag);
  1093. return false;
  1094. }
  1095. return true;
  1096. }
  1097. // loadCkeditor: function(config, pageNode){
  1098. // COMMON.AjaxModule.loadDom("ckeditor", function(){
  1099. // CKEDITOR.disableAutoInline = true;
  1100. // var editorDiv = new Element("div").inject(this.node);
  1101. // //var editorDiv = pageNode;
  1102. // var htmlData = this._getBusinessData();
  1103. // if (htmlData){
  1104. // editorDiv.set("html", htmlData);
  1105. // }else if (this.json.templateCode){
  1106. // editorDiv.set("html", this.json.templateCode);
  1107. // }
  1108. // var height = this.node.getSize().y;
  1109. // var editorConfig = config || {};
  1110. //
  1111. // if (this.form.json.mode==="Mobile"){
  1112. // if (!editorConfig.toolbar && !editorConfig.toolbarGroups){
  1113. // editorConfig.toolbar = [
  1114. // { name: 'paragraph', items: [ 'Bold', 'Italic', "-" , 'TextColor', "BGColor", 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', "-", 'Undo', 'Redo' ] },
  1115. // { name: 'basicstyles', items: [ 'Styles', 'FontSize']}
  1116. // ];
  1117. // }
  1118. // }
  1119. // var editorConfig = {};
  1120. // editorConfig.localImageMaxWidth = 800;
  1121. // editorConfig.reference = this.form.businessData.work.job;
  1122. // editorConfig.referenceType = "processPlatformJob";
  1123. //
  1124. // editorConfig.toolbarGroups = [
  1125. // { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
  1126. // { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  1127. // { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  1128. // { name: 'forms', groups: [ 'forms' ] },
  1129. // { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  1130. // { name: 'insert', groups: [ 'insert' ] },
  1131. // { name: 'tools', groups: [ 'tools' ] },
  1132. // '/',
  1133. // { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  1134. // { name: 'links', groups: [ 'links' ] },
  1135. // '/',
  1136. // { name: 'styles', groups: [ 'styles' ] },
  1137. // { name: 'colors', groups: [ 'colors' ] },
  1138. // { name: 'others', groups: [ 'others' ] },
  1139. // { name: 'about', groups: [ 'about' ] }
  1140. // ];
  1141. // editorConfig.enterMode = 3;
  1142. // editorConfig.removeButtons = 'ShowBlocks,Templates,Scayt,Form,Bold,Italic,Underline,Strike,Subscript,Superscript,CopyFormatting,RemoveFormat,Indent,Outdent,Blockquote,CreateDiv,BidiLtr,BidiRtl,Language,Link,Unlink,Anchor,Flash,HorizontalRule,Smiley,SpecialChar,Iframe,PageBreak,Styles,Format,Font,FontSize,TextColor,BGColor,About,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField';
  1143. // // editorConfig.bodyClass = "document-editor";
  1144. // editorConfig.contentsCss = [ '/x_component_process_Xform/$Form/doc.css' ];
  1145. // //editorConfig.extraPlugins = ['ecnet','doc_page', 'doc_copiesSecretPriority','doc_fileno','doc_redHeader','doc_subject','doc_mainSend', 'doc_file', 'doc_filenoup', 'doc_attachment'];
  1146. // editorConfig.extraPlugins = ['ecnet','doc_page'];
  1147. // editorConfig.removePlugins = ['magicline'];
  1148. // // editorConfig.allowedContent = "div(o2_editorPlugin_doc_Page,o2_editorPlugin_doc_Page_content," +
  1149. // // "o2_editorPlugin_redHeader,o2_editorPlugin_redHeader_content," +
  1150. // // "o2_editorPlugin_doc_copiesSecretPriority,o2_editorPlugin_doc_copies,o2_editorPlugin_doc_secret,o2_editorPlugin_doc_priority," +
  1151. // // "o2_editorPlugin_doc_fileno,o2_editorPlugin_doc_subject,o2_editorPlugin_doc_mainSend,o2_editorPlugin_doc_file," +
  1152. // // "o2_editorPlugin_doc_redline);" +
  1153. // // "table(o2_editorPlugin_doc_filenoup,o2_editorPlugin_doc_filenoup_signer_table,o2_editorPlugin_doc_attachment)[width,cellpadding,cellspacing,border];" +
  1154. // // "tr td(o2_editorPlugin_doc_filenoup_td,o2_editorPlugin_doc_filenoup_td_signer,o2_editorPlugin_doc_filenoup_signer_td,o2_editorPlugin_doc_filenoup_signerContent_td," +
  1155. // // "o2_editorPlugin_doc_attachment_title_td,o2_editorPlugin_doc_attachment_title_content_td);" +
  1156. // // "span(o2_editorPlugin_doc_filenoup_fileno,o2_editorPlugin_doc_filenoup_signer,o2_editorPlugin_doc_filenoup_signerContent,o2_editorPlugin_doc_attachment_title,o2_editorPlugin_doc_attachment_content)";
  1157. //
  1158. // editorConfig.allowedContent = true;
  1159. //
  1160. // editorConfig.disableAutoInline = false;
  1161. // //this.editor = CKEDITOR.replace(editorDiv, editorConfig);
  1162. // //this.editor = CKEDITOR.inline(editorDiv);
  1163. //
  1164. // //this.editor.on("key",function(e){
  1165. // // var sel = e.editor.getSelection();
  1166. // // var h = e.editor.getSelectedHtml().getHtml();
  1167. // // if (h.indexOf("o2_editorPlugin_redHeader")!=-1 ||
  1168. // // h.indexOf("o2_editorPlugin_doc_Page")!=-1){
  1169. // // e.cancel();
  1170. // // }
  1171. // // debugger;
  1172. // // var el = sel.getSelectedElement();
  1173. // //});
  1174. // var html = "<div class=\"o2_editorPlugin_doc_Page\">" +
  1175. // "<div class=\"o2_editorPlugin_doc_Page_content\">" +
  1176. //
  1177. // '<div class="o2_editorPlugin_doc_copiesSecretPriority">' +
  1178. // ' <div class="o2_editorPlugin_doc_copies">000001</div>' +
  1179. // ' <div class="o2_editorPlugin_doc_secret">机密★1年</div>' +
  1180. // ' <div class="o2_editorPlugin_doc_priority">特急</div>' +
  1181. // '</div>' +
  1182. //
  1183. // "<div class=\"o2_editorPlugin_redHeader\"><div class=\"o2_editorPlugin_redHeader_content\">文件红头</div></div>" +
  1184. //
  1185. // // '<table class="o2_editorPlugin_doc_filenoup" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  1186. // // ' <tr><td class="o2_editorPlugin_doc_filenoup_td">' +
  1187. // // ' <span> </span><span class="o2_editorPlugin_doc_filenoup_fileno">浙移发〔2019〕20号</span>' +
  1188. // // ' </td><td class="o2_editorPlugin_doc_filenoup_td_signer">' +
  1189. // // ' <table class="o2_editorPlugin_doc_filenoup_signer_table" cellpadding="0" cellspacing="0" border="0">' +
  1190. // // ' <tr><td class="o2_editorPlugin_doc_filenoup_signer_td">' +
  1191. // // ' <span class="o2_editorPlugin_doc_filenoup_signer">签发人:</span>' +
  1192. // // ' </td><td class="o2_editorPlugin_doc_filenoup_signerContent_td">' +
  1193. // // ' <span class="o2_editorPlugin_doc_filenoup_signerContent">蔡志煌 谢玲巧 张傻托 王雄哥</span><span> </span>' +
  1194. // // ' </td></tr>' +
  1195. // // ' </table>' +
  1196. // // ' </td></tr>' +
  1197. // // '</table>'+
  1198. // "<div class=\"o2_editorPlugin_doc_fileno\">浙移发〔2019〕20号</div>" +
  1199. // "<div color=\"#ff0000\" class=\"o2_editorPlugin_doc_redline\"></div>" +
  1200. // "<div class=\"o2_editorPlugin_doc_subject\">文件标题</div>" +
  1201. // "<div class=\"o2_editorPlugin_doc_mainSend\">主送单位:</div>"+
  1202. // "<div class=\"o2_editorPlugin_doc_file\">  正文内容...</div>" +
  1203. //
  1204. // '<table class="o2_editorPlugin_doc_attachment" width="100%" cellpadding="0" cellspacing="0" border="0">' +
  1205. // ' <tr><td class="o2_editorPlugin_doc_attachment_title_td">' +
  1206. // ' <span>  </span><span class="o2_editorPlugin_doc_attachment_title">附件:</span>' +
  1207. // ' </td><td class="o2_editorPlugin_doc_attachment_title_content_td">' +
  1208. // ' <span class="o2_editorPlugin_doc_attachment_content">附件名称</span>' +
  1209. // ' </td></tr>' +
  1210. // '</table>'+
  1211. //
  1212. // "</div></div>"
  1213. // //this.editor.setData(html);
  1214. // editorDiv.loadCss('/x_component_process_Xform/$Form/doc.css', function(){
  1215. // editorDiv.set("html", html);
  1216. //
  1217. // var node = editorDiv.getElement('.o2_editorPlugin_doc_file');
  1218. // node.setAttribute('contenteditable', true);
  1219. // this.editor = CKEDITOR.inline(node, {"allowedContent":true});
  1220. //
  1221. // });
  1222. //
  1223. // }.bind(this));
  1224. // },
  1225. // getEcnetString: function(node, nodes){
  1226. // for (var i=0; i<node.childNodes.length; i++){
  1227. // if (node.childNodes[i].nodeType===Node.TEXT_NODE){
  1228. // var s = this.ecnetString.length;
  1229. // this.ecnetString += node.childNodes[i].nodeValue;
  1230. // var e = this.ecnetString.length;
  1231. //
  1232. // nodes.push({
  1233. // "pnode": node,
  1234. // "node": node.childNodes[i],
  1235. // "start": s, "end": e
  1236. // });
  1237. // }else{
  1238. // this.getEcnetString(node.childNodes[i], nodes);
  1239. // }
  1240. // }
  1241. // },
  1242. // createEcnetNode: function(node){
  1243. // var newNode = node.node.ownerDocument.createElement("span");
  1244. //
  1245. // var increment = 0;
  1246. // var html = node.node.nodeValue;;
  1247. // node.ecnets.each(function(ecnet){
  1248. // var s = ecnet.begin+increment-node.start;
  1249. // var e = ecnet.end+increment-node.start;
  1250. // if (s<0) s=0;
  1251. // if (e>node.end+increment) e = node.end+increment;
  1252. // var length = html.length;
  1253. //
  1254. // var left = html.substring(0, s);
  1255. // var ecnetStr = html.substring(s, e);
  1256. // var right = html.substring(e, html.length);
  1257. //
  1258. // html = left+"<span class='o2_ecnet_item' style='color: red'><u>"+ecnetStr+"</u></span>"+right;
  1259. // increment += (html.length-length);
  1260. //
  1261. // }.bind(this));
  1262. // newNode.innerHTML = html;
  1263. // node.pnode.replaceChild(newNode, node.node);
  1264. // node.pnode.textNode = node.node;
  1265. // node.pnode.ecnetNode = newNode;
  1266. //
  1267. // var _self = this;
  1268. // var editorFrame = this.editor.document.$.defaultView.frameElement;
  1269. // var spans = newNode.getElementsByTagName("span");
  1270. // if (spans.length){
  1271. // for (var i = 0; i<spans.length; i++){
  1272. // var span = spans[i];
  1273. // if (span.className==="o2_ecnet_item"){
  1274. // var ecnetNode = new Element("div", {"styles": {
  1275. // "border": "1px solid #999999",
  1276. // "box-shadow": "0px 0px 5px #999999",
  1277. // "background-color": "#ffffff",
  1278. // "position": "fixed",
  1279. // "display": "none"
  1280. // }}).inject(editorFrame, "after");
  1281. // var correctNode = new Element("div", {
  1282. // "styles": {
  1283. // "padding": "3px 10px",
  1284. // "font-weight": "bold",
  1285. // "font-size": "12px",
  1286. // "cursor": "pointer"
  1287. // },
  1288. // "text": node.ecnets[i].origin+"->"+node.ecnets[i].correct,
  1289. // "events": {
  1290. // "mouseover": function(){this.setStyle("background-color", "#dddddd")},
  1291. // "mouseout": function(){this.setStyle("background-color", "#ffffff")},
  1292. // "mousedown": function(){
  1293. // var ecnetNode = this.getParent();
  1294. // var node = ecnetNode.node;
  1295. // var item = ecnetNode.node.ecnets[ecnetNode.idx];
  1296. // var textNode = node.node.ownerDocument.createTextNode(item.correct);
  1297. // ecnetNode.span.parentNode.replaceChild(textNode, ecnetNode.span);
  1298. // ecnetNode.destroy();
  1299. // node.node.nodeValue = node.pnode.ecnetNode.innerText;
  1300. //
  1301. // node.ecnets.erase(item);
  1302. // if (!node.ecnets.length){
  1303. // _self.ecnetNodes.erase(node);
  1304. // }
  1305. // }
  1306. // }
  1307. // }).inject(ecnetNode);
  1308. // var ignoreNode = new Element("div", {
  1309. // "styles": {
  1310. // "padding": "3px 10px",
  1311. // "font-size": "12px",
  1312. // "cursor": "pointer"
  1313. // },
  1314. // "text": MWF.xApplication.process.Xform.LP.ignore,
  1315. // "events": {
  1316. // "mouseover": function(){this.setStyle("background-color", "#dddddd")},
  1317. // "mouseout": function(){this.setStyle("background-color", "#ffffff")},
  1318. // "mousedown": function(){
  1319. // var ecnetNode = this.getParent();
  1320. // var node = ecnetNode.node;
  1321. // var item = ecnetNode.node.ecnets[ecnetNode.idx];
  1322. // var textNode = node.node.ownerDocument.createTextNode(ecnetNode.span.innerText);
  1323. // ecnetNode.span.parentNode.replaceChild(textNode, ecnetNode.span);
  1324. // ecnetNode.destroy();
  1325. // node.node.nodeValue = node.pnode.ecnetNode.innerText;
  1326. //
  1327. // node.ecnets.erase(item);
  1328. // if (!node.ecnets.length){
  1329. // _self.ecnetNodes.erase(node);
  1330. // }
  1331. // }
  1332. // }
  1333. // }).inject(ecnetNode);
  1334. // ecnetNode.node = node;
  1335. // ecnetNode.idx = i;
  1336. //
  1337. // span.ecnetNode = ecnetNode;
  1338. // ecnetNode.span = span;
  1339. // span.addEventListener("click", function(){
  1340. // var ecnetNode = this.ecnetNode;
  1341. // ecnetNode.show();
  1342. // var y = this.offsetTop;
  1343. // var x = this.offsetLeft;
  1344. // var w = this.offsetWidth;
  1345. // var h = this.offsetHeight;
  1346. // var p = editorFrame.getPosition();
  1347. // var s = ecnetNode.getSize();
  1348. // var top = y+p.y+h+5;
  1349. // var left = x+p.x-((s.x-w)/2);
  1350. //
  1351. // ecnetNode.style.left = ""+left+"px";
  1352. // ecnetNode.style.top = ""+top+"px";
  1353. //
  1354. // var _span = this;
  1355. // var hideEcnetNode = function(){
  1356. // ecnetNode.hide();
  1357. // _span.ownerDocument.removeEventListener("mousedown", hideEcnetNode);
  1358. // };
  1359. // this.ownerDocument.addEventListener("mousedown", hideEcnetNode);
  1360. //
  1361. // });
  1362. //
  1363. // }
  1364. // }
  1365. // }
  1366. // },
  1367. // clearEcnetNodes: function(){
  1368. // if (this.ecnetNodes && this.ecnetNodes.length){
  1369. // this.ecnetNodes.each(function(node){
  1370. // if (node.pnode.ecnetNode){
  1371. // if (node.pnode.ecnetInforNode) node.pnode.ecnetInforNode.destroy();
  1372. // node.pnode.ecnetInforNode = null;
  1373. // node.pnode.replaceChild(node.pnode.textNode, node.pnode.ecnetNode);
  1374. // }
  1375. // }.bind(this));
  1376. // this.ecnetNodes = [];
  1377. // }
  1378. // },
  1379. // ecnet: function(data){
  1380. // //this.editor.document.$.body.innerText
  1381. // var editorFrame = this.editor.document.$.defaultView.frameElement;
  1382. // //var data = this.editor.getData();
  1383. // var body = this.editor.document.$.body;
  1384. //
  1385. // if (!this.ecnetNodes) this.ecnetNodes = [];
  1386. // if (this.ecnetNodes.length) this.clearEcnetNodes();
  1387. //
  1388. // var nodes = [];
  1389. // this.ecnetString = "";
  1390. // this.getEcnetString(body, nodes);
  1391. //
  1392. // MWF.Actions.get("x_general_assemble_control").ecnetCheck({"value": this.ecnetString}, function(json){
  1393. // if (json.data.itemList && json.data.itemList.length){
  1394. //
  1395. // nodes.each(function(node){
  1396. // var items = [];
  1397. // json.data.itemList.each(function(item){
  1398. // if ((node.end<=item.end && node.end>item.begin) || (node.start>=item.begin && node.start<item.end) || (node.start<=item.begin && node.end>item.end)){
  1399. // items.push(item);
  1400. // }
  1401. // }.bind(this));
  1402. // if (items.length){
  1403. // node.ecnets = items;
  1404. // this.ecnetNodes.push(node);
  1405. // }
  1406. // }.bind(this));
  1407. //
  1408. //
  1409. // this.ecnetNodes.each(function(node){
  1410. // this.createEcnetNode(node);
  1411. // }.bind(this));
  1412. // }else{
  1413. // body = null;
  1414. // nodes = null;
  1415. // }
  1416. // }.bind(this));
  1417. // },
  1418. });