| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641 | 
							
- function GooFlow (bgDiv, property) {
 
-   if (navigator.userAgent.indexOf('MSIE 8.0') > 0 || navigator.userAgent.indexOf('MSIE 7.0') > 0 || navigator.userAgent.indexOf('MSIE 6.0') > 0) {
 
-     GooFlow.prototype.useSVG = '';
 
-   } else GooFlow.prototype.useSVG = '1';
 
-   
 
-   this.$id = bgDiv.attr('id');
 
-   this.$bgDiv = bgDiv; 
 
-   this.$bgDiv.addClass('GooFlow');
 
-   if (GooFlow.prototype.color.font) {
 
-     this.$bgDiv.css('color', GooFlow.prototype.color.font);
 
-   }
 
-   if (GooFlow.prototype.color.main) {
 
-     this.$bgDiv.append('<style>.GooFlow_tool_btndown{background:' + GooFlow.prototype.color.main + '}</style>');
 
-   }
 
-   var width = (property.width || 800);
 
-   var height = (property.height || 500);
 
-   this.$bgDiv.css({
 
-     width: width + 'px',
 
-     height: height + 'px'
 
-   });
 
-   this.$tool = null; 
 
-   this.$head = null; 
 
-   this.$title = 'newFlow_1'; 
 
-   this.$id = '';
 
-   this.$nodeRemark = {}; 
 
-   this.$nowType = 'cursor'; 
 
-   this.$lineData = {};
 
-   this.$lineCount = 0;
 
-   this.$nodeData = {};
 
-   this.$nodeCount = 0;
 
-   this.$areaData = {};
 
-   this.$areaCount = 0;
 
-   this.$lineDom = {};
 
-   this.$nodeDom = {};
 
-   this.$areaDom = {};
 
-   this.$max = property.initNum || 1; 
 
-   this.$focus = ''; 
 
-   this.$cursor = 'default'; 
 
-   this.$editable = false; 
 
-   this.$deletedItem = {}; 
 
-   this.$workExtendStep = 200; 
 
-   this.$setName = function (id, name, type) {
 
-     if (type == 'node') { 
 
-       this.$nodeData[id].name = name;
 
-         this.$nodeDom[id].children('.span').text(name);
 
-         this.$nodeDom[id].find('td:eq(1)').text(name);
 
-     } else if (type == 'line') { 
 
-         this.$lineDom[id].childNodes[2].textContent = name;
 
-         this.$lineDom[id].childNodes[1].innerHTML = name;
 
-     }
 
-   };
 
-   var headHeight = 0;
 
-   var tmp = '';
 
-   if (property.haveHead) {
 
-     tmp = "<div class='GooFlow_head' " + (GooFlow.prototype.color.main ? "style='border-bottom-color:" + GooFlow.prototype.color.main + "'" : '') +
 
-       '>';
 
-     if (property.headLabel) {
 
-       tmp += "<label title='" + (property.initLabelText || 'newFlow_1') + "' " +
 
-         (GooFlow.prototype.color.main ? "style='background:" + GooFlow.prototype.color.main + "'" : '') + '>' + (property.initLabelText || 'newFlow_1') + '</label>';
 
-     }
 
-     for (var x = 0; x < property.headBtns.length; ++x) {
 
-       tmp += "<a href='javascript:void(0)' class='GooFlow_head_btn'><i class='ico_" + property.headBtns[x] + "'></i></a>"
 
-     }
 
-     tmp += '</div>';
 
-     this.$head = $(tmp);
 
-     this.$bgDiv.append(this.$head);
 
-     headHeight = 28;
 
-     
 
-     this.onBtnNewClick = null; 
 
-     this.onBtnOpenClick = null; 
 
-     this.onBtnSaveClick = null; 
 
-     this.onFreshClick = null; 
 
-     this.onPrintClick = null; 
 
-     if (property.headBtns) {
 
-       this.$head.on('click', {
 
-         inthis: this
 
-       }, function (e) {
 
-         if (!e) e = window.event;
 
-         var tar = e.target;
 
-         if (tar.tagName == 'DIV' || tar.tagName == 'SPAN') return;
 
-         else if (tar.tagName == 'A') tar = tar.childNodes[0];
 
-         var This = e.data.inthis;
 
-         
 
-         switch ($(tar).attr('class')) {
 
-           case 'ico_new':
 
-             if (This.onBtnNewClick != null) This.onBtnNewClick();
 
-             break;
 
-           case 'ico_open':
 
-             if (This.onBtnOpenClick != null) This.onBtnOpenClick();
 
-             break;
 
-           case 'ico_save':
 
-             if (This.onBtnSaveClick != null) This.onBtnSaveClick();
 
-             break;
 
-           case 'ico_undo':
 
-             This.undo();
 
-             break;
 
-           case 'ico_redo':
 
-             This.redo();
 
-             break;
 
-           case 'ico_reload':
 
-             if (This.onFreshClick != null) This.onFreshClick();
 
-             break;
 
-           case 'ico_print':
 
-             if (This.onPrintClick != null) This.onPrintClick();
 
-             break;
 
-         }
 
-       });
 
-     }
 
-   }
 
-   var toolWidth = 0;
 
-   if (property.haveTool) {
 
-     this.$bgDiv.append("<div class='GooFlow_tool'" + (property.haveHead ? '' : " style='margin-top:4px'") + "><div style='height:" + (height - headHeight - (property.haveHead ? 5 : 8)) + "px' class='GooFlow_tool_div'></div></div>");
 
-     this.$tool = this.$bgDiv.find('.GooFlow_tool div');
 
-     
 
-     this.$tool.append("<div style='margin-bottom:5px'><span/><span/><span/><span/></div>" +
 
-       "<a href='javascript:void(0)' type='cursor' class='GooFlow_tool_btndown' id='" + this.$id + "_btn_cursor'><i class='ico_cursor'/></a>" +
 
-       "<a href='javascript:void(0)' type='direct' class='GooFlow_tool_btn' id='" + this.$id + "_btn_direct'><i class='ico_direct'/></a>"
 
-     );
 
-     if (property.toolBtns && property.toolBtns.length > 0) {
 
-       tmp = '<span/>';
 
-       for (var i = 0; i < property.toolBtns.length; ++i) {
 
-         tmp += "<a href='javascript:void(0)' type='" + property.toolBtns[i] + "' id='" + this.$id + '_btn_' + property.toolBtns[i].split(' ')[0] + "' class='GooFlow_tool_btn'><i class='ico_" + property.toolBtns[i] + "'/></a>"; 
 
-       }
 
-       this.$tool.append(tmp);
 
-     }
 
-     
 
-     if (property.haveGroup) {
 
-       this.$tool.append("<span/><a href='javascript:void(0)' type='group' class='GooFlow_tool_btn' id='" + this.$id + "_btn_group'><i class='ico_group'/></a>");
 
-     }
 
-     toolWidth = 31;
 
-     this.$nowType = 'cursor';
 
-     
 
-     this.$tool.on('click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (!e) e = window.event;
 
-       var tar;
 
-       switch (e.target.tagName) {
 
-         case 'SPAN':
 
-           return false;
 
-         case 'DIV':
 
-           return false;
 
-         case 'I':
 
-           tar = e.target.parentNode;
 
-           break;
 
-         case 'A':
 
-           tar = e.target;
 
-       };
 
-       var type = $(tar).attr('type');
 
-       e.data.inthis.switchToolBtn(type);
 
-       return false;
 
-     });
 
-     this.$editable = true; 
 
-   }
 
-   width = width - toolWidth - 9;
 
-   height = height - headHeight - (property.haveHead ? 5 : 8);
 
-   this.$bgDiv.append("<div class='GooFlow_work' style='width:" + (width) + 'px;height:' + (height) + 'px;' + (property.haveHead ? '' : 'margin-top:3px') + "'></div>");
 
-   this.$workArea = $("<div class='GooFlow_work_inner' style='width:" + width + 'px;height:' + height + "px'></div>")
 
-     .attr({
 
-       'unselectable': 'on',
 
-       'onselectstart': 'return false',
 
-       'onselect': 'document.selection.empty()'
 
-     });
 
-   this.$bgDiv.children('.GooFlow_work').append(this.$workArea);
 
-   this.$draw = null; 
 
-   this.initDraw('draw_' + this.$id, width, height);
 
-   this.$group = null;
 
-   if (property.haveGroup) {
 
-     this.initGroup(width, height);
 
-   }
 
-   this.initExpendFunc();
 
-   if (this.$editable) {
 
-     
 
-     this.$workArea.on('click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (!e) e = window.event;
 
-       var This = e.data.inthis;
 
-       if (!This.$editable) return;
 
-       var type = This.$nowType;
 
-       if (type == 'cursor') {
 
-         var t = $(e.target);
 
-         var n = t.prop('tagName');
 
-         
 
-         if (n == 'svg' || (n == 'DIV' && t.prop('class').indexOf('GooFlow_work') > -1) || n == 'LABEL') {
 
-           if (This.$lineOper.data('tid')) {
 
-             This.focusItem(This.$lineOper.data('tid'), false);
 
-             
 
-           } else {
 
-             This.blurItem();
 
-           }
 
-         }
 
-         return;
 
-       } else if (type == 'direct' || type == 'group') return;
 
-       var X, Y;
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(this);
 
-       X = ev.x - t.left + this.parentNode.scrollLeft;
 
-       Y = ev.y - t.top + this.parentNode.scrollTop;
 
-       var id = This.generateMixed(3) + String(new Date().getTime());
 
-       This.addNode(id, {
 
-         name: 'node_' + This.$max,
 
-         left: X,
 
-         top: Y,
 
-         type: This.$nowType
 
-       });
 
-       This.$max++;
 
-     });
 
-     
 
-     this.$workArea.mousemove({
 
-       inthis: this
 
-     }, function (e) {
 
-       if (e.data.inthis.$nowType != 'direct' && !e.data.inthis.$mpTo.data('p')) return;
 
-       var lineStart = $(this).data('lineStart');
 
-       var lineEnd = $(this).data('lineEnd');
 
-       if (!lineStart && !lineEnd) return;
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(this);
 
-       var X, Y;
 
-       X = ev.x - t.left + this.parentNode.scrollLeft;
 
-       Y = ev.y - t.top + this.parentNode.scrollTop;
 
-       var line = document.getElementById('GooFlow_tmp_line');
 
-       if (lineStart) {
 
-         if (GooFlow.prototype.useSVG != '') {
 
-           line.childNodes[0].setAttribute('d', 'M ' + lineStart.x + ' ' + lineStart.y + ' L ' + X + ' ' + Y);
 
-           line.childNodes[1].setAttribute('d', 'M ' + lineStart.x + ' ' + lineStart.y + ' L ' + X + ' ' + Y);
 
-           if (line.childNodes[1].getAttribute('marker-end') == 'url("#arrow2")') {
 
-             line.childNodes[1].setAttribute('marker-end', 'url(#arrow3)');
 
-           } else line.childNodes[1].setAttribute('marker-end', 'url(#arrow2)');
 
-         } else line.points.value = lineStart.x + ',' + lineStart.y + ' ' + X + ',' + Y;
 
-       } else if (lineEnd) {
 
-         if (GooFlow.prototype.useSVG != '') {
 
-           line.childNodes[0].setAttribute('d', 'M ' + X + ' ' + Y + ' L ' + lineEnd.x + ' ' + lineEnd.y);
 
-           line.childNodes[1].setAttribute('d', 'M ' + X + ' ' + Y + ' L ' + lineEnd.x + ' ' + lineEnd.y);
 
-           if (line.childNodes[1].getAttribute('marker-end') == 'url("#arrow2")') {
 
-             line.childNodes[1].setAttribute('marker-end', 'url(#arrow3)');
 
-           } else line.childNodes[1].setAttribute('marker-end', 'url(#arrow2)');
 
-         } else line.points.value = X + ',' + Y + ' ' + lineEnd.x + ',' + lineEnd.y;
 
-       }
 
-     });
 
-     this.$workArea.mouseup({
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis;
 
-       if (This.$nowType != 'direct' && !This.$mpTo.data('p')) return;
 
-       var tmp = document.getElementById('GooFlow_tmp_line');
 
-       if (tmp) {
 
-         $(this).css('cursor', 'auto').removeData('lineStart').removeData('lineEnd');
 
-         This.$mpTo.hide().removeData('p');
 
-         This.$mpFrom.hide().removeData('p');
 
-         This.$draw.removeChild(tmp);
 
-         This.focusItem(This.$focus, false);
 
-       } else {
 
-         This.$lineOper.removeData('tid');
 
-       }
 
-     });
 
-     
 
-     this.initWorkForNode();
 
-     
 
-     this.$ghost = $("<div class='rs_ghost'></div>").attr({
 
-       'unselectable': 'on',
 
-       'onselectstart': 'return false',
 
-       'onselect': 'document.selection.empty()'
 
-     });
 
-     this.$bgDiv.append(this.$ghost);
 
-     this.$textArea = $('<textarea></textarea>');
 
-     this.$bgDiv.append(this.$textArea);
 
-     this.$lineMove = $('<div class="GooFlow_linemove" style="display:none"></div>'); 
 
-     this.$workArea.append(this.$lineMove);
 
