$Module.js 23 KB

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