");
//ds = ds.replace(/\n+/g, "
");
this.documentEditor.layout_filetext.set("html", ds);
var node = this.documentEditor.layout_filetext.querySelector('ins,del');
if (node){
node.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"});
}
}else{
this.documentEditor.layout_filetext.set("html",this.historyData.json.data);
}
}.bind(this));
},
diffCurrent: function(){
if (this.history.documentHistoryItems && this.history.documentHistoryItems.length){
this.history.documentHistoryItems.each(function(item){
if (item.histroyObj) item.histroyObj.hideCurrent();
});
}
this.histroyObj.showCurrent();
this.launch();
},
createTitleNode: function(){
this.node = new Element("div", {"styles": this.css.historyListItemNode}).inject(this.history.historyListContentAreaNode);
if (this.historyData.json.v && this.historyData.json.v=="6"){
if (this.history.documentHistoryItems && this.history.documentHistoryItems.length){
this.actionNode = new Element("div", {"styles": this.css.historyListItemActionNode, "text": MWF.xApplication.process.Xform.LP.documentHistory.diff, "title": MWF.xApplication.process.Xform.LP.documentHistory.diffTitle}).inject(this.node);
this.actionNode.addEvent("click", function(e){
this.diffCurrent();
}.bind(this));
}
}
var obj = this.historyData;
var patchHtml = "";
if (this.historyData.json.data){
var d = this.documentEditor.getFiletextText(this.historyData.json.data);
var s = d.length+" "+MWF.xApplication.process.Xform.LP.documentHistory.word;
patchHtml = ""+o2.name.cn(obj.person)+" ["+obj.activityName+"] ("+s+")
"+obj.createTime+"
"
}else{
patchHtml = ""+o2.name.cn(obj.person)+" ["+obj.activityName+"]
"+obj.createTime+"
"
}
this.patchNode = new Element("div", {"styles": this.css.historyListItemPatchNode, "html": patchHtml}).inject(this.node);
this.diffsNode = new Element("div", {"styles": this.css.historyListItemDiffsNode}).inject(this.node);
},
createDataNode:function(){
var infor = MWF.xApplication.process.Xform.LP.documentHistory.original;
var histroyObj = {
"node": this.node,
"showCurrent": function(){
this.node.setStyles({"background-color": "#e2edfb"});
//if (show) this.node.scrollIn();
},
"hideCurrent": function(){
this.node.setStyles(_self.css.historyListItemDiffNode);
}
};
var _self = this;
this.histroyObj = histroyObj;
this.node.addEvents({
"click": function(){
// if (_self.history.stop){
// _self.history.origina(_self.historyData.json.data, histroyObj);
// }
_self.diffCurrent();
}
});
},
createPatchNode: function(patch){
var _self = this;
patch.diffs.each(function(diff){
if (diff[0]!=0){
diff["id"] = (new o2.widget.UUID()).toString();
var tmp = new Element("div", {"html": diff[1]});
infor = tmp.get("text");
var infor = ((infor.length>50) ? infor.substring(0, 50)+"..." : infor);
tmp.destroy();
if (diff[0]==-1){
infor = MWF.xApplication.process.Xform.LP.documentHistory.delete +": "+""+infor+""
}else{
infor = MWF.xApplication.process.Xform.LP.documentHistory.insert +": "+""+infor+""
}
diffNode = new Element("div", {"styles": this.css.historyListItemDiffNode, "html": infor}).inject(this.diffsNode);
diffNode.store("diff", diff);
diff["item"] = {
"node": diffNode,
"showCurrent": function(show){
var thisDiff = this.node.retrieve("diff");
var color = (thisDiff[0]==-1) ? "#fbe0e7": "#e2edfb";
this.node.setStyles({"background-color": color});
var ss = _self.history.historyListContentAreaNode.getScrollSize();
var s = _self.history.historyListContentAreaNode.getSize();
if (ss.y>s.y) if (show) this.node.scrollIn();
},
"hideCurrent": function(){
this.node.setStyles(_self.css.historyListItemDiffNode);
}
};
}
}.bind(this));
},
load: function(){
this.createTitleNode();
var patchs = this.historyData.json.patchObj || null;
if (this.historyData.json.v && this.historyData.json.v=="6"){
if (this.historyData.json.data) this.createDataNode();
if (patchs){
patchs.each(function(patch){
this.createPatchNode(patch);
}.bind(this));
}else{
new Element("div", {"styles": this.css.historyListItemDiffNode, "text": MWF.xApplication.process.Xform.LP.documentHistory.original}).inject(this.diffsNode);
}
}else{
var _self = this;
if (patchs){
patchs.each(function(patch){
patch.diffs.each(function(diff){
if (diff[0]!=0){
diff["id"] = (new o2.widget.UUID()).toString();
var tmp = new Element("div", {"html": diff[1]});
infor = tmp.get("text");
var infor = ((infor.length>50) ? infor.substring(0, 50)+"..." : infor);
tmp.destroy();
if (diff[0]==-1){
infor = MWF.xApplication.process.Xform.LP.documentHistory.delete +": "+""+infor+""
}else{
infor = MWF.xApplication.process.Xform.LP.documentHistory.insert +": "+""+infor+""
}
diffNode = new Element("div", {"styles": this.css.historyListItemDiffNode, "html": infor}).inject(this.diffsNode);
diffNode.store("diff", diff);
diff["item"] = {
"node": diffNode,
"showCurrent": function(show){
var thisDiff = this.node.retrieve("diff");
var color = (thisDiff[0]==-1) ? "#fbe0e7": "#e2edfb";
this.node.setStyles({"background-color": color});
var ss = _self.history.historyListContentAreaNode.getScrollSize();
var s = _self.history.historyListContentAreaNode.getSize();
if (ss.y>s.y) if (show) this.node.scrollIn();
},
"hideCurrent": function(){
this.node.setStyles(_self.css.historyListItemDiffNode);
}
};
diffNode.addEvents({
"click": function(){
if (_self.history.stop){
var diff = this.retrieve("diff");
_self.history.to(diff);
}
}
});
}
}.bind(this));
}.bind(this));
}else{
infor = MWF.xApplication.process.Xform.LP.documentHistory.original;
diffNode = new Element("div", {"styles": this.css.historyListItemDiffNode, "html": infor}).inject(this.diffsNode);
this.history.originaDiff = {
"node": diffNode,
"showCurrent": function(){
this.node.setStyles({"background-color": "#e2edfb"});
},
"hideCurrent": function(){
this.node.setStyles(_self.css.historyListItemDiffNode);
}
};
diffNode.addEvents({
"click": function(){
if (_self.history.stop){
_self.history.origina();
}
}
});
}
}
}
})