-     this.$lineMove.on('mousedown', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (e.button == 2) return false;
 
-       var lm = $(this);
 
-       lm.css({
 
-         'background-color': '#333'
 
-       });
 
-       var This = e.data.inthis;
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(This.$workArea[0]);
 
-       var X, Y;
 
-       X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
 
-       Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
 
-       var p = This.$lineMove.position();
 
-       var vX = X - p.left,
 
-         vY = Y - p.top;
 
-       var isMove = false;
 
-       document.onmousemove = function (e) {
 
-         if (!e) e = window.event;
 
-         var ev = mousePosition(e);
 
-         var ps = This.$lineMove.position();
 
-         X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
 
-         Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
 
-         if (This.$lineMove.data('type') == 'lr') {
 
-           X = X - vX;
 
-           if (X < 0) X = 0;
 
-           else if (X > This.$workArea.width()) {
 
-             X = This.$workArea.width();
 
-           }
 
-           This.$lineMove.css({
 
-             left: X + 'px'
 
-           });
 
-         } else if (This.$lineMove.data('type') == 'tb') {
 
-           Y = Y - vY;
 
-           if (Y < 0) Y = 0;
 
-           else if (Y > This.$workArea.height()) {
 
-             Y = This.$workArea.height();
 
-           }
 
-           This.$lineMove.css({
 
-             top: Y + 'px'
 
-           });
 
-         }
 
-         isMove = true;
 
-       }
 
-       document.onmouseup = function (e) {
 
-         if (isMove) {
 
-           var p = This.$lineMove.position();
 
-           if (This.$lineMove.data('type') == 'lr') {
 
-             This.setLineM(This.$lineMove.data('tid'), p.left + 3);
 
-           } else if (This.$lineMove.data('type') == 'tb') {
 
-             This.setLineM(This.$lineMove.data('tid'), p.top + 3);
 
-           }
 
-         }
 
-         This.$lineMove.css({
 
-           'background-color': 'transparent'
 
-         });
 
-         if (This.$focus == This.$lineMove.data('tid')) {
 
-           This.focusItem(This.$lineMove.data('tid'));
 
-         }
 
-         document.onmousemove = null;
 
-         document.onmouseup = null;
 
-       }
 
-     });
 
-     var chars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
 
-     this.generateMixed = function (n) {
 
-          var res = '';
 
-          for (var i = 0; i < n; i++) {
 
-              var id = Math.ceil(Math.random() * 24);
 
-              res += chars[id];
 
-          }
 
-          return res;
 
-     }
 
-     
 
-     this.$lineOper = $("<div class='GooFlow_line_oper' style='display:none'><i class='b_l1'></i><i class='b_l2'></i><i class='b_l3'></i><i class='b_x'></i></div>"); 
 
-     this.$workArea.parent().append(this.$lineOper);
 
-     this.$lineOper.on('click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (!e) e = window.event;
 
-       if (e.target.tagName != 'I') return;
 
-       var This = e.data.inthis;
 
-       var id = $(this).data('tid');
 
-       switch ($(e.target).attr('class')) {
 
-         case 'b_x':
 
-           This.delLine(id);
 
-           this.style.display = 'none';
 
-           break;
 
-         case 'b_l1':
 
-           This.setLineType(id, 'lr');
 
-           break;
 
-         case 'b_l2':
 
-           This.setLineType(id, 'tb');
 
-           break;
 
-         case 'b_l3':
 
-           This.setLineType(id, 'sl');
 
-           break;
 
-       }
 
-     });
 
-     
 
-     this.$mpFrom = $("<div class='GooFlow_line_mp' style='display:none'></div>");
 
-     this.$mpTo = $("<div class='GooFlow_line_mp' style='display:none'></div>");
 
-     this.$workArea.append(this.$mpFrom).append(this.$mpTo);
 
-     this.initLinePointsChg();
 
-     
 
-     
 
-     
 
-     this.onItemAdd = null;
 
-     
 
-     
 
-     this.onItemDel = null;
 
-     
 
-     
 
-     this.onItemMove = null;
 
-     
 
-     
 
-     this.onItemRename = null;
 
-     
 
-     
 
-     this.onItemFocus = null;
 
-     
 
-     
 
-     this.onItemBlur = null;
 
-     
 
-     
 
-     this.onItemResize = null;
 
-     
 
-     
 
-     this.onLineMove = null;
 
-     
 
-     
 
-     this.onLineSetType = null;
 
-     
 
-     
 
-     this.onLinePointMove = null;
 
-     
 
-     
 
-     this.onItemMark = null;
 
-     if (property.useOperStack && this.$editable) { 
 
-       this.$undoStack = [];
 
-       this.$redoStack = [];
 
-       this.$isUndo = 0;
 
-       
 
-       
 
-       this.pushOper = function (funcName, paras) {
 
-         var len = this.$undoStack.length;
 
-         if (this.$isUndo == 1) {
 
-           this.$redoStack.push([funcName, paras]);
 
-           this.$isUndo = false;
 
-           if (this.$redoStack.length > 40) this.$redoStack.shift();
 
-         } else {
 
-           this.$undoStack.push([funcName, paras]);
 
-           if (this.$undoStack.length > 40) this.$undoStack.shift();
 
-           if (this.$isUndo == 0) {
 
-             this.$redoStack.splice(0, this.$redoStack.length);
 
-           }
 
-           this.$isUndo = 0;
 
-         }
 
-       };
 
-       
 
-       
 
-       
 
-       this.pushExternalOper = function (func, jsonPara) {
 
-         this.pushOper('externalFunc', [func, jsonPara]);
 
-       };
 
-       
 
-       this.undo = function () {
 
-         if (this.$undoStack.length == 0) return;
 
-         this.blurItem();
 
-         var tmp = this.$undoStack.pop();
 
-         this.$isUndo = 1;
 
-         if (tmp[0] == 'externalFunc') {
 
-           tmp[1][0](tmp[1][1]);
 
-         } else {
 
-           
 
-           switch (tmp[1].length) {
 
-             case 0:
 
-               this[tmp[0]]();
 
-               break;
 
-             case 1:
 
-               this[tmp[0]](tmp[1][0]);
 
-               break;
 
-             case 2:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1]);
 
-               break;
 
-             case 3:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2]);
 
-               break;
 
-             case 4:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3]);
 
-               break;
 
-             case 5:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3], tmp[1][4]);
 
-               break;
 
-             case 6:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3], tmp[1][4], tmp[1][5]);
 
-               break;
 
-           }
 
-         }
 
-       };
 
-       
 
-       this.redo = function () {
 
-         if (this.$redoStack.length == 0) return;
 
-         this.blurItem();
 
-         var tmp = this.$redoStack.pop();
 
-         this.$isUndo = 2;
 
-         if (tmp[0] == 'externalFunc') {
 
-           tmp[1][0](tmp[1][1]);
 
-         } else {
 
-           
 
-           switch (tmp[1].length) {
 
-             case 0:
 
-               this[tmp[0]]();
 
-               break;
 
-             case 1:
 
-               this[tmp[0]](tmp[1][0]);
 
-               break;
 
-             case 2:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1]);
 
-               break;
 
-             case 3:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2]);
 
-               break;
 
-             case 4:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3]);
 
-               break;
 
-             case 5:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3], tmp[1][4]);
 
-               break;
 
-             case 6:
 
-               this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3], tmp[1][4], tmp[1][5]);
 
-               break;
 
-           }
 
-         }
 
-       };
 
-     }
 
-     $(document).keydown({
 
-       inthis: this
 
-     }, function (e) {
 
-       
 
-       var This = e.data.inthis;
 
-       if (This.$focus == '') return;
 
-       switch (e.keyCode) {
 
-         case 46: 
 
-           This.delNode(This.$focus, true);
 
-           This.delLine(This.$focus);
 
-           break;
 
-       }
 
-     });
 
-   }
 
- }
 
- GooFlow.prototype = {
 
-   useSVG: '',
 
-   getSvgMarker: function (id, color) {
 
-     var m = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
 
-     m.setAttribute('id', id);
 
-     m.setAttribute('viewBox', '0 0 6 6');
 
-     m.setAttribute('refX', 5);
 
-     m.setAttribute('refY', 3);
 
-     m.setAttribute('markerUnits', 'strokeWidth');
 
-     m.setAttribute('markerWidth', 6);
 
-     m.setAttribute('markerHeight', 6);
 
-     m.setAttribute('orient', 'auto');
 
-     var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
-     path.setAttribute('d', 'M 0 0 L 6 3 L 0 6 z');
 
-     path.setAttribute('fill', color);
 
-     path.setAttribute('stroke-width', 0);
 
-     m.appendChild(path);
 
-     return m;
 
-   },
 
-   initDraw: function (id, width, height) {
 
-     var elem;
 
-     if (GooFlow.prototype.useSVG != '') {
 
-       this.$draw = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); 
 
-       this.$workArea.prepend(this.$draw);
 
-       var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
 
-       this.$draw.appendChild(defs);
 
-       defs.appendChild(GooFlow.prototype.getSvgMarker('arrow1', GooFlow.prototype.color.line || '#3892D3'));
 
-       defs.appendChild(GooFlow.prototype.getSvgMarker('arrow2', GooFlow.prototype.color.mark || '#ff8800'));
 
-       defs.appendChild(GooFlow.prototype.getSvgMarker('arrow3', GooFlow.prototype.color.mark || '#ff8800'));
 
-     } else {
 
-       this.$draw = document.createElement('v:group');
 
-       this.$draw.coordsize = width + ',' + height;
 
-       this.$workArea.prepend("<div class='GooFlow_work_vml' style='position:relative;width:" + width + 'px;height:' + height + "px'></div>");
 
-       this.$workArea.children('div')[0].insertBefore(this.$draw, null);
 
-     }
 
-     this.$draw.id = id;
 
-     this.$draw.style.width = width + 'px';
 
-     this.$draw.style.height = +height + 'px';
 
-     
 
-     var tmpClk = null;
 
-     if (GooFlow.prototype.useSVG != '') tmpClk = 'g';
 
-     else tmpClk = 'PolyLine';
 
-     if (!this.$editable) return;
 
-     $(this.$draw).delegate(tmpClk, 'click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       e.data.inthis.focusItem(this.id, true);
 
-     });
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-   },
 
-   initGroup: function (width, height) {
 
-     this.$group = $("<div class='GooFlow_work_group' style='width:" + width + 'px;height:' + height + "px'></div>"); 
 
-     this.$workArea.prepend(this.$group);
 
-     if (!this.$editable) return;
 
-     
 
-     this.$group.on('mousedown', {
 
-       inthis: this
 
-     }, function (e) { 
 
-       if (e.button == 2) return false;
 
-       var This = e.data.inthis;
 
-       if (This.$nowType != 'group') return;
 
-       if (!e) e = window.event;
 
-       var cursor = $(e.target).css('cursor');
 
-       var id = e.target.parentNode;
 
-       switch (cursor) {
 
-         case 'nw-resize':
 
-           id = id.parentNode;
 
-           break;
 
-         case 'w-resize':
 
-           id = id.parentNode;
 
-           break;
 
-         case 'n-resize':
 
-           id = id.parentNode;
 
-           break;
 
-         case 'move':
 
-           break;
 
-         default:
 
-           return;
 
-       }
 
-       id = id.id;
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(This.$workArea[0]);
 
-       var X, Y;
 
-       X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
 
-       Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
 
-       if (cursor != 'move') {
 
-         This.$ghost.css({
 
-           display: 'block',
 
-           width: This.$areaData[id].width + 'px',
 
-           height: This.$areaData[id].height + 'px',
 
-           top: This.$areaData[id].top + t.top - This.$workArea[0].parentNode.scrollTop + 'px',
 
-           left: This.$areaData[id].left + t.left - This.$workArea[0].parentNode.scrollLeft + 'px',
 
-           cursor: cursor
 
-         });
 
-         var vX = (This.$areaData[id].left + This.$areaData[id].width) - X;
 
-         var vY = (This.$areaData[id].top + This.$areaData[id].height) - Y;
 
-       } else {
 
-         var vX = X - This.$areaData[id].left;
 
-         var vY = Y - This.$areaData[id].top;
 
-       }
 
-       var isMove = false;
 
-       This.$ghost.css('cursor', cursor);
 
-       document.onmousemove = function (e) {
 
-         if (!e) e = window.event;
 
-         var ev = mousePosition(e);
 
-         if (cursor != 'move') {
 
-           X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft - This.$areaData[id].left + vX;
 
-           Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop - This.$areaData[id].top + vY;
 
-           if (X < 200) X = 200;
 
-           if (Y < 100) Y = 100;
 
-           switch (cursor) {
 
-             case 'nw-resize':
 
-               This.$ghost.css({
 
-                 width: X + 'px',
 
-                 height: Y + 'px'
 
-               });
 
-               break;
 
-             case 'w-resize':
 
-               This.$ghost.css({
 
-                 width: X + 'px'
 
-               });
 
-               break;
 
-             case 'n-resize':
 
-               This.$ghost.css({
 
-                 height: Y + 'px'
 
-               });
 
-               break;
 
-           }
 
-         } else {
 
-           if (This.$ghost.css('display') == 'none') {
 
-             This.$ghost.css({
 
-               display: 'block',
 
-               width: This.$areaData[id].width + 'px',
 
-               height: This.$areaData[id].height + 'px',
 
-               top: This.$areaData[id].top + t.top - This.$workArea[0].parentNode.scrollTop + 'px',
 
-               left: This.$areaData[id].left + t.left - This.$workArea[0].parentNode.scrollLeft + 'px',
 
-               cursor: cursor
 
-             });
 
-           }
 
-           X = ev.x - vX;
 
-           Y = ev.y - vY;
 
-           if (X < t.left - This.$workArea[0].parentNode.scrollLeft) {
 
-             X = t.left - This.$workArea[0].parentNode.scrollLeft;
 
-           } else if (X + This.$workArea[0].parentNode.scrollLeft + This.$areaData[id].width > t.left + This.$workArea.width()) {
 
-             X = t.left + This.$workArea.width() - This.$workArea[0].parentNode.scrollLeft - This.$areaData[id].width;
 
-           }
 
-           if (Y < t.top - This.$workArea[0].parentNode.scrollTop) {
 
-             Y = t.top - This.$workArea[0].parentNode.scrollTop;
 
-           } else if (Y + This.$workArea[0].parentNode.scrollTop + This.$areaData[id].height > t.top + This.$workArea.height()) {
 
-             Y = t.top + This.$workArea.height() - This.$workArea[0].parentNode.scrollTop - This.$areaData[id].height;
 
-           }
 
-           This.$ghost.css({
 
-             left: X + 'px',
 
-             top: Y + 'px'
 
-           });
 
-         }
 
-         isMove = true;
 
-       }
 
-       document.onmouseup = function (e) {
 
-         This.$ghost.empty().hide();
 
-         document.onmousemove = null;
 
-         document.onmouseup = null;
 
-         if (!isMove) return;
 
-         if (cursor != 'move') {
 
-           This.resizeArea(id, This.$ghost.outerWidth(), This.$ghost.outerHeight());
 
-         } else {
 
-           This.moveArea(id, X + This.$workArea[0].parentNode.scrollLeft - t.left, Y + This.$workArea[0].parentNode.scrollTop - t.top);
 
-         }
 
-         return false;
 
-       }
 
-     });
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     this.$group.mouseup({
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis;
 
-       if (This.$textArea.css('display') == 'block') {
 
-         This.setName(This.$textArea.data('id'), This.$textArea.val(), 'area');
 
-         This.$textArea.val('').removeData('id').hide();
 
-         return false;
 
-       };
 
-       if (This.$nowType != 'group') return;
 
-       if (!e) e = window.event;
 
-       switch ($(e.target).attr('class')) {
 
-         case 'rs_close':
 
-           This.delArea(e.target.parentNode.parentNode.id);
 
-           return false; 
 
-         case 'bg':
 
-           return;
 
-       }
 
-       switch (e.target.tagName) {
 
-         case 'LABEL':
 
-           return false;
 
-         case 'I': 
 
-           var id = e.target.parentNode.id;
 
-           switch (This.$areaData[id].color) {
 
-             case 'red':
 
-               This.setAreaColor(id, 'yellow');
 
-               break;
 
-             case 'yellow':
 
-               This.setAreaColor(id, 'blue');
 
-               break;
 
-             case 'blue':
 
-               This.setAreaColor(id, 'green');
 
-               break;
 
-             case 'green':
 
-               This.setAreaColor(id, 'red');
 
-               break;
 
-           }
 
-           return false;
 
-       }
 
-       if (e.data.inthis.$ghost.css('display') == 'none') {
 
-         var X, Y;
 
-         var ev = mousePosition(e),
 
-           t = getElCoordinate(this);
 
-         X = ev.x - t.left + this.parentNode.parentNode.scrollLeft;
 
-         Y = ev.y - t.top + this.parentNode.parentNode.scrollTop;
 
-         var color = ['red', 'yellow', 'blue', 'green'];
 
-         e.data.inthis.addArea(new Date().getTime(), {
 
-           name: 'area_' + e.data.inthis.$max,
 
-           left: X,
 
-           top: Y,
 
-           color: color[e.data.inthis.$max % 4],
 
-           width: 200,
 
-           height: 100
 
-         });
 
-         e.data.inthis.$max++;
 
-         return false;
 
-       }
 
-     });
 
-   },
 
