Main.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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 = MWF.Actions.get("x_cms_assemble_control"); //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. var application = this.options.application;
  179. if (!this.application){
  180. this.actions.getColumn( (typeOf( application )=="object" ? application.id : application) , function(json){
  181. this.application = {"name": json.data.appName, "id": json.data.id};
  182. if (callback) callback();
  183. }.bind(this));
  184. }else{
  185. if (callback) callback();
  186. }
  187. },
  188. openView: function(callback){
  189. this.getApplication(function(){
  190. this.initOptions();
  191. this.loadNodes();
  192. this.loadViewListNodes();
  193. // this.loadToolbar();
  194. this.loadContentNode();
  195. this.loadProperty();
  196. // this.loadTools();
  197. this.resizeNode();
  198. this.addEvent("resize", this.resizeNode.bind(this));
  199. this.loadView(function(){
  200. if (callback) callback();
  201. });
  202. this.setScrollBar(this.propertyDomArea, null, {
  203. "V": {"x": 0, "y": 0},
  204. "H": {"x": 0, "y": 0}
  205. });
  206. }.bind(this));
  207. },
  208. initOptions: function(){
  209. //this.toolsData = null;
  210. //this.toolbarMode = "all";
  211. //this.tools = [];
  212. //this.toolbarDecrease = 0;
  213. //
  214. //this.designNode = null;
  215. //this.form = null;
  216. },
  217. loadNodes: function(){
  218. this.viewListNode = new Element("div.viewListNode", {
  219. "styles": this.css.viewListNode
  220. }).inject(this.node);
  221. this.propertyNode = new Element("div.propertyNode", {
  222. "styles": this.css.propertyNode
  223. }).inject(this.node);
  224. this.contentNode = new Element("div.contentNode", {
  225. "styles": this.css.contentNode
  226. }).inject(this.node);
  227. },
  228. //loadViewListNodes-------------------------------
  229. loadViewListNodes: function(){
  230. this.viewListTitleNode = new Element("div.viewListTitleNode", {
  231. "styles": this.css.viewListTitleNode,
  232. "text": MWF.CMSQVD.LP.view
  233. }).inject(this.viewListNode);
  234. this.viewListResizeNode = new Element("div.viewListResizeNode", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode);
  235. this.viewListAreaSccrollNode = new Element("div.viewListAreaSccrollNode", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode);
  236. this.viewListAreaNode = new Element("div.viewListAreaNode", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode);
  237. this.loadViewListResize();
  238. this.loadViewList();
  239. },
  240. loadViewListResize: function(){
  241. this.viewListResize = new Drag(this.viewListResizeNode,{
  242. "snap": 1,
  243. "onStart": function(el, e){
  244. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  245. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  246. el.store("position", {"x": x, "y": y});
  247. var size = this.viewListAreaSccrollNode.getSize();
  248. el.store("initialWidth", size.x);
  249. }.bind(this),
  250. "onDrag": function(el, e){
  251. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  252. // var y = e.event.y;
  253. var bodySize = this.content.getSize();
  254. var position = el.retrieve("position");
  255. var initialWidth = el.retrieve("initialWidth").toFloat();
  256. var dx = x.toFloat() - position.x.toFloat();
  257. var width = initialWidth+dx;
  258. if (width> bodySize.x/2) width = bodySize.x/2;
  259. if (width<40) width = 40;
  260. this.contentNode.setStyle("margin-left", width+1);
  261. this.viewListNode.setStyle("width", width);
  262. //this.tab.pages.each(function(page){
  263. this.view.setViewWidth();
  264. //});
  265. }.bind(this)
  266. });
  267. this.viewListResizeNode.addEvents({
  268. "touchstart": function(e){
  269. el = e.target;
  270. var x = (Browser.name=="firefox") ? e.page.clientX : e.page.x;
  271. var y = (Browser.name=="firefox") ? e.page.clientY : e.page.y;
  272. el.store("position", {"x": x, "y": y});
  273. var size = this.viewListAreaSccrollNode.getSize();
  274. el.store("initialWidth", size.x);
  275. }.bind(this),
  276. "touchmove": function(e){
  277. //Object.each(e, function(v, k){
  278. // alert(k+": "+ v);
  279. //});
  280. el = e.target;
  281. var x = (Browser.name=="firefox") ? e.page.clientX : e.page.x;
  282. // var y = e.event.y;
  283. var bodySize = this.content.getSize();
  284. var position = el.retrieve("position");
  285. var initialWidth = el.retrieve("initialWidth").toFloat();
  286. var dx = x.toFloat() - position.x.toFloat();
  287. var width = initialWidth+dx;
  288. if (width> bodySize.x/2) width = bodySize.x/2;
  289. if (width<40) width = 40;
  290. this.contentNode.setStyle("margin-left", width+1);
  291. this.viewListNode.setStyle("width", width);
  292. //this.tab.pages.each(function(page){
  293. this.view.setViewWidth();
  294. //});
  295. }.bind(this)
  296. });
  297. },
  298. loadViewList: function(){
  299. this.actions.listQueryView(this.application.id, function (json) {
  300. json.data.each(function(view){
  301. this.createListViewItem(view);
  302. }.bind(this));
  303. }.bind(this), null, false);
  304. },
  305. //列示所有视图列表
  306. createListViewItem: function(view, isNew){
  307. var _self = this;
  308. var listViewItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  309. var listViewItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem);
  310. var listViewItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (view.name) ? view.name+" ("+view.alias+")" : this.lp.newView}).inject(listViewItem);
  311. listViewItem.store("view", view);
  312. listViewItem.addEvents({
  313. "dblclick": function(e){_self.loadViewByData(this, e);},
  314. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  315. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  316. });
  317. },
  318. //打开视图
  319. loadViewByData: function(node, e){
  320. var view = node.retrieve("view");
  321. var openNew = true;
  322. //for (var i = 0; i<this.tab.pages.length; i++){
  323. // if (view.id==this.tab.pages[i].view.data.id){
  324. // this.tab.pages[i].showTabIm();
  325. // openNew = false;
  326. // break;
  327. // }
  328. //}
  329. if (openNew){
  330. //this.loadViewData(view.id, function(vdata){
  331. // var view = new MWF.xApplication.cms.QueryViewDesigner.View(this, vdata);
  332. // view.load();
  333. //}.bind(this));
  334. var _self = this;
  335. var options = {
  336. "onQueryLoad": function(){
  337. this.actions = _self.actions;
  338. this.category = _self;
  339. this.options.id = view.id;
  340. this.application = _self.application;
  341. this.explorer = _self.explorer;
  342. }
  343. };
  344. this.desktop.openApplication(e, "cms.QueryViewDesigner", options);
  345. }
  346. },
  347. //loadContentNode------------------------------
  348. loadContentNode: function(){
  349. this.contentToolbarNode = new Element("div#contentToolbarNode", {
  350. "styles": this.css.contentToolbarNode
  351. }).inject(this.contentNode);
  352. if (!this.options.readMode) this.loadContentToolbar();
  353. this.editContentNode = new Element("div", {
  354. "styles": this.css.editContentNode
  355. }).inject(this.contentNode);
  356. this.loadEditContent(function(){
  357. // if (this.designDcoument) this.designDcoument.body.setStyles(this.css.designBody);
  358. if (this.designNode) this.designNode.setStyles(this.css.designNode);
  359. }.bind(this));
  360. },
  361. loadContentToolbar: function(callback){
  362. this.getFormToolbarHTML(function(toolbarNode){
  363. var spans = toolbarNode.getElements("span");
  364. spans.each(function(item, idx){
  365. var img = item.get("MWFButtonImage");
  366. if (img){
  367. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbar/"+img);
  368. }
  369. }.bind(this));
  370. $(toolbarNode).inject(this.contentToolbarNode);
  371. MWF.require("MWF.widget.Toolbar", function(){
  372. this.toolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "ProcessCategory"}, this);
  373. this.toolbar.load();
  374. if (callback) callback();
  375. }.bind(this));
  376. }.bind(this));
  377. },
  378. getFormToolbarHTML: function(callback){
  379. var toolbarUrl = this.path+this.options.style+"/toolbars.html";
  380. var r = new Request.HTML({
  381. url: toolbarUrl,
  382. method: "get",
  383. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  384. var toolbarNode = responseTree[0];
  385. if (callback) callback(toolbarNode);
  386. }.bind(this),
  387. onFailure: function(xhr){
  388. this.notice("request processToolbars error: "+xhr.responseText, "error");
  389. }.bind(this)
  390. });
  391. r.send();
  392. },
  393. maxOrReturnEditor: function(){
  394. if (!this.isMax){
  395. this.designNode.inject(this.node);
  396. this.designNode.setStyles({
  397. "position": "absolute",
  398. "width": "100%",
  399. "height": "100%",
  400. "top": "0px",
  401. "margin": "0px",
  402. "left": "0px"
  403. });
  404. //this.tab.pages.each(function(page){
  405. this.view.setAreaNodeSize();
  406. //});
  407. this.isMax = true;
  408. }else{
  409. this.isMax = false;
  410. this.designNode.inject(this.editContentNode);
  411. this.designNode.setStyles(this.css.designNode);
  412. this.designNode.setStyles({
  413. "position": "static"
  414. });
  415. this.resizeNode();
  416. //this.tab.pages.each(function(page){
  417. this.view.setAreaNodeSize();
  418. //});
  419. }
  420. },
  421. loadEditContent: function(callback){
  422. this.designNode = new Element("div", {
  423. "styles": this.css.designNode
  424. }).inject(this.editContentNode);
  425. //MWF.require("MWF.widget.Tab", function(){
  426. // this.tab = new MWF.widget.Tab(this.designNode, {"style": "dictionary"});
  427. // this.tab.load();
  428. //}.bind(this), false);
  429. // MWF.require("MWF.widget.ScrollBar", function(){
  430. // new MWF.widget.ScrollBar(this.designNode, {"distance": 100});
  431. // }.bind(this));
  432. },
  433. //loadProperty------------------------
  434. loadProperty: function(){
  435. this.propertyTitleNode = new Element("div.propertyTitleNode", {
  436. "styles": this.css.propertyTitleNode,
  437. "text": MWF.CMSQVD.LP.property
  438. }).inject(this.propertyNode);
  439. this.propertyResizeBar = new Element("div.propertyResizeBar", {
  440. "styles": this.css.propertyResizeBar
  441. }).inject(this.propertyNode);
  442. this.loadPropertyResize();
  443. this.propertyContentNode = new Element("div.propertyContentNode", {
  444. "styles": this.css.propertyContentNode
  445. }).inject(this.propertyNode);
  446. this.propertyDomArea = new Element("div.propertyDomArea", {
  447. "styles": this.css.propertyDomArea
  448. }).inject(this.propertyContentNode);
  449. this.propertyDomPercent = 0.3;
  450. this.propertyContentResizeNode = new Element("div.propertyContentResizeNode", {
  451. "styles": this.css.propertyContentResizeNode
  452. }).inject(this.propertyContentNode);
  453. this.propertyContentArea = new Element("div.propertyContentArea", {
  454. "styles": this.css.propertyContentArea
  455. }).inject(this.propertyContentNode);
  456. this.loadPropertyContentResize();
  457. //this.setPropertyContent();
  458. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  459. },
  460. //setPropertyContent: function(){
  461. // this.dictionaryPropertyNode = new Element("div", {"styles": this.css.dictionaryPropertyNode});
  462. // this.jsonDomNode = new Element("div", {"styles": this.css.jsonDomNode});
  463. // this.jsonTextNode = new Element("div", {"styles": this.css.jsonTextNode});
  464. // this.jsonTextAreaNode = new Element("textarea", {"styles": this.css.jsonTextAreaNode}).inject(this.jsonTextNode);
  465. //
  466. // MWF.require("MWF.widget.Tab", function(){
  467. // var tab = new MWF.widget.Tab(this.propertyContentArea, {"style": "moduleList"});
  468. // tab.load();
  469. // tab.addTab(this.dictionaryPropertyNode, this.lp.property, false);
  470. // tab.addTab(this.jsonDomNode, "JSON", false);
  471. // tab.addTab(this.jsonTextNode, "TEXT", false);
  472. // tab.pages[0].showTab();
  473. // }.bind(this));
  474. //
  475. // var node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.id+":"}).inject(this.dictionaryPropertyNode);
  476. // this.propertyIdNode = new Element("div", {"styles": this.css.propertyTextNode}).inject(this.dictionaryPropertyNode);
  477. //
  478. // node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.name+":"}).inject(this.dictionaryPropertyNode);
  479. // this.propertyNameNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  480. // if (this.options.noModifyName || this.options.readMode){
  481. // this.propertyNameNode.set("readonly", true);
  482. // this.propertyNameNode.addEvent("keydown", function(){
  483. // this.notice(this.lp.notice.noModifyName, "error");
  484. // }.bind(this));
  485. // }
  486. //
  487. // node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.alias+":"}).inject(this.dictionaryPropertyNode);
  488. // this.propertyAliasNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  489. // if (this.options.noModifyName || this.options.readMode){
  490. // this.propertyAliasNode.set("readonly", true);
  491. // this.propertyAliasNode.addEvent("keydown", function(){
  492. // this.notice(this.lp.notice.noModifyName, "error");
  493. // }.bind(this));
  494. // }
  495. //
  496. // node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.description+":"}).inject(this.dictionaryPropertyNode);
  497. // this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.propertyInputAreaNode}).inject(this.dictionaryPropertyNode);
  498. // if (this.options.noModifyName || this.options.readMode){
  499. // this.propertyDescriptionNode.set("readonly", true);
  500. // }
  501. //},
  502. loadPropertyResize: function(){
  503. // var size = this.propertyNode.getSize();
  504. // var position = this.propertyResizeBar.getPosition();
  505. this.propertyResize = new Drag(this.propertyResizeBar,{
  506. "snap": 1,
  507. "onStart": function(el, e){
  508. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  509. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  510. el.store("position", {"x": x, "y": y});
  511. var size = this.propertyNode.getSize();
  512. el.store("initialWidth", size.x);
  513. }.bind(this),
  514. "onDrag": function(el, e){
  515. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  516. // var y = e.event.y;
  517. var bodySize = this.content.getSize();
  518. var position = el.retrieve("position");
  519. var initialWidth = el.retrieve("initialWidth").toFloat();
  520. var dx = position.x.toFloat()-x.toFloat();
  521. var width = initialWidth+dx;
  522. if (width> bodySize.x/2) width = bodySize.x/2;
  523. if (width<40) width = 40;
  524. this.contentNode.setStyle("margin-right", width+1);
  525. this.propertyNode.setStyle("width", width);
  526. //this.tab.pages.each(function(page){
  527. this.view.setViewWidth();
  528. //});
  529. }.bind(this)
  530. });
  531. },
  532. loadPropertyContentResize: function(){
  533. this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
  534. "snap": 1,
  535. "onStart": function(el, e){
  536. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  537. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  538. el.store("position", {"x": x, "y": y});
  539. var size = this.propertyDomArea.getSize();
  540. el.store("initialHeight", size.y);
  541. }.bind(this),
  542. "onDrag": function(el, e){
  543. var size = this.propertyContentNode.getSize();
  544. // var x = e.event.x;
  545. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  546. var position = el.retrieve("position");
  547. var dy = y.toFloat()-position.y.toFloat();
  548. var initialHeight = el.retrieve("initialHeight").toFloat();
  549. var height = initialHeight+dy;
  550. if (height<40) height = 40;
  551. if (height> size.y-40) height = size.y-40;
  552. this.propertyDomPercent = height/size.y;
  553. this.setPropertyContentResize();
  554. }.bind(this)
  555. });
  556. },
  557. setPropertyContentResize: function(){
  558. var size = this.propertyContentNode.getSize();
  559. var resizeNodeSize = this.propertyContentResizeNode.getSize();
  560. var height = size.y-resizeNodeSize.y;
  561. var domHeight = this.propertyDomPercent*height;
  562. var contentHeight = height-domHeight;
  563. this.propertyDomArea.setStyle("height", ""+domHeight+"px");
  564. this.propertyContentArea.setStyle("height", ""+contentHeight+"px");
  565. if (this.view){
  566. if (this.view.currentSelectedModule){
  567. if (this.view.currentSelectedModule.property){
  568. var tab = this.view.currentSelectedModule.property.propertyTab;
  569. if (tab){
  570. var tabTitleSize = tab.tabNodeContainer.getSize();
  571. tab.pages.each(function(page){
  572. var topMargin = page.contentNodeArea.getStyle("margin-top").toFloat();
  573. var bottomMargin = page.contentNodeArea.getStyle("margin-bottom").toFloat();
  574. var tabContentNodeAreaHeight = contentHeight - topMargin - bottomMargin - tabTitleSize.y.toFloat()-15;
  575. page.contentNodeArea.setStyle("height", tabContentNodeAreaHeight);
  576. }.bind(this));
  577. }
  578. }
  579. }
  580. }
  581. },
  582. //resizeNode------------------------------------------------
  583. resizeNode: function(){
  584. var nodeSize = this.node.getSize();
  585. this.contentNode.setStyle("height", ""+nodeSize.y+"px");
  586. this.propertyNode.setStyle("height", ""+nodeSize.y+"px");
  587. var contentToolbarMarginTop = this.contentToolbarNode.getStyle("margin-top").toFloat();
  588. var contentToolbarMarginBottom = this.contentToolbarNode.getStyle("margin-bottom").toFloat();
  589. var allContentToolberSize = this.contentToolbarNode.getComputedSize();
  590. var y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom;
  591. this.editContentNode.setStyle("height", ""+y+"px");
  592. if (this.designNode){
  593. var designMarginTop = this.designNode.getStyle("margin-top").toFloat();
  594. var designMarginBottom = this.designNode.getStyle("margin-bottom").toFloat();
  595. y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom - designMarginTop - designMarginBottom;
  596. this.designNode.setStyle("height", ""+y+"px");
  597. }
  598. titleSize = this.propertyTitleNode.getSize();
  599. titleMarginTop = this.propertyTitleNode.getStyle("margin-top").toFloat();
  600. titleMarginBottom = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
  601. titlePaddingTop = this.propertyTitleNode.getStyle("padding-top").toFloat();
  602. titlePaddingBottom = this.propertyTitleNode.getStyle("padding-bottom").toFloat();
  603. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  604. y = nodeSize.y-y;
  605. this.propertyContentNode.setStyle("height", ""+y+"px");
  606. this.propertyResizeBar.setStyle("height", ""+y+"px");
  607. this.setPropertyContentResize();
  608. titleSize = this.viewListTitleNode.getSize();
  609. titleMarginTop = this.viewListTitleNode.getStyle("margin-top").toFloat();
  610. titleMarginBottom = this.viewListTitleNode.getStyle("margin-bottom").toFloat();
  611. titlePaddingTop = this.viewListTitleNode.getStyle("padding-top").toFloat();
  612. titlePaddingBottom = this.viewListTitleNode.getStyle("padding-bottom").toFloat();
  613. nodeMarginTop = this.viewListAreaSccrollNode.getStyle("margin-top").toFloat();
  614. nodeMarginBottom = this.viewListAreaSccrollNode.getStyle("margin-bottom").toFloat();
  615. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;
  616. y = nodeSize.y-y;
  617. this.viewListAreaSccrollNode.setStyle("height", ""+y+"px");
  618. this.viewListResizeNode.setStyle("height", ""+y+"px");
  619. },
  620. //loadView------------------------------------------
  621. loadView: function(callback){
  622. this.getViewData(this.options.id, function(vdata){
  623. this.setTitle(this.options.appTitle + "-"+vdata.name);
  624. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  625. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  626. //if (this.options.readMode){
  627. // this.view = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, ddata);
  628. //}else{
  629. this.view = new MWF.xApplication.cms.QueryViewDesigner.View(this, vdata);
  630. //}
  631. this.view.load();
  632. if (callback) callback();
  633. //if (this.status){
  634. // if (this.status.openViews){
  635. // this.status.openViews.each(function(id){
  636. // this.loadViewData(id, function(data){
  637. // var showTab = true;
  638. // if (this.status.currentId){
  639. // if (this.status.currentId!=data.id) showTab = false;
  640. // }
  641. // //if (this.options.readMode){
  642. // // var view = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, data, {"showTab": showTab});
  643. // //}else{
  644. // var view = new MWF.xApplication.process.DictionaryDesigner.View(this, data, {"showTab": showTab});
  645. // //}
  646. //
  647. // view.load();
  648. // }.bind(this), true);
  649. // }.bind(this));
  650. // }
  651. //}
  652. }.bind(this));
  653. },
  654. getViewData: function(id, callback){
  655. if (!this.options.id){
  656. this.loadNewViewData(callback);
  657. }else{
  658. this.loadViewData(id, callback);
  659. }
  660. },
  661. loadNewViewData: function(callback){
  662. var url = "/x_component_cms_QueryViewDesigner/$View/view.json";
  663. MWF.getJSON(url, {
  664. "onSuccess": function(obj){
  665. this.actions.getUUID(function(id){
  666. obj.id=id;
  667. obj.isNewView = true;
  668. obj.application = this.application.id;
  669. this.createListViewItem(obj, true);
  670. if (callback) callback(obj);
  671. }.bind(this));
  672. }.bind(this),
  673. "onerror": function(text){
  674. this.notice(text, "error");
  675. }.bind(this),
  676. "onRequestFailure": function(xhr){
  677. this.notice(xhr.responseText, "error");
  678. }.bind(this)
  679. });
  680. },
  681. loadViewData: function(id, callback){
  682. this.actions.getQueryView(id, function(json){
  683. if (json){
  684. var data = json.data;
  685. var dataJson = JSON.decode(data.data);
  686. data.data = dataJson;
  687. if (!this.application){
  688. var application = data.application;
  689. this.actions.getColumn( (typeOf( application )=="object" ? application.id : application), function(json){
  690. this.application = {"name": json.data.appName, "id": json.data.id};
  691. if (callback) callback(data);
  692. }.bind(this));
  693. }else{
  694. if (callback) callback(data);
  695. }
  696. }
  697. }.bind(this));
  698. },
  699. saveView: function(){
  700. //if (this.tab.showPage){
  701. //var view = this.tab.showPage.view;
  702. this.view.save(function(){
  703. //if (view==this.view){
  704. var name = this.view.data.name;
  705. this.setTitle(MWF.CMSQVD.LP.title + "-"+name);
  706. this.options.desktopReload = true;
  707. this.options.id = this.view.data.id;
  708. //}
  709. }.bind(this));
  710. //}
  711. },
  712. saveViewAs: function(){
  713. this.view.saveAs();
  714. },
  715. dictionaryExplode: function(){
  716. this.view.explode();
  717. },
  718. dictionaryImplode: function(){
  719. this.view.implode();
  720. },
  721. //recordStatus: function(){
  722. // return {"id": this.options.id};
  723. //},
  724. recordStatus: function(){
  725. //if (this.tab){
  726. var openViews = [];
  727. openViews.push(this.view.data.id);
  728. var currentId = this.view.data.id;
  729. return {
  730. "id": this.options.id,
  731. "application": this.application,
  732. "openViews": openViews,
  733. "currentId": currentId
  734. };
  735. //}
  736. //return {"id": this.options.id, "application": this.application};
  737. }
  738. });