Main.js 33 KB

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