-   
 
-   initExpendFunc: function () {
 
-     this.$workArea.append('<div class="Gooflow_extend_right"></div><div class="Gooflow_extend_bottom"></div>');
 
-     this.$workArea.children('.Gooflow_extend_right').on('click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis;
 
-       var w = This.$workArea.width() + This.$workExtendStep;
 
-       var h = This.$workArea.height();
 
-       This.$workArea.css({
 
-         width: w + 'px'
 
-       });
 
-       if (GooFlow.prototype.useSVG == '') {
 
-         This.$draw.coordsize = w + ',' + h;
 
-       }
 
-       This.$draw.style.width = w + 'px';
 
-       if (This.$group != null) {
 
-         This.$group.css({
 
-           width: w + 'px'
 
-         });
 
-       }
 
-       var parentDiv = This.$workArea.parent()[0];
 
-       parentDiv.scrollLeft = parentDiv.scrollWidth;
 
-       return false;
 
-     });
 
-     this.$workArea.children('.Gooflow_extend_bottom').on('click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis
 
-       var w = This.$workArea.width();
 
-       var h = This.$workArea.height() + This.$workExtendStep;
 
-       This.$workArea.css({
 
-         height: h + 'px'
 
-       });
 
-       if (GooFlow.prototype.useSVG == '') {
 
-         This.$draw.coordsize = w + ',' + h;
 
-       }
 
-       This.$draw.style.height = h + 'px';
 
-       if (This.$group != null) {
 
-         This.$group.css({
 
-           height: h + 'px'
 
-         });
 
-       }
 
-       var parentDiv = This.$workArea.parent()[0];
 
-       parentDiv.scrollTop = parentDiv.scrollHeight;
 
-       return false;
 
-     });
 
-   },
 
-   
 
-   initLinePointsChg: function () {
 
-     this.$mpFrom.on('mousedown', {
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis;
 
-       This.switchToolBtn('cursor');
 
-       var ps = This.$mpFrom.data('p').split(',');
 
-       var pe = This.$mpTo.data('p').split(',');
 
-       $(this).hide();
 
-       This.$workArea.data('lineEnd', {
 
-         'x': pe[0],
 
-         'y': pe[1],
 
-         'id': This.$lineData[This.$lineOper.data('tid')].to
 
-       }).css('cursor', 'crosshair');
 
-       var line = GooFlow.prototype.drawLine('GooFlow_tmp_line', [ps[0], ps[1]], [pe[0], pe[1]], true, true);
 
-       This.$draw.appendChild(line);
 
-       return false;
 
-     });
 
-     this.$mpTo.on('mousedown', {
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis;
 
-       This.switchToolBtn('cursor');
 
-       var ps = This.$mpFrom.data('p').split(',');
 
-       var pe = This.$mpTo.data('p').split(',');
 
-       $(this).hide();
 
-       This.$workArea.data('lineStart', {
 
-         'x': ps[0],
 
-         'y': ps[1],
 
-         'id': This.$lineData[This.$lineOper.data('tid')].from
 
-       }).css('cursor', 'crosshair');
 
-       var line = GooFlow.prototype.drawLine('GooFlow_tmp_line', [ps[0], ps[1]], [pe[0], pe[1]], true, true);
 
-       This.$draw.appendChild(line);
 
-       return false;
 
-     });
 
-   },
 
-   
 
-   setNodeRemarks: function (remark) {
 
-     if (this.$tool == null) return;
 
-     this.$tool.children('a').each(function () {
 
-       this.title = remark[$(this).attr('id').split('btn_')[1]];
 
-     });
 
-     this.$nodeRemark = remark;
 
-   },
 
-   
 
-   switchToolBtn: function (type) {
 
-     this.$tool.children('#' + this.$id + '_btn_' + this.$nowType.split(' ')[0]).attr('class', 'GooFlow_tool_btn');
 
-     if (this.$nowType == 'group') {
 
-       this.$workArea.prepend(this.$group);
 
-       for (var key in this.$areaDom) this.$areaDom[key].addClass('lock').children('div:eq(1)').css('display', 'none');
 
-     }
 
-     this.$nowType = type;
 
-     this.$tool.children('#' + this.$id + '_btn_' + type.split(' ')[0]).attr('class', 'GooFlow_tool_btndown');
 
-     if (this.$nowType == 'group') {
 
-       this.blurItem();
 
-       this.$workArea.append(this.$group);
 
-       for (var key in this.$areaDom) this.$areaDom[key].removeClass('lock').children('div:eq(1)').css('display', '');
 
-     } else if (this.$nowType == 'direct') {
 
-       this.blurItem();
 
-     }
 
-     if (this.$textArea.css('display') == 'none') this.$textArea.removeData('id').val('').hide();
 
-   },
 
-   
 
-   addNode: function (id, json) {
 
-     if (this.onItemAdd != null && !this.onItemAdd(id, 'node', json)) return;
 
-     if (this.$undoStack && this.$editable) {
 
-       this.pushOper('delNode', [id]);
 
-     }
 
-     var mark = json.marked ? ' item_mark' : '';
 
-     var mark2 = mark + json.type === 'plug' ? 'plugShape' : '';
 
-     if (json.type.indexOf(' round') < 0 && json.type !== 'plug') {
 
-       if (!json.width || json.width < 104) json.width = 104;
 
-       if (!json.height || json.height < 55) json.height = 55;
 
-       if (!json.top || json.top < 0) json.top = 0;
 
-       if (!json.left || json.left < 0) json.left = 0;
 
-       if (json.type === 'plug') {
 
-           json.width = 60;
 
-           json.height = 60;
 
-       }
 
-       this.$nodeDom[id] = $("<div class='GooFlow_item " + mark + "' id='" + id + "' style='top:" + json.top + 'px;left:' + json.left + "px'><table cellspacing='1' style='width:" + (json.width - 2) + 'px;height:' + (json.height - 2) + "px;'><tr><td class='icon ico'><i class='ico_" + json.type + "'></i></td><td class='icon'>" + json.name + "</td></tr></table><div style='display:none'><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
 
-     } else if (json.type === 'plug') {
 
-         json.width = 60;
 
-         json.height = 60;
 
-         if (!json.top || json.top < 0) json.top = 0;
 
-         if (!json.left || json.left < 0) json.left = 0;
 
-         this.$nodeDom[id] = $("<div class='GooFlow_item " + mark2 + "' id='" + id + "' style='top:" + json.top + 'px;left:' + json.left + "px;'><table cellspacing='0' style='width:" + (json.width - 2) + 'px;height:' + (json.height - 2) + "px;'><tr><td class='icon ico'><i class='ico_" + json.type + "'></i></td></tr></table><div style='display:none'><div class='rs_close'></div></div><div class='span'>" + json.name + '</div></div>');
 
-     } else {
 
-       json.width = 26;
 
-       json.height = 26;
 
-       json.top += 16;
 
-       this.$nodeDom[id] = $("<div class='GooFlow_item item_round " + mark + "' id='" + id + "' style='top:" + json.top + 'px;left:' + json.left + "px;'><table cellspacing='0'><tr><td class='icon ico'><i class='ico_" + json.type + "'></i></td></tr></table><div  style='display:none'><div class='rs_close'></div></div><div class='span'>" + json.name + '</div></div>');
 
-     }
 
-     if (GooFlow.prototype.color.node) {
 
-       if (json.type.indexOf(' mix') > -1) {
 
-         this.$nodeDom[id].css({
 
-           'background-color': GooFlow.prototype.color.mix,
 
-           'border-color': GooFlow.prototype.color.mix
 
-         });
 
-         if (GooFlow.prototype.color.mixFont) {
 
-           this.$nodeDom[id].find('td:eq(1)').css('color', GooFlow.prototype.color.mixFont);
 
-           this.$nodeDom[id].find('.span').css('color', GooFlow.prototype.color.mixFont);
 
-         }
 
-       } else {
 
-         this.$nodeDom[id].css({
 
-           'background-color': GooFlow.prototype.color.node,
 
-           'border-color': GooFlow.prototype.color.node
 
-         });
 
-       }
 
-       if (mark && GooFlow.prototype.color.mark) {
 
-         this.$nodeDom[id].css({
 
-           'border-color': GooFlow.prototype.color.mark
 
-         });
 
-       }
 
-     }
 
-     if (json.type.indexOf(' mix') > -1) {
 
-       this.$nodeDom[id].addClass('item_mix');
 
-     }
 
-     var ua = navigator.userAgent.toLowerCase();
 
-     if (ua.indexOf('msie') != -1 && ua.indexOf('8.0') != -1) {
 
-       this.$nodeDom[id].css('filter', 'progid:DXImageTransform.Microsoft.Shadow(color=#94AAC2,direction=135,strength=2)');
 
-     }
 
-     this.$workArea.append(this.$nodeDom[id]);
 
-     json.group = '';
 
-     this.$nodeData[id] = json;
 
-     ++this.$nodeCount;
 
-     if (this.$editable) {
 
-       this.$nodeData[id].alt = true;
 
-       if (this.$deletedItem[id]) delete this.$deletedItem[id]; 
 
-     }
 
-   },
 
-   initWorkForNode: function () {
 
-     
 
-     this.$workArea.delegate('.GooFlow_item', 'click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       e.data.inthis.focusItem(this.id, true);
 
-       $(this).removeClass('item_mark');
 
-     });
 
-     
 
-     this.$workArea.delegate('.icon', 'mousedown', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (!e) e = window.event;
 
-       if (e.button == 2) return false;
 
-       var This = e.data.inthis;
 
-       if (This.$nowType == 'direct') return;
 
-       var Dom = $(this).parents('.GooFlow_item');
 
-       var id = Dom.attr('id');
 
-       This.focusItem(id, true);
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(This.$workArea[0]);
 
-       Dom.children('table').clone().prependTo(This.$ghost);
 
-       var X, Y;
 
-       X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
 
-       Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
 
-       var vX = X - This.$nodeData[id].left,
 
-         vY = Y - This.$nodeData[id].top;
 
-       var isMove = false;
 
-       document.onmousemove = function (e) {
 
-         if (!e) e = window.event;
 
-         var ev = mousePosition(e);
 
-         if (X == ev.x - vX && Y == ev.y - vY) return false;
 
-         X = ev.x - vX;
 
-         Y = ev.y - vY;
 
-         if (isMove && This.$ghost.css('display') == 'none') {
 
-           This.$ghost.css({
 
-             display: 'block',
 
-             width: This.$nodeData[id].width + 'px',
 
-             height: This.$nodeData[id].height + 'px',
 
-             top: This.$nodeData[id].top + t.top - This.$workArea[0].parentNode.scrollTop + 'px',
 
-             left: This.$nodeData[id].left + t.left - This.$workArea[0].parentNode.scrollLeft + 'px',
 
-             cursor: 'move'
 
-           });
 
-         }
 
-         if (X < t.left - This.$workArea[0].parentNode.scrollLeft) {
 
-           X = t.left - This.$workArea[0].parentNode.scrollLeft;
 
-         } else if (X + This.$workArea[0].parentNode.scrollLeft + This.$nodeData[id].width > t.left + This.$workArea.width()) {
 
-           X = t.left + This.$workArea.width() - This.$workArea[0].parentNode.scrollLeft - This.$nodeData[id].width;
 
-         }
 
-         if (Y < t.top - This.$workArea[0].parentNode.scrollTop) {
 
-           Y = t.top - This.$workArea[0].parentNode.scrollTop;
 
-         } else if (Y + This.$workArea[0].parentNode.scrollTop + This.$nodeData[id].height > t.top + This.$workArea.height()) {
 
-           Y = t.top + This.$workArea.height() - This.$workArea[0].parentNode.scrollTop - This.$nodeData[id].height;
 
-         }
 
-         This.$ghost.css({
 
-           left: X + 'px',
 
-           top: Y + 'px'
 
-         });
 
-         isMove = true;
 
-       }
 
-       document.onmouseup = function (e) {
 
-         if (isMove) This.moveNode(id, X + This.$workArea[0].parentNode.scrollLeft - t.left, Y + This.$workArea[0].parentNode.scrollTop - t.top);
 
-         This.$ghost.empty().hide();
 
-         document.onmousemove = null;
 
-         document.onmouseup = null;
 
-       }
 
-     });
 
