Main.js 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. MWF.SRVID = MWF.xApplication.service.InvokeDesigner = MWF.xApplication.service.InvokeDesigner || {};
  2. MWF.SRVID.options = {
  3. "multitask": true,
  4. "executable": false
  5. };
  6. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", null, false);
  7. MWF.xDesktop.requireApp("service.InvokeDesigner", "Invoke", null, false);
  8. MWF.require("MWF.xDesktop.UserData", null, false);
  9. MWF.xApplication.service.InvokeDesigner.Main = new Class({
  10. Extends: MWF.xApplication.Common.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "service.InvokeDesigner",
  15. "icon": "icon.png",
  16. "title": MWF.SRVID.LP.title,
  17. "appTitle": MWF.SRVID.LP.title,
  18. "id": "",
  19. "actions": null,
  20. "category": null,
  21. "sortKeys": ['name', 'alias', 'createTime', 'updateTime'],
  22. "sortKey": '',
  23. "listToolbarExpanded": false
  24. },
  25. onQueryLoad: function(){
  26. if (this.status){
  27. this.options.id = this.status.id;
  28. }
  29. if (!this.options.id){
  30. this.options.desktopReload = false;
  31. this.options.title = this.options.title + "-"+MWF.SRVID.LP.newInvoke;
  32. }
  33. this.actions = MWF.Actions.get("x_program_center");
  34. //this.actions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  35. this.lp = MWF.xApplication.service.InvokeDesigner.LP;
  36. this.addEvent("queryClose", function(e){
  37. if (this.explorer){
  38. this.explorer.reload();
  39. }
  40. }.bind(this));
  41. // this.processData = this.options.processData;
  42. },
  43. loadApplication: function(callback){
  44. this.createNode();
  45. if (!this.options.isRefresh){
  46. this.maxSize(function(){
  47. this.openInvoke();
  48. }.bind(this));
  49. }else{
  50. this.openInvoke();
  51. }
  52. if (callback) callback();
  53. },
  54. createNode: function(){
  55. this.content.setStyle("overflow", "hidden");
  56. this.node = new Element("div", {
  57. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  58. }).inject(this.content);
  59. },
  60. openInvoke: function(){
  61. this.getUd(function(){
  62. this.loadNodes();
  63. this.loadInvokeListNodes();
  64. this.loadContentNode(function(){
  65. this.loadProperty();
  66. // this.loadTools();
  67. this.resizeNode();
  68. this.addEvent("resize", this.resizeNode.bind(this));
  69. this.loadInvoke();
  70. if (this.toolbarContentNode){
  71. this.setScrollBar(this.toolbarContentNode, null, {
  72. "V": {"x": 0, "y": 0},
  73. "H": {"x": 0, "y": 0}
  74. });
  75. this.setScrollBar(this.propertyDomArea, null, {
  76. "V": {"x": 0, "y": 0},
  77. "H": {"x": 0, "y": 0}
  78. });
  79. }
  80. }.bind(this));
  81. }.bind(this));
  82. },
  83. loadNodes: function(){
  84. this.invokeListNode = new Element("div", {
  85. "styles": this.css.invokeListNode
  86. }).inject(this.node);
  87. this.propertyNode = new Element("div", {
  88. "styles": this.css.propertyNode
  89. }).inject(this.node);
  90. this.contentNode = new Element("div", {
  91. "styles": this.css.contentNode
  92. }).inject(this.node);
  93. },
  94. //loadInvokeList-------------------------------
  95. loadInvokeListNodes: function(){
  96. this.invokeListTitleNode = new Element("div", {
  97. "styles": this.css.invokeListTitleNode,
  98. "text": MWF.SRVID.LP.invokeLibrary
  99. }).inject(this.invokeListNode);
  100. this.invokeListResizeNode = new Element("div", {"styles": this.css.invokeListResizeNode}).inject(this.invokeListNode);
  101. this.createListTitleNodes();
  102. this.invokeListAreaSccrollNode = new Element("div.invokeListAreaSccrollNode", {"styles": this.css.invokeListAreaSccrollNode}).inject(this.invokeListNode);
  103. this.invokeListAreaNode = new Element("div", {"styles": this.css.invokeListAreaNode}).inject(this.invokeListAreaSccrollNode);
  104. this.loadInvokeListResize();
  105. this.loadInvokeList();
  106. },
  107. createListTitleNodes: function (){
  108. this.invokeListTitleNode.setStyle("display", 'flex');
  109. this.titleActionArea = new Element("div", {
  110. styles: this.css.titleActionArea
  111. }).inject(this.invokeListTitleNode);
  112. this.moreAction = new Element("div", {
  113. styles: this.css.moreAction,
  114. title: this.lp.searchAndSort
  115. }).inject(this.titleActionArea);
  116. this.moreAction.addEvent("click", function(){
  117. var isHidden = this.toolbarNode.getStyle("display") === "none";
  118. this.toolbarNode.setStyle("display", isHidden ? "" : "none" );
  119. this.resizeNode();
  120. this.options.listToolbarExpanded = isHidden;
  121. this.setUd();
  122. }.bind(this));
  123. this.toolbarNode = new Element("div", {
  124. styles: this.css.toolbarNode
  125. }).inject(this.invokeListNode);
  126. if( this.options.listToolbarExpanded )this.toolbarNode.show();
  127. this.createSortNode();
  128. this.createSearchNode();
  129. },
  130. getUd: function ( callback ){
  131. MWF.UD.getDataJson(this.options.name, function (data){
  132. if( data ){
  133. this.options.sortKey = data.sortKey;
  134. this.options.listToolbarExpanded = data.listToolbarExpanded || false;
  135. }
  136. callback();
  137. }.bind(this));
  138. },
  139. setUd: function (){
  140. var data = {
  141. sortKey: this.options.sortKey,
  142. listToolbarExpanded: this.options.listToolbarExpanded
  143. };
  144. MWF.UD.putData(this.options.name, data);
  145. },
  146. openApp: function (){
  147. layout.openApplication(null, 'service.ServiceManager', {
  148. appId: 'service.ServiceManager'
  149. }, {
  150. "navi":1
  151. });
  152. },
  153. createElement: function(){
  154. var flag = true;
  155. this.itemArray.each(function(i){
  156. if( i.data.isNewInvoke ){
  157. flag = false;
  158. return;
  159. }
  160. });
  161. if( !flag ){
  162. this.notice(this.lp.duplicateNewNote, 'info');
  163. return;
  164. }
  165. if( this.currentListInvokeItem ){
  166. this.currentListInvokeItem.setStyles(this.css.listInvokeItem);
  167. }
  168. this.options.id = "";
  169. this.loadInvoke();
  170. },
  171. createSortNode: function(){
  172. this.itemSortArea = new Element("div.itemSortArea", {
  173. styles: this.css.itemSortArea
  174. }).inject(this.toolbarNode);
  175. this.itemSortSelect = new Element('select.itemSortSelect', {
  176. styles: this.css.itemSortSelect,
  177. events: {
  178. change: function(){
  179. this.options.sortKey = this.itemSortSelect[ this.itemSortSelect.selectedIndex ].value;
  180. this.setUd();
  181. this.loadInvokeList();
  182. }.bind(this)
  183. }
  184. }).inject(this.itemSortArea);
  185. new Element('option',{ 'text': this.lp.sorkKeyNote, 'value': "" }).inject(this.itemSortSelect);
  186. this.options.sortKeys.each(function (key){
  187. var opt = new Element('option',{ 'text': this.lp[key] + " " + this.lp.asc, 'value': key+"-asc" }).inject(this.itemSortSelect);
  188. if( this.options.sortKey === opt.get('value') )opt.set('selected', true);
  189. opt = new Element('option',{ 'text': this.lp[key] + " " + this.lp.desc, 'value': key+"-desc" }).inject(this.itemSortSelect);
  190. if( this.options.sortKey === opt.get('value') )opt.set('selected', true);
  191. }.bind(this));
  192. },
  193. createSearchNode: function (){
  194. this.searchNode = new Element("div.searchNode", {
  195. "styles": this.css.searchArea
  196. }).inject(this.toolbarNode);
  197. this.searchInput = new Element("input.searchInput", {
  198. "styles": this.css.searchInput,
  199. "placeholder": this.lp.searchPlacholder,
  200. "value": this.options.searchKey || ""
  201. }).inject(this.searchNode);
  202. this.searchButton = new Element("i", {
  203. "styles": this.css.searchButton
  204. }).inject(this.searchNode);
  205. this.searchCancelButton = new Element("i", {
  206. "styles": this.css.searchCancelButton
  207. }).inject(this.searchNode);
  208. this.searchInput.addEvents({
  209. focus: function(){
  210. this.searchNode.addClass("mainColor_border");
  211. this.searchButton.addClass("mainColor_color");
  212. }.bind(this),
  213. blur: function () {
  214. this.searchNode.removeClass("mainColor_border");
  215. this.searchButton.removeClass("mainColor_color");
  216. }.bind(this),
  217. keydown: function (e) {
  218. if( (e.keyCode || e.code) === 13 ){
  219. this.search();
  220. }
  221. }.bind(this),
  222. keyup: function (e){
  223. this.searchCancelButton.setStyle('display', this.searchInput.get('value') ? '' : 'none');
  224. }.bind(this)
  225. });
  226. this.searchCancelButton.addEvent("click", function (e) {
  227. this.searchInput.set("value", "");
  228. this.searchCancelButton.hide();
  229. this.search();
  230. }.bind(this));
  231. this.searchButton.addEvent("click", function (e) {
  232. this.search();
  233. }.bind(this));
  234. },
  235. checkSort: function (data){
  236. if( !!this.options.sortKey ){
  237. var sortKey = this.options.sortKey.split("-");
  238. var key = sortKey[0], isDesc = sortKey[1] === 'desc';
  239. data.sort(function (a, b){
  240. var av = a[key];
  241. var bv = b[key];
  242. if( typeOf(av) === 'string' && typeOf(bv) === 'string' ){
  243. var isLetterA = /^[a-zA-Z0-9]/.test(av);
  244. var isLetterB = /^[a-zA-Z0-9]/.test(bv);
  245. if (isLetterA && !isLetterB) return isDesc ? 1 : -1; // a是字母,b不是,a排在前面
  246. if (!isLetterA && isLetterB) return isDesc ? -1 : 1; // a不是字母,b是,b排在前面
  247. return isDesc ? bv.localeCompare(av) : av.localeCompare(bv);
  248. }
  249. return isDesc ? (bv - av) : (av - bv);
  250. }.bind(this));
  251. }
  252. },
  253. checkShow: function (i){
  254. if( this.options.searchKey ){
  255. var v = this.options.searchKey;
  256. if( i.data.name.contains(v) || (i.data.alias || "").contains(v) || i.data.id.contains(v) ){
  257. //i.node.setStyle("display", "");
  258. }else{
  259. i.node.setStyle("display", "none");
  260. }
  261. }
  262. },
  263. search: function (){
  264. var v = this.searchInput.get("value");
  265. this.options.searchKey = v;
  266. this.itemArray.each(function (i){
  267. if( !v ){
  268. i.node.setStyle("display", "");
  269. }else if( i.data.name.contains(v) || (i.data.alias || "").contains(v) || i.data.id.contains(v) ){
  270. i.node.setStyle("display", "");
  271. }else{
  272. i.node.setStyle("display", "none");
  273. }
  274. }.bind(this));
  275. },
  276. loadInvokeListResize: function(){
  277. // var size = this.propertyNode.getSize();
  278. // var position = this.propertyResizeBar.getPosition();
  279. this.invokeListResize = new Drag(this.invokeListResizeNode,{
  280. "snap": 1,
  281. "onStart": function(el, e){
  282. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  283. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  284. el.store("position", {"x": x, "y": y});
  285. var size = this.invokeListAreaSccrollNode.getSize();
  286. el.store("initialWidth", size.x);
  287. }.bind(this),
  288. "onDrag": function(el, e){
  289. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  290. // var y = e.event.y;
  291. var bodySize = this.content.getSize();
  292. var position = el.retrieve("position");
  293. var initialWidth = el.retrieve("initialWidth").toFloat();
  294. var dx = x.toFloat() - position.x.toFloat();
  295. var width = initialWidth+dx;
  296. if (width> bodySize.x/2) width = bodySize.x/2;
  297. if (width<40) width = 40;
  298. this.contentNode.setStyle("margin-left", width+1);
  299. this.invokeListNode.setStyle("width", width);
  300. }.bind(this)
  301. });
  302. },
  303. loadInvokeList: function() {
  304. if( this.currentListInvokeItem ){
  305. var d = this.currentListInvokeItem.retrieve('invoke');
  306. this.options.id = d.id;
  307. }
  308. if( this.itemArray && this.itemArray.length ){
  309. this.itemArray = this.itemArray.filter(function(i){
  310. if(!i.data.isNewInvoke)i.node.destroy();
  311. return i.data.isNewInvoke;
  312. });
  313. }else{
  314. this.itemArray = [];
  315. }
  316. this.actions.listInvoke(function (json) {
  317. this.checkSort(json.data);
  318. json.data.each(function(invoke){
  319. this.createListInvokeItem(invoke);
  320. }.bind(this));
  321. }.bind(this), null, false);
  322. },
  323. createListInvokeItem: function(invoke, isNew){
  324. var _self = this;
  325. var listInvokeItem = new Element("div", {"styles": this.css.listInvokeItem}).inject(this.invokeListAreaNode, (isNew) ? "top": "bottom");
  326. var listInvokeItemIcon = new Element("div", {"styles": this.css.listInvokeItemIcon}).inject(listInvokeItem);
  327. var listInvokeItemText = new Element("div", {"styles": this.css.listInvokeItemText, "text": (invoke.name) ? invoke.name+" ("+invoke.alias+")" : this.lp.newInvoke}).inject(listInvokeItem);
  328. listInvokeItem.store("invoke", invoke);
  329. listInvokeItem.addEvents({
  330. "click": function(e){_self.loadInvokeByData(this, e);},
  331. "mouseover": function(){if (_self.currentListInvokeItem!=this) this.setStyles(_self.css.listInvokeItem_over);},
  332. "mouseout": function(){if (_self.currentListInvokeItem!=this) this.setStyles(_self.css.listInvokeItem);}
  333. });
  334. if( invoke.id === this.options.id ){
  335. listInvokeItem.setStyles(this.css.listInvokeItem_current);
  336. this.currentListInvokeItem = listInvokeItem;
  337. }
  338. var itemObj = {
  339. node: listInvokeItem,
  340. data: invoke
  341. };
  342. this.itemArray.push(itemObj);
  343. this.checkShow(itemObj);
  344. this.listInvokeItemMove(listInvokeItem);
  345. },
  346. createInvokeListCopy: function(node){
  347. var copyNode = node.clone().inject(this.node);
  348. copyNode.position({
  349. "relativeTo": node,
  350. "position": "upperLeft",
  351. "edge": "upperLeft"
  352. });
  353. var size = copyNode.getSize();
  354. copyNode.setStyles({
  355. "width": ""+size.x+"px",
  356. "height": ""+size.y+"px",
  357. "z-index": 50001
  358. });
  359. return copyNode;
  360. },
  361. listDrinvokeer: function(dragging, inObj){
  362. var markNode = inObj.retrieve("markNode");
  363. if (!markNode){
  364. var size = inObj.getSize();
  365. markNode = new Element("div", {"styles": this.css.dragListItemMark}).inject(this.node);
  366. markNode.setStyles({
  367. "width": ""+size.x+"px",
  368. "height": ""+size.y+"px",
  369. "position": "absolute",
  370. "background-color": "#666",
  371. "z-index": 50000,
  372. "opacity": 0.3
  373. // "border": "2px solid #ffba00"
  374. });
  375. markNode.position({
  376. "relativeTo": inObj,
  377. "position": "upperLeft",
  378. "edge": "upperLeft"
  379. });
  380. var y = markNode.getStyle("top").toFloat()-1;
  381. var x = markNode.getStyle("left").toFloat()-2;
  382. markNode.setStyles({
  383. "left": ""+x+"px",
  384. "top": ""+y+"px"
  385. });
  386. inObj.store("markNode", markNode);
  387. }
  388. },
  389. listDragLeave: function(dragging, inObj){
  390. var markNode = inObj.retrieve("markNode");
  391. if (markNode) markNode.destroy();
  392. inObj.eliminate("markNode");
  393. },
  394. listInvokeItemMove: function(node){
  395. var iconNode = node.getFirst();
  396. iconNode.addEvent("mousedown", function(e){
  397. var invoke = node.retrieve("invoke");
  398. if (invoke.id!=this.invokeTab.showPage.invoke.data.id){
  399. var copyNode = this.createInvokeListCopy(node);
  400. var droppables = [this.designNode, this.propertyDomArea];
  401. var listItemDrag = new Drag.Move(copyNode, {
  402. "droppables": droppables,
  403. "onEnter": function(dragging, inObj){
  404. this.listDrinvokeer(dragging, inObj);
  405. }.bind(this),
  406. "onLeave": function(dragging, inObj){
  407. this.listDragLeave(dragging, inObj);
  408. }.bind(this),
  409. "onDrag": function(e){
  410. //nothing
  411. }.bind(this),
  412. "onDrop": function(dragging, inObj){
  413. if (inObj){
  414. //this.addIncludeInvoke(invoke);
  415. this.listDragLeave(dragging, inObj);
  416. copyNode.destroy();
  417. }else{
  418. copyNode.destroy();
  419. }
  420. }.bind(this),
  421. "onCancel": function(dragging){
  422. copyNode.destroy();
  423. }.bind(this)
  424. });
  425. listItemDrag.start(e);
  426. }
  427. }.bind(this));
  428. },
  429. addIncludeInvoke: function(invoke){
  430. var currentInvoke = this.invokeTab.showPage.invoke;
  431. if (currentInvoke.data.dependInvokeList.indexOf(invoke.name)==-1){
  432. currentInvoke.data.dependInvokeList.push(invoke.name);
  433. this.addIncludeToList(invoke.name);
  434. }
  435. },
  436. addIncludeToList: function(name){
  437. this.actions.getInvokeByName(name, function(json){
  438. var invoke = json.data;
  439. var includeInvokeItem = new Element("div", {"styles": this.css.includeInvokeItem}).inject(this.propertyIncludeListArea);
  440. var includeInvokeItemAction = new Element("div", {"styles": this.css.includeInvokeItemAction}).inject(includeInvokeItem);
  441. var includeInvokeItemText = new Element("div", {"styles": this.css.includeInvokeItemText}).inject(includeInvokeItem);
  442. includeInvokeItemText.set("text", invoke.name+" ("+invoke.alias+")");
  443. includeInvokeItem.store("invoke", invoke);
  444. var _self = this;
  445. includeInvokeItemAction.addEvent("click", function(){
  446. var node = this.getParent();
  447. var invoke = node.retrieve("invoke");
  448. if (invoke){
  449. _self.invokeTab.showPage.invoke.data.dependInvokeList.erase(invoke.name);
  450. }
  451. node.destroy();
  452. });
  453. }.bind(this), function(){
  454. this.invokeTab.showPage.invoke.data.dependInvokeList.erase(name);
  455. }.bind(this));
  456. },
  457. loadInvokeByData: function(node, e){
  458. var invoke = node.retrieve("invoke");
  459. var openNew = true;
  460. for (var i = 0; i<this.invokeTab.pages.length; i++){
  461. if (invoke.id==this.invokeTab.pages[i].invoke.data.id){
  462. this.invokeTab.pages[i].showTabIm();
  463. openNew = false;
  464. break;
  465. }
  466. }
  467. if (openNew){
  468. this.loadInvokeData(invoke.id, function(data){
  469. var invoke = new MWF.xApplication.service.InvokeDesigner.Invoke(this, data);
  470. invoke.load();
  471. }.bind(this), true);
  472. }
  473. //var _self = this;
  474. //var options = {
  475. // "onQueryLoad": function(){
  476. // this.actions = _self.actions;
  477. // this.options.id = invoke.id;
  478. // this.application = _self.application;
  479. // }
  480. //};
  481. //this.desktop.openApplication(e, "service.InvokeDesigner", options);
  482. },
  483. //loadContentNode------------------------------
  484. loadContentNode: function(toolbarCallback, contentCallback){
  485. this.contentToolbarNode = new Element("div#contentToolbarNode", {
  486. "styles": this.css.contentToolbarNode
  487. }).inject(this.contentNode);
  488. this.loadContentToolbar(toolbarCallback);
  489. this.editContentNode = new Element("div", {
  490. "styles": this.css.editContentNode
  491. }).inject(this.contentNode);
  492. this.loadEditContent(function(){
  493. // if (this.designDcoument) this.designDcoument.body.setStyles(this.css.designBody);
  494. if (this.designNode) this.designNode.setStyles(this.css.designNode);
  495. if (contentCallback) contentCallback();
  496. }.bind(this));
  497. },
  498. loadContentToolbar: function(callback){
  499. this.getFormToolbarHTML(function(toolbarNode){
  500. var spans = toolbarNode.getElements("span");
  501. spans.each(function(item, idx){
  502. var img = item.get("MWFButtonImage");
  503. if (img){
  504. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbar/"+img);
  505. }
  506. }.bind(this));
  507. $(toolbarNode).inject(this.contentToolbarNode);
  508. MWF.require("MWF.widget.Toolbar", function(){
  509. this.toolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "ProcessCategory"}, this);
  510. this.toolbar.load();
  511. var _self = this;
  512. this.styleSelectNode = toolbarNode.getElement("select[MWFnodetype='theme']");
  513. this.styleSelectNode.addEvent("change", function(){
  514. _self.changeEditorStyle(this);
  515. });
  516. this.fontsizeSelectNode = toolbarNode.getElement("select[MWFnodetype='fontSize']");
  517. this.fontsizeSelectNode.addEvent("change", function(){
  518. _self.changeFontSize(this);
  519. });
  520. this.editorSelectNode = toolbarNode.getElement("select[MWFnodetype='editor']");
  521. this.editorSelectNode.addEvent("change", function(){
  522. _self.changeEditor(this);
  523. });
  524. this.monacoStyleSelectNode = toolbarNode.getElement("select[MWFnodetype='monaco-theme']");
  525. this.monacoStyleSelectNode.addEvent("change", function(){
  526. _self.changeEditorStyle(this);
  527. });
  528. if (callback) callback();
  529. }.bind(this));
  530. }.bind(this));
  531. },
  532. changeEditor: function(node){
  533. var idx = node.selectedIndex;
  534. var value = node.options[idx].value;
  535. if (!MWF.editorData){
  536. MWF.editorData = {
  537. "javascriptEditor": {
  538. "monaco_theme": "vs",
  539. "theme": "tomorrow",
  540. "fontSize" : "12px"
  541. }
  542. };
  543. }
  544. MWF.editorData.javascriptEditor["editor"] = value;
  545. MWF.UD.putData("editor", MWF.editorData);
  546. this.invokeTab.pages.each(function(page){
  547. var editor = page.invoke.editor;
  548. if (editor) editor.changeEditor(value);
  549. }.bind(this));
  550. if (value=="ace"){
  551. this.monacoStyleSelectNode.hide();
  552. this.styleSelectNode.show();
  553. }else{
  554. this.monacoStyleSelectNode.show();
  555. this.styleSelectNode.hide();
  556. }
  557. },
  558. changeFontSize: function(node){
  559. var idx = node.selectedIndex;
  560. var value = node.options[idx].value;
  561. //var editorData = null;
  562. this.invokeTab.pages.each(function(page){
  563. //if (!editorData) editorData = page.invoke.editor.editorData;
  564. var editor = page.invoke.editor;
  565. if (editor) editor.setFontSize(value);
  566. }.bind(this));
  567. //if (!editorData) editorData = MWF.editorData;
  568. //editorData.javainvokeEditor.theme = value;
  569. if (!MWF.editorData){
  570. MWF.editorData = {
  571. "javascriptEditor": {
  572. "monaco_theme": "vs",
  573. "theme": "tomorrow",
  574. "fontSize" : "12px"
  575. }
  576. };
  577. }
  578. MWF.editorData.javascriptEditor["fontSize"] = value;
  579. MWF.UD.putData("editor", MWF.editorData);
  580. },
  581. changeEditorStyle: function(node){
  582. var idx = node.selectedIndex;
  583. var value = node.options[idx].value;
  584. //var editorData = null;
  585. this.invokeTab.pages.each(function(page){
  586. //if (!editorData) editorData = page.script.editor.editorData;
  587. var editor = page.invoke.editor;
  588. if (editor) editor.setTheme(value);
  589. }.bind(this));
  590. //if (!editorData) editorData = MWF.editorData;
  591. //editorData.javascriptEditor.theme = value;
  592. if (!MWF.editorData){
  593. MWF.editorData = {
  594. "javascriptEditor": {
  595. "monaco_theme": "vs",
  596. "theme": "tomorrow",
  597. "fontSize" : "12px"
  598. }
  599. };
  600. }
  601. if (MWF.editorData.javascriptEditor.editor === "monaco"){
  602. MWF.editorData.javascriptEditor.monaco_theme = value;
  603. }else{
  604. MWF.editorData.javascriptEditor.theme = value;
  605. }
  606. MWF.UD.putData("editor", MWF.editorData);
  607. },
  608. getFormToolbarHTML: function(callback){
  609. var toolbarUrl = this.path+this.options.style+"/toolbars.html";
  610. MWF.getRequestText(toolbarUrl, function(responseText, responseXML){
  611. var htmlString = responseText;
  612. htmlString = o2.bindJson(htmlString, {"lp": this.lp.formToolbar});
  613. var temp = new Element('div').set('html', htmlString);
  614. if (callback) callback( temp.childNodes[0] );
  615. }.bind(this));
  616. },
  617. maxOrReturnEditor: function(){
  618. if (!this.isMax){
  619. this.designNode.inject(this.node);
  620. this.designNode.setStyles({
  621. "position": "absolute",
  622. "width": "100%",
  623. "height": "100%",
  624. "top": "0px",
  625. "margin": "0px",
  626. "left": "0px"
  627. });
  628. this.invokeTab.pages.each(function(page){
  629. page.invoke.setAreaNodeSize();
  630. });
  631. this.isMax = true;
  632. }else{
  633. this.isMax = false;
  634. this.designNode.inject(this.editContentNode);
  635. this.designNode.setStyles(this.css.designNode);
  636. this.designNode.setStyles({
  637. "position": "static"
  638. });
  639. this.resizeNode();
  640. this.invokeTab.pages.each(function(page){
  641. page.invoke.setAreaNodeSize();
  642. });
  643. }
  644. },
  645. loadEditContent: function(callback){
  646. this.designNode = new Element("div", {
  647. "styles": this.css.designNode
  648. }).inject(this.editContentNode);
  649. MWF.require("MWF.widget.Tab", function(){
  650. this.invokeTab = new MWF.widget.Tab(this.designNode, {"style": "script"});
  651. this.invokeTab.load();
  652. }.bind(this), false);
  653. //MWF.require("MWF.widget.ScrollBar", function(){
  654. // new MWF.widget.ScrollBar(this.designNode, {"distance": 100});
  655. //}.bind(this));
  656. },
  657. //loadProperty------------------------
  658. loadProperty: function(){
  659. this.propertyTitleNode = new Element("div", {
  660. "styles": this.css.propertyTitleNode,
  661. "text": MWF.SRVID.LP.property
  662. }).inject(this.propertyNode);
  663. this.propertyResizeBar = new Element("div", {
  664. "styles": this.css.propertyResizeBar
  665. }).inject(this.propertyNode);
  666. this.loadPropertyResize();
  667. this.propertyContentNode = new Element("div", {
  668. "styles": this.css.propertyContentNode
  669. }).inject(this.propertyNode);
  670. //this.propertyDomArea = new Element("div", {
  671. // "styles": this.css.propertyDomArea
  672. //}).inject(this.propertyContentNode);
  673. //this.propertyDomPercent = 0.3;
  674. //this.propertyContentResizeNode = new Element("div", {
  675. // "styles": this.css.propertyContentResizeNode
  676. //}).inject(this.propertyContentNode);
  677. this.propertyContentArea = new Element("div", {
  678. "styles": this.css.propertyContentArea
  679. }).inject(this.propertyContentNode);
  680. //this.loadPropertyContentResize();
  681. this.setPropertyContent();
  682. //this.setIncludeNode();
  683. },
  684. setIncludeNode: function(){
  685. this.includeTitleNode = new Element("div", {"styles": this.css.includeTitleNode}).inject(this.propertyDomArea);
  686. this.includeTitleActionNode = new Element("div", {"styles": this.css.includeTitleActionNode}).inject(this.includeTitleNode);
  687. this.includeTitleTextNode = new Element("div", {"styles": this.css.includeTitleTextNode, "text": this.lp.include}).inject(this.includeTitleNode);
  688. this.includeTitleActionNode.addEvent("click", function(){
  689. this.addInclude();
  690. }.bind(this));
  691. this.propertyIncludeListArea = new Element("div", {
  692. "styles": {"overflow": "hidden"}
  693. }).inject(this.propertyDomArea);
  694. },
  695. addInclude: function(){
  696. },
  697. setPropertyContent: function(){
  698. var node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.id+":"}).inject(this.propertyContentArea);
  699. this.propertyIdNode = new Element("div", {"styles": this.css.propertyTextNode, "text": ""}).inject(this.propertyContentArea);
  700. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.name+":"}).inject(this.propertyContentArea);
  701. this.propertyNameNode = new Element("input", {"styles": this.css.propertyInputNode, "value": ""}).inject(this.propertyContentArea);
  702. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.alias+":"}).inject(this.propertyContentArea);
  703. this.propertyAliasNode = new Element("input", {"styles": this.css.propertyInputNode, "value": ""}).inject(this.propertyContentArea);
  704. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.remoteAddrRegex+":"}).inject(this.propertyContentArea);
  705. this.propertyRemoteAddrRegexNode = new Element("input", {"styles": this.css.propertyInputNode, "value": ""}).inject(this.propertyContentArea);
  706. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.lastStartTime+":"}).inject(this.propertyContentArea);
  707. this.propertyLastStartTimeNode = new Element("div", {"styles": this.css.propertyTextNode, "value": ""}).inject(this.propertyContentArea);
  708. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.lastEndTime+":"}).inject(this.propertyContentArea);
  709. this.propertyLastEndTimeNode = new Element("div", {"styles": this.css.propertyTextNode, "value": ""}).inject(this.propertyContentArea);
  710. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.description+":"}).inject(this.propertyContentArea);
  711. this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.propertyInputAreaNode, "value": ""}).inject(this.propertyContentArea);
  712. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.enableToken+":"}).inject(this.propertyContentArea);
  713. this.propertyEnableTokenNode = new Element("select", {"styles": this.css.propertySelectNode }).inject(this.propertyContentArea);
  714. new Element("option" , { "value" : "true", "text" : this.lp.true }).inject(this.propertyEnableTokenNode);
  715. new Element("option" , { "value" : "false", "text" : this.lp.false }).inject(this.propertyEnableTokenNode);
  716. new Element("div", {"styles": this.css.propertyTextNode, "html": this.lp.enableTokenInfo}).setStyles({
  717. "word-break":"break-all",
  718. "height" : "auto",
  719. "line-height": "18px",
  720. "margin-top": "10px",
  721. "color": "#999999"
  722. }).inject(this.propertyContentArea);
  723. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.executorList+":"}).inject(this.propertyContentArea);
  724. this.propertyExecutorListNode = new Element("div", {"styles": this.css.propertyOrgNode}).inject(this.propertyContentArea);
  725. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  726. this.executorListSelector = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(this.propertyExecutorListNode, this, {
  727. "types": ['person', 'unit', 'group', 'role'],
  728. "names": [],
  729. "onChange": function (ids) {
  730. if(this.invokeTab)this.invokeTab.showPage.invoke.data.executorList = ids.map(function(id){
  731. return id.data.distinguishedName;
  732. });
  733. }.bind(this)
  734. });
  735. }.bind(this));
  736. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.isEnable+":"}).inject(this.propertyContentArea);
  737. this.propertyEnableNode = new Element("select", {"styles": this.css.propertySelectNode }).inject(this.propertyContentArea);
  738. new Element("option" , { "value" : "true", "text" : this.lp.true }).inject(this.propertyEnableNode);
  739. new Element("option" , { "value" : "false", "text" : this.lp.false }).inject(this.propertyEnableNode);
  740. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.invokeUri+":"}).inject(this.propertyContentArea);
  741. this.propertyInvokeUriNode = new Element("div", {"styles": this.css.propertyTextNode, "text": ""}).inject(this.propertyContentArea);
  742. this.propertyInvokeUriNode.setStyles({
  743. "word-break":"break-all",
  744. "height" : "auto"
  745. });
  746. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.invokeMethod+":"}).inject(this.propertyContentArea);
  747. this.propertyInvokeMethodNode = new Element("div", {"styles": this.css.propertyTextNode, "text": "POST"}).inject(this.propertyContentArea);
  748. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.invokeHead+":"}).inject(this.propertyContentArea);
  749. this.propertyInvokeHeadTextNode = new Element("div", {"styles": this.css.propertyTextNode, "text": "Content-Type:application/json; charset=utf-8"}).inject(this.propertyContentArea);
  750. this.propertyInvokeHeadTextNode.setStyles({
  751. "height": "auto"
  752. })
  753. node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.debugger+":"}).inject(this.propertyContentArea);
  754. // new Element("div", {"styles": this.css.propertyTextNode, "text": this.lp.requireArguments}).setStyles({
  755. // "word-break":"break-all",
  756. // "height" : "auto",
  757. // "line-height": "18px",
  758. // "margin-top": "10px",
  759. // "color": "#999999"
  760. // }).inject(this.propertyContentArea);
  761. // this.propertyRequireBodyNode = new Element("textarea", {
  762. // "styles": this.css.propertyInputAreaNode,
  763. // "value": "",
  764. // "events": {
  765. // change : function () {
  766. // debugger;
  767. // if(this.currentPage){
  768. // this.currentPage.requireBody = this.propertyRequireBodyNode.get("value");
  769. // }
  770. // }.bind(this)
  771. // }
  772. // }).inject(this.propertyContentArea);
  773. var propertyRequireBodyScriptWraper = new Element("div").inject(this.propertyContentArea);
  774. MWF.require("MWF.widget.ScriptArea", null, false);
  775. this.propertyRequireBodyScriptArea = new MWF.widget.ScriptArea(propertyRequireBodyScriptWraper, {
  776. "title": this.lp.requireArguments,
  777. "isload" : true,
  778. "isbind" : false,
  779. "forceType": "ace",
  780. "maxObj": this.content,
  781. "onChange": function(){
  782. if(this.currentPage){
  783. this.currentPage.requireBody = this.propertyRequireBodyScriptArea.toJson().code;
  784. }
  785. }.bind(this),
  786. "onPostLoad": function () {
  787. if(this.jsEditor)this.jsEditor.setFontSize( "12px" );
  788. },
  789. "style": "formula"
  790. });
  791. this.propertyRequireBodyScriptArea.load({code: ""});
  792. node = new Element("div", {"styles": this.css.propertyTextNode, "text": this.lp.tokenSetting+":"}).inject(this.propertyContentArea);
  793. this.propertyTokenNode = new Element("select", {"styles": this.css.propertySelectNode }).inject(this.propertyContentArea);
  794. o2.Actions.load("x_program_center").ConfigAction.getToken(function(json){
  795. debugger;
  796. json.data.ssos.each(function(sso){
  797. if( sso.enable ){
  798. new Element("option" , { "value" : sso.key, "text" : sso.client }).inject(this.propertyTokenNode);
  799. }
  800. }.bind(this));
  801. }.bind(this), function(){
  802. return true;
  803. });
  804. new Element("div", {"styles": this.css.propertyTextNode, "text": this.lp.runResult}).setStyles({
  805. "word-break":"break-all",
  806. "height" : "auto",
  807. "line-height": "18px",
  808. "margin-top": "10px",
  809. "color": "#999999"
  810. }).inject(this.propertyContentArea);
  811. this.propertyRunResultNode = new Element("div", {"styles": this.css.propertyTextNode}).inject(this.propertyContentArea);
  812. this.propertyRunResultNode.set("style", "white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; height: auto; overflow:auto; margin-left:10px;");
  813. var div = new Element("div", {"styles": this.css.propertyTextNode, "text": ""}).setStyles({
  814. "margin-top": "10px"
  815. }).inject(this.propertyContentArea);
  816. this.propertyExecuteButton = new Element("input", { type : "button", styles : this.css.propertyButton, "value": this.lp.run }).inject(div);
  817. this.propertyExecuteButton.addEvent("click", function(){
  818. var alias = this.propertyExecuteButton.retrieve("alias");
  819. var name = this.propertyExecuteButton.retrieve("name");
  820. var id = this.propertyExecuteButton.retrieve("id");
  821. //var body = this.propertyRequireBodyNode.get("value");
  822. var body = this.propertyRequireBodyScriptArea.toJson().code;
  823. debugger;
  824. var enableToken = false;
  825. this.propertyEnableTokenNode.getElements("option").each(function(el){
  826. if( el.selected )enableToken = el.get("value") === "true";
  827. });
  828. if( id ){
  829. var address = o2.Actions.getHost("x_program_center");
  830. var serviceName = o2.Actions.load("x_program_center").InvokeAction.action.serviceName;
  831. var uri, url;
  832. if( enableToken ){
  833. uri = o2.Actions.load("x_program_center").InvokeAction.action.actions.executeToken.uri;
  834. var client, key, token;
  835. this.propertyTokenNode.getElements("option").each(function(el){
  836. if( el.selected ){
  837. client = el.get("text");
  838. key = el.get("value");
  839. }
  840. });
  841. if( client && key ){
  842. o2.Actions.load("x_program_center").InvokeAction.token({ client : client }, function(json){
  843. token = json.data.value;
  844. }, null, false);
  845. url = uri.replace("{flag}", alias || name || id).replace("{client}", client).replace("{token}", token);
  846. }else{
  847. this.notice( this.lp.noSSOSetting, "error");
  848. return;
  849. }
  850. }else{
  851. uri = o2.Actions.load("x_program_center").InvokeAction.action.actions.execute.uri;
  852. url = uri.replace("{flag}", alias || name || id);
  853. }
  854. url = o2.filterUrl( address + "/" + serviceName + url );
  855. var res = new Request({
  856. url: url,
  857. async: false,
  858. method: "POST",
  859. withCredentials: true,
  860. onSuccess: function(responseText, responseXML){
  861. var result;
  862. try{
  863. var json = JSON.parse( responseText );
  864. result = JSON.stringify(json, null, 4);
  865. }catch (e) {
  866. result = responseText;
  867. }
  868. if(this.currentPage){
  869. this.currentPage.executeResult = result;
  870. }
  871. this.propertyRunResultNode.set("text",result);
  872. this.notice( this.lp.runSuccess, "success");
  873. }.bind(this),
  874. onFailure: function(xhr){
  875. var result;
  876. try{
  877. result = JSON.stringify(xhr.responseText, null, 4);
  878. }catch (e) {
  879. result = xhr.responseText;
  880. }
  881. if(this.currentPage){
  882. this.currentPage.executeResult = result;
  883. }
  884. this.propertyRunResultNode.set("text",result);
  885. }.bind(this)
  886. });
  887. res.setHeader("Content-Type", "application/json; charset=utf-8");
  888. res.setHeader("Accept", "text/html,application/json,*/*");
  889. res.setHeader("Accept-Language", o2.languageName);
  890. res.send( body );
  891. }
  892. // if( id )o2.Actions.load("x_program_center").InvokeAction.execute( alias || name || id, bodyJson || body, function (json) {
  893. // var result;
  894. // try{
  895. // result = JSON.stringify(json, null, 4);
  896. // }catch (e) {
  897. // result = json;
  898. // }
  899. // if(this.currentPage){
  900. // this.currentPage.executeResult = result;
  901. // }
  902. // this.propertyRunResultNode.set("html",result);
  903. //
  904. // this.notice( this.lp.runSuccess, "success");
  905. // }.bind(this), function (xhr) {
  906. // var result;
  907. // try{
  908. // result = JSON.stringify(xhr.responseText, null, 4);
  909. // }catch (e) {
  910. // result = xhr.responseText;
  911. // }
  912. // if(this.currentPage){
  913. // this.currentPage.executeResult = result;
  914. // }
  915. // this.propertyRunResultNode.set("html",result);
  916. // }.bind(this));
  917. }.bind(this));
  918. this.propertyExecuteButton.setStyle("margin","0px");
  919. this.propertyOpenLogViewer = new Element("input", { type : "button", styles : this.css.propertyButton, "value": this.lp.openLogViewer }).inject(div);
  920. this.propertyOpenLogViewer.addEvent("click", function(){
  921. layout.openApplication(null, "LogViewer");
  922. }.bind(this));
  923. },
  924. loadPropertyResize: function(){
  925. // var size = this.propertyNode.getSize();
  926. // var position = this.propertyResizeBar.getPosition();
  927. this.propertyResize = new Drag(this.propertyResizeBar,{
  928. "snap": 1,
  929. "onStart": function(el, e){
  930. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  931. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  932. el.store("position", {"x": x, "y": y});
  933. var size = this.propertyNode.getSize();
  934. el.store("initialWidth", size.x);
  935. }.bind(this),
  936. "onDrag": function(el, e){
  937. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  938. // var y = e.event.y;
  939. var bodySize = this.content.getSize();
  940. var position = el.retrieve("position");
  941. var initialWidth = el.retrieve("initialWidth").toFloat();
  942. var dx = position.x.toFloat()-x.toFloat();
  943. var width = initialWidth+dx;
  944. if (width> bodySize.x/2) width = bodySize.x/2;
  945. if (width<40) width = 40;
  946. this.contentNode.setStyle("margin-right", width+1);
  947. this.propertyNode.setStyle("width", width);
  948. }.bind(this)
  949. });
  950. },
  951. loadPropertyContentResize: function(){
  952. this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
  953. "snap": 1,
  954. "onStart": function(el, e){
  955. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  956. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  957. el.store("position", {"x": x, "y": y});
  958. var size = this.propertyDomArea.getSize();
  959. el.store("initialHeight", size.y);
  960. }.bind(this),
  961. "onDrag": function(el, e){
  962. var size = this.propertyContentNode.getSize();
  963. // var x = e.event.x;
  964. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  965. var position = el.retrieve("position");
  966. var dy = y.toFloat()-position.y.toFloat();
  967. var initialHeight = el.retrieve("initialHeight").toFloat();
  968. var height = initialHeight+dy;
  969. if (height<40) height = 40;
  970. if (height> size.y-40) height = size.y-40;
  971. this.propertyDomPercent = height/size.y;
  972. this.setPropertyContentResize();
  973. }.bind(this)
  974. });
  975. },
  976. setPropertyContentResize: function(){
  977. var size = this.propertyContentNode.getSize();
  978. //var resizeNodeSize = this.propertyContentResizeNode.getSize();
  979. //var height = size.y-resizeNodeSize.y;
  980. //var domHeight = this.propertyDomPercent*height;
  981. //var contentHeight = height-domHeight;
  982. //this.propertyDomArea.setStyle("height", ""+domHeight+"px");
  983. //this.propertyContentArea.setStyle("height", ""+contentHeight+"px");
  984. this.propertyContentArea.setStyle("height", ""+size.y+"px");
  985. },
  986. //resizeNode------------------------------------------------
  987. resizeNode: function(){
  988. if (!this.isMax){
  989. var nodeSize = this.node.getSize();
  990. this.contentNode.setStyle("height", ""+nodeSize.y+"px");
  991. this.propertyNode.setStyle("height", ""+nodeSize.y+"px");
  992. var contentToolbarMarginTop = this.contentToolbarNode.getStyle("margin-top").toFloat();
  993. var contentToolbarMarginBottom = this.contentToolbarNode.getStyle("margin-bottom").toFloat();
  994. var allContentToolberSize = this.contentToolbarNode.getComputedSize();
  995. var y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom;
  996. this.editContentNode.setStyle("height", ""+y+"px");
  997. if (this.designNode){
  998. var designMarginTop = this.designNode.getStyle("margin-top").toFloat();
  999. var designMarginBottom = this.designNode.getStyle("margin-bottom").toFloat();
  1000. y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom - designMarginTop - designMarginBottom;
  1001. this.designNode.setStyle("height", ""+y+"px");
  1002. }
  1003. titleSize = this.propertyTitleNode.getSize();
  1004. titleMarginTop = this.propertyTitleNode.getStyle("margin-top").toFloat();
  1005. titleMarginBottom = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
  1006. titlePaddingTop = this.propertyTitleNode.getStyle("padding-top").toFloat();
  1007. titlePaddingBottom = this.propertyTitleNode.getStyle("padding-bottom").toFloat();
  1008. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  1009. y = nodeSize.y-y;
  1010. this.propertyContentNode.setStyle("height", ""+y+"px");
  1011. this.propertyResizeBar.setStyle("height", ""+y+"px");
  1012. this.setPropertyContentResize();
  1013. titleSize = this.invokeListTitleNode.getSize();
  1014. titleMarginTop = this.invokeListTitleNode.getStyle("margin-top").toFloat();
  1015. titleMarginBottom = this.invokeListTitleNode.getStyle("margin-bottom").toFloat();
  1016. titlePaddingTop = this.invokeListTitleNode.getStyle("padding-top").toFloat();
  1017. titlePaddingBottom = this.invokeListTitleNode.getStyle("padding-bottom").toFloat();
  1018. nodeMarginTop = this.invokeListAreaSccrollNode.getStyle("margin-top").toFloat();
  1019. nodeMarginBottom = this.invokeListAreaSccrollNode.getStyle("margin-bottom").toFloat();
  1020. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;
  1021. y = nodeSize.y-y;
  1022. var leftToolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {x:0,y:0};
  1023. this.invokeListAreaSccrollNode.setStyle("height", ""+(y-leftToolbarSize.y)+"px");
  1024. this.invokeListResizeNode.setStyle("height", ""+y+"px");
  1025. }
  1026. },
  1027. //loadForm------------------------------------------
  1028. loadInvoke: function(){
  1029. //this.invokeTab.addTab(node, title);
  1030. this.getInvokeData(this.options.id, function(data){
  1031. this.invoke = new MWF.xApplication.service.InvokeDesigner.Invoke(this, data);
  1032. this.invoke.load();
  1033. if (this.status){
  1034. if (this.status.openInvokes){
  1035. this.status.openInvokes.each(function(id){
  1036. this.loadInvokeData(id, function(data){
  1037. var showTab = true;
  1038. if (this.status.currentId){
  1039. if (this.status.currentId!=data.id) showTab = false;
  1040. }
  1041. var invoke = new MWF.xApplication.service.InvokeDesigner.Invoke(this, data, {"showTab": showTab});
  1042. invoke.load();
  1043. }.bind(this), true);
  1044. }.bind(this));
  1045. this.status.openInvokes = [];
  1046. }
  1047. }
  1048. //if (!this.invokeHelpMenu){
  1049. // MWF.require("MWF.widget.ScriptHelp", function(){
  1050. // this.invokeHelpMenu = new MWF.widget.ScriptHelp($("MWFScriptAutoCode"), this.invoke.editor);
  1051. // this.invokeHelpMenu.getEditor = function(){
  1052. // if (this.invokeTab.showPage) return this.invokeTab.showPage.invoke.editor.editor;
  1053. // return null;
  1054. // }.bind(this)
  1055. // }.bind(this));
  1056. //}
  1057. }.bind(this));
  1058. },
  1059. getInvokeData: function(id, callback){
  1060. if (!id){
  1061. this.loadNewInvokeData(callback);
  1062. }else{
  1063. this.loadInvokeData(id, callback);
  1064. }
  1065. },
  1066. loadNewInvokeData: function(callback){
  1067. MWF.Actions.get("x_cms_assemble_control").getUUID(function(id){
  1068. var data = {
  1069. "name": "",
  1070. "id": id,
  1071. "alias": "",
  1072. "description": "",
  1073. //"language": "javascript",
  1074. //"dependInvokeList": [],
  1075. "isNewInvoke": true,
  1076. "text": "",
  1077. "enableToken" : true,
  1078. "enable" : true,
  1079. "remoteAddrRegex" : "",
  1080. "lastStartTime" : "",
  1081. "lastEndTime" : ""
  1082. };
  1083. this.createListInvokeItem(data, true);
  1084. if (callback) callback(data);
  1085. }.bind(this))
  1086. },
  1087. loadInvokeData: function(id, callback, notSetTile){
  1088. this.actions.getInvoke(id, function(json){
  1089. if (json){
  1090. var data = json.data;
  1091. if (!notSetTile){
  1092. this.setTitle(this.options.appTitle + "-"+data.name);
  1093. if(this.taskitem)this.taskitem.setText(this.options.appTitle + "-"+data.name);
  1094. this.options.appTitle = this.options.appTitle + "-"+data.name;
  1095. }
  1096. if (callback) callback(data);
  1097. }
  1098. }.bind(this));
  1099. },
  1100. saveInvoke: function(){
  1101. if (this.invokeTab.showPage){
  1102. var invoke = this.invokeTab.showPage.invoke;
  1103. invoke.save(function(){
  1104. if (invoke==this.invoke){
  1105. var name = invoke.data.name;
  1106. this.setTitle(MWF.SRVID.LP.title + "-"+name);
  1107. this.options.desktopReload = true;
  1108. this.options.id = invoke.data.id;
  1109. }
  1110. }.bind(this));
  1111. }
  1112. },
  1113. saveDictionaryAs: function(){
  1114. this.dictionary.saveAs();
  1115. },
  1116. dictionaryExplode: function(){
  1117. this.dictionary.explode();
  1118. },
  1119. dictionaryImplode: function(){
  1120. this.dictionary.implode();
  1121. },
  1122. recordStatus: function(){
  1123. if (this.invokeTab){
  1124. var openInvokes = [];
  1125. this.invokeTab.pages.each(function(page){
  1126. if (page.invoke.data.id!=this.options.id) openInvokes.push(page.invoke.data.id);
  1127. }.bind(this));
  1128. var currentId = this.invokeTab.showPage.invoke.data.id;
  1129. var status = {
  1130. "id": this.options.id,
  1131. "openInvokes": openInvokes,
  1132. "currentId": currentId
  1133. };
  1134. return status;
  1135. }
  1136. return {"id": this.options.id};
  1137. }
  1138. });