Page.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. MWF.xApplication.portal.PageDesigner.Module = MWF.xApplication.portal.PageDesigner.Module || {};
  2. MWF.require("MWF.widget.Common", null, false);
  3. MWF.xApplication.portal.PageDesigner.Module.Page = MWF.PCPage = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_portal_PageDesigner/Module/Page/page.html",
  9. "mode": "PC",
  10. "fields": ["Calendar", "Checkbox", "Datagrid", "Datagrid$Title", "Datagrid$Data", "Htmleditor", "Number", "Office", "Orgfield", "Personfield", "Radio", "Select", "Textarea", "Textfield"]
  11. },
  12. initializeBase: function(options){
  13. this.setOptions(options);
  14. this.path = "/x_component_portal_PageDesigner/Module/Page/";
  15. this.cssPath = "/x_component_portal_PageDesigner/Module/Page/"+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. },
  18. initialize: function(designer, container, options){
  19. this.initializeBase(options);
  20. this.container = null;
  21. this.page = this;
  22. this.form = this;
  23. this.moduleType = "page";
  24. this.moduleList = [];
  25. this.moduleNodeList = [];
  26. this.moduleContainerNodeList = [];
  27. this.moduleElementNodeList = [];
  28. this.moduleComponentNodeList = [];
  29. // this.moduleContainerList = [];
  30. this.dataTemplate = {};
  31. this.designer = designer;
  32. this.container = container;
  33. this.selectedModules = [];
  34. },
  35. reload: function(data){
  36. this.moduleList.each(function(module){
  37. if (module.property){
  38. module.property.destroy();
  39. }
  40. }.bind(this));
  41. if (this.property) this.property.destroy();
  42. this.property = null;
  43. this.moduleList = [];
  44. this.moduleNodeList = [];
  45. this.moduleContainerNodeList = [];
  46. this.moduleElementNodeList = [];
  47. this.moduleComponentNodeList = [];
  48. this.dataTemplate = {};
  49. this.selectedModules = [];
  50. this.container.empty();
  51. if (this.treeNode){
  52. this.domTree.empty();
  53. this.domTree.node.destroy();
  54. this.domTree = null;
  55. this.treeNode = null;
  56. }
  57. this.currentSelectedModule = null;
  58. this.propertyMultiTd = null;
  59. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  60. this.load(data);
  61. },
  62. load : function(data){
  63. this.data = data;
  64. this.json = data.json;
  65. this.html = data.html;
  66. this.json.mode = this.options.mode;
  67. this.isNewPage = (this.json.id) ? false : true;
  68. if (this.isNewPage) this.checkUUID();
  69. if(this.designer.application) this.data.json.applicationName = this.designer.application.name;
  70. if(this.designer.application) this.data.json.application = this.designer.application.id;
  71. this.container.set("html", this.html);
  72. this.loadStylesList(function(){
  73. var oldStyleValue = "";
  74. if ((!this.json.pageStyleType) || !this.stylesList[this.json.pageStyleType]) this.json.pageStyleType="blue-simple";
  75. if (this.options.mode=="Mobile"){
  76. if (this.json.pageStyleType != "defaultMobile"){
  77. oldStyleValue = this.json.pageStyleType;
  78. this.json.pageStyleType = "defaultMobile";
  79. }
  80. }
  81. this.templateStyles = (this.stylesList && this.json.pageStyleType) ? this.stylesList[this.json.pageStyleType] : null;
  82. this.loadDomModules();
  83. if (this.json.pageStyleType){
  84. if (this.stylesList[this.json.pageStyleType]){
  85. if (this.stylesList[this.json.pageStyleType]["page"]){
  86. this.setTemplateStyles(this.stylesList[this.json.pageStyleType]["page"]);
  87. }
  88. }
  89. }
  90. this.setCustomStyles();
  91. this.node.setProperties(this.json.properties);
  92. this.setNodeEvents();
  93. if (this.options.mode=="Mobile"){
  94. if (oldStyleValue) this._setEditStyle("pageStyleType", null, oldStyleValue);
  95. }
  96. this.selected();
  97. this.autoSave();
  98. this.designer.addEvent("queryClose", function(){
  99. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  100. }.bind(this));
  101. }.bind(this));
  102. },
  103. removeStyles: function(from, to){
  104. if (this.json[to]){
  105. Object.each(from, function(style, key){
  106. if (this.json[to][key] && this.json[to][key]==style){
  107. delete this.json[to][key];
  108. }
  109. }.bind(this));
  110. }
  111. },
  112. copyStyles: function(from, to){
  113. if (!this.json[to]) this.json[to] = {};
  114. Object.each(from, function(style, key){
  115. if (!this.json[to][key]) this.json[to][key] = style;
  116. }.bind(this));
  117. },
  118. clearTemplateStyles: function(styles){
  119. if (styles){
  120. if (styles.styles) this.removeStyles(styles.styles, "styles");
  121. if (styles.properties) this.removeStyles(styles.properties, "properties");
  122. }
  123. },
  124. setTemplateStyles: function(styles){
  125. if (styles.styles) this.copyStyles(styles.styles, "styles");
  126. if (styles.properties) this.copyStyles(styles.properties, "properties");
  127. },
  128. loadStylesList: function(callback){
  129. var stylesUrl = "/x_component_portal_PageDesigner/Module/Page/template/"+((this.options.mode=="Mobile") ? "styles": "styles")+".json";
  130. MWF.getJSON(stylesUrl,{
  131. "onSuccess": function(responseJSON){
  132. this.stylesList= responseJSON;
  133. if (callback) callback(this.stylesList);
  134. }.bind(this),
  135. "onRequestFailure": function(){
  136. this.stylesList = {};
  137. if (callback) callback(this.stylesList);
  138. }.bind(this),
  139. "onError": function(){
  140. this.stylesList = {};
  141. if (callback) callback(this.stylesList);
  142. }.bind(this)
  143. }
  144. );
  145. },
  146. autoSave: function(){
  147. this.autoSaveCheckNode = this.designer.pageToolbarNode.getElement("#MWFPageAutoSaveCheck");
  148. if (this.autoSaveCheckNode){
  149. this.autoSaveTimerID = window.setInterval(function(){
  150. if (this.autoSaveCheckNode.get("checked")){
  151. this.save();
  152. }
  153. }.bind(this), 60000);
  154. }
  155. },
  156. checkUUID: function(){
  157. this.designer.actions.getUUID(function(id){
  158. this.json.id = id;
  159. }.bind(this));
  160. },
  161. loadDomModules: function(){
  162. this.node = this.container.getFirst();
  163. this.node.set("id", this.json.id);
  164. this.node.setStyles(this.css.pageNode);
  165. this.node.store("module", this);
  166. var y = this.container.getSize().y-2;
  167. this.node.setStyle("min-height", ""+y+"px");
  168. this.designer.addEvent("resize", function(){
  169. var y = this.container.getSize().y-2;
  170. this.node.setStyle("min-height", ""+y+"px");
  171. }.bind(this));
  172. this.loadDomTree();
  173. },
  174. loadDomTree: function(){
  175. MWF.require("MWF.widget.Tree", function(){
  176. this.domTree = new MWF.widget.Tree(this.designer.propertyDomArea, {"style": "domtree"});
  177. this.domTree.load();
  178. this.createPageTreeNode();
  179. this.parseModules(this, this.node);
  180. }.bind(this));
  181. },
  182. createPageTreeNode: function(){
  183. var text = "<"+this.json.type+"> "+this.json.name+" ["+this.options.mode+"] ";
  184. var o = {
  185. "expand": true,
  186. "title": this.json.id,
  187. "text": "<"+this.json.type+"> "+this.json.name+" ["+this.options.mode+"] ",
  188. "icon": (this.options.mode=="Mobile") ? "mobile.png": "pc.png"
  189. };
  190. o.action = function(){
  191. if (this.module) this.module.selected();
  192. };
  193. this.treeNode = this.domTree.appendChild(o);
  194. this.treeNode.setText(text);
  195. this.treeNode.module = this;
  196. },
  197. parseModules: function(parent, dom){
  198. var tmpDom = null;
  199. var subDom = dom.getFirst();
  200. while (subDom){
  201. if (subDom.get("MWFtype")){
  202. // var module = subDom.retrieve("module");
  203. // alert(subDom.get("id")+": "+module);
  204. // if (!module){
  205. var json = this.getDomjson(subDom);
  206. if (json) module = this.loadModule(json, subDom, parent);
  207. // }
  208. // if (module.moduleType=="container") this.parseModules(module, subDom);
  209. // }else{
  210. // this.parseModules(parent, subDom);
  211. }
  212. // else if (subDom.getFirst()){
  213. // subDom = subDom.getFirst();
  214. // this.parseModules(parent, subDom);
  215. // }else{
  216. // subDom = subDom.getNext();
  217. // }
  218. if (!json) tmpDom = subDom;
  219. subDom = subDom.getNext();
  220. if (tmpDom){
  221. tmpDom.destroy();
  222. tmpDom = null;
  223. }
  224. }
  225. },
  226. getDomjson: function(dom){
  227. var mwfType = dom.get("MWFtype");
  228. switch (mwfType) {
  229. case "page":
  230. return this.json;
  231. case "":
  232. return null;
  233. default:
  234. var id = dom.get("id");
  235. if (id){
  236. return this.json.moduleList[id];
  237. }else{
  238. return null;
  239. }
  240. }
  241. },
  242. loadModule: function(json, dom, parent){
  243. if (json) {
  244. var module = new MWF["PC" + json.type](this);
  245. module.load(json, dom, parent);
  246. return module;
  247. }
  248. },
  249. setNodeEvents: function(){
  250. this.node.addEvent("click", function(e){
  251. this.selected();
  252. }.bind(this));
  253. },
  254. createModule: function(className, e){
  255. this.getTemplateData(className, function(data){
  256. var moduleData = Object.clone(data);
  257. var newTool = new MWF["PC"+className](this);
  258. newTool.create(moduleData, e);
  259. }.bind(this));
  260. },
  261. getTemplateData: function(className, callback){
  262. if (this.dataTemplate[className]){
  263. if (callback) callback(this.dataTemplate[className]);
  264. }else{
  265. var templateUrl = "/x_component_portal_PageDesigner/Module/"+className+"/template.json";
  266. MWF.getJSON(templateUrl, function(responseJSON, responseText){
  267. this.dataTemplate[className] = responseJSON;
  268. if (callback) callback(responseJSON);
  269. }.bind(this));
  270. }
  271. },
  272. selected: function(){
  273. if (this.currentSelectedModule){
  274. if (this.currentSelectedModule==this){
  275. return true;
  276. }else{
  277. this.currentSelectedModule.unSelected();
  278. }
  279. }
  280. if (this.propertyMultiTd){
  281. this.propertyMultiTd.hide();
  282. this.propertyMultiTd = null;
  283. }
  284. this.unSelectedMulti();
  285. this.currentSelectedModule = this;
  286. if (this.treeNode){
  287. this.treeNode.selectNode();
  288. }
  289. this.showProperty();
  290. // this.isFocus = true;
  291. },
  292. unSelectedMulti: function(){
  293. while (this.selectedModules.length){
  294. this.selectedModules[0].unSelectedMulti();
  295. }
  296. if (this.multimoduleActionsArea) this.multimoduleActionsArea.setStyle("display", "none");
  297. },
  298. unSelectAll: function(){
  299. },
  300. _beginSelectMulti: function(){
  301. if (this.currentSelectedModule) this.currentSelectedModule.unSelected();
  302. this.unSelectedMulti();
  303. this.noSelected = true;
  304. },
  305. _completeSelectMulti: function(){
  306. if (this.selectedModules.length<2){
  307. this.selectedModules[0].selected();
  308. }else{
  309. this._showMultiActions();
  310. }
  311. },
  312. createMultimoduleActionsArea: function(){
  313. this.multimoduleActionsArea = new Element("div", {
  314. styles: {
  315. "display": "none",
  316. // "width": 18*this.options.actions.length,
  317. "position": "absolute",
  318. "background-color": "#F1F1F1",
  319. "padding": "1px",
  320. "padding-right": "0px",
  321. "border": "1px solid #AAA",
  322. "box-shadow": "0px 2px 5px #999",
  323. "z-index": 10001
  324. }
  325. }).inject(this.page.container, "after");
  326. },
  327. _showMultiActions: function(){
  328. if (!this.multimoduleActionsArea) this.createMultimoduleActionsArea();
  329. var firstModule = this._getFirstMultiSelectedModule();
  330. if (firstModule){
  331. // var module = firstModule.module;
  332. var y = firstModule.position.y-25;
  333. var x = firstModule.position.x;
  334. this.multimoduleActionsArea.setPosition({"x": x, "y": y});
  335. this.multimoduleActionsArea.setStyle("display", "block");
  336. }
  337. },
  338. _getFirstMultiSelectedModule: function(){
  339. var firstModule = null;
  340. this.selectedModules.each(function(module){
  341. var position = module.node.getPosition(module.form.node.getOffsetParent());
  342. if (!firstModule){
  343. firstModule = {"module": module, "position": position};
  344. }else{
  345. if (position.y<firstModule.position.y){
  346. firstModule = {"module": module, "position": position};
  347. }else if (position.y==firstModule.position.y){
  348. if (position.x<firstModule.position.x){
  349. firstModule = {"module": module, "position": position};
  350. }
  351. }
  352. }
  353. });
  354. return firstModule;
  355. },
  356. showProperty: function(){
  357. if (!this.property){
  358. this.property = new MWF.xApplication.process.FormDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  359. "path": this.options.propertyPath,
  360. "onPostLoad": function(){
  361. this.property.show();
  362. }.bind(this)
  363. });
  364. this.property.load();
  365. }else{
  366. this.property.show();
  367. }
  368. },
  369. hideProperty: function(){
  370. if (this.property) this.property.hide();
  371. },
  372. unSelected: function(){
  373. this.currentSelectedModule = null;
  374. this.hideProperty();
  375. },
  376. _dragIn: function(module){
  377. if (!this.Component) module.inContainer = this;
  378. module.parentContainer = this;
  379. this.node.setStyles({"border": "1px solid #ffa200"});
  380. var copyNode = module._getCopyNode();
  381. copyNode.inject(this.node);
  382. },
  383. _dragOut: function(module){
  384. module.inContainer = null;
  385. module.parentContainer = null;
  386. this.node.setStyles(this.css.pageNode);
  387. this.node.setStyles(this.json.styles);
  388. var copyNode = module._getCopyNode();
  389. copyNode.setStyle("display", "none");
  390. },
  391. _dragDrop: function(module){
  392. this.node.setStyles(this.css.pageNode);
  393. this.node.setStyles(this.json.styles);
  394. },
  395. _clearNoId: function(node){
  396. var subNode = node.getFirst();
  397. while (subNode){
  398. var nextNode = subNode.getNext();
  399. if (subNode.get("MWFType")){
  400. if (!subNode.get("id")){
  401. subNode.destroy();
  402. }else{
  403. if (subNode) this._clearNoId(subNode);
  404. }
  405. }else{
  406. if (subNode) this._clearNoId(subNode);
  407. }
  408. subNode = nextNode;
  409. }
  410. },
  411. _getPageData: function(){
  412. var copy = this.node.clone(true, true);
  413. copy.clearStyles(true);
  414. this._clearNoId(copy);
  415. var html = copy.outerHTML;
  416. copy.destroy();
  417. this.data.json.mode = this.options.mode;
  418. this.data.html = html;
  419. return this.data;
  420. },
  421. preview: function(){
  422. var url = "/x_desktop/portal.html?id="+this.json.application+"&page="+this.json.id;
  423. window.open(url);
  424. // MWF.xDesktop.requireApp("process.FormDesigner", "Preview", function(){
  425. //
  426. // if (this.options.mode=="Mobile"){
  427. // this.previewBox = new MWF.xApplication.process.FormDesigner.Preview(this, {"size": {"x": "340", "y": 580, "layout":"mobile"}});
  428. // }else{
  429. // this.previewBox = new MWF.xApplication.process.FormDesigner.Preview(this);
  430. // }
  431. // this.previewBox.load();
  432. //
  433. // }.bind(this));
  434. },
  435. save: function(callback){
  436. this.designer.savePage();
  437. },
  438. explode: function(){
  439. this._getPageData();
  440. MWF.require("MWF.widget.Base64", null, false);
  441. var data = MWF.widget.Base64.encode(JSON.encode(this.data));
  442. MWF.require("MWF.widget.Panel", function(){
  443. var node = new Element("div");
  444. var size = this.designer.pageNode.getSize();
  445. var position = this.designer.pageNode.getPosition(this.designer.pageNode.getOffsetParent());
  446. var textarea = new Element("textarea", {
  447. "styles": {
  448. "border": "1px solid #999",
  449. "width": "770px",
  450. "margin-left": "14px",
  451. "margin-top": "14px",
  452. "height": "580px"
  453. },
  454. "text": JSON.encode(this.data)
  455. }).inject(node);
  456. this.explodePanel = new MWF.widget.Panel(node, {
  457. "style": "page",
  458. "isResize": false,
  459. "isMax": false,
  460. "title": "",
  461. "width": 800,
  462. "height": 660,
  463. "top": position.y,
  464. "left": position.x+3,
  465. "isExpand": false,
  466. "target": this.designer.node
  467. });
  468. this.explodePanel.load();
  469. }.bind(this));
  470. },
  471. implode: function(){
  472. MWF.require("MWF.widget.Panel", function(){
  473. var node = new Element("div");
  474. var size = this.designer.pageNode.getSize();
  475. var position = this.designer.pageNode.getPosition(this.designer.pageNode.getOffsetParent());
  476. var textarea = new Element("textarea", {
  477. "styles": {
  478. "border": "1px solid #999",
  479. "width": "770px",
  480. "margin-left": "14px",
  481. "margin-top": "14px",
  482. "height": "540px"
  483. }
  484. }).inject(node);
  485. var button = new Element("div", {
  486. "styles": {
  487. "margin": "10px auto",
  488. "width": "100px",
  489. "border-radius": "8px",
  490. "height": "30px",
  491. "line-height": "30px",
  492. "text-align": "center",
  493. "cursor": "pointer",
  494. "color": "#ffffff",
  495. "background-color": "#4c6b87"
  496. },
  497. "text": "OK"
  498. }).inject(node);
  499. button.addEvent("click", function(e){
  500. var _self = this;
  501. this.designer.confirm("warn", e, this.designer.lp.implodeConfirmTitle, this.designer.lp.implodeConfirmText, 300, 120, function(){
  502. var str = textarea.get("value");
  503. _self.implodeJsonData(str);
  504. this.close();
  505. }, function(){
  506. this.close();
  507. });
  508. }.bind(this));
  509. this.implodePanel = new MWF.widget.Panel(node, {
  510. "style": "page",
  511. "isResize": false,
  512. "isMax": false,
  513. "title": "",
  514. "width": 800,
  515. "height": 660,
  516. "top": position.y,
  517. "left": position.x+3,
  518. "isExpand": false,
  519. "target": this.designer.node
  520. });
  521. this.implodePanel.load();
  522. }.bind(this));
  523. },
  524. implodeJsonData: function(str){
  525. if (str){
  526. //try{
  527. debugger;
  528. var data = JSON.decode(str);
  529. if (data){
  530. var json = data.json;
  531. data.id = this.data.id;
  532. data.isNewPage = this.data.isNewPage;
  533. json.id = this.json.id;
  534. json.name = this.json.name;
  535. json.application = this.json.application;
  536. json.applicationName = this.json.applicationName;
  537. this.reload(data);
  538. this.implodePanel.closePanel();
  539. }else{
  540. this.designer.notice(this.designer.lp.implodeError, "error");
  541. }
  542. // }catch(e){
  543. // this.designer.notice(this.designer.lp.implodeError, "error");
  544. // }
  545. }else{
  546. this.designer.notice(this.designer.lp.implodeEmpty, "error");
  547. }
  548. },
  549. implodeHTML: function(){
  550. MWF.require("MWF.widget.Panel", function(){
  551. var node = new Element("div");
  552. var size = this.designer.pageNode.getSize();
  553. var position = this.designer.pageNode.getPosition(this.designer.pageNode.getOffsetParent());
  554. var textarea = new Element("textarea", {
  555. "styles": {
  556. "border": "1px solid #999",
  557. "width": "770px",
  558. "margin-left": "14px",
  559. "margin-top": "14px",
  560. "height": "540px"
  561. }
  562. }).inject(node);
  563. var button = new Element("div", {
  564. "styles": {
  565. "margin": "10px auto",
  566. "width": "100px",
  567. "border-radius": "8px",
  568. "height": "30px",
  569. "line-height": "30px",
  570. "text-align": "center",
  571. "cursor": "pointer",
  572. "color": "#ffffff",
  573. "background-color": "#4c6b87"
  574. },
  575. "text": "OK"
  576. }).inject(node);
  577. button.addEvent("click", function(){
  578. var str = textarea.get("value");
  579. try{
  580. var json = JSON.decode(str);
  581. if (json){
  582. this.reload(json);
  583. this.implodePanel.closePanel();
  584. }else{
  585. this.designer.notice(this.designer.lp.implodeError, "error")
  586. }
  587. }catch(e){
  588. this.designer.notice(this.designer.lp.implodeError, "error")
  589. }
  590. }.bind(this));
  591. this.implodeHtmlPanel = new MWF.widget.Panel(node, {
  592. "style": "page",
  593. "isResize": false,
  594. "isMax": false,
  595. "title": "",
  596. "width": 800,
  597. "height": 660,
  598. "top": position.y,
  599. "left": position.x+3,
  600. "isExpand": false,
  601. "target": this.designer.node
  602. });
  603. this.implodeHtmlPanel.load();
  604. }.bind(this));
  605. },
  606. setPropertiesOrStyles: function(name){
  607. if (name=="styles"){
  608. this.setCustomStyles();
  609. }
  610. if (name=="properties"){
  611. this.node.setProperties(this.json.properties);
  612. }
  613. },
  614. setCustomStyles: function(){
  615. var border = this.node.getStyle("border");
  616. this.node.clearStyles();
  617. this.node.setStyles(this.css.pageNode);
  618. var y = this.container.getSize().y-2;
  619. this.node.setStyle("min-height", ""+y+"px");
  620. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  621. this.node.setStyle("border", border);
  622. Object.each(this.json.styles, function(value, key){
  623. var reg = /^border\w*/ig;
  624. if (!key.test(reg)){
  625. this.node.setStyle(key, value);
  626. }
  627. }.bind(this));
  628. },
  629. _setEditStyle: function(name, obj, oldValue){
  630. debugger;
  631. if (name=="name"){
  632. var title = this.json.name || this.json.id;
  633. this.treeNode.setText("<"+this.json.type+"> "+title+" ["+this.options.mode+"] ");
  634. }
  635. if (name=="id"){
  636. if (!this.json.name) this.treeNode.setText("<"+this.json.type+"> "+this.json.id+" ["+this.options.mode+"] ");
  637. this.treeNode.setTitle(this.json.id);
  638. this.node.set("id", this.json.id);
  639. }
  640. if (name=="pageStyleType"){
  641. debugger;
  642. this.templateStyles = (this.stylesList && this.json.pageStyleType) ? this.stylesList[this.json.pageStyleType] : null;
  643. if (oldValue) {
  644. var oldTemplateStyles = this.stylesList[oldValue];
  645. if (oldTemplateStyles){
  646. if (oldTemplateStyles["page"]) this.clearTemplateStyles(oldTemplateStyles["page"]);
  647. }
  648. }
  649. if (this.templateStyles){
  650. if (this.templateStyles["page"]) this.setTemplateStyles(this.templateStyles["page"]);
  651. }
  652. this.setAllStyles();
  653. this.moduleList.each(function(module){
  654. if (oldTemplateStyles){
  655. module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  656. }
  657. module.setStyleTemplate();
  658. module.setAllStyles();
  659. }.bind(this));
  660. }
  661. this._setEditStyle_custom(name, obj, oldValue);
  662. },
  663. setAllStyles: function(){
  664. this.setPropertiesOrStyles("styles");
  665. this.setPropertiesOrStyles("properties");
  666. this.reloadMaplist();
  667. },
  668. reloadMaplist: function(){
  669. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  670. },
  671. _setEditStyle_custom: function(){
  672. },
  673. saveAsTemplete: function(){
  674. },
  675. checkModuleId: function(id, type, currentSubform){
  676. var fieldConflict = false;
  677. var elementConflict = false;
  678. if (this.json.moduleList[id]){
  679. elementConflict = true;
  680. if (this.options.fields.indexOf(type)!=-1 || this.options.fields.indexOf(this.json.moduleList[id].type)!=-1){
  681. fieldConflict = true;
  682. }
  683. return {"fieldConflict": fieldConflict, "elementConflict": elementConflict};
  684. }
  685. // if (this.subformList){
  686. // Object.each(this.subformList, function(subform){
  687. // if (!currentSubform || currentSubform!=subform.id){
  688. // if (subform.moduleList[id]){
  689. // elementConflict = true;
  690. // if (this.options.fields.indexOf(type)!=-1 || this.options.fields.indexOf(subform.moduleList[id].type)!=-1){
  691. // fieldConflict = true;
  692. // }
  693. // }
  694. // }
  695. // }.bind(this));
  696. // }
  697. return {"fieldConflict": fieldConflict, "elementConflict": elementConflict};
  698. }
  699. });