-     if (!this.$editable) return;
 
-     
 
-     this.$workArea.delegate('.GooFlow_item', 'mouseenter', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (e.data.inthis.$nowType != 'direct' && !document.getElementById('GooFlow_tmp_line')) return;
 
-       $(this).addClass('item_mark').addClass('crosshair').css('border-color', GooFlow.prototype.color.mark || '#ff8800');
 
-     });
 
-     this.$workArea.delegate('.GooFlow_item', 'mouseleave', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (e.data.inthis.$nowType != 'direct' && !document.getElementById('GooFlow_tmp_line')) return;
 
-       $(this).removeClass('item_mark').removeClass('crosshair');
 
-       if (this.id == e.data.inthis.$focus) {
 
-         $(this).css('border-color', GooFlow.prototype.color.line || '#3892D3');
 
-       } else {
 
-         $(this).css('border-color', GooFlow.prototype.color.node || '#A1DCEB');
 
-       }
 
-     });
 
-     
 
-     this.$workArea.delegate('.GooFlow_item', 'mousedown', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (e.button == 2) return false;
 
-       var This = e.data.inthis;
 
-       if (This.$nowType != 'direct') return;
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(This.$workArea[0]);
 
-       var X, Y;
 
-       X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
 
-       Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
 
-       This.$workArea.data('lineStart', {
 
-         'x': X,
 
-         'y': Y,
 
-         'id': this.id
 
-       }).css('cursor', 'crosshair');
 
-       var line = GooFlow.prototype.drawLine('GooFlow_tmp_line', [X, Y], [X, Y], true, true);
 
-       This.$draw.appendChild(line);
 
-     });
 
-     
 
-     this.$workArea.delegate('.GooFlow_item', 'mouseup', {
 
-       inthis: this
 
-     }, function (e) {
 
-       var This = e.data.inthis;
 
-       if (This.$nowType != 'direct' && !This.$mpTo.data('p')) return;
 
-       var lineStart = This.$workArea.data('lineStart');
 
-       var lineEnd = This.$workArea.data('lineEnd');
 
-       if (lineStart && !This.$mpTo.data('p')) {
 
-         var id = This.generateMixed(4) + String(new Date().getTime());
 
-         This.addLine(id, {
 
-           from: lineStart.id,
 
-           to: this.id,
 
-           name: ''
 
-         });
 
-         This.$max++;
 
-       } else {
 
-         if (lineStart) {
 
-           This.moveLinePoints(This.$focus, lineStart.id, this.id);
 
-         } else if (lineEnd) {
 
-           This.moveLinePoints(This.$focus, this.id, lineEnd.id);
 
-         }
 
-         if (!This.$nodeData[this.id].marked) {
 
-           $(this).removeClass('item_mark');
 
-           if (this.id != This.$focus) {
 
-             $(this).css('border-color', GooFlow.prototype.color.node);
 
-           } else {
 
-             $(this).css('border-color', GooFlow.prototype.color.line);
 
-           }
 
-         }
 
-       }
 
-     });
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     
 
-     this.$workArea.delegate('.rs_close', 'click', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (!e) e = window.event;
 
-       e.data.inthis.delNode(e.data.inthis.$focus);
 
-       return false;
 
-     });
 
-     
 
-     this.$workArea.delegate('.GooFlow_item > div > div[class!=rs_close]', 'mousedown', {
 
-       inthis: this
 
-     }, function (e) {
 
-       if (!e) e = window.event;
 
-       if (e.button == 2) return false;
 
-       var cursor = $(this).css('cursor');
 
-       if (cursor == 'pointer') {
 
-         return;
 
-       }
 
-       var This = e.data.inthis;
 
-       var id = This.$focus;
 
-       This.switchToolBtn('cursor');
 
-       e.cancelBubble = true;
 
-       e.stopPropagation();
 
-       var ev = mousePosition(e),
 
-         t = getElCoordinate(This.$workArea[0]);
 
-       This.$ghost.css({
 
-         display: 'block',
 
-         width: This.$nodeData[id].width + 'px',
 
-         height: This.$nodeData[id].height + 'px',
 
-         top: This.$nodeData[id].top + t.top - This.$workArea[0].parentNode.scrollTop + 'px',
 
-         left: This.$nodeData[id].left + t.left - This.$workArea[0].parentNode.scrollLeft + 'px',
 
-         cursor: cursor
 
-       });
 
-       var X, Y;
 
-       X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
 
-       Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
 
-       var vX = (This.$nodeData[id].left + This.$nodeData[id].width) - X;
 
-       var vY = (This.$nodeData[id].top + This.$nodeData[id].height) - Y;
 
-       var isMove = false;
 
-       This.$ghost.css('cursor', cursor);
 
-       document.onmousemove = function (e) {
 
-         if (!e) e = window.event;
 
-         var ev = mousePosition(e);
 
-         X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft - This.$nodeData[id].left + vX;
 
-         Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop - This.$nodeData[id].top + vY;
 
-         if (X < 104) X = 104;
 
-         if (Y < 26) Y = 26;
 
-         isMove = true;
 
-         switch (cursor) {
 
-           case 'nw-resize':
 
-             This.$ghost.css({
 
-               width: X + 'px',
 
-               height: Y + 'px'
 
-             });
 
-             break;
 
-           case 'w-resize':
 
-             This.$ghost.css({
 
-               width: X + 'px'
 
-             });
 
-             break;
 
-           case 'n-resize':
 
-             This.$ghost.css({
 
-               height: Y + 'px'
 
-             });
 
-             break;
 
-         }
 
-       }
 
-       document.onmouseup = function (e) {
 
-         document.onmousemove = null;
 
-         document.onmouseup = null;
 
-         This.$ghost.hide();
 
-         if (!isMove) return;
 
-         if (!e) e = window.event;
 
-         This.resizeNode(id, This.$ghost.outerWidth(), This.$ghost.outerHeight());
 
-       }
 
-     });
 
-   },
 
-   
 
-   getItemInfo: function (id, type) {
 
-     switch (type) {
 
-       case 'node':
 
-         return this.$nodeData[id] || null;
 
-       case 'line':
 
-         return this.$lineData[id] || null;
 
-       case 'area':
 
-         return this.$areaData[id] || null;
 
-     }
 
-   },
 
-   
 
-   blurItem: function () {
 
-     if (this.$focus != '') {
 
-       var jq = $('#' + this.$focus);
 
-       if (jq.prop('tagName') == 'DIV') {
 
-         if (this.onItemBlur != null && !this.onItemBlur(this.$focus, 'node')) return false;
 
-         jq.removeClass('item_focus').children('div:eq(0)').css('display', 'none');
 
-         if (this.$nodeData[this.$focus].marked) {
 
-           jq.addClass('item_mark').css('border-color', GooFlow.prototype.color.mark || '#ff8800');
 
-         }
 
-       } else {
 
-         if (this.onItemBlur != null && !this.onItemBlur(this.$focus, 'line')) return false;
 
-         if (GooFlow.prototype.useSVG != '') {
 
-           if (!this.$lineData[this.$focus].marked) {
 
-             jq[0].childNodes[1].setAttribute('stroke', GooFlow.prototype.color.line || '#3892D3');
 
-             jq[0].childNodes[1].setAttribute('marker-end', 'url(#arrow1)');
 
-           }
 
-         } else {
 
-           if (!this.$lineData[this.$focus].marked) {
 
-             jq[0].strokeColor = GooFlow.prototype.color.line || '#3892D3';
 
-           }
 
-         }
 
-         this.$lineMove.hide().removeData('type').removeData('tid');
 
-         if (this.$editable) {
 
-           this.$lineOper.hide().removeData('tid');
 
-           this.$mpFrom.hide().removeData('p');
 
-           this.$mpTo.hide().removeData('p');
 
-         }
 
-       }
 
-     }
 
-     this.$focus = '';
 
-     return true;
 
-   },
 
-   
 
-   focusItem: function (id, bool) {
 
-     var jq = $('#' + id);
 
-     if (jq.length == 0) return;
 
-     if (!this.blurItem()) return; 
 
-     if (jq.prop('tagName') == 'DIV') {
 
-       if (bool && this.onItemFocus != null && !this.onItemFocus(id, 'node'));
 
-       jq.addClass('item_focus');
 
-       if (GooFlow.prototype.color.line) {
 
-         jq.css('border-color', GooFlow.prototype.color.line);
 
-       }
 
-       if (this.$editable) jq.children('div:eq(0)').css('display', 'block');
 
-       this.$workArea.append(jq);
 
-     } else { 
 
-       if (this.onItemFocus != null && !this.onItemFocus(id, 'line'));
 
-       if (GooFlow.prototype.useSVG != '') {
 
-         jq[0].childNodes[1].setAttribute('stroke', GooFlow.prototype.color.mark || '#ff8800');
 
-         jq[0].childNodes[1].setAttribute('marker-end', 'url(#arrow2)');
 
-       } else {
 
-         jq[0].strokeColor = GooFlow.prototype.color.mark || '#ff8800';
 
-       }
 
-       if (!this.$editable) return;
 
-       var x, y, from, to, n;
 
-       if (GooFlow.prototype.useSVG != '') {
 
-         from = jq.attr('from').split(',');
 
-         to = jq.attr('to').split(',');
 
-         n = [from[0], from[1], to[0], to[1]];
 
-       } else {
 
-         n = jq[0].getAttribute('fromTo').split(',');
 
-         from = [n[0], n[1]];
 
-         to = [n[2], n[3]];
 
-       }
 
-       from[0] = parseInt(from[0], 10);
 
-       from[1] = parseInt(from[1], 10);
 
-       to[0] = parseInt(to[0], 10);
 
-       to[1] = parseInt(to[1], 10);
 
-       
 
-       if (this.$lineData[id].type == 'lr') {
 
-         from[0] = this.$lineData[id].M;
 
-         to[0] = from[0];
 
-         this.$lineMove.css({
 
-           width: '5px',
 
-           height: (to[1] - from[1]) * (to[1] > from[1] ? 1 : -1) + 'px',
 
-           left: from[0] - 3 + 'px',
 
-           top: (to[1] > from[1] ? from[1] : to[1]) + 1 + 'px',
 
-           cursor: 'e-resize',
 
-           display: 'block'
 
-         }).data({
 
-           'type': 'lr',
 
-           'tid': id
 
-         });
 
-       } else if (this.$lineData[id].type == 'tb') {
 
-         from[1] = this.$lineData[id].M;
 
-         to[1] = from[1];
 
-         this.$lineMove.css({
 
-           width: (to[0] - from[0]) * (to[0] > from[0] ? 1 : -1) + 'px',
 
-           height: '5px',
 
-           left: (to[0] > from[0] ? from[0] : to[0]) + 1 + 'px',
 
-           top: from[1] - 3 + 'px',
 
-           cursor: 's-resize',
 
-           display: 'block'
 
-         }).data({
 
-           'type': 'tb',
 
-           'tid': id
 
-         });
 
-       }
 
-       x = (from[0] + to[0]) / 2 - 40;
 
-       y = (from[1] + to[1]) / 2 + 4;
 
-       this.$lineOper.css({
 
-         display: 'block',
 
-         left: x + 'px',
 
-         top: y + 'px'
 
-       }).data('tid', id);
 
-       if (this.$editable) {
 
-         this.$mpFrom.css({
 
-           display: 'block',
 
-           left: n[0] - 4 + 'px',
 
-           top: n[1] - 4 + 'px'
 
-         }).data('p', n[0] + ',' + n[1]);
 
-         this.$mpTo.css({
 
-           display: 'block',
 
-           left: n[2] - 4 + 'px',
 
-           top: n[3] - 4 + 'px'
 
-         }).data('p', n[2] + ',' + n[3]);
 
-       }
 
-       this.$draw.appendChild(jq[0]);
 
-     }
 
-     this.$focus = id;
 
-     this.switchToolBtn('cursor');
 
-   },
 
-   
 
