mwf.xdesktop.requireapp("process.xform", "$module", null, false);
/** @class documenteditor 公文编辑器。
* @o2cn 公文编辑器
* @example
* //可以在脚本中获取该组件
* //方法1:
* var documenteditor = this.form.get("fieldid"); //获取组件
* //方法2
* var documenteditor = this.target; //在组件事件脚本中获取
* @extends mwf.xapplication.process.xform.$module
* @o2category formcomponents
* @o2range {process}
* @hideconstructor
*/
mwf.xapplication.process.xform.documenteditor = mwf.appdocumenteditor = new class(
/** @lends mwf.xapplication.process.xform.documenteditor# */
{
extends: mwf.app$module,
options: {
/**
* 当公文编辑器内容每次被渲染的时候都会触发。
* @event mwf.xapplication.process.xform.documenteditor#loadpage
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
"moduleevents": ["load", "queryload", "beforeload", "postload", "afterload", "loadpage", "fullscreen", "returnscreen", "pageposition"],
"docpageheight": 850.4,
"docpagefullwidth": 794,
"pageshow": "single"
},
initialize: function(node, json, form, options){
this.node = $(node);
this.node.store("module", this);
this.json = json;
this.form = form;
this.field = true;
this.fieldmoduleloaded = false;
},
_loadcss: function(reload){
var key = encodeuricomponent(this.csspath);
if (!reload && o2.widget.css[key]){
this.css = o2.widget.css[key];
}else{
this.csspath = (this.csspath.indexof("?")!=-1) ? this.csspath "&v=" o2.version.v : this.csspath "?v=" o2.version.v;
var r = new request.json({
url: this.csspath,
secure: false,
async: false,
method: "get",
nocache: false,
onsuccess: function(responsejson, responsetext){
this.css = responsejson;
o2.widget.css[key] = responsejson;
}.bind(this),
onerror: function(text, error){
console.log(error text);
}
});
r.send();
}
},
load: function(){
if (!this.json.isdelay){
this.active();
}
},
/**
* 激活公文编辑器编辑。设置了延迟加载的时候,可以通过这个方法来激活
* @example
* this.form.get("fieldid").active();
*/
active: function(){
this._loadmoduleevents();
if (this.fireevent("queryload")){
this.fireevent("beforeload");
this.csspath = this.form.path this.form.options.style "/doc.wcss";
this._loadcss();
this._queryloaded();
this._loaduserinterface(function(){
this.fieldmoduleloaded = true;
this.fireevent("postload");
this.fireevent("afterload");
this.fireevent("load");
this.form.app.addevent("resize", function(){
// if (this.options.pageshow!=="double"){
// this._doublepage();
// }else{
this._singlepage();
// }
// this.scaleto(this.scale);
// this._checkscale();
}.bind(this));
o2.ud.getdatajson("documenteditorscale", function(json){
if (json){
this.scaleto(json.scale);
this.documenteditorscale = json.scale
}
// if (this.documenteditorscale) this.scaleto(this.documenteditorscale);
// this.addevent("loadpage", function(){
// if (this.documenteditorscale) this.scaleto(this.documenteditorscale);
// }.bind(this));
this._checkscale();
}.bind(this));
}.bind(this));
this._loadstyles();
this._afterloaded();
}
},
_createnewpage: function(){
var pagenode = new element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.contentnode);
var pagecontentnode = new element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pagenode);
pagenode.set("data-pagecount", this.pages.length 1);
this.pages.push(pagenode);
return pagenode;
},
_getshow: function(name, typeitem, scriptitem){
switch (this.json[typeitem]) {
case "y":
return true;
case "n":
return false;
case "a":
if (["copies", "secret", "priority", "attachment", "annotation"].indexof(name!=-1)){
if (o2.typeof(this.data[name])=="string"){
var v = this.data[name].trim();
return !!v && (!!v.length);
}else{
return !!this.data[name] && (!!this.data[name].length);
}
}
return true;
case "s":
if (this.json[scriptitem] && this.json[scriptitem].code){
return !!this.form.macro.exec(this.json[scriptitem].code, this);
}
return true;
default:
return true;
}
},
_loadcssstyle: function(){
if (this.json.css && this.json.css.code && !this.stylenode){
var csstext = this.form.parsecss(this.json.css.code);
csstext = csstext.replace(/documenteditor_table/g, 'documenteditor_table' this.form.json.id this.json.id);
var stylenode = document.createelement("style");
stylenode.setattribute("type", "text/css");
stylenode.id="style" this.json.id;
stylenode.inject(this.node, "top");
if(stylenode.stylesheet){
var setfunc = function(){
if(stylenode.stylesheet.disabled){
settimeout(setfunc, 100);
}else{
stylenode.stylesheet.csstext = csstext;
}
};
setfunc();
}else{
var csstextnode = document.createtextnode(csstext);
stylenode.appendchild(csstextnode);
}
this.stylenode = stylenode;
}
},
_createpage: function(callback, callbackaftreload){
var control = this.getshowcontrol();
this.json.fileup = !!(control.signer);
this._loadcssstyle();
var url = (this.json.documenttempletetype==="cus") ?
this.json.documenttempleteurl :
"../x_component_process_formdesigner/module/documenteditor/templete/" (this.json.documenttempletename || "standard") ".html";
url = url ((url.indexof("?")!==-1) ? "&" : "?") "v=" o2.version.v;
this._clearcopytotrs();
fetch(o2.filter).then(function(res){
return res.text();
}).then(function(html){
this.contentnode.empty();
if (this.filetexteditor) this.filetexteditor.destroy();
if (this.attachmenttexteditor) this.attachmenttexteditor.destroy();
this.editmode = false;
// this.historymode = false;
var pagecontentnode = this._createnewpage().getfirst();
pagecontentnode.set("html", html);
if (this.attachmenttemplete){
var attnode = pagecontentnode.getelement(".doc_layout_attachment_content");
if (attnode) attnode.empty();
}
if (callback) callback(control);
this.fireevent("loadpage");
if (callbackaftreload) callbackaftreload(control);
}.bind(this));
},
_clearcopytotrs: function(){
if (this.layout_copytocontenttr){
this.layout_copytocontenttr.destroy();
this.layout_copytocontenttr = null;
}
if (this.layout_copytocontenttrp){
this.layout_copytocontenttrp.destroy();
this.layout_copytocontenttrp = null;
}
if (this.layout_copyto2contenttr){
this.layout_copyto2contenttr.destroy();
this.layout_copyto2contenttr = null;
}
if (this.layout_copyto2contenttrp){
this.layout_copyto2contenttrp.destroy();
this.layout_copyto2contenttrp = null;
}
},
gettempletejson: function(callback){
if (this.templetejson){
if (callback) callback();
}else{
o2.getjson(o2.filter, function(json){
this.templetejson = json;
if (callback) callback();
}.bind(this));
}
},
getshowcontrol: function(){
var control = {};
control.copiessecretpriority = this._getshow("copiessecretpriority", "copiessecretpriorityshow", "copiessecretpriorityshowscript");
control.copies = this._getshow("copies", "copiesshow", "copiesshowscript");
control.secret = this._getshow("secret", "secretshow", "secretshowscript");
control.priority = this._getshow("priority", "priorityshow", "priorityshowscript");
control.redheader = this._getshow("redheader", "redheadershow", "redheadershowscript");
control.redline = this._getshow("redline", "redlineshow", "redlineshowscript");
control.signer = this._getshow("signer", "signershow", "signershowscript");
control.fileno = this._getshow("fileno", "filenoshow", "filenoshowscript");
control.subject = this._getshow("subject", "subjectshow", "subjectshowscript");
control.mainsend = this._getshow("mainsend", "mainsendshow", "mainsendshowscript");
control.attachment = this._getshow("attachment", "attachmentshow", "attachmentshowscript");
control.issuanceunit = this._getshow("issuanceunit", "issuanceunitshow", "issuanceunitshowscript");
control.issuancedate = this._getshow("issuancedate", "issuancedateshow", "issuancedateshowscript");
control.annotation = this._getshow("annotation", "annotationshow", "annotationshowscript");
control.copyto = this._getshow("copyto", "copytoshow", "copytoshowscript");
control.copyto2 = this._getshow("copyto2", "copyto2show", "copyto2showscript");
control.editionunit = this._getshow("editionunit", "editionunitshow", "editionunitshowscript");
control.editiondate = this._getshow("editiondate", "editiondateshow", "editiondateshowscript");
control.meetingattend = this._getshow("meetingattend", "meetingattendshow", "meetingattendshowscript");
control.meetingleave = this._getshow("meetingleave", "meetingleaveshow", "meetingleaveshowscript");
control.meetingsit = this._getshow("meetingsit", "meetingsitshow", "meetingsitshowscript");
control.meetingrecord = this._getshow("meetingrecord", "meetingrecordshow", "meetingrecordshowscript");
this.json.fileup = !!(control.signer);
return control;
},
geteditcontrol: function(){
var control = {};
control.copies = this._getedit("copies", "copiesedit", "copieseditscript");
control.secret = this._getedit("secret", "secretedit", "secreteditscript");
control.priority = this._getedit("priority", "priorityedit", "priorityeditscript");
control.redheader = this._getedit("redheader", "redheaderedit", "redheadereditscript");
control.signer = this._getedit("signer", "signeredit", "signereditscript");
control.fileno = this._getedit("fileno", "filenoedit", "filenoeditscript");
control.subject = this._getedit("subject", "subjectedit", "subjecteditscript");
control.mainsend = this._getedit("mainsend", "mainsendedit", "mainsendeditscript");
control.attachment = this._getedit("attachment", "attachmentedit", "attachmenteditscript");
control.attachmenttext = this._getedit("attachmenttext", "attachmenttextedit", "attachmenttexteditscript");
control.issuanceunit = this._getedit("issuanceunit", "issuanceunitedit", "issuanceuniteditscript");
control.issuancedate = this._getedit("issuancedate", "issuancedateedit", "issuancedateeditscript");
control.annotation = this._getedit("annotation", "annotationedit", "annotationeditscript");
control.copyto = this._getedit("copyto", "copytoedit", "copytoeditscript");
control.copyto2 = this._getedit("copyto2", "copyto2edit", "copyto2editscript");
control.editionunit = this._getedit("editionunit", "editionunitedit", "editionuniteditscript");
control.editiondate = this._getedit("editiondate", "editiondateedit", "editiondateeditscript");
control.meetingattend = this._getshow("meetingattend", "meetingattendedit", "meetingattendeditscript");
control.meetingleave = this._getshow("meetingleave", "meetingleaveedit", "meetingleaveeditscript");
control.meetingsit = this._getshow("meetingsit", "meetingsitedit", "meetingsiteditscript");
control.meetingrecord = this._getshow("meetingrecord", "meetingrecordedit", "meetingrecordeditscript");
return control;
},
//份数 密级 紧急程度
_loadcopiessecretpriority: function(){
this.layout_copiessecretpriority = this.contentnode.getelement(".doc_layout_copiessecretpriority");
if (this.layout_copiessecretpriority) this.layout_copiessecretpriority.setstyles(this.css.doc_layout_copiessecretpriority);
/**
* @summary 份数的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_copies = this.contentnode.getelement(".doc_layout_copies");
if (this.layout_copies) this.layout_copies.setstyles(this.css.doc_layout_copies);
/**
* @summary 密级的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_secret = this.contentnode.getelement(".doc_layout_secret");
if (this.layout_secret) this.layout_secret.setstyles(this.css.doc_layout_secret);
/**
* @summary 紧急度的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_priority = this.contentnode.getelement(".doc_layout_priority");
if (this.layout_priority) this.layout_priority.setstyles(this.css.doc_layout_priority);
this.layout_copiessecretpriority_blank = this.contentnode.getelement(".doc_layout_copiessecretpriority_blank");
},
//红头
_loadredheader: function(){
/**
* @summary 红头的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_redheader = this.contentnode.getelement(".doc_layout_redheader");
if (this.layout_redheader) this.layout_redheader.setstyles(this.css.doc_layout_redheader);
},
//文号签发人(上行文)
_loadfilenoup: function(){
this.layout_filenoarea = this.contentnode.getelement(".doc_layout_fileno_area");
this.layout_filenouptable = this.contentnode.getelement(".doc_layout_filenoup");
if (this.layout_filenouptable) this.layout_filenouptable.setstyles(this.css.doc_layout_filenoup);
var td = this.contentnode.getelement(".doc_layout_filenoup_fileno_td");
if (td) td.setstyles(this.css.doc_layout_filenoup_fileno_td);
/**
* @summary 文号的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_fileno = this.contentnode.getelement(".doc_layout_filenoup_fileno");
if (this.layout_fileno) this.layout_fileno.setstyles(this.css.doc_layout_filenoup_fileno);
td = this.contentnode.getelement(".doc_layout_filenoup_signer_td");
if (td) td.setstyles(this.css.doc_layout_filenoup_signer_td);
var node = this.contentnode.getelement(".doc_layout_filenoup_signer_table");
if (node) node.setstyles(this.css.doc_layout_filenoup_signer_table);
node = this.contentnode.getelement(".doc_layout_filenoup_signertitle_td");
if (node) node.setstyles(this.css.doc_layout_filenoup_signertitle_td);
this.layout_signertitle = this.contentnode.getelement(".doc_layout_filenoup_signer");
if (this.layout_signertitle) this.layout_signertitle.setstyles(this.css.doc_layout_filenoup_signer);
node = this.contentnode.getelement(".doc_layout_filenoup_signercontent_td");
if (node) node.setstyles(this.css.doc_layout_filenoup_signercontent_td);
/**
* @summary 签发人的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_signer = this.contentnode.getelement(".doc_layout_filenoup_signercontent");
if (this.layout_signer) this.layout_signer.setstyles(this.css.doc_layout_filenoup_signercontent);
if (!this.layout_fileno){
this.layout_filenouptable = this.contentnode.getelement(".doc_layout_filenoup");
this.layout_filenoarea = this.contentnode.getelement(".doc_layout_fileno_area");
this.layout_fileno = this.contentnode.getelement(".doc_layout_fileno");
if (this.layout_fileno) this.layout_fileno.setstyles(this.css.doc_layout_fileno);
}
},
//文号
_loadfileno: function(){
this.layout_filenouptable = this.contentnode.getelement(".doc_layout_filenoup");
this.layout_filenoarea = this.contentnode.getelement(".doc_layout_fileno_area");
this.layout_fileno = this.contentnode.getelement(".doc_layout_fileno");
if (this.layout_fileno) this.layout_fileno.setstyles(this.css.doc_layout_fileno);
td = this.contentnode.getelement(".doc_layout_filenoup_signer_td");
if (td) td.setstyles(this.css.doc_layout_filenoup_signer_td);
var node = this.contentnode.getelement(".doc_layout_filenoup_signer_table");
if (node) node.setstyles(this.css.doc_layout_filenoup_signer_table);
node = this.contentnode.getelement(".doc_layout_filenoup_signertitle_td");
if (node) node.setstyles(this.css.doc_layout_filenoup_signertitle_td);
this.layout_signertitle = this.contentnode.getelement(".doc_layout_filenoup_signer");
if (this.layout_signertitle) this.layout_signertitle.setstyles(this.css.doc_layout_filenoup_signer);
node = this.contentnode.getelement(".doc_layout_filenoup_signercontent_td");
if (node) node.setstyles(this.css.doc_layout_filenoup_signercontent_td);
this.layout_signer = this.contentnode.getelement(".doc_layout_filenoup_signercontent");
if (this.layout_signer) this.layout_signer.setstyles(this.css.doc_layout_filenoup_signercontent);
if (!this.layout_fileno){
this.layout_filenoarea = this.contentnode.getelement(".doc_layout_fileno_area");
this.layout_filenouptable = this.contentnode.getelement(".doc_layout_filenoup");
if (this.layout_filenouptable) this.layout_filenouptable.setstyles(this.css.doc_layout_filenoup);
var td = this.contentnode.getelement(".doc_layout_filenoup_fileno_td");
if (td) td.setstyles(this.css.doc_layout_filenoup_fileno_td);
this.layout_fileno = this.contentnode.getelement(".doc_layout_filenoup_fileno");
if (this.layout_fileno) this.layout_fileno.setstyles(this.css.doc_layout_filenoup_fileno);
}
},
//红线
_loadredline: function(){
this.layout_redline = this.contentnode.getelement(".doc_layout_redline");
if (this.layout_redline) this.layout_redline.setstyles(this.css.doc_layout_redline);
},
//标题
_loadsubject:function(){
/**
* @summary 标题的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_subject = this.contentnode.getelement(".doc_layout_subject");
if (this.layout_subject) this.layout_subject.setstyles(this.css.doc_layout_subject);
if (this.json.subjectfontfamily){
if (this.layout_subject) this.layout_subject.setstyle("font-family", this.json.subjectfontfamily);
}
},
//主送
_loadmainsend: function(){
/**
* @summary 主送的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_mainsend = this.contentnode.getelement(".doc_layout_mainsend");
if (this.layout_mainsend) this.layout_mainsend.setstyles(this.css.doc_layout_mainsend);
},
//正文
// _createfiletext: function(filetextnode, node, where){
// if (!filetextnode){
// var filetextnode = new element("div.doc_layout_filetext").inject(node, where);
// filetextnode.addclass("doc_block");
// filetextnode.setattribute('contenteditable', true);
// }
// ckeditor.disableautoinline = true;
// var filetexteditor = ckeditor.inline(filetextnode, this._geteditorconfig());
// filetextnode.store("editor", filetexteditor);
// if (!this.filetexteditors) this.filetexteditors = [];
// this.filetexteditors.push(filetexteditor);
//
// filetexteditor.on( 'blur', function(e) {
// // var filetextnode = e.editor.container.$;
// // var pagenode = filetextnode.getparent(".doc_layout_page");
// // this._checksplitpage(pagenode);
// // this._repage();
// }.bind(this));
//
// return filetextnode;
// },
_loadfiletext: function(){
/**
* @summary 正文区域的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_filetext = this.contentnode.getelement(".doc_layout_filetext");
this.layout_filetext.addclass("css" this.form.json.id this.json.id);
this.layout_filetext.setstyles(this.css.doc_layout_filetext);
//this.layout_filetext = this.contentnode.getelement(".doc_layout_filetext");
// if (this.layout_filetexts.length){
// this.layout_filetexts.each(function(layout_filetext){
// layout_filetext.setstyles(this.css.doc_layout_filetext);
// }.bind(this));
// }
},
//附件
_loadattachment: function(){
this.layout_attachmenttable = this.contentnode.getelement(".doc_layout_attachment");
if (this.layout_attachmenttable) this.layout_attachmenttable.setstyles(this.css.doc_layout_attachment);
var node = this.contentnode.getelement(".doc_layout_attachment_title_td");
if (node) node.setstyles(this.css.doc_layout_attachment_title_td);
this.layout_attachmenttitle = this.contentnode.getelement(".doc_layout_attachment_title");
if (node) node.setstyles(this.css.doc_layout_attachment_title);
node = this.contentnode.getelement(".doc_layout_attachment_content_td");
if (node) node.setstyles(this.css.doc_layout_attachment_content_td);
/**
* @summary 附件区域的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_attachment = this.contentnode.getelement(".doc_layout_attachment_content");
if (this.layout_attachment) this.layout_attachment.setstyles(this.css.doc_layout_attachment_content);
},
//发布单位
_loadissuance: function(){
this.layout_issuancetable = this.contentnode.getelement(".doc_layout_issuance");
/**
* @summary 发文单位的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_issuanceunit = this.contentnode.getelement(".doc_layout_issuanceunit");
/**
* @summary 发文时间的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_issuancedate = this.contentnode.getelement(".doc_layout_issuancedate");
if (this.layout_issuancetable) this.layout_issuancetable.setstyles(this.css.doc_layout_issuance);
if (this.layout_issuanceunit) this.layout_issuanceunit.setstyles(this.css.doc_layout_issuanceunit);
if (this.layout_issuancedate) this.layout_issuancedate.setstyles(this.css.doc_layout_issuancedate);
},
//附注
_loadannotation: function(){
/**
* @summary 附注的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_annotation = this.contentnode.getelement(".doc_layout_annotation");
if (this.layout_annotation) this.layout_annotation.setstyles(this.css.doc_layout_annotation);
},
//附件文本
_loadattachmenttext: function(){
this.layout_attachmenttext = this.contentnode.getelement(".doc_layout_attachment_text");
},
//版记
_loadedition: function(){
this.layout_editionarea = this.contentnode.getelement(".doc_layout_editionarea");
this.layout_edition = this.contentnode.getelement(".doc_layout_edition");
if (this.layout_edition) this.layout_edition.setstyles(this.css.doc_layout_edition);
var node = this.contentnode.getelement(".doc_layout_edition_copyto");
if (node) node.setstyles(this.css.doc_layout_edition_copyto);
node = this.contentnode.getelement(".doc_layout_edition_copyto_table");
if (node) node.setstyles(this.css.doc_layout_edition_copyto_table);
var node = this.contentnode.getelement(".doc_layout_edition_copyto2");
if (node) node.setstyles(this.css.doc_layout_edition_copyto);
node = this.contentnode.getelement(".doc_layout_edition_copyto2_table");
if (node) node.setstyles(this.css.doc_layout_edition_copyto_table);
this.layout_copytotitle = this.contentnode.getelement(".doc_layout_edition_copyto_title");
if (this.layout_copytotitle) this.layout_copytotitle.setstyles(this.css.doc_layout_edition_copyto_title);
/**
* @summary 抄送的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_copytocontent = this.contentnode.getelement(".doc_layout_edition_copyto_content");
if (this.layout_copytocontent) this.layout_copytocontent.setstyles(this.css.doc_layout_edition_copyto_content);
this.layout_copyto2title = this.contentnode.getelement(".doc_layout_edition_copyto2_title");
if (this.layout_copyto2title) this.layout_copyto2title.setstyles(this.css.doc_layout_edition_copyto_title);
this.layout_copyto2content = this.contentnode.getelement(".doc_layout_edition_copyto2_content");
if (this.layout_copyto2content) this.layout_copyto2content.setstyles(this.css.doc_layout_edition_copyto_content);
var issuance = this.contentnode.getelement(".doc_layout_edition_issuance");
if (issuance) issuance.setstyles(this.css.doc_layout_edition_issuance);
var issuance_table = this.contentnode.getelement(".doc_layout_edition_issuance_table");
if (issuance_table) issuance_table.setstyles(this.css.doc_layout_edition_issuance_table);
/**
* @summary 印发单位的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_edition_issuance_unit = this.contentnode.getelement(".doc_layout_edition_issuance_unit");
if (this.layout_edition_issuance_unit) this.layout_edition_issuance_unit.setstyles(this.css.doc_layout_edition_issuance_unit);
/**
* @summary 印发时间的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_edition_issuance_date = this.contentnode.getelement(".doc_layout_edition_issuance_date");
if (this.layout_edition_issuance_date) this.layout_edition_issuance_date.setstyles(this.css.doc_layout_edition_issuance_date);
},
loadseal: function(){
/**
* @summary 模拟盖章的dom对象.
* @member {mwf.xapplication.process.xform.documenteditor}
*/
this.layout_seals = this.contentnode.getelements(".doc_layout_seal");
this.layout_seals.each(function(node){
// if (!node.get("src")){
node.hide();
// }else{
// node.show();
// node.setstyles({
// "border": "0",
// "border-radius": "0"
// });
// }
});
},
/**对正文进行模拟盖章(模板中必须有class为“doc_layout_seal”的img对象)
* @summary 对正文进行模拟盖章,此方法只是进行模拟盖章,通过图片显示,并非专业盖章,不具备法律效应。
* * @param src{string} 盖章图片的url.
* @param position{integer} 要盖章的位置, 默认为0.
* @example
* this.form.get("documenteditor").seal("../custom/img/seal.png", 0); //在第一个盖章位置进行模拟盖章
*/
seal: function(src, position){
var p = position || 0;
if (this.layout_seals && this.layout_seals.length){
if (this.layout_seals[p]){
this.layout_seals[p].src = src;
this.layout_seals[p].show();
this.layout_seals[p].setstyles({
"border": "0",
"border-radius": "0",
"z-index": -1
});
}
this.getsealdata();
}
},
_loadmeeting: function(){
this.layout_meetingattendarea = this.contentnode.getelement(".doc_layout_meeting_attend");
this.layout_meetingattendtitle = this.contentnode.getelement(".doc_layout_meeting_attend_title");
this.layout_meetingattendcontent = this.contentnode.getelement(".doc_layout_meeting_attend_content");
this.layout_meetingleavearea = this.contentnode.getelement(".doc_layout_meeting_leave");
this.layout_meetingleavetitle = this.contentnode.getelement(".doc_layout_meeting_leave_title");
this.layout_meetingleavecontent = this.contentnode.getelement(".doc_layout_meeting_leave_content");
this.layout_meetingsitarea = this.contentnode.getelement(".doc_layout_meeting_sit");
this.layout_meetingsittitle = this.contentnode.getelement(".doc_layout_meeting_sit_title");
this.layout_meetingsitcontent = this.contentnode.getelement(".doc_layout_meeting_sit_content");
this.layout_meetingrecordarea = this.contentnode.getelement(".doc_layout_meeting_record");
this.layout_meetingrecordtitle = this.contentnode.getelement(".doc_layout_meeting_record_title");
this.layout_meetingrecordcontent = this.contentnode.getelement(".doc_layout_meeting_record_content");
},
_loadcustom: function(){
var nodes = this.contentnode.getelements(".doc_layout");
nodes.each(function(node){
var name = node.get("data-doc-layout");
if (!this.customlayouts) this.customlayouts = [];
this.customlayouts.push({
"name": name,
"node": node,
});
this[name] = node;
}.bind(this));
},
_loadpagelayout: function(control){
this._loadcopiessecretpriority();
this._loadredheader();
if (this.json.fileup){
this._loadfilenoup();
}else{
this._loadfileno();
}
if (!this.layout_fileno) this._loadfileno();
this._loadredline();
this._loadsubject();
this._loadmainsend();
this._loadfiletext();
this._loadattachment();
this._loadissuance();
this._loadannotation();
this._loadattachmenttext()
this._loadedition();
this.loadseal();
//会议纪要
this._loadmeeting();
//自定义
this._loadcustom();
this.resetshow(control);
this.resetedit();
// 份数: this.layout_copies
// 密级: this.layout_secret
// 紧急程度: this.layout_priority
// 红头: this.layout_redheader
// 上行文编号签发: this.layout_filenouptable
// 文号: this.layout_fileno
// 签发: this.layout_signertitle
// 签发人: this.layout_signer
// 文号: this.layout_fileno
// 红线: this.layout_redline
// 标题: this.layout_subject
// 主送单位: this.layout_mainsend
// 正文: this.layout_filetexts
// 附件: this.layout_attachmenttitle
// 附件: this.layout_attachment
// 单位: this.layout_issuanceunit
// 签发时间: this.layout_issuancedate
// 附注: this.layout_annotation
// 抄送: this.layout_copytotitle
// 抄送: this.layout_copytocontent
// 版记单位 this.layout_edition_issuance_unit
// 版记日期 this.layout_edition_issuance_date
},
resetshow: function(control){
if (!control) control = this.getshowcontrol();
var m = function(s){ return (control[s]) ? "show" : "hide"; }
if (this.layout_copiessecretpriority) this.layout_copiessecretpriority[m("copiessecretpriority")]();
// control.copies = this._getshow("copies", "copiesshow", "copiesshowscript");
// control.secret = this._getshow("secret", "secretshow", "secretshowscript");
// control.priority = this._getshow("priority", "priorityshow", "priorityshowscript");
var n = 0;
if (!control.copies) n ;
if (!control.secret) n ;
if (!control.priority) n ;
if (this.layout_copiessecretpriority_blank){
this.layout_copiessecretpriority_blank.empty();
while (n>0){
this.layout_copiessecretpriority_blank.appendhtml("
");
n--;
}
}
if (this.layout_copies) this.layout_copies[m("copies")]();
if (this.layout_secret) this.layout_secret[m("secret")]();
if (this.layout_priority) this.layout_priority[m("priority")]();
if (this.layout_redheader) this.layout_redheader[m("redheader")]();
if (this.layout_redline) this.layout_redline[m("redline")]();
if (this.layout_filenouptable) this.layout_filenouptable[m("signer")]();
if (this.layout_filenoarea) this.layout_filenoarea[(!control.signer) ? "show" : "hide"]();
if (this.json.fileup){
this._loadfilenoup();
}else{
this._loadfileno();
}
if (this.layout_fileno) this.layout_fileno.set("text", this.data.fileno || " ");
if (this.layout_signertitle) this.layout_signertitle[m("signer")]();
if (this.layout_signer) this.layout_signer[m("signer")]();
if (this.layout_fileno) this.layout_fileno[m("fileno")]();
if (this.layout_subject) this.layout_subject[m("subject")]();
if (this.layout_mainsend) this.layout_mainsend[m("mainsend")]();
if (this.layout_attachmenttable) this.layout_attachmenttable[m("attachment")]();
if (this.layout_issuanceunit) this.layout_issuanceunit[m("issuanceunit")]();
if (this.layout_issuancedate) this.layout_issuancedate[m("issuancedate")]();
if (this.layout_issuanceunit && this.layout_issuancedate){
var table = this.layout_issuanceunit.getparent("table")
if (table && !table.hasclass("doc_layout_headissuance")) {
var unitwidth = o2.gettextsize(this.layout_issuanceunit.get("text"), {
"font-size": "16pt",
"font-family": "'times new roman',仿宋_gb2312",
"letter-spacing": "-0.4pt"
}).x;
var datewidth = o2.gettextsize(this.layout_issuancedate.get("text"), {
"font-size": "16pt",
"font-family": "'times new roman',仿宋_gb2312",
"letter-spacing": "-0.4pt"
}).x;
if (table.hasclass("doc_layout_issuancev2")){
if (unitwidth<=datewidth){
//日期右空四字,单位相对与日期居中
var flagtd = this.layout_issuanceunit.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "64pt");
flagtd = this.layout_issuancedate.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "64pt");
var datep = this.layout_issuancedate.getparent("p");
if (datep){
datep.setstyle("text-align", "right");
var span = datep.getelement("span.space");
if (span) span.destroy();
}
}else{
var flagtd = this.layout_issuanceunit.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "32pt");
flagtd = this.layout_issuancedate.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "32pt");
var datep = this.layout_issuancedate.getparent("p");
var datep = this.layout_issuancedate.getparent("p");
if (datep){
datep.setstyle("text-align", "left");
var span = datep.getelement("span.space");
if (!span) new element("span.space", { "html": " " }).inject(datep, "top");
}
}
}else{
if (unitwidth <= datewidth) {
//日期右空四字,单位相对与日期居中
var flagtd = this.layout_issuancedate.getparent("td").getnext("td");
if (flagtd) {
var pt = 16*4; //空四字
flagtd.setstyle("width", "" pt "pt");
flagtd = this.layout_issuanceunit.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "" pt "pt");
}
//var datetd = this.layout_issuancedate.getparent("td");
var unittd = this.layout_issuanceunit.getparent("td");
unittd.setstyle("width", datewidth);
var p = this.layout_issuanceunit.getparent("p");
if (p) p.setstyle("text-align", "center");
} else {
var flagtd = this.layout_issuanceunit.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "32pt");
var unittd = this.layout_issuanceunit.getparent("td");
unittd.setstyle("width", "auto");
flagtd = this.layout_issuancedate.getparent("td").getnext("td");
if (flagtd) flagtd.setstyle("width", "64pt");
var p = this.layout_issuancedate.getparent("p");
if (p) p.setstyle("text-align", "right");
}
}
}
}
if (this.layout_annotation) this.layout_annotation[m("annotation")]();
if ((!control.copyto || !this.layout_copytocontent) && (!control.copyto2 || !this.layout_copyto2content) && (!control.editionunit || !this.layout_edition_issuance_unit) && (!control.editiondate || !this.layout_edition_issuance_date)){
if (this.layout_editionarea) this.layout_editionarea.hide();
}else{
if (this.layout_copytocontent){
if (!this.layout_copytocontenttr) this.layout_copytocontenttr = this.layout_copytocontent.getparent("tr");
if (!this.layout_copytocontenttrp) this.layout_copytocontenttrp = this.layout_copytocontenttr.getparent();
}
if (this.layout_copyto2content){
if (!this.layout_copyto2contenttr) this.layout_copyto2contenttr = this.layout_copyto2content.getparent("tr");
if (!this.layout_copyto2contenttrp) this.layout_copyto2contenttrp = this.layout_copyto2contenttr.getparent();
}
if (!this.copytoorder){
this.copytoorder = "unknow"
if (this.layout_copytocontenttr && this.layout_copyto2contenttr){ //需要知道顺序
if (this.layout_copytocontenttrp && this.layout_copyto2contenttrp && this.layout_copytocontenttrp==this.layout_copyto2contenttrp){
var n = this.layout_copytocontenttrp.getfirst();
while (n && n!=this.layout_copytocontenttr && n!=this.layout_copyto2contenttr){
n = n.getnext();
}
if (n==this.layout_copytocontenttr){
this.copytoorder = "copyto";
}
if (n==this.layout_copyto2contenttr){
this.copytoorder = "copyto2";
}
}
}
}
if ((!control.copyto || !this.layout_copytocontent) && (!control.copyto2 || !this.layout_copyto2content) ){
if (this.layout_edition){
if (this.layout_copytocontenttr) this.layout_copytocontenttr.dispose();
if (this.layout_copyto2contenttr) this.layout_copyto2contenttr.dispose();
// if (this.layout_edition) this.layout_edition.getelement("tr").getelements("td")[0].setstyles({
// "border-top": "solid windowtext 1.5pt",
// "mso-border-top-alt": "solid windowtext 1pt"
// });
}
}else if (!control.copyto || !this.layout_copytocontent){
if (this.layout_copytocontenttr) this.layout_copytocontenttr.dispose();
if (this.layout_copyto2contenttr){
try{
this.layout_copyto2contenttr.inject(this.layout_copyto2contenttrp, "top");
}catch (e){
this.layout_copyto2contenttrp.appendhtml(this.layout_copyto2contenttr.outerhtml, "top");
}
}
//if (this.layout_copyto2content) this.layout_edition.getelement("tr").destroy();
// if (this.layout_edition) this.layout_edition.getelement("tr").getelements("td").setstyles({
// "border-top": "solid windowtext 1.5pt",
// "mso-border-top-alt": "solid windowtext 1pt"
// });
}else if (!control.copyto2 || !this.layout_copyto2content) {
if (this.layout_copyto2contenttr) this.layout_copyto2contenttr.dispose();
// if (this.layout_copytocontenttr) this.layout_copytocontenttr.inject(this.layout_copytocontenttrp, "top");
if (this.layout_copytocontenttr){
try{
this.layout_copytocontenttr.inject(this.layout_copytocontenttrp, "top");
}catch (e){
this.layout_copytocontenttrp.appendhtml(this.layout_copytocontenttr.outerhtml, "top");
}
}
// if (this.layout_edition) this.layout_edition.getelement("tr").getelements("td").setstyles({
// "border-bottom": "solid windowtext 0.75pt",
// "mso-border-bottom-alt": "solid windowtext 0.75pt"
// });
}else{
if (this.copytoorder == "copyto2"){
// if (this.layout_copytocontenttr) this.layout_copytocontenttr.inject(this.layout_copytocontenttrp, "top");
// if (this.layout_copyto2contenttr) this.layout_copyto2contenttr.inject(this.layout_copyto2contenttrp, "top");
if (this.layout_copytocontenttr){
try{
this.layout_copytocontenttr.inject(this.layout_copytocontenttrp, "top");
}catch (e){
this.layout_copytocontenttrp.appendhtml(this.layout_copytocontenttr.outerhtml, "top");
}
}
if (this.layout_copyto2contenttr){
try{
this.layout_copyto2contenttr.inject(this.layout_copyto2contenttrp, "top");
}catch (e){
this.layout_copyto2contenttrp.appendhtml(this.layout_copyto2contenttr.outerhtml, "top");
}
}
}else{
// if (this.layout_copyto2contenttr) this.layout_copyto2contenttr.inject(this.layout_copyto2contenttrp, "top");
// if (this.layout_copytocontenttr) this.layout_copytocontenttr.inject(this.layout_copytocontenttrp, "top");
if (this.layout_copyto2contenttr){
try{
this.layout_copyto2contenttr.inject(this.layout_copyto2contenttrp, "top");
}catch (e){
this.layout_copyto2contenttrp.appendhtml(this.layout_copyto2contenttr.outerhtml, "top");
}
}
if (this.layout_copytocontenttr){
try{
this.layout_copytocontenttr.inject(this.layout_copytocontenttrp, "top");
}catch (e){
this.layout_copytocontenttrp.appendhtml(this.layout_copytocontenttr.outerhtml, "top");
}
}
}
}
if ((!control.editionunit || !this.layout_edition_issuance_unit) && (!control.editiondate || !this.layout_edition_issuance_date)){
if (this.layout_editionarea && (this.contentnode.getelement(".doc_layout_edition_issuance_date") || this.contentnode.getelement(".doc_layout_edition_issuance_unit"))){
var trs = this.layout_editionarea.getelement("table").rows;
trs.item(trs.length-1).destroy();
// trs = this.layout_editionarea.getelement("table").rows;
// var tr = trs.item(trs.length-1);
// if (tr){
// tr.getelements("td").setstyles({
// "border-bottom": "solid windowtext 1.5pt",
// "mso-border-bottom-alt": "solid windowtext 1pt"
// });
// }
}
}
if (this.layout_editionarea && (this.layout_edition_issuance_date || this.layout_edition_issuance_unit)){
trs = this.layout_editionarea.getelement("table").rows;
for (var i=0; i
source
"
"附件1"
""
"附件标题"
""
" 附件内容");
}
}.bind(this));
},
_loaduserinterface: function(callback){
this.node.empty();
this.node.setstyles(this.form.css.documenteditornode);
this.pages = [];
this.allowedit = this._isallowedit();
this.allowprint = this._isallowprint();
this.allowhistory = this._isallowhistory();
this.toolnode = new element("div", {"styles": this.css.doc_toolbar}).inject(this.node);
this.contentnode = new element("div#doc_content", {"styles": this.css.doc_content}).inject(this.node);
if (!this.form.isloaded){
this.form.addevent("aftermodulesload", function(){this.loaddocumenteditor(callback);}.bind(this));
}else{
this.loaddocumenteditor(callback);
}
o2.loadcss('../x_desktop/fonts/fonts.css');
},
loaddocumenteditor: function(callback){
this._loadtoolbars();
this._loadfiletextpage(function(){
this._singlepage();
this.form.addevent("beforesave", function(){
this.getdata();
this.checksavenewedition();
}.bind(this));
if (this.json.toword=="y"){
if (this.json.towordtrigger=="open") this.doctoword();
if (this.json.towordtrigger=="save") {
if (!this.form.towordsavelist) this.form.towordsavelist = [];
this.form.towordsavelist.push(this);
}
if (this.json.towordtrigger=="submit") {
if (!this.form.towordsubmitlist) this.form.towordsubmitlist = [];
this.form.towordsubmitlist.push(this);
}
}
//if (!layout.mobile) this.loadsidetoolbar();
o2.load("../o2_lib/diff-match-patch/diff_match_patch.js");
if (this.form.businessdata.data["$work"]){
var id = this.form.businessdata.data["$work"].job;
o2.actions.load("x_processplatform_assemble_surface").documentversionaction.listwithjobcategory(id, this.json.id, function(json){
this.historydocumentlist = json.data;
if (this.historydocumentlist.length){
o2.actions.load("x_processplatform_assemble_surface").documentversionaction.get(this.historydocumentlist[this.historydocumentlist.length-1].id, function(json){
var data = json.parse(json.data.data);
this.originahistorydata = data.data;
}.bind(this));
}
}.bind(this));
}
if (callback) callback();
}.bind(this));
if (!this.form.documenteditorlist) this.form.documenteditorlist=[];
this.form.documenteditorlist.push(this);
},
getfiletexttext: function(data){
// var div = new element("div", {
// "html": data
// });
// var text = div.get("text");
// div.destroy();
// return text;
var div = document.createelement("div");
div.style.height = '0px';
document.body.appendchild(div);
div.innerhtml = data;
var text = div.innertext;
if (div.remove){
div.remove();
}else{
if (div.parentnode) div.parentnode.removechild(div);
}
return text;
},
checksavenewedition: function(callback){
if (!this.allowedit || !this.data.filetext || this.data.filetext == this.json.defaultvalue.filetext) return false;
if (this.form.businessdata.work){
var originadata = this.form.businessdata.originaldata[this.json.id];
var editiondata = {"category": this.json.id};
if (!originadata || !originadata.filetext || !this.originahistorydata){
//保存原始版本
this.originahistorydata = {"data": this.data.filetext, "v": "6"};
editiondata.data = json.stringify({"data": this.data.filetext, "v": "6"});
}else if (originadata.filetext!=this.data.filetext){
//保存历史版本
var data = this.getfiletexttext(this.data.filetext);
var earlydata = this.getfiletexttext(originadata.filetext);
//var data = this.data.filetext;
//var earlydata = originadata.filetext;
var dmp = new diff_match_patch();
var diff_d = dmp.diff_main(earlydata, data);
dmp.diff_cleanupsemantic(diff_d);
var patch_list = dmp.patch_make(earlydata, data, diff_d);
var d = {
"patchs": dmp.patch_totext(patch_list),
"data": this.data.filetext,
"v": "6"
};
editiondata.data = json.stringify(d);
}else{
return false;
}
o2.actions.load("x_processplatform_assemble_surface").documentversionaction.create(this.form.businessdata.work.id, editiondata, function(json){
//originadata.filetext = this.data.filetext;
if (callback) callback();
}.bind(this));
}
},
checksavenewhistroy: function(){
var p = o2.actions.load("x_processplatform_assemble_surface").documentrevisionaction.getlast(this.form.businessdata.work.job, this.json.id);
p.then(function(json){
if (!json.data || json.data.data!=this.data.filetext){
var data = {
"category": this.json.id,
"data":this.data.filetext
}
return o2.actions.load("x_processplatform_assemble_surface").documentrevisionaction.create(this.form.businessdata.work.id, data);
}
}.bind(this));
return p;
},
resettoolbarevent: function(node){
if (browser.ie11){
if (!this.waitlocation){
this.waitlocation = window.settimeout(function(){
this.resizetoolbar(node);
this.waitlocation = false;
}.bind(this), 1000);
}
}else{
this.resizetoolbar(node);
}
},
resizetoolbar: function(node){
if (this.toolbarnode){
var p = this.toolnode.getposition(node || this.scrollnode);
var size = this.toolnode.getsize();
var pl = this.toolbarnode.getstyle("padding-left").toint();
var pr = this.toolbarnode.getstyle("padding-right").toint();
var x = size.x-pl-pr;
//var pnode = this.toolnode.getoffsetparent();
var paddingtop = (this.isfullscreen) ? 0 : (node || this.form.node).getstyle("padding-top");
try {
paddingtop = paddingtop.toint();
}catch (e) {
paddingtop = 0;
}
if (p.y";
this.sidebarnode.set("html", html);
mwf.require("mwf.widget.toolbar", function() {
this.sidetoolbar = new mwf.widget.toolbar(this.sidebarnode, {"style": "documentedit_side"}, this);
this.sidetoolbar.load();
}.bind(this));
}
}
}
},
_returnscale: function(){
this.isscale = false;
this.scale = 0;
this.contentnode.setstyles({
"transform":"scale(1)",
});
if (this.pages.length){
this.pages.each(function(page){
page.setstyles({
"transform":"scale(1)",
});
});
}
this.node.setstyles({
"height": "auto"
});
},
_checkscale: function(offset){
offset = 0;
this._contentnodewitdh();
if (this.pages.length){
//var pagesize = this.pages[0].getsize();
var pagesize_x = this.options.docpagefullwidth;
// var contentsize = this.contentnode.getsize();
//var contentsize = this.node.getsize();
// var contentwidth = (offset) ? contentsize.x-20-offset : contentsize.x-20;
// if (contentwidthscrollnode.getsize().y){
break;
}
}
scrollnode = scrollnode.getparent();
}
this.filetextscrollnode = scrollnode;
}
var h = toolbarnode.getsize().y;
var position = node.getposition();
var size = node.getsize();
var contentsize = this.filetextscrollnode.getsize();
if (layout.userlayout && layout.userlayout.scale && layout.userlayout.scale!==1){
var x = editor.editable().$.getposition().x;
toolbarnode.setstyle("left", "" x "px");
}
toolbarnode.setstyle("min-width", "530px");
if (position.y<0 && size.y position.y hscrollnode.getsize().y){
break;
}
}
scrollnode = scrollnode.getparent();
}
if (scrollnode){
this.filetextscrollnode = scrollnode
if (editorname){
if (this.relocationattachmenttexttoolbarfun) this.filetextscrollnode.removeevent("scroll", this.relocationattachmenttexttoolbarfun);
if (!this.relocationattachmenttexttoolbarfun) this.relocationattachmenttexttoolbarfun = function(){
this.relocationfiletexttoolbarevent(editorname);
}.bind(this);
this.filetextscrollnode.addevent("scroll", this.relocationattachmenttexttoolbarfun);
}else{
if (this.relocationfiletexttoolbarfun) this.filetextscrollnode.removeevent("scroll", this.relocationfiletexttoolbarfun);
if (!this.relocationfiletexttoolbarfun) this.relocationfiletexttoolbarfun = this.relocationfiletexttoolbarevent.bind(this);
this.filetextscrollnode.addevent("scroll", this.relocationfiletexttoolbarfun);
}
}
}
},
_isallowedit:function(){
if (this.readonly) return false;
if (this.json.allowedit=="n") return false;
if (this.json.allowedit=="s"){
if (this.json.alloweditscript && this.json.alloweditscript.code){
return !!this.form.macro.exec(this.json.alloweditscript.code, this);
}
}
return true;
},
_isallowprint: function(){
if (this.json.allowprint=="n") return false;
if (this.json.allowprint=="s"){
if (this.json.allowprintscript && this.json.allowprintscript.code){
return !!this.form.macro.exec(this.json.allowprintscript.code, this);
}
}
return true;
},
_isallowhistory: function(){
if (this.json.allowhistory=="n") return false;
if (this.json.allowhistory=="s"){
if (this.json.allowhistoryscript && this.json.allowhistoryscript.code){
return !!this.form.macro.exec(this.json.allowhistoryscript.code, this);
}
}
return true;
},
_getedit: function(name, typeitem, scriptitem){
switch (this.json[typeitem]) {
case "y":
return true;
case "n":
return false;
case "s":
if (this.json[scriptitem] && this.json[scriptitem].code){
return !!this.form.macro.exec(this.json[scriptitem].code, this);
}
return true;
}
},
loadckeditorstyle: function(node){
if (node){
o2.load("ckeditor", function(){
//ckeditor.disableautoinline = true;
node.setattribute('contenteditable', true);
var editor = ckeditor.inline(this.layout_filetext, this._geteditorconfig());
this.filetexteditor.on("instanceready", function(e){
if (callback) callback(e);
}.bind(this));
}.bind(this));
}
},
_loadtoolbars: function(){
var html ="";
var editdoc, printdoc, history, fullscreen=mwf.xapplication.process.xform.lp.fullscreen;
if (layout.mobile){
editdoc = mwf.xapplication.process.xform.lp.editdoc_mobile;
printdoc = mwf.xapplication.process.xform.lp.printdoc_mobile;
history = mwf.xapplication.process.xform.lp.history_mobile;
}else{
editdoc = mwf.xapplication.process.xform.lp.editdoc;
printdoc = mwf.xapplication.process.xform.lp.printdoc;
history = mwf.xapplication.process.xform.lp.history;
}
// if (this.allowedit){
// //html = "";
// html = "";
// //html = "";
// }
if (this.allowprint){
html = "";
}
if (this.allowhistory){
html = "";
}
if (this.json.canfullscreen!=="n"){
html = "";
}
// if (this.json.fullwidth=="y"){
// html = "已启用半角空格自动转换为全角空格,如需输入半角空格,请使用:shift 空格"
// }
this.toolbarnode = new element("div", {"styles": this.css.doc_toolbar_node}).inject(this.toolnode);
this.toolbarnode.set("html", html);
mwf.require("mwf.widget.toolbar", function() {
this.toolbar = new mwf.widget.toolbar(this.toolbarnode, {"style": "documentedit"}, this);
this.toolbar.load();
}.bind(this));
if (!layout.mobile){
this.scrollnode = this.toolbarnode.getparentsrcollnode();
if (this.scrollnode){
this.scrollnode.addevent("scroll", function(){
this.resettoolbarevent();
}.bind(this));
}
}
//if (this.json.candoublepage!=="n" && !layout.mobile){
this.doublepageaction = new element("div", {"styles": this.css.doc_toolbar_doublepage, "text": mwf.xapplication.process.xform.lp.doublepage}).inject(this.toolbarnode);
this.doublepageaction.addevent("click", function(){
if (this.options.pageshow!=="double"){
this._doublepage();
}else{
this.options.pageshow="single";
this.reload();
// this._singlepage();
var _self = this;
window.settimeout(function(){
_self.scaleto(_self.documenteditorscale);
},10);
}
}.bind(this));
if (this.json.candoublepage==="n" || layout.mobile) this.doublepageaction.hide();
//}
this.zoomactionarea = new element("div", {"styles": {"float": "right", "margin-right": "10px"}}).inject(this.toolbarnode);
if (this.json.isscale !== "y") this.zoomactionarea.hide();
this.zoomaddaction = new element("div", {
"styles": {
"float": "right",
"margin-top": "3px",
"height": "20px",
"width": "20px",
"text-align": "center",
"line-height": "20px",
"border": "1px solid #cccccc",
"background-color": "#ffffff",
"margin-left": "5px"
},
"text": " "
}).inject(this.zoomactionarea);
this.zoomselectaction = new element("select", {
"styles": {
"float": "right",
"margin-top": "3px",
"height": "20px",
"width": "60px",
"text-align": "center",
"line-height": "20px",
"border": "1px solid #cccccc",
"background-color": "#ffffff",
"margin-left": "5px"
},
"text": "100%"
}).inject(this.zoomactionarea);
this.zoomsubaction = new element("div", {
"styles": {
"float": "right",
"margin-top": "3px",
"height": "20px",
"width": "20px",
"text-align": "center",
"line-height": "20px",
"border": "1px solid #cccccc",
"background-color": "#ffffff",
"margin-left": "5px"
},
"text": "-"
}).inject(this.zoomactionarea);
// this.zoomselectaction = new element("select", {"styles": {"float": "right"}}).inject(this.toolbarnode);
var options = " "
""
""
""
""
""
""
""
""
""
" "
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
"";
this.zoomselectaction.set("html", options);
this.zoomselectaction.addevent("change", function(e){
this.scaleto(e.target.options[e.target.selectedindex].value);
o2.ud.putdata("documenteditorscale", {"scale": this.scale});
this.documenteditorscale = this.scale;
}.bind(this));
this.zoomaddaction.addevent("click", function(){
var i = (this.scale/0.05).toint();
if (i*0.052) v = 2;
this.scaleto(v);
o2.ud.putdata("documenteditorscale", {"scale": this.scale});
this.documenteditorscale = this.scale;
}.bind(this));
this.zoomsubaction.addevent("click", function(){
var i = (this.scale/0.05).toint();
if (i*0.052) v = 2;
this.scaleto(v);
o2.ud.putdata("documenteditorscale", {"scale": this.scale});
this.documenteditorscale = this.scale;
}.bind(this));
},
_fullscreen: function(){
this.positionnode = new element("div").inject(this.node, "after");
this.node.inject(this.scrollnode, "top");
this.form.node.hide();
this.node.setstyle("min-height", "100%");
this.fireevent("fullscreen");
this.isfullscreen = true;
this.resizetoolbar();
},
_returnscreen: function(){
this.form.node.show();
this.node.inject(this.positionnode, "before");
this.positionnode.destroy();
this.node.setstyle("min-height", "");
this.fireevent("returnscreen");
this.isfullscreen = false;
this.resizetoolbar();
},
fullscreen: function(bt){
var text = bt.node.get("text");
var content = this.form.app.content;
var stopfun = function(e){ e.stoppropagation(); };
if (text===mwf.xapplication.process.xform.lp.returnscreen){
//this.form.node.getparent().show();
this.form.node.show();
this.node.inject(this.positionnode, "before");
this.positionnode.destroy();
// var styles = content.retrieve("tmpstyles");
// content.setstyles({
// "position": styles.position,
// "overflow": styles.overflow
// });
//this.node.setstyles(this.css.returnscreen);
this.node.setstyle("min-height", "");
this.fireevent("returnscreen");
bt.settext(mwf.xapplication.process.xform.lp.fullscreen);
// this.fullscreenscrollnode = this.node.getoffsetparent().getfirst().getparentsrcollnode();
// if (this.fullscreenscrollnode){
// if (this.fullscreenscrollresizetoolbarfun) this.fullscreenscrollnode.removeevent("scroll", this.fullscreenscrollresizetoolbarfun);
// }
//this.node.removeevent("wheel", stopfun);
this.isfullscreen = false;
this.resizetoolbar();
}else{
// this.positionnode = new element("div").inject(this.node, "after");
// this.node.inject(content, "top");
// this.form.node.hide();
this.positionnode = new element("div").inject(this.node, "after");
this.node.inject(this.scrollnode, "top");
//this.form.node.getparent().hide();
this.form.node.hide();
// var position = content.getstyle("poaition");
// var overflow = content.getstyle("overflow");
// content.store("tmpstyles", {"position": position, "overflow": overflow});
// content.setstyles({
// "position": "relative",
// "overflow": "auto"
// });
//this.node.setstyles(this.css.fullscreen);
this.node.setstyle("min-height", "100%");
this.fireevent("fullscreen");
// this.fullscreenscrollnode = this.node.getoffsetparent().getfirst().getparentsrcollnode();
// if (this.fullscreenscrollnode){
// this.fullscreenscrollresizetoolbarfun = function(){this.resizetoolbar(this.fullscreenscrollnode);}.bind(this);
// this.fullscreenscrollresizetoolbarfun();
// this.fullscreenscrollnode.addevent("scroll", this.fullscreenscrollresizetoolbarfun);
// }
bt.settext(mwf.xapplication.process.xform.lp.returnscreen);
this.isfullscreen = true;
//this.node.addevent("wheel", stopfun);
this.resizetoolbar();
}
if (this.options.pageshow!=="double"){
this.getdata();
}
// this.getdata();
var _self = this;
window.settimeout(function(){
_self.reload();
},20)
},
/**缩放文件内容
* @param scale{number} 缩放的比率
* @example
* this.form.get("fieldid").scaleto(0.5);
*/
scaleto: function(scale){
//this._returnscale();
this.isscale = false;
this.scale = scale;
this.zoom();
// //var w = this.contentnode.getsize().x*this.scale;
// var w = this.contentnode.offsetwidth*this.scale;
// //if (layout.userlayout && layout.userlayout.scale) w = w*layout.userlayout.scale;
// var count = 1;
// var docpagefullwidth = (this.scale) ? this.scale*this.options.docpagefullwidth : this.options.docpagefullwidth;
// //if (layout.userlayout && layout.userlayout.scale) docpagefullwidth = docpagefullwidth*layout.userlayout.scale;
// var pagewidth = count * docpagefullwidth;
// var margin = (w-pagewidth)/(count 1);
// if (this.isscale){
// margin = "10";
// }
// if (this.scale) margin = margin/this.scale;
// if (margin < 10){
// var offset = 10-margin;
// margin = 10;
// this.contentnode.scrollto(offset, 0);
// }
// this.pages.each(function(page, i){
// page.setstyles({
// "float": "left",
// "margin-left": "" margin "px"
// });
// });
this.resetnodesize();
},
_repage: function(delay){
if (this.options.pageshow!=="double"){
this._singlepage();
}else{
this._doublepage();
}
if (delay){
if (!this.form.isloaded){
this.form.addevent("afterload", this._checkscale.bind(this));
}else{
this._checkscale();
}
}else{
this._checkscale();
}
},
_contentnodewitdh: function(){
var w = this.node.getsize().x;
if (this.history && this.history.historylistareanode) w = w-this.history.historylistareanode.getcomputedsize().totalwidth-2;
w = w/this.scale;
this.contentnode.setstyles({
"width": "" w "px"
});
},
_pagemargin: function(){
this._contentnodewitdh();
var w = this.contentnode.offsetwidth.tofloat();
w = (this.scale) ? this.scale*w : w;
var count = 1;
var docpagefullwidth = (this.scale) ? this.scale*this.options.docpagefullwidth : this.options.docpagefullwidth;
var pagewidth = count * docpagefullwidth;
var margin = (w-pagewidth)/(count 1);
if (this.scale) margin = margin/this.scale;
if (margin<0) margin=0;
this.pages.each(function(page, i){
page.setstyles({
"float": "left",
"margin-left": "" margin "px"
});
});
if (margin==0){
var scrollleft = (this.contentnode.scrollwidth - this.contentnode.offsetwidth)/2;
if (this.contentnode.scrollto){
this.contentnode.scrollto(scrollleft, 0);
}else{
this.contentnode.scrollleft = scrollleft;
}
}
this.fireevent("pageposition");
},
_singlepage: function(){
//if (this.editmode) this._readfiletext();
var scale = this.singlepagezoom;
if (!scale) scale = this.scale || 1;
if( this.singlepagezoom && this.singlepagezoom.toint() != 1 ){
this.isscale = true;
this.scale = this.singlepagezoom;
this.singlepagezoom = null;
}
//this.zoom(scale);
this._checkscale();
this._pagemargin();
// var w = this.contentnode.getsize().x;
// var count = 1;
// var docpagefullwidth = (this.scale) ? this.scale*this.options.docpagefullwidth : this.options.docpagefullwidth;
// //var docpagefullwidth = this.options.docpagefullwidt;
//
// var pagewidth = count * docpagefullwidth;
// var margin = (w-pagewidth)/(count 1);
//
// if (this.isscale){
// margin = "10";
// }
// if (this.scale) margin = margin/this.scale;
// this.pages.each(function(page, i){
// page.setstyles({
// "float": "left",
// "margin-left": "" margin "px"
// });
// });
this.resetnodesize();
// this.pages.each(function(page){
// page.setstyle("float", "none");
// });
this.resizesidebar();
this.options.pageshow="single";
this.doublepageaction.set("text", mwf.xapplication.process.xform.lp.doublepage);
},
resetnodesize: function(){
//var contentsize = this.contentnode.getsize();
var contentheight = this.contentnode.offsetheight;
var toolbarsize = this.toolnode.getsize();
contentheight = contentheight*(this.scale || 1);
var h = contentheight toolbarsize.y 20;
//h = h - contentsize.y*(1-this.scale);
this.node.setstyles({
"height":"" h "px"
});
this.resizesidebar();
},
createwaitsplitpage: function(){
this.node.mask({
"style": {
"background-color": "#cccccc",
"opacity": 0.3
}
});
this.waitsplitpagenode = new element("div", {"styles": this.form.css.waitsplitpagenode, "text": mwf.xapplication.process.xform.lp.computepage}).inject(this.node);
this.waitsplitpagenode.position({
"relativeto": this.node,
"position": "topright",
"edge": "topright",
"offset": {
"x": -10,
"y": 45
}
});
//this.form.notice(mwf.xapplication.process.xform.lp.computepage, "info", this.node);
},
clearwaitsplitpage: function(){
this.node.unmask();
if (this.waitsplitpagenode) this.waitsplitpagenode.destroy();
this.waitsplitpagenode = null;
},
_doublepage: function(){
if (this.editmode) this._switchreadoreditinline();
if( this.zoomselectaction ){
this.singlepagezoom = ( this.zoomselectaction.options[this.zoomselectaction.selectedindex].value ).tofloat();
}
this.zoom(1);
this.createwaitsplitpage();
window.settimeout(function(){
this._checksplitpage(this.pages[0]);
this.zoom(1);
var w = this.contentnode.getsize().x;
var topagewidth = (w-100)/2;
scale = topagewidth/this.options.docpagefullwidth;
if (scale<1) this.zoom(scale);
var docpagefullwidth = (this.scale) ? this.scale*this.options.docpagefullwidth : this.options.docpagefullwidth;
//var docpagefullwidth = this.options.docpagefullwidth;
var w = this.contentnode.getsize().x;
var count = (w/docpagefullwidth).toint();
var pages = this.contentnode.getelements(".doc_layout_page");
count = math.min(pages.length, count);
var pagewidth = count * docpagefullwidth;
var margin = (w-pagewidth)/(count 1);
if (this.scale) margin = margin/(this.scale);
this.pages.each(function(page, i){
page.setstyles({
"float": "left",
"margin-left": "" margin "px"
});
});
// this.pages.each(function(page, i){
// if ((i % 2)===0){
// page.setstyle("float", "left");
// }else{
// page.setstyle("float", "right");
// }
// });
this.resetnodesize();
this.options.pageshow="double";
this.doublepageaction.set("text", mwf.xapplication.process.xform.lp.singlepage);
this.resizesidebar();
this.clearwaitsplitpage();
var s = 0;
this.pages.foreach(function(page, i){
s ;
var styles = {
"bottom": "-60px",
"margin-top": "10px",
"position": "absolute"
}
if (s % 2 === 0){
styles.left = "0";
}else{
styles.right = "0";
}
var pagenumbernode = new element("div", {
"html": "— " s " —",
"styles": styles
}).inject(page.getfirst());
}.bind(this));
}.bind(this), 1000);
},
_getdefaultdata: function(){
return object.clone(this.json.defaultvalue);
//return object.clone(mwf.xapplication.process.xform.lp.documenteditor);
},
_loadfiletextpage: function(callback){
this.data = this._getbusinessdata();
if (!this.data) this.data = this._getdefaultdata();
this._computedata(true);
this._createpage(function(control){
this._loadpagelayout(control);
// this.data = this._getbusinessdata();
// if (!this.data) this.data = this._getdefaultdata();
this.setdata(this.data);
// this._checksplitpage(this.pages[0]);
//this._repage(true);
//this.loadckeditorfiletext();
if (!this.readonly){
//if (this.json.alloweditfiletext!==false) this.loadckeditorfiletext();
// if (this.json.alloweditredheader) this.loadckeditorredheader();
// if (this.json.alloweditsubject) this.loadckeditorsubject();
// if (this.json.alloweditmainsend) this.loadckeditormainsend();
// if (this.json.alloweditfileno) this.loadckeditorfileno();
// if (this.json.alloweditsigner) this.loadckeditorsigner();
// if (this.json.alloweditattachment) this.loadckeditorattachment();
}
if (!this.editmode && this.allowedit && !this.historymode){
this._editfiletext("inline");
//if (this.loadfiletexteditfun) this.layout_filetext.removeevent("click", this.loadfiletexteditfun);
this.editmode = true;
}
if (callback) callback();
}.bind(this));
},
_geteditorconfig: function(editorname){
// var mathelements = [
// 'math',
// 'maction',
// 'maligngroup',
// 'malignmark',
// 'menclose',
// 'merror',
// 'mfenced',
// 'mfrac',
// 'mglyph',
// 'mi',
// 'mlabeledtr',
// 'mlongdiv',
// 'mmultiscripts',
// 'mn',
// 'mo',
// 'mover',
// 'mpadded',
// 'mphantom',
// 'mroot',
// 'mrow',
// 'ms',
// 'mscarries',
// 'mscarry',
// 'msgroup',
// 'msline',
// 'mspace',
// 'msqrt',
// 'msrow',
// 'mstack',
// 'mstyle',
// 'msub',
// 'msup',
// 'msubsup',
// 'mtable',
// 'mtd',
// 'mtext',
// 'mtr',
// 'munder',
// 'munderover',
// 'semantics',
// 'annotation',
// 'annotation-xml'
// ];
//ckeditor.plugins.addexternal('ckeditor_wiris', 'https://ckeditor.com/docs/ckeditor4/4.13.0/examples/assets/plugins/ckeditor_wiris/', 'plugin.js');
var editorconfig = {
qtrows: 20, // count of rows
qtcolumns: 20, // count of columns
qtborder: '1', // border of inserted table
qtwidth: '95%', // width of inserted table
qtstyle: { 'border-collapse' : 'collapse' },
qtclass: 'documenteditor_table' this.form.json.id this.json.id, // class of table
qtcellpadding: '0', // cell padding table
qtcellspacing: '0', // cell spacing table
qtpreviewborder: '4px double black', // preview table border
qtpreviewsize: '4px', // preview table cell size
qtpreviewbackground: '#c8def4', // preview table background (hover)
language: o2.language,
// format_tags: '标题一;标题二;标题三;标题四;正文', // entries is displayed in "paragraph format"
format_tags: '标题一;标题二;正文(标题三,四)', // entries is displayed in "paragraph format"
'format_标题一': {
name: '标题一(三号黑体)',
element: 'div',
styles: {
'font-family': '黑体',
'font-size': '16pt'
}
},
'format_标题二': {
name: '标题二(三号楷体)',
element: 'div',
styles: {
'font-family': '楷体_gb2312',
'font-size': '16pt'
}
},
// 'format_标题三': {
// name: '标题三',
// element: 'div',
// styles: {
// 'font-family': '仿宋_gb2312',
// 'font-size': '16pt'
// }
// },
// 'format_标题四': {
// name: '标题四',
// element: 'div',
// styles: {
// 'font-family': '仿宋_gb2312',
// 'font-size': '16pt'
// }
// },
'format_正文(标题三,四)': {
name: '正文(标题三,四)',
element: 'div',
styles: {
'font-family': '仿宋_gb2312',
'font-size': '16pt'
}
}
};
editorconfig.toolbargroups = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'forms', groups: [ 'forms' ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'about', groups: [ 'about' ] }
];
//editorconfig.extraplugins = "ecnet,colordialog,tableresize,quicktable,mathjax,ckeditor_wiris";
//editorconfig.extraplugins = "ecnet,colordialog,quicktable,tableresize,eqneditor";
//editorconfig.extraplugins = "tableresize,quicktable";
editorconfig.extraplugins = "quicktable,tableresize";
//editorconfig.mathjaxlib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/mathjax.js?config=tex-ams_html',
//editorconfig.removebuttons = 'numberedlist,source,save,newpage,preview,print,templates,paste,pastefromword,scayt,form,checkbox,radio,textfield,textarea,select,button,imagebutton,hiddenfield,bold,italic,underline,strike,subscript,superscript,copyformatting,removeformat,bulletedlist,outdent,indent,blockquote,creatediv,bidiltr,bidirtl,language,link,unlink,anchor,image,flash,horizontalrule,smiley,specialchar,pagebreak,iframe,textcolor,bgcolor,maximize,showblocks,about,styles,font,fontsize';
editorconfig.removebuttons = 'easyimageupload,exportpdf,source,save,newpage,preview,print,templates,paste,pastefromword,scayt,form,checkbox,radio,textfield,textarea,select,button,imagebutton,hiddenfield,bold,italic,underline,strike,subscript,superscript,copyformatting,removeformat,outdent,indent,blockquote,creatediv,bidiltr,bidirtl,language,link,unlink,anchor,image,flash,horizontalrule,smiley,specialchar,pagebreak,iframe,textcolor,bgcolor,maximize,showblocks,about,styles,font,fontsize';
//editorconfig.removebuttons = 'source,save,newpage,preview,print,templates,paste,pastefromword,scayt,form,checkbox,radio,textfield,textarea,select,button,imagebutton,hiddenfield,bold,italic,underline,strike,subscript,superscript,copyformatting,removeformat,outdent,indent,blockquote,creatediv,bidiltr,bidirtl,language,link,unlink,anchor,flash,horizontalrule,smiley,specialchar,pagebreak,iframe,textcolor,bgcolor,maximize,showblocks,about,styles,font,fontsize';
//editorconfig.extraallowedcontent = mathelements.join(' ') '(*)[*]{*};img[data-mathml,data-custom-editor,role](wirisformula)';
editorconfig.pastefromwordremovefontstyles = false;
editorconfig.pastefromwordremovestyles = false;
editorconfig.pastefromwordnumberedheadingtolist = false;
//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';
editorconfig.removeplugins = ['magicline','cloudservices','easyimage', 'exportpdf'];
editorconfig.entermode = ckeditor.enter_div;
editorconfig.pastefilter = "plain-text";
// editorconfig.extraplugins = ['ecnet','mathjax'];
// editorconfig.removeplugins = ['magicline'];
// editorconfig.mathjaxlib = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/mathjax.js?config=tex-ams_html';
if (this.json.ckeditconfigoptions && this.json.ckeditconfigoptions.code){
var o = this.form.macro.exec(this.json.ckeditconfigoptions.code, this);
if (o) editorconfig = object.merge(editorconfig, o);
}
if (editorname){
editorconfig.removebuttons = editorconfig.removebuttons.split(/,\s*/).erase("pagebreak").join(",");
var tags = editorconfig.format_tags.split(/;\s*/);
if (tags.indexof("附件标题")==-1){
editorconfig.format_tags = "附件标题" ((editorconfig.format_tags) ? ";" : "") editorconfig.format_tags;
}
if (tags.indexof("附件序号")==-1){
editorconfig.format_tags = "附件序号" ((editorconfig.format_tags) ? ";" : "") editorconfig.format_tags;
}
if (!editorconfig["format_附件序号"]) editorconfig["format_附件序号"] = {
name: '附件序号',
element: 'div',
styles: {
'font-family': '黑体',
'font-size': '16pt'
}
};
if (!editorconfig["format_附件标题"]) editorconfig["format_附件标题"] = {
name: '附件标题',
element: 'div',
styles: {
'font-family': '方正小标宋简体',
'font-size': '22pt',
'text-align': 'center'
}
}
}
return editorconfig;
},
_checksplitpage: function(pagenode){
if (this.layout_edition) this.layout_edition.setstyles({ "position": "static"});
var contentnode = pagenode.getfirst();
if (contentnode.getsize().y>this.options.docpageheight){
this._splitpage(pagenode);
}
var i = pagenode.get("data-pagecount").toint();
if (i && this.pages.length-1>=i){
this._checksplitpage(this.pages[i]);
}
if (this.layout_edition) this.layout_edition.setstyles({ "position": "absolute", "bottom": "0px" });
},
_splitfiletextnodeoneword:function(lnode, nextpagenode){
var text = lnode.textcontent;
var len = text.length;
var left = text.substring(0, len-1);
var right = text.substring(len-1, len);
lnode.textcontent = left;
nextpagenode.textcontent = right nextpagenode.textcontent;
//nextpagenode.appendtext(right, "top");
},
_splitfiletext: function(node, nextpagenode, nextfiletextnode, pagenode){
var contentnode = pagenode.getfirst();
var lnode = node.lastchild;
if (!lnode){
if (node.parentnode) node.parentnode.removechild(node);
//node.remove();
}else{
while (contentnode.getsize().y>this.options.docpageheight && lnode) {
var tmpnode = lnode.previoussibling;
var nodetype = lnode.nodetype;
if (!nextpagenode) nextpagenode = nextfiletextnode;
if (nodetype == node.element_node) {
if (lnode.tagname == "table") {
lnode.inject(nextpagenode);
} else if (lnode.tagname == "br") {
if (lnode.parentnode) lnode.parentnode.removechild(lnode);
} else {
var id = lnode.get("data-pagepart");
if (!id){
id = (new o2.widget.uuid()).tostring();
lnode.set("data-pagepart", id);
}
var tmpnode = nextpagenode.getfirst();
if (tmpnode && tmpnode.get("data-pagepart")==id){
nextpagenode = tmpnode;
}else{
nextpagenode = lnode.clone(false).inject(nextpagenode, "top");
}
//var subnode = lnode.getlast();
this._splitfiletext(lnode, nextpagenode, nextfiletextnode, pagenode);
if (!lnode.firstchild) if (lnode.parentnode) lnode.parentnode.removechild(lnode);
nextpagenode = nextpagenode.getparent();
}
} else if (nodetype == node.text_node) {
var nextpagetextnode = nextpagenode.insertbefore(document.createtextnode(""), nextpagenode.firstchild);
while ((contentnode.getsize().y > this.options.docpageheight) && lnode.textcontent) {
//console.log(contentnode.getsize().y);
this._splitfiletextnodeoneword(lnode, nextpagetextnode)
}
if (!lnode.textcontent) if (lnode.parentnode) lnode.parentnode.removechild(lnode); //lnode.remove();
} else {
//lnode.remove();
if (lnode.parentnode) lnode.parentnode.removechild(lnode);
}
lnode = tmpnode;
}
if (!node.lastchild) if (node.parentnode) node.parentnode.removechild(node); //node.remove();
}
//this._checksplitpage(pagenode);
},
_splitpage: function(pagenode){
var contentnode = pagenode.getfirst();
var blocknodes = pagenode.getelements(".doc_block");
if (blocknodes.length){
var blocknode = blocknodes[blocknodes.length-1];
var idx = this.pages.indexof(pagenode);
if (this.pages.length<=idx 1) this._createnewpage();
var nextpage = this.pages[idx 1];
if (blocknode.hasclass("doc_layout_filetext")){
var filetextnode = nextpage.getelement(".doc_layout_filetext");
if (!filetextnode){
filetextnode = new element("div.doc_layout_filetext").inject(nextpage.getfirst(), "top");
//filetextnode.setattribute('contenteditable', true);
}
if (!filetextnode.hasclass("doc_block"))filetextnode.addclass("doc_block");
//var nexteditor = filetextnode.retrieve("editor");
var node = blocknode;
var nextpagenode = filetextnode;
this._splitfiletext(node, nextpagenode, filetextnode, pagenode);
}else{
blocknode.inject(nextpage.getfirst(), "top");
//var contentnode = pagenode.getfirst();
if (contentnode.getsize().y>this.options.docpageheight){
this._splitpage(pagenode);
}
}
}
},
transwidth: function(node){
if (!node) return '';
while (node){
if (node.nodetype==3){
node.nodevalue = node.nodevalue.replace(/\x20/g, " ");
}else if (node.nodetype==8){
//nothing
}else{
this.transwidth(node.firstchild);
}
node = node.nextsibling;
}
},
insertfullwidth: function(node, txt){
if (!node) return '';
while (node){
if (node.nodetype==3){
node.nodevalue = txt node.nodevalue;
return true;
}else if (node.nodetype==8){
//nothing
}else{
var flag = this.insertfullwidth(node.firstchild, txt);
if (flag) return true;
}
node = node.nextsibling;
}
},
loadckeditorfiletext: function(callback, inline, node, editorname){
if (node || this.layout_filetext){
o2.load("../o2_lib/htmleditor/ckeditor4161/ckeditor.js", function(){
ckeditor.disableautoinline = true;
(node || this.layout_filetext).setattribute('contenteditable', true);
var editor;
try{
editor = ckeditor.inline(node || this.layout_filetext, this._geteditorconfig(editorname));
this[(editorname || "filetexteditor")] = editor;
editor.on("instanceready", function(e){
var v = e.editor.editable().$.get("text");
if (!v || v==" ") e.editor.setdata(this.json.defaultvalue.filetext);
if (callback) callback(e);
}.bind(this));
editor.on( 'focus', function( e ) {
window.settimeout(function(){
// this.relocationfiletexttoolbar(editorname);
this.locationfiletexttoolbar(editorname);
}.bind(this), 10);
var v = e.editor.editable().$.get("text");
if (!v || v==this.json.defaultvalue.filetext){
e.editor.setdata(" ");
e.editor.focus();
var range = e.editor.createrange();
range.movetoelementeditend(e.editor.editable());
range.select();
}
}.bind(this) );
editor.on( 'blur', function( e ) {
if (!!editorname) this.getattachmenttextdata();
var v = e.editor.editable().$.get("text");
if (!v || v==" ") e.editor.setdata(this.json.defaultvalue.filetext);
}.bind(this) );
editor.on( 'loaded', function( e ) {
editor.element.$.store("module", this);
editor.element.$.store("scale", this.scale);
}.bind(this) );
editor.on( 'afterpaste', function( e ) {
}.bind(this));
editor.on( 'afterpastefromword', function( e ) {
}.bind(this));
editor.on( 'paste', function( e ) {
var html = e.data.datavalue;
//if (this.json.fullwidth=="y") html = html.replace(/\x20/g, " ");
var rexbr = /\
|\
|\
/g;
var rexp = /\/g;
if (rexbr.test(html) && !rexp.test(html)){
var ps = html.split(/\
|\
|\
/g);
html = "";
ps.each(function(p){
html = html "
" p "
";
});
}
var tmp = new element("div")
tmp.set("html", html);
var plist = tmp.getelements("p");
plist.each(function(p, i){
//if (browser.name=="ie"){
if (this.json.fullwidth!=="n") this.transwidth(p);
if (!p.getparent("table")){
var text = p.get("text");
var rex = /^\u3000*/;
var m = text.match(rex);
var l = (m[0]) ? math.max((2-m[0].length), 0): 2;
var txt = "";
// for (var i=0; iw){
table.setstyle("width", "" w "px");
}
});
tablelist.setstyles({
"margin-left": "",
"margin-right": "",
"word-break": "break-all"
});
}
var tdlist = tmp.getelements("td");
tdlist.each(function(td){
var tbw_top = td.getstyle("border-top-width").tofloat() || 0;
var tbw_bottom = td.getstyle("border-bottom-width").tofloat() || 0;
var tbw_left = td.getstyle("border-left-width").tofloat() || 0;
var tbw_right = td.getstyle("border-right-width").tofloat() || 0;
td.setstyles({
"border-top-width": (tbw_top/2) "px",
"border-bottom-width": (tbw_bottom/2) "px",
"border-left-width": (tbw_left/2) "px",
"border-right-width": (tbw_right/2) "px",
});
});
e.data.datavalue = tmp.get("html");
tmp.destroy();
this.fireevent("paste");
}.bind(this) );
editor.on( 'afterpaste', function( e ) {
this.resetnodesize();
this.fireevent("afterpaste");
}.bind(this) );
editor.on( 'change', function( e ) {
var h = document.documentelement.scrolltop;
var scrollnode = this.contentnode;
while (scrollnode && (scrollnode.getscrollsize().y<=scrollnode.getsize().y || (scrollnode.getstyle("overflow")!=="auto" && scrollnode.getstyle("4-y")!=="auto"))){
scrollnode = scrollnode.getparent();
}
if (scrollnode){
var top = scrollnode.scrolltop.tofloat();
scrollnode.scrolltop = h top;
}
document.documentelement.scrolltop = 0;
if (!!editorname) this.getattachmenttextdata();
o2.defer(this.resetnodesize, 500, this);
}.bind(this) );
editor.on( 'insertelement', function( e ) {
if (e.data.$.tagname.tostring().tolowercase()=="table"){
e.data.$.setstyles({
"margin-left": "",
"margin-right": "",
"word-break": "break-all"
});
}
var tr = e.data.$.getelement("tr");
if (tr){
var tds = tr.getelements("td");
if (tds && tds.length){
var p = 100/tds.length;
tds.setstyle("width", "" p "%");
}
}
}.bind(this) );
if (this.json.textindent!=="n"){
(node || this.layout_filetext).addevent("keyup", function(ev){
if (ev.code==13) editor.inserttext(" ");
}.bind(this));
}
if (this.json.fullwidth!=="n"){
editor.addcommand( 'inserthalfspace', {
exec: function( editor ) {
editor.inserttext(" ");
}
} );
editor.setkeystroke( ckeditor.shift 32, 'inserthalfspace' );
editor.on("key", function(e){
if (this.json.fullwidth!=="n") if (e.data.keycode==32){
e.editor.inserttext(" ");
e.cancel();
}
}.bind(this));
}
}catch(e){
editor = this[(editorname || "filetexteditor")];
}
}.bind(this));
}
},
_loadevents: function(editorconfig){
object.each(this.json.events, function(e, key){
if (e.code){
this.editor.on(key, function(event){
return this.form.macro.fire(e.code, this, event);
}.bind(this), this);
}
}.bind(this));
},
_bindfieldchange: function(name,dataitem, dom){
var field = this.form.all[this.json[dataitem]];
if (field){
var bindfun = function(){
this._computeitemfielddata(name, dataitem);
//if (this.data[name]){
if (this[dom]){
if (dom=="layout_redheader" ||dom=="layout_issuanceunit" || dom=="layout_meetingattendcontent" || dom=="layout_meetingleavecontent" || dom=="layout_meetingsitcontent" || dom=="layout_meetingrecordcontent" || dom=="layout_signer") {
this[dom].set("html", this.filterhtml(this.data[name] || ""));
}else if (dom=="layout_subject"){
this[dom].set("html", (this.data[name] || ""));
}else if (dom=="layout_attachment"){
this.setattachmentdata();
}else if (dom=="layout_annotation"){
var annotation = this.data[name];
if (annotation){
if (annotation.substring(0, 1)!=="(") annotation = "(" annotation;
if (annotation.substring(annotation.length-1, annotation.length)!==")") annotation = annotation ")";
this[dom].set("text", annotation);
}else{
this[dom].set("text", "");
}
}else{
this[dom].set("text", this.data[name]|| "");
}
}
this.resetshow();
//}
}.bind(this);
field.node.store(this.json.id "bindfun", bindfun);
field.addmoduleevent("change", bindfun);
}
},
_computeitemfielddata: function(name, dataitem, dataitemnode){
var v = "";
var module = (dataitemnode) ? this.form.all[dataitemnode] : this.form.all[this.json[dataitem]];
if (module && module.getdata) v = module.getdata();
if (!v) v = (dataitemnode) ? this.form.businessdata.data[dataitemnode] : this.form.businessdata.data[this.json[dataitem]];
if (v){
var t = o2.typeof(v);
switch (t) {
case "string":
switch (name) {
case "issuancedate":
case "editiondate":
var d = new date(v);
if (d && d.isvalid() && d.getfullyear()!=1970){
var y = d.getfullyear();
var m = d.getmonth();
var day = d.getdate();
m = m 1;
var lp = mwf.xapplication.process.xform.lp;
this.data[name] = "" y lp.year m lp.month day lp.date;
}else{
this.data[name] = v;
}
//this.data[name] = (new date(v).isvalid()) ? date.parse(v).format("%y年%m月%d%日") : v;
break;
case "mainsend":
this.data[name] = v ":";
break;
case "copyto":
case "copyto2":
var flag = (v.substring(v.length-1, v.length)=="。");
this.data[name] = v ((flag) ? "" : "。");
break;
default:
if (name==="subject") v = o2.txt(v);
this.data[name] = v;
}
break;
case "array":
var strs = [];
var strlength = 0;
v.each(function(value){
if (o2.typeof(value)=="object" && value.distinguishedname){
if (value.name.length>strlength) strlength = value.name.length;
strs.push(value.name);
}else{
if (value.length>strlength) strlength = value.length;
strs.push(value.tostring());
}
});
//if (strs.length){
switch (name) {
case "attachment":
// this.data[name] = strs.map(function(n, i){ var j = i 1; return j "、" n}).join("
");
var atts = strs.map(function(a){
return (a.indexof(".")!=-1) ? a.substring(0, a.lastindexof(".")) : a;
});
this.data[name] = atts;
break;
case "issuancedate":
case "editiondate":
var tmpstrs = strs.map(function(n, i){
var d = date.parse(n);
if (d && d.isvalid() && d.getfullyear()!=1970){
var y = d.getfullyear();
var m = d.getmonth();
var day = d.getdate();
m = m 1;
var lp = mwf.xapplication.process.xform.lp;
return "" y lp.year m lp.month day lp.date;
}else{
return n;
}
//return () ? d.format("%y年%m月%d日") : n;
});
this.data[name] = tmpstrs.join(",");
break;
case "signer":
var signers = "";
strs.each(function(name, i){
while (name.length";
}
});
this.data[name] = signers;
break;
case "mainsend":
this.data[name] = strs.length ? strs.join(",") ":" : "";
break;
case "copyto":
case "copyto2":
this.data[name] = strs.length ? strs.join(",") "。" : "";
break;
default:
this.data[name] = strs.join(",");
}
//}
break;
default:
this.data[name] = v.tostring();
}
}else{
this.data[name] = this.json.defaultvalue[name];
}
},
computedata: function(){
this._computedata(false);
this.setdata(this.data);
},
_computeitemdata: function(name, typeitem, dataitem, scriptitem, ev, dom){
switch (this.json[typeitem]) {
case "data":
if (this.json[dataitem]){
if (ev) this._bindfieldchange(name, dataitem, dom);
this._computeitemfielddata(name, dataitem);
}
break;
case "script":
if (this.json[scriptitem] && this.json[scriptitem].code){
var v = this.form.macro.exec(this.json[scriptitem].code, this);
this.data[name] = v;
if (name=="attachment"){
//this.data[name] = (typeof(v)=="array") ? v.map(function(n, i){ var j = i 1; return j "、" n}).join("
") : v;
this.data[name] = (typeof(v)=="array") ? v : [v];
}
if (name=="signer"){
var strs = [];
var strlength = 0;
if (o2.typeof(v)!=="array") v = [v];
v.each(function(value){
if (o2.typeof(value)=="object" && value.distinguishedname){
if (value.name.length>strlength) strlength = value.name.length;
strs.push(value.name);
}else{
if (value.length>strlength) strlength = value.length;
strs.push(value.tostring());
}
});
var signers = "";
strs.each(function(name, i){
while (name.length";
}
});
this.data[name] = signers;
}
if (name=="issuancedate" || name=="editiondate"){
var d = date.parse(v);
if (d && d.isvalid() && d.getfullyear()!=1970){
var y = d.getfullyear();
var m = d.getmonth();
var day = d.getdate();
m = m 1;
var lp = mwf.xapplication.process.xform.lp;
this.data[name] = "" y lp.year m lp.month day lp.date;
}else{
this.data[name] = v;
}
//this.data[name] = (d.isvalid() && d.getfullyear()!=1970) ? d.format("%y年%m月%d日") : v;
}
}
break;
}
},
_computecustomitemdata: function(name, field, ev){
//if (this.json.customfields[l.name]){
if (ev) this._bindcustomfieldchange(name, field, name);
this._computeitemfielddata(name, null, field);
//}
},
_bindcustomfieldchange: function(name, dataitem, dom){
var field = this.form.all[dataitem];
if (field){
var bindfun = function(){
this._computeitemfielddata(name, null, dataitem);
//if (this.data[name]){
if (this[dom]){
var value = this.data[name] || "";
var reg = new regexp("\n","g");
var text = value.replace(reg,"
");
if (dom=="layout_redheader" || dom=="layout_issuanceunit") {
this[dom].set("html", this.data[name] || "");
}else if (dom=="layout_subject"){
this[dom].set("html", (this.data[name] || ""));
}else if (dom=="layout_attachment"){
this.setattachmentdata();
}else{
this[dom].set("html", text|| "");
}
}
this.resetshow();
//}
}.bind(this);
field.node.store(this.json.id "bindfun", bindfun);
field.addmoduleevent("change", bindfun);
}
},
_computedata: function(ev){
this._computeitemdata("copies", "copiesvaluetype", "copiesvaluedata", "copiesvaluescript", ev, "layout_copies");
this._computeitemdata("secret", "secretvaluetype", "secretvaluedata", "secretvaluescript", ev, "layout_secret");
this._computeitemdata("priority", "priorityvaluetype", "priorityvaluedata", "priorityvaluescript", ev, "layout_priority");
this._computeitemdata("redheader", "redheadervaluetype", "redheadervaluedata", "redheadervaluescript", ev, "layout_redheader");
this._computeitemdata("fileno", "filenovaluetype", "filenovaluedata", "filenovaluescript", ev, "layout_fileno");
this._computeitemdata("signer", "signervaluetype", "signervaluedata", "signervaluescript", ev, "layout_signer");
this._computeitemdata("subject", "subjectvaluetype", "subjectvaluedata", "subjectvaluescript", ev, "layout_subject");
this._computeitemdata("mainsend", "mainsendvaluetype", "mainsendvaluedata", "mainsendvaluescript", ev, "layout_mainsend");
this._computeitemdata("attachment", "attachmentvaluetype", "attachmentvaluedata", "attachmentvaluescript", ev, "layout_attachment");
this._computeitemdata("issuanceunit", "issuanceunitvaluetype", "issuanceunitvaluedata", "issuanceunitvaluescript", ev, "layout_issuanceunit");
this._computeitemdata("issuancedate", "issuancedatevaluetype", "issuancedatevaluedata", "issuancedatevaluescript", ev, "layout_issuancedate");
this._computeitemdata("annotation", "annotationvaluetype", "annotationvaluedata", "annotationvaluescript", ev, "layout_annotation");
this._computeitemdata("copyto", "copytovaluetype", "copytovaluedata", "copytovaluescript", ev, "layout_copytocontent");
this._computeitemdata("copyto2", "copyto2valuetype", "copyto2valuedata", "copyto2valuescript", ev, "layout_copyto2content");
this._computeitemdata("editionunit", "editionunitvaluetype", "editionunitvaluedata", "editionunitvaluescript", ev, "layout_edition_issuance_unit");
this._computeitemdata("editiondate", "editiondatevaluetype", "editiondatevaluedata", "editiondatevaluescript", ev, "layout_edition_issuance_date");
this._computeitemdata("meetingattend", "meetingattendvaluetype", "meetingattendvaluedata", "meetingattendvaluescript", ev, "layout_meetingattendcontent");
this._computeitemdata("meetingleave", "meetingleavevaluetype", "meetingleavevaluedata", "meetingleavevaluescript", ev, "layout_meetingleavecontent");
this._computeitemdata("meetingsit", "meetingsitvaluetype", "meetingsitvaluedata", "meetingsitvaluescript", ev, "layout_meetingsitcontent");
this._computeitemdata("meetingrecord", "meetingrecordvaluetype", "meetingrecordvaluedata", "meetingrecordvaluescript", ev, "layout_meetingrecordcontent");
object.each(this.json.customfields, function(field, k){
this._computecustomitemdata(k, field, ev);
}.bind(this));
// if (this.customlayouts){
// this.customlayouts.each(function(l){
// this._computecustomitemdata(l, ev);
// }.bind(this))
// }
},
_loadvalue: function(){
var data = this._getbusinessdata();
},
/**重新计算公文编辑器的所有字段,当字段是脚本时可以使用该方法立即更新
* @summary 重新计算公文编辑器的所有字段
* @example
* this.form.get("fieldid").reload();
*/
reload: function(callback){
this.resetdata(false, callback);
},
resetdata: function(difffiletext, callback){
this._computedata(false);
this.pages = [];
this.editmode = false;
this._createpage(function(control){
this._loadpagelayout(control);
this.setdata(this.data, difffiletext);
this._repage();
if (!this.editmode && this.allowedit && !this.historymode && this.options.pageshow!=="double") {
this._editfiletext("inline");
this.editmode = true;
}
if (callback) callback();
}.bind(this));
},
/**
* @summary 判断公文编辑器的正文内容是否已经填写
* @return {boolean} 是否为空
* @example
* if( this.form.get("fieldid").isempty() ){
* this.form.notice('请填写正文内容')
* }
*/
isempty: function(){
var data = this.getdata();
if( typeof(data) !== "object" )return true;
return !data.filetext || data.filetext===this.json.defaultvalue.filetext;
},
/**
* @summary 获取公文编辑器数据
* @return {object} 公文编辑器的数据
* @example
* var data = this.form.get("fieldid").getdata();
*/
getdata: function(){
//if (this.editmode){
if (this.layout_copies) this.data.copies = this.layout_copies.get("text");
if (this.layout_secret) this.data.secret = this.layout_secret.get("text");
if (this.layout_priority) this.data.priority = this.layout_priority.get("text");
if (this.layout_redheader) this.data.redheader = this.layout_redheader.get("html");
if (this.layout_fileno) this.data.fileno = this.layout_fileno.get("text");
if (this.layout_signertitle) this.data.signertitle = this.layout_signertitle.get("text");
if (this.layout_signer) this.data.signer = this.layout_signer.get("html");
if (this.layout_subject) this.data.subject = this.layout_subject.get("html");
if (this.layout_mainsend) this.data.mainsend = this.layout_mainsend.get("text");
if (this.editmode) {
if (this.layout_filetext){
var text = this.layout_filetext.get("text");
text = text.replace(/\u3000*/g, "");
if (text && text !==this.json.defaultvalue.filetext){
this.data.filetext = this.layout_filetext.get("html");
}else{
this.data.filetext = "";
}
}
}
this.getattachmenttextdata();
if (this.layout_signer) this.data.signer = this.layout_signer.get("html");
if (this.layout_attachmenttitle) this.data.attachmenttitle = this.layout_attachmenttitle.get("text");
if (this.layout_attachment){
this._computeitemdata("attachment", "attachmentvaluetype", "attachmentvaluedata", "attachmentvaluescript", false, "layout_attachment");
// var atts = [];
// var nodes = this.layout_attachment.getelements(".doc_layout_attachment_content_name");
// if (nodes.length){
// nodes.each(function(node){
// atts.push(node.get("text"));
// });
// }
// this.data.attachment = atts;
}
if (this.layout_issuanceunit) this.data.issuanceunit = this.layout_issuanceunit.get("html");
if (this.layout_issuancedate) this.data.issuancedate = this.layout_issuancedate.get("text");
if (this.layout_annotation){
var annotation = this.layout_annotation.get("text");
if (annotation.substring(0,1)=="(") annotation = annotation.substring(1, annotation.length);
if (annotation.substring(annotation.length-1, annotation.length)==")") annotation = annotation.substring(0, annotation.length-1);
this.data.annotation = annotation;
}
if (this.layout_copytotitle) this.data.copytotitle = this.layout_copytotitle.get("text");
if (this.layout_copytocontent) this.data.copyto = this.layout_copytocontent.get("text");
if (this.layout_copyto2title) this.data.copyto2title = this.layout_copyto2title.get("text");
if (this.layout_copyto2content) this.data.copyto2 = this.layout_copyto2content.get("text");
if (this.layout_edition_issuance_unit) this.data.editionunit = this.layout_edition_issuance_unit.get("text");
if (this.layout_edition_issuance_date) this.data.editiondate = this.layout_edition_issuance_date.get("text");
if (this.layout_meetingattendtitle) this.data.meetingattendtitle = this.layout_meetingattendtitle.get("text");
if (this.layout_meetingleavetitle) this.data.meetingleavetitle = this.layout_meetingleavetitle.get("text");
if (this.layout_meetingsittitle) this.data.meetingsittitle = this.layout_meetingsittitle.get("text");
if (this.layout_meetingattendcontent) this.data.meetingattend = this.layout_meetingattendcontent.get("html");
if (this.layout_meetingleavecontent) this.data.meetingleave = this.layout_meetingleavecontent.get("html");
if (this.layout_meetingsitcontent) this.data.meetingsit = this.layout_meetingsitcontent.get("html");
if (this.layout_meetingrecordcontent) this.data.meetingrecord = this.layout_meetingrecordcontent.get("html");
this.getsealdata();
if (this.customlayouts){
this.customlayouts.each(function(l){
this.data[l.name] = l.node.get("html");
}.bind(this))
}
//}
return this.data;
},
getattachmenttextdata: function(){
if (this.layout_attachmenttext && this.layout_attachmenttext.get("contenteditable")=="true"){
var text = this.layout_attachmenttext.get("text");
text = text.replace(/\u3000*/g, "");
if (text && text !==mwf.xapplication.process.xform.lp.documenteditor.attachmentinfor){
this.data.attachmenttext = this.layout_attachmenttext.get("html");
}else{
this.data.attachmenttext = "";
}
}
},
getsealdata: function(){
if (this.layout_seals && this.layout_seals.length) {
this.data.seals = [];
this.layout_seals.each(function(seal){
this.data.seals.push(seal.get("src"));
}.bind(this));
}
},
setattachmentdata: function(){
if (!this.attachmenttemplete){
this.attachmenttemplete = this.layout_attachment.get("html");
}
this.layout_attachment.empty();
if (this.data.attachment && !this.data.attachment.each){
this.data.attachment = this.data.attachment.split(/,\s*/g);
}
if (this.data.attachment && this.data.attachment.length && this.data.attachment.each){
//var tmpdiv = new element("div", {"styles": {"display":"none"}}).inject(document.body);
var tmpdiv = new element("div");
this.data.attachment.each(function(name, idx){
tmpdiv.set("html", this.attachmenttemplete);
var serialnode = tmpdiv.getelement(".doc_layout_attachment_content_serial");
var namenode = tmpdiv.getelement(".doc_layout_attachment_content_name");
if (this.data.attachment.length>1){
if (serialnode){
serialnode.set("text", idx 1);
serialnode.getnext().set("text", ".");
}
}else{
if (serialnode){
serialnode.set("text", "");
serialnode.getnext().set("text", "");
}
}
if (namenode) namenode.set("text", name);
var html = tmpdiv.get("html");
tmpdiv.empty();
this.layout_attachment.appendhtml(html);
}.bind(this));
tmpdiv.destroy();
}
},
setattachmenttext: function(data){
this.layout_attachmenttext.empty();
if (data.attachmenttext){
this.layout_attachmenttext.set("html", data.attachmenttext);
}else{
if (this._getedit("attachmenttext", "attachmenttextedit", "attachmenttexteditscript")){
this.layout_attachmenttext.set("text", mwf.xapplication.process.xform.lp.documenteditor.attachmentinfor);
}
}
},
filterhtml: function(html){
var content = html.replace(/(?: