Main.js 31 KB

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