-   moveNode: function (id, left, top) {
 
-     if (!this.$nodeData[id]) return;
 
-     if (this.onItemMove != null && !this.onItemMove(id, 'node', left, top)) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$nodeData[id].left, this.$nodeData[id].top];
 
-       this.pushOper('moveNode', paras);
 
-     }
 
-     if (left < 0) left = 0;
 
-     if (top < 0) top = 0;
 
-     $('#' + id).css({
 
-       left: left + 'px',
 
-       top: top + 'px'
 
-     });
 
-     this.$nodeData[id].left = left;
 
-     this.$nodeData[id].top = top;
 
-     
 
-     this.resetLines(id, this.$nodeData[id]);
 
-     if (this.$editable) {
 
-       this.$nodeData[id].alt = true;
 
-     }
 
-   },
 
-   
 
-   setName: function (id, name, type) {
 
-     var oldName;
 
-     if (type == 'node') { 
 
-       if (!this.$nodeData[id]) return;
 
-       if (this.$nodeData[id].name == name) return;
 
-       if (this.onItemRename != null && !this.onItemRename(id, name, 'node'));
 
-       oldName = this.$nodeData[id].name;
 
-       this.$nodeData[id].name = name;
 
-       if (this.$nodeData[id].type.indexOf('round') > 1) {
 
-         this.$nodeDom[id].children('.span').text(name);
 
-       } else {
 
-         this.$nodeDom[id].find('td:eq(1)').text(name);
 
-         var width = this.$nodeDom[id].width();
 
-         var height = this.$nodeDom[id].height();
 
-         this.$nodeDom[id].children('table').css({
 
-           width: width + 'px',
 
-           height: height + 'px'
 
-         });
 
-         this.$nodeData[id].width = width;
 
-         this.$nodeData[id].height = height;
 
-       }
 
-       if (this.$editable) {
 
-         this.$nodeData[id].alt = true;
 
-       }
 
-       
 
-       this.resetLines(id, this.$nodeData[id]);
 
-     } else if (type == 'line') { 
 
-       if (!this.$lineData[id]) return;
 
-       if (this.$lineData[id].name == name) return;
 
-       if (this.onItemRename != null && !this.onItemRename(id, name, 'line'));
 
-       oldName = this.$lineData[id].name;
 
-       this.$lineData[id].name = name;
 
-       if (GooFlow.prototype.useSVG != '') {
 
-         this.$lineDom[id].childNodes[2].textContent = name;
 
-       } else {
 
-         this.$lineDom[id].childNodes[1].innerHTML = name;
 
-         var n = this.$lineDom[id].getAttribute('fromTo').split(',');
 
-         var x;
 
-         if (this.$lineData[id].type != 'lr') {
 
-           x = (n[2] - n[0]) / 2;
 
-         } else {
 
-           var Min = n[2] > n[0] ? n[0] : n[2];
 
-           if (Min > this.$lineData[id].M) Min = this.$lineData[id].M;
 
-           x = this.$lineData[id].M - Min;
 
-         }
 
-         if (x < 0) x = x * -1;
 
-         this.$lineDom[id].childNodes[1].style.left = x - this.$lineDom[id].childNodes[1].offsetWidth / 2 + 4 + 'px';
 
-       }
 
-       if (this.$editable) {
 
-         this.$lineData[id].alt = true;
 
-       }
 
-     } else if (type == 'area') { 
 
-       if (!this.$areaData[id]) return;
 
-       if (this.$areaData[id].name == name) return;
 
-       if (this.onItemRename != null && !this.onItemRename(id, name, 'area'));
 
-       oldName = this.$areaData[id].name;
 
-       this.$areaData[id].name = name;
 
-       this.$areaDom[id].children('label').text(name);
 
-       if (this.$editable) {
 
-         this.$areaData[id].alt = true;
 
-       }
 
-     }
 
-     if (this.$undoStack) {
 
-       var paras = [id, oldName, type];
 
-       this.pushOper('setName', paras);
 
-     }
 
-   },
 
-   
 
-   resizeNode: function (id, width, height) {
 
-     if (!this.$nodeData[id]) return;
 
-     if (this.onItemResize != null && !this.onItemResize(id, 'node', width, height)) return;
 
-     if (this.$nodeData[id].type == 'start' || this.$nodeData[id].type == 'end') return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$nodeData[id].width, this.$nodeData[id].height];
 
-       this.pushOper('resizeNode', paras);
 
-     }
 
-     this.$nodeDom[id].children('table').css({
 
-       width: width - 2 + 'px',
 
-       height: height - 2 + 'px'
 
-     });
 
-     
 
-     
 
-     
 
-     this.$nodeData[id].width = width;
 
-     this.$nodeData[id].height = height;
 
-     if (this.$editable) {
 
-       this.$nodeData[id].alt = true;
 
-     }
 
-     
 
-     this.resetLines(id, this.$nodeData[id]);
 
-   },
 
-   
 
-   delNode: function (id, trigger) {
 
-     if (!this.$nodeData[id]) return;
 
-     if (trigger != false && this.onItemDel != null && !this.onItemDel(id, 'node')) return;
 
-     
 
-     for (var k in this.$lineData) {
 
-       if (this.$lineData[k].from == id || this.$lineData[k].to == id) {
 
-         
 
-         
 
-         
 
-         this.delLine(k, false);
 
-       }
 
-     }
 
-     
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$nodeData[id]];
 
-       this.pushOper('addNode', paras);
 
-     }
 
-     delete this.$nodeData[id];
 
-     this.$nodeDom[id].remove();
 
-     delete this.$nodeDom[id];
 
-     --this.$nodeCount;
 
-     if (this.$focus == id) this.$focus = '';
 
-     if (this.$editable) {
 
-       
 
-       if (id.indexOf(this.$id + '_node_') < 0) {
 
-         this.$deletedItem[id] = 'node';
 
-       }
 
-     }
 
-   },
 
-   
 
-   setTitle: function (text) {
 
-     this.$title = text;
 
-     if (this.$head) this.$head.children('label').attr('title', text).text(text);
 
-   },
 
-   setId: function (id) {
 
-       this.$id = id
 
-   },
 
-   
 
-   loadData: function (data) {
 
-     var t = this.$editable;
 
-     this.$editable = false;
 
-     if (data.title) this.setTitle(data.title);
 
-     if (data.initNum) this.$max = data.initNum;
 
-     this.$id = data.id;
 
-     for (var i in data.nodes) {
 
-       this.addNode(i, data.nodes[i]);
 
-     }
 
-     for (var j in data.lines) {
 
-       this.addLine(j, data.lines[j]);
 
-     }
 
-     for (var k in data.areas) {
 
-       this.addArea(k, data.areas[k]);
 
-     }
 
-     this.$editable = t;
 
-     this.$deletedItem = {};
 
-     
 
-     var width = this.$workArea.width();
 
-     var height = this.$workArea.height();
 
-     var maxW = 0,
 
-       maxH = 0;
 
-     for (var key in this.$nodeData) {
 
-       var item = this.$nodeData[key];
 
-       if (maxW < item.width + item.left) {
 
-         maxW = item.width + item.left;
 
-       }
 
-       if (maxH < item.height + item.top) {
 
-         maxH = item.height + item.top;
 
-       }
 
-     }
 
-     for (var key in this.$areaData) {
 
-       var item = this.$areaData[key];
 
-       if (maxW < item.width + item.left) {
 
-         maxW = item.width + item.left;
 
-       }
 
-       if (maxH < item.height + item.top) {
 
-         maxH = item.height + item.top;
 
-       }
 
-     }
 
-     M = 0;
 
-     for (var key in this.$lineData) {
 
-       var item = this.$lineData[key];
 
-       if (item.M && item.type == 'lt' && maxW < item.M) {
 
-         maxW = M + 4;
 
-       }
 
-       if (item.M && item.type == 'tb' && maxH < item.M) {
 
-         maxH = M + 4;
 
-       }
 
-     }
 
-     while (maxW > width) {
 
-       width += this.$workExtendStep;
 
-     }
 
-     while (maxH > height) {
 
-       height += this.$workExtendStep;
 
-     }
 
-     this.$workArea.css({
 
-       height: height + 'px',
 
-       width: width + 'px'
 
-     });
 
-     if (GooFlow.prototype.useSVG == '') {
 
-       this.$draw.coordsize = width + ',' + height;
 
-     }
 
-     this.$draw.style.width = width + 'px';
 
-     this.$draw.style.height = +height + 'px';
 
-     if (this.$group != null) {
 
-       this.$group.css({
 
-         height: height + 'px',
 
-         width: width + 'px'
 
-       });
 
-     }
 
-   },
 
-   
 
-   
 
-   loadDataAjax: function (para) {
 
-     var This = this;
 
-     $.ajax({
 
-       type: para.type,
 
-       url: para.url,
 
-       dataType: 'json',
 
-       data: para.data,
 
-       success: function (msg) {
 
-         if (para.dataFilter) para.dataFilter(msg, 'json');
 
-         This.loadData(msg);
 
-         if (para.success) para.success(msg);
 
-       },
 
-       error: function (XMLHttpRequest, textStatus, errorThrown) {
 
-         if (para.error) para.error(textStatus, errorThrown);
 
-       }
 
-     })
 
-   },
 
-   
 
-   exportData: function () {
 
-     var ret = {
 
-       title: this.$title,
 
-       id: this.$id,
 
-       nodes: this.$nodeData,
 
-       lines: this.$lineData,
 
-       areas: this.$areaData,
 
-       initNum: this.$max
 
-     };
 
-     for (var k1 in ret.nodes) {
 
-       if (!ret.nodes[k1].marked) {
 
-         delete ret.nodes[k1]['marked'];
 
-       }
 
-     }
 
-     for (var k2 in ret.lines) {
 
-       if (!ret.lines[k2].marked) {
 
-         delete ret.lines[k2]['marked'];
 
-       }
 
-     }
 
-     return ret;
 
-   },
 
-   exportDataToXML: function (JsonData) {
 
-     let file = `
 
-     <?xml version="1.0" encoding="UTF-8"?>
 
-     <definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="test2019" exporter="camunda modeler" exporterVersion="2.7.1" name="" targetNamespace="http://www.activiti.org/test">
 
-                 <process id="${this.$id}" name="${this.$title}" isExecutable="true">
 
-         `
 
-     let nodeData = '',
 
-         lineData = '',
 
-         detail = '',
 
-         startData = '',
 
-         data = '',
 
-         endData = '';
 
-     
 
-     for (let itemNode in this.$nodeData) {
 
-         if (this.$nodeData[itemNode].type.indexOf('start') >= 0) {
 
-             startData += `
 
-                 <startEvent id="${itemNode}" name="${this.$nodeData[itemNode].name}">
 
-                     ${this.checkNodeLine(itemNode)}
 
-                 </startEvent>
 
-             `
 
-         } else if (this.$nodeData[itemNode].type.indexOf('end') >= 0) {
 
-             endData += `
 
-                 <endEvent id="${itemNode}" name="${this.$nodeData[itemNode].name}">
 
-                     ${this.checkNodeLine(itemNode)}
 
-                 </endEvent>
 
-             `
 
-         } else if (this.$nodeData[itemNode].type === 'plug') {
 
-             data += `
 
-                 <exclusiveGateway id="${itemNode}" name="${this.$nodeData[itemNode].name}">
 
-                     ${this.checkNodeLine(itemNode)}
 
-                 </exclusiveGateway>
 
-             `
 
-         } else {
 
-             data += `
 
-                 <userTask id="${itemNode}" activiti:candidateGroups="${this.$nodeData[itemNode].group}" activiti:exclusive="true" name="${this.$nodeData[itemNode].name}">
 
-                     ${this.checkNodeLine(itemNode)}
 
-                 </userTask>
 
-             `
 
-         }
 
-     }
 
-     nodeData = startData + data + endData;
 
-     
 
-     for (let item in this.$lineData) {
 
-         if (this.$lineData[item].rules) {
 
-             lineData += `
 
-                 <sequenceFlow id="${item}" sourceRef="${this.$lineData[item].from}" targetRef="${this.$lineData[item].to}">
 
-                     <conditionExpression xsi:type="tFormalExpression">
 
-                         <![CDATA[ ${this.$lineData[item].rules} ]]>
 
-                     </conditionExpression>
 
-                 </sequenceFlow>
 
-             `
 
-         } else {
 
-             lineData += `
 
-                 <sequenceFlow id="${item}" sourceRef="${this.$lineData[item].from}" targetRef="${this.$lineData[item].to}"/>
 
-             `
 
-         }
 
-     }
 
-     lineData += '</process>'
 
-     
 
-     detail += ` 
 
-             <bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
 
-             <bpmndi:BPMNPlane bpmnElement="${this.$id}">
 
-         `
 
-     for (let item in this.$nodeData) {
 
-         detail += `
 
-             <bpmndi:BPMNShape id="Shape-${item}" bpmnElement="${item}">  
 
-                 <omgdc:Bounds height="${this.$nodeData[item].height}" width="${this.$nodeData[item].width}" x="${this.$nodeData[item].left}" y="${this.$nodeData[item].top}"/>
 
-                 <bpmndi:BPMNLabel>
 
-                     <omgdc:Bounds height="${this.$nodeData[item].height}" width="${this.$nodeData[item].width}" x="0.0" y="0.0"/>
 
-                 </bpmndi:BPMNLabel>
 
-             </bpmndi:BPMNShape>
 
-         ` 
 
-     }
 
-     for (let item in this.$lineData) {
 
-         if (this.$lineData[item].type !== 'sl') {
 
-             let arr = this.calcPolyPoints(this.$nodeData[this.$lineData[item].from], this.$nodeData[this.$lineData[item].to], this.$lineData[item].type, this.$lineData[item].M)
 
-             detail += `
 
-                 <bpmndi:BPMNEdge id="BPMNEdge_${item}" bpmnElement="${item}">
 
-                     <omgdi:waypoint xsi:type="omgdc:Point" x="${arr.start[0]}" y="${arr.start[1]}"/>
 
-                     <omgdi:waypoint xsi:type="omgdc:Point" x="${arr.m1[0]}" y="${arr.m1[1]}"/>
 
-                     <omgdi:waypoint xsi:type="omgdc:Point" x="${arr.m2[0]}" y="${arr.m2[1]}"/>
 
-                     <omgdi:waypoint xsi:type="omgdc:Point" x="${arr.end[0]}" y="${arr.end[1]}"/>
 
-                     <bpmndi:BPMNLabel>
 
-                         <omgdc:Bounds height="-1.0" width="-1.0" x="-1.0" y="-1.0"/>
 
-                     </bpmndi:BPMNLabel>
 
-                 </bpmndi:BPMNEdge>
 
-             `
 
-         } else {
 
-             let arr = this.calcStartEnd(this.$nodeData[this.$lineData[item].from], this.$nodeData[this.$lineData[item].to])
 
-             detail += `
 
-                 <bpmndi:BPMNEdge id="BPMNEdge_${item}" bpmnElement="${item}">
 
-                     <omgdi:waypoint xsi:type="omgdc:Point" x="${arr.start[0]}" y="${arr.start[1]}"/>
 
-                     <omgdi:waypoint xsi:type="omgdc:Point" x="${arr.end[0]}" y="${arr.end[1]}"/>
 
-                     <bpmndi:BPMNLabel>
 
-                         <omgdc:Bounds height="-1.0" width="-1.0" x="-1.0" y="-1.0"/>
 
-                     </bpmndi:BPMNLabel>
 
-                 </bpmndi:BPMNEdge>
 
-             `
 
-         }
 
-     }
 
-     detail += `
 
-                 </bpmndi:BPMNPlane>
 
-             </bpmndi:BPMNDiagram>
 
-         </definitions>
 
-     `
 
-     return (file + nodeData + lineData + detail)
 
-   },
 
