$Module.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.require("MWF.widget.Common", null, false);
  3. MWF.xDesktop.requireApp("process.FormDesigner", "Property", null, false);
  4. MWF.xApplication.process.FormDesigner.Module.$Module = MWF.FC$Module = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "actions": [
  10. {
  11. "name": "move",
  12. "icon": "move1.png",
  13. "event": "mousedown",
  14. "action": "move",
  15. "title": MWF.APPFD.LP.formAction.move
  16. },
  17. {
  18. "name": "copy",
  19. "icon": "copy1.png",
  20. "event": "mousedown",
  21. "action": "copy",
  22. "title": MWF.APPFD.LP.formAction.copy
  23. },
  24. {
  25. "name": "delete",
  26. "icon": "delete1.png",
  27. "event": "click",
  28. "action": "delete",
  29. "title": MWF.APPFD.LP.formAction["delete"]
  30. }
  31. // {
  32. // "name": "styleBrush",
  33. // "icon": "styleBrush.png",
  34. // "event": "click",
  35. // "action": "styleBrush",
  36. // "title": MWF.APPFD.LP.formAction["styleBrush"]
  37. // }
  38. ],
  39. "actionNodeStyles": {
  40. "width": "16px",
  41. "height": "16px",
  42. "margin-left": "2px",
  43. "margin-right": "2px",
  44. "float": "left",
  45. "border": "1px solid #F1F1F1",
  46. "cursor": "pointer"
  47. },
  48. "propertyPath": "/x_component_process_FormDesigner/Module/Label/label.html"
  49. },
  50. _getNewId: function(prefix, moduleName){
  51. var p = "";
  52. if (prefix){
  53. p = prefix+"_";
  54. }
  55. if (!moduleName) moduleName = this.moduleName;
  56. var idx = 1;
  57. var id = p+moduleName;
  58. var type = (this.json) ? this.json.type : this.moduleName.capitalize();
  59. while (this.form.checkModuleId(id, type).elementConflict){
  60. //while (this.form.json.moduleList[id]){
  61. id = p+moduleName+"_"+idx;
  62. idx++;
  63. }
  64. return id;
  65. },
  66. load : function(json, node, parent){
  67. this.json = json;
  68. this.node= node;
  69. this.node.store("module", this);
  70. this.node.setStyles(this.css.moduleNode);
  71. this._loadNodeStyles();
  72. this._loadTreeNode(parent);
  73. this.parentContainer = this.treeNode.parentNode.module;
  74. this._initModule();
  75. this._setEditStyle_custom("id");
  76. this.json.moduleName = this.moduleName;
  77. },
  78. _loadNodeStyles: function(){
  79. },
  80. _loadNodeCustomStyles: function(){
  81. this.setCustomStyles();
  82. },
  83. _loadTreeNode: function(parent){
  84. var title = this.json.name || this.json.id;
  85. var text = "";
  86. if (this.json.type==="Common"){
  87. text = this.json.tagName+"(Common)";
  88. }else{
  89. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  90. }
  91. var o = {
  92. "expand": true,
  93. "title": this.json.id,
  94. "text": "<"+text+"> "+title,
  95. "icon": ""
  96. };
  97. o.action = function(){
  98. if (this.module) this.module.selected();
  99. };
  100. if (this.nextModule){
  101. this.treeNode = this.nextModule.treeNode.insertChild(o);
  102. }else{
  103. this.treeNode = parent.treeNode.appendChild(o);
  104. }
  105. this.treeNode.module = this;
  106. },
  107. copyStyles: function(from, to){
  108. if (!this.json[to]) this.json[to] = {};
  109. Object.each(from, function(style, key){
  110. //if (!this.json[to][key])
  111. this.json[to][key] = style;
  112. }.bind(this));
  113. },
  114. removeStyles: function(from, to){
  115. if (this.json[to]){
  116. Object.each(from, function(style, key){
  117. if (this.json[to][key] && this.json[to][key]==style){
  118. delete this.json[to][key];
  119. }
  120. //if (this.json[from][key]){
  121. // delete this.json[to][key];
  122. //}
  123. }.bind(this));
  124. }
  125. },
  126. setTemplateStyles: function(styles){
  127. if (styles.styles) this.copyStyles(styles.styles, "styles");
  128. if (styles.properties) this.copyStyles(styles.properties, "properties");
  129. },
  130. clearTemplateStyles: function(styles){
  131. if (styles){
  132. if (styles.styles) this.removeStyles(styles.styles, "styles");
  133. if (styles.properties) this.removeStyles(styles.properties, "properties");
  134. }
  135. },
  136. setStyleTemplate: function(){
  137. if (this.form.stylesList){
  138. if (this.form.json.formStyleType){
  139. if (this.form.stylesList[this.form.json.formStyleType]){
  140. if (this.form.stylesList[this.form.json.formStyleType][this.moduleName]){
  141. this.setTemplateStyles(this.form.stylesList[this.form.json.formStyleType][this.moduleName]);
  142. }
  143. }
  144. }
  145. }
  146. },
  147. setAllStyles: function(){
  148. this.setPropertiesOrStyles("styles");
  149. this.setPropertiesOrStyles("inputStyles");
  150. this.setPropertiesOrStyles("properties");
  151. this.reloadMaplist();
  152. },
  153. _initModule: function(){
  154. if (!this.json.isSaved) this.setStyleTemplate();
  155. this.setPropertiesOrStyles("styles");
  156. this.setPropertiesOrStyles("inputStyles");
  157. this.setPropertiesOrStyles("properties");
  158. this._setNodeProperty();
  159. if (!this.form.isSubform) this._createIconAction();
  160. this._setNodeEvent();
  161. this.json.isSaved = true;
  162. },
  163. _setNodeProperty: function(){},
  164. _createIconAction: function(){
  165. if (!this.actionArea){
  166. this.actionArea = new Element("div", {
  167. styles: {
  168. "display": "none",
  169. // "width": 18*this.options.actions.length,
  170. "position": "absolute",
  171. "background-color": "#F1F1F1",
  172. "padding": "1px",
  173. "padding-right": "0px",
  174. "border": "1px solid #AAA",
  175. "box-shadow": "0px 2px 5px #999",
  176. "opacity": 1,
  177. "z-index": 100
  178. }
  179. }).inject(this.form.container, "after");
  180. this.options.actions.each(function(action){
  181. var actionNode = new Element("div", {
  182. "styles": this.options.actionNodeStyles,
  183. "title": action.title
  184. }).inject(this.actionArea);
  185. actionNode.setStyle("background", "url("+this.path+this.options.style+"/icon/"+action.icon+") no-repeat left center");
  186. actionNode.addEvent(action.event, function(e){
  187. this[action.action](e);
  188. }.bind(this));
  189. actionNode.addEvents({
  190. "mouseover": function(e){
  191. e.target.setStyle("border", "1px solid #999");
  192. }.bind(this),
  193. "mouseout": function(e){
  194. e.target.setStyle("border", "1px solid #F1F1F1");
  195. }.bind(this)
  196. });
  197. }.bind(this));
  198. this._createCustomIconAction();
  199. }
  200. },
  201. _createCustomIconAction: function(){},
  202. _setActionAreaPosition: function(){
  203. var p = this.node.getPosition(this.form.node.getOffsetParent());
  204. var y = p.y-25;
  205. var x = p.x;
  206. this.actionArea.setPosition({"x": x, "y": y});
  207. },
  208. _moveTo: function(container){
  209. this.parentContainer = container;
  210. if (!this.node){
  211. this._createNode();
  212. }
  213. this._resetTreeNode();
  214. this.node.inject(container.node);
  215. },
  216. move: function(e){
  217. this._createMoveNode();
  218. var thisDisplay = this.node.getStyle("display");
  219. this.node.store("thisDisplay", thisDisplay);
  220. this.node.setStyle("display", "none");
  221. this._setNodeMove(e);
  222. },
  223. copy: function(e){
  224. this.copyTo().move(e);
  225. },
  226. copyTo: function(node){
  227. if (!node) node = this.form;
  228. var newNode = this.node.clone(true, true);
  229. var newModuleJson = Object.clone(this.json);
  230. newNode.inject(node.node);
  231. var className = this.moduleName.capitalize();
  232. var prefix = (this.form.moduleType=="page") ? "PC" : "FC";
  233. var newTool = new MWF[prefix+className](this.form);
  234. newTool.json = newModuleJson;
  235. newModuleJson.id = newTool._getNewId();
  236. newNode.set("id", newModuleJson.id);
  237. this.form.json.moduleList[newModuleJson.id] = newModuleJson;
  238. if (this.form.scriptDesigner) this.form.scriptDesigner.createModuleScript(newModuleJson);
  239. newTool.load(newModuleJson, newNode, node);
  240. return newTool;
  241. },
  242. "delete": function(e){
  243. var module = this;
  244. this.form.designer.shortcut = false;
  245. this.form.designer.confirm("warn", module.node, MWF.APPFD.LP.notice.deleteElementTitle, MWF.APPFD.LP.notice.deleteElement, 300, 120, function(){
  246. module.form.selected();
  247. module.form.designer.shortcut = true;
  248. module.destroy();
  249. this.close();
  250. }, function(){
  251. module.form.designer.shortcut = true;
  252. this.close();
  253. }, null);
  254. },
  255. styleBrush: function(){
  256. //@todo
  257. this.form.styleBrushContent = Object.clone(this.json.style);
  258. },
  259. _setNodeEvent: function(){
  260. if (this.form.moduleType!="subform"){
  261. if (!this.isSetEvents){
  262. this.node.addEvent("click", function(e){
  263. if (!this.form.noSelected) this.selected();
  264. this.form.noSelected = false;
  265. e.stopPropagation();
  266. }.bind(this));
  267. this.node.addEvent("mouseover", function(e){
  268. this.over();
  269. e.stopPropagation();
  270. }.bind(this));
  271. this.node.addEvent("mouseout", function(e){
  272. this.unOver();
  273. e.stopPropagation();
  274. }.bind(this));
  275. this.node.addEvent("copy", function(e){
  276. this.copyModule(e);
  277. });
  278. this._setOtherNodeEvent();
  279. this.isSetEvents = true;
  280. }
  281. }
  282. },
  283. copyModule: function(e){
  284. },
  285. _setOtherNodeEvent: function(){},
  286. over: function(){
  287. if (!this.form.moveModule) if (this.form.currentSelectedModule!=this){
  288. this.node.store("normalBorder", this.node.getBorder());
  289. this.node.setStyles({
  290. "border-width": "1px",
  291. "border-color": "#4e73ff"
  292. });
  293. }
  294. },
  295. unOver: function(){
  296. if (!this.form.moveModule) if (this.form.currentSelectedModule!=this){
  297. this.node.setStyles({
  298. "border-width": "1px",
  299. "border-color": "#333"
  300. });
  301. var border = this.node.retrieve("normalBorder");
  302. this.node.setStyles(border);
  303. }
  304. },
  305. _showActions: function(){
  306. if (this.actionArea){
  307. if (this.options.actions.length){
  308. this._setActionAreaPosition();
  309. this.actionArea.setStyle("display", "block");
  310. }
  311. }
  312. },
  313. _hideActions: function(){
  314. if (this.actionArea) this.actionArea.setStyle("display", "none");
  315. },
  316. selected: function(){
  317. if (this.form.currentSelectedModule){
  318. if (this.form.currentSelectedModule==this){
  319. return true;
  320. }else{
  321. this.form.currentSelectedModule.unSelected();
  322. }
  323. }
  324. if (this.form.propertyMultiTd){
  325. this.form.propertyMultiTd.hide();
  326. this.form.propertyMultiTd = null;
  327. }
  328. this.form.unSelectedMulti();
  329. this.node.setStyles({
  330. "border-width": "1px",
  331. "border-color": "red"
  332. });
  333. this._showActions();
  334. this.form.currentSelectedModule = this;
  335. if (this.treeNode){
  336. this.treeNode.selectNode();
  337. (new Fx.Scroll(this.form.designer.propertyDomScrollArea)).toElement(this.treeNode.node);
  338. // this.treeNode.node.scrollIntoView();
  339. }
  340. if (this.form.brushStyle){
  341. this.json.styles = Object.clone(this.form.brushStyle);
  342. this.setPropertiesOrStyles("styles");
  343. if (this.property) this.property.loadMaplist();
  344. }
  345. this.showProperty();
  346. },
  347. unSelected: function(){
  348. this.node.setStyles({
  349. "border-width": "1px",
  350. "border-color": "#333"
  351. });
  352. var border = this.node.retrieve("normalBorder");
  353. this.node.setStyles(border);
  354. this._hideActions();
  355. this.form.currentSelectedModule = null;
  356. this.hideProperty();
  357. },
  358. selectedMulti: function(){
  359. if (this.form.selectedModules.indexOf(this)==-1){
  360. this.form.selectedModules.push(this);
  361. this.node.setStyle("border-color", "red");
  362. }
  363. },
  364. unSelectedMulti: function(){
  365. if (this.form.selectedModules.indexOf(this)!=-1){
  366. this.form.selectedModules.erase(this);
  367. this.node.setStyle("border-color", "#333");
  368. }
  369. },
  370. showProperty: function(){
  371. if (!this.property){
  372. this.property = new MWF.xApplication.process.FormDesigner.Property(this, this.form.designer.propertyContentArea, this.form.designer, {
  373. "path": this.options.propertyPath,
  374. "onPostLoad": function(){
  375. this.property.show();
  376. }.bind(this)
  377. });
  378. this.property.load();
  379. }else{
  380. this.property.show();
  381. }
  382. },
  383. hideProperty: function(){
  384. if (this.property) this.property.hide();
  385. },
  386. create: function(data, e){
  387. this.json = data;
  388. this.json.id = this._getNewId();
  389. this._createMoveNode();
  390. this._setNodeMove(e);
  391. },
  392. _createMoveNode: function(){
  393. this.moveNode = new Element("div", {
  394. "MWFType": "label",
  395. "styles": this.css.moduleNodeMove,
  396. "text": "Text",
  397. "events": {
  398. "selectstart": function(){
  399. return false;
  400. }
  401. }
  402. }).inject(this.form.container);
  403. },
  404. _onEnterOther: function(dragging, inObj){
  405. },
  406. _onLeaveOther: function(dragging, inObj){
  407. },
  408. _onMoveEnter: function(dragging, inObj){
  409. var module = inObj.retrieve("module");
  410. if (module) module._dragIn(this);
  411. this._onEnterOther(dragging, inObj);
  412. },
  413. _setNodeMove: function(e){
  414. this._setMoveNodePosition(e);
  415. var droppables = [this.form.node].concat(this.form.moduleElementNodeList, this.form.moduleContainerNodeList, this.form.moduleComponentNodeList);
  416. var nodeDrag = new Drag.Move(this.moveNode, {
  417. "droppables": droppables,
  418. "onEnter": function(dragging, inObj){
  419. this._onMoveEnter(dragging, inObj);
  420. }.bind(this),
  421. "onLeave": function(dragging, inObj){
  422. var module = inObj.retrieve("module");
  423. if (module) module._dragOut(this);
  424. this._onLeaveOther(dragging, inObj);
  425. }.bind(this),
  426. "onDrag": function(e){
  427. this._nodeDrag(e, nodeDrag);
  428. }.bind(this),
  429. "onDrop": function(dragging, inObj){
  430. if (inObj){
  431. var module = inObj.retrieve("module");
  432. if (module) module._dragDrop(this);
  433. this._nodeDrop();
  434. }else{
  435. this._dragCancel(dragging);
  436. }
  437. }.bind(this),
  438. "onCancel": function(dragging){
  439. this._dragCancel(dragging);
  440. }.bind(this)
  441. });
  442. nodeDrag.start(e);
  443. this.form.moveModule = this;
  444. this.form.recordCurrentSelectedModule = this.form.currentSelectedModule;
  445. // var d = (new Date()).getTime();
  446. this.form.selected();
  447. //var d1 = (new Date()).getTime();
  448. //alert((d1-d))
  449. },
  450. _setMoveNodePosition: function(e){
  451. // var x = e.event.clientX+2;
  452. // var y = e.event.clientY+2;
  453. var x = e.page.x+2;
  454. var y = e.page.y+2;
  455. this.moveNode.positionTo(x, y);
  456. // this.moveNode.setStyles({
  457. // "top": y,
  458. // "left": x
  459. // });
  460. },
  461. _getCopyNode: function(module){
  462. if (!this.copyNode) this._createCopyNode();
  463. this.copyNode.setStyles(this.css.moduleNodeShow);
  464. this.copyNode.empty();
  465. if (module){
  466. try{
  467. var display = module.node.getStyle("display").toString().toLowerCase();
  468. this.copyNode.setStyle("display", display);
  469. if (display==="inline" || display==="inline-block"){
  470. var h = module.node.getSize().y-2;
  471. this.copyNode.setStyle("height", ""+h+"px");
  472. //this.copyNode.setStyle("display", "inline");
  473. }
  474. }catch(e){}
  475. }
  476. // this.copyNode.setStyle("display", "block");
  477. return this.copyNode;
  478. },
  479. _createCopyNode: function(){
  480. this.copyNode = this.moveNode.clone();
  481. this.copyNode.setStyles(this.css.moduleNodeShow);
  482. this.copyNode.addEvent("selectstart", function(){
  483. return false;
  484. });
  485. },
  486. _nodeDrop: function(){
  487. if (this.parentContainer){
  488. this._dragComplete();
  489. }else{
  490. this._dragCancel();
  491. }
  492. },
  493. _dragComplete: function(){
  494. this.setStyleTemplate();
  495. if (!this.node){
  496. this._createNode();
  497. }
  498. this._resetTreeNode();
  499. this.node.inject(this.copyNode, "before");
  500. this._initModule();
  501. var thisDisplay = this.node.retrieve("thisDisplay");
  502. if (thisDisplay){
  503. this.node.setStyle("display", thisDisplay);
  504. }
  505. if (this.copyNode) this.copyNode.destroy();
  506. if (this.moveNode) this.moveNode.destroy();
  507. this.moveNode = null;
  508. this.copyNode = null;
  509. this.nextModule = null;
  510. this.form.moveModule = null;
  511. this.form.json.moduleList[this.json.id] = this.json;
  512. if (this.form.scriptDesigner) this.form.scriptDesigner.createModuleScript(this.json);
  513. this.selected();
  514. },
  515. _resetTreeNode: function(){
  516. if (this.parentContainer){
  517. if (this.treeNode){
  518. if (this.treeNode.parentNode){
  519. var originalModule = this.treeNode.parentNode.module;
  520. // if (originalModule == this.parentContainer){
  521. // if (!this.nextModule) return true;
  522. // };
  523. }
  524. this.treeNode.destroy();
  525. }
  526. this._loadTreeNode(this.parentContainer);
  527. if (this.treeNode.parentNode){
  528. if (!this.treeNode.parentNode.options.expand) this.treeNode.parentNode.expandOrCollapse();
  529. }
  530. this._resetSubTreeNode(this.node)
  531. }
  532. },
  533. _resetSubTreeNode: function(node){
  534. var subNode = node.getFirst();
  535. while (subNode){
  536. var module = subNode.retrieve("module");
  537. if (module) module._resetTreeNode();
  538. this._resetSubTreeNode(subNode);
  539. subNode = subNode.getNext();
  540. }
  541. },
  542. _createNode: function(){
  543. this.node = this.moveNode.clone(true, true);
  544. this.node.clearStyles(false);
  545. this.node.setStyles(this.css.moduleNode);
  546. this.node.set("id", this.json.id);
  547. this.node.addEvent("selectstart", function(){
  548. return false;
  549. });
  550. },
  551. _dragCancel: function(){
  552. if (this.node){
  553. var thisDisplay = this.node.retrieve("thisDisplay");
  554. if (thisDisplay){
  555. this.node.setStyle("display", thisDisplay);
  556. }
  557. this.selected();
  558. }else{
  559. this.data = null;
  560. if (this.form.recordCurrentSelectedModule) this.form.recordCurrentSelectedModule.selected();
  561. }
  562. if (this.moveNode) this.moveNode.destroy();
  563. if (this.copyNode) this.copyNode.destroy();
  564. this.copyNode = null;
  565. this.moveNode = null;
  566. this.form.moveModule = null;
  567. },
  568. _nodeDrag: function(e, drag){
  569. if (this.inContainer){
  570. var p = this.inContainer.node.getCoordinates();
  571. var now = drag.mouse.now;
  572. var height = p.height*0.4;
  573. if (p.height>200) height = 100;
  574. var y = p.top.toFloat()+height.toFloat();
  575. if (this.inContainer == this.parentContainer){
  576. if (this.parentContainer!=this.form){
  577. if (now.x > p.left && now.x < p.right && now.y < y && now.y > p.top){
  578. this.parentContainer.node.setStyles(this.parentContainer.css.moduleNode);
  579. this.parentContainer.node.setStyles(this.parentContainer.json.styles);
  580. this.parentContainer._dragInLikeElement(this);
  581. }
  582. }
  583. }else{
  584. if (now.x > p.left && now.x < p.right && now.y < p.bottom && now.y > y){
  585. this.parentContainer.node.setStyles(this.parentContainer.css.moduleNode);
  586. this.parentContainer.node.setStyles(this.parentContainer.json.styles);
  587. this.inContainer._dragIn(this);
  588. }
  589. }
  590. }
  591. },
  592. setPropertiesOrStyles: function(name){
  593. if (name=="styles"){
  594. try{
  595. this.setCustomStyles();
  596. }catch(e){}
  597. }
  598. if (name=="properties"){
  599. try{
  600. this.node.setProperties(this.json.properties);
  601. }catch(e){}
  602. }
  603. },
  604. setCustomNodeStyles: function(node, styles){
  605. var border = node.getStyle("border");
  606. node.clearStyles();
  607. //node.setStyles(styles);
  608. node.setStyle("border", border);
  609. Object.each(styles, function(value, key){
  610. var reg = /^border\w*/ig;
  611. if (!key.test(reg)){
  612. node.setStyle(key, value);
  613. }
  614. }.bind(this));
  615. },
  616. setCustomStyles: function(){
  617. var border = this.node.getStyle("border");
  618. this.node.clearStyles();
  619. this.node.setStyles(this.css.moduleNode);
  620. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  621. this.node.setStyle("border", border);
  622. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  623. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  624. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  625. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  626. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  627. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  628. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  629. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  630. }
  631. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  632. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  633. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  634. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  635. }
  636. }
  637. var reg = /^border\w*/ig;
  638. if (!key.test(reg)){
  639. if (key){
  640. if (key.toString().toLowerCase()==="display"){
  641. if (value.toString().toLowerCase()==="none"){
  642. this.node.setStyle("opacity", 0.3);
  643. }else{
  644. this.node.setStyle("opacity", 1);
  645. this.node.setStyle(key, value);
  646. }
  647. }else{
  648. this.node.setStyle(key, value);
  649. }
  650. }
  651. }
  652. //this.node.setStyle(key, value);
  653. }.bind(this));
  654. // Object.each(this.json.styles, function(value, key){
  655. // var reg = /^border\w*/ig;
  656. // if (!key.test(reg)){
  657. // if (key){
  658. // if (key.toString().toLowerCase()==="display"){
  659. // if (value.toString().toLowerCase()==="none"){
  660. // this.node.setStyle("opacity", 0.3);
  661. // }else{
  662. // this.node.setStyle("opacity", 1);
  663. // }
  664. // }else{
  665. // this.node.setStyle(key, value);
  666. // }
  667. // }
  668. // }
  669. // }.bind(this));
  670. },
  671. _setEditStyle: function(name, obj, oldValue){
  672. var title = "";
  673. var text = "";
  674. if (name==="name"){
  675. title = this.json.name || this.json.id;
  676. if (this.json.type==="Common"){
  677. text = text = this.json.tagName+"(Common)";
  678. }else{
  679. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  680. }
  681. this.treeNode.setText("<"+text+"> "+title);
  682. }
  683. if (name==="id"){
  684. title = this.json.name || this.json.id;
  685. if (!this.json.name){
  686. if (this.json.type==="Common"){
  687. text = text = this.json.tagName+"(Common)";
  688. }else{
  689. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  690. }
  691. this.treeNode.setText("<"+text+"> "+this.json.id);
  692. }
  693. this.treeNode.setTitle(this.json.id);
  694. this.node.set("id", this.json.id);
  695. }
  696. this._setEditStyle_custom(name, obj, oldValue);
  697. },
  698. reloadMaplist: function(){
  699. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  700. },
  701. _setEditStyle_custom: function(name, obj, oldValue){
  702. },
  703. getHtml: function(){
  704. var copy = this.node.clone(true, true);
  705. copy.clearStyles(true);
  706. this.form._clearNoId(copy);
  707. var html = copy.outerHTML;
  708. copy.destroy();
  709. return html;
  710. },
  711. _getSubModuleJson: function(node, moduleJsons){
  712. var subNode = node.getFirst();
  713. while (subNode){
  714. var module = subNode.retrieve("module");
  715. if (module) {
  716. moduleJsons[module.json.id] = Object.clone(module.json);
  717. }
  718. this._getSubModuleJson(subNode, moduleJsons);
  719. subNode = subNode.getNext();
  720. }
  721. },
  722. getJson: function(){
  723. var json = Object.clone(this.json);
  724. var o = {};
  725. o[json.id] = json;
  726. this._getSubModuleJson(this.node, o);
  727. return o;
  728. }
  729. // dragInElement: function(dragging, inObj, module){
  730. // this.containerNode = module.containerNode;
  731. //
  732. // // var border = this.containerNode.retrieve("thisborder", null);
  733. // // if (!border){
  734. // var top = this.containerNode.getStyle("border-top");
  735. // var left = this.containerNode.getStyle("border-left");
  736. // var bottom = this.containerNode.getStyle("border-bottom");
  737. // var right = this.containerNode.getStyle("border-right");
  738. //
  739. // this.containerNode.store("thisborder", {"top": top, "left": left, "bottom": bottom, "right": right});
  740. // // }
  741. // this.containerNode.setStyles({"border": "1px solid #ffa200"});
  742. //
  743. // if (!this.copyNode) this.createCopyNode(dragging, inObj);
  744. // this.copyNode.inject(inObj, "before");
  745. // },
  746. // dragInContainer: function(dragging, inObj){
  747. // // var border = inObj.retrieve("thisborder", null);
  748. // // if (!border){
  749. // var top = inObj.getStyle("border-top");
  750. // var left = inObj.getStyle("border-left");
  751. // var bottom = inObj.getStyle("border-bottom");
  752. // var right = inObj.getStyle("border-right");
  753. // inObj.store("thisborder", {"top": top, "left": left, "bottom": bottom, "right": right});
  754. // // }
  755. //
  756. // inObj.setStyles({"border": "1px solid #ffa200"});
  757. //
  758. // if (!this.copyNode) this.createCopyNode(dragging, inObj);
  759. //
  760. // this.copyNode.inject(inObj);
  761. //
  762. // this.containerNode = inObj;
  763. // },
  764. //
  765. //
  766. // dragOutElement: function(dragging, inObj){
  767. // var border = this.containerNode.retrieve("thisborder");
  768. // if (border) {
  769. // this.containerNode.setStyles({
  770. // "border-top": border.top,
  771. // "border-left": border.left,
  772. // "border-bottom": border.bottom,
  773. // "border-right": border.right
  774. // });
  775. // }
  776. // this.containerNode = null;
  777. // },
  778. // dragOutContainer: function(dragging, inObj){
  779. // var border = inObj.retrieve("thisborder");
  780. // if (border) {
  781. // inObj.setStyles({
  782. // "border-top": border.top,
  783. // "border-left": border.left,
  784. // "border-bottom": border.bottom,
  785. // "border-right": border.right
  786. // });
  787. // // inObj.setStyles({"border": border});
  788. // }
  789. // if (!this.node){
  790. // if (this.copyNode){
  791. // this.copyNode.destroy();
  792. // this.copyNode = null;
  793. // }
  794. // }
  795. // this.containerNode = null;
  796. // },
  797. //
  798. //
  799. //
  800. //
  801. // dragCancel: function(dragging){
  802. // if (this.node){
  803. // var thisDisplay = this.node.retrieve("thisDisplay");
  804. // if (thisDisplay){
  805. // this.node.setStyle("display", thisDisplay);
  806. // }
  807. // this.selected();
  808. // }else{
  809. // this.data = null;
  810. // if (this.form.recordCurrentSelectedModule) this.form.recordCurrentSelectedModule.selected();
  811. // }
  812. // if (dragging) dragging.destroy();
  813. // if (this.copyNode) this.copyNode.destroy();
  814. // this.copyNode = null;
  815. // this.moveNode = null;
  816. // this.form.moveModule = null;
  817. // }
  818. });