MWF.xApplication.process.Xform.widget = MWF.xApplication.process.Xform.widget || {}; MWF.xApplication.process.Xform.widget.DocumentHistory = new Class({ Implements: [Options, Events], options: { "speed": 1, "fxTime": 500, "inforTime": 2000 }, initialize: function(documentEditor, options){ this.setOptions(options); this.documentEditor = documentEditor; this.css = this.documentEditor.css; }, is_iPad: function(){ var ua = navigator.userAgent.toLowerCase(); return (ua.match(/iPad/i)=="ipad"); }, load: function(callback, nodiff){ this.getHistroyDocumentList(function(){ if (this.historyDocumentList && this.historyDocumentList.length){ this.getHistoryDataList(function(){ this.createHistoryToolbar(); if (!layout.mobile || this.is_iPad()) this.createHistoryListNode(); this.documentEditor.options.pageShow = "single"; this.beginDiffHistory(); this.loadHistoryToolbar(); if (!layout.mobile) this.loadHistoryList(); this.documentEditor.resetData(false, function(){ this.documentEditor._readFiletext(); if (callback) callback(); }.bind(this)); }.bind(this)); }else{ this.documentEditor.form.app.notice(MWF.xApplication.process.Xform.LP.documentHistory.nodiff, "info", this.documentEditor.node); if (nodiff) nodiff(); } }.bind(this)); }, createHistoryToolbar: function(){ this.documentEditor.documentToolbarNode = this.documentEditor.toolbarNode; this.toolbarNode = this.documentEditor.toolbarNode.clone(true); this.toolbarNode.inject(this.documentEditor.toolbarNode, "after"); this.documentEditor.toolbarNode = this.toolbarNode; this.documentEditor.documentToolbarNode.hide(); this.toolbarNode.empty(); if (this.documentEditor.sidebarNode) this.documentEditor.sidebarNode.hide(); }, loadHistoryToolbar: function(){ debugger; var html = ""; if (this.historyDataList && this.historyDataList.length && this.historyDataList[0].json.v!="6"){ html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; } html += ""; html += ""; var text = MWF.xApplication.process.Xform.LP.documentHistory.diff_patch_count; text = text.replace(/{history}/, this.historyDataList.length).replace(/{diff}/, this.diffCount); html += ""+text+""; 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(); this.checkToolbar(); }.bind(this)); this.toolbarNode.setStyle("overflow", "visible"); if (this.historyListAreaNode) this.historyListAreaNode.inject(this.toolbarNode); }, checkToolbar: function(){ if (this.historyDataList && this.historyDataList.length && this.historyDataList[0].json.v!="6"){ if (this.toolbar){ if (this.playing){ if (this.stop){ this.toolbar.childrenButton[0].enable(); this.toolbar.childrenButton[1].disable(); if (this.patchIndex==0 && this.diffIndex==0){ this.toolbar.childrenButton[3].disable(); if (this.diffPatch.length) this.toolbar.childrenButton[4].enable(); }else{ if (this.patchIndex"); ds = ds.replace(/(?)(?:¶)/g, ''); ds = ds.replace(/(\n\t\t\t)+/g, " | ") .replace(/(\n\t\t)+/g,"\n") .replace(/(\n\t)+/g,"\n") .replace(/\n+/g,"
") .replace(/\t+/g,""); //ds = ds.replace(/(\n\t)+/g,""); //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"}); } var node = this.documentEditor.layout_filetext.querySelector('ins,del'); if (node){ node.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"}); } }.bind(this)); }.bind(this)); }, createHistoryListItem: function(historyData){ if (!this.documentHistoryItems) this.documentHistoryItems = []; this.documentHistoryItems.push(new MWF.xApplication.process.Xform.widget.DocumentHistory.Item(this, historyData)); }, getHistoryDataList: function(callback){ // if (this.historyDataList && this.historyDataList.length){ // this.getHistoryDataListFinish(this.historyDataList); // if (callback) callback(); // }else{ var historyDataList = []; var getDataCount = 0; var idx = 0; var checkBeginDiffHistory = function(){ if (getDataCount>=this.historyDocumentList.length){ this.getHistoryDataListFinish(historyDataList, callback); } }.bind(this); for (var i=this.historyDocumentList.length-1; i>=0; i--){ historyDataList.push(null); this.getHistroyDocumentData(this.historyDocumentList[i].id, function(){ getDataCount++; checkBeginDiffHistory(); }.bind(this), idx, historyDataList); idx++; } //} }, getHistoryDataListFinish: function(historyDataList, callback){ this.historyDataList = historyDataList; this.originaHistoryData = historyDataList[0].json.data || null; if (this.documentEditor.allowEdit){ o2.load("../o2_lib/diff-match-patch/diff_match_patch_uncompressed.js", function(){ var originaData = this.documentEditor.form.businessData.originalData[this.documentEditor.json.id]; //var data = this.documentEditor.getFiletextText(this.documentEditor.data.filetext); var data = this.documentEditor.data.filetext.replace(/
<\/div>/g, ''); var earlyData = originaData.filetext.replace(/
<\/div>/g, ''); // var data = this.documentEditor.data.filetext; // var earlyData = originaData.filetext; if (data!=earlyData){ dataTxt = this.documentEditor.getFiletextText(data); earlyDataTxt = this.documentEditor.getFiletextText(earlyData); var dmp = new diff_match_patch(); var diff_d = dmp.diff_main(earlyDataTxt, dataTxt); dmp.diff_cleanupSemantic(diff_d); var patch_list = dmp.patch_make(earlyDataTxt, dataTxt, diff_d); if (patch_list.length){ var patch = dmp.patch_toText(patch_list); var patchData = JSON.stringify({"patchs": patch, "v": "6"}); var currentData = { "data": patchData, "json": {"patchs": patch, "data": data, "current": true, "v": "6"}, "person": layout.session.user.distinguishedName, "activityName": this.documentEditor.form.businessData.activity.name, "createTime" : (new Date()).format("db") }; this.historyDataList.push(currentData); } } if (callback) callback(); }.bind(this)); }else{ if (callback) callback(); } }, getHistroyDocumentData: function(id, callback, i, historyDataList){ o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.get(id, function(json){ var obj = JSON.parse(json.data.data); json.data.json = obj; if (historyDataList) historyDataList[i] = json.data; if (callback) callback(json.data); }.bind(this)); }, getHistroyDocumentList: function(callback){ //if (!this.historyDocumentList){ var id = this.documentEditor.form.businessData.work.job; o2.Actions.load("x_processplatform_assemble_surface").DocumentVersionAction.listWithJobCategory(id, this.documentEditor.json.id, function(json){ this.historyDocumentList = json.data; if (callback) callback(); }.bind(this)); //}else{ // if (callback) callback(); //} }, beginDiffHistory: function(){ //o2.load("../o2_lib/diff-match-patch/diff_match_patch_uncompressed.js", function(){ this.initAnimation(); //if (callback) callback(); //}.bind(this)); }, initAnimation: function(){ this.diffPatch = this.diffHistroy(); this.diffCount = 0; this.diffInsertCount = 0; this.diffDeleteCount = 0; this.diffPatch.each(function(patch){ patch.patch.diffs.each(function(diff){ if (diff[0]!=0) this.diffCount++; if (diff[0]==-1) this.diffDeleteCount++; if (diff[0]==1) this.diffInsertCount++; }.bind(this)); }.bind(this)); // this.initData(); this.initAnimationStatus(); }, initData: function(data, diffObj){ this.currentHistoryData = data || this.originaHistoryData; this.documentEditor.layout_filetext.set("html", this.currentHistoryData); this.patchIndex = 0; this.diffIndex = 0; if (this.documentHistoryItems && this.documentHistoryItems.length){ this.documentHistoryItems.each(function(item){ if (item.histroyObj) item.histroyObj.hideCurrent(); }); } if (diffObj || this.originaDiff) (diffObj || this.originaDiff).showCurrent(); }, initAnimationStatus: function(){ this.patchIndex = 0; this.diffIndex = 0; this.currentDiffs = null; this.stop = true; this.step = false; this.playing = false; this.reverse = false; this.options.fxTime = 500; this.options.inforTime = 2000; this.checkToolbar(); }, doAnimationAuto: function(){ this.playing = true; this.checkToolbar(); this.doPatchAnimation(function(){ this.patchIndex = 0; this.diffIndex = 0; this.playing = false; this.stop = true; this.documentEditor.resetData(); this.checkToolbar(); }.bind(this)); }, do: function(){ if (this.nextPlayPrefixFunction){ this.nextPlayPrefixFunction(); this.nextPlayPrefixFunction = null; }else{ this.doAnimationAuto(); } }, play: function(){ if (!this.playing){ this.initData(); this.initAnimationStatus(); } this.reverse = false; this.stop = false; this.stopWhile = ""; this.options.fxTime = 500; this.options.inforTime = 2000; this.toolbar.childrenButton[0].disable(); this.toolbar.childrenButton[3].disable(); this.toolbar.childrenButton[4].disable(); this.do(); }, stopPlay: function(){ if (this.playing){ this.stop = true; this.playing = false; if (this.nextPlayPrefixFunction){ this.nextPlayPrefixFunction(); this.nextPlayPrefixFunction = null; } this.patchIndex = 0; this.diffIndex = 0; this.toolbar.childrenButton[1].disable(); this.toolbar.childrenButton[2].disable(); } }, pause: function(){ if (this.playing){ this.stop = true; this.toolbar.childrenButton[1].disable(); this.toolbar.childrenButton[2].disable(); } }, next: function(){ this.reverse = false; this.options.fxTime = 0; this.options.inforTime = 0; this.stop = true; this.toolbar.childrenButton[3].disable(); this.toolbar.childrenButton[4].disable(); if (!this.playing) this.initData(); this.do(); }, prev: function(){ this.reverse = true; this.options.fxTime = 0; this.options.inforTime = 0; this.stop = true; this.toolbar.childrenButton[3].disable(); this.toolbar.childrenButton[4].disable(); if (!this.playing) this.initData(); this.do(); }, to: function(diff){ if (this.nextPlayPrefixFunction){ this.playing = false; this.nextPlayPrefixFunction(function(){ this.initData(); this.initAnimationStatus(); this.reverse = false; this.options.fxTime = 0; this.options.inforTime = 0; this.stop = false; this.stopWhile = diff.id; // this.toolbar.childrenButton[3].disable(); // this.toolbar.childrenButton[4].disable(); this.doAnimationAuto(diff.id); }.bind(this)); //this.nextPlayPrefixFunction = null; }else{ this.initData(); this.initAnimationStatus(); this.reverse = false; this.options.fxTime = 0; this.options.inforTime = 0; this.stop = false; this.stopWhile = diff.id; // this.toolbar.childrenButton[3].disable(); // this.toolbar.childrenButton[4].disable(); this.doAnimationAuto(diff.id); } }, origina: function(data, diffObj){ if (this.nextPlayPrefixFunction){ this.playing = false; this.nextPlayPrefixFunction(function(){ this.initData(data, diffObj); this.initAnimationStatus(); }.bind(this)); this.nextPlayPrefixFunction = null; }else{ this.initData(data, diffObj); this.initAnimationStatus(); } }, exit: function(){ this.initAnimationStatus(); this.options.fxTime = 0; this.options.inforTime = 0; if (this.nextPlayPrefixFunction){ this.nextPlayPrefixFunction(function(){ this.documentEditor.toolbarNode = this.documentEditor.documentToolbarNode; this.documentEditor.toolbarNode.show(); if (this.documentEditor.sidebarNode) this.documentEditor.sidebarNode.show(); this.documentEditor.resizeToolbar(); }.bind(this)); this.nextPlayPrefixFunction = null; }else{ this.documentEditor.toolbarNode = this.documentEditor.documentToolbarNode; this.documentEditor.toolbarNode.show(); if (this.documentEditor.sidebarNode) this.documentEditor.sidebarNode.show(); this.documentEditor.resizeToolbar(); } if (this.historyListAreaNode) this.historyListAreaNode.destroy(); this.documentHistoryItems = []; this.historyListAreaNode = null; this.documentEditor.zoom(1); this.documentEditor._checkScale(); this.documentEditor.historyMode = false; this.documentEditor.resetData(); this.toolbarNode.hide(); this.documentEditor._returnScreen(); }, active: function(callback, nodiff){ this.getHistroyDocumentList(function(){ if (this.historyDocumentList && this.historyDocumentList.length){ this.getHistoryDataList(function(){ this.documentEditor.options.pageShow = "single"; this.documentEditor.resetData(); this.beginDiffHistory(); this.documentEditor.resetData(); this.toolbarNode.show(); this.documentEditor.documentToolbarNode = this.documentEditor.toolbarNode; this.documentEditor.documentToolbarNode.hide(); if (this.documentEditor.sidebarNode) this.documentEditor.sidebarNode.hide(); this.documentEditor.toolbarNode = this.toolbarNode; this.documentEditor.resizeToolbar(); var text = MWF.xApplication.process.Xform.LP.documentHistory.diff_patch_count; text = text.replace(/{history}/, this.historyDataList.length).replace(/{diff}/, this.diffCount); this.toolbarNode.getLast().set("html", text); if (!layout.mobile || this.is_iPad()) { this.createHistoryListNode(); if (this.toolbarNode){ this.toolbarNode.setStyle("overflow", "visible"); if (this.historyListAreaNode) this.historyListAreaNode.inject(this.toolbarNode); } this.loadHistoryList(); } this.documentEditor.options.pageShow = "single"; this.documentEditor.resetData(false, function (){ this.documentEditor._readFiletext(); }.bind(this)); if (callback) callback(); }.bind(this)); }else{ this.documentEditor.form.app.notice(MWF.xApplication.process.Xform.LP.documentHistory.nodiff, "info", this.documentEditor.node); if (nodiff) nodiff(); } }.bind(this)); }, diffHistroy: function(){ var diffPatch = []; //var historyPatchs = []; for (var i=1; i=0){ this.currentHistoryData = this.documentEditor.layout_filetext.get("html"); this.doPatchAnimation(callback); }else{ if (callback) callback(); } }else{ this.patchIndex++; if (this.patchIndexthis.diffPatch.length || this.patchIndex<0){ this.initAnimationStatus(); this.documentEditor.resetData(); this.checkToolbar(); }else{ var patchObj = this.diffPatch[this.patchIndex]; var patch = patchObj.patch; var obj = patchObj.obj; this.currentDiffs = patch.diffs; this.diffIndex = 0; this.doDiffsAnimation(obj, patch.start1); this.patchIndex = this.patchIndex+i; } }, createDiifInforNode: function(obj, node, color, insertInfor){ if (this.historyInforDiv){ this.historyInforDiv.dispose(); this.historyInforDiv = null; } var styles = (!layout.mobile) ? this.css.historyInforNode : this.css.historyInforMobileNode var insertInforDiv = new Element("div", { "styles": styles }).inject(this.documentEditor.node); insertInforDiv.setStyle("background", color); insertInfor = insertInfor.replace(/{name}/, o2.name.cn(obj.person)) .replace(/{activity}/, obj.activityName) .replace(/{time}/, obj.createTime); insertInforDiv.set("html", insertInfor); if (!layout.mobile){ insertInforDiv.position({ "relativeTo": node, "position": 'upperCenter', "edge": 'bottomCenter', "offset": { "x": 0, "y": -10 } }); }else{ } // debugger; // var p = node.getPosition(node.getOffsetParent()); // if (p.x<0) p.x=0; // var y = (p.y-10-insertInforDiv.getSize().y); // var x = p.x; // alert(x) // var scale = (this.documentEditor.scale<0.7) ? 0.7 : this.documentEditor.scale; // insertInforDiv.setStyles({ // "left": ""+x+"px", // "top": ""+y+"px", // "transform":"scale("+scale+")", // "transform-origin": "0px 0px", // }); this.historyInforDiv = insertInforDiv; return insertInforDiv; }, doDiffsAnimation: function(obj, start, callback){ var diff = this.currentDiffs[this.diffIndex]; var filetextNode = this.documentEditor.layout_filetext; switch (diff[0]) { case DIFF_INSERT: if (diff["item"]) diff["item"].showCurrent((!this.stopWhile || this.stopWhile == diff["id"])); if (this.originaDiff) this.originaDiff.hideCurrent(); var text = diff[1]; if (this.reverse){ start -= text.length; var left = this.currentHistoryData.substring(0, start); var middle = this.currentHistoryData.substring(start, start+diff[1].length); var right = this.currentHistoryData.substring(start+diff[1].length); filetextNode.set("html", left+""+right); }else{ var left = this.currentHistoryData.substring(0, start); var right = this.currentHistoryData.substring(start); filetextNode.set("html", left+""+right); } var ins = filetextNode.getElement("ins"); if (!this.stopWhile || this.stopWhile == diff["id"]) ins.scrollIn(); this.doInsetAnimation(ins, [1], function(invisible){ var insertInforDiv = null; if (!invisible && (!this.stopWhile || this.stopWhile == diff["id"]) ){ insertInforDiv = this.createDiifInforNode(obj, ins, "#e2edfb", MWF.xApplication.process.Xform.LP.documentHistory.insertContent); } window.setTimeout(function(){ var endFunction = function(cb){ if (insertInforDiv) insertInforDiv.fade("out"); var fx = new Fx.Tween(ins, {property: 'opacity', duration:this.options.speed*this.options.fxTime}); fx.start(1.1).chain(function(){ if (insertInforDiv) insertInforDiv.destroy(); if (diff["item"]) diff["item"].hideCurrent(); if (this.reverse){ ins.destroy(); this.currentHistoryData = filetextNode.get("html"); }else{ data = filetextNode.get("html"); this.currentHistoryData = data.replace(//m, text); filetextNode.set("html", this.currentHistoryData); } if (this.playing){ if (this.reverse){ this.diffIndex--; if (this.diffIndex>=0){ window.setTimeout(function(){this.doDiffsAnimation(obj, start, function(){ if (callback) callback(); if (cb) cb(); });}.bind(this), this.options.speed*this.options.fxTime); //this.doDiffsAnimation(obj, start, callback); }else{ if (callback) callback(); } }else{ start += text.length; this.diffIndex++; if (this.diffIndex"+text+""+right); start -= text.length; }else{ var left = this.currentHistoryData.substring(0, start); var middle = this.currentHistoryData.substring(start, start+diff[1].length); var right = this.currentHistoryData.substring(start+diff[1].length); //start -= .length; filetextNode.set("html", left+""+middle+""+right); } var del = filetextNode.getElement("del"); if (!this.stopWhile || this.stopWhile == diff["id"]) del.scrollIn(); this.doDeleteAnimation(del, diff, obj, function(deleteInforDiv){ // var deleteInforDiv = null; // if (!invisible){ // deleteInforDiv = this.createDiifInforNode(obj, del, "#fbe0e7", MWF.xApplication.process.Xform.LP.documentHistory.deleteContent); // } var invisible = !deleteInforDiv; window.setTimeout(function(){ var endFunction = function(cb){ if (deleteInforDiv) deleteInforDiv.fade("out"); var fx = new Fx.Tween(del, {property: 'opacity', duration:this.options.speed*this.options.fxTime}); fx.start(0.5,0).chain(function(){ if (deleteInforDiv) deleteInforDiv.destroy(); if (diff["item"]) diff["item"].hideCurrent(); if (this.reverse){ data = filetextNode.get("html"); this.currentHistoryData = data.replace(//m, text); filetextNode.set("html", this.currentHistoryData); }else{ del.destroy(); this.currentHistoryData = filetextNode.get("html"); } if (this.playing){ if (this.reverse){ this.diffIndex--; if (this.diffIndex>=0){ window.setTimeout(function(){this.doDiffsAnimation(obj, start, function(){ if (callback) callback(); if (cb) cb(); });}.bind(this), this.options.speed*this.options.fxTime); }else{ if (callback) callback(); } }else{ this.diffIndex++; if (this.diffIndex=0){ this.doDiffsAnimation(obj, start, callback); }else{ if (callback) callback(); } }else{ start += diff[1].length; this.diffIndex++; if (this.diffIndex=0){ var text2 = this.documentEditor.getFiletextText(this.history.documentHistoryItems[i].historyData.json.data); // dmp.Diff_Timeout = parseFloat(document.getElementById('timeout').value); // dmp.Diff_EditCost = parseFloat(document.getElementById('editcost').value); var d = dmp.diff_main(text2, text1); dmp.diff_cleanupSemantic(d); var ds = dmp.diff_prettyHtml(d); //ds = ds.replace(/[\n\r]+/g, "
"); ds = ds.replace(/(?)(?:¶)/g, ''); ds = ds.replace(/(\n\t\t\t)+/g, " | ") .replace(/(\n\t\t)+/g,"\n") .replace(/(\n\t)+/g,"\n") .replace(/\n+/g,"
") .replace(/\t+/g,""); //ds = ds.replace(/(\n\t)+/g,"
"); //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(); } } }); } } } })