-   checkNodeLine: function (itemName) {
 
-     let goIn = '';
 
-     let goOut = '';
 
-     for (let itemLine in this.$lineData) {
 
-         if (this.$lineData[itemLine].from === itemName) {
 
-             goOut += '<outgoing>' + itemLine + '</outgoing>'
 
-         } else if (this.$lineData[itemLine].to === itemName) {
 
-             goIn += '<incoming>' + itemLine + '</incoming>'
 
-         }
 
-     }
 
-     return (goIn + goOut)
 
-   },
 
-   
 
-   exportAlter: function () {
 
-     var ret = {
 
-       nodes: {},
 
-       lines: {},
 
-       areas: {}
 
-     };
 
-     for (var k1 in this.$nodeData) {
 
-       if (this.$nodeData[k1].alt) {
 
-         ret.nodes[k1] = this.$nodeData[k1];
 
-       }
 
-     }
 
-     for (var k2 in this.$lineData) {
 
-       if (this.$lineData[k2].alt) {
 
-         ret.lines[k2] = this.$lineData[k2];
 
-       }
 
-     }
 
-     for (var k3 in this.$areaData) {
 
-       if (this.$areaData[k3].alt) {
 
-         ret.areas[k3] = this.$areaData[k3];
 
-       }
 
-     }
 
-     ret.deletedItem = this.$deletedItem;
 
-     return ret;
 
-   },
 
-   
 
-   transNewId: function (oldId, newId, type) {
 
-     var tmp;
 
-     switch (type) {
 
-       case 'node':
 
-         if (this.$nodeData[oldId]) {
 
-           tmp = this.$nodeData[oldId];
 
-           delete this.$nodeData[oldId];
 
-           this.$nodeData[newId] = tmp;
 
-           tmp = this.$nodeDom[oldId].attr('id', newId);
 
-           delete this.$nodeDom[oldId];
 
-           this.$nodeDom[newId] = tmp;
 
-         }
 
-         break;
 
-       case 'line':
 
-         if (this.$lineData[oldId]) {
 
-           tmp = this.$lineData[oldId];
 
-           delete this.$lineData[oldId];
 
-           this.$lineData[newId] = tmp;
 
-           tmp = this.$lineDom[oldId].attr('id', newId);
 
-           delete this.$lineDom[oldId];
 
-           this.$lineDom[newId] = tmp;
 
-         }
 
-         break;
 
-       case 'area':
 
-         if (this.$areaData[oldId]) {
 
-           tmp = this.$areaData[oldId];
 
-           delete this.$areaData[oldId];
 
-           this.$areaData[newId] = tmp;
 
-           tmp = this.$areaDom[oldId].attr('id', newId);
 
-           delete this.$areaDom[oldId];
 
-           this.$areaDom[newId] = tmp;
 
-         }
 
-         break;
 
-     }
 
-   },
 
-   
 
-   clearData: function () {
 
-     for (var key in this.$nodeData) {
 
-       this.delNode(key);
 
-     }
 
-     for (var key in this.$lineData) {
 
-       this.delLine(key);
 
-     }
 
-     for (var key in this.$areaData) {
 
-       this.delArea(key);
 
-     }
 
-     this.$deletedItem = {};
 
-   },
 
-   
 
-   destrory: function () {
 
-     this.$bgDiv.empty();
 
-     this.$lineData = null;
 
-     this.$nodeData = null;
 
-     this.$lineDom = null;
 
-     this.$nodeDom = null;
 
-     this.$areaDom = null;
 
-     this.$areaData = null;
 
-     this.$nodeCount = 0;
 
-     this.$areaCount = 0;
 
-     this.$areaCount = 0;
 
-     this.$deletedItem = {};
 
-   },
 
-   
 
-   
 
-   drawLine: function (id, sp, ep, mark, dash) {
 
-     var line;
 
-     if (GooFlow.prototype.useSVG != '') {
 
-       line = document.createElementNS('http://www.w3.org/2000/svg', 'g');
 
-       var hi = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
-       var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
-       if (id != '') line.setAttribute('id', id);
 
-       line.setAttribute('from', sp[0] + ',' + sp[1]);
 
-       line.setAttribute('to', ep[0] + ',' + ep[1]);
 
-       hi.setAttribute('visibility', 'hidden');
 
-       hi.setAttribute('stroke-width', 9);
 
-       hi.setAttribute('fill', 'none');
 
-       hi.setAttribute('stroke', 'white');
 
-       hi.setAttribute('d', 'M ' + sp[0] + ' ' + sp[1] + ' L ' + ep[0] + ' ' + ep[1]);
 
-       hi.setAttribute('pointer-events', 'stroke');
 
-       path.setAttribute('d', 'M ' + sp[0] + ' ' + sp[1] + ' L ' + ep[0] + ' ' + ep[1]);
 
-       path.setAttribute('stroke-width', mark ? 2.4 : 1.4);
 
-       path.setAttribute('stroke-linecap', 'round');
 
-       path.setAttribute('fill', 'none');
 
-       if (dash) path.setAttribute('style', 'stroke-dasharray:6,5');
 
-       if (mark) {
 
-         path.setAttribute('stroke', GooFlow.prototype.color.mark || '#ff8800');
 
-         path.setAttribute('marker-end', 'url(#arrow2)');
 
-       } else {
 
-         path.setAttribute('stroke', GooFlow.prototype.color.line || '#3892D3');
 
-         path.setAttribute('marker-end', 'url(#arrow1)');
 
-       }
 
-       line.appendChild(hi);
 
-       line.appendChild(path);
 
-       line.style.cursor = 'crosshair';
 
-       if (id != '' && id != 'GooFlow_tmp_line') {
 
-         var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
 
-         text.setAttribute('fill', GooFlow.prototype.color.lineFont || '#333');
 
-         line.appendChild(text);
 
-         var x = (ep[0] + sp[0]) / 2;
 
-         var y = (ep[1] + sp[1]) / 2;
 
-         text.setAttribute('text-anchor', 'middle');
 
-         text.setAttribute('x', x);
 
-         text.setAttribute('y', y);
 
-         line.style.cursor = 'pointer';
 
-         text.style.cursor = 'text';
 
-       }
 
-     } else {
 
-       line = document.createElement('v:polyline');
 
-       if (id != '') line.id = id;
 
-       
 
-       line.points.value = sp[0] + ',' + sp[1] + ' ' + ep[0] + ',' + ep[1];
 
-       line.setAttribute('fromTo', sp[0] + ',' + sp[1] + ',' + ep[0] + ',' + ep[1]);
 
-       line.strokeWeight = '1.2';
 
-       line.stroke.EndArrow = 'Block';
 
-       line.style.cursor = 'crosshair';
 
-       if (id != '' && id != 'GooFlow_tmp_line') {
 
-         var text = document.createElement('div');
 
-         
 
-         line.appendChild(text);
 
-         var x = (ep[0] - sp[0]) / 2;
 
-         var y = (ep[1] - sp[1]) / 2;
 
-         if (x < 0) x = x * -1;
 
-         if (y < 0) y = y * -1;
 
-         text.style.left = x + 'px';
 
-         text.style.top = y - 6 + 'px';
 
-         line.style.cursor = 'pointer';
 
-       }
 
-       if (dash) line.stroke.dashstyle = 'Dash';
 
-       if (mark) line.strokeColor = GooFlow.prototype.color.mark || '#ff8800';
 
-       else line.strokeColor = GooFlow.prototype.color.line || '#3892D3';
 
-       line.fillColor = GooFlow.prototype.color.line || '#3892D3';
 
-     }
 
-     return line;
 
-   },
 
-   
 
-   drawPoly: function (id, sp, m1, m2, ep, mark) {
 
-     var poly, strPath;
 
-     if (GooFlow.prototype.useSVG != '') {
 
-       poly = document.createElementNS('http://www.w3.org/2000/svg', 'g');
 
-       var hi = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
-       var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
 
-       if (id != '') poly.setAttribute('id', id);
 
-       poly.setAttribute('from', sp[0] + ',' + sp[1]);
 
-       poly.setAttribute('to', ep[0] + ',' + ep[1]);
 
-       hi.setAttribute('visibility', 'hidden');
 
-       hi.setAttribute('stroke-width', 9);
 
-       hi.setAttribute('fill', 'none');
 
-       hi.setAttribute('stroke', 'white');
 
-       strPath = 'M ' + sp[0] + ' ' + sp[1];
 
-       if (m1[0] != sp[0] || m1[1] != sp[1]) {
 
-         strPath += ' L ' + m1[0] + ' ' + m1[1];
 
-       }
 
-       if (m2[0] != ep[0] || m2[1] != ep[1]) {
 
-         strPath += ' L ' + m2[0] + ' ' + m2[1];
 
-       }
 
-       strPath += ' L ' + ep[0] + ' ' + ep[1];
 
-       hi.setAttribute('d', strPath);
 
-       hi.setAttribute('pointer-events', 'stroke');
 
-       path.setAttribute('d', strPath);
 
-       path.setAttribute('stroke-width', mark ? 2.4 : 1.4);
 
-       path.setAttribute('stroke-linecap', 'round');
 
-       path.setAttribute('fill', 'none');
 
-       if (mark) {
 
-         path.setAttribute('stroke', GooFlow.prototype.color.mark || '#ff8800');
 
-         path.setAttribute('marker-end', 'url(#arrow2)');
 
-       } else {
 
-         path.setAttribute('stroke', GooFlow.prototype.color.line || '#3892D3');
 
-         path.setAttribute('marker-end', 'url(#arrow1)');
 
-       }
 
-       poly.appendChild(hi);
 
-       poly.appendChild(path);
 
-       var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
 
-       text.setAttribute('fill', GooFlow.prototype.color.lineFont || '#333');
 
-       poly.appendChild(text);
 
-       var x = (m2[0] + m1[0]) / 2;
 
-       var y = (m2[1] + m1[1]) / 2;
 
-       text.setAttribute('text-anchor', 'middle');
 
-       text.setAttribute('x', x);
 
-       text.setAttribute('y', y);
 
-       text.style.cursor = 'text';
 
-       poly.style.cursor = 'pointer';
 
-     } else {
 
-       poly = document.createElement('v:Polyline');
 
-       if (id != '') poly.id = id;
 
-       poly.filled = 'false';
 
-       strPath = sp[0] + ',' + sp[1];
 
-       if (m1[0] != sp[0] || m1[1] != sp[1]) {
 
-         strPath += ' ' + m1[0] + ',' + m1[1];
 
-       }
 
-       if (m2[0] != ep[0] || m2[1] != ep[1]) {
 
-         strPath += ' ' + m2[0] + ',' + m2[1];
 
-       }
 
-       strPath += ' ' + ep[0] + ',' + ep[1];
 
-       poly.points.value = strPath;
 
-       poly.setAttribute('fromTo', sp[0] + ',' + sp[1] + ',' + ep[0] + ',' + ep[1]);
 
-       poly.strokeWeight = mark ? '2.4' : '1.2';
 
-       poly.stroke.EndArrow = 'Block';
 
-       var text = document.createElement('div');
 
-       
 
-       poly.appendChild(text);
 
-       var x = (m2[0] - m1[0]) / 2;
 
-       var y = (m2[1] - m1[1]) / 2;
 
-       if (x < 0) x = x * -1;
 
-       if (y < 0) y = y * -1;
 
-       text.style.left = x + 'px';
 
-       text.style.top = y - 4 + 'px';
 
-       poly.style.cursor = 'pointer';
 
-       if (mark) poly.strokeColor = GooFlow.prototype.color.mark || '#ff8800';
 
-       else poly.strokeColor = GooFlow.prototype.color.line || '#3892D3';
 
-     }
 
-     return poly;
 
-   },
 
