Main.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. MWF.CMSDD = MWF.xApplication.cms.DictionaryDesigner;
  2. MWF.CMSDD.options = {
  3. "multitask": true,
  4. "executable": false
  5. };
  6. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", null, false);
  7. MWF.xDesktop.requireApp("cms.DictionaryDesigner", "Dictionary", null, false);
  8. MWF.xApplication.cms.DictionaryDesigner.Main = new Class({
  9. Extends: MWF.xApplication.Common.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "name": "cms.DictionaryDesigner",
  14. "icon": "icon.png",
  15. "title": MWF.CMSDD.LP.title,
  16. "appTitle": MWF.CMSDD.LP.title,
  17. "id": "",
  18. "width": "1200",
  19. "height": "600",
  20. "actions": null,
  21. "category": null,
  22. "processData": null
  23. },
  24. onQueryLoad: function(){
  25. this.shortcut = true;
  26. if (this.status){
  27. this.options.application = this.status.applicationId;
  28. this.application = this.status.application || this.status.applicationId;;
  29. this.options.id = this.status.id;
  30. this.setOptions(this.status.options);
  31. }
  32. if (!this.options.id){
  33. this.options.desktopReload = false;
  34. this.options.title = this.options.title + "-"+MWF.CMSDD.LP.newDictionary;
  35. }
  36. this.actions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  37. this.lp = MWF.xApplication.cms.DictionaryDesigner.LP;
  38. // this.cmsData = this.options.processData;
  39. this.actions.application = this.application;
  40. this.addEvent("queryClose", function(e){
  41. if (this.explorer){
  42. this.explorer.reload();
  43. }
  44. }.bind(this));
  45. },
  46. loadApplication: function(callback){
  47. this.createNode();
  48. if (!this.options.isRefresh){
  49. this.maxSize(function(){
  50. this.openForm();
  51. }.bind(this));
  52. }else{
  53. this.openForm();
  54. }
  55. if (!this.options.readMode) this.addKeyboardEvents();
  56. if (callback) callback();
  57. },
  58. addKeyboardEvents: function(){
  59. this.addEvent("copy", function(){
  60. this.copyModule();
  61. }.bind(this));
  62. this.addEvent("paste", function(){
  63. this.pasteModule();
  64. }.bind(this));
  65. this.addEvent("cut", function(){
  66. this.cutModule();
  67. }.bind(this));
  68. this.addEvent("keySave", function(e){
  69. this.keySave(e);
  70. }.bind(this));
  71. this.addEvent("keyDelete", function(e){
  72. this.keyDelete(e);
  73. }.bind(this));
  74. },
  75. keySave: function(e){
  76. if (this.shortcut) {
  77. if (this.tab.showPage) {
  78. var dictionary = this.tab.showPage.dictionary;
  79. if (dictionary) {
  80. dictionary.save();
  81. e.preventDefault();
  82. }
  83. }
  84. }
  85. },
  86. keyDelete: function(){
  87. if (this.shortcut) {
  88. if (this.tab.showPage) {
  89. var dictionary = this.tab.showPage.dictionary;
  90. if (dictionary) {
  91. if (dictionary.currentSelectedItem) {
  92. var item = dictionary.currentSelectedItem;
  93. item.delItem(item.itemTextNode);
  94. }
  95. }
  96. }
  97. }
  98. },
  99. copyModule: function(){
  100. if (this.shortcut) {
  101. if (this.tab.showPage) {
  102. var dictionary = this.tab.showPage.dictionary;
  103. if (dictionary) {
  104. if (dictionary.currentSelectedItem) {
  105. var item = dictionary.currentSelectedItem;
  106. MWF.clipboard.data = {
  107. "type": "dictionary",
  108. "data": {
  109. "key": item.key,
  110. "value": (typeOf(item.value)=="object") ? Object.clone(item.value) : item.value
  111. }
  112. };
  113. }
  114. }
  115. }
  116. }
  117. },
  118. cutModule: function(){
  119. if (this.shortcut) {
  120. if (this.tab.showPage) {
  121. var dictionary = this.tab.showPage.dictionary;
  122. if (dictionary) {
  123. if (dictionary.currentSelectedItem) {
  124. this.copyModule();
  125. var item = dictionary.currentSelectedItem;
  126. item.destroy();
  127. }
  128. }
  129. }
  130. }
  131. },
  132. pasteModule: function(){
  133. if (this.shortcut) {
  134. if (MWF.clipboard.data) {
  135. if (MWF.clipboard.data.type == "dictionary") {
  136. if (this.tab.showPage) {
  137. var dictionary = this.tab.showPage.dictionary;
  138. if (dictionary) {
  139. if (dictionary.currentSelectedItem) {
  140. var item = dictionary.currentSelectedItem;
  141. var key = MWF.clipboard.data.data.key;
  142. var value = (typeOf(MWF.clipboard.data.data.value)=="object") ? Object.clone(MWF.clipboard.data.data.value) : MWF.clipboard.data.data.value;
  143. var level = item.level;
  144. var parent = item;
  145. var nextSibling = null;
  146. if (!item.parent){//top level
  147. level = 1;
  148. }else{
  149. if (item.type!="array" && item.type!="object"){
  150. parent = item.parent;
  151. nextSibling = item;
  152. }else{
  153. if (item.exp){
  154. level = item.level+1;
  155. }else{
  156. parent = item.parent;
  157. nextSibling = item;
  158. }
  159. }
  160. }
  161. var idx = parent.children.length;
  162. if (item.type=="array"){
  163. if (nextSibling){
  164. key = nextSibling.key;
  165. parent.value.splice(nextSibling.key, 0, value);
  166. for (var i=nextSibling.key; i<parent.children.length; i++){
  167. subItem = parent.children[i];
  168. subItem.key = subItem.key+1;
  169. subItem.setNodeText();
  170. }
  171. }else{
  172. var key = parent.value.length;
  173. parent.value.push(value);
  174. }
  175. idx = key;
  176. }else{
  177. var oldKey = key;
  178. var i = 0;
  179. while (parent.value[key] != undefined) {
  180. i++;
  181. key = oldKey + i;
  182. }
  183. parent.value[key] = value;
  184. if (nextSibling) var idx = parent.children.indexOf(nextSibling);
  185. }
  186. var item = new MWF.xApplication.cms.DictionaryDesigner.Dictionary.item(key, value, parent, level, this.dictionary, true, nextSibling);
  187. if (idx) parent.children[idx-1].nextSibling = item;
  188. parent.children.splice(idx, 0, item);
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. },
  196. createNode: function(){
  197. this.content.setStyle("overflow", "hidden");
  198. this.node = new Element("div", {
  199. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  200. }).inject(this.content);
  201. },
  202. getApplication:function(callback){
  203. if (!this.application){
  204. this.actions.getApplication(this.options.application, function(json){
  205. this.application = {"name": json.data.name || json.data.appName, "id": json.data.id};
  206. if (callback) callback();
  207. }.bind(this));
  208. }else{
  209. if (callback) callback();
  210. }
  211. },
  212. openForm: function(){
  213. this.getApplication(function(){
  214. this.initOptions();
  215. this.loadNodes();
  216. this.loadDictionaryListNodes();
  217. // this.loadToolbar();
  218. this.loadContentNode();
  219. this.loadProperty();
  220. // this.loadTools();
  221. this.resizeNode();
  222. this.addEvent("resize", this.resizeNode.bind(this));
  223. this.loadDictionary();
  224. if (this.toolbarContentNode){
  225. this.setScrollBar(this.toolbarContentNode, null, {
  226. "V": {"x": 0, "y": 0},
  227. "H": {"x": 0, "y": 0}
  228. });
  229. this.setScrollBar(this.propertyDomArea, null, {
  230. "V": {"x": 0, "y": 0},
  231. "H": {"x": 0, "y": 0}
  232. });
  233. }
  234. }.bind(this));
  235. },
  236. initOptions: function(){
  237. //this.toolsData = null;
  238. //this.toolbarMode = "all";
  239. //this.tools = [];
  240. //this.toolbarDecrease = 0;
  241. //
  242. //this.designNode = null;
  243. //this.form = null;
  244. },
  245. loadNodes: function(){
  246. this.dictionaryListNode = new Element("div", {
  247. "styles": this.css.dictionaryListNode
  248. }).inject(this.node);
  249. this.propertyNode = new Element("div", {
  250. "styles": this.css.propertyNode
  251. }).inject(this.node);
  252. this.contentNode = new Element("div", {
  253. "styles": this.css.contentNode
  254. }).inject(this.node);
  255. },
  256. //loadDictionaryListNodes-------------------------------
  257. loadDictionaryListNodes: function(){
  258. this.dictionaryListTitleNode = new Element("div", {
  259. "styles": this.css.dictionaryListTitleNode,
  260. "text": MWF.CMSDD.LP.dictionary
  261. }).inject(this.dictionaryListNode);
  262. this.dictionaryListResizeNode = new Element("div", {"styles": this.css.dictionaryListResizeNode}).inject(this.dictionaryListNode);
  263. this.dictionaryListAreaSccrollNode = new Element("div", {"styles": this.css.dictionaryListAreaSccrollNode}).inject(this.dictionaryListNode);
  264. this.dictionaryListAreaNode = new Element("div", {"styles": this.css.dictionaryListAreaNode}).inject(this.dictionaryListAreaSccrollNode);
  265. this.loadDictionaryListResize();
  266. this.loadDictionaryList();
  267. },
  268. loadDictionaryListResize: function(){
  269. this.dictionaryListResize = new Drag(this.dictionaryListResizeNode,{
  270. "snap": 1,
  271. "onStart": function(el, e){
  272. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  273. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  274. el.store("position", {"x": x, "y": y});
  275. var size = this.dictionaryListAreaSccrollNode.getSize();
  276. el.store("initialWidth", size.x);
  277. }.bind(this),
  278. "onDrag": function(el, e){
  279. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  280. // var y = e.event.y;
  281. var bodySize = this.content.getSize();
  282. var position = el.retrieve("position");
  283. var initialWidth = el.retrieve("initialWidth").toFloat();
  284. var dx = x.toFloat() - position.x.toFloat();
  285. var width = initialWidth+dx;
  286. if (width> bodySize.x/2) width = bodySize.x/2;
  287. if (width<40) width = 40;
  288. this.contentNode.setStyle("margin-left", width+1);
  289. this.dictionaryListNode.setStyle("width", width);
  290. }.bind(this)
  291. });
  292. },
  293. loadDictionaryList: function(){
  294. this.actions.listDictionary(this.application.id || this.application, function (json) {
  295. json.data.each(function(dictionary){
  296. this.createListDictionaryItem(dictionary);
  297. }.bind(this));
  298. }.bind(this), null, false);
  299. },
  300. createListDictionaryItem: function(dictionary, isNew){
  301. var _self = this;
  302. var listDictionaryItem = new Element("div", {"styles": this.css.listDictionaryItem}).inject(this.dictionaryListAreaNode, (isNew) ? "top": "bottom");
  303. var listDictionaryItemIcon = new Element("div", {"styles": this.css.listDictionaryItemIcon}).inject(listDictionaryItem);
  304. var listDictionaryItemText = new Element("div", {"styles": this.css.listDictionaryItemText, "text": (dictionary.name) ? dictionary.name+" ("+dictionary.alias+")" : this.lp.newDictionary}).inject(listDictionaryItem);
  305. listDictionaryItem.store("dictionary", dictionary);
  306. listDictionaryItem.addEvents({
  307. "dblclick": function(e){_self.loadDictionaryByData(this, e);},
  308. "mouseover": function(){if (_self.currentListDictionaryItem!=this) this.setStyles(_self.css.listDictionaryItem_over);},
  309. "mouseout": function(){if (_self.currentListDictionaryItem!=this) this.setStyles(_self.css.listDictionaryItem);}
  310. });
  311. },
  312. loadDictionaryByData: function(node, e){
  313. var dictionary = node.retrieve("dictionary");
  314. var openNew = true;
  315. for (var i = 0; i<this.tab.pages.length; i++){
  316. if (dictionary.id==this.tab.pages[i].dictionary.data.id){
  317. this.tab.pages[i].showTabIm();
  318. openNew = false;
  319. break;
  320. }
  321. }
  322. if (openNew){
  323. this.loadDictionaryData(dictionary.id, function(data){
  324. var dictionary = new MWF.xApplication.cms.DictionaryDesigner.Dictionary(this, data);
  325. dictionary.load();
  326. }.bind(this), true);
  327. }
  328. },
  329. //loadContentNode------------------------------
  330. loadContentNode: function(){
  331. this.contentToolbarNode = new Element("div#contentToolbarNode", {
  332. "styles": this.css.contentToolbarNode
  333. }).inject(this.contentNode);
  334. if (!this.options.readMode) this.loadContentToolbar();
  335. this.editContentNode = new Element("div", {
  336. "styles": this.css.editContentNode
  337. }).inject(this.contentNode);
  338. this.loadEditContent(function(){
  339. // if (this.designDcoument) this.designDcoument.body.setStyles(this.css.designBody);
  340. if (this.designNode) this.designNode.setStyles(this.css.designNode);
  341. }.bind(this));
  342. },
  343. loadContentToolbar: function(callback){
  344. this.getFormToolbarHTML(function(toolbarNode){
  345. var spans = toolbarNode.getElements("span");
  346. spans.each(function(item, idx){
  347. var img = item.get("MWFButtonImage");
  348. if (img){
  349. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbar/"+img);
  350. }
  351. }.bind(this));
  352. $(toolbarNode).inject(this.contentToolbarNode);
  353. MWF.require("MWF.widget.Toolbar", function(){
  354. this.toolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "ProcessCategory"}, this);
  355. this.toolbar.load();
  356. if (callback) callback();
  357. }.bind(this));
  358. }.bind(this));
  359. },
  360. getFormToolbarHTML: function(callback){
  361. var toolbarUrl = this.path+this.options.style+"/toolbars.html";
  362. var r = new Request.HTML({
  363. url: toolbarUrl,
  364. method: "get",
  365. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  366. var toolbarNode = responseTree[0];
  367. if (callback) callback(toolbarNode);
  368. }.bind(this),
  369. onFailure: function(xhr){
  370. this.notice("request cmsToolbars error: "+xhr.responseText, "error");
  371. }.bind(this)
  372. });
  373. r.send();
  374. },
  375. maxOrReturnEditor: function(){
  376. if (!this.isMax){
  377. this.designNode.inject(this.node);
  378. this.designNode.setStyles({
  379. "position": "absolute",
  380. "width": "100%",
  381. "height": "100%",
  382. "top": "0px",
  383. "margin": "0px",
  384. "left": "0px"
  385. });
  386. this.tab.pages.each(function(page){
  387. page.dictionary.setAreaNodeSize();
  388. });
  389. this.isMax = true;
  390. }else{
  391. this.isMax = false;
  392. this.designNode.inject(this.editContentNode);
  393. this.designNode.setStyles(this.css.designNode);
  394. this.designNode.setStyles({
  395. "position": "static"
  396. });
  397. this.resizeNode();
  398. this.tab.pages.each(function(page){
  399. page.dictionary.setAreaNodeSize();
  400. });
  401. }
  402. },
  403. loadEditContent: function(callback){
  404. this.designNode = new Element("div", {
  405. "styles": this.css.designNode
  406. }).inject(this.editContentNode);
  407. MWF.require("MWF.widget.Tab", function(){
  408. this.tab = new MWF.widget.Tab(this.designNode, {"style": "dictionary"});
  409. this.tab.load();
  410. }.bind(this), false);
  411. // MWF.require("MWF.widget.ScrollBar", function(){
  412. // new MWF.widget.ScrollBar(this.designNode, {"distance": 100});
  413. // }.bind(this));
  414. },
  415. //loadProperty------------------------
  416. loadProperty: function(){
  417. this.propertyTitleNode = new Element("div", {
  418. "styles": this.css.propertyTitleNode,
  419. "text": MWF.CMSDD.LP.property
  420. }).inject(this.propertyNode);
  421. this.propertyResizeBar = new Element("div", {
  422. "styles": this.css.propertyResizeBar
  423. }).inject(this.propertyNode);
  424. this.loadPropertyResize();
  425. this.propertyContentNode = new Element("div", {
  426. "styles": this.css.propertyContentNode
  427. }).inject(this.propertyNode);
  428. this.propertyDomArea = new Element("div", {
  429. "styles": this.css.propertyDomArea
  430. }).inject(this.propertyContentNode);
  431. this.propertyDomPercent = 0.3;
  432. this.propertyContentResizeNode = new Element("div", {
  433. "styles": this.css.propertyContentResizeNode
  434. }).inject(this.propertyContentNode);
  435. this.propertyContentArea = new Element("div", {
  436. "styles": this.css.propertyContentArea
  437. }).inject(this.propertyContentNode);
  438. this.loadPropertyContentResize();
  439. this.setPropertyContent();
  440. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  441. },
  442. setPropertyContent: function(){
  443. this.dictionaryPropertyNode = new Element("div", {"styles": this.css.dictionaryPropertyNode});
  444. this.jsonDomNode = new Element("div", {"styles": this.css.jsonDomNode});
  445. this.jsonTextNode = new Element("div", {"styles": this.css.jsonTextNode});
  446. this.jsonTextAreaNode = new Element("textarea", {"styles": this.css.jsonTextAreaNode}).inject(this.jsonTextNode);
  447. MWF.require("MWF.widget.Tab", function(){
  448. var tab = new MWF.widget.Tab(this.propertyContentArea, {"style": "moduleList"});
  449. tab.load();
  450. tab.addTab(this.dictionaryPropertyNode, this.lp.property, false);
  451. tab.addTab(this.jsonDomNode, "JSON", false);
  452. tab.addTab(this.jsonTextNode, "TEXT", false);
  453. tab.pages[0].showTab();
  454. }.bind(this));
  455. var node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.id+":"}).inject(this.dictionaryPropertyNode);
  456. this.propertyIdNode = new Element("div", {"styles": this.css.propertyTextNode}).inject(this.dictionaryPropertyNode);
  457. node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.name+":"}).inject(this.dictionaryPropertyNode);
  458. this.propertyNameNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  459. if (this.options.noModifyName || this.options.readMode){
  460. this.propertyNameNode.set("readonly", true);
  461. this.propertyNameNode.addEvent("keydown", function(){
  462. this.notice(this.lp.notice.noModifyName, "error");
  463. }.bind(this));
  464. }
  465. node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.alias+":"}).inject(this.dictionaryPropertyNode);
  466. this.propertyAliasNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  467. if (this.options.noModifyName || this.options.readMode){
  468. this.propertyAliasNode.set("readonly", true);
  469. this.propertyAliasNode.addEvent("keydown", function(){
  470. this.notice(this.lp.notice.noModifyName, "error");
  471. }.bind(this));
  472. }
  473. node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.description+":"}).inject(this.dictionaryPropertyNode);
  474. this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.propertyInputAreaNode}).inject(this.dictionaryPropertyNode);
  475. if (this.options.noModifyName || this.options.readMode){
  476. this.propertyDescriptionNode.set("readonly", true);
  477. }
  478. },
  479. loadPropertyResize: function(){
  480. // var size = this.propertyNode.getSize();
  481. // var position = this.propertyResizeBar.getPosition();
  482. this.propertyResize = new Drag(this.propertyResizeBar,{
  483. "snap": 1,
  484. "onStart": function(el, e){
  485. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  486. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  487. el.store("position", {"x": x, "y": y});
  488. var size = this.propertyNode.getSize();
  489. el.store("initialWidth", size.x);
  490. }.bind(this),
  491. "onDrag": function(el, e){
  492. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  493. // var y = e.event.y;
  494. var bodySize = this.content.getSize();
  495. var position = el.retrieve("position");
  496. var initialWidth = el.retrieve("initialWidth").toFloat();
  497. var dx = position.x.toFloat()-x.toFloat();
  498. var width = initialWidth+dx;
  499. if (width> bodySize.x/2) width = bodySize.x/2;
  500. if (width<40) width = 40;
  501. this.contentNode.setStyle("margin-right", width+1);
  502. this.propertyNode.setStyle("width", width);
  503. }.bind(this)
  504. });
  505. },
  506. loadPropertyContentResize: function(){
  507. this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
  508. "snap": 1,
  509. "onStart": function(el, e){
  510. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  511. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  512. el.store("position", {"x": x, "y": y});
  513. var size = this.propertyDomArea.getSize();
  514. el.store("initialHeight", size.y);
  515. }.bind(this),
  516. "onDrag": function(el, e){
  517. var size = this.propertyContentNode.getSize();
  518. // var x = e.event.x;
  519. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  520. var position = el.retrieve("position");
  521. var dy = y.toFloat()-position.y.toFloat();
  522. var initialHeight = el.retrieve("initialHeight").toFloat();
  523. var height = initialHeight+dy;
  524. if (height<40) height = 40;
  525. if (height> size.y-40) height = size.y-40;
  526. this.propertyDomPercent = height/size.y;
  527. this.setPropertyContentResize();
  528. }.bind(this)
  529. });
  530. },
  531. setPropertyContentResize: function(){
  532. var size = this.propertyContentNode.getSize();
  533. var resizeNodeSize = this.propertyContentResizeNode.getSize();
  534. var height = size.y-resizeNodeSize.y;
  535. var domHeight = this.propertyDomPercent*height;
  536. var contentHeight = height-domHeight;
  537. this.propertyDomArea.setStyle("height", ""+domHeight+"px");
  538. this.propertyContentArea.setStyle("height", ""+contentHeight+"px");
  539. if (this.form){
  540. if (this.form.currentSelectedModule){
  541. if (this.form.currentSelectedModule.property){
  542. var tab = this.form.currentSelectedModule.property.propertyTab;
  543. if (tab){
  544. var tabTitleSize = tab.tabNodeContainer.getSize();
  545. tab.pages.each(function(page){
  546. var topMargin = page.contentNodeArea.getStyle("margin-top").toFloat();
  547. var bottomMargin = page.contentNodeArea.getStyle("margin-bottom").toFloat();
  548. var tabContentNodeAreaHeight = contentHeight - topMargin - bottomMargin - tabTitleSize.y.toFloat()-15;
  549. page.contentNodeArea.setStyle("height", tabContentNodeAreaHeight);
  550. }.bind(this));
  551. }
  552. }
  553. }
  554. }
  555. },
  556. //resizeNode------------------------------------------------
  557. resizeNode: function(){
  558. var nodeSize = this.node.getSize();
  559. this.contentNode.setStyle("height", ""+nodeSize.y+"px");
  560. this.propertyNode.setStyle("height", ""+nodeSize.y+"px");
  561. var contentToolbarMarginTop = this.contentToolbarNode.getStyle("margin-top").toFloat();
  562. var contentToolbarMarginBottom = this.contentToolbarNode.getStyle("margin-bottom").toFloat();
  563. var allContentToolberSize = this.contentToolbarNode.getComputedSize();
  564. var y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom;
  565. this.editContentNode.setStyle("height", ""+y+"px");
  566. if (this.designNode){
  567. var designMarginTop = this.designNode.getStyle("margin-top").toFloat();
  568. var designMarginBottom = this.designNode.getStyle("margin-bottom").toFloat();
  569. y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom - designMarginTop - designMarginBottom;
  570. this.designNode.setStyle("height", ""+y+"px");
  571. }
  572. titleSize = this.propertyTitleNode.getSize();
  573. titleMarginTop = this.propertyTitleNode.getStyle("margin-top").toFloat();
  574. titleMarginBottom = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
  575. titlePaddingTop = this.propertyTitleNode.getStyle("padding-top").toFloat();
  576. titlePaddingBottom = this.propertyTitleNode.getStyle("padding-bottom").toFloat();
  577. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  578. y = nodeSize.y-y;
  579. this.propertyContentNode.setStyle("height", ""+y+"px");
  580. this.propertyResizeBar.setStyle("height", ""+y+"px");
  581. this.setPropertyContentResize();
  582. titleSize = this.dictionaryListTitleNode.getSize();
  583. titleMarginTop = this.dictionaryListTitleNode.getStyle("margin-top").toFloat();
  584. titleMarginBottom = this.dictionaryListTitleNode.getStyle("margin-bottom").toFloat();
  585. titlePaddingTop = this.dictionaryListTitleNode.getStyle("padding-top").toFloat();
  586. titlePaddingBottom = this.dictionaryListTitleNode.getStyle("padding-bottom").toFloat();
  587. nodeMarginTop = this.dictionaryListAreaSccrollNode.getStyle("margin-top").toFloat();
  588. nodeMarginBottom = this.dictionaryListAreaSccrollNode.getStyle("margin-bottom").toFloat();
  589. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;
  590. y = nodeSize.y-y;
  591. this.dictionaryListAreaSccrollNode.setStyle("height", ""+y+"px");
  592. this.dictionaryListResizeNode.setStyle("height", ""+y+"px");
  593. },
  594. //loadForm------------------------------------------
  595. loadDictionary: function(){
  596. //debugger;
  597. this.getDictionaryData(this.options.id, function(ddata){
  598. this.setTitle(this.options.appTitle + "-"+ddata.name);
  599. this.taskitem.setText(this.options.appTitle + "-"+ddata.name);
  600. this.options.appTitle = this.options.appTitle + "-"+ddata.name;
  601. if (this.options.readMode){
  602. this.dictionary = new MWF.xApplication.cms.DictionaryDesigner.DictionaryReader(this, ddata);
  603. }else{
  604. this.dictionary = new MWF.xApplication.cms.DictionaryDesigner.Dictionary(this, ddata);
  605. }
  606. this.dictionary.load();
  607. if (this.status){
  608. if (this.status.openDictionarys){
  609. this.status.openDictionarys.each(function(id){
  610. this.loadDictionaryData(id, function(data){
  611. var showTab = true;
  612. if (this.status.currentId){
  613. if (this.status.currentId!=data.id) showTab = false;
  614. }
  615. if (this.options.readMode){
  616. var dictionary = new MWF.xApplication.cms.DictionaryDesigner.DictionaryReader(this, data, {"showTab": showTab});
  617. }else{
  618. var dictionary = new MWF.xApplication.cms.DictionaryDesigner.Dictionary(this, data, {"showTab": showTab});
  619. }
  620. dictionary.load();
  621. }.bind(this), true);
  622. }.bind(this));
  623. }
  624. }
  625. }.bind(this));
  626. },
  627. getDictionaryData: function(id, callback){
  628. if (!this.options.id){
  629. this.loadNewDictionaryData(callback);
  630. }else{
  631. this.loadDictionaryData(id, callback);
  632. }
  633. },
  634. loadNewDictionaryData: function(callback){
  635. var data = {
  636. "name": "",
  637. "id": "",
  638. "application": this.application.id,
  639. "alias": "",
  640. "description": "",
  641. "data": {}
  642. };
  643. this.createListDictionaryItem(data, true);
  644. if (callback) callback(data);
  645. },
  646. loadDictionaryData: function(id, callback){
  647. //debugger;
  648. this.actions.getDictionary(id, function(json){
  649. if (json){
  650. var data = json.data;
  651. if (!this.application){
  652. this.actions.getApplication(data.application, function(json){
  653. this.application = {"name": json.data.name, "id": json.data.id};
  654. if (callback) callback(data);
  655. }.bind(this));
  656. }else{
  657. if (callback) callback(data);
  658. }
  659. }
  660. }.bind(this));
  661. },
  662. saveDictionary: function(){
  663. if (this.tab.showPage){
  664. var dictionary = this.tab.showPage.dictionary;
  665. dictionary.save(function(){
  666. if (dictionary==this.dictionary){
  667. var name = dictionary.data.name;
  668. this.setTitle(MWF.CMSDD.LP.title + "-"+name);
  669. this.options.desktopReload = true;
  670. this.options.id = dictionary.data.id;
  671. }
  672. this.fireAppEvent("postSave")
  673. }.bind(this));
  674. }
  675. },
  676. saveDictionaryAs: function(){
  677. this.dictionary.saveAs();
  678. },
  679. dictionaryExplode: function(){
  680. this.dictionary.explode();
  681. },
  682. dictionaryImplode: function(){
  683. this.dictionary.implode();
  684. },
  685. //recordStatus: function(){
  686. // return {"id": this.options.id};
  687. //},
  688. dictionarySearch: function(){
  689. this.dictionary.loadSearch();
  690. },
  691. recordStatus: function(){
  692. if (this.tab){
  693. var openDictionarys = [];
  694. this.tab.pages.each(function(page){
  695. if (page.dictionary.data.id!=this.options.id) openDictionarys.push(page.dictionary.data.id);
  696. }.bind(this));
  697. var currentId = this.tab.showPage.dictionary.data.id;
  698. var status = {
  699. "id": this.options.id,
  700. "application": this.application,
  701. "applicationId": this.application.id || this.application,
  702. "openDictionarys": openDictionarys,
  703. "currentId": currentId,
  704. "options": {
  705. "action": this.options.action,
  706. "noCreate": this.options.noCreate,
  707. "noDelete": this.options.noDelete,
  708. "noModifyName": this.options.noModifyName,
  709. "readMode": this.options.readMode
  710. }
  711. };
  712. return status;
  713. }
  714. return {"id": this.options.id, "application": this.application};
  715. }
  716. });