-   
 
-   calcStartEnd: function (n1, n2) {
 
-     var X_1, Y_1, X_2, Y_2;
 
-     
 
-     var x11 = n1.left,
 
-       x12 = n1.left + n1.width,
 
-       x21 = n2.left,
 
-       x22 = n2.left + n2.width;
 
-     
 
-     if (x11 >= x22) {
 
-       X_1 = x11;
 
-       X_2 = x22;
 
-     }
 
-     
 
-     else if (x12 <= x21) {
 
-       X_1 = x12;
 
-       X_2 = x21;
 
-     }
 
-     
 
-     else if (x11 <= x21 && x12 >= x21 && x12 <= x22) {
 
-       X_1 = (x12 + x21) / 2;
 
-       X_2 = X_1;
 
-     } else if (x11 >= x21 && x12 <= x22) {
 
-       X_1 = (x11 + x12) / 2;
 
-       X_2 = X_1;
 
-     } else if (x21 >= x11 && x22 <= x12) {
 
-       X_1 = (x21 + x22) / 2;
 
-       X_2 = X_1;
 
-     } else if (x11 <= x22 && x12 >= x22) {
 
-       X_1 = (x11 + x22) / 2;
 
-       X_2 = X_1;
 
-     }
 
-     
 
-     var y11 = n1.top,
 
-       y12 = n1.top + n1.height,
 
-       y21 = n2.top,
 
-       y22 = n2.top + n2.height;
 
-     
 
-     if (y11 >= y22) {
 
-       Y_1 = y11;
 
-       Y_2 = y22;
 
-     }
 
-     
 
-     else if (y12 <= y21) {
 
-       Y_1 = y12;
 
-       Y_2 = y21;
 
-     }
 
-     
 
-     else if (y11 <= y21 && y12 >= y21 && y12 <= y22) {
 
-       Y_1 = (y12 + y21) / 2;
 
-       Y_2 = Y_1;
 
-     } else if (y11 >= y21 && y12 <= y22) {
 
-       Y_1 = (y11 + y12) / 2;
 
-       Y_2 = Y_1;
 
-     } else if (y21 >= y11 && y22 <= y12) {
 
-       Y_1 = (y21 + y22) / 2;
 
-       Y_2 = Y_1;
 
-     } else if (y11 <= y22 && y12 >= y22) {
 
-       Y_1 = (y11 + y22) / 2;
 
-       Y_2 = Y_1;
 
-     }
 
-     return {
 
-       'start': [X_1, Y_1],
 
-       'end': [X_2, Y_2]
 
-     };
 
-   },
 
-   
 
-   calcPolyPoints: function (n1, n2, type, M) {
 
-     
 
-     var SP = {
 
-       x: n1.left + n1.width / 2,
 
-       y: n1.top + n1.height / 2
 
-     };
 
-     var EP = {
 
-       x: n2.left + n2.width / 2,
 
-       y: n2.top + n2.height / 2
 
-     };
 
-     var sp = [],
 
-       m1 = [],
 
-       m2 = [],
 
-       ep = [];
 
-     
 
-     
 
-     sp = [SP.x, SP.y];
 
-     ep = [EP.x, EP.y];
 
-     if (type == 'lr') {
 
-       
 
-       m1 = [M, SP.y];
 
-       m2 = [M, EP.y];
 
-       
 
-       if (m1[0] > n1.left && m1[0] < n1.left + n1.width) {
 
-         m1[1] = (SP.y > EP.y ? n1.top : n1.top + n1.height);
 
-         sp[0] = m1[0];
 
-         sp[1] = m1[1];
 
-       } else {
 
-         sp[0] = (m1[0] < n1.left ? n1.left : n1.left + n1.width)
 
-       }
 
-       
 
-       if (m2[0] > n2.left && m2[0] < n2.left + n2.width) {
 
-         m2[1] = (SP.y > EP.y ? n2.top + n2.height : n2.top);
 
-         ep[0] = m2[0];
 
-         ep[1] = m2[1];
 
-       } else {
 
-         ep[0] = (m2[0] < n2.left ? n2.left : n2.left + n2.width)
 
-       }
 
-     }
 
-     
 
-     else if (type == 'tb') {
 
-       
 
-       m1 = [SP.x, M];
 
-       m2 = [EP.x, M];
 
-       
 
-       if (m1[1] > n1.top && m1[1] < n1.top + n1.height) {
 
-         m1[0] = (SP.x > EP.x ? n1.left : n1.left + n1.width);
 
-         sp[0] = m1[0];
 
-         sp[1] = m1[1];
 
-       } else {
 
-         sp[1] = (m1[1] < n1.top ? n1.top : n1.top + n1.height)
 
-       }
 
-       
 
-       if (m2[1] > n2.top && m2[1] < n2.top + n2.height) {
 
-         m2[0] = (SP.x > EP.x ? n2.left + n2.width : n2.left);
 
-         ep[0] = m2[0];
 
-         ep[1] = m2[1];
 
-       } else {
 
-         ep[1] = (m2[1] < n2.top ? n2.top : n2.top + n2.height);
 
-       }
 
-     }
 
-     return {
 
-       start: sp,
 
-       m1: m1,
 
-       m2: m2,
 
-       end: ep
 
-     };
 
-   },
 
-   
 
-   getMValue: function (n1, n2, mType) {
 
-     if (mType == 'lr') {
 
-       return (n1.left + n1.width / 2 + n2.left + n2.width / 2) / 2;
 
-     } else if (mType == 'tb') {
 
-       return (n1.top + n1.height / 2 + n2.top + n2.height / 2) / 2;
 
-     }
 
-   },
 
-   
 
-   addLineDom: function (id, lineData) {
 
-     var n1 = this.$nodeData[lineData.from],
 
-       n2 = this.$nodeData[lineData.to]; 
 
-     if (!n1 || !n2) return;
 
-     
 
-     var res;
 
-     if (lineData.type && lineData.type != 'sl') {
 
-       res = GooFlow.prototype.calcPolyPoints(n1, n2, lineData.type, lineData.M);
 
-     } else {
 
-       res = GooFlow.prototype.calcStartEnd(n1, n2);
 
-     }
 
-     if (!res) return;
 
-     if (lineData.type == 'sl') {
 
-       this.$lineDom[id] = GooFlow.prototype.drawLine(id, res.start, res.end, lineData.marked);
 
-     } else {
 
-       this.$lineDom[id] = GooFlow.prototype.drawPoly(id, res.start, res.m1, res.m2, res.end, lineData.marked);
 
-     }
 
-     this.$draw.appendChild(this.$lineDom[id]);
 
-     if (GooFlow.prototype.useSVG == '') {
 
-       this.$lineDom[id].childNodes[1].innerHTML = lineData.name;
 
-       if (lineData.type != 'sl') {
 
-         var Min = (res.start[0] > res.end[0] ? res.end[0] : res.start[0]);
 
-         if (Min > res.m2[0]) Min = res.m2[0];
 
-         if (Min > res.m1[0]) Min = res.m1[0];
 
-         this.$lineDom[id].childNodes[1].style.left = (res.m2[0] + res.m1[0]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetWidth / 2 + 4;
 
-         Min = (res.start[1] > res.end[1] ? res.end[1] : res.start[1]);
 
-         if (Min > res.m2[1]) Min = res.m2[1];
 
-         if (Min > res.m1[1]) Min = res.m1[1];
 
-         this.$lineDom[id].childNodes[1].style.top = (res.m2[1] + res.m1[1]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetHeight / 2;
 
-       } else {
 
-         this.$lineDom[id].childNodes[1].style.left =
 
-           ((res.end[0] - res.start[0]) * (res.end[0] > res.start[0] ? 1 : -1) - this.$lineDom[id].childNodes[1].offsetWidth) / 2 + 4;
 
-       }
 
-     } else this.$lineDom[id].childNodes[2].textContent = lineData.name;
 
-   },
 
-   
 
-   addLine: function (id, json) {
 
-     if (this.onItemAdd != null && !this.onItemAdd(id, 'line', json)) return;
 
-     if (this.$undoStack && this.$editable) {
 
-       this.pushOper('delLine', [id]);
 
-     }
 
-     if (json.from == json.to) return;
 
-     var n1 = this.$nodeData[json.from],
 
-       n2 = this.$nodeData[json.to]; 
 
-     if (!n1 || !n2) return;
 
-     
 
-     for (var k in this.$lineData) {
 
-       if ((json.from == this.$lineData[k].from && json.to == this.$lineData[k].to)) {
 
-         return;
 
-       }
 
-     }
 
-     
 
-     this.$lineData[id] = {};
 
-     if (json.type) {
 
-       this.$lineData[id].type = json.type;
 
-       this.$lineData[id].M = json.M;
 
-     } else this.$lineData[id].type = 'sl'; 
 
-     this.$lineData[id].from = json.from;
 
-     this.$lineData[id].to = json.to;
 
-     this.$lineData[id].name = json.name;
 
-     this.$lineData[id].rules = '';
 
-     if (json.marked) this.$lineData[id].marked = json.marked;
 
-     else this.$lineData[id].marked = false;
 
-     
 
-     this.addLineDom(id, this.$lineData[id]);
 
-     ++this.$lineCount;
 
-     if (this.$editable) {
 
-       this.$lineData[id].alt = true;
 
-       if (this.$deletedItem[id]) delete this.$deletedItem[id]; 
 
-     }
 
-   },
 
-   
 
-   resetLines: function (id, node) {
 
-     for (var i in this.$lineData) {
 
-       var other = null; 
 
-       var res;
 
-       if (this.$lineData[i].from == id) { 
 
-         other = this.$nodeData[this.$lineData[i].to] || null;
 
-         if (other == null) continue;
 
-         if (this.$lineData[i].type == 'sl') {
 
-           res = GooFlow.prototype.calcStartEnd(node, other);
 
-         } else {
 
-           res = GooFlow.prototype.calcPolyPoints(node, other, this.$lineData[i].type, this.$lineData[i].M)
 
-         }
 
-         if (!res) break;
 
-       } else if (this.$lineData[i].to == id) { 
 
-         other = this.$nodeData[this.$lineData[i].from] || null;
 
-         if (other == null) continue;
 
-         if (this.$lineData[i].type == 'sl') {
 
-           res = GooFlow.prototype.calcStartEnd(other, node);
 
-         } else {
 
-           res = GooFlow.prototype.calcPolyPoints(other, node, this.$lineData[i].type, this.$lineData[i].M);
 
-         }
 
-         if (!res) break;
 
-       }
 
-       if (other == null) continue;
 
-       this.$draw.removeChild(this.$lineDom[i]);
 
-       if (this.$lineData[i].type == 'sl') {
 
-         this.$lineDom[i] = GooFlow.prototype.drawLine(i, res.start, res.end, this.$lineData[i].marked);
 
-       } else {
 
-         this.$lineDom[i] = GooFlow.prototype.drawPoly(i, res.start, res.m1, res.m2, res.end, this.$lineData[i].marked);
 
-       }
 
-       this.$draw.appendChild(this.$lineDom[i]);
 
-       if (GooFlow.prototype.useSVG == '') {
 
-         this.$lineDom[i].childNodes[1].innerHTML = this.$lineData[i].name;
 
-         if (this.$lineData[i].type != 'sl') {
 
-           var Min = (res.start[0] > res.end[0] ? res.end[0] : res.start[0]);
 
-           if (Min > res.m2[0]) Min = res.m2[0];
 
-           if (Min > res.m1[0]) Min = res.m1[0];
 
-           this.$lineDom[i].childNodes[1].style.left = (res.m2[0] + res.m1[0]) / 2 - Min - this.$lineDom[i].childNodes[1].offsetWidth / 2 + 4;
 
-           Min = (res.start[1] > res.end[1] ? res.end[1] : res.start[1]);
 
-           if (Min > res.m2[1]) Min = res.m2[1];
 
-           if (Min > res.m1[1]) Min = res.m1[1];
 
-           this.$lineDom[i].childNodes[1].style.top = (res.m2[1] + res.m1[1]) / 2 - Min - this.$lineDom[i].childNodes[1].offsetHeight / 2 - 4;
 
-         } else {
 
-           this.$lineDom[i].childNodes[1].style.left =
 
-             ((res.end[0] - res.start[0]) * (res.end[0] > res.start[0] ? 1 : -1) - this.$lineDom[i].childNodes[1].offsetWidth) / 2 + 4;
 
-         }
 
-       } else this.$lineDom[i].childNodes[2].textContent = this.$lineData[i].name;
 
-     }
 
-   },
 
-   
 
-   setLineType: function (id, newType, M) {
 
-     if (!newType || newType == null || newType == '' || newType == this.$lineData[id].type) return false;
 
-     if (this.onLineSetType != null && !this.onLineSetType(id, newType)) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$lineData[id].type, this.$lineData[id].M];
 
-       this.pushOper('setLineType', paras);
 
-     }
 
-     var from = this.$lineData[id].from;
 
-     var to = this.$lineData[id].to;
 
-     this.$lineData[id].type = newType;
 
-     var res;
 
-     
 
-     if (newType != 'sl') {
 
-       var res = GooFlow.prototype.calcPolyPoints(this.$nodeData[from], this.$nodeData[to], this.$lineData[id].type, this.$lineData[id].M);
 
-       if (M) {
 
-         this.setLineM(id, M, true);
 
-       } else {
 
-         this.setLineM(id, this.getMValue(this.$nodeData[from], this.$nodeData[to], newType), true);
 
-       }
 
-     }
 
-     
 
-     else {
 
-       delete this.$lineData[id].M;
 
-       this.$lineMove.hide().removeData('type').removeData('tid');
 
-       res = GooFlow.prototype.calcStartEnd(this.$nodeData[from], this.$nodeData[to]);
 
-       if (!res) return;
 
-       this.$draw.removeChild(this.$lineDom[id]);
 
-       this.$lineDom[id] = GooFlow.prototype.drawLine(id, res.start, res.end, this.$lineData[id].marked);
 
-       this.$draw.appendChild(this.$lineDom[id]);
 
-       if (GooFlow.prototype.useSVG == '') {
 
-         this.$lineDom[id].childNodes[1].innerHTML = this.$lineData[id].name;
 
-         this.$lineDom[id].childNodes[1].style.left =
 
-           ((res.end[0] - res.start[0]) * (res.end[0] > res.start[0] ? 1 : -1) - this.$lineDom[id].childNodes[1].offsetWidth) / 2 + 4;
 
-       } else {
 
-         this.$lineDom[id].childNodes[2].textContent = this.$lineData[id].name;
 
-       }
 
-     }
 
-     if (this.$focus == id) {
 
-       this.focusItem(id);
 
-     }
 
-     if (this.$editable) {
 
-       this.$lineData[id].alt = true;
 
-     }
 
-   },
 
-   
 
-   setLineM: function (id, M, noStack) {
 
-     if (!this.$lineData[id] || M < 0 || !this.$lineData[id].type || this.$lineData[id].type == 'sl') return false;
 
-     if (this.onLineMove != null && !this.onLineMove(id, M)) return false;
 
-     if (this.$undoStack && !noStack) {
 
-       var paras = [id, this.$lineData[id].M];
 
-       this.pushOper('setLineM', paras);
 
-     }
 
-     var from = this.$lineData[id].from;
 
-     var to = this.$lineData[id].to;
 
-     this.$lineData[id].M = M;
 
-     var ps = GooFlow.prototype.calcPolyPoints(this.$nodeData[from], this.$nodeData[to], this.$lineData[id].type, this.$lineData[id].M);
 
-     this.$draw.removeChild(this.$lineDom[id]);
 
-     this.$lineDom[id] = GooFlow.prototype.drawPoly(id, ps.start, ps.m1, ps.m2, ps.end, this.$lineData[id].marked);
 
-     this.$draw.appendChild(this.$lineDom[id]);
 
-     if (GooFlow.prototype.useSVG == '') {
 
-       this.$lineDom[id].childNodes[1].innerHTML = this.$lineData[id].name;
 
-       var Min = (ps.start[0] > ps.end[0] ? ps.end[0] : ps.start[0]);
 
-       if (Min > ps.m2[0]) Min = ps.m2[0];
 
-       if (Min > ps.m1[0]) Min = ps.m1[0];
 
-       this.$lineDom[id].childNodes[1].style.left = (ps.m2[0] + ps.m1[0]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetWidth / 2 + 4;
 
-       Min = (ps.start[1] > ps.end[1] ? ps.end[1] : ps.start[1]);
 
-       if (Min > ps.m2[1]) Min = ps.m2[1];
 
-       if (Min > ps.m1[1]) Min = ps.m1[1];
 
-       this.$lineDom[id].childNodes[1].style.top = (ps.m2[1] + ps.m1[1]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetHeight / 2 - 4;
 
-     } else this.$lineDom[id].childNodes[2].textContent = this.$lineData[id].name;
 
-     if (this.$editable) {
 
-       this.$lineData[id].alt = true;
 
-     }
 
-   },
 
-   
 
-   delLine: function (id, trigger) {
 
-     if (!this.$lineData[id]) return;
 
-     if (trigger != false && this.onItemDel != null && !this.onItemDel(id, 'node')) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$lineData[id]];
 
-       this.pushOper('addLine', paras);
 
-     }
 
-     this.$draw.removeChild(this.$lineDom[id]);
 
-     delete this.$lineData[id];
 
-     delete this.$lineDom[id];
 
-     if (this.$focus == id) this.$focus = '';
 
-     --this.$lineCount;
 
-     if (this.$editable) {
 
-       
 
-       if (id.indexOf(this.$id + '_line_') < 0) {
 
-         this.$deletedItem[id] = 'line';
 
-       }
 
-       this.$mpFrom.hide().removeData('p');
 
-       this.$mpTo.hide().removeData('p');
 
-     }
 
-     if (this.$lineOper) {
 
-       this.$lineOper.hide().removeData('tid');
 
-     }
 
-   },
 
-   
 
-   
 
-   moveLinePoints: function (lineId, newStart, newEnd, noStack) {
 
-     if (newStart == newEnd) return;
 
-     if (!lineId || !this.$lineData[lineId]) return;
 
-     if (newStart == null || newStart == '') {
 
-       newStart = this.$lineData[lineId].from;
 
-     }
 
-     if (newEnd == null || newEnd == '') {
 
-       newEnd = this.$lineData[lineId].to;
 
-     }
 
-     
 
-     for (var k in this.$lineData) {
 
-       if ((newStart == this.$lineData[k].from && newEnd == this.$lineData[k].to)) {
 
-         return;
 
-       }
 
-     }
 
-     if (this.onLinePointMove != null && !this.onLinePointMove(id, newStart, newEnd)) return;
 
-     if (this.$undoStack && !noStack) {
 
-       var paras = [lineId, this.$lineData[lineId].from, this.$lineData[lineId].to];
 
-       this.pushOper('moveLinePoints', paras);
 
-     }
 
-     if (newStart != null && newStart != '') {
 
-       this.$lineData[lineId].from = newStart;
 
-     }
 
-     if (newEnd != null && newEnd != '') {
 
-       this.$lineData[lineId].to = newEnd;
 
-     }
 
-     
 
-     this.$draw.removeChild(this.$lineDom[lineId]);
 
-     this.addLineDom(lineId, this.$lineData[lineId]);
 
-     if (this.$editable) {
 
-       this.$lineData[lineId].alt = true;
 
-     }
 
-   },
 
-   
 
-   
 
-   markItem: function (id, type, mark) {
 
-     if (type == 'node') {
 
-       if (!this.$nodeData[id]) return;
 
-       if (this.onItemMark != null && !this.onItemMark(id, 'node', mark)) return;
 
-       this.$nodeData[id].marked = mark || false;
 
-       if (mark) {
 
-         this.$nodeDom[id].addClass('item_mark').css('border-color', GooFlow.prototype.color.mark);
 
-       } else {
 
-         this.$nodeDom[id].removeClass('item_mark');
 
-         if (id != this.$focus) this.$nodeDom[id].css('border-color', 'transparent');
 
-       }
 
-     } else if (type == 'line') {
 
-       if (!this.$lineData[id]) return;
 
-       if (this.onItemMark != null && !this.onItemMark(id, 'line', mark)) return;
 
-       this.$lineData[id].marked = mark || false;
 
-       if (GooFlow.prototype.useSVG != '') {
 
-         if (mark) {
 
-           this.$lineDom[id].childNodes[1].setAttribute('stroke', GooFlow.prototype.color.mark || '#ff8800');
 
-           this.$lineDom[id].childNodes[1].setAttribute('marker-end', 'url(#arrow2)');
 
-           this.$lineDom[id].childNodes[1].setAttribute('stroke-width', 2.4);
 
-         } else {
 
-           this.$lineDom[id].childNodes[1].setAttribute('stroke', GooFlow.prototype.color.line || '#3892D3');
 
-           this.$lineDom[id].childNodes[1].setAttribute('marker-end', 'url(#arrow1)');
 
-           this.$lineDom[id].childNodes[1].setAttribute('stroke-width', 1.4);
 
-         }
 
-       } else {
 
-         if (mark) {
 
-           this.$lineDom[id].strokeColor = GooFlow.prototype.color.mark || '#ff8800';
 
-           this.$lineDom[id].strokeWeight = '2.4';
 
-         } else {
 
-           this.$lineDom[id].strokeColor = GooFlow.prototype.color.line || '#3892D3';
 
-           this.$lineDom[id].strokeWeight = '1.2';
 
-         }
 
-       }
 
-     }
 
-     if (this.$undoStatck) {
 
-       var paras = [id, type, !mark];
 
-       this.pushOper('markItem', paras);
 
-     }
 
-   },
 
-   
 
-   moveArea: function (id, left, top) {
 
-     if (!this.$areaData[id]) return;
 
-     if (this.onItemMove != null && !this.onItemMove(id, 'area', left, top)) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$areaData[id].left, this.$areaData[id].top];
 
-       this.pushOper('moveNode', paras);
 
-     }
 
-     if (left < 0) left = 0;
 
-     if (top < 0) top = 0;
 
-     $('#' + id).css({
 
-       left: left + 'px',
 
-       top: top + 'px'
 
-     });
 
-     this.$areaData[id].left = left;
 
-     this.$areaData[id].top = top;
 
-     if (this.$editable) {
 
-       this.$areaData[id].alt = true;
 
-     }
 
-   },
 
-   
 
-   delArea: function (id, trigger) {
 
-     if (!this.$areaData[id]) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$areaData[id]];
 
-       this.pushOper('addArea', paras);
 
-     }
 
-     if (trigger != false && this.onItemDel != null && !this.onItemDel(id, 'node')) return;
 
-     delete this.$areaData[id];
 
-     this.$areaDom[id].remove();
 
-     delete this.$areaDom[id];
 
-     --this.$areaCount;
 
-     if (this.$editable) {
 
-       
 
-       if (id.indexOf(this.$id + '_area_') < 0) {
 
-         this.$deletedItem[id] = 'area';
 
-       }
 
-     }
 
-   },
 
-   
 
-   setAreaColor: function (id, color) {
 
-     if (!this.$areaData[id]) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$areaData[id].color];
 
-       this.pushOper('setAreaColor', paras);
 
-     }
 
-     if (color == 'red' || color == 'yellow' || color == 'blue' || color == 'green') {
 
-       this.$areaDom[id].removeClass('area_' + this.$areaData[id].color).addClass('area_' + color);
 
-       this.$areaData[id].color = color;
 
-     }
 
-     if (this.$editable) {
 
-       this.$areaData[id].alt = true;
 
-     }
 
-   },
 
-   
 
-   resizeArea: function (id, width, height) {
 
-     if (!this.$areaData[id]) return;
 
-     if (this.onItemResize != null && !this.onItemResize(id, 'area', width, height)) return;
 
-     if (this.$undoStack) {
 
-       var paras = [id, this.$areaData[id].width, this.$areaData[id].height];
 
-       this.pushOper('resizeArea', paras);
 
-     }
 
-     this.$areaDom[id].children('.bg').css({
 
-       width: width + 'px',
 
-       height: height + 'px'
 
-     });
 
-     
 
-     
 
-     
 
-     this.$areaData[id].width = width;
 
-     this.$areaData[id].height = height;
 
-     if (this.$editable) {
 
-       this.$areaData[id].alt = true;
 
-     }
 
-   },
 
-   addArea: function (id, json) {
 
-     if (this.onItemAdd != null && !this.onItemAdd(id, 'area', json)) return;
 
-     if (this.$undoStack && this.$editable) {
 
-       this.pushOper('delArea', [id]);
 
-     }
 
-     this.$areaDom[id] = $("<div id='" + id + "' class='GooFlow_area area_" + json.color + "' style='top:" + json.top + 'px;left:' + json.left + "px'><div class='bg' style='width:" + (json.width) + 'px;height:' + (json.height) + "px'></div>" +
 
-       '<label>' + json.name + "</label><i></i><div><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
 
-     this.$areaData[id] = json;
 
-     this.$group.append(this.$areaDom[id]);
 
-     if (this.$nowType != 'group') this.$areaDom[id].children('div:eq(1)').css('display', 'none');
 
-     ++this.$areaCount;
 
-     if (this.$editable) {
 
-       this.$areaData[id].alt = true;
 
-       if (this.$deletedItem[id]) delete this.$deletedItem[id]; 
 
-     }
 
-   },
 
-   
 
-   reinitSize: function (width, height) {
 
-     var w = (width || 800);
 
-     var h = (height || 500);
 
-     this.$bgDiv.css({
 
-       height: h + 'px',
 
-       width: w + 'px'
 
-     });
 
-     var headHeight = 0,
 
-       hack = 8;
 
-     if (this.$head != null) {
 
-       headHeight = 26;
 
-       hack = 5;
 
-     }
 
-     if (this.$tool != null) {
 
-       this.$tool.css({
 
-         height: h - headHeight - hack + 'px'
 
-       });
 
-       w -= 31;
 
-     }
 
-     w -= 9;
 
-     h = h - headHeight - (this.$head != null ? 5 : 8);
 
-     this.$workArea.parent().css({
 
-       height: h + 'px',
 
-       width: w + 'px'
 
-     });
 
-     if (this.$workArea.width() > w) {
 
-       w = this.$workArea.width();
 
-     }
 
-     if (this.$workArea.height() > h) {
 
-       h = this.$workArea.height();
 
-     }
 
-     this.$workArea.css({
 
-       height: h + 'px',
 
-       width: w + 'px'
 
-     });
 
-     if (GooFlow.prototype.useSVG == '') {
 
-       this.$draw.coordsize = w + ',' + h;
 
-     }
 
-     this.$draw.style.width = w + 'px';
 
-     this.$draw.style.height = +h + 'px';
 
-     if (this.$group != null) {
 
-       this.$group.css({
 
-         height: h + 'px',
 
-         width: w + 'px'
 
-       });
 
-     }
 
-   }
 
- }
 
- GooFlow.prototype.color = {};
 
- jQuery.extend({
 
-   createGooFlow: function (bgDiv, property) {
 
-     return new GooFlow(bgDiv, property);
 
-   }
 
- });
